It's an update from code I posted here as Warband provide new operations to improve that.
It's a custom camera that put the character at the middle of the screen, and when we aiming for shooting or throwing, it automatically switches to default camera for beter aiming and backs to custom camera after shoot. It allow you to jump from bot to bot, not to control them but for to get their view of battle. By modifying defeat condition and enabling battle continuation after knocked down, this can be used as death camera too.
Credit to
- Rubik (custom camera)
- Martin F (death camera)
Code :
Usage :
Note :
- $cam_mode=0 -> standard camera
$cam_mode=1 -> Custom Camera
$cam_mode=2 -> Standard Camera, disable Custom Camera
- $free_cam=0 -> only can jump for ally bots
$free_cam=1 -> free jump (I usually switch $free_cam to 1 when player's knocked down)
- You can make own presentation to set the keys overriding the "init_camera" script
- Others :
* pressing left shift while pressing buttons for zooming will produce smooth zooming.
* pressing left shift while pressing buttons to jump to another bot will attempt to jump to next hero
* pressing left Alt while pressing buttons to jump to another bot will attempt to jump to opposite side bot. (only when free_cam=1 or in death cam)
* pressing left Ctrl while pressing buttons to jump to another bot will attempt to jump to same side bot.
It's a custom camera that put the character at the middle of the screen, and when we aiming for shooting or throwing, it automatically switches to default camera for beter aiming and backs to custom camera after shoot. It allow you to jump from bot to bot, not to control them but for to get their view of battle. By modifying defeat condition and enabling battle continuation after knocked down, this can be used as death camera too.
Credit to
- Rubik (custom camera)
- Martin F (death camera)
Code :
Code:
################################################################
## CUSTOM CAMERA
################################################################
camera_init = (0,0,ti_once,[(get_player_agent_no, "$cam_current_agent"), (gt, "$cam_current_agent", -1)],
[(assign,"$cam_mode", 0),(assign, "$shoot_mode",0), (assign, "$cam_free", 0)])
camera_mode = ( 0, 0, 0, [],
[(try_begin),
(eq, "$cam_mode", 1),
(set_fixed_point_multiplier, 100),
(agent_get_look_position, pos7, "$cam_current_agent"),
(position_get_rotation_around_x, ":angle", pos7),
(store_sub, ":reverse", 0, ":angle"),
(position_rotate_x, pos7, ":reverse"),
(position_move_y, pos7, "$g_camera_y"),
(position_move_z, pos7, "$g_camera_z"),
(agent_get_horse, ":horse_agent", "$cam_current_agent"),
(try_begin),
(ge, ":horse_agent", 0),
(position_move_z, pos7, 80),
(try_end),
(store_mul, ":reverse", -1, "$g_camera_y"),
(store_atan2, ":drop", "$g_camera_z", ":reverse"),
(convert_from_fixed_point, ":drop"),
(val_sub, ":angle", ":drop"),
(position_rotate_x, pos7, ":angle"),
(mission_cam_animate_to_position, pos7, 100, 0),
(else_try),
(lt, "$cam_mode", 2),
(main_hero_fallen),
(agent_get_position, 1, "$cam_current_agent"),
(get_player_agent_no, ":player_agent"),
(agent_set_position, ":player_agent", 1),
(try_end),])
camera_set = ( 0, 0, 0,[(key_clicked, "$key_camera_toggle"), (lt, "$cam_mode", 2),(neq, "$shoot_mode", 1)],
# toggling only when came mode =0 or 1 (2=disable) ; shoot_mode=1 temporary diable toggling
[(try_begin),
(eq, "$cam_mode", 0),
(assign, "$cam_mode", 1),
(else_try),
(eq, "$cam_mode", 1),
(try_begin),
(neg|main_hero_fallen, 0),
(get_player_agent_no, "$cam_current_agent"),
(try_end),
(assign, "$cam_mode", 0),
(try_end),
(mission_cam_set_mode, "$cam_mode"),])
camera_zoom_in = ( 0, 0, 0,[(key_is_down, "$key_camera_zoom_plus"), (eq, "$cam_mode", 1)], [(val_add, "$g_camera_y",1),(neg|key_is_down, key_left_shift),(val_add, "$g_camera_y",9),(val_min,"$g_camera_y",-50),])
camera_zoom_out = ( 0, 0, 0,[(key_is_down, "$key_camera_zoom_min"), (eq, "$cam_mode", 1)], [(val_sub, "$g_camera_y",1),(neg|key_is_down, key_left_shift),(val_sub, "$g_camera_y",9),])
camera_raise = ( 0, 0, 0,[(key_is_down, "$key_camera_height_plus"),(eq, "$cam_mode", 1)], [(val_add, "$g_camera_z",1),(neg|key_is_down, key_left_shift),(val_add, "$g_camera_z",9),])
camera_lower = ( 0, 0, 0,[(key_is_down, "$key_camera_height_min"), (eq, "$cam_mode", 1)], [(val_sub, "$g_camera_z",1),(neg|key_is_down, key_left_shift),(val_sub, "$g_camera_z",9),(val_max,"$g_camera_z", 50),])
camera_cycle_fowards = ( 0, 0, 0,[(key_clicked, "$key_camera_next"),(call_script, "script_dmod_cycle_forwards") ,], [])
camera_cycle_backwards = ( 0, 0, 0,[(key_clicked, "$key_camera_prev"),(call_script, "script_dmod_cycle_backwards"),], [])
camera_shot = ( 0, 0, 0,[(key_is_down, key_left_mouse_button), (eq, "$cam_mode", 1)], [(get_player_agent_no, ":player_agent"), (eq, ":player_agent","$cam_current_agent"),(agent_get_wielded_item,":weapon","$cam_current_agent",0), (item_get_type, ":type", ":weapon"), (this_or_next|eq,":type",itp_type_bow),(this_or_next|eq,":type",itp_type_crossbow),(eq,":type",itp_type_thrown),(assign, "$cam_mode", 0),(assign,"$shoot_mode",1),(mission_cam_set_mode, "$cam_mode")])
camera_normal = ( 0, 0, 0,[(neg|key_is_down, key_left_mouse_button), (eq, "$shoot_mode",1)], [(assign, "$cam_mode", 1),(assign,"$shoot_mode",0),(mission_cam_set_mode, "$cam_mode")])
###############################################
Usage :
Code:
camera_init,
camera_mode,
camera_raise,
camera_lower,
camera_zoom_out,
camera_zoom_in,
camera_set,
camera_cycle_fowards,
camera_cycle_backwards,
camera_shot, camera_normal,
Code:
("init_camera",
[(assign, "$key_camera_toggle",key_end), #END button to toggle camera mode
(assign, "$key_camera_next",key_right), #right key to jump to next bot
(assign, "$key_camera_prev",key_left), #left key to jump to prev bot
(assign, "$key_camera_zoom_plus",key_numpad_plus), #Num + to zoom in
(assign, "$key_camera_zoom_min",key_numpad_minus), #Num - to zoom out
(assign, "$key_camera_height_plus",key_up),
(assign, "$key_camera_height_min",key_down),
(assign, "$cam_free", 0),
(assign, "$g_camera_z", 300),
(assign, "$g_camera_y", -1000),
]),
Code:
# Modified MartinF's code for DeathCam
# 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"),
(agent_get_team, ":prev_team", "$cam_current_agent"),
(try_for_agents, ":agent_no"),
(neq, ":agent_moved", 1),
(agent_is_human, ":agent_no"),
(agent_is_alive, ":agent_no"),
(agent_get_team, ":cur_team", ":agent_no"),
(agent_get_troop_id, ":troop_id", ":agent_no"),
(this_or_next|troop_is_hero, ":troop_id"),
(neg|key_is_down, key_left_shift),
(this_or_next|eq, ":cur_team", ":prev_team"),
(neg|key_is_down, key_left_control),
(this_or_next|neq, ":cur_team", ":prev_team"),
(neg|key_is_down, key_left_alt),
(this_or_next|eq, "$cam_free", 1),
(eq, ":cur_team", ":player_team"),
(try_begin),
(lt, ":first_agent", 0), # Find the 1st agent alive and (1 team or free mod)
(assign, ":first_agent", ":agent_no"),
(try_end),
(gt, ":agent_no", "$cam_current_agent"), # Find next agent alive and (1 team or free mod)
(assign, "$cam_current_agent", ":agent_no"),
(assign, ":agent_moved", 1),
(try_end),
(try_begin),
(eq, ":agent_moved", 0), # Next Agent not found, but 1st agent found, then the next is the first one
(neq, ":first_agent", -1),
(assign, "$cam_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), # there is next one
(try_begin),
(agent_is_alive, ":player_agent"), # if player is still alive, push to mode 1
(assign, "$cam_mode", 1),
(mission_cam_set_mode, "$cam_mode"),
(try_end),
(str_store_agent_name, 1, "$cam_current_agent"),
(try_end),]),
# 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"),
(agent_get_team, ":prev_team", "$cam_current_agent"),
(try_for_agents, ":agent_no"),
(agent_is_human, ":agent_no"),
(agent_is_alive, ":agent_no"),
(agent_get_team, ":cur_team", ":agent_no"),
(agent_get_troop_id, ":troop_id", ":agent_no"),
(this_or_next|troop_is_hero, ":troop_id"),
(neg|key_is_down, key_left_shift),
(this_or_next|eq, ":cur_team", ":prev_team"),
(neg|key_is_down, key_left_control),
(this_or_next|neq, ":cur_team", ":prev_team"),
(neg|key_is_down, key_left_alt),
(this_or_next|eq, "$cam_free", 1),
(eq, ":cur_team", ":player_team"),
(assign, ":last_agent", ":agent_no"), # Ok, the last
(lt, ":agent_no", "$cam_current_agent"),
(assign, ":new_agent", ":agent_no"), # prev agent
(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), # There is prev agent
(assign, "$cam_current_agent", ":new_agent"),
(try_begin),
(agent_is_alive, ":player_agent"),
(assign, "$cam_mode", 1),
(mission_cam_set_mode, "$cam_mode"),
(try_end),
(str_store_agent_name, 1, "$cam_current_agent"),
(try_end), ]),
Note :
- $cam_mode=0 -> standard camera
$cam_mode=1 -> Custom Camera
$cam_mode=2 -> Standard Camera, disable Custom Camera
- $free_cam=0 -> only can jump for ally bots
$free_cam=1 -> free jump (I usually switch $free_cam to 1 when player's knocked down)
- You can make own presentation to set the keys overriding the "init_camera" script
- Others :
* pressing left shift while pressing buttons for zooming will produce smooth zooming.
* pressing left shift while pressing buttons to jump to another bot will attempt to jump to next hero
* pressing left Alt while pressing buttons to jump to another bot will attempt to jump to opposite side bot. (only when free_cam=1 or in death cam)
* pressing left Ctrl while pressing buttons to jump to another bot will attempt to jump to same side bot.