SetPlayerControls and Papyrus

Post » Mon Jun 18, 2012 11:43 pm

Hello all, I have been working on a mod, but have been having problems with the method SetPlayerControls. It is a method of the Actor class, but doesn't seem to work as it is supposed to. I may be doing it completely wrong, but my script seems to work fine. Heres my script, it is attached to a magic effect:

criptname PossessionScript extends ActiveMagicEffectEVENT OnEffectStart(Actor Target, Actor Caster)  if Caster.GetPlayerControls()   Caster.SetPlayerControls(false)   Target.SetPlayerControls(true)  endIfENDEVENTEvent OnEffectFinish(Actor Target, Actor Caster)  if Target.GetPlayerControls()   Target.SetPlayerControls(false)   Caster.SetPlayerControls(true)  endIfENDEVENT

I've tried things liek disabling the AI of the target and many other things, but it still won't work. It just freezes the target, and makes the player only be able to look up/down, cast, sheathe/unsheathe and go to the tab menu. Anyone have an idea why this isn't working?


Also another question, another way I could possible do this is through the Console Command TC. Is there anyway to call console commands in a Papyrus script? Also, I heard that the console commands are papyrus scripts, if that is the case, where can I look up the source of them, as I would like to know how they made TC work as it does. Thank you.
User avatar
Michelle Chau
 
Posts: 3308
Joined: Sat Aug 26, 2006 4:24 am

Post » Mon Jun 18, 2012 11:16 pm

Also, I heard that the console commands are papyrus scripts, if that is the case, where can I look up the source of them, as I would like to know how they made TC work as it does. Thank you.
Sorry, but whoever told you that is wrong. Some console functions have an equivalent Papyrus function, but many don't.

Is there an example of http://www.creationkit.com/SetPlayerControls_-_Actor being used in the vanilla game that you could look at, perhaps?

Cipscis
User avatar
Rebecca Clare Smith
 
Posts: 3508
Joined: Fri Aug 04, 2006 4:13 pm

Post » Tue Jun 19, 2012 12:44 am

I have looked, but I have found nothing that uses it so far. I checked the Dream quest, it doesn't use it. I checked the quest where Brelyna transforms you, also doesn't use it. Is there a way I can search the text in all of the papyrus files? And can I call console commands using Papyrus? Thanks.
User avatar
Blessed DIVA
 
Posts: 3408
Joined: Thu Jul 13, 2006 12:09 am

Post » Tue Jun 19, 2012 4:11 am

Unless a console command has a Papyrus equivalent, it can't be used in Papyrus.

I've been using http://gnuwin32.sourceforge.net/packages/grep.htm to search in the Papyrus source files. I don't believe there is a way to use the Creation Kit or any of its related utilities to do that.

Cipscis
User avatar
Pants
 
Posts: 3440
Joined: Tue Jun 27, 2006 4:34 am

Post » Tue Jun 19, 2012 12:50 am



http://www.creationkit.com/DisablePlayerControls_-_Game



http://www.creationkit.com/EnablePlayerControls_-_Game

User avatar
kristy dunn
 
Posts: 3410
Joined: Thu Mar 01, 2007 2:08 am

Post » Mon Jun 18, 2012 11:33 pm

I just finished searching, I only came up with one file, and the method is there, but the line is commented out. This method is not used in a script in the game. Maybe it really doesn't work. Any other ideas?

The code is interesting, I'll try it later.

;Game.GetPlayer().PlaceAtMe(Alias_PlayerClone.GetReference(),1,True);Actor Clone = Alias_PlayerClone.GetActorReference() as Actor;Alias_PlayerClone.GetActorReference().SetPlayerControls(true);Clone.SetPlayerControls(True);Game.GetPlayer().SetPlayerControls(False);Game.GetPlayer().EnableAI(False);Game.SetCameraTarget(Clone)
User avatar
Oscar Vazquez
 
Posts: 3418
Joined: Sun Sep 30, 2007 12:08 pm

Post » Mon Jun 18, 2012 2:20 pm

It's possible the content requiring it was scrapped before the function was made fully functional, or perhaps it was broken after the content required it was scrapped. If it's not used successfully in the game, though, I'd not be particularly surprised if it's broken.

Cipscis
User avatar
Lucy
 
Posts: 3362
Joined: Sun Sep 10, 2006 4:55 am

Post » Mon Jun 18, 2012 7:09 pm

I imagine there is no way to look at or edit how the method works? I guess I'm just stuck.
User avatar
Amber Ably
 
Posts: 3372
Joined: Wed Aug 29, 2007 4:39 pm

Post » Mon Jun 18, 2012 5:29 pm

