Dancer_A

AI Ignore (ASMC)

May 5th, 2025 (edited)
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.24 KB | None | 0 0
  1. ## AI Ignore (ASMC)
  2. ## Credit to gooseish & Ryn
  3.  
  4. ## Event_Processor_Commands.cs
  5. ## New ASMC case
  6. ## Place within the command value section inside of command_custom()
  7. ## line ~2842
  8.                 case "AI Ignore":
  9.                     #region Have the AI not acknowledge a specific unit
  10.                     // Value[1] = id
  11.                     // Value[2] = ignored unit id
  12.                     int ignorer_id = process_unit_id(command.Value[1]);
  13.                     int ignored_id = process_unit_id(command.Value[2]);
  14.  
  15.                     Game_Unit ignorer_unit = null;
  16.                     if (ignorer_id == -1)
  17.                         if (Global.game_map.last_added_unit != null)
  18.                             ignorer_unit = Global.game_map.last_added_unit;
  19.                     if (Global.game_map.units.ContainsKey(ignorer_id))
  20.                         ignorer_unit = Global.game_map.units[ignorer_id];
  21.                     if (ignorer_unit != null)
  22.                         ignorer_unit.new_ai_ignore = ignored_id;
  23.  
  24.                     break;
  25.                     #endregion
  26.  
  27. ## Game_Unit.cs
  28. ## New property of Game_unit
  29. ## place in between 'protected int Mission = 0, Ai_Mission = 2;' and 'protected bool Dead = false;'
  30. ## line ~42
  31.         protected List<int> Ai_Ignore = new List<int> { -1 };
  32. ## Add new writer within Serialization
  33. ## place after writer.Write(Ai_Mission); within public void write(BinaryWriter writer)
  34. ## line ~108
  35.     Ai_Ignore.write(writer);
  36. ## add new reader within Serialization
  37. ## place after Ai_Mission = reader.ReadInt32(); within public void read(BinaryWriter reader)
  38. ## line ~162
  39.     Ai_Ignore.read(reader);
  40. ## create new method
  41. ## place after full_ai_mission method
  42. ## line ~368
  43.         public bool ai_ignores (int id)
  44.         {
  45.             return Ai_Ignore.Contains(id);
  46.         }
  47.         public int new_ai_ignore
  48.         {
  49.             set
  50.             {
  51.                 Ai_Ignore.Add(value);
  52.             }
  53.         }
  54.  
  55. ## Game_AI.cs
  56. ## within Regular Weapons region
  57. ## add two if checks
  58. ## line ~189
  59.                         #region Regular Weapons
  60.                         if (weapon_index != Global.ActorConfig.NumItems)
  61.                         {
  62.                             if (!attacker.ai_ignores(targetId)) //change this to just check if the target's id is not in the list of targets to ignore <-- new
  63.                             {
  64.                                 targetUses = check_target(
  65.                                 attacker, targetUnit, can_move, best, retreating,
  66.                                 damage_test, retreat_loc, weapon_index);
  67.                             }
  68.  
  69.                         }
  70.                         #endregion
  71.                         #region Siege Weapons
  72.                         else
  73.                         {
  74.                             if (!attacker.ai_ignores(targetId)) //change this to just check if the target's id is not in the list of targets to ignore <-- new
  75.                             {
  76.                                 targetUses = check_siege_target(
  77.                                 attacker, targetUnit, can_move, best,
  78.                                 damage_test, weapon_index);
  79.                             }
  80.                         }
  81.                         #endregion
Advertisement
Add Comment
Please, Sign In to add comment