diff --git a/Disarm/DisarmingPatch.cs b/Disarm/DisarmingPatch.cs index 0d327f9..e877ac4 100644 --- a/Disarm/DisarmingPatch.cs +++ b/Disarm/DisarmingPatch.cs @@ -22,7 +22,7 @@ public static class DisarmingPatch [HarmonyPatch(typeof(Disarming), nameof(Disarming.Disarm))] public static void Postfix(GameObject Object, GameObject Disarmer, string DisarmerStat, GameObject DisarmingWeapon, GameObject __result) { - if (__result == null || Object.pBrain == null) + if (__result == null || Object.Brain == null) { return; } @@ -30,17 +30,13 @@ public static void Postfix(GameObject Object, GameObject Disarmer, string Disarm { return; } - if(Object.IsPlayer()) - { - return; - } if (Options.GetOption("OptionReequipSearch") == "Yes") { - Object.pBrain.PushGoal(new ReequipOrFindNew(__result)); + Object.Brain.PushGoal(new ReequipOrFindNew(__result)); } else { - Object.pBrain.PushGoal(new EquipObject(__result)); + Object.Brain.PushGoal(new EquipObject(__result)); } } } @@ -57,19 +53,15 @@ static void ReequipHelper(GameObject who, GameObject what) { return; } - if(who.IsPlayer()) - { - return; - } - if (who?.pBrain != null && what != null) + if (who?.Brain != null && what != null) { if (Options.GetOption("OptionReequipSearch") == "Yes") { - who.pBrain.PushGoal(new ReequipOrFindNew(what)); + who.Brain.PushGoal(new ReequipOrFindNew(what)); } else { - who.pBrain.PushGoal(new EquipObject(what)); + who.Brain.PushGoal(new EquipObject(what)); } } } @@ -136,4 +128,4 @@ static IEnumerable Transpiler(IEnumerable inst return codes; } } -} \ No newline at end of file +} diff --git a/Equip/EquipObject.cs b/Equip/EquipObject.cs index 0bda96c..764c0d0 100644 --- a/Equip/EquipObject.cs +++ b/Equip/EquipObject.cs @@ -35,7 +35,7 @@ public override bool CanFight() public override bool Finished() { - return GameObject.validate(targetObject) && ParentObject.Contains(targetObject); + return GameObject.Validate(targetObject) && ParentObject.Contains(targetObject); } private void DoFail() @@ -54,7 +54,7 @@ protected virtual void OnFail() public override void TakeAction() { - if (!GameObject.validate(targetObject)) + if (!GameObject.Validate(targetObject)) { Think($"What I was trying to equip no longer exists!"); DoFail(); @@ -105,4 +105,4 @@ public override void TakeAction() } } } -} \ No newline at end of file +} diff --git a/Equip/SearchForWeapon.cs b/Equip/SearchForWeapon.cs index fbe681b..2547d5e 100644 --- a/Equip/SearchForWeapon.cs +++ b/Equip/SearchForWeapon.cs @@ -46,7 +46,7 @@ public override void TakeAction() } int searchRadius = XRL.Rules.Stat.Random(ParentBrain.MinKillRadius, ParentBrain.MaxKillRadius); - List equipCandidates = CurrentZone.FastFloodVisibility(CurrentCell.X, CurrentCell.Y, searchRadius, searchPart, ParentObject).Where(GO => GO.CurrentCell != null && GO.IsTakeable() && CurrentCell.PathDistanceTo(GO.CurrentCell.location) <= searchRadius && scorerPredicate(GO) > maxScore).OrderByDescending(scorerPredicate).ToList(); + List equipCandidates = CurrentZone.FastFloodVisibility(CurrentCell.X, CurrentCell.Y, searchRadius, searchPart, ParentObject).Where(GO => GO.CurrentCell != null && GO.IsTakeable() && CurrentCell.PathDistanceTo(GO.CurrentCell.Location) <= searchRadius && scorerPredicate(GO) > maxScore).OrderByDescending(scorerPredicate).ToList(); if (equipCandidates.Count() <= 0) { ParentBrain.DoReequip = true; @@ -56,4 +56,4 @@ public override void TakeAction() ParentBrain.PushGoal(new EquipObject(equipCandidates.First())); // if we don't get it, don't search again. } } -} \ No newline at end of file +} diff --git a/SmartUse/FiringConePatch.cs b/SmartUse/FiringConePatch.cs index bc83d17..2fd2158 100644 --- a/SmartUse/FiringConePatch.cs +++ b/SmartUse/FiringConePatch.cs @@ -34,7 +34,7 @@ public static class FiringConePatch static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { var codes = new List(instructions); - LocalBuilder local10 = (LocalBuilder) codes.Find(x => x.opcode == OpCodes.Ldloc_S && ((LocalBuilder)x.operand).LocalIndex == (byte) 10).operand; + LocalBuilder local9 = (LocalBuilder) codes.Find(x => x.opcode == OpCodes.Ldloc_S && ((LocalBuilder)x.operand).LocalIndex == (byte) 9).operand; int callidx = codes.FindIndex(x => x.Calls(AccessTools.Method(typeof(Zone), "Line"))); int startidx = callidx - 8; if (callidx == -1) @@ -43,15 +43,16 @@ static IEnumerable Transpiler(IEnumerable inst } codes[callidx] = CodeInstruction.Call(typeof(FiringConePatch), nameof(GetFiringCone)); // ldarg.0; call get ParentObject - // ldloc.0; - // ldloc.s 10 + // ldarg.0; call get Target + // ldloc.s 9 // List