OSP Code QoL Alive horses

Users who are viewing this thread

AndyYa

Veteran
M&BWB
This OSP changes static horses in towns (horse merchant) to alive ones.
The following trigger can be added to the "town_center" part in module_mission_templates.py to "animate" selling horses.
Code:
    (0, 0, ti_once, [],### replace static horse
      [(neg|is_edit_mode_enabled),
        (try_for_range, ":horse", all_items_begin, all_items_end), # horses_begin, horses_end
            (item_get_type, ":type", ":horse"),
            (eq, ":type", itp_type_horse),
            (scene_item_get_num_instances, ":num_instances", ":horse"),
            (try_for_range, ":number", 0, ":num_instances"),
                (scene_item_get_instance, ":scene_item", ":horse", ":number"),
                (prop_instance_get_position, pos53, ":scene_item"),
                (prop_instance_set_scale, ":scene_item", 0, 0, 0),
                (set_spawn_position, pos53),
                (spawn_horse, ":horse", 0),
            (try_end),
        (try_end),
     ]),
 
Last edited:

Ramaraunt

bonus challange:

make it so you can be a horse thief, but the guards go after you  :fruity:
 

NPC99

Baron
M&BWBWF&SVC
Great. Thanks for this.

Time to check all my town scenes. Some horse stalls don't have ai barriers & horses wander.

Unfortunately, occasional horses judder - they appear stuck - continuously walking into the collision mesh of their horse stall. My horse stalls may need a redesign to avoid this. Any ideas?


Edit: LOL the ai barriers in WFaS are the wrong way round to keep people out of the horse stalls so nothing currently stops the horses escaping. Presumably, it's the same for warband.

Edit2: It seems there are problems with horses and collision meshes.

1. Hind quarters overlap the posts of open stables, ignoring collision meshes, which they can't walk through. Looks ok now I've removed the middle two front posts from open_stable_a
2. Two horses stuck in the corner of a pen are occupying the same space, swinging side to side through each other's bodies, which looks wierd.
 

NPC99

Baron
M&BWBWF&SVC
WARNING

Don't edit & save the town center scene while its mission template is active. I did. While there were no problems with re-running the scene in game, when I tried to edit the scene normally (outside of an active mission template, using scene chooser) my prop horses had disappeared. They were still in the scene assets list and when I double clicked them they reappeared in their starting positions but as 2D, not 3D horses!! Presumably, once spawned as animated horses they can't quite re-save as normal scene props.
 

Leonion

Master Knight
NPC99 said:
WARNING

Don't edit & save the town center scene while its mission template is active. I did. While there were no problems with re-running the scene in game, when I tried to edit the scene normally (outside of an active mission template, using scene chooser) my prop horses had disappeared. They were still in the scene assets list and when I double clicked them they reappeared in their starting positions but as 2D, not 3D horses!! Presumably, once spawned as animated horses they can't quite re-save as normal scene props.
Ouch.
Thanks for the warning.
I think it should be added to the first message.

P.S. It's probably worth giving the trigger condition
(neg|is_edit_mode_enabled),
 

Ramaraunt

Tip: put this at the top of module_ mission_templates

andyya_alive_horses = (
ti_once, 0, 0, [],### replace static horse
  [(neg|is_edit_mode_enabled),
(try_for_range, ":horse", all_items_begin, all_items_end),#itp_type_horse
(item_get_type, ":type", ":horse"),
(eq, ":type", itp_type_horse),
(scene_item_get_num_instances, ":num_instances", ":horse"),
(try_for_range, ":number", 0, ":num_instances"),
(scene_item_get_instance, ":scene_item", ":horse", ":number"),
(prop_instance_get_position, pos53, ":scene_item"),
(prop_instance_set_scale, ":scene_item", 0, 0, 0),
(set_spawn_position, pos53),
(spawn_horse, ":horse", 0),
(try_end),
(try_end),
])

Then, put this in every mission template you want this to work on:
Code:
andyya_alive_horses ,
 

NPC99

Baron
M&BWBWF&SVC
This also works for animals flagged as itp_type_horse. Some horse animations look strange on sheep, but any movement's a plus. Remember to reduce their speed if you're going to let them wander.
 

Turban

Veteran
Not a coder so when I added this to module_mission_templates.py I'm stumped at this error I get on compile:

Code:
  File "process_init.py", line 5, in <module>
    from process_operations import *
  File "C:\Users\acer\Desktop\mb_warband_module_system_1171\process_operations.py", line 25, in <module>
    from module_mission_templates import *
  File "C:\Users\acer\Desktop\mb_warband_module_system_1171\module_mission_templates.py", line 918, in <module>
    (try_for_range, ":horse", all_items_begin, all_items_end),#itp_type_horse
NameError: name 'all_items_end' is not defined

I'm presuming I need to define 'all_items_end' somewhere? How? If not, where have I gone wrong?"
 

kalarhan

Python Saint
Count
WBNWVCWF&S
Anglolord said:
where have I gone wrong?

constants are defined on module_constants.py. Check why yours is not there. It is from Native (should be there already for Warband based module).
 

AndyYa

Veteran
M&BWB
Azura34 said:
(45,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),
(46,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),
(47,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),
    ],
    [ 

ikinci parantezin altına ekledim fakat çalışmadı hatayı nerde yaptım ?

This is the part of my module_mission_templates.py
(
    "town_center",0,-1,
    "Default town visit",
    [ (0,mtef_scene_source|mtef_team_0,af_override_horse,0,1,pilgrim_disguise), #Player when entering on foot
      (1,mtef_scene_source|mtef_team_0,0,0,1,[]),#Player when entering on horseback
      .
      .
      .
      (62,mtef_visitor_source,af_override_horse,0,1,[]),
      (63,mtef_visitor_source,af_override_horse,0,1,[]),
    ],
    [

    (0, 0, ti_once, [],### static horse
      [ (neg|is_edit_mode_enabled),
    (try_for_range, ":horse", all_items_begin, all_items_end),
(item_get_type, ":type", ":horse"),
(eq, ":type", itp_type_horse),
(scene_item_get_num_instances, ":num_instances", ":horse"),
(try_for_range, ":number", 0, ":num_instances"),
(scene_item_get_instance, ":scene_item", ":horse", ":number"),
(prop_instance_get_position, pos53, ":scene_item"),
(prop_instance_set_scale, ":scene_item", 0, 0, 0),
(set_spawn_position, pos53),
(spawn_horse, ":horse", 0),
(try_end),
(try_end),
    ]),

      (ti_on_agent_spawn, 0, 0,
        .
        .

ps. To view ingame change Disable Edit Mode (in game configure -> advanced) if enabled
 

Corbul

Sergeant at Arms
WBWF&SNWVC
I tried adding both versions (separately) (AndyYa's and Ramaraunt's), but neither works - the horses in towns are still static. I added the codes to mod_mission_templates as instructed. It compiled without error in both cases, but in-game, there's no difference. What am I doing wrong? :sad:

Edit: Ok, so I tried adding the AndyYa's version as shown just two posts above me. Now the compiler gives me a syntax error for "])," in line 2821, which is the end of the town_center tuple (or whatever it's called). What gives? :neutral:
 
Top Bottom