No, native functions are part of the game engine and aren't written in Papyrus. I expect we'll have to wait on the SKSE team for this one, assuming it's even something they might one day implement.

Cipscis
User avatar
Lakyn Ellery
 
Posts: 3447
Joined: Sat Jan 27, 2007 1:02 pm

Post » Mon Jun 18, 2012 7:55 pm

Yea I just tried the code, tries different variations, still the same things happening. I even tried adding this before the chunk:
ReferenceAlias Property Alias_PlayerClone AutoAlias_PlayerClone.ForceRefTo(Game.GetPlayer())


But still no luck. Probably just an unfinished method. Its too bad you can't call console commands in Papyrus, because the TC command works just like I would want it too, oh well. Hopefully the fix it later.
User avatar
Alexander Lee
 
Posts: 3481
Joined: Sun Nov 04, 2007 9:30 pm

Post » Mon Jun 18, 2012 10:36 pm

Still unsure what you are trying to do exactly here...?

If you want to freeze the player look into the event that happens on the throat of the world after you open the elder scroll at the time wound, that entire scene takes place with the player frozen and unable to do anything.
User avatar
Elizabeth Lysons
 
Posts: 3474
Joined: Fri Feb 02, 2007 7:16 am

Post » Tue Jun 19, 2012 1:23 am

Well, I'm actually having a better luck at this than most. I was able to use the SetPlayerControls(True) on another actor and lock the camera on them, but, the problem I have now, is I have to tag the original player along with them, otherwise I can't open doors or activate anything. Seems the actor activation method isn't available to the actor, so I can't make them open doors, pick things up, or even fight, they'll pull their knife out and put it right back, odd. The hud still shows whatever the player is looking at (crosshair reference) and other actors talk to it... Not sure what to do next, if possible. Seems as though this was an afterthought.

GuruSR.

(Edit, grammatical errors, too much late night coding.)
User avatar
Bethany Short
 
Posts: 3450
Joined: Fri Jul 14, 2006 11:47 am

Post » Tue Jun 19, 2012 3:19 am

How did you even get it to work?

I'm Trying to use it to essentially tc a horse, and everytime I try and compile the script it says "SetPlayerControls is not an existing function." Really annoying, considering I don't need it to do anything more than toggle movement which seems to work for you?
User avatar
Genocidal Cry
 
Posts: 3357
Joined: Fri Jun 22, 2007 10:02 pm

Post » Tue Jun 19, 2012 4:38 am

Yea GuruSR how did you get it working? It sounds like you got the exact same effect as the TC command, that could work for what I want to do. Would you mind sharing a snippit of your script? Thanks.
User avatar
Aliish Sheldonn
 
Posts: 3487
Joined: Fri Feb 16, 2007 3:19 am

Post » Mon Jun 18, 2012 8:34 pm

Well, the first thing I did, was with the spell I'm using, I cause it to raise a Story Event (Script Event). Then I pass the quest both the caster and the target. Then in the Quest, the OnStoryEvent gives me both of them (akRef1 = Caster, akRef2 = Target). From there, I merely do what you were doing, disable the control of the Caster, and enable the control of the Target, then I move the camera to that (forcing third and then first person, causes the camera view to snap to the right spot).

I'll break this down a bit, the OnStoryEvent needs a keyword (make one, name it something like ImGonnBeYou), Keyword Property Auto, then set that one in the quest script's property and your spell's script property to the same thing (because you'll want to test for it when the event happens, the keyword is the way of telling what event you got).

In your Quest's Quest Data tab, set it's Event Type to "Script Event".

You'll need to Alias References (Quest Aliases). When you go in, make a New Reference Alias, Name it, set Fill Type for "From Event" (if the Event Data only lists NONE, don't be shocked, I ran into that too), select "Allow reuse in Quest", click Ok,

Right click on that one, and duplicate. Edit the first one, you'll now see "Ref 1" and "Ref 2" added to that list, change it to Ref 1, edit your second one (change the name) and set it to Ref 2.

Now if you call from your Magic Effect's Script; In your OnEffectStart, do this:
.SendStoryEvent(akRef1 = , akRef2 = )

When that happens, it'll inform your quest that keyword with the 2 references came in as an OnStoryEvent. Using your keyword property on the Quest that points to the ImGonnaBeYou keyword, you can test to see if that was indeed the event you wanted and then set actor variables in the quest and then do the work there. Now one thing I've run into (that you also run into with TC, if the actor is busy, you can't break them out of it.

GuruSR.
User avatar
Phillip Brunyee
 
Posts: 3510
Joined: Tue Jul 31, 2007 7:43 pm


Return to V - Skyrim