I have an inconsistency issue with my recently release Disarm Retrieval mod that I've been hard pressed to stamp out.
Sometimes when a weapon is lost, it doesn't return. It always seems to be a bow, crossbow or a 2 handed weapon. For anything else, it works consistently.
I've did some profiling and well, see for yourself:
Script_RetrieveDisarmWepRefScript log opened (PC)86747:QUEUE_PUSH:2093766:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.??.OnMagicEffectApply86747:QUEUE_PUSH:2093767:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.??.OnMagicEffectApply86748:PUSH:2093766:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnMagicEffectApply86766:PUSH:2093767:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnMagicEffectApply86779:QUEUE_PUSH:2093770:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.??.OnObjectEquipped86779:QUEUE_PUSH:2093772:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.??.OnObjectEquipped86780:QUEUE_PUSH:2093773:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.??.OnItemRemoved86781:PUSH:2093770:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnObjectEquipped86781:PUSH:2093772:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnObjectEquipped86798:PUSH:2093773:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.WaitingForDisarm.OnItemRemoved86831:QUEUE_POP:2093772:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnObjectEquipped86851:POP:2093772:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnObjectEquipped86864:QUEUE_POP:2093773:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.WaitingForDisarm.OnItemRemoved86895:POP:2093773:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.WaitingForDisarm.OnItemRemoved86895:QUEUE_POP:2093770:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnObjectEquipped86897:POP:2093770:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnObjectEquipped89766:QUEUE_POP:2093766:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnMagicEffectApply89782:POP:2093766:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnMagicEffectApply89782:QUEUE_POP:2093767:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnMagicEffectApply89799:POP:2093767:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnMagicEffectApply111933:QUEUE_PUSH:2093932:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.??.OnObjectEquipped111951:PUSH:2093932:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnObjectEquipped112065:QUEUE_POP:2093932:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnObjectEquipped112067:POP:2093932:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnObjectEquipped123297:QUEUE_PUSH:2094011:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.??.OnMagicEffectApply123297:QUEUE_PUSH:2094012:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.??.OnMagicEffectApply123299:PUSH:2094011:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnMagicEffectApply123316:PUSH:2094012:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnMagicEffectApply123331:QUEUE_PUSH:2094014:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.??.OnItemRemoved123346:PUSH:2094014:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.WaitingForDisarm.OnItemRemoved123430:QUEUE_POP:2094014:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.WaitingForDisarm.OnItemRemoved123465:POP:2094014:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript.WaitingForDisarm.OnItemRemoved126316:QUEUE_POP:2094011:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnMagicEffectApply126332:POP:2094011:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnMagicEffectApply126349:QUEUE_POP:2094012:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnMagicEffectApply126366:POP:2094012:0:alias Player on quest RetrieveDisarmQuest (24000D62):RetrieveDisarmWepRefScript..OnMagicEffectApply
I'm no pro at profile reading, but that seems to be painfully slow, and OnItemRemoved seems to be called last.
Is there any changes I need to make this script for better functionality, or optimization?
Scriptname RetrieveDisarmWepRefScript extends ReferenceAlias{Attempts to detect if the equipped weapon has been removed.}Actor property PlayerRef autoObjectReference FindCurrentWeaponForm CurrentWeaponBool WeaponRetrieved = falseBool NewWeapon = trueMagicEffect property VoiceDisarmShout01 autoMagicEffect property VoiceDisarmShout02 autoMagicEffect property VoiceDisarmShout03 autoMagicEffect property DragonVoiceDisarmEffect autoEvent OnInit()CurrentWeapon = PlayerRef.GetEquippedWeapon()debug.notification("Current Weapon:" +CurrentWeapon.GetName() as string);The weapon stored is the weapon currently equipped AT THE TIME THIS EVENT IS FIRED.;Any subsequent weapon changes is handled through OnObjectEquipped.AddInventoryEventFilter(CurrentWeapon);So that the OnItem events only fire for the weapons.RegisterForMenu("BarterMenu")RegisterForMenu("CraftingMenu")RegisterForMenu("MessageBoxMenu")RegisterForMenu("ContainerMenu");Incase the weapon that is stored is then sold or destroyed through disenchantment.EndEventEvent OnPlayerLoadGame()debug.notification("Testing OnPlayerLoadGame")RegisterForMenu("BarterMenu")RegisterForMenu("CraftingMenu")RegisterForMenu("MessageBoxMenu")RegisterForMenu("ContainerMenu")EndEventEvent OnMagicEffectApply(ObjectReference akSource, MagicEffect akEffect) if (akEffect == VoiceDisarmShout01 || akEffect == VoiceDisarmShout02 || akEffect == VoiceDisarmShout03 || akEffect == DragonVoiceDisarmEffect) GoToState("WaitingForDisarm") Utility.wait(0.5) GoToState("") endifEndEventSTATE WaitingForDisarmEvent OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)CurrentWeapon = akBaseItemFindCurrentWeapon = Game.FindClosestReferenceOfTypeFromRef(CurrentWeapon, PlayerRef, 1000.0) if (CurrentWeapon) ; debug.notification("Correct Weapon") endif if FindCurrentWeapon == none ; debug.notification("Did not find weapon.") else PlayerRef.Additem(FindCurrentWeapon) WeaponRetrieved = true ; debug.notification("Get Boolean Value:" +WeaponRetrieved) endif if WeaponRetrieved == true ; debug.notification("Removing all filters.") RemoveAllInventoryEventFilters() endif EndEventENDSTATEEvent OnObjectEquipped(Form akBaseObject, ObjectReference akReference)CurrentWeapon = akBaseObject if (akBaseObject as weapon) == CurrentWeapon debug.notification("Weapon in hand.") CurrentWeapon = PlayerRef.GetEquippedWeapon() if NewWeapon == true debug.notification("New weapon.") ; CurrentWeapon = PlayerRef.GetEquippedWeapon() AddInventoryEventFilter(CurrentWeapon) debug.notification("Current Weapon:" +CurrentWeapon.GetName() as string) endif endifEndEventEvent OnMenuOpen(String MenuName) if MenuName == "BarterMenu" || MenuName == "CraftingMenu" || MenuName == "MessageBoxMenu" || MenuName == "ContainerMenu" ; debug.notification("Menu opened.") GoToState("Listening") endifEndEventEvent OnMenuClose(String MenuName) if MenuName == "BarterMenu" || MenuName == "CraftingMenu" || MenuName == "MessageBoxMenu" || MenuName == "ContainerMenu" ; debug.notification("Menu closed.") GoToState("") endifEndEventSTATE ListeningEvent OnObjectEquipped(Form akBaseObject, ObjectReference akReference);emptyEndEventENDSTATEEvent OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) ;emptyEndEventEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer);emptyEndEvent