Skip to content

Commit

Permalink
*Fixes to WIP Quests + Siege MT Changes
Browse files Browse the repository at this point in the history
- Make sure that archers are not affected by trigger_reinforcement_scripted_destination
- Added code to check that if chokepoints are taken, don't script destination.
  • Loading branch information
khamukkamu committed Oct 18, 2017
1 parent e4f5603 commit aa6c802
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 100 deletions.
21 changes: 16 additions & 5 deletions ModuleSystem/module_dialogs.py
Expand Up @@ -2656,7 +2656,9 @@
## Defend Refugees Completion Dialogues - Kham

[anyone,"lord_start", [(check_quest_active,"qst_blank_quest_01"),
(check_quest_succeeded, "qst_blank_quest_01")],
(check_quest_succeeded, "qst_blank_quest_01"),
(quest_get_slot, ":quest_giver", "qst_blank_quest_01", slot_quest_giver_troop),
(eq, ":quest_giver", "$g_talk_troop"),],
"I have received reports that all refugees were safely escorted. We thank you {playername} for your help. In this war, it is the innocent that suffer the most.", "lord_generic_mission_completed",
[(call_script, "script_finish_quest", "qst_blank_quest_01", 100),
(assign, reg18, "$qst_raider_party_defeated"),
Expand All @@ -2671,7 +2673,9 @@
(faction_set_slot,":faction",slot_faction_strength_tmp,":enemy_strength"), ]],

[anyone,"lord_start", [ (check_quest_active,"qst_blank_quest_01"),
(check_quest_failed, "qst_blank_quest_01"),],
(check_quest_failed, "qst_blank_quest_01"),
(quest_get_slot, ":quest_giver", "qst_blank_quest_01", slot_quest_giver_troop),
(eq, ":quest_giver", "$g_talk_troop"),],
"{playername}, I have received reports that the refugees were intercepted by raiders and were all slaughtered. This is very disappointing...", "lord_defend_refugees_failed", []],

[anyone|plyr,"lord_defend_refugees_failed", [(str_store_troop_name, s65, "$g_talk_troop")],
Expand All @@ -2696,6 +2700,8 @@

[anyone,"lord_start", [(check_quest_active,"qst_blank_quest_01"),
(check_quest_concluded, "qst_blank_quest_01"),
(quest_get_slot, ":quest_giver", "qst_blank_quest_01", slot_quest_giver_troop),
(eq, ":quest_giver", "$g_talk_troop"),
(assign, reg17, "$qst_refugees_escaped")],
"I have received reports that only {reg17} refugee trains reached their destination. This is unfortunate, but that is the cost of war. There will be more events such as these, {playername}. I hope you are more prepared next time.", "lord_defend_refugees_half_completed",
[(store_mul, ":completion", "$qst_refugees_escaped", 100),
Expand Down Expand Up @@ -2724,7 +2730,9 @@
## Hunt Down Refugees Completion Dialogues - Kham

[anyone,"lord_start", [(check_quest_active,"qst_blank_quest_02"),
(check_quest_succeeded, "qst_blank_quest_02")],
(check_quest_succeeded, "qst_blank_quest_02"),
(quest_get_slot, ":quest_giver", "qst_blank_quest_02", slot_quest_giver_troop),
(eq, ":quest_giver", "$g_talk_troop")],
"I have received reports that the refugees were all killed, and that prisoner trains will be coming soon... You did well, {playername}. This is only the beginning, we shall rule over this land soon enough.", "lord_generic_mission_completed",
[(call_script, "script_finish_quest", "qst_blank_quest_02", 100),
(call_script, "script_cf_get_random_enemy_center_in_theater","p_main_party"),
Expand All @@ -2736,8 +2744,11 @@
(faction_set_slot,":faction",slot_faction_strength_tmp,":enemy_strength"), ]],

[anyone,"lord_start", [ (check_quest_active,"qst_blank_quest_02"),
(check_quest_failed, "qst_blank_quest_02"),],
"{playername}, our spies tell us that you failed in intercepting all of the refugee trains. They are weak and slow, and still you fail. What use are you?", "lord_hunt_refugees_failed", []],
(check_quest_failed, "qst_blank_quest_02"),
(quest_get_slot, ":quest_giver", "qst_blank_quest_02", slot_quest_giver_troop),
(eq, ":quest_giver", "$g_talk_troop"),
(assign, reg1, "$qst_refugees_escaped")],
"{playername}, our spies tell us that you failed to intercept {reg1} of the refugee trains. They are weak and slow, and still you fail. What use are you?", "lord_hunt_refugees_failed", []],

