Tons of QUEUING in my mod's script and other info

Post » Sat Aug 23, 2014 4:27 am

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:

Spoiler
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?

Spoiler
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  
User avatar
emily grieve
 
Posts: 3408
Joined: Thu Jun 22, 2006 11:55 pm

Post » Fri Aug 22, 2014 10:58 pm

A few thoughts.

Do you see the "Did not find weapon." notification when the bow is disarmed? (if not, you may need to increase the radius of the Find..Ref function)

Your OnObjectEquipped event looks like it will set the "CurrentWeapon" to anything that is equipped, including armor and other items. I have a suspicion that when you equip a bow, the ammo is equipped immediately afterward, which may mean the ammo gets set as CurrentWeapon and maybe that's why the bow isn't being found? Try doing a check like:

if (akBaseObject as Weapon) ;only change current weapon if this is a weapon being equipped    CurrentWeapon = akBaseObject    ;etceteraendif
User avatar
Jonathan Montero
 
Posts: 3487
Joined: Tue Aug 14, 2007 3:22 am

Post » Fri Aug 22, 2014 10:20 pm

Yeah I see the notification. When the game is loaded, it will display the currently equipped weapon that OnInit is pointing to. For me, this is always "nothing" since I'm a spellcaster now. When I switch to a bow for testing, CurrentWeapon is displaying the correct name and such. However on Disarm, the weapon isn't found by the Find function.

I didn't think about the ammo. And it is supposed to change what CurrentWeapon is pointing to but it's only supposed to do this for weapons. I will try your suggestion.

Still, don't know why that happens with 2H weapons.

User avatar
NeverStopThe
 
Posts: 3405
Joined: Tue Mar 27, 2007 11:25 pm

Post » Fri Aug 22, 2014 7:09 pm

Alright, with your suggestion, the bow is being returned as expected as well as 2h weapons. Thanks. :smile:

I think I'm understanding how to properly place variables.

User avatar
Luis Longoria
 
Posts: 3323
Joined: Fri Sep 07, 2007 1:21 am


Return to V - Skyrim