OSP Kit Combat Battlefield Tactics kit. Multiple formations per team+command revamp!

Users who are viewing this thread

thanks for your answer. I can understand what you say... but think about this (talking about a unique battlemap):

1.- game does not support ( I think , at least native does not) to assign a kind of archers on to 2 different groups:
I mean if you have 20 swadian crossbowmen, you can not assign 10 of them to group 2 and 10 of them to group 4, in example. As far as I know, you can just assign all 20 swadian crossbowmen into a unique group, you can not divide them into 2 different groups.

2.- Not talking about a leveled terrain, but more on a hilly terrain (when I am on hilly terrain I usually try to tell my men to go to the top of the nearest hill and stay there ) , if you could do the point 1 (having 2 diff groups for 1 kind of men) you could tell group 1 to Stay here and group 2 to stay 20 meters back, or front, so that being on a hilly terrain they 2nd row back could fire despite having the 1st row of archers in front of them, couse of the different level of highness.

Point 2 could be applied to infantry as well, if you would like to form a 2-line (row) or 3-rows infantry formation.

So now my question is: could the point 1 be made by scripting/modding? Becouse could be the definetly basis for formations in battles: separate a concrete kind of troop (swadian crossbowmen that are in your party) , divide them into different groups.

Edit : moreover imagine this: (could be awesome!! ) making 3 rows of 12 swadian crossbowmen each row (or vaegir archers, just 1 kind of unit). Each row corresponds to a group, being 1st row = group 2 ; 2nd row = group 4 ; 3rd row = group 5.
Here comes the most difficult idea about this: As I read about crawling scripts and being able to make some players (don't know if it could be applied to AI or only human) to bend, or crawl or lower their body... imagine now telling 1st group to fire !... then telling 1st group to crawl (static, don't know the word, get their body down in the ground), so the 2nd row can fire. Then you order 2nd row to fire, and they would crawl too after firing, so the 3rd row can fire .
Could something like this be possible?
Thanks again
 
Everthen said:
thanks for your answer. I can understand what you say... but think about this (talking about a unique battlemap):

1.- game does not support ( I think , at least native does not) to assign a kind of archers on to 2 different groups:
I mean if you have 20 swadian crossbowmen, you can not assign 10 of them to group 2 and 10 of them to group 4, in example. As far as I know, you can just assign all 20 swadian crossbowmen into a unique group, you can not divide them into 2 different groups.
actually, I have been trying to see if there was a way to assign precise groups rather than by troop types.  Even go as far as looking at using blank troops to temporarily copy the troop data and adjust the numbers.  e.g. say I have 40 swardian crossbowmen, I can use an unused troop id to copy over data for swardian crossbowmen (let's call this crossbowmen_b), then add say 20 crossbowmen_b to the party, while reducing crossbowmen to 20.  Then theoretically, the 2 troop slots can be assigned to different divisions... but it seems that troop data cannot be copied completely? and the pre/post battle adjustments is messy, and it is hard to scale to npcs ( i don't like doing stuff just to make player party special, but would prefer if npc can do this as well).

iow, it seems not feasible. unless done at engine level.

There IS another possibility of keeping the grouping info completely abstract and instantiate it only when creating agents for the battle, but it is another logistics hell which I don't feel comfortable looking into yet.  perhaps some brave souls can give it a try?

2.- Not talking about a leveled terrain, but more on a hilly terrain (when I am on hilly terrain I usually try to tell my men to go to the top of the nearest hill and stay there ) , if you could do the point 1 (having 2 diff groups for 1 kind of men) you could tell group 1 to Stay here and group 2 to stay 20 meters back, or front, so that being on a hilly terrain they 2nd row back could fire despite having the 1st row of archers in front of them, couse of the different level of highness.

Point 2 could be applied to infantry as well, if you would like to form a 2-line (row) or 3-rows infantry formation.

So now my question is: could the point 1 be made by scripting/modding? Becouse could be the definetly basis for formations in battles: separate a concrete kind of troop (swadian crossbowmen that are in your party) , divide them into different groups.

Edit : moreover imagine this: (could be awesome!! ) making 3 rows of 12 swadian crossbowmen each row (or vaegir archers, just 1 kind of unit). Each row corresponds to a group, being 1st row = group 2 ; 2nd row = group 4 ; 3rd row = group 5.
Here comes the most difficult idea about this: As I read about crawling scripts and being able to make some players (don't know if it could be applied to AI or only human) to bend, or crawl or lower their body... imagine now telling 1st group to fire !... then telling 1st group to crawl (static, don't know the word, get their body down in the ground), so the 2nd row can fire. Then you order 2nd row to fire, and they would crawl too after firing, so the 3rd row can fire .
Could something like this be possible?
Thanks again

