Jump to content

Exiting Power Armor Event


Recommended Posts

I'm trying to configure a script so that it fires when you exit power armor. I checked all the native "OnEvent" options, and none of them seemed to be what was needed. Which means I need to create my own event for this? If I am wrong, can someone please clarify for me, and if I'm not, I would greatly appreciate some help with event creation, as I'm not sure how to go about doing that.

Link to comment
Share on other sites

Not sure of the proper way to catch the exit, but I think there would be a few ways to do it.

 

RegisterForAnimationEvent() and catch when the actor exits the power armor...

But you will need to work out what the animation event string name is that's sent when exiting power armor.

 

 

Here's a crude method you could try if your just wanting it on a single Actor eg: player.

Create an empty quest with a single alias, fill the alias with the actor you want to monitor for enter/exit Power Armor.
Attach this script to the alias (no properties to fill).

Scriptname EnterExitPowerArmorEventScript Extends ReferenceAlias

Keyword ArmorTypePower
Bool bIsInPowerArmor

Event OnInit()
    ArmorTypePower = Game.GetFormFromFile(0x0004D8A1, "Fallout4.esm") As Keyword
    bIsInPowerArmor = Self.GetActorRef().WornHasKeyword(ArmorTypePower)
    AddInventoryEventFilter(ArmorTypePower)
EndEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
    If !bIsInPowerArmor && Self.GetActorRef().WornHasKeyword(ArmorTypePower)
        bIsInPowerArmor = !bIsInPowerArmor
        ;Do your enter actions here
        Debug.Notification("Actor Is In Power Armor")
    EndIf
EndEvent

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
    If bIsInPowerArmor && !Self.GetActorRef().WornHasKeyword(ArmorTypePower)
        bIsInPowerArmor = !bIsInPowerArmor
        ; Do your exit actions here
        Debug.Notification("Actor Not In Power Armor")
    EndIf
EndEvent

Now get the actor to Enter and Exit armor and you should see a Debug Notification when entering or exiting the armor.

If your wondering why I use WornHasKeyword(ArmorTypePower) as opposed to IsInPowerArmor(), the answer is simple.
IsInPowerArmor() randomly fails to report coreectly from what I've experienced with it.
WornHasKeyword(ArmorTypePower) can fail at times, but it seemed way more consistent from what I tested.

 

Edit:

And yes I did actually test this method out and it does appear to work in the brief I tested of it (tested on the player)

Can post the test esp if needed.

 

Edit Again:

If your not wanting to force the player into an Alias, then register for remote events and just use an empty quest and attach a quest script without any alias at all eg:

Scriptname PlayerPowerArmorEventScript Extends Quest

Actor Player
Keyword ArmorTypePower
Bool bIsInPowerArmor

Event OnInit()
    ArmorTypePower = Game.GetFormFromFile(0x0004D8A1, "Fallout4.esm") As Keyword
    Player = Game.GetPlayer()
    bIsInPowerArmor = Player.WornHasKeyword(ArmorTypePower)
    AddInventoryEventFilter(ArmorTypePower)
    RegisterForRemoteEvent(Player, "OnItemAdded")
    RegisterForRemoteEvent(Player, "OnItemRemoved")
EndEvent

Event ObjectReference.OnItemAdded(ObjectReference akSender, Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
    If !bIsInPowerArmor && Player.WornHasKeyword(ArmorTypePower)
        bIsInPowerArmor = !bIsInPowerArmor
        ;Do your enter actions here
        Debug.Notification("Actor Is In Power Armor")
    EndIf
EndEvent

Event ObjectReference.OnItemRemoved(ObjectReference akSender, Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
    If bIsInPowerArmor && !Player.WornHasKeyword(ArmorTypePower)
        bIsInPowerArmor = !bIsInPowerArmor
        ; Do your exit actions here
        Debug.Notification("Actor Not In Power Armor")
    EndIf
EndEvent
Edited by sLoPpYdOtBiGhOlE
Link to comment
Share on other sites

  • 7 months later...

sLoPpYdOtBiGhOlE, could you make a script that changes the scale of the PC upon entering and exiting a PA?

For example, using SetScale so if you enter the scale is set to 1.15 and as you exit it goes back to 1.0.

 

EDIT: Come to think of it, an esp would be much better! :smile:

Edited by TheMothMan
Link to comment
Share on other sites

The Event you're looking for is "OnExitFurniture" believe it or not. Since power armor frames are technically a furniture, this event get's triggered once the power armor exiting animation starts. This event is called by the furniture itself though so the frame itself would have to have the script attached which may not be what you're looking for.

Edited by ZerasCETA
Link to comment
Share on other sites

The Event you're looking for is "OnExitFurniture" believe it or not. Since power armor frames are technically a furniture, this event get's triggered once the power armor exiting animation starts. This event is called by the furniture itself though so the frame itself would have to have the script attached which may not be what you're looking for.

I see! :)

 

Is there an esp availible that demostrates this?

Link to comment
Share on other sites

I'm sure there is but I don't know of one off the top of my head, sorry. It's very easy to use though. When you enter power armor in the game, first it plays the frame furniture's "getting in" animation, then it disables the frame furniture and stores it and changes the player's race to power armor race and adds the frame skin (which is just an armor set to be the race's "naked" body). when you exit the frame, it respawns the furniture and plays the getting out animation. the frame that you got in will have the same editor id as the one you exit, so if you make a custom frame in the editor, and add a script below the battery script in the editor with something like:

Event OnExitFurniture(ObjectReference akActionRef)
 If akActionRef != Game.GetPlayer()
  ;Do NPC Related Stuff
 Else
  ;Do Player Related Stuff
 EndIf
EndEvent

It will trigger. I'm not sure if it's possible to add a script with that event to furniture objects on the fly to make it work without modifying the frames already in the game, but i don't think it is. Maybe with an ActiveMagicFffect actually, haven't tried it like this before.

 

EDIT: This might be useful to you too, this is a function I wrote to wait for the player to finish the animation for getting into a power armor before doing anything else. There may be better ways to do it but i know this way works. It's also in the frame's script:

;Wait for Player to Finish Activating Power Armor
Function WaitForPowerArmorEnter()

	If PlayerRef.IsInPowerArmor() == False
		Utility.Wait(0.1)
		WaitForPowerArmorEnter()
	Else
		;DoStuff
	EndIf
EndFunction
Edited by ZerasCETA
Link to comment
Share on other sites

I'm trying to configure a script so that it fires when you exit power armor. I checked all the native "OnEvent" options, and none of them seemed to be what was needed. Which means I need to create my own event for this? If I am wrong, can someone please clarify for me, and if I'm not, I would greatly appreciate some help with event creation, as I'm not sure how to go about doing that.

 

Power armor is a sitting furniture. The Actor event you should use is OnGetUp().

 

Example (in a script extending Actor, placed on a player alias):

Event OnGetUp(ObjectReference akFurniture)
    if akFurniture.HasKeyword(FurnitureTypePowerArmor)
        ; do your stuff here
    endif
EndEvent

You're welcome :smile:

Edited by steve40
Link to comment
Share on other sites

So there is no esp around that scales the PC upon entering and exiting a PA?

 

I could really use one.

 

Player scaling when using power armor is built into the entry and exit animations.

Link to comment
Share on other sites

 

So there is no esp around that scales the PC upon entering and exiting a PA?

 

I could really use one.

 

Player scaling when using power armor is built into the entry and exit animations.

 

Ahh, that's awesome.

So how do I change then scales when entering and exiting?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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