OSP LSP Combat Extra Building: Ammo distribution

Users who are viewing this thread

So my mod, For Rome, works with approximatly 20 unique new buildings, and i thought it would be nice to share at least one of them.
So here we go, its the ammo distribution centre building, so what this basicly means is that you can set up an ammo distribution centre and based upon the level of this building defenders will get an ammo refill more quick or slow.

This mod might not have a real impact on archery, as the refill time not really mathers when you have 31 projectiles, however my mod works around roman legionaires and refill time of their pilums actually makes an difference on the battlefield.

Module mission templates
Replace common_siege_refill_ammo with
Code:
common_siege_refill_ammo = (
  15, 0, 0, [],
  [#refill ammo of defenders every two minutes.
	(try_begin),
		(party_slot_eq, "$g_encountered_party", slot_center_has_ammodis, 1),
		(val_add, "$refill", 4), #every 45 seconds
	(else_try),
		(party_slot_eq, "$g_encountered_party", slot_center_has_ammodis, 2),
		(val_add, "$refill", 6), #every 30 seconds
	(else_try),
		(party_slot_eq, "$g_encountered_party", slot_center_has_ammodis, 3),
		(val_add, "$refill", 12),#every 15 seconds
	(else_try),
		(val_add, "$refill", 3), #every 60 seconds
	(try_end),
	(eq, "$refill", 12),
	(assign, "$refill", 0), #so default refill time is 60 seconds
    (try_for_agents,":cur_agent"),
      (agent_is_alive, ":cur_agent"),
      (agent_is_human, ":cur_agent"),
      (agent_get_team, ":agent_team", ":cur_agent"),
      (this_or_next|eq, ":agent_team", "$defender_team"),
      (eq, ":agent_team", "$defender_team_2"),
      (agent_refill_ammo, ":cur_agent"),
    (try_end),
    ])

then
find a ti_once thats used everywhere and add the following code to it
Code:
(assign, "$refill", 0),

module game menus
Search for:
Code:
"Build a prisoner tower.",[(assign, "$g_improvement_type", slot_center_has_prisoner_tower),
                                  (jump_to_menu, "mnu_center_improve"),]),
And after this add
Code:
#building 18: ammo distribution
	   ("center_build_ammodis1",
	   [
	   (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
	   (party_slot_eq, "$g_encountered_party", slot_center_has_ammodis, 0),
	   (store_troop_gold, ":gold", "trp_player"),
	   (ge, ":gold", 1250),
       ],
       "Build an ammo distribution to distribute new ammo more quickly",
	   [
	   (party_set_slot, "$g_encountered_party", slot_center_has_ammodis, 1),
	   (troop_remove_gold, "trp_player", 1250),
	   ]),
	   
	   ("center_build_ammodis2",
	   [
	   (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
	   (party_slot_eq, "$g_encountered_party", slot_center_has_ammodis, 1),
	   (store_troop_gold, ":gold", "trp_player"),
	   (ge, ":gold", 1250),
       ],
       "Expand the ammo distribution to distribute new ammo more quickly",
	   [
	   (party_set_slot, "$g_encountered_party", slot_center_has_ammodis, 2),
	   (troop_remove_gold, "trp_player", 1250),
	   ]),
	   
	   ("center_build_ammodis3",
	   [
	   (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
	   (party_slot_eq, "$g_encountered_party", slot_center_has_ammodis, 2),
	   (store_troop_gold, ":gold", "trp_player"),
	   (ge, ":gold", 2250),
       ],
       "Build an huge ammo distribution network to distribute new ammo more quickly",
	   [
	   (party_set_slot, "$g_encountered_party", slot_center_has_ammodis, 3),
	   (troop_remove_gold, "trp_player", 2250),
	   ]),

Module constants
find  slot_center_has_prisoner_tower  = 135 #town, castle
then after this add
Code:
slot_center_has_ammodis             = 143

Optional - cool pre battle notification
put this after your assign point of refill
Code:
		(try_begin),
			(party_slot_gt, "$g_encountered_party", slot_center_has_ammodis, 0),
			(party_get_slot, ":slot", "$g_encountered_party", slot_center_has_ammodis),
			(assign, reg4, ":slot"),
			(display_message, "@Ammo distribution level: {reg4} is present, defenders will have faster ammo refills",0xe72c12), 
		(try_end),

optional 2: give archery a reload speed bonus
in module mission templates
Code:
building_effects_init = (
  ti_on_agent_spawn, 0, 0, 
  [
	(store_trigger_param_1, ":agent"),
	(agent_is_human, ":agent"),
	],
  
  [
      (store_trigger_param_1, ":agent"),
      (agent_is_human, ":agent"),
      (agent_get_troop_id, ":troop_id", ":agent"),
      (agent_get_team, ":team", ":agent"),
      (eq, ":team", 2), #2 = defender team
                (assign, ":modifier1", 100),
		(try_begin),
			(party_slot_eq, "$g_encountered_party", slot_center_has_ammodis, 1), 
			(val_add, ":modifier1", 5),
		(else_try),
			(party_slot_eq, "$g_encountered_party", slot_center_has_ammodis, 2), 
			(val_add, ":modifier1", 10),
		(else_try),
			(party_slot_eq, "$g_encountered_party", slot_center_has_ammodis, 3), #we work with val_add instead of assign becase more buildings are able to influence reload speed in the mod
			(val_add, ":modifier1", 15),
		(try_end),
		(agent_set_reload_speed_modifier, ":agent", ":modifier1"),
  ])
 
Back
Top Bottom