[anyone|plyr,"lord_hunt_refugees_failed", [(str_store_troop_name, s65, "$g_talk_troop")],
"They were slippery, {s65}. I was unable to track them down.", "lord_hunt_refugees_failed_1", []],
Expand Down
114 changes: 70 additions & 44 deletions ModuleSystem/module_mission_templates.py
Expand Up @@ -3053,7 +3053,7 @@
(finish_mission,0),
]),

## This block starts the commands of both attackers and defenders at the beginning of battle.
## This block starts the commands of both attackers and defenders at the beginning of battle. (trigger_initial_commands)
## Both Attackers & Defenders are asked to move towards Entry Point 41, 42, 43
## Attacker Archers are asked to HOLD at entry point 60,61,62.
## I added Siege order exception (charge) to attackers for Umbar Camp, so that they do not get stuck on boats.
Expand Down Expand Up @@ -3099,7 +3099,7 @@

## End of Starting Orders Block ##

## Reinforcement Scripted destinations
## Reinforcement Scripted destinations (trigger_reinforcement_scripted_destination)
## I added this block so that reinforcements still try to take the flanks or the center (as above).
## We set a scripted destination for the agents, and after a few seconds, clear it, when they are close to their destination.
## We are using the slot_agent_is_not_reinforcement as a tracker.
Expand All @@ -3108,53 +3108,74 @@