You're asking for something beyond just formations w formation ai.  I did some prelim design for something like this.  I'll say possible, but not necessary feasible. and questionable how well it really fits individual playing styles too.  formation with simple formation-specific ui will prob have more audience.  But honestly, I am more ambitious than you, but just not confident enough to tackle that problem yet (at least until first problem from above is solved). 

Basically, i think a more complete solution would be to have simple formations and formation-level ai(fixed in modes), a tactical level ai that can switch formations for a group or change modes for a formation (e.g. order cavalry to regroup or charge), and a strategic-level ai, that groups troops into formations and set parameters for tactical-level ai.  The tactical and strategic level ai can be suppressed/replaced by player if it is his side, but can be automated (possibly wrt to culture) if commander is npc.  But this is just a rough design.  I'm looking at an experiment on the map-level ai first.  When I can get a decent design working, then I'll look into whether a similar framework can be transplanted to the mission-level.

apologise if I sound a little blur, feels blur after working on something for a long time... lol
 
Version 3.16 9/30/2010, specially for othr!

-- Reenable archer stagger as option
-- Fix typo in team faction determination script
-- AI: default long range extended to empirical limit
-- Fix centering: archers Hold-F1, stand closer, spread out; archers & infantry Hold from battle panel
-- AI: add cavalry line charge and generally make them more aggressive
-- AI: add leader placement for when there is no infantry to stand by
-- AI: remove leader speed limitation: no longer needed
-- Have battlegroups/divisions 3-8 hold at start of battle

http://www.mbrepository.com/file.php?id=2207

EDIT: I added the line charge to v3 since it was not an extensive addition (in terms of lines -- took me a day to think those lines through though).

Still some weirdnesses. Sometimes last few cavalry end up stranded in a hold position. I have continuing challenges with get_position -- cavalry wedge may pace (due to reported target position teleporting) and archers slide left over time.
 
Hi,

I'm trying to test out the code by manually installing it to a standard v1.132 module system.

Unfortunately the AI is not working and I think it must have been something in the manual install that I did wrong.
The build has warnings about unassigned variables in mainly scripts but also in presentations when I build the manual install.

To make it build without warnings I had to put the following into script_start_game:

Code:
     
              (assign, "$fplayer_agent_no",0),
              (assign, "$fplayer_team_no", 0),           
              (assign, "$autorotate_at_player", 0),
              (assign, "$team0_faction", fac_kingdom_1),
              (assign, "$team1_faction", fac_kingdom_2),
              (assign, "$team2_faction", fac_kingdom_3),
              (assign, "$team3_faction", fac_kingdom_4),
              (assign, "$cur_casualties", 0),
              (assign, "$team0_reinforcement_stage", 0),
              (assign, "$team1_reinforcement_stage", 0),

I noticed in the manual install instructions that there is no mention of renaming the "decide_run_away_or_not" script. However that script is stated to be replaced with the equally named function in the formAI_scripts_wb.py file (line 2211). So I renamed the original "decide_run_away_or_not" to "orig_decide_run_away_or_not" and moved your "decide_run_away_or_not" to themodule_script code (as the last function in that file).

What else ... in module_constants I moved your code over like this:
Code:
# Formations for Warband by Motomataru
# rel. 08/27/10

#Formation modes
formation_none	= 0
formation_default	= 1
formation_ranks	= 2
formation_shield	= 3
formation_wedge	= 4
formation_square	= 5

#Formation tweaks
formation_minimum_spacing	= 67
formation_start_spread_out	= 2
formation_min_foot_troops	= 12
formation_min_cavalry_troops	= 5
formation_autorotate_at_player	= 1
formation_native_ai_use_formation = 1
formation_delay_for_spawn	= .4
formation_stagger_archers	= 0

key_for_ranks	= key_j
key_for_shield	= key_k
key_for_wedge	= key_l
key_for_square	= key_semicolon
key_for_undo	= key_u


