Jump to content

Papyrus script to Detect when the player is Idle?


Recommended Posts

I've written a magic effect script that will require the player to be standing still on the ground before continuing, while wearing power armor, and I cannot for the life of me find the correct AnimEvent or a suitable animation variable to use to detect it, in either the power armor behaviors or the root behaviors, 1st or 3rd person... The Idle Animation dialogue box in the CK, under 1st person root behaviors shows ActionIdle, then "1stPIdle", but the AnimEvent is set to None, which of course it is, that's the whole point, but that means I can't friggin detect it.

 

Does anyone know how to do this, or a better way than going either of those routes?

Edited by ZerasCETA
Link to comment
Share on other sites

What do you mean by "the player to be standing still on the ground"?

 

If you mean that you need to detect when the player is not playing other anims than his very limited idle (compared to the NPCs idles), to my knowledge the best way is to use conditions to exclude all other animations (like swimming, running, sneaking, inCombat, using furniture, being in conversations, etc.) - Papyrus has a whole list of these - you can add them as conditions to your Magic Effect + make sure that he is indeed wearing Power Armor.

Link to comment
Share on other sites

Exactly, that's what i need, sorry if my explanation was confusing. I was looking for a simpler method than just excluding all other possible anims, of which there are a lot. The effect is cast by the use of a potion object and uses PlaceAtMe to place an object. The only way to avoid it being placed in midair, since this object cannot have physics, is to make sure the player isn't moving. I was hoping to avoid a thirty mile long If/Or statement, haha, but i guess that's the plan then.

Link to comment
Share on other sites

Oh thanks for your explanations - and sorry, not native English speaker here, sometimes it doesn't help...

 

I've been working a lot with anims lately, and trying to get an actor (not player) to just keep moving at all, so basically looking for the same Idle or animEvent you're looking for, and the closest one I found was IdleStop, except the player will not use it (that I know of) unless a script calls it. But if calling that animEvent finds room in your MGEF - after excluding all other movements I'm afraid, it should work with placeAtMe - at least it does in my experience. PlaceAtMe will not match the player's rotation though, so if it's important that your object matches the player's AngleZ, you'll need to correct that with myObjectRef.SetAngle(0.0, 0.0, PlayerRef.GetAngleZ()).

Link to comment
Share on other sites

I don't know answer to your question, but something I noticed while playing a LOT with animevents: Most of them do not send event, ever. So you have to figure which works and which doesn't. Maybe I did something wrong, but I registered for several animations with debug msgs, and most of them never sent event. I use this on npc, not player, maybe that's why.

 

Also, you need to re-register everytime 3d gets un-loaded/loaded, which can randomly happen on a npc if he is too far away or player fast travels etc.

 

I did find enough animations to play with, but it was pain to test which work and which doesn't.

Link to comment
Share on other sites

Oh, sorry, my English failed me again - I was not asking a question. I was just sharing bits of infos I've found, like the PlaceAtMe() function not matching the player's rotation when you use it in Fallout 4 in case it was useful to you.

I haven't even tried to use "Debug;SendAnimationEvent" which is apparently no longer a valid function in Fallout 4. As for "onAnimationEvent', I didn't try it either because I remember from Skyrim that many events where not detected at all by Skyrim's engine either. Whenever I wanted to male sure the player was not playing any other anim than his default Idle, I always had to proceed by excluding all other possibilties in Skyrim too.

 

Here's a link to the Skyrim Wiki page about that: http://www.creationkit.com/index.php?title=OnAnimationEvent_-_Form. So I figured it might be the same in F04, + too many idles share the same AnimEvent for that to be accurate in my experience. My best advice would be for you to forget about AnimEvents which don't work for you and find some other work-around which fits your purpose.

 

What works better in Fallout 4 is using "PlayIdle" - it actually works way better than the equivalent Skyrim function.

 

As far as I've seen, NPCs in Fallout 4 are always playing some idle - they're always sandboxing except on occasional times when you teleport to a settlement and find all your settlers sort of frozen. So if you need them to stand still, you'll have to call "myActor.PlayIdle(IdleStop)" on them and immediately use "myActor.SetRestrained()" for them to remain where they've stopped (which later needs to be undone with "myActor.SetRestrained(false)" once you're done needing them to stand still).

Link to comment
Share on other sites

Yeah, I simply needed to detect when NPC gets in ragdoll state(knocked down from sniper push perk for example) and then when he is not ragdolling anymore.

 

I got mine working like this:

 

RegisterForAnimationEvent(Fighter, "enterfullyragdoll")
RegisterForAnimationEvent(Fighter, "ragdollandgetup")
RegisterForAnimationEvent(Fighter, "defaultrefpose")
RegisterForAnimationEvent(Fighter, "getupstart")

I registered for these in Event OnCombatStateChanged, and then unregistered when combat state is 0.

 

Then simply doing:

Event OnAnimationEvent(ObjectReference akSource, string asEventName)
	;RAGDOLLING
	if (asEventName == "enterfullyragdoll") 
		Debug.Notification("D:enterfullyragdoll")
		AreWeRagdolling = 1
	
	elseif (asEventName == "ragdollandgetup") 
		Debug.Notification("D:ragdollandgetup")
		AreWeRagdolling = 1

	;NOT RAGDOLLING		
	elseIf (asEventName == "defaultrefpose") 
		;Debug.Notification("E:defaultrefpose")
		AreWeRagdolling = 0
		
	elseIf (asEventName == "getupstart")
		Debug.Notification("E:getupstart")
		AreWeRagdolling = 0
	endIf
EndEvent

I had a problem finding good enough AnimationEvents to detect when npc gets up from ragdoll. "getupstart" works good enough. So I'm lucky I found what I needed. I tried ton of different animation events and many of them never fire events.

 

For example, I wanted to register for animation event where my npc reloads weapon. Never got it working. Or when he starts running, never got that working either. Or swimming. It's possible I didn't try all the possible animations but still find it weird they have listed animation events in CK -> gameplay -> animations but they don't work.

 

I got my script working good enough so it's all good now.

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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