ok, I played around with the concept of binoculars and am pretty happy with how it is working so far. If you have itm_binocular in your inventory then the B key changes you view between a 0-4x magnification. The player and/or horse they are ridding will stop moving while you are zoomed in. You can also use your mouse to move the binoculars while zoomed. It could use a presentation overlay (no clue how to add that), and I may have some redundant code so let me know if you guys can improve it any further...
#--------------------------------------------------------------------------------------------------------------------------------------------------
#SW - zoom in/out code by jik and WilliamBerne - http://forums.taleworlds.net/index.php/topic,68192.0.html - modified further by HokieBT
common_use_binocular_1 = (0, 0, 0, [
(key_clicked, key_b)
],
[
(get_player_agent_no, ":player_agent"),
(agent_is_alive, ":player_agent"),
#(troop_get_inventory_capacity, ":inv_cap", "trp_player"),
(troop_get_inventory_capacity, ":inv_cap", "$g_player_troop"), #since custom commander is integrated
(assign, ":binocular_slot", -1),
(try_for_range, ":slot_no", 0, ":inv_cap"),
#(troop_get_inventory_slot,":item_id","trp_player",":slot_no"),
(troop_get_inventory_slot,":item_id","$g_player_troop",":slot_no"), #since custom commander is integrated
#check for binoculars
(try_begin),
(eq, ":item_id", "itm_binocular"),
(assign, ":binocular_slot", ":slot_no"),
(try_end),
(try_end),
(try_begin),
(eq, ":binocular_slot", -1),
(display_message, "@You don't have any Binoculars in your inventory!"),
(else_try),
(try_begin),
(le, "$binocular_magnification", 0), #incase this variable isn't set yet
(assign, "$binocular_magnification", 1000),
(display_message, "@Binocular Zoom is 1x"),
(else_try),
(eq, "$binocular_magnification", 1000),
(assign, "$binocular_magnification", 2000),
(display_message, "@Binocular Zoom is 2x"),
(else_try),
(eq, "$binocular_magnification", 2000),
(assign, "$binocular_magnification", 3000),
(display_message, "@Binocular Zoom is 3x"),
(else_try),
(eq, "$binocular_magnification", 3000),
(assign, "$binocular_magnification", 4000),
(display_message, "@Binocular Zoom is 4x"),
(else_try),
(eq, "$binocular_magnification", 4000),
(assign, "$binocular_magnification", 0),
(display_message, "@Binocular Zoom is off"),
(try_end),
#change the zoom
(try_begin),
(le, "$binocular_magnification", 0),
(mission_cam_clear_target_agent),
(mission_cam_set_mode,0),
(mission_cam_set_target_agent, ":player_agent", 1),
(else_try),
(mission_cam_clear_target_agent),
(assign,":height",0),
#get where the player is looking
(agent_get_look_position, pos1, ":player_agent"),
(position_move_y,pos1,"$binocular_magnification"),
(position_get_z,":height",pos1),
(try_begin),
(lt,":height",50),
(position_move_z,pos1,200),
(try_end),
(mission_cam_set_mode,1),
(mission_cam_animate_to_position, pos1, 100, 0), #the speed of the zoom-in
(try_end),
(try_end),
])
common_use_binocular_2 = (
0.1, 0, 0,
[
(try_begin),
(gt, "$binocular_magnification", 0),
(get_player_agent_no, ":player_agent"),
(agent_is_alive, ":player_agent"),
#(agent_set_animation, ":player_agent", "anim_unused_human_anim_1"), #so the player doesn't move, must include module_animations at the top of the python file
(agent_set_animation, ":player_agent", "anim_defend_fist"), #so the player looks more like they are holding binoculars
(try_for_agents, ":cur_agent"),
(agent_is_alive, ":cur_agent"), #so we don't try dead agents
(neg|agent_is_human,":cur_agent"), #agent is a horse
(agent_get_rider,":cur_rider", ":cur_agent"),
(eq, ":cur_rider", ":player_agent"), #rider of this horse is the player
(agent_set_animation, ":cur_agent", "anim_unused_horse_anim_1"), #so the horse doesn't move, must include module_animations at the top of the python file
(try_end),
#fix the camera to follow the mouse movement
#reset the camera (not sure all of these steps are necessary?)
(mission_cam_clear_target_agent),
(mission_cam_set_mode,0),
(mission_cam_set_target_agent, ":player_agent", 1),
#zoom in the camera (removed the height check so the camera wouldn't jump on the z-axis as the player moved the mouse around)
(mission_cam_clear_target_agent),
(agent_get_look_position, pos1, ":player_agent"),
(position_move_y,pos1,"$binocular_magnification"),
(mission_cam_set_mode,1),
(mission_cam_animate_to_position, pos1, 1, 0), #the speed of the zoom-in (really fast for the mouse movement camera, zero doesn't work)
(try_end),
],
[
])
#---------------------------------------------------------------------------------------------------------------------------------------------------