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

正在查看此主题的用户

I need help...

I got stuck while trying to get the pikemen-only formation script to work.

I needed a series of troops(upgrade tree of pikemen, pikemen of different factions) to use formation while everything else behave like native.

There are so many troops that I can't list them one by one, so I had to try stuff that I never learned(I never officially learned anything about scripting)

I set in module_constants:

rhodoks_begin = "trp_rhodok_tribesman"
rhodoks_end = "trp_rhodok_messenger"
(I'm using native to test out if the script works)

then in module_scripts where the formation is:

...............

      (try_for_range, ":rhodok", rhodoks_begin, rhodoks_end),
      (agent_get_troop_id,":troop", ":teamleader"),
      (eq,":troop",":rhodok"),

...............

      (try_for_range, ":rhodok", rhodoks_begin, rhodoks_end),
      (agent_get_troop_id,":troop", ":agent"),
      (eq,":troop",":rhodok"),

...etc.



Obviously it didn't work. The rhodoks acted the same as in native, nobody was using formations.

First of all I am not sure at all if "try_for_range" is what I should use to include all rhodok troops, and second I don't know how to make ":rhodok" the ones using formation while everybody else doesn't.

Could someone please tell me if I'm doing anything right and which parts are wrong?

 
Very helpful as always Mirathei!

Not exactly formation scripts but I was wondering (given that its a battlefield tactics kit in general) if it were possible to set up a system for translating world map context into battlefield starting orders and position.

For example, currently in Native, if on the world map I have 40 Khergit Horse Archers and attack 30 Mountain Bandits, who are "Running Away From Player", I get the 'cowardly' dialogue (i.e. "Eh? What do you want") from the Mountain Bandits and then I go to lead_charge.  Now, despite the cowardly behaviour on the world map, the Mountain Bandits still charge my horse archers in a suicidal manner on the battlefield.  This is of course stupid and makes things predictable.

So an alternative system: There are two factors at work on the world map of relevance, these are relative speeds of the parties (e.g. Khergit Horsemen are faster than Peasants) and the differing attitudes of the parties (generally one party is fleeing, and/or another party is attacking).  Relevant battlefield properties associated with this are to my mind, starting location(s) and default AI orders (Hold, Charge etc.)

The logic of this system would be to as said, translate these properties from world map to battlefield.  So (forgive the crude pseudocode):


Strength:

IF ai_party_attitude == attack_player_on_world_map AND ai_party_speed <= player_party_speed THEN
  Both parties spawn at opposite edges of field
  AI starting orders Charging, Player is Holding

IF ai_party_attitude == attack_player_on_world_map AND ai_party_speed > player_party_speed THEN
  Player spawns in CENTRE of battlefield
  AI spawns on two opposite edges of battlefield
  AI starting orders Charging, Player is Holding

IF ai_party_attitude == flee_player AND ai_party_speed <= player_party_speed THEN
  AI spawns in CENTRE of battlefield
  Player spawns on one edge of battlefield
  AI starting orders Holding, Player is charging

IF ai_party_attitude == flee_player AND ai_party_speed > player_party_speed THEN
  Both spawn on two opposite edges of battlefield
  AI starting orders Holding, Player is charging

NB: Mounted skirmishers would always charge.

The effect of this would be more intelligent battles, hopefully.  For example, if your 20 pikemen are attacked on the world map by a party of 20 Swadian Knights and 25 Footmen, then you would start the battle in the centre of the field, in a pincer movement caught between the two enemy troops (knights on one side, footmen on the other)

The major snag with the formations I guess would be if there was only one type of unit (e.g 20 pikemen versus 40 horsemen) on each side - the pincer movement would be difficult to keep together as the two units spawned on each side of the battlefield would try to get into one formation at the start of the battle, though you could add some logic checks to disable this I guess.

I'm not sure how feasible it is, just putting it out there.  Even a simple system of the AI holding by default if running away on world map would be an improvement.  Of course it would be even better if AI units adopted tactics and formations appropriately depending on the tactical situation on the battlefield.

Oh yeah, finally re the formations and morale:

1) Possibly better keys for the formation orders would be: G for "Wedge", N for "Line", K for "Ranks" (as is), and F9 (Spread out) for "Formation Disassemble".  G and N are phonetically better when the player thinks of the worlds "line" and "wedge".  Spread Out and Formation Disassemble are functionally very similar orders.  Unless you've got future plans for spread out and stand closer..

2) I noticed that there are no logic checks for the "your enemies/your troops are wavering" and "your enemies/troops flee in terror" messages appearing when there are e.g. no more of your troops on the battlefield, from Chel's morale system.  Maybe hes adding them himself later and youre waiting for him, just thought I'd note it.

3) Would be great to have a circular formation as well, for infantry.  This was a commonly used formation by the Romans and the Saxons, albeit purely defensively.  Would be nice to have.

