I'm trying to add a scripted siege defence event, but I'm struggling to understand exactly how sieges are setup in the game and how the attacking and defending teams are decided. This code, for example, sets up and runs a siege, but I don't know where in mt_castle_attack_walls_ladder the game decides which parties to use as attackers and which to use as defenders.
I assumed that it had something to do with p_collective_ally and p_collective_enemy at first, but that appears to only be used for battle simulation. Where exactly are attackers and defenders decided?
Code:
("test_defence_battle",0,
"The forces of the placeholders are attacking the stronghold.",
"none",
[],
[
("test_defend",
[],
"Lead your soldiers in the defence.",
[
(assign, ":battle_scene", "scn_test_capital_walls"),
(call_script, "script_calculate_renown_value"),
(call_script, "script_calculate_battle_advantage"),
(assign, ":battle_advantage", reg0),
(val_mul, ":battle_advantage", 2),
(val_div, ":battle_advantage", 3), #scale down the advantage a bit in sieges.
(set_battle_advantage, ":battle_advantage"),
(set_party_battle_mode),
(assign, "$g_siege_battle_state", 1),
(set_jump_mission,"mt_castle_attack_walls_ladder"),
(assign, "$cant_talk_to_enemy", 0),
(assign, "$g_siege_final_menu", "mnu_castle_besiege"),
(try_begin),
(call_script, "script_party_count_members_with_full_health","$g_encountered_party"),
(le, reg0, 0), #(TODO : compare with num_routed_enemies)
(assign, "$g_next_menu", "mnu_test_stronghold"),
(else_try),
(assign, "$g_next_menu", "mnu_test_defence_battle"),
(try_end),
(assign, "$g_siege_method", 0), #reset siege timer
(jump_to_scene,":battle_scene"),
(jump_to_menu, "mnu_battle_debrief"),
(change_screen_mission),
]),
]
),