• Please note that we've updated the Mount & Blade II: Bannerlord save file system which requires you to take certain steps in order for your save files to be compatible with e1.7.1 and any later updates. You can find the instructions here.

WB Coding Spawn mantlets/carts as barricades

Users who are viewing this thread

dariel

Sergeant Knight at Arms
Hi all! Quick question: I want to be able to spawn the siege_large_shield or cart props in a line in front of a team's troops in battle if the commander meets a condition (probably Tactics + either having Tools in inventory or something else). I already have an idea of how to use set_spawn_position and spawn_scene_prop. My question is about positioning. How do I find the coordinates of the left and right ends of a team's battle line?

(I'm trying to emulate the Turkish/Mughal 'tabur cengi' battle formation that uses carts and mantlets as barricades.)

Thanks!
 
Solution
Exactly, 0 is the level of water, so terrain covered by it will always fall below said value.

position_get_distance_to_terrain is the operation to measure the distance to the ground level (excluding and ignoring scene props and their collision meshes). With WSE, you can align scene props to the ground level with some other fancy operations.

dariel

Sergeant Knight at Arms
Thanks for the replies. If these use .sco files to create these battles though that's not what I'm looking for. I'm looking for a way to do it from within the mission_template scripts.
 
Upvote 0

RecursiveHarmony

This looks like a geometry question essentially.
First you need to know how much space those wagons and soldiers take. You can write a simple trigger that displays your position's x and y coordinates then find someone to battle and figure it out at the battlefield. Or simply use some constant value like 0.5x0.5 meters per soldier.
About positioning wagons.
If you do it circular like this
EW3FdTGX0AcNGqh

(Source: tweet, also talks about the history of "tabur cengi" in Turkish)
It becomes a convex regular n-gon (look at the wiki image). My advice is advancing the size using the multiplies of 2 ( 4,6,8,10...). In those cases, longest diagonal is the diameter of the circle encircling the polygon. It may help with the calculations.
Rectangular shape looks easier to implement. It doesn't require angle calculations. You only need to rotate the side wagons 90 degrees.
If you can't figure out how to implement the calculations, go to the nearest high school and find a nerdy-looking student :grin:
 
Upvote 0
There are more implications of such endeavor, such as AI Mesh. Using .sco files would prove to be much easier and prone to yield fewer bugs in total. The ultimate drawback would be the boredom of having only a handful of scenes at disposal.
 
Upvote 0

Eärendil Ardamírë

Subforum Moderator
WBWF&SM&B
Agreeing here with Veledemtella. With random scenes are coming random hills (and rivers) and the placement of scene props simply by code might end with odd results, not even taken random bushes and trees into account.
 
Upvote 0

RecursiveHarmony

Carts can be destroyable if it helps with the ai mesh. For other issues one can remove all randomly generated scene objects in the area and flatten the terrain if these are possible by the operations. I think WFAS does something like this but i have to play a couple battles to see how it handles the situation.
Using .sco files would prove to be much easier and prone to yield fewer bugs in total.
I agree with that. He seemed enthusiastic about making it in the hard but flexible way. I just gave him some insights.
 
Upvote 0

RecursiveHarmony

I think WFAS does something like this but i have to play a couple battles to see how it handles the situation.
After a couple battles and checking module_scenes.py i can say WFAS uses scenes (actually 3, oim_wagenburg_small, oim_wagenburg_medium and oim_wagenburg_big). I guess he's stuck premade scenes rather than random ones.
 
Upvote 0

dariel

Sergeant Knight at Arms
Thanks for the replies! I do want to use random scenes. My plan is to spawn just a line covering the front, using the cart and siege shield objects already in Native which already have collision meshes.

Is there any way to find the elevation at a given coordinate, or can I just use the position_set_z_to_ground_level to put it correctly on the ground without knowing the elevation?

Also, is there a way to get the terrain type at a given coordinate inside a scene? Looked for an operation in header_operations and there doesn't seem to be any, just checking if I missed something.
 
Last edited:
Upvote 0
Is there any way to find the elevation at a given coordinate, or can I just use the position_set_z_to_ground_level to put it correctly on the ground without knowing the elevation?
I think there is no option to find out what you described (even with WSE). You may experiment with the operation, but some parts of the props you specified might be sort of protruding above the terrain level on slight inclinations. You are free to test it.
Also, is there a way to get the terrain type at a given coordinate inside a scene?
What do you mean by terrain type? Position with respect to water level, degree of inclination or texture used?

As I forgot to add, it is better to stick to pre-made scenes. Even if you succeeded in positioning the scene props to form an encampment, the entire scene would lack the basic quality of gameplay, as there is no way to cover the ground with AI Mesh with scripted operations. As a result, there would be no possibility of reaching foes across the wagons with melee weapons and on foot. Bots would get stuck in attempts to engage in combat and any shootout with ranged weapons would be very chaotic. Too much work with scripting...
 
Upvote 0

dariel

Sergeant Knight at Arms
I should have been more specific - I meant to ask if there was a way to tell if a spot is water or land, so barricades won't be placed in water.
 
Upvote 0

Eärendil Ardamírë

Subforum Moderator
WBWF&SM&B
Should be the operation position_get_distance_to_terrain. Afaik water is appearing if the terrain level is below zero. So you can make a check if it is negativ or not, negative values should indicate for water then.
 
Upvote 0
Exactly, 0 is the level of water, so terrain covered by it will always fall below said value.

position_get_distance_to_terrain is the operation to measure the distance to the ground level (excluding and ignoring scene props and their collision meshes). With WSE, you can align scene props to the ground level with some other fancy operations.
 
Upvote 0
Solution
Top Bottom