OSP Code QoL [WB] Ironsight mode

Users who are viewing this thread

doomsayer

Knight
WB
I didn't like it that crossbows and rifles are pointed from the lower right corner to the middle of the screen so here's a script I made that let's you actually aim over crossbows (and rifles) by putting the 1st person viewport to the right position.
Looks pretty nice with crossbows already, though some minor changes in animations are required to make it really good.
It should work smooth in singleplayer might get some stuttering when running around with the crossbow aimed in mp, though I'd need some testers to confirm this. With crossbows it's still a bit off vertically but that doesn't matter much due to arrow drop anyway, horizontally it's almost correct.

All it basically does is force you into an 1st person "ironsight" view whenever you aim a crossbow. There are still a view glitches, you should definately go into 1st person first to shoot crossbows or you'll see the inside of your head, which is embarassingly empty.  :mrgreen:

Here goes the code:
Code:
singleplayer_ironsight_mode = (

0, 0, 0, [],

       [

         (get_player_agent_no, ":player_agent"),

#         (ge, ":player_agent", 0),

         (try_begin),

           (game_key_is_down, gk_view_char),

           (mission_cam_set_mode, 0),

         (else_try),

           (agent_get_wielded_item, ":player_item", ":player_agent", 0),

           (this_or_next|eq, ":player_item", "itm_tutorial_crossbow"),

           (this_or_next|eq, ":player_item", "itm_practice_crossbow"),

           (this_or_next|eq, ":player_item", "itm_hunting_crossbow"),

           (this_or_next|eq, ":player_item", "itm_light_crossbow"),

           (this_or_next|eq, ":player_item", "itm_crossbow"),

           (this_or_next|eq, ":player_item", "itm_heavy_crossbow"),

           (eq, ":player_item", "itm_sniper_crossbow"),

           (game_key_is_down, gk_zoom),

           (agent_get_look_position, pos1, ":player_agent"),

           (position_move_x, pos1, 7),

           (position_move_z, pos1, 40),

           (init_position, pos2),

           (init_position, pos3),

           (position_copy_rotation, pos3, pos1),

           (position_copy_rotation, pos1, pos2),

           (position_move_z, pos1, 127),

           (position_copy_rotation, pos1, pos3),

           (mission_cam_set_mode, 1),

#          whatever you do to zoom...

           (mission_cam_set_position, pos1),

           (mission_cam_set_aperture, 45),

         (else_try),

           (agent_get_wielded_item, ":player_item", ":player_agent", 0),

           (this_or_next|eq, ":player_item", "itm_tutorial_crossbow"),

           (this_or_next|eq, ":player_item", "itm_practice_crossbow"),

           (this_or_next|eq, ":player_item", "itm_hunting_crossbow"),

           (this_or_next|eq, ":player_item", "itm_light_crossbow"),

           (this_or_next|eq, ":player_item", "itm_crossbow"),

           (this_or_next|eq, ":player_item", "itm_heavy_crossbow"),

           (eq, ":player_item", "itm_sniper_crossbow"),

           (game_key_is_down, gk_attack),

           (agent_get_look_position, pos1, ":player_agent"),

           (position_move_x, pos1, 7),

           (position_move_z, pos1, 40),

           (init_position, pos2),

           (init_position, pos3),

           (position_copy_rotation, pos3, pos1),

           (position_copy_rotation, pos1, pos2),

           (position_move_z, pos1, 127),

           (position_copy_rotation, pos1, pos3),

           (mission_cam_set_mode, 1),

           (mission_cam_set_position, pos1),

         (else_try),

           (mission_cam_set_mode, 0),

         (try_end),

         ])

Code:
multiplayer_ironsight_mode = (

0, 0, 0, [],

       [

         (multiplayer_get_my_player, ":my_player_no"),

         (player_get_agent_id, ":player_agent", ":my_player_no"),

         (ge, ":player_agent", 0),

         (try_begin),

           (game_key_is_down, gk_view_char),

           (mission_cam_set_mode, 0),

         (else_try),

           (agent_get_wielded_item, ":player_item", ":player_agent", 0),

           (this_or_next|eq, ":player_item", "itm_crossbow"),

           (this_or_next|eq, ":player_item", "itm_heavy_crossbow"),

           (eq, ":player_item", "itm_sniper_crossbow"),

           (game_key_is_down, gk_zoom),

           (agent_get_look_position, pos1, ":player_agent"),

           (position_move_x, pos1, 7),

           (position_move_z, pos1, 40),

           (init_position, pos2),

           (init_position, pos3),

           (position_copy_rotation, pos3, pos1),

           (position_copy_rotation, pos1, pos2),

           (position_move_z, pos1, 127),

           (position_copy_rotation, pos1, pos3),

           (mission_cam_set_mode, 1),

#          whatever you do to zoom...

           (mission_cam_set_position, pos1),

           (mission_cam_set_aperture, 45),

         (else_try),

           (agent_get_wielded_item, ":player_item", ":player_agent", 0),

           (this_or_next|eq, ":player_item", "itm_crossbow"),

           (this_or_next|eq, ":player_item", "itm_heavy_crossbow"),

           (eq, ":player_item", "itm_sniper_crossbow"),

           (game_key_is_down, gk_attack),

           (agent_get_look_position, pos1, ":player_agent"),

           (position_move_x, pos1, 7),

           (position_move_z, pos1, 40),

           (init_position, pos2),

           (init_position, pos3),

           (position_copy_rotation, pos3, pos1),

           (position_copy_rotation, pos1, pos2),

           (position_move_z, pos1, 127),

           (position_copy_rotation, pos1, pos3),

           (mission_cam_set_mode, 1),

           (mission_cam_set_position, pos1),

         (else_try),

           (mission_cam_set_mode, 0),

         (try_end),

         ])

