Please help me if you can.
This script has been working fine for a year and now some change I made to it in the last few weeks has the game delaying it ( thread pile up? dropping threads?) until the player changes to another cell. At first I thought the script was crashing, stopping and not running at all anymore there after. But after many hours of testing I finally tried going thu a load door and suddenly my PC started blocking several times and other functions in the script quickly executed as well all trying to “catch up” I guess.
Can some better modder/programmer please see if they can spot what I did wrong?
I just need to know what is dropping threads, that is all, because if this thread dropping issue cannot be fixed then nothing else in the script that may also be lacking will matter as I and my players would not be able to use the mod anymore. I am very scared of that.
After it is working again I would also like tips on the other issues in the script, but for now I have to get it working, people are waiting on me and I feel bad about that as well.
Scriptname aadpPlayerScript extends ReferenceAlias Actor Property PlayerRef AutoActor AttackerBool LeftBlockingMiscObject Property aadpDummyHolySymbol Auto Light Property aadpVampSolarSep AutoObjectReference Property aadpMovToNewCellMarkRef AutoImageSpaceModifier Property aadpLowStamina AutoSpell Property aadpMakeWepLightSpl Auto Spell Property AltarStendarrSpell AutoSpell Property aadpFakeWeaponHit AutoInt ikey ;-- Middle mouse by defaultint WeaponTypeLeftint WeaponTypeRightint FreeToMoveint PrayLockDoonceint iforwardKeyint AttackWithLightWeaponInt iRAttackKeyInt iLAttackKey int PressAttackToLeftBlockfloat CellDooncefloat XDistfloat YDistfloat OldXfloat OldYMagiceffect Property FortifyBlockFFSelf Auto MagicEffect PrayLockMagicEffect Property FortifyHealthFFSelf AutoKeyword Property MagicBlessing AutoKeyword Property ArmorGauntlets AutoKeyword Property armorCuirass AutoBool HasAgileDefender80Bool ISAttackingCell OldCellQuest Property aadpMainQuest AutoQuest Property aadpGiveActorsItems Auto Faction Property aadpHolySymbolFaction Auto Faction Property aadpJustDodged AutoFaction Property aadpSpeedCutRight AutoFaction Property aadpSpeedCutLeft Autoperk Property AgileDefender60 Autoperk Property AgileDefender80 AutoGlobalVariable Property aadpTwoWepBlock Auto GlobalVariable Property aadpCellSoftLimit AutoGlobalVariable Property aadpEnablePlayerControlsInConsole AutoGlobalVariable Property aadpPressAttackToLeftBlock AutoGlobalVariable Property aadpClassicVampires AutoEvent OnInit() ; This event will run once, when the script is initialized RegisterForMenu("Console") RegisterForCrosshairRef() RegisterForAnimationEvent(playerref, "BlockAnticipateStart") RegisterForAnimationEvent(playerref, "BlockAnticipateStop") RegisterForAnimationEvent(playerref, "BlockStart") RegisterForAnimationEvent(playerref, "BlockStartOut")SetUp()playerref.addspell(aadpMakeWepLightSpl)EndEventEvent OnMenuClose(String MenuName)if MenuName == "Console"utility.wait(1.0);-- for fade from black if aadpEnablePlayerControlsInConsole.getvalue() == 1 Game.EnablePlayerControls() endif SetUp()endifendeventevent OnObjectEquipped(Form akBaseObject, ObjectReference akReference)WeaponTypeRight = Playerref.GetEquippedItemType(1) ;- crossbow = 12 with GetWeaponType() crossbow = 9WeaponTypeLeft = Playerref.GetEquippedItemType(0)BlockWithLeft()FreeToMove = 0if playerref.hasperk(AgileDefender60) FreeToMove = 1 if playerref.WornHasKeyword(ArmorGauntlets) FreeToMove = 0 elseif playerref.WornHasKeyword(armorCuirass) FreeToMove = 0 endif if playerref.getactorvalue("DamageResist") <= 20 FreeToMove = 1 endifendifendeventevent OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference)WeaponTypeRight = Playerref.GetEquippedItemType(1) ;- crossbow = 12 with GetWeaponType() crossbow = 9WeaponTypeLeft = Playerref.GetEquippedItemType(0)BlockWithLeft()FreeToMove = 0if playerref.hasperk(AgileDefender60) FreeToMove = 1 if playerref.WornHasKeyword(ArmorGauntlets) FreeToMove = 0 elseif playerref.WornHasKeyword(armorCuirass) FreeToMove = 0 endif if playerref.getactorvalue("DamageResist") <= 20 FreeToMove = 1 endifendifendeventEvent OnPlayerLoadGame()SetUp()CellDoonce = 0Weapon MyBow = Playerref.GetEquippedWeapon()if MyBow.isbow()Playerref.UnequipItem(MyBow, false, true) ;-- will not need this anymore after making a bow formlist function;Playerref.equipItem(MyBow, false, true);- cannot do this, it confuses the on equip script for the bow and will not actually equip the bow endifendeventEvent OnKeyDown(Int KeyCode)ISAttacking = playerref.getAnimationVariableBool("IsAttacking")if KeyCode == iLAttackKey || KeyCode == iRAttackKey if playerref.Getactorvaluepercentage("stamina") <= 0.1 if IsAttacking == true if (!Playerref.getAnimationVariableBool("Isfirstperson")) Debug.SendAnimationEvent(playerref, "Bleedoutstart") utility.wait(0.2) Debug.SendAnimationEvent(playerref, "Bleedoutstop") return else aadpFakeWeaponHit.cast(Playerref, Playerref) Debug.SendAnimationEvent(playerref, "recoilstart") return endif endif endifendifint TwoWepBlock = 0if KeyCode == iKey ;-- this is to block with the player chosen key if WeaponTypeRight > 0 || WeaponTypeLeft > 0 if IsAttacking == false Debug.SendAnimationEvent(playerref, "Blockstart") TwoWepBlock = 1 elseif FreeToMove == 1 && WeaponTypeLeft != 7 && WeaponTypeLeft != 12 && AttackWithLightWeapon == 1 Debug.SendAnimationEvent(playerref, "attackstop") Debug.SendAnimationEvent(playerref, "Blockstart") TwoWepBlock = 1 endif endifendif;-WeaponTypeRight <= 4 HARD CODE will not allow some combinations like bow or staff in right hand.if KeyCode == iLAttackKey && TwoWepBlock == 0if FreeToMove == 1 && WeaponTypeLeft != 7 && WeaponTypeLeft != 12if AttackWithLightWeapon == 1 && IsAttacking == True Debug.SendAnimationEvent(playerref, "attackstop") Debug.SendAnimationEvent(playerref, "Blockstart")elseif PressAttackToLeftBlock == 1 && LeftBlocking == True if Attacker.getcombattarget() == playerref if Attacker.getAnimationVariableBool("Isattacking") == true if Attacker.GetEquippedItemType(0) != 7 if Attacker.getAnimationVariableBool("IsCasting") == False if IsAttacking == True Debug.SendAnimationEvent(playerref, "attackstop") endif Debug.SendAnimationEvent(playerref, "Blockstart") endif endif endif endifendifendifendifAttackWithLightWeapon = 0;;;;;;;;;;if ISAttacking == true ;- do not use, this makes the feature inconsistent with fast button pressif HasAgileDefender80 == True if KeyCode == iRAttackKey && (playerref.isinfaction(aadpSpeedCutRight)) ;-- this light weapon attack detection must be at the bottom of this block. AttackWithLightWeapon = 1 elseif KeyCode == iLAttackKey && (playerref.isinfaction(aadpSpeedCutLeft)) AttackWithLightWeapon = 1 endifendifEndEventEvent OnKeyUp(Int KeyCode, Float HoldTime)if KeyCode == iforwardKey float NewX = playerref.GetPositionX() float NewY = playerref.GetPositionY() int DistNum if (playerref.IsInInterior()) OldX = 0 OldY = 0 if Playerref.GetParentCell() != OldCell OldCell = Playerref.GetParentCell() CellChange() endif Else if NewX > (OldX + 8000) OldX = NEWX CellChange() elseif NewX < (OldX - 8000) OldX = NEWX CellChange() elseif NewY > (OldY + 8000) OldY = NewY CellChange() elseif NewY < (OldY - 8000) OldY = NewY CellChange() endif endifendifif KeyCode == iKeyif (Playerref.getAnimationVariableBool("Isblocking"))Debug.SendAnimationEvent(playerref, "Blockstop")endifendifEndEventEvent OnAnimationEvent(ObjectReference akSource, string asEventName)if asEventName == "BlockStart" || asEventName == "BlockStartOut" if akSource == playerref if playerref.Getactorvaluepercentage("stamina") <= 0.1 if (!Playerref.getAnimationVariableBool("Isfirstperson")) Debug.SendAnimationEvent(playerref, "Bleedoutstart") utility.wait(0.2) Debug.SendAnimationEvent(playerref, "Bleedoutstop") else aadpFakeWeaponHit.cast(Playerref, Playerref) Debug.SendAnimationEvent(playerref, "recoilstart") utility.wait(0.2) Debug.SendAnimationEvent(playerref, "recoilstart") endif endif endifelseif asEventName == "BlockAnticipateStart"Debug.MessageBox("error-00 Conflicting mod edit”)elseif asEventName == "BlockAnticipateStop"Debug.MessageBox("error-00 Conflicting mod edit”)endifendeventEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)if akBaseItem == aadpDummyHolySymbolplayerref.removeitem(aadpDummyHolySymbol, 1, true)playerref.additem(aadpVampSolarSep, 1, true)endifendeventEvent OnMagicEffectApply(ObjectReference akCaster, MagicEffect akEffect);if akEffect == FortifyBlockFFSelf || akEffect == FortifyHealthFFSelfif (aadpMainQuest as aadpMainCombatQuest).OncePerDay == 0 if akEffect.HasKeyword(MagicBlessing) if PraylockDoonce == 0 PraylockDoonce = 1 Debug.messagebox("The next time you pray at a shrine your choice will be locked in. Thenceforth when you pray at the same Deity's shrine again your Righteous Influence for the holy symbol will ascend to a higher level. But only once a day.") Playerref.AddToFaction(aadpHolySymbolFaction) playerref.ModFactionRank(aadpHolySymbolFaction, 100) Debug.messagebox("This one time only your Righteous Influence for the holy symbol will ascend to the maximum level.") elseif PrayLock == none PrayLock = akEffect endif if PrayLock == akeffect playerref.ModFactionRank(aadpHolySymbolFaction, 34) debug.Notification("Righteous Influence Ascended To " + playerref.getFactionRank(aadpHolySymbolFaction) + "%") (aadpMainQuest as aadpMainCombatQuest).OncePerDay = 1 endif endifendifEndEventFunction CellChange()if CellDoonce < Utility.GetCurrentRealTime() Celldoonce = Utility.GetCurrentRealTime() + 10 int count = aadpCellSoftLimit.getvalue() as int if count > Game.GetGameSettingInt("iAiNumberActorsComplexScene") count = Game.GetGameSettingInt("iAiNumberActorsComplexScene") endif aadpMainQuest as aadpMainCombatQuest).CellSpawnCount = count aadpGiveActorsItems.Stop() utility.wait(5.0) aadpGiveActorsItems.Start();debug.messagebox("cell load")endifendfunctionBool Function BlockWithLeft()LeftBlocking = falseif WeaponTypeLeft > 0 if WeaponTypeLeft != 5if WeaponTypeLeft != 6if WeaponTypeLeft != 10 LeftBlocking = TrueendifendifendifendifendfunctionEvent OnCrosshairRefChange(ObjectReference ref)if ref.gettype() == 62 Attacker = Ref as actorendifendevent Function SetUp()WeaponTypeRight = Playerref.GetEquippedItemType(1) ;- crossbow = 12 with GetWeaponType() crossbow = 9WeaponTypeLeft = Playerref.GetEquippedItemType(0)BlockWithLeft()HasAgileDefender80 = playerref.hasperk(AgileDefender80)playerref.removefromfaction(aadpJustDodged)UnregisterForKey(iKey)ikey = aadpTwoWepBlock.getvalue() as intif ikey > 0 PressAttackToLeftBlock = aadpPressAttackToLeftBlock.getvalue() as int RegisterForKey(iKey)endifUnregisterForKey(iforwardKey)iforwardKey = Input.GetMappedKey("Forward")RegisterForKey(iforwardKey)UnregisterForKey(iRAttackKey)UnregisterForKey(iLAttackKey)iRAttackKey = Input.GetMappedKey("Right Attack/Block")iLAttackKey = Input.GetMappedKey("Left Attack/Block")RegisterForKey(iRAttackKey)RegisterForKey(iLAttackKey)endfunction