###FormAI_constants:
#AI variables
AI_long_range	= 13000	#do not put over 130m if you want archers to always fire
AI_firing_distance	= AI_long_range / 2
AI_charge_distance	= 2000
AI_for_kingdoms_only	= 0
Weapon_Length_Proxy	= 100
Far_Away	= 1000000
Percentage_Cav_For_New_Dest	= 40
Hold_Point	= 100	#archer hold if outnumbered
Advance_More_Point	= 100 - Hold_Point * 100 / (Hold_Point + 100)	#advance 'cause expect other side is holding
AI_Delay_For_Spawn	= formation_delay_for_spawn + .1	#fire AFTER formations init

#Battle Phases
BP_Setup	= 1
BP_Jockey	= 2
BP_Fight	= 3

#positions used in a script, named for convenience
Nearest_Enemy_Troop_Pos	= 46	#pos46
Nearest_Non_Cav_Enemy_Troop_Pos	= 47	#pos47
Nearest_Threat_Pos	= 48	#pos48
Nearest_Target_Pos	= 49	#pos49
Infantry_Pos	= 50	#pos50
Archers_Pos	= 51	#pos51
Cavalry_Pos	= 52	#pos52
Enemy_Team_Pos	= 53	#pos53
Nearest_Enemy_Battlegroup_Pos	= 54	#pos54

#positions used through AI trigger
Player_Battle_Group3_Pos	= 24	#pos24
Player_Battle_Group4_Pos	= 25	#pos25
Player_Battle_Group5_Pos	= 26	#pos26
Player_Battle_Group6_Pos	= 27	#pos27
Player_Battle_Group7_Pos	= 28	#pos28
Player_Battle_Group8_Pos	= 29	#pos29

Team0_Infantry_Pos	= 30	#pos30
Team0_Archers_Pos	= 31	#pos31
Team0_Cavalry_Pos	= 32	#pos32
Team0_Average_Pos	= 33	#pos33
Team1_Infantry_Pos	= 34	#pos34
Team1_Archers_Pos	= 35	#pos35
Team1_Cavalry_Pos	= 36	#pos36
Team1_Average_Pos	= 37	#pos37
Team2_Infantry_Pos	= 38	#pos38
Team2_Archers_Pos	= 39	#pos39
Team2_Cavalry_Pos	= 40	#pos40
Team2_Average_Pos	= 41	#pos41
Team3_Infantry_Pos	= 42	#pos42
Team3_Archers_Pos	= 43	#pos43
Team3_Cavalry_Pos	= 44	#pos44
Team3_Average_Pos	= 45	#pos45

#positions used through battle
Team0_Cavalry_Destination	= 56	#pos56
Team1_Cavalry_Destination	= 57	#pos57
Team2_Cavalry_Destination	= 58	#pos58
Team3_Cavalry_Destination	= 59	#pos59
Team0_Starting_Point	= 12	#pos12
Team1_Starting_Point	= 13	#pos13
Team2_Starting_Point	= 14	#pos14
Team3_Starting_Point	= 16	#pos16
### End of formAI_constants
I moved over only the "from header_triggers import *" (to the import section in the top section of the module_constans file) and I put your constants at the end of the constants file (after the native Achievement constants).

As for the rest I followed the instructions in the readme.txt

Any ideas what I should change to make it work.

On the battlefield there is basically no AI (the AI sends one single unit to charge and the rest of them form a formation and stand still all the time). The formation keys do not work and I even experienced sporadic invisible weapons and shields textures (with 1.132).
 
Treebeard said:
Any ideas what I should change to make it work.

OK, lessee. It sounds like the triggers got lost.

You should have added both the "formations_triggers = [..." and "AI_triggers = [..." structures to module_missions_templates.py. Or more simply a "from formations_mission_templates_wb import formations_triggers" and similar for AI.

Then you added them to any desired mission template triggers array (like for "lead_charge") like so:

Code:
      common_battle_order_panel,
      common_battle_order_panel_tick,

    ] + formations_triggers + AI_triggers
  ),

I believe you must insert the structures BEFORE they are called (i.e., above the line "mission_templates = [").

??? As for constants, in the original files the constants definitions ARE left adjusted. I don't know how they ended up not in your file. Perhaps your editor added an indent?

Thanks for the heads up on script_decide_run_away_or_not.

The textures and items: remember you have to start with a new clean copy of mod/Native 1.132, as well as use the 1.132 module source code.

Hope this helps!
 
motomataru said:
Then you added them to any desired mission template triggers array (like for "lead_charge") like so:


      common_battle_order_panel,
      common_battle_order_panel_tick,

    ] + formations_triggers + AI_triggers
  ),

Thanks for the suggestions. I will look over the code again and see if I understand how to attach them (the bold part in the quote) to mission templates.

I didn't attach any formations_triggers or ai_triggers to mission templates (the bold part), so maybe that is the reason the AI was so passive?
By the way the bold part is not to be taken literally, correct?
 
Lumos said:
It is to be taken absolutely literally. But you don't need to add the square bracket (or whatever it's called - I mean this: ]).

Thank you for the clarification.



When using it the way Motomataru described it works. Leaving the last comma in place works too:

Code:
      common_battle_order_panel,
      common_battle_order_panel_tick,
    ] + formations_triggers + AI_triggers,
  ),

Edit2:
And with the above code, I also do not get any unassigned variable errors (- I commented out the "fake" assigns for them in script_game_start).

Time to test this on the battlefield :smile:

Edit 3:
I am still seeing a few graphical issues when using the manual install. Namely, when I start a new game, my character on the main map starts out being invisible. When I move him everything goes back to normal.

I used the 1.132 module system, manually installed the formations+AI kit and have a fresh folder copy of Native (- a test_Native) to which I build the module.
This graphics issue might only affect ATI users with Catalyst 10.7 or greater though.

Edit 4:
Actually the graphics glitch at start is present in normal Native too, so it seems TW didn't fix it completely in the 1.132 patch.
 
v3.17 AI refinements
http://www.mbrepository.com/file.php?id=2207

10/07/2010
-- Change: archer stagger is now archer "ranks" formation
-- AI: close a couple loopholes that were preventing infantry advance
-- AI: change logic that sometimes kept cavalry from charging
10/15/2010
-- AI: broaden test of army nearness to enemy for switch into fight phase
-- AI: break formation only for lower level troops
-- AI: remove random variable in cavalry target assessment
-- AI: double cavalry strength assessment vs. potential non-cavalry threat/target
-- AI: specify cavalry decision to free fight more precisely
-- AI: ignore fake reinforcements (i.e. reinforcements stages > 1)
-- AI: handle no archer situation for horse archers and during reinforcement
-- AI: remove obsolete destination tracking for cavalry wedge (and whatever loopholes that created)
 
v3.18 fixes and other random stuff
http://www.mbrepository.com/file.php?id=2207

-- AI: handle team_give_order lumping mounted heroes with infantry (made non-leader heroes do nothing but stand)
-- Rewrite arcsine in script_point_y_toward_position from scratch (Native "normalized" vector warbled, etc.)
-- Shut down reform on Stand Ground
-- Center rotation on reform (in progress)
-- AI: refine infantry formation approach
-- Reset reform clock for most formation commands
-- Fix centering function error (caused infantry in square to run off)
-- AI: Fix null target/threat logic (caused cavalry to run off) (thanks Treebeard)
 
Thanks for the update motomataru, giving it a shot :smile:

EDIT: Great improvements Motomataru, definitely loving what you did.  Only one suggestion, when there is lots of cavalry on one side and the charge begins soon after spawning, it would be nice for the charging cav to spread out a little so they don't bump into each other and form a huge traffic jam :smile:

Oh some version ago when cavalry attempted to avoid certain troop types it had a very good effect on horse archers.  Check this thread and the video linked in the first reply: http://forums.taleworlds.com/index.php/topic,145100.0/topicseen.html

Even though the horse archers in the video are in the wedge formation they behave so well!
 
@motomataru

This looks great! I'd like to include it in my mod, Battle for Hindustan.  I've a few questions about it though, hope you can find the time to answer.

1) Is your formations code compatible with Chel's morale code? If it is, what happens when troops rout?  Do individual troops leave the formation, or does the formation collapse entirely?

2) I'm using dstemmer's Command Cursor.  I read something about different unit types forming up at certain positions relative to where you pointed them to hold.  Can I change this so troops form up exactly where I pointed them, and what do I change in your code to do it? 

I also plan to revise the positioning a bit - instead of your default, I'm going to put cav on the right, infantry on the left, because in the Hindustan mod a lot of the cav are horse archers and are most effective when they charge from the party's right.  This position allows them to fire more easily, as they shoot best to the left.

Thanks!

 
Is there any way to stop the player army from initially 'forming ranks' at the beginning of the battle?  I am trying to make this kit compatible with
http://forums.taleworlds.com/index.php/topic,142816.0.html - Pre battle orders & Deployment, but currently the 'forming ranks' null's the pre-orders I've set for troops.

