GrimGrim31 Posted November 28, 2021 Share Posted November 28, 2021 I have a simple script that changes Actor Values (Aggression, Confidence, and Assistance) using akActor.SetValue (ActorValueName, 0) when an armor item is equipped (using the script function OnEquipped (Actor akActor). The Actor Values are changed to zero some of the time but not always. Sometimes the NPCs keep their original values. The inconsistent application of the zero values is frustrating. Is there a way to make sure that SetValue works every time? The script also attempts to give the NPC potions using akActor.AddItems (ItemName, 2, true). When the armor item is unequipped the script tries to remove the added potions using akActor.RemoveItem (ItemName, -1, true). The items have a property declared as Potion property ItemName auto and I filled the property in CK with the proper potion. However, when the script runs, the potions are not added to the NPC. If I add the potions to the NPC manually in the console and then activate the script to remove the potions, they are not removed. I am puzzled as to why AddItem and RemoveItem are not working in the script. akActor.SetProtected (False) and akActor.SetEssential(False) are also applied inconsistently. Sometimes, it works and sometimes it does not. Is there a way for the script to consistently make the NPC unprotected and non-essential. Link to comment Share on other sites More sharing options...
SKKmods Posted November 28, 2021 Share Posted November 28, 2021 To understand the conditions for inconsistency add some debug.trace statements to the script that output the actor values and watch for them in the log. Debug.Trace("MysScriptName.MyFunctionName.TheActorValueName " + akActor + " " + akActor.GetValue(TheActorValueName) ) That will soon sort you out rather than us guessing. Link to comment Share on other sites More sharing options...
GrimGrim31 Posted November 29, 2021 Author Share Posted November 29, 2021 The Debug Trace did not help much this time but I can find uses for it in the future. It turns out that my code was fine but I had to start a new game instead of running new versions of the script in the middle of a game. Thanks for offering assistance. Most folks read and move on without helping so I appreciate anyone that takes time to respond. Link to comment Share on other sites More sharing options...
Recommended Posts