#(display_message, "@Scripting reinforcement destinations"),
(store_trigger_param_1, ":agent_no"),
(neq, ":agent_no", "$gate_aggravator_agent"),
(agent_is_human, ":agent_no"),
(agent_slot_eq, ":agent_no", slot_agent_is_not_reinforcement, 0),
(neq, ":agent_no", "$gate_aggravator_agent"), #We don't ask the gate aggravator to do anything :)
(agent_is_human, ":agent_no"), #neither horses
(agent_slot_eq, ":agent_no", slot_agent_is_not_reinforcement, 0), # We check if these are reinforcements, and not inital spawns
(agent_get_team, ":reinforcement_team", ":agent_no"),
(try_begin),
(eq, "$gate_breached", 1),
(store_random_in_range, ":random", 0, 100),
(le, ":random", 75), #75% Chance troop is asked to go through the portal. Other than that, go to team destinations.
(entry_point_get_position, pos10, 42),
(agent_set_scripted_destination, ":agent_no", pos10),
] + (is_a_wb_mt==1 and [
(agent_force_rethink, ":agent_no"),
] or []) + [
(agent_set_slot, ":agent_no", slot_agent_is_not_reinforcement, 42), #Kham - Use this slot to track scripted movement
# (display_message, "@Reinforcement Agent moving towards Center"),
(else_try),
(this_or_next|eq, ":reinforcement_team", 0),
( eq, ":reinforcement_team", 1),
(entry_point_get_position, pos10, 41),
(agent_set_scripted_destination, ":agent_no", pos10),
] + (is_a_wb_mt==1 and [
(agent_force_rethink, ":agent_no"),
] or []) + [
(agent_set_slot, ":agent_no", slot_agent_is_not_reinforcement, 41), #Kham - Use this slot to track scripted movement
#(display_message, "@Reinforcement Agent moving towards Left"),
(else_try),
(this_or_next|eq, ":reinforcement_team", 2),
( eq, ":reinforcement_team", 3),
(entry_point_get_position, pos10, 42),
(agent_set_scripted_destination, ":agent_no", pos10),
] + (is_a_wb_mt==1 and [
(agent_force_rethink, ":agent_no"),
] or []) + [
(agent_set_slot, ":agent_no", slot_agent_is_not_reinforcement, 42), #Kham - Use this slot to track scripted movement
#(display_message, "@Reinforcement Agent moving towards Center"),
(agent_get_class, ":agent_class", ":agent_no"),
(neq, ":agent_class", grc_archers), #Do not apply to archers

#This block here checks if chokepoints are taken (troop_slot for trp_no_troop, 0,1,2)

(try_for_range, ":slot", 0, 3),
(troop_get_slot, ":choke_point_taken", "trp_no_troop", ":slot"),
(eq, ":choke_point_taken", -1),
(team_give_order, ":reinforcement_team", mordr_charge),

#If chokepoints are not taken yet...

(else_try),
(entry_point_get_position, pos10, 43),
(agent_set_scripted_destination, ":agent_no", pos10),
] + (is_a_wb_mt==1 and [
(agent_force_rethink, ":agent_no"),
] or []) + [
(agent_set_slot, ":agent_no", slot_agent_is_not_reinforcement, 43), #Kham - Use this slot to track scripted movement
#(display_message, "@Reinforcement Agent moving towards Right"),
(eq, "$gate_breached", 1),
(store_random_in_range, ":random", 0, 100),
(le, ":random", 75), #75% Chance troop is asked to go through the portal. Other than that, go to team destinations.
(entry_point_get_position, pos10, 42),
(agent_set_scripted_destination, ":agent_no", pos10),
] + (is_a_wb_mt==1 and [
(agent_force_rethink, ":agent_no"),
] or []) + [
(agent_set_slot, ":agent_no", slot_agent_is_not_reinforcement, 42), #Kham - Use this slot to track scripted movement
# (display_message, "@Reinforcement Agent moving towards Center"),

(else_try), #If gate is not breached, and left flank not taken, move reinforcements there.
(try_begin),
(eq, ":slot", 0),
(this_or_next|eq, ":reinforcement_team", 0),
( eq, ":reinforcement_team", 1),
(entry_point_get_position, pos10, 41),
(agent_set_scripted_destination, ":agent_no", pos10),
] + (is_a_wb_mt==1 and [
(agent_force_rethink, ":agent_no"),
] or []) + [
(agent_set_slot, ":agent_no", slot_agent_is_not_reinforcement, 41), #Kham - Use this slot to track scripted movement
#(display_message, "@Reinforcement Agent moving towards Left"),

(else_try), #If gate is not breached, and right flank not taken, move reinforcements there.
(eq, ":slot", 2),
(this_or_next|eq, ":reinforcement_team", 4),
( eq, ":reinforcement_team", 5),
(entry_point_get_position, pos10, 43),
(agent_set_scripted_destination, ":agent_no", pos10),
] + (is_a_wb_mt==1 and [
(agent_force_rethink, ":agent_no"),
] or []) + [
(agent_set_slot, ":agent_no", slot_agent_is_not_reinforcement, 43), #Kham - Use this slot to track scripted movement
#(display_message, "@Reinforcement Agent moving towards Right"),

(else_try), #If gate is not breached, and center is not taken, move reinforcements there.
(this_or_next|eq, ":reinforcement_team", 2),
( eq, ":reinforcement_team", 3),
(entry_point_get_position, pos10, 42),
(agent_set_scripted_destination, ":agent_no", pos10),
] + (is_a_wb_mt==1 and [
(agent_force_rethink, ":agent_no"),
] or []) + [
(agent_set_slot, ":agent_no", slot_agent_is_not_reinforcement, 42), #Kham - Use this slot to track scripted movement
#(display_message, "@Reinforcement Agent moving towards Center"),
(try_end),
(try_end),
]),

## This is where we remove the scripted mode of the reinforcement agents.
## This is where we remove the scripted mode of the reinforcement agents. (trigger_remove_reinforcement_scripted_destinations)
(7, 0, 0, [(this_or_next|ge, "$attacker_reinforcement_stage", 1), (ge, "$defender_reinforcement_stage",1)], [

(get_player_agent_no, ":player_agent"),
Expand Down Expand Up @@ -3353,6 +3374,11 @@
(try_end),
(try_end),
]),

## This Block checks if chokepoints are taken. (trigger_check_chokepoints)
## We check the troop slot of trp_no_troop (0,1,2) which corresponds to each choke point (entry 41,42,43)
## If we find less than 2 defenders near the chokepoint, we consider that chokepoint taken and the team that is assigned to that choke point is asked to charge.

