Jump to content

Pass by value vs pass by reference


Sturmkrahe

Recommended Posts

I'm pretty bad with programming terminology, so I'm going to state this as plainly as possible.

 

What I'm trying to do is set up a Papyrus script to turn an NPC into the player character (or vice versa), using something like the following:

Event OnEffectStart(Actor hitActor, Actor casterActor)
	hitActor = casterActor
EndEvent

The issue (I believe) is that this just sets "hitActor" to point at "casterActor", instead of overriding the actual object.

I know there are probably some issues with trying to do it this way, but the only other way I can think of achieving the desired effect is by manually copying everything from one actor to another using SetAV().

It's discussed somewhat further here, but nobody goes into detail about possible work-arounds.

 

Thanks for the help.

Edited by Sturmkrahe
Link to comment
Share on other sites

Is it your intention to switch places with the other actor, or to turn that actor into a duplicate of the player that is computer controlled or something else?

I will help if I can, but I need more information about what you're trying to achieve before I know if I can help.

Link to comment
Share on other sites

Is it your intention to switch places with the other actor, or to turn that actor into a duplicate of the player that is computer controlled or something else?

I will help if I can, but I need more information about what you're trying to achieve before I know if I can help.

Ultimately, I'd like the information of original player Actor to be temporarily stored, then the player will take on the Actor information of the target, hiding or disabling the original target and putting the new player-controlled copy in their place. And then eventually undoing that process. I was thinking something along the lines of a "possession" spell.

 

As far as I can tell, after some research and experimentation, Papyrus doesn't give the direct access to Actor data that would be needed to accomplish something like that. I'll probably end up taking the manual route with getAV and setAV, along with whatever else I need for character appearance and inventory.

Link to comment
Share on other sites

You could try something like This

 

Eck. :D

Sadly, SetPlayerControls (misleadingly) only provides movement control, and nothing else.

That's a shame. :(

Then I guess you're going to have to do it manually unless you can use SetPlayerControls followed by EnablePlayerControls to enable more than just movement.

Link to comment
Share on other sites

Probably what you want to do is determine the race of the target and then change the player's race to the same. If you do it with creatures, you will have a problem with the camera POV being at their feet height iirc.

 

Look at Master Shape Shifter mod.

 

TUTORIAL.

 

Edit: fixed a silly typo.

Edited by steve40
Link to comment
Share on other sites

Probably what you want to do is determine the race of the target and then change the player's race to the same. If you do it with creatures, you will have a problem with the camera POV being at their feed height iirc.

 

Look at Master Shape Shifter mod.

 

TUTORIAL.

 

Thanks! That will be quite helpful if I decide to let the player possess more than humanoids.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...