jik said:I've played with moving the camera in my tournament that I am building into my mod. In this case, when the player fires his arrow, the camera moves forward to look at the target.
###Camera stuff (if possible)
(0.1,0,0,
[###Conditions that the arrow was fired
(get_player_agent_no, ":player_agent"),
(agent_get_ammo, ":ammo", ":player_agent"),
(gt,"$num_arrows",":ammo"), ##means an arrow was fired
],
[###Moving the camera near pos10 with delta-y about 300
(display_message,"@An arrow was fired"),
(val_sub,"$num_arrows",1),
(mission_cam_clear_target_agent),
(position_move_y,pos10,-100),
(position_move_z,pos10,80),
(mission_cam_set_mode,1),
(mission_cam_animate_to_position, pos10, 1000, 0),
(assign,"$cam_lock",20),
],
),
(0.1,0,1,
[###Camera has moved, need to move it back after 4 seconds
(try_begin),
(gt,"$cam_lock",1),
(val_sub,"$cam_lock",1),
(try_end),
(eq,"$cam_lock",1),
],
[(assign,"$cam_lock",0),
(mission_cam_set_mode,0),
(get_player_agent_no, ":player_agent"),
(mission_cam_set_target_agent, ":player_agent", 1),
],
),
###Camera Stuff ends
I'm not sure how things work when the camera is zoomed in this case. You could always take the players Y direction to move the camera where they are looking. If you are talking about pressing Shift, I think that is hard coded, though you can make your own.
The Red Baron said:Not that I'm an excellent modder, but i would try to base it off the one that is hardcoded and just make the scale of zoom larger. Not sure how you would make it different for each weapon unless you made a different zoom for each weapon and added them as flags(I think) to the weapon
Well That's a great idea. I mean if you stand and hold the shot will say... I'll try that. Thank you all for putting your master-minds together and helped me out...Ruthven said:Well maybe you could on_ti_weapon_attack in the item tuple and call a script to zoom in the camera ala Jik's code?
zoom_in = (
0, 0, 0,
[
(key_clicked,key_left_control),
],
[
(mission_cam_clear_target_agent),
(assign,":height",0),
(get_player_agent_no, ":player"),
(agent_get_look_position, pos1, ":player"),
(position_move_y,pos1,6000),
(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, 5, 0),
# (start_presentation,"prsnt_scope"),
])
zoom_out = (
0, 0, 0,
[
(key_clicked,key_left_alt),
],
[
(mission_cam_clear_target_agent),
(get_player_agent_no, ":player"),
(mission_cam_set_mode,0),
(mission_cam_set_target_agent, ":player", 1),
])
WilliamBerne said:I want to do the same thing like sniperscope effect, but still no success.
That shift function is hardcored I believe.
I don't think on_ti_weapon_attack would work good. Edit in mission_templates should work, first check which weapon the player is using, then decide how much scale he can zoom in.
mission_cam_set_target_agent or mission_cam_animate_to_position etc could do the trick, but I have some question: In my practise, I'm sure that the player's/agents' looking position, or line of sight, is not always same as aiming line, or should I say these lines NEVER perfectly matched. In this way if we move the cam to some direction, how can we sure that the player's target would still be in the sight/screen?
can you guys who have tested jik's code give us some screenies to show this effect?
["binocular","Macro Binoculars", [("laser_scope",0)], itp_merchandise|itp_type_goods, 0,5000,weight(5)|abundance(40),imodbits_none],
from module_animations import *
#--------------------------------------------------------------------------------------------------------------------------------------------------
#SW - zoom in/out code by jik and WilliamBerne - http://forums.taleworlds.com/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),
],
[
])
#---------------------------------------------------------------------------------------------------------------------------------------------------
common_use_binocular_1,
common_use_binocular_2,