Jump to content

How to get ObjectReference of Power Armor someone is wearing?


vkz89q

Recommended Posts

Hello.

 

I have a magic effect that mimics vanilla effect "shoot enemies in the fusion core and they explode + the PA user jumps out of pa". I'm using this for non-player npc and it works fantastic, except for one part.

 

I need to remove the fusion core from the guys PA frame.

 

Only thing I got to work is:

 

ObjectReference Cont

 

Victim.SwitchToPowerArmor(None) ; victim is the guy wearing PA ; and now he jumps out of it
Cont = Victim.GetLinkedRef(LinkPowerArmorKeyword) ; i have test almost all PA related keywords for this while the guy is wearing it and all return none; works fine AFTER he jumps out of it
Cont.RemoveItem(FusionCore)

 

And that WORKS. But, I want to get Ref to that PA when he is wearing it. Now, I have tried lots of keywords etc and functions but I just can't seem to figure how to get that PA ref while the guy is using it.

 

In the vanilla script they have script at Armor: ArmorPoweredFramexxx and it has(on every power armor frame):

akSender.RemoveModFromInventoryItem( GetBaseObject(), PA_FusionCore01 )

Which works WHILE the guy is in PA, but I can't figure how to get that BaseObject() in magic effect script.

 

Any ideas? Like I said, works fine to get that ref when guy jumps out of the PA, but I need it while he is wearing it.

Link to comment
Share on other sites

Ahhh, I've been working on a power armor related mod myself and ran into a similar issue. The bad news is there's really no perfect way around it. The problem is, power armor frames are a race skin or armor while they're being worn, and a furniture item when they aren't being worn, with absolutely no link from one to the other. The reference of the frame furniture they got into will be the same for the one they get out of, but i haven't found anywhere that that information is stored while they're wearing it and i believe, as with most things related to power armor, it's hardcoded.

 

When you use Victim.SwitchToPowerArmor(None), the npc will automatically switch back to their previous race (power armor is technically a race, for anyone reading) and the animation event of the frame furniture object begins to play. Believe it or not, the get out animation isn't an actor animation but is actually the frame furniture's animation being activated on the actor, exactly the way getting out of a chair object works.

 

The best way I can say to go about getting around it is to use FindAllReferencesWithKeyword(isPowerArmorFrame) with a small radius, on the "victim" at the time right after they're ejected from the power armor, while the geting out animation is playing. If you call it before they're getting out, there won't be a frame furniture object nearby. This should get you that furniture frame's reference ID and allow you to tap it's inventory at will. I can't say for certain that this will work as it's not what i needed to do exactly, but it should work. The only time i can think of that it might not is if they get hit by your effect in a room full of power armor frames. Then you could narrow it down by comparing the distance from the victim to each reference and choosing the one with the smallest distance. Should work in 99% of cases.

 

hope this helps.

Edited by ZerasCETA
Link to comment
Share on other sites

Yeah, unfortunately. I Can't say with 100% certainty that it can't be done, but i'm almost positive. It's like trying to get the last chair used by an npc, when the chair has since been disabled, and none of it happened on screen. The functions to do it just don't exist, and in all likelihood, the npc exiting power armor just spawns a generic frame reference, with no specific reference because he never technically got in one. You're going to have to use a workaround of some sort. If you can optimize the script enough to run instantly, it should still appear to the player the way you'd like it to at least.

Edited by ZerasCETA
Link to comment
Share on other sites

  • Recently Browsing   0 members

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