In any case this is great work and you've basically completely revolutionized the native AI and made the developers look rather feeble, so thanks for all your efforts! :cool:
 
Hello.

First I want to thank you for making this mod.

I see that this game has very strong community and it definitely deserves it.

The second thing is.......ummm the problem I've ran to.

I've added both codes(from the OP) in their corresponding places, then I ran the .bat file and there were no errors or problems. But there are absolutely no commands in game(except the native ones). I've tried both with new and saved game, but with the same result.

Tried to implement it to some mods(right now I have Battle Morale for .960) as well as the native files, but the result was all the same.
I've saw that BM is in fact already included in the mod and I though that the "double code" could be causing some problems when I've added the code in it's files, but I can't understand what is the reason for the code not to work on the native files.....

Any ideas what is causing the problems?
 
You have to hit the right keys for the formations.

In the code, there should be some sections where it says "key_pressed J" or something - just analyze the code and you should get it.
 
I don't understand where to put all the ****. Can some one just copy everything and send it in here so i can replace everything.
 
Antoxi 说:
I don't understand where to put all the genius code. Can some one just copy everything and send it in here so i can replace everything.
Fixed.

Get the module system if you haven't already, and put it in module_scripts.py and module_mission_templates.py.

It should be simple enough.

Put the triggers under the "lead_charge" mission template right after this part:

    [
    (1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
    (0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
    (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
    (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
    ],
    [


Put all the scripts in the bottom of module_scripts.py, right before the last ] at the very bottom.
 
Possible bug.  All mounted units in Lord x army parties dismount at start of battle.  Allies seem to be fine however.
 
Are you sure? The cavalry are only supposed to dismount if there are only a few of them - 3 or less cavalry left.
 
Ah - perhaps it is that.  I only tested with a few situations mostly involving minor amounts of cav.  Its rather annoying though, can I reduce the threshold for dismounting somewhere?
 
I have the module system, but when I try to open the module_scripts.py it doesn't open. the computer can't find the right program.
is there a program I need to open these files?
 
Update on bug:

The dismounting definitely happened when there were more than 3 cavalry on the battlefield.  IIRC it was about 5, with a large contingent of ground troops.

What exactly happened was that I changed the nord_champion trooptype to be cavalry (skirmishers), restarted the game, and attacked a Lord party.  Though 90%+ of the troops were your typical nord infantry, the 5 cav at the start stood still for about 20 seconds, then dismounted and ran to join the rest of the host. 

I'll do some more tests in a bit.
 
If you have more than 2 times the amount of infantry than cav, and you have less than 10 cav, they will dismount.

(5.0, 0, 0,
      [(neq, "$battle_won", 1),
      (assign,":infantry",0),
      (assign,":cavalry",0),
      (get_player_agent_no,":player"),
      (agent_get_team  ,reg0, ":player"),
      (val_add,reg0,2),
      (try_for_agents,":agent"),
        (agent_is_human,":agent"),
        (agent_is_alive,":agent"),
        (agent_get_team  ,":team", ":agent"),
        (eq,":team",reg0),
        (agent_get_class ,":class", ":agent"),
        (try_begin),
            (eq,":class",grc_cavalry),
            (val_add,":cavalry",1),
        (else_try),
            (val_add,":infantry",1),
        (end_try),
      (end_try),
      (assign,":ratio",":infantry"),
      (val_div,":ratio",":cavalry"),
      (try_begin),
        (gt,":ratio",2),
        (lt,":cavalry",10),
        (team_give_order, reg0, grc_everyone, mordr_dismount),
      (else_try),
        (team_give_order, reg0, grc_everyone, mordr_mount),
      (end_try),], []),


Take out this trigger if you dont want that at all, if you still want it but want to change it, increase (gt,":ratio",2) and decrease  (lt,":cavalry",10)

The same happens with the enemy ai 2 triggers above this one.

Just to make sure, it is not your cav that does this and it is only allied ai cav right?  Cause that is what should happen according to code.
 
Much appreciated grailknighthero!

-edit-
Yes, its enemy cav I noticed the behaviour, any allied battles I was in had plenty of cavalry so it didn't occur.  It does make tactical sense in general, though not for mounted skirmishers.
 
Fei Dao 说:
You have to hit the right keys for the formations.

Yup. I already knew that.

Fei Dao 说:
In the code, there should be some sections where it says "key_pressed J" or something - just analyze the code and you should get it.

I've looked through the code and everything seems fine - there are the commands and the triggers, but still when I hit the corresponding key(J, K.....) nothing really happens.

Thanks for your answer anyway.
 
right, so I added the codes to the python files, in the correct places I think, but nothing happens in-game.
is there something I need to do to get it to work in game?
 
kavien 说:
right, so I added the codes to the python files, in the correct places I think, but nothing happens in-game.
is there something I need to do to get it to work in game?

Did you go through the documentation???
 
后退
顶部 底部