Sorry, Colt, for for breaking your monopoly.
The formation code:
in module_scripts:
========================
("formation_start",
[(get_player_agent_no,reg(10)),
(agent_get_position,1,reg(10)),
(try_for_range,reg(20),1,100), #reset of the player dummy-slots
(agent_set_slot,reg(10),reg(20),0),
(try_end),
(try_for_agents,reg(5)),
(assign,reg(0),0),
#Not the player
(neq, reg(5), reg(10)),
#Not Dead
(agent_is_alive, reg(5)),
#Not a Horse?
(agent_is_human, reg(5)),
#If the Selected Troop is an Ally
(agent_is_ally,reg(5)),
(assign,reg(1),1),
(try_begin),
(assign,reg(20),1), #reg(20) is the agent number to use every position only once
(agent_get_slot,reg(21),reg(10),reg(20)), #player agent used as a dummy not to make several agent use one position
(eq,reg(21),0), #number isn't used, yet
(assign,reg(1),reg(20)),
(assign,reg(3),reg(1)),
(val_mul,reg(3),
100),
(copy_position,reg(1),1),
(position_move_x,reg(1),reg(3)), #number 1 = 100 metres right to the player agent 2= 200 etc...
(agent_set_scripted_destination,reg(5),reg(1)), #tells the agent to run there
(agent_set_slot,reg(5),1,reg(1)), #tells the agent which position he has - only important if you want to do somethink else with the script, it would work without it right now.
(agent_set_slot,reg(10),reg(20),1), #tells the game that the number is used, by using the player slots.
(else_try),
#very odd, sorry (the more call_scripts are there \/, the more agents will build a formation
(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),
(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),
(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),
(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),
(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),
(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),
(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),
(try_end),
(try_end),
]),
("formation_repeat",
[ (val_add,reg(20),1), # adds 1 to the agent number
(agent_get_slot,reg(21),reg(10),reg(20)),
(eq,reg(21),0), # again, is the number already used?
(assign,reg(1),reg(20)), #just copying the number to use it somewhere else...
(assign,reg(3),reg(1)), #again copying
(assign,reg(4),0), #assigns the row of this agent to 0
#-#-#-#-#-#-#-#-#-#
(try_for_range,reg(15),1,100), #this try-code assigns the right row.
(assign,reg(17),reg(15)),
(assign,reg(16),reg(15)),
(val_mul,reg(15),
5), #number of troops in one line
(val_mul,reg(16),
5), #has to be the same as above
(val_add,reg(16),
5), #has to be the same as above
(gt,reg(3),reg(15)),
(le,reg(3),reg(16)),
(assign,reg(15),reg(17)),
(val_mul,reg(15),
6), #number of troops in one line + 1
(val_sub,reg(3),reg(15)),
(assign,reg(4),reg(17)),
(try_end),
#delete these lines to get a 1 line formation
#-#-#-#-#-#-#-#-#-#
(val_mul,reg(3),
100),
(val_mul,reg(4),
200),
(copy_position,reg(1),1),
(position_move_x,reg(1),reg(3)),
(position_move_y,reg(1),reg(4)),
(agent_set_scripted_destination,reg(5),reg(1)),
(agent_set_slot,reg(5),1,reg(1)),
(agent_set_slot,reg(10),reg(20),1),
]),
========================
100 is the distance between the agents from right to left,
200 is the distance between the agents from the front to background
how to use:
add [(ti_on_weapon_attack,[(call_script,"script_formation_start")])] to the weapon that should cause the formation
!Don't change the distance to less than 70 in a line formation, less than 100 otherwise! The guys will build the formation after weapon attack on your right hand site. The max. number of agents is 40 right now.
Everyone feel free to use it, would be nice if I get credit.
Screenshot? Here you go: