Horses and Agents as scene props.

Users who are viewing this thread

f5aP1Fu.jpg
Hello, I have just started to try and learn some of Warbands scripting and have so far created some "scene props" that have some nice abilities such as props that spawns an actual horse rather than a static mesh as well as ones that spawn AI, they work quiet well aside from a few oddities with the AI, (They are always the first team, defence, attack guards in failed sneaking ect) but to make these props better I'd like to be able use the scene props Var and Var2 numbers to assign which troop or horse to spawn and eventually what animation or team they are, this would hopefull have some amazing outcomes that don't require the user to muck around in mission templates.
so far the script looks like this in python.

(ti_on_scene_prop_init,
    [
    (spawn_agent,<agent_ID_goes_here>),
    ])
  ]),
]


but I'd like it to be something like

(ti_on_scene_prop_init,
    [
    (spawn_agent,
    (prop_instance_get_variation_id, <destination>, <scene_prop_id>)),
    ])
  ]),
]


But I got errors, and I'm not sure what goes in <destination> and if leaving <scene_prop_id> as blank will use the current scene props ID

Any help or suggestions would be awesome,

If you want to try it for yourself add these to your scene_props.txt and adjust the number under scene_propsfile version 1 adding +1 for each new scene prop

spr_Spawn_Agent 0 0 0 0 1
-40.000000  1 1972 1 97


Change "97" to whatever troop ID you want to spawn.

spr_Spawn_Horse 0 0 0 0 1
-40.000000  1 1973 2 9 0


Change"9" to watever Horse ID you want to spawn

and just another code useful for multiplayer mood setting

spr_Spawn_Rain 0 0 0 0 1
-40.000000  1 1797 2 1 100


Change the "1" to 2 for snow and the "100" is strength from 0-100

Also here are some more shenanigans
TqDjvSw.jpg

jk7I9D3.jpg

xWPoAH9.jpg



 
spawn_agent is fairly buggy, horses shouldn't be a problem but it's a PITA to get the game to recognize them the same way as regular agents.
Code:
store_trigger_param_1
returns the trigger's parameter (instance id) which you then plug into
Code:
prop_instance_get_variation_id/id_2
 
(ti_on_scene_prop_init,
    [
    (store_trigger_param_1,":scene_prop_id"),
    (prop_instance_get_variation_id, ":var_id", ":scene_prop_id"),
    (spawn_agent,":var_id"),
    ])
  ]),
]


It works! Thank you Somebody! The only problem it seems is that scene props Var1/var2 can only go up to 100 therefore only being able to set the first 100 troops, I could probably fix this by using scale or another variable to set the troop but I'm just happy it works and that I was able to learn how to use the coding a bit better.

For anyone who wants to try this for yourself just put this in your scene_props.txt

spr_Spawn_Agent 0 0 0 0 1
-40.000000  3 2071 1 1224979098644774912 1840 2 1224979098644774913 1224979098644774912 1972 1 1224979098644774913


Also note Variations is set to default of 0, therfore spawns another version of the player, so in campaign another version of you (with a random face) and multiplayer a blank naked man.
 
No, the idea is a scene prop having the ability to spawn any agent the user wants in a scene and hopefully also choose an animation for them, so a more living breathing world, so you could easily add soldiers drinking at the tavern, villagers cutting wood, cheering crowds at the arena and King Harlaus eating butter in the streets.
 
Scene props variation id are 7 bits long (127 is the max number (including 0)). What you can do is mix both variation ids, so you will get a 14 bits long number (16383 being the highest value (including 0)).
To do that, you can use one of these simple formulas (they are the same) to get that number:
Code:
variation_1 << 7 + variation_2 
OR 
variation_1 * 128 + variation_2
Now, the tricky part is what values you should put for that specific scene prop. Here it is how you decide what to put in both variation ids:
Code:
variation_1 = troop_id / 128
variation_2 = troop_id % 128
 
Hopefully someone can help with my ideas,

Scene Prop Scale


J1ItcoD.jpg


As The_dragon has said Var1 and Var2 for scene props only go up to 128 so using them to choose an agent to spawn is limiting, so I hoped to use the scene props scale information to have bigger numbers. like this.

(ti_on_scene_prop_init,
    [
    (store_trigger_param_1,":scene_prop_id"),
    (prop_instance_get_position, pos1, ":scene_prop_id"),
    (position_get_scale_x,":scale_x", pos1),
    (spawn_agent,":scale_x"),
    ])
  ]),


Either I've mucked up the script or it works differently to how I think it should, there is a set scale operation for scene props that looks like this.

(prop_instance_set_scale, <scene_prop_id>, <value_x_fixed_point>, <value_y_fixed_point>, <value_z_fixed_point>),