(10, 0, 0,[(store_mission_timer_a, ":mission_time"), (gt, ":mission_time", 30)], [# check if targets are captured by attackers; only fire after 30 seconds.
(try_for_range, ":slot",0,3),
(neg|troop_slot_eq,"trp_no_troop",":slot",-1), # -1 in slot means this flank defeated its choke and proceeds with charge
Expand Down
60 changes: 49 additions & 11 deletions ModuleSystem/module_scripts.py
Expand Up @@ -3966,7 +3966,7 @@ def set_item_score():
(try_end),
(else_try),
(eq, ":template_no", "pt_refugees"),
(set_trigger_result, 45),
(set_trigger_result, 55),
(else_try),
(set_trigger_result, 100),
(try_end),
Expand Down Expand Up @@ -11967,7 +11967,7 @@ def set_item_score():
(try_end),
(set_jump_mission,":mission"),
#Kham - End

(call_script, "script_jump_to_random_scene","$current_player_region","$current_player_terrain","$current_player_landmark"),
(assign, "$g_next_menu", "mnu_simple_encounter"),
(jump_to_menu, "mnu_battle_debrief"),
Expand Down Expand Up @@ -22828,16 +22828,19 @@ def set_item_score():
(is_between, "$g_encountered_party", centers_begin, centers_end),
(assign, ":giver_center_no", "$g_encountered_party"),
(try_end),
(gt, ":giver_center_no", 0),#Skip if lord is outside the center
#(gt, ":giver_center_no", 0),#Skip if lord is outside the center
(eq, "$g_defending_against_siege", 0),#Skip if the center is under siege (because of resting)

(assign, ":cur_object_center", ":giver_center_no"), #TLD: just start from the same town
(call_script, "script_cf_get_random_friendly_center_in_theater", "p_main_party",),
(assign, ":cur_target_center", reg0),
(store_faction_of_party, ":center_faction", ":cur_target_center"),
(this_or_next|neq, ":center_faction", "fac_lorien"),
(this_or_next|neq, ":center_faction", "fac_woodelf"),
( neq, ":center_faction", "fac_imladris"),
(try_begin),
(this_or_next|eq, ":center_faction", "fac_lorien"),
(this_or_next|eq, ":center_faction", "fac_woodelf"),
( eq, ":center_faction", "fac_imladris"),
(assign, ":cur_target_center", "p_town_woodsmen_village"),
(try_end),
(call_script, "script_get_tld_distance", "p_main_party", ":cur_target_center"),
(ge, reg0, 10),
(neq, ":cur_target_center", ":giver_center_no"),#Skip current center
Expand Down Expand Up @@ -22888,6 +22891,13 @@ def set_item_score():
(assign, ":guards", "pt_dale_scouts"),
(try_end),

(try_begin),
(this_or_next|eq, ":quest_target_center", "p_town_woodsmen_village"),
(this_or_next|eq, ":quest_target_center", "p_town_beorning_village"),
(eq, ":quest_target_center", "p_town_beorn_house"),
(assign, ":guards", "pt_beorn_scouts"),
(try_end),

(store_random_in_range, ":refugee_radius", 1, 5),
(set_spawn_radius, ":refugee_radius"),

Expand Down Expand Up @@ -22921,6 +22931,12 @@ def set_item_score():
(assign, "$qst_raider_party_1", reg0),
(party_add_template, "$qst_raider_party_1", ":raiders"),
(party_add_template, "$qst_raider_party_1", ":raiders"),
(try_begin),
(this_or_next|eq, ":theater", theater_SE),
( eq, ":theater", theater_SW),
(party_add_template, "$qst_raider_party_1", ":raiders"),
(party_add_template, "$qst_raider_party_1", ":raiders"),
(try_end),
(party_set_name, "$qst_raider_party_1", "@Raiders"),
(party_set_ai_behavior,"$qst_raider_party_1",ai_bhvr_attack_party),
(party_set_ai_object,"$qst_raider_party_1","$qst_refugee_party_1"),
Expand All @@ -22932,6 +22948,12 @@ def set_item_score():
(assign, "$qst_raider_party_2", reg0),
(party_add_template, "$qst_raider_party_2", ":raiders"),
(party_add_template, "$qst_raider_party_2", ":raiders"),
(try_begin),
(this_or_next|eq, ":theater", theater_SE),
( eq, ":theater", theater_SW),
(party_add_template, "$qst_raider_party_2", ":raiders"),
(party_add_template, "$qst_raider_party_2", ":raiders"),
(try_end),
(party_set_name, "$qst_raider_party_2", "@Raiders"),
(party_set_ai_behavior,"$qst_raider_party_2",ai_bhvr_attack_party),
(party_set_ai_object,"$qst_raider_party_2","$qst_refugee_party_2"),
Expand All @@ -22943,6 +22965,12 @@ def set_item_score():
(assign, "$qst_raider_party_3", reg0),
(party_add_template, "$qst_raider_party_3", ":raiders"),
(party_add_template, "$qst_raider_party_3", ":raiders"),
(try_begin),
(this_or_next|eq, ":theater", theater_SE),
( eq, ":theater", theater_SW),
(party_add_template, "$qst_raider_party_3", ":raiders"),
(party_add_template, "$qst_raider_party_3", ":raiders"),
(try_end),
(party_set_name, "$qst_raider_party_3", "@Raiders"),
(party_set_ai_behavior,"$qst_raider_party_3",ai_bhvr_attack_party),
(party_set_ai_object,"$qst_raider_party_3","$qst_refugee_party_3"),
Expand Down Expand Up @@ -22971,17 +22999,20 @@ def set_item_score():
(is_between, "$g_encountered_party", centers_begin, centers_end),
(assign, ":giver_center_no", "$g_encountered_party"),
(try_end),
(gt, ":giver_center_no", 0),#Skip if lord is outside the center
#(gt, ":giver_center_no", 0),#Skip if lord is outside the center
(neq, ":giver_center_no", "p_town_morannon"), #Morannon is too far from any fiefs.
(eq, "$g_defending_against_siege", 0),#Skip if the center is under siege (because of resting)

(assign, ":cur_object_center", ":giver_center_no"), #TLD: just start from the same town
(call_script, "script_cf_get_random_enemy_center_in_theater", "p_main_party",),
(assign, ":cur_target_center", reg0),
(store_faction_of_party, ":center_faction", ":cur_target_center"),
(this_or_next|neq, ":center_faction", "fac_lorien"),
(this_or_next|neq, ":center_faction", "fac_woodelf"),
( neq, ":center_faction", "fac_imladris"),
(try_begin),
(this_or_next|eq, ":center_faction", "fac_lorien"),
(this_or_next|eq, ":center_faction", "fac_woodelf"),
( eq, ":center_faction", "fac_imladris"),
(assign, ":cur_target_center", "p_town_woodsmen_village"),
(try_end),
(call_script, "script_get_tld_distance", "p_main_party", ":cur_target_center"),
(le, reg0, 20),
(neq, ":cur_target_center", ":giver_center_no"),#Skip current center
Expand Down Expand Up @@ -23024,6 +23055,13 @@ def set_item_score():
(assign, ":guards", "pt_dale_scouts"),
(try_end),

(try_begin),
(this_or_next|eq, ":quest_target_center", "p_town_woodsmen_village"),
(this_or_next|eq, ":quest_target_center", "p_town_beorning_village"),
(eq, ":quest_target_center", "p_town_beorn_house"),
(assign, ":guards", "pt_beorn_scouts"),
(try_end),

(store_random_in_range, ":refugee_radius", 25, 35),
(set_spawn_radius, ":refugee_radius"),

Expand Down Expand Up @@ -23073,7 +23111,7 @@ def set_item_score():
## store to s30 the text you want to show before calling the script.
## $troop_talk_hero = troop ID for upper right portrait;
## $troop_talk_enemy for lower left portrait;
## $troop_talk_duration for how long it should last (miliseconds)
## $troop_talk_duration for how long it should last (seconds)
#Output: Presentation

("troop_talk_presentation",
Expand Down

0 comments on commit aa6c802

Please sign in to comment.