SolastaMods / SolastaUnfinishedBusiness

MIT License
142 stars 66 forks source link

The game freezes when attacking an enemy that is maintaining concentration #4709

Closed magicskysword closed 4 months ago

magicskysword commented 4 months ago

This happened while I was attacking an enemy who was maintaining focus.

ModVersion 1.5.97.14

NullReferenceException: Object reference not set to an instance of an object
  at SolastaUnfinishedBusiness.Patches.RulesetCharacterPatcher+RollConcentrationCheck_Patch.RollConcentrationCheck (RulesetCharacter __instance, System.Int32 saveDC, System.String damageType, RuleDefinitions+RollOutcome& outcome) [0x00073] in <19a45cd7ff024d578fb41c69ddd953d1>:0 
  at SolastaUnfinishedBusiness.Patches.RulesetCharacterPatcher+RollConcentrationCheck_Patch.Prefix (RulesetCharacter __instance, System.Int32 saveDC, System.String damageType, RuleDefinitions+RollOutcome& outcome) [0x00000] in <19a45cd7ff024d578fb41c69ddd953d1>:0 
  at (wrapper dynamic-method) RulesetCharacter.RulesetCharacter.RollConcentrationCheck_Patch1(RulesetCharacter,int,string,RuleDefinitions/RollOutcome&)
  at (wrapper dynamic-method) RulesetCharacter.RulesetCharacter.RollConcentrationCheckFromDamage_Patch0(RulesetCharacter,int,string,RuleDefinitions/RollOutcome&)
  at (wrapper dynamic-method) GameLocationCharacter.GameLocationCharacter.CheckConcentration_Patch2(GameLocationCharacter,RulesetCharacter,int,string,bool)
  at GameLocationCharacter.DamageSustained (RulesetCharacter character, System.Int32 damage, System.String damageType, System.Boolean wasConscious, System.Boolean stillConscious, System.Boolean massiveDamage) [0x00000] in <14069e0776c443f6af77ee3eeee86525>:0 
  at (wrapper delegate-invoke) <Module>.invoke_void_RulesetCharacter_int_string_bool_bool_bool(RulesetCharacter,int,string,bool,bool,bool)
  at RulesetCharacter.SustainDamage (System.Int32 totalDamageRaw, System.String damageType, System.Boolean criticalSuccess, System.UInt64 sourceGuid, RollInfo rollInfo, System.Boolean& damageAbsorbedByTemporaryHitPoints, System.Boolean forceKillOnZeroHp, ConditionDefinition specialDeathCondition) [0x004a9] in <14069e0776c443f6af77ee3eeee86525>:0 
  at (wrapper dynamic-method) RulesetActor.RulesetActor.InflictDamage_Patch1(int,DamageForm,string,RulesetImplementationDefinitions/ApplyFormsParams,RulesetActor,bool,ulong,bool,System.Collections.Generic.List`1<string>,RollInfo,bool,bool&)
  at (wrapper dynamic-method) RulesetImplementationManager.RulesetImplementationManager.ApplyDamageForm_Patch0(RulesetImplementationManager,EffectForm,RulesetImplementationDefinitions/ApplyFormsParams,bool&,int&,int&,string&,bool&,System.Collections.Generic.List`1<string>)
  at RulesetImplementationManager.ApplyEffectForm (EffectForm effectForm, EffectForm nextEffectForm, RulesetImplementationDefinitions+ApplyFormsParams formsParams, System.Boolean retargeting, System.Boolean proxyOnly, System.Boolean forceSelfConditionOrLightOnly, System.Int32& damageReceived, System.String& damageType, System.Boolean& firstDamage, System.Boolean& firstHealing, System.Int32& formIndex, System.Boolean& damageAbsorbedByTemporaryHitPoints, System.Collections.Generic.List`1[T] effectiveDamageTypes) [0x00386] in <14069e0776c443f6af77ee3eeee86525>:0 
  at RulesetImplementationManager.ApplyEffectForms (System.Collections.Generic.List`1[T] effectForms, RulesetImplementationDefinitions+ApplyFormsParams formsParams, System.Collections.Generic.List`1[T] effectiveDamageTypes, System.Boolean& damageAbsorbedByTemporaryHitPoints, System.Boolean& terminateEffectOnTarget, System.Boolean retargeting, System.Boolean proxyOnly, System.Boolean forceSelfConditionOrLightOnly, RuleDefinitions+EffectApplication effectApplication, System.Collections.Generic.List`1[T] filters) [0x00068] in <14069e0776c443f6af77ee3eeee86525>:0 
  at SolastaUnfinishedBusiness.Patches.CharacterActionAttackPatcher+ExecuteImpl_Patch+<ExecuteImpl>d__1.MoveNext () [0x0138f] in <19a45cd7ff024d578fb41c69ddd953d1>:0 
  at TA.Coroutine.Run () [0x00019] in <14069e0776c443f6af77ee3eeee86525>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
Trace:LogException(Exception)
TA.Coroutine:Run()
GameLocationActionManager:UpdateImpl()
GameLocationActionManager:Update()

SaveFile.zip

magicskysword commented 4 months ago

I found that it's possible that the problem is in SolastaUnfinishedBusiness/SolastaUnfinishedBusiness/Patches/RulesetCharacterPatcher.cs line 1757

            // supports mind sharpener infusion
            if (__instance.CharacterInventory.InventorySlotsByName
                .TryGetValue(EquipmentDefinitions.SlotTypeTorso, out var inventorySlot))

I guess it's because monsters don't have inventory, so I modify it to this:

            // supports mind sharpener infusion
            var inventory = __instance.CharacterInventory;
            // monster don't have inventory
            if (inventory != null && inventory.InventorySlotsByName
                .TryGetValue(EquipmentDefinitions.SlotTypeTorso, out var inventorySlot))

This was the solution to my problem.

ThyWoof commented 4 months ago

Thanks!