OSP Code QoL Framework to assign traits to troops for uniqueness and variety.

troycall

Squire
WB
Best answers
0
Perhaps something interesting could come out of this code.
Have you ever wanted your troops to have varying health, speed & damage potentional? well now you can!

Code:
		("assign_traits",  #Call this script in module_mission_templates with ti_once.
		#This script assigns one of two traits to each troop, with varying effects on each assignment, the trait will either be helpful or a burden to the troop, of course this is just a framework and you can use it to extend to whatever you want.
		[
		(eq,  "$traits_enabled", 1), #Make sure to add: (assign,  "$traits_enabled", 1) to game_start script.
		(mission_tpl_are_all_agents_spawned),
		(get_player_agent_no, ":agent_player"),
	    (try_for_agents,":agent"), #Check for all agents, this isn't necessary if triggering this  script when hit, rather than scanning every once in a while.
	    (neq, ":agent", -1), #Agent is actually an agent
		(neq, ":agent", ":agent_player"), # (OPTIONAL) Agent is not a player
		(agent_is_alive, ":agent"),
		(agent_is_human, ":agent"),	
		(agent_is_active, ":agent"),
		(store_agent_hit_points, ":hp", ":agent", 0),
		#Randomize % values
		(store_random_in_range, ":damage_change", 0, 26),
		(store_random_in_range, ":speed_change", 0, 26),
		(store_random_in_range, ":type_of_trait", 0, 2),
		#(store_random_in_range, ":health_change", 1, 10), #Optional health variance, be sure to uncomment all the health variances if you uncomment this line. should troops start with variable health?
		(try_begin),
		(eq, ":type_of_trait", 0), #Positive trait
		(val_add, ":damage_change", ":hp"),
		(val_add, ":speed_change", ":hp"),
		(agent_set_speed_modifier, ":agent", ":speed_change"), 
		(agent_set_damage_modifier, ":agent", ":damage_change"),
		(else_try),
		(eq, ":type_of_trait", 1), #Negative trait
		(assign, ":hp_damage_var", ":hp"),
		(assign, ":hp_speed_var", ":hp"),
		(val_sub, ":hp_damage_var", ":damage_change"),
		(val_sub, ":hp_speed_var", ":speed_change"),
		(agent_set_speed_modifier, ":agent", ":hp_speed_var"), 
		(agent_set_damage_modifier, ":agent", ":hp_damage_var"),
		(try_end),
		]),
 

Iron Sight

Sergeant
Best answers
0
This is something that I was thinking about doing recently. Should save a lot of time, and that stuff is precious, like your generosity. Thanks for sharing.