Advertisement
PastebinnerMKII

Dickplomacy Reloaded lance fix

Sep 26th, 2018
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. lance_usage = [
  2. # LANCE USAGE BEGIN
  3. # Force mounted NPCs to switch to their lance. This is called once at the
  4. # start of the battle. If you want lancers to ALWAYS use lances on horseback,
  5. # replace ti_once with 1. Otherwise they may switch to sword if bogged down
  6. (0, 0, 5, [],
  7. [
  8. # Run through all active NPCs on the battle field.
  9. #(display_message, "@DEBUG -- lance usage"),
  10. #(eq, 0,1),
  11. (get_player_agent_no, ":p_agent"),
  12. (try_for_agents, ":agent"),
  13. # Isn't a horse.
  14. (agent_is_human, ":agent"),
  15. # Isn't a player.
  16. #(agent_is_non_player, ":agent"),
  17. (neq, ":p_agent", ":agent"),
  18. (agent_slot_eq, ":agent", slot_possessed, 0), #not a player spawn
  19. # Hasn't been defeated.
  20. (agent_is_alive, ":agent"),
  21. # They riding a horse?
  22. (agent_get_horse, ":horse", ":agent"),
  23. # Is riding a horse.
  24. #(gt, ":horse", 0), #TOM SPEAR
  25. (agent_slot_eq, ":agent", slot_agent_is_running_away, 0), #Isn't routing.
  26. (agent_get_troop_id, ":troop_id", ":agent"),
  27. (agent_get_ammo, ":ammo_left", ":agent"),
  28. (le, ":ammo_left", 0),
  29. #(store_troop_faction, ":troop_faction", ":troop_id"),
  30. (try_begin),
  31. (gt, ":horse", 0), #Mounted
  32. (neg | troop_is_guarantee_ranged, ":troop_id"),
  33. # Get wielded item.
  34. (agent_get_wielded_item, ":wielded", ":agent", 0),
  35. # Is it a lance?
  36. (neg|is_between, ":wielded", "itm_light_lance","itm_spear_a"), # adjust as needed
  37. # Force the NPC to wield the lance, but this will only happen if they
  38. # actually have a lance in their inventory. Otherwise this does
  39. # nothing.
  40. (try_for_range,":item","itm_light_lance","itm_spear_a"), # adjust as needed
  41. (agent_set_wielded_item, ":agent", ":item"),
  42. (try_end),
  43. (else_try), #WIELD FLAG
  44. (eq, "$tom_use_banners", 1),
  45. (try_for_range,":item",itm_flag_pole_1,itm_cross +1), # adjust as needed
  46. (agent_set_wielded_item, ":agent", ":item"),
  47. (try_end),
  48. (agent_get_wielded_item, ":item", ":agent", 0),
  49. (is_between, ":item", itm_flag_pole_1, itm_cross + 1),
  50. (else_try),#no lance on foot
  51. (neg | troop_is_guarantee_ranged, ":troop_id"),
  52. (le, ":horse", 0),
  53. (agent_get_wielded_item, ":wielded", ":agent", 0),
  54. (is_between, ":wielded", "itm_light_lance","itm_spear_a"),
  55. (try_for_range, reg0, 0, 4),
  56. (agent_get_item_slot, ":item", ":agent", reg0),
  57. (is_between, ":item", 1, "itm_items_end"),
  58. #(gt, ":item", 0),
  59. (neg|is_between, ":item", "itm_light_lance","itm_bamboo_spear"),
  60. (item_get_type, ":item_type", ":item"),
  61. (this_or_next|eq, ":item_type", itp_type_two_handed_wpn),
  62. (this_or_next|eq, ":item_type", itp_type_polearm),
  63. (eq, ":item_type", itp_type_one_handed_wpn),
  64. (agent_set_wielded_item, ":agent", ":item"),
  65. (try_end),
  66. (else_try), #TOM - SPEAR USSAGE
  67. (neg | troop_is_guarantee_ranged, ":troop_id"),
  68. #(agent_get_horse, ":horse", ":agent"),
  69. (le, ":horse", 0), #unmounted
  70. (agent_get_wielded_item, ":wielded", ":agent", 0),
  71. (neg|is_between, ":wielded", "itm_bamboo_spear","itm_wooden_shield"),
  72. #(neg|is_between, ":wielded", "itm_flag_pole_1","itm_items_end"), #not a flag
  73. (try_for_range,":item","itm_bamboo_spear","itm_wooden_shield"), # adjust as needed
  74. #(gt, ":item", 0),
  75. #(agent_equip_item, ":agent", ":item"),
  76. (agent_set_wielded_item, ":agent", ":item"),
  77. (try_end),
  78. (else_try), #tom - range usage
  79. (troop_is_guarantee_ranged, ":troop_id"),
  80.  
  81. (agent_get_team, ":team", ":agent"),
  82. (agent_get_division, ":division", ":agent"),
  83.  
  84. (team_get_hold_fire_order, ":order", ":team", ":division"),
  85. (neq, ":order", 1), #mordr_hold_fire
  86.  
  87. #(gt, ":wielded", 0),
  88. (is_between, ":wielded", 1, "itm_items_end"),
  89. (item_get_type, ":type", ":wielded"),
  90. (this_or_next|le, ":wielded", -1),
  91. (this_or_next|neq, ":type", itp_type_thrown),
  92. (this_or_next|neq, ":type", itp_type_crossbow),
  93. (neq, ":type", itp_type_bow),
  94.  
  95. (call_script, "script_get_closest_enemy_distance_new", ":agent", ":team", 300),
  96. (assign, ":nearest_enemy", reg1),
  97. (gt, ":nearest_enemy", 300), #7meters.
  98.  
  99. (assign, ":top", 4),
  100. (try_for_range, reg0, 0, ":top"),
  101. (agent_get_item_slot, ":item_no", ":agent", reg0),
  102. (is_between, ":item_no", 1, "itm_items_end"),
  103. #(gt, ":item_no", 0),
  104.  
  105. (item_get_type, ":type", ":item_no"),
  106. (this_or_next|eq, ":type", itp_type_thrown),
  107. (this_or_next|eq, ":type", itp_type_bow),
  108. (eq, ":type", itp_type_crossbow),
  109.  
  110. (agent_set_wielded_item, ":agent", ":item_no"),
  111. (assign, ":top", -1),
  112. (try_end),
  113. (try_end),
  114. (try_end),
  115. ]),
  116. ]
  117. # LANCE USAGE END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement