Having random meshes for a single horse

Users who are viewing this thread

John25-

Sergeant at Arms
Hi everyone, I am working on a mod in which horses should have different colours (meshes) on a single item instead of having three times the same item but with a different mesh for each one. You could tell me to just leave it as it is, but this brings an issue:

One of the units in the mod can be either mounted or dismounted, but so far I have been using three items for the horse (saddle horse, hunter, and courser). The issue is that 3/4 of the units are mounted considering they have 3 horse items in their inventory, while I only want 1/2 of them to be mounted. I have noticed that the usual saddle horse in Warband is black in most cases but can also be white and brown:
["saddle_horse","Saddle Horse", [("saddle_horse",0),("horse_c",imodbits_horse_good)], itp_merchandise|itp_type_horse, 0, 240,abundance(90)|hit_points(100)|body_armor(8 )|difficulty(1)|horse_speed(45)|horse_maneuver(44)|horse_charge(10)|horse_scale(104),imodbits_horse_basic],

bRW1e5g.png

→ From a merchant in-game, and both horses refer to the same item in module_items.py

I am wondering if there is a way to make one horse item with all three saddle horse, hunter, and courser 'colours' (meshes), so that the ratio of mounted/dismounted soldiers would be closer to 1/2, and the ratio of the horse mesh would be close to 1/3 looking like a saddle horse, 1/3 looking like a courser, and 1/3 looking like a hunter. Considering the saddle_horse item can have two meshes (although one of them is imodbits_horse_good), I guess there can be a way to add a third mesh, and most important a way for all of them to appear equally in-game.
If I use a single item in the troop's inventory (new_horse), the ratio of mounted/dismounted soldiers is good (1/2), but all horses appear looking like saddle horses. Here is the code I have made:
["new_horse","Saddle Horse", [("saddle_horse",0),("courser",0),("hunting_horse",0)], itp_merchandise|itp_type_horse, 0,
240,abundance(90)|hit_points(100)|body_armor(8 )|difficulty(1)|horse_speed(45)|horse_maneuver(44)|horse_charge(10)|horse_scale(104),imodbits_horse_basic],

I was hoping that all three meshes would be appearing in-game by removing that imodbits_horse_good from the original saddle_horse item, however only the black ones appear and there are no hunter or courser meshes at all among the troops

I may simply have missed a detail in the coding process for the issue to be sorted, but have no idea of what needs to be done
 
Solution
Sadly I have to tell you that it won't work with horses. Beside the fact that I made a little code misstake of mine, it should be something like
Code:
    (ti_on_agent_spawn, 0, 0, [],
    [
    (store_trigger_param_1, ":agent_no"),
    (agent_get_horse, ":horse", ":agent_no"),
    (gt, ":horse", -1),
    (agent_get_item_id, ":horse_item", ":horse"),#Forgot to get the item_id of the horse, before we only checked the agent_id of the horse.
    (call_script, "script_random_horse", ":agent_no", ":horse_item"),
    ]),
there is the fact that at ti_on_agent_spawn the agents are already spawned. We can change the equipment of spawned agents. However, horses are no equipment anymore inside a scene but they are agents on their own. Now I was...
I have had a look around at horse merchants and the item does appear with different textures, but that's the same as the original saddle_horse item I was referring to in my first message:
bRW1e5g.png

In my case:
6vMdpjV.png


But they don't appear with random colours in the field

As requested:
["new_horse","New Horse", [("saddle_horse",0), ("courser ",imodbit_timid), (" hunting_horse",imodbit_meek)], itp_merchandise|itp_type_horse, 0, 450,abundance(90)|hit_points(100)|body_armor(8 )|difficulty(1)|horse_speed(52)|horse_maneuver(48 )|horse_charge(12)|horse_scale(104),imodbits_random_horse],

["swadian_recruit","Swadian Recruit","Swadian Recruits",tf_guarantee_armor,0,0,fac_kingdom_1,
[itm_scythe,itm_hatchet,itm_pickaxe,itm_club,itm_stones,itm_tab_shield_heater_a,itm_leather_cap,itm_felt_hat,itm_felt_hat,
itm_shirt,itm_coarse_tunic,itm_leather_apron,itm_nomad_boots,itm_wrapping_boots,itm_new_horse],
def_attrib|level(4),wp(60),knows_common,swadian_face_younger_1, swadian_face_middle_2],
 
Upvote 0
Sadly I have to tell you that it won't work with horses. Beside the fact that I made a little code misstake of mine, it should be something like
Code:
    (ti_on_agent_spawn, 0, 0, [],
    [
    (store_trigger_param_1, ":agent_no"),
    (agent_get_horse, ":horse", ":agent_no"),
    (gt, ":horse", -1),
    (agent_get_item_id, ":horse_item", ":horse"),#Forgot to get the item_id of the horse, before we only checked the agent_id of the horse.
    (call_script, "script_random_horse", ":agent_no", ":horse_item"),
    ]),
there is the fact that at ti_on_agent_spawn the agents are already spawned. We can change the equipment of spawned agents. However, horses are no equipment anymore inside a scene but they are agents on their own. Now I was thinking about how to arrange it all before the mission starts, ti_before_mission_start would have been a better place. But then one would not only need to iterate through all parties participating at the battle but also count the relevant troops and make an additional loop for assigning them a random horse. And I am not sure if that is even possible since I doubt that it is possible to store random horses at the same troop type. Inside the mission each troop would be an individual agent and it would have worked perfectly, outside it would work only for hero-troops or the player for which all we ironically enough don't want it to work. I am not a master coder, so it could be feasible in some way. I myself don't see a solution though, so I won't sink more time into it, I already put a couple of hours today at it.

Horses are stupid. For basically everything else you can pick my first solution and it will work out. A pity that it won't work with horses :/

In the case with the random horse you will have to the old solution of having two units: a mounted one with three horse items in its inventory, and a dismounted one with no horse. I will look up how it works with unmounted units, maybe I find a solution for you there.

Is it a special unit troop which only the player can get or which only appears in a specific party (bandits, etc.) or is used by a specific kingdom?

P.S. Can we change the thread title to 'Having random meshes for a single horse'? It would fit better in this case.
 
Last edited:
Upvote 0
Solution
I haven't thought about it for a use in singleplayer yet, so far it is only to be used in multiplayer for ai troops
There is still an option that came to my mind, because there is a 'random' code for faces and scenes - maybe we could try to create some kind of similar coding for horses? Not even sure it is possible though
 
Upvote 0
They are from the standard units that can be selected, even if I added them to the original ones as a fourth troop (archer, footman, horseman, volunteer: mix between mounted and dismounted)
 
Upvote 0
Yes that seems to be the only solution
It makes me wonder though as you said it would work with anything else than horses, have you tried the coding for another item and did it appear randomly in-game?
 
Upvote 0
Quoting my old stuff first
Add in module_strings.py strings like
Code:
  ("random_horse_1", "random_horse_1"),
  ("random_horse__2", "random_horse_2"),
  ...
  ("random_horse_end", "random_horse_end"),
Be aware that the second entry should always be the name of the respective material for the relevant horse mesh. So you need to add the texture variants to your texture folder and create texture and material entries via openbrf in one of your brf files.
Make then use of the operation cur_item_set_material (looking through header_operations.py is worth the time)
Code:
cur_item_set_material                 = 1978   # (cur_item_set_material, <string_no>, <sub_mesh_no>, [<lod_begin>], [<lod_end>]), #only call inside ti_on_init_item in module_items # lod values are optional. lod_end is not included.
Apply it to the relevant horse entry in module_items.py via ti_on_init_item
Code:
 ["common_horse_a","Sumpter Horse",[("sumpter_horse",0)],itp_type_horse,0,50,hit_points(40)|body_armor(1)|difficulty(1)|horse_speed(28)|horse_maneuver(33)|horse_charge(5),imodbits_none,[(ti_on_init_item,[(store_random_in_range, ":rand_horse", "str_random_horse_1", "str_random_horse_end"),(cur_item_set_material, ":rand_horse", sumpter_horse),])]],
The horse should then have a random look. Not sure if I have written it up correctly but should only be bugfixing then for you (I think it should work without assigning the lod values behind).

Give me a short feedback if it works :wink:
I used the cur_item_add_mesh operation in the same way to add random cloaks to an armour and it worked perfectly fine. For the cur_item_set_material it should work perfectly at armouries but I haven't tested it personally yet. I am still organising some of my resources such way to make optimal use of it and the above way would have been how I would do it. Boots might be the only thing at which this operation is not working.
 
Upvote 0
Back
Top Bottom