I love the different A.I. of enemy lords, it really spices up native quite nice.  Also, I wanted to ask if there are any plans to explore the quirk/bug in horse archer behavior that resulted from your script that made cavalry avoid spears while holding a wedge formation?  I saw a video on Youtube of a past version of 1257 where this behavior seemed to be quite effective.
 
Sorry to take so long responding. My machine was in the shop...

dariel said:
1) Is your formations code compatible with Chel's morale code? If it is, what happens when troops rout?  Do individual troops leave the formation, or does the formation collapse entirely?
I don't know for sure. For WB, when a troop is routing, I basically ignore it. In the case you mention, the unit will form without the routing troop. The formation will continue bleeding routed (or reintegrating rallied) troops until it falls below the minimum number of troops to make a formation (set by you in module_constants).
dariel said:
2) I'm using dstemmer's Command Cursor.  I read something about different unit types forming up at certain positions relative to where you pointed them to hold.  Can I change this so troops form up exactly where I pointed them, and what do I change in your code to do it? 
On a Hold-F1, my code tests if multiple units are listening. If so, it uses the same positioning as for F1-F1, as if the player were located at the Hold-F1 position. Otherwise the unit should center at the spot. All of this is controled by the trigger titled
Code:
#implement HOLD OVER THERE when player lets go of key
in module_missions_templates.

Note that right now I'm overhauling formation centering, 'cause it's not working perfectly.
dariel said:
I also plan to revise the positioning a bit - instead of your default, I'm going to put cav on the right, infantry on the left,
??? It ought to be doing this. I reversed positioning early in v3 after Idibil informed me that commanders stood on their unit right since antiquity. Are you sure you have the latest release? See

http://www.mbrepository.com/file.php?id=2207

StinkyMcGirk said:
Is there any way to stop the player army from initially 'forming ranks' at the beginning of the battle? 
The code blocks starting
Code:
		(display_message, "@Forming ranks."),
in module_missions_templates.
StinkyMcGirk said:
I love the different A.I. of enemy lords, it really spices up native quite nice. 
Thanks! The effect comes from all the logic "rabbit holes" that are in there now. And more are on the way as the mod community develops more extensions. Some of the things that happened last month that I need to catch up with!
StinkyMcGirk said:
Also, I wanted to ask if there are any plans to explore the quirk/bug in horse archer behavior that resulted from your script that made cavalry avoid spears while holding a wedge formation?  I saw a video on Youtube of a past version of 1257 where this behavior seemed to be quite effective.
Latest release addresses this. My arcsine function was depending on the engine vector normalization which was actually shifting back and forth about 10 degrees, causing problems where the "compass" overlaps. I completely rewrote the sucker plus a lot of related stuff.

BTW, the actual code definition of a threat to be avoided (if a target exists elsewhere) takes into account numbers and experience as well as (a proxy for) weapon length.
 
So glad you're back!

The newest patch implemented agent_set_division, imagine the possibilities now :smile:

 
Yeah, NOW they make an arcsine function. Actually, I knew it was coming down the pike, but since I'm still supporting M&B...

Another personal development for me is that I've (finally) picked up a temp job. Hence, I may not be able to do much on this until May. The good news is that a couple coders from the community, Caba'drin and Treebeard, have lent and may continue to lend their considerable expertise to expanding/improving the project.

"Version 3" seems fairly stable now, thanks to its trial-by-fire in Brytenwalda, so I'm thinking of presenting new features in this thread only, as "Version 4 Development." That way you modders can choose which to use...
 
Is it possible to disable routing for certain factions? I'd hate to see droids running away, my mod isn't the stupid new cartoon, and clones fight to the last man.
 
Updated v3 again: bug fixes.

CC-4361 Lux said:
Is it possible to disable routing for certain factions? I'd hate to see droids running away, my mod isn't the stupid new cartoon, and clones fight to the last man.

I'd probably add a couple tests-for-faction to the module_mission_templates trigger that calls script_decide_run_away_or_not -- the one that looks like this:

Code:
      (3, 0, 0, [
          (try_for_agents, ":agent_no"),
            (agent_is_human, ":agent_no"),
            (agent_is_alive, ":agent_no"),          
            (store_mission_timer_a,":mission_time"),
            (ge,":mission_time",3),          
            (call_script, "script_decide_run_away_or_not", ":agent_no", ":mission_time"),
          (try_end),          
              ], []), #controlling courage score and if needed deciding to run away for each agent
 
Back
Top Bottom