# script_dmod_cycle_forwards
# Output: New $dmod_current_agent
# Used to cycle forwards through valid agents
("dmod_cycle_forwards",[
(assign, ":agent_moved", 0),
(assign, ":first_agent", -1),
(get_player_agent_no, ":player_agent"),
(agent_get_team, ":player_team", ":player_agent"),
(try_for_agents, ":agent_no"),
(neq, ":agent_moved", 1),
(neq, ":agent_no", ":player_agent"),
(agent_is_human, ":agent_no"),
(agent_is_alive, ":agent_no"),
(agent_get_team, ":cur_team", ":agent_no"),
(eq, ":cur_team", ":player_team"),
# (agent_get_troop_id, ":agent_troop", ":agent_no"),
(try_begin),
(lt, ":first_agent", 0),
(assign, ":first_agent", ":agent_no"),
(try_end),
(gt, ":agent_no", "$dmod_current_agent"),
(assign, "$dmod_current_agent", ":agent_no"),
(assign, ":agent_moved", 1),
(try_end),
(try_begin),
(eq, ":agent_moved", 0),
(neq, ":first_agent", -1),
(assign, "$dmod_current_agent", ":first_agent"),
(assign, ":agent_moved", 1),
(else_try),
(eq, ":agent_moved", 0),
(eq, ":first_agent", -1),
(display_message, "@No Troops Left."),
(try_end),
(try_begin),
(eq, ":agent_moved", 1),
(str_store_agent_name, 1, "$dmod_current_agent"),
(display_message, "@Selected Troop: {s1}"),
(try_end),
(assign, "$dmod_move_camera", 1),
]),
# script_dmod_cycle_backwards
# Output: New $dmod_current_agent
# Used to cycle backwards through valid agents
("dmod_cycle_backwards",[
(assign, ":new_agent", -1),
(assign, ":last_agent", -1),
(get_player_agent_no, ":player_agent"),
(agent_get_team, ":player_team", ":player_agent"),
(try_for_agents, ":agent_no"),
(neq, ":agent_no", ":player_agent"),
(agent_is_human, ":agent_no"),
(agent_is_alive, ":agent_no"),
(agent_get_team, ":cur_team", ":agent_no"),
(eq, ":cur_team", ":player_team"),
# (agent_get_troop_id, ":agent_troop", ":agent_no"),
(assign, ":last_agent", ":agent_no"),
(lt, ":agent_no", "$dmod_current_agent"),
(assign, ":new_agent", ":agent_no"),
(try_end),
(try_begin),
(eq, ":new_agent", -1),
(neq, ":last_agent", -1),
(assign, ":new_agent", ":last_agent"),
(else_try),
(eq, ":new_agent", -1),
(eq, ":last_agent", -1),
(display_message, "@No Troops Left."),
(try_end),
(try_begin),
(neq, ":new_agent", -1),
(assign, "$dmod_current_agent", ":new_agent"),
(str_store_agent_name, 1, "$dmod_current_agent"),
(display_message, "@Selected Troop: {s1}"),
(try_end),
(assign, "$dmod_move_camera", 1),
]),
sw_deathcam_follow_troop = (0, 0, 0,[(eq, "$dmod_move_camera", 2),
(agent_get_position, 1, "$dmod_current_agent"),
(get_player_agent_no, ":player_agent"),
(agent_set_position, ":player_agent", 1)
],[])
sw_deathcam_valkyrie_move_camera = (0, 1, 2.1,[(eq, "$dmod_move_camera", 1),
(agent_get_position, 2, "$dmod_current_agent"),
(position_move_z, 2, 300),
(mission_cam_set_mode,1),
(mission_cam_set_position, 2),
(position_move_z, 2, 600),
(mission_cam_animate_to_position, 2, 1000),
],[
(mission_cam_set_mode, 0, 1000, 1),
(assign, "$dmod_move_camera", 2),
])
sw_deathcam_cycle_fowards = (0, 0, 0,[(key_clicked, key_m), (main_hero_fallen),
(call_script, "script_dmod_cycle_forwards"),
], [])
sw_deathcam_cycle_backwards = (0, 0, 0,[(key_clicked, key_n), (main_hero_fallen),
(call_script, "script_dmod_cycle_backwards"),
], [])
common_siege_check_defeat_condition = (
1, 4, ti_once,
[
(main_hero_fallen)
],
[
(assign, "$pin_player_fallen", 1),
(display_message, "@You have been knocked out by the enemy. Watch your men continue the fight without you or press Tab to retreat."),
(display_message, "@If you choose to watch the fight you can use the M and N keys to change your camera view."),
# (get_player_agent_no, ":player_agent"),
# (agent_get_team, ":agent_team", ":player_agent"),
# (try_begin),
# (neq, "$attacker_team", ":agent_team"),
# (neq, "$attacker_team_2", ":agent_team"),
# (str_store_string, s5, "str_siege_continues"),
# (call_script, "script_simulate_retreat", 8, 15),
# (else_try),
# (str_store_string, s5, "str_retreat"),
# (call_script, "script_simulate_retreat", 5, 20),
# (try_end),
# (assign, "$g_battle_result", -1),
# (set_mission_result,-1),
# (call_script, "script_count_mission_casualties_from_agents"),
# (finish_mission,0),
])
(0, 0, ti_once, [], [(assign,"$battle_won",0),
(assign,"$defender_reinforcement_stage",0),
(assign,"$attacker_reinforcement_stage",0),
(assign,"$g_presentation_battle_active", 0),
(call_script, "script_place_player_banner_near_inventory"),
(call_script, "script_combat_music_set_situation_with_culture"),
#SW Deathcam
(assign, "$dmod_current_agent", -1),
(assign, "$dmod_move_camera", -1),
]),
(1, 4, ti_once, [(main_hero_fallen)],
[
(assign, "$pin_player_fallen", 1),
(display_message, "@You have been knocked out by the enemy. Watch your men continue the fight without you or press Tab to retreat."),
(display_message, "@If you choose to watch the fight you can use the M and N keys to change your camera view."),
# (str_store_string, s5, "str_retreat"),
# (call_script, "script_simulate_retreat", 10, 20),
# (assign, "$g_battle_result", -1),
# (set_mission_result,-1),
# (call_script, "script_count_mission_casualties_from_agents"),
# (finish_mission,0)
]),
common_battle_tab_press = (
ti_tab_pressed, 0, 0, [],
[
(try_begin),
(eq, "$battle_won", 1),
(call_script, "script_count_mission_casualties_from_agents"),
(finish_mission,0),
(else_try),
(eq, "$pin_player_fallen", 1),
(call_script, "script_simulate_retreat", 5, 20),
(str_store_string, s5, "str_retreat"),
(call_script, "script_count_mission_casualties_from_agents"),
(set_mission_result, -1),
(finish_mission,0),
(else_try),
(call_script, "script_cf_check_enemies_nearby"),
(question_box,"str_do_you_want_to_retreat"),
(else_try),
(display_message,"str_can_not_retreat"),
(try_end),
])
MartinF said:I've adapted that code so that it won't let you switch players but just jump the view through your surviving troops, a little like the way it works in Counter Strike after you're dead.
jik said:Is it possible to move the camera back, and take away the ability to move the player agent?
The reason I ask this is it might be cool to (after striking/missing) in the joust to have the camera zoom back so you can see the outcome. Even if the player's agent is not dead/KOed.
Berserker Pride said:Martinf I found what might be a bug in the code. Due to removing the check that your player is dead what is there to check that your team has actually lost the battle. I went to a battle alone died and the mission wouldn't end. When I "retreated" the game crashed. I couldn't find a common battle check defeat condition maybe it just checks for your death at the end of all the mission templates? Do I need to modify the MT's to count your team and see if they are all dead?
EDIT: The crash was due to something else but that still means that if you lose by yourself you "retreat" and get to fight again or run? I've been looking in module operations but haven't found an operation to count your teams remaining agents. Its probably there somewhere though.
(1, 4, ti_once, [(main_hero_fallen)],
[
(assign, "$pin_player_fallen", 1),
(display_message, "@You have fallen in battle!"),
(assign, ":num_allies", 0),
(try_for_agents, ":agent"),
(agent_is_ally, ":agent"),
(agent_is_alive, ":agent"),
(val_add, ":num_allies", 1),
(try_end),
(try_begin),
(eq, ":num_allies", 0),
(assign, "$g_battle_result", -1),
(set_mission_result,-1),
(call_script, "script_count_mission_casualties_from_agents"),
(finish_mission,0),
(else_try),
(display_message, "@You have been knocked out by the enemy. Watch your men continue the fight without you or press Tab to retreat."),
(display_message, "@If you choose to watch the fight you can use the M and N keys to change your camera view."),
(try_end),
]),