jik
Knight
Since the mod I am working on has troops that are for various "jobs", I have been manually spawning the troops to the scenes. The first round works find, but it seems that if I have wounded, they are counted twice when adding the troops to the scene. Here is the code I am using:
I have bolded the section that I added to manage this, but it doesn't seem to be working right. I start with 5 fighters, and wound them all at the end of the first round. At the start of the second round, I have 10 fighters! If I exit out, I'm back down to 5 fighters. Any ideas anyone?
##script_search_party
##Called before jumping into the mission_template
##Input : The party searching, but will mostly be the player party; Max troops that can be at the scene, default/max is 40
##Output: Sets up the visitor slots for the search team, up to 20 fighting members per entry point.
("search_party",
[(store_script_param,":cur_party",1),
(store_script_param,":max_troops",2),
(try_for_range,":search_slot",scav_start,fighter_start),
(party_set_slot,"p_bus",":search_slot",0), ##reset the locator troop numbers in the scene
(try_end),
(try_begin),
(this_or_next|gt,":max_troops",40),
(lt,":max_troops",1),
(assign, ":max_troops",40), ##Set the default
(try_end),
(party_get_num_companion_stacks,":stacks",":cur_party"),
(val_add,":stacks",1), ##Make sure to get the last stack
(try_for_range, ":cur_stack",1,":stacks"), ##Loop through the stacks
(gt, ":max_troops",0), ##loop as long as there is space left
(party_stack_get_troop_id,":this_troop",":cur_party",":cur_stack"),
(party_stack_get_size,":troop_count",":cur_party",":cur_stack"), ##get the number of troops in the current stack
(party_stack_get_num_wounded,":wounded",":cur_party",":cur_stack"), ##Need to skip wounded, or they are counted twice!
(val_sub, ":troop_count",":wounded"), ##:wounded will be subtracted from the total that will be used
(gt,":troop_count", 0), ##there has to be at least 1 to continue
(try_begin),###Fighters
(is_between,":this_troop","trp_fighter","trp_tinker"), ##trp_tinker is after last of the fighting troops
(val_min, ":troop_count",":max_troops"), ##Don't go over the max number
(val_sub, ":max_troops",":troop_count"),
#(party_remove_members,":cur_party",":this_troop",":troop_count"), ##Don't remove them here
##Need to check who survives and remove casualties from the stack at the end
(store_random_in_range,":spot",1,5), ##Set entry points before starting mission
(set_visitors,":spot",":this_troop",":troop_count"),
(else_try),###Searchers
(eq,":this_troop","trp_scavenger"),
(party_set_slot,"p_bus",scav_start,":troop_count"),
(else_try),
(eq,":this_troop","trp_searcher"),
(party_set_slot,"p_bus",sear_start,":troop_count"),
(else_try),
(eq,":this_troop","trp_locator"),
(party_set_slot,"p_bus",loca_start,":troop_count"),
(try_end),
(try_end),
]
),
##Called before jumping into the mission_template
##Input : The party searching, but will mostly be the player party; Max troops that can be at the scene, default/max is 40
##Output: Sets up the visitor slots for the search team, up to 20 fighting members per entry point.
("search_party",
[(store_script_param,":cur_party",1),
(store_script_param,":max_troops",2),
(try_for_range,":search_slot",scav_start,fighter_start),
(party_set_slot,"p_bus",":search_slot",0), ##reset the locator troop numbers in the scene
(try_end),
(try_begin),
(this_or_next|gt,":max_troops",40),
(lt,":max_troops",1),
(assign, ":max_troops",40), ##Set the default
(try_end),
(party_get_num_companion_stacks,":stacks",":cur_party"),
(val_add,":stacks",1), ##Make sure to get the last stack
(try_for_range, ":cur_stack",1,":stacks"), ##Loop through the stacks
(gt, ":max_troops",0), ##loop as long as there is space left
(party_stack_get_troop_id,":this_troop",":cur_party",":cur_stack"),
(party_stack_get_size,":troop_count",":cur_party",":cur_stack"), ##get the number of troops in the current stack
(party_stack_get_num_wounded,":wounded",":cur_party",":cur_stack"), ##Need to skip wounded, or they are counted twice!
(val_sub, ":troop_count",":wounded"), ##:wounded will be subtracted from the total that will be used
(gt,":troop_count", 0), ##there has to be at least 1 to continue
(try_begin),###Fighters
(is_between,":this_troop","trp_fighter","trp_tinker"), ##trp_tinker is after last of the fighting troops
(val_min, ":troop_count",":max_troops"), ##Don't go over the max number
(val_sub, ":max_troops",":troop_count"),
#(party_remove_members,":cur_party",":this_troop",":troop_count"), ##Don't remove them here
##Need to check who survives and remove casualties from the stack at the end
(store_random_in_range,":spot",1,5), ##Set entry points before starting mission
(set_visitors,":spot",":this_troop",":troop_count"),
(else_try),###Searchers
(eq,":this_troop","trp_scavenger"),
(party_set_slot,"p_bus",scav_start,":troop_count"),
(else_try),
(eq,":this_troop","trp_searcher"),
(party_set_slot,"p_bus",sear_start,":troop_count"),
(else_try),
(eq,":this_troop","trp_locator"),
(party_set_slot,"p_bus",loca_start,":troop_count"),
(try_end),
(try_end),
]
),
I have bolded the section that I added to manage this, but it doesn't seem to be working right. I start with 5 fighters, and wound them all at the end of the first round. At the start of the second round, I have 10 fighters! If I exit out, I'm back down to 5 fighters. Any ideas anyone?