9raxus Posted January 9, 2021 Share Posted January 9, 2021 I have a script that involves customizing a weapon and this script is attached to a quest. The quest is called upon the start of the game. The script involves the animation event "weaponfire." The script works just fine as long as the player is the normal "human" race that they start out as but, once the player enters power armor, the script breaks. Exiting power armor does not resume the script effect. I have learned that the player changes race when entering power armor and, so, I can only guess that the act of changing race is breaking my script. I have further learned that the power armor "race" uses different animation events than the human "race" and, since my script uses animation events, I can only guess that part of the precise reason for why my script is breaking is because, once the player becomes the power armor race, the animation event is no longer valid. However, I have looked extensively for a list of animation events for the power armor race and can not find the power armor race equivalent for "weaponfire." It may be that both the power armor & human race use the same event and my script is breaking through the act of changing race. Therefore: 1). How do you "race-proof" scripts so that, upon changing races (ex. from human to power armor), the script remains intact? 2). Is there a power armor race equivalent to "weaponFire" and, if so, what would that be? Thank you. Link to comment Share on other sites More sharing options...
DieFeM Posted January 9, 2021 Share Posted January 9, 2021 I would try re-registering for the animation event in OnRaceSwitchComplete. Link to comment Share on other sites More sharing options...
DieFeM Posted January 9, 2021 Share Posted January 9, 2021 Found a post from 2016 in which is described this same problem and OnRaceSwitchComplete doesn't work, so I have remembered that I developed a script to be able to do certain things while I enter to/exit from a power armor for this same reason, there you have it: Event OnActivate(ObjectReference akActionRef) ; This animation event occurs when the enter animation ends, just before the camera changes. RegisterForAnimationEvent(akActionRef, "QuickExitTriggerStart") If akActionRef == Game.GetPlayer() ; This animation event occurs when the player puts a core, it will unregister for QuickExitTriggerStart. RegisterForAnimationEvent(akActionRef, "DisablePACameraAdd") EndIf EndEvent Event OnExitFurniture(ObjectReference akActionRef) ; This animation event occurs when the exit animation ends. RegisterForAnimationEvent(akActionRef, "idleChairGetUp") EndEvent Event OnAnimationEvent(ObjectReference akSource, string asEventName) UnregisterForAnimationEvent(akSource, asEventName) Debug.MessageBox(asEventName) If asEventName == "idleChairGetUp" Debug.MessageBox("Exit PowerArmor") EndIf If asEventName == "QuickExitTriggerStart" UnregisterForAnimationEvent(akSource, "DisablePACameraAdd") Debug.MessageBox("Enter PowerArmor") EndIf If asEventName == "DisablePACameraAdd" UnregisterForAnimationEvent(akSource, "QuickExitTriggerStart") EndIf EndEvent Link to comment Share on other sites More sharing options...
octodecoy Posted January 9, 2021 Share Posted January 9, 2021 You can also use OnSit, or OnAnimationEventUnregistered: OnSit: Event OnQuestInit() RegisterForRemoteEvent(Game.GetPlayer(), "OnSit") RegisterForAnimationEvent(Game.GetPlayer(), "weaponFire") EndEvent Event Actor.OnSit(Actor akSender, ObjectReference akFurniture) If (akFurniture is PowerArmorBatteryInsertScript) RegisterForAnimationEvent(Game.GetPlayer(), "weaponFire") EndIf EndEvent Edit: Would need to use OnGetUp in the same way to re-register after exiting power armor as well I think. OnAnimationEventUnregistered: Event OnQuestInit() RegisterForAnimationEvent(Game.GetPlayer(), "weaponFire") EndEvent Event OnAnimationEventUnregistered(ObjectReference akSource, string asEventName) int i = 0 While (i < 50 && !RegisterForAnimationEvent(akSource, asEventName)) Utility.Wait(0.1) i += 1 EndWhile EndEvent Link to comment Share on other sites More sharing options...
9raxus Posted January 10, 2021 Author Share Posted January 10, 2021 Hi guys and thanks for your efforts so far in helping me to resolve this. I've made attempts to use your solutions and my lack of proficiency in Papyrus scripting is clearly revealing itself as I haven't gotten any of them to work so far. One avenue that I have not tried yet is to even eliminate the "Use a quest" method of injecting the script to be used in the game. Since using Power Armor is a significant part of the game, I'm hard pressed to believe that it takes so much effort to program around the "your character turns into another race every time they use Power Armor" problem that I've experienced. It simply feels like that there's another method for introducing the script that is ultimately 'race-changing' friendlier and doesn't need to compensate for the race changing at all. Again, I'd like to thank everyone for their efforts so far. At the very least, it's revealed the challenges in programming around entering and leaving Power Armor. Link to comment Share on other sites More sharing options...
octodecoy Posted January 11, 2021 Share Posted January 11, 2021 It won't matter what your script extends (quest, referencealias, objectreference, etc) - entering and exiting power armor causes animation graphs to be "unloaded" or "reset", whatever you want to call it, which causes any script registered animations to be un-registered. Link to comment Share on other sites More sharing options...
Fantafaust Posted January 11, 2021 Share Posted January 11, 2021 I think it would be better to explain what you're trying to do exactly. Perhaps there is an alternative to using the animation event to achieve the effect you're going for, whatever that may be. Link to comment Share on other sites More sharing options...
PJMail Posted January 12, 2021 Share Posted January 12, 2021 I have found re-registering the animation event via the OnAnimationEventUnregistered event resolves my similar issues.Monitoring my mods shows that animation events become unregistered for all sorts of reasons - not just PA entry. Link to comment Share on other sites More sharing options...
9raxus Posted January 13, 2021 Author Share Posted January 13, 2021 I think it would be better to explain what you're trying to do exactly. Perhaps there is an alternative to using the animation event to achieve the effect you're going for, whatever that may be. This is a valid question but one that does not have a specific answer. Originally, all that I had wanted to do was to "fool around" in Creation Kit / Papyrus and see if I could regain some of the modding skills that I had in Fallout 3/NV/Oblivion. I understood that Papyrus was different than prior Bethesda game scripting but did not anticipate the significance of that difference. I fell upon the desire to have a weapon cause a specific effect whenever it was fired. I know that an early example was to have a weapon perform energy damage but also a bit of radiation damage as well and also a tiny bit of radiation damage to the player. There were a few others ideas but, eventually, I started using a primitive version of a "recharger" effect (one pull of the trigger, one energy cell added to the inventory) just as a test bed for my scripting lessons. I thought that I had achieved this effect and that would have been the end of it. However, I did not properly playtest the mod because I typically do not use power armor in my play styles and added the mod AFTER the one time in the beginning where you use power armor. Therefore, it came as a surprise to me when I began experiencing a loss of the scripted ability whenever I entered power armor (such as new characters following the Minutemen quest line). Normally, I usually keep my mods private since I don't consider them "Nexus-Quality" since they don't have quests, balancing or other features attached to them that would make such mods "lore friendly." However, the reason for why the script was breaking because of power armor intrigued me and I thought that if the problem was something simple to overcome, why not add that into the script and attempt to make such mods public? It seems evident now that a script inserted through a quest involving a weapon effect for when the trigger is pulled might not be the best approach and a script attached directly to a weapon or as a magic effect might be more efficient in order to make such mods "power armor" friendly with the less scripting. It's been an interesting and educational experience, to say the least. Link to comment Share on other sites More sharing options...
PJMail Posted January 14, 2021 Share Posted January 14, 2021 My "Power Armor Improvements" mod is entirely one magic effect (containing one script) applied to the player (and each of the companions) as I found that the least intrusive way of monitoring the player through power armor transitions.This is where I hit the same problem as you - the animation events becoming 'unregistered'. If you do follow this path of using a magic effect be aware of another problem - there are many points in the game where all magic effects are terminated (and not re-started after that point - which is the bad bit).This is much more pronounced on NPC's - where even just equipping a clothing item in their inventory causes it.Very annoying... Link to comment Share on other sites More sharing options...
Recommended Posts