You just have to add this to your module_mission_templates.py after the line

Code:
pilgrim_disguise = [itm_pilgrim_hood,itm_pilgrim_disguise,itm_practice_staff, itm_throwing_daggers]

af_castle_lord = af_override_horse | af_override_weapons| af_require_civilian

And then in every mission you want it add the line below where the triggers are.

Code:
      multiplayer_ironsight_mode,

or

Code:
      singleplayer_ironsight_mode,

depending on what the mission is for ofc.

Pictures:

mb55x.jpg

mb56.jpg

mb57r.jpg

You are free to use and modify it however you like, I really hope some of the gunbased mods out there consider it. If you can improveme it I'd be glad to incorporate it.
 

mr.master

Count
Id be happy to use this in my mod. I have really been waiting for something like this :razz: Thanks. Should this work in multiplayer if I ad multiplayer_is_server?
 

doomsayer

Knight
WB
I've made some pics and managed to add a zoom. Updating the first post...

mr.master said:
Id be happy to use this in my mod. I have really been waiting for something like this :razz: Thanks. Should this work in multiplayer if I ad multiplayer_is_server?

Herr_Thomas said:
sounds cool. but i've never done ANYTHING to mod m&b.

could you make a tutorial or explain the triggers thing? i get the first part

Oh, and does this work with Warband?