But the get scale looks like this

(prop_instance_get_scale, <position_no>, <scene_prop_id>),

And doesn't seem to yield any results either, so my question is how do I return the scene props individual scales?
so
Scale X = 1.000128
Scale Y = 1.000235
Scale Z = 1.000246

The main Idea is to be able to have an X scale of 1.000128,
and return a result of 128, that way the reference scene object stays more or less the same but can have heaps of information.

Talking

I'd like to disable talking for agents as it will break their animation direction, or set it to be like the archers in the tutorial (They don't look at you and continue their animation) I have to find the Tutorial archer code but I think disabling talking to the agent would be easier.
 
ShaunRemo said:
Hopefully someone can help with my ideas,

Scene Prop Scale


J1ItcoD.jpg


As The_dragon has said Var1 and Var2 for scene props only go up to 128 so using them to choose an agent to spawn is limiting, so I hoped to use the scene props scale information to have bigger numbers. like this.

(ti_on_scene_prop_init,
    [
    (store_trigger_param_1,":scene_prop_id"),
    (prop_instance_get_position, pos1, ":scene_prop_id"),
    (position_get_scale_x,":scale_x", pos1),
    (spawn_agent,":scale_x"),
    ])
  ]),


Either I've mucked up the script or it works differently to how I think it should, there is a set scale operation for scene props that looks like this.

(prop_instance_set_scale, <scene_prop_id>, <value_x_fixed_point>, <value_y_fixed_point>, <value_z_fixed_point>),

But the get scale looks like this

(prop_instance_get_scale, <position_no>, <scene_prop_id>),

And doesn't seem to yield any results either, so my question is how do I return the scene props individual scales?
so
Scale X = 1.000128
Scale Y = 1.000235
Scale Z = 1.000246

The main Idea is to be able to have an X scale of 1.000128,
and return a result of 128, that way the reference scene object stays more or less the same but can have heaps of information.

Talking

I'd like to disable talking for agents as it will break their animation direction, or set it to be like the archers in the tutorial (They don't look at you and continue their animation) I have to find the Tutorial archer code but I think disabling talking to the agent would be easier.

afaik, you need to use set_fixed_point_multiplier or sth like that, cause warband variables don't work with decimals, only with integers. this way if you set the fixed point to be 1000000 for example, you'll get 1000128 instead of 1 (which was 1.00012:cool:
 
Hey thank you Ikaguia that really helped, I've managed to achieve everything at a basic level now,
The new code is in the spoiler if you want to use it,
It works like

1.000128 for Scale X will spawn troop 128,
1.000497 for Scale Z will set animation 497
1.000546 for Scale Y will give them item 546,

It's a little bit fiddly but considering you can now spawn any troop into any scene with any item and animation you choose I think that's pretty good.
I hope to use Var1 and Var2 to set conditions for the agents spawning only at night, during the day, only during feasts, only with tournaments etc.


(ti_on_scene_prop_init,
    [
    (store_trigger_param_1, ":scene_prop_id"),
          (set_fixed_point_multiplier, 1000000),
          (prop_instance_get_scale, pos5, ":scene_prop_id"),
          (position_get_scale_x, ":scale_x", pos5),
          (store_sub,":agent",":scale_x",1000000),
          (gt,":agent",0),
          (position_get_scale_y, ":scale_y", pos5),
          (store_sub,":animation",":scale_y",1000000),
          (position_get_scale_z, ":scale_z", pos5),
          (store_sub,":item",":scale_z",1000000),
          (prop_instance_get_variation_id_2, ":var_id_2", ":scene_prop_id"),
    (spawn_agent,":agent"),
    (agent_set_no_dynamics, reg0, ":var_id_2"),
    (try_begin),
                (gt,":item",0),
                (agent_equip_item, reg0, ":item", 0),
                (agent_set_wielded_item, reg0, ":item"),
    (try_end),
    (try_begin),
                (gt,":animation",0),
                (lt,":animation",553),
                (agent_set_stand_animation, reg0, ":animation"),
                (agent_set_animation, reg0, ":animation"),
                (agent_clear_scripted_mode,reg0),
    (try_end),
    ])
  ]),

I've taken a few screenshots and have used the sitting animations from Slawomir of Aaarrghh tavern animation pack.

xtQlrXo.jpg

Two Soldiers sitting in the sun.

YKjGy8p.jpg

3 soldiers using the wedding animations, and a guy in the back using the staff defend up animation.

doddaho.jpg

All the different factions prison guards sitting together.

Currently the only issue I'm having so far is I can't disable talking for specific agents so they turn to you potentially breaking the animation and also say off topic things.
 
Back
Top Bottom