Yeah, what I have is basically Warband multiplayer, I also added a singleplayer version.
No, using the thing without any multiplayer_is_server lines works fine (or maybe stutters I don't know :grin: ). You just have to add it to the mission_templates like I said and the line to the triggers.

It basically works like this:

Code:
(

    "village_center",0,-1,

    "village center",

    [(0,mtef_scene_source|mtef_team_0,0,0,1,[]),

     (1,mtef_scene_source|mtef_team_0,0,0,1,[]),

This is where the mission starts, here it is the village visit. After that comes some stuff I don't know. Then comes an open square bracket and these blocks:

Code:
(1, 0, ti_once, [], [

          (store_current_scene, ":cur_scene"),

          (scene_set_slot, ":cur_scene", slot_scene_visited, 1),

          (call_script, "script_init_town_walker_agents"),

          (call_script, "script_music_set_situation_with_culture", mtf_sit_travel),

        ]),

Code:
(ti_before_mission_start, 0, 0, [], [(call_script, "script_change_banners_and_chest")]),

These are the triggers. If you paste the line directly behind that square bracket like so:

Code:
  (

    "village_center",0,-1,

    "village center",

    [(0,mtef_scene_source|mtef_team_0,0,0,1,[]),

     (1,mtef_scene_source|mtef_team_0,0,0,1,[]),

     (2,mtef_scene_source|mtef_team_0,af_override_horse,0,1,[]),

     (3,mtef_scene_source|mtef_team_0,af_override_horse,0,1,[]),

     (4,mtef_scene_source|mtef_team_0,af_override_horse,0,1,[]),

     (5,mtef_scene_source|mtef_team_0,af_override_horse,0,1,[]),

     (6,mtef_scene_source|mtef_team_0,af_override_horse,0,1,[]),

     (7,mtef_scene_source|mtef_team_0,af_override_horse,0,1,[]),

     

     (8,mtef_visitor_source,af_override_horse,0,1,[]),

     (9,mtef_visitor_source,af_override_horse,0,1,[]),(10,mtef_visitor_source,af_override_horse,0,1,[]),(11,mtef_visitor_source,af_override_horse,0,1,[]),(12,mtef_visitor_source,af_override_horse,0,1,[]),(13,mtef_visitor_source,0,0,1,[]),(14,mtef_visitor_source,0,0,1,[]),(15,mtef_visitor_source,0,0,1,[]),

     (16,mtef_visitor_source,af_override_horse,0,1,[]),(17,mtef_visitor_source,af_override_horse,0,1,[]),(18,mtef_visitor_source,af_override_horse,0,1,[]),(19,mtef_visitor_source,af_override_horse,0,1,[]),(20,mtef_visitor_source,af_override_horse,0,1,[]),(21,mtef_visitor_source,af_override_horse,0,1,[]),(22,mtef_visitor_source,af_override_horse,0,1,[]),(23,mtef_visitor_source,af_override_horse,0,1,[]),

     (24,mtef_visitor_source,af_override_horse,0,1,[]),(25,mtef_visitor_source,af_override_horse,0,1,[]),(26,mtef_visitor_source,af_override_horse,0,1,[]),(27,mtef_visitor_source,af_override_horse,0,1,[]),(28,mtef_visitor_source,af_override_horse,0,1,[]),(29,mtef_visitor_source,af_override_horse,0,1,[]),(30,mtef_visitor_source,af_override_horse,0,1,[]),(31,mtef_visitor_source,af_override_horse,0,1,[]),

     (32,mtef_visitor_source,af_override_horse,0,1,[]),(33,mtef_visitor_source,af_override_horse,0,1,[]),(34,mtef_visitor_source,af_override_horse,0,1,[]),(35,mtef_visitor_source,af_override_horse,0,1,[]),(36,mtef_visitor_source,af_override_horse,0,1,[]),(37,mtef_visitor_source,af_override_horse,0,1,[]),(38,mtef_visitor_source,af_override_horse,0,1,[]),(39,mtef_visitor_source,af_override_horse,0,1,[]),

     (40,mtef_visitor_source,af_override_horse,0,1,[]),(41,mtef_visitor_source,af_override_horse,0,1,[]),(42,mtef_visitor_source,af_override_horse,0,1,[]),(43,mtef_visitor_source,af_override_horse,0,1,[]),(44,mtef_visitor_source,af_override_horse,0,1,[]),(45,mtef_visitor_source,af_override_horse,0,1,[]),(46,mtef_visitor_source,af_override_horse,0,1,[]),(47,mtef_visitor_source,af_override_horse,0,1,[]),

     ],

    [

      singleplayer_ironsight_mode,

      (1, 0, ti_once, [], [

          (store_current_scene, ":cur_scene"),

          (scene_set_slot, ":cur_scene", slot_scene_visited, 1),

          (call_script, "script_init_town_walker_agents"),

          (call_script, "script_music_set_situation_with_culture", mtf_sit_travel),

        ]),

it enables the ironsight mode for village visits. You'd have to do this for any mission that is in the game, like battles and sieges.
Another example for multiplayer:

Code:
    [

      multiplayer_ironsight_mode,

      #multiplayer_server_check_belfry_movement,      

     

      multiplayer_server_check_polls,

      

      (ti_on_agent_spawn, 0, 0, [],
I hope that helps, though I guess if you haven't modded before you might need to check the real tutorials that I can't really cover here. Anyways, when I have a more polished version, I will upload a small mod for native.
 

herre

Sergeant at Arms
Would it be possible to just upload the whole file from the native? (this is native compatible, yes?)
Would be alot easier
 

Nord Champion

Grandmaster Knight
M&BWBWF&SNW
This is wonderful!!!

Thanks for this, I really appreciate the work you put into this. Also, I figured out a fix for the 3rd person head glitch thing (it may require WSE but I'm not sure)


          (game_key_is_down, gk_zoom),
 
          (set_camera_in_first_person, 1),

          (agent_get_look_position, pos1, ":player_agent"),
 

Specialist

Master Knight
WB
Amazing work. I'm going to try making a script based off of this so that right click refocuses the camera atop the gun. :wink:
 

KevinP97

Regular
Could someone help me install this? I don't know how to and I would really like to try this out with a musket mod. Thank you  :grin:
 

KevinP97

Regular
I am new to modding scripts of warband lol. So I have no idea where anything goes =(. So maybe if you could take a few screenshots of you installing the mod yourself that would be very useful. Thanks.
 

mr.master

Count
KevinP97 said:
I am new to modding scripts of warband lol. So I have no idea where anything goes =(. So maybe if you could take a few screenshots of you installing the mod yourself that would be very useful. Thanks.
It says where you need to put em. I suggest you take a look at the module system a bit just to get familiar of everything and read a few tuts.
 

Woelfie

Master Knight
M&BWBWF&SNW
I used to have it in 'The Vast Fields of Europe' but no released mods at the moment. I believe Specialist uses it a lot in most projects he works on. I myself use it in most of my mods as its a nifty little addition, I'm sure if you look around though you may find one.

Wolf.
 

Specialist

Master Knight
WB
Well, I use a version of it in all my mods. :wink: As Wolf said, it's a nifty addon. I'm still working on my ironsights view on key combinations
 

Specialist

Master Knight
WB
Yeah. Download the MS, follow the same install procedure, but add all of the muskets, crossbows, pistols, etc that you want instead of the Warband crossbows. Very tedious, but it will be worthwhile if you do it correctly
 

DJK83

Sergeant
Okay, I just tested it with one, but there were a few problems. First, I'm confused when it comes to the part about adding "whatever you use to zoom". How exactly do you do that? Without doing anything in that regard, it stayed zoomed in permanently. So how do I get that to work properly? Second, the model is gonna need to be moved over and re-arranged a bit so that it's lined up properly. Can that be done with the X Y and Z coordinates that are in the code?
 
Top Bottom