Author Topic: Battlefield Tactics kit. Multiple formations per team+command revamp!  (Read 40435 times)

0 Members and 2 Guests are viewing this topic.

Shik

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: irc://Shik
  • M&BWB
Re: Battlefield Tactics kit. Now includes Chel's morale scripts!
« Reply #150 on: July 07, 2008, 04:09:33 PM »
Another small bug: When soloing or when all your men are dead, the cohesion messages like "your troops are fleeing" or "your morale wavers!" still pops up, even if you don't have any men.

Mirathei

  • Sergeant Knight
  • *
    • View Profile
  • Faction: Vaegir
Re: Battlefield Tactics kit. Now includes Chel's morale scripts!
« Reply #151 on: July 07, 2008, 04:14:04 PM »
Alright, love these scripts, but there's one issue I encountered:

The "formation, hold this position" command is broken. After a certain amount of time passes, the troops break off from the formation and revert to their native commands.

"Formation, follow" works fine though.
Fixed it. Just use the native commands for this version, except use the mod commands to get them in\out of formation in the first place.

@all morale bugs: Also tell Chel. Some of them have been my fault (ie. troops not really fleeing) but most are ones he'd like to know about.


Changes:
Multiple formations per ai team now possible.
Holding formations no longer break inexplicably.
Multiple formations can be commanded at once, or moved by the tactics screen.
Fleeing troops actually flee.
Ranged units no longer join wedge.
Player formations can now be ordered to charge without player.


Screenie of two Swadian formations attacking a khergit wedge:

vuk

  • Sergeant at Arms
  • *
  • Apocalypto
    • View Profile
  • Faction: Swadian
  • MP nick: Vuk
  • M&BWB
Re: Battlefield Tactics kit. Now includes Chel's morale scripts!
« Reply #152 on: July 07, 2008, 04:22:25 PM »
Is there anyway to get this without the morale script? I saw the morale script and like it very much, but I do not like the way that they go to the edge of the map and stay there.

Mirathei

  • Sergeant Knight
  • *
    • View Profile
  • Faction: Vaegir
Re: Battlefield Tactics kit. Multiple formations per team+command revamp!
« Reply #153 on: July 07, 2008, 04:26:15 PM »
Yes. Remove the morale scripts and triggers, and delete all lines containing the variables "$rout" and "$ai rout".

As a matter of fact, you could just delete the lines with those two variables, and that would do it, but your game will run smoother if you go ahead and remove all those other scripts that you don't want.

EDIT:
I'll stop being a lazy *******.  :lol:

Triggers:
Code: [Select]
######Tactical triggers below##########

(ti_before_mission_start, 0, 0, [],
   [ (assign,"$formation",0),
    (assign,"$infantryformationtype",0),
    (assign,"$archerformationtype",0),
    (assign,"$cavalryformationtype",0),]),


     (0, 0, 0,
      [(key_clicked, key_2),       
       (assign,"$formation",grc_infantry),
        ], []),
     (0, 0, 0,
      [(key_clicked, key_3),       
       (assign,"$formation",grc_archers),
        ], []),
     (0, 0, 0,
      [(key_clicked, key_4),       
       (assign,"$formation",grc_cavalry),
        ], []),


     (0, 0, 0,
      [(key_clicked, key_j),       
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (assign,reg1,"$formation"),
       (call_script,"script_cf_formation"),
       (try_begin),
          (eq,"$formation",grc_infantry),
          (assign,"$infantryformationtype",1),
       (else_try),
          (eq,"$formation",grc_archers),
          (assign,"$archerformationtype",1),
       (else_try),
          (eq,"$formation",grc_cavalry),
          (assign,"$cavalryformationtype",1),
       (end_try),
       (display_message,"@Forming_ranks."),
        ], []),

     (0, 0, 0,
      [(key_clicked, key_p),       
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (assign,reg1,"$formation"),
       (call_script,"script_cf_formation_stagger"),
       (call_script,"script_cf_formation"),
       (try_begin),
          (eq,"$formation",grc_infantry),
          (assign,"$infantryformationtype",3),
       (else_try),
          (eq,"$formation",grc_archers),
          (assign,"$archerformationtype",3),
       (else_try),
          (eq,"$formation",grc_cavalry),
          (assign,"$cavalryformationtype",3),
       (end_try),
       (display_message,"@Forming_a_line."),
        ], []),

     (0, 0, 0,
      [(key_clicked, key_k),       
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (assign,reg1,"$formation"),
       (call_script,"script_cf_formation_wedge"),
       (call_script,"script_cf_formation"),
       (try_begin),
          (eq,"$formation",grc_infantry),
          (assign,"$infantryformationtype",2),
       (else_try),
          (eq,"$formation",grc_archers),
          (assign,"$archerformationtype",2),
       (else_try),
          (eq,"$formation",grc_cavalry),
          (assign,"$cavalryformationtype",2),
       (end_try),
       (display_message,"@Forming_a_wedge."),
        ], []),

     (0, 0, 0,
      [(key_clicked, key_u),       
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (assign,reg1,"$formation"),
       (call_script,"script_formation_end"),
       (call_script,"script_cf_formation"),
       (try_begin),
          (eq,"$formation",grc_infantry),
          (assign,"$infantryformationtype",0),
       (else_try),
          (eq,"$formation",grc_archers),
          (assign,"$archerformationtype",0),
       (else_try),
          (eq,"$formation",grc_cavalry),
          (assign,"$cavalryformationtype",0),
       (end_try),
       (display_message,"@Formation_disassembled."),
        ], []),

     (5.0, 0, 0,
      [(try_for_agents,":agent"),
         (agent_is_human,":agent"),
         (neg|agent_is_ally,":agent"),
         (assign,":enemy",":agent"),
       (end_try),
       (gt,":enemy",-1),
       (agent_get_team  ,reg0, ":enemy"),
       (assign,reg1,grc_cavalry),
       (call_script,"script_formation_end"),
       (assign,reg1,grc_infantry),
       (call_script,"script_formation_end"),
       (assign,reg1,grc_archers),
       (call_script,"script_formation_end"),], []),

     (5.0, 0, 0,
      [(assign,":enemy",-1),
       (assign,":infantry",0),
       (assign,":cavalry",0),
       (try_for_agents,":agent"),
         (agent_is_human,":agent"),
         (agent_is_alive,":agent"),
         (neg|agent_is_ally,":agent"),
         (assign,":enemy",":agent"),
         (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),
       (gt,":enemy",-1),
       (agent_get_team  ,reg0, ":enemy"),
       (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),], []),


     (5.0, 0, 0,
      [(get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (val_add,reg0,2),
       (assign,reg1,grc_cavalry),
       (call_script,"script_formation_end"),
       (assign,reg1,grc_infantry),
       (call_script,"script_formation_end"),
       (assign,reg1,grc_archers),
       (call_script,"script_formation_end"),], []),

     (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),], []),

     (0.2, 0, 0,
      [(get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (assign,reg1,grc_infantry),
       (try_begin),
          (eq,"$infantryformationtype",1),
          (call_script,"script_cf_formation"),
       (else_try),
          (eq,"$infantryformationtype",2),
          (call_script,"script_cf_formation_wedge"),
       (else_try),
          (eq,"$infantryformationtype",3),
          (call_script,"script_cf_formation_stagger"),
       (else_try),
          (call_script,"script_formation_end"),
       (end_try),], []),

     (0.2, 0, 0,
      [(get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (assign,reg1,grc_archers),
       (try_begin),
          (eq,"$archerformationtype",1),
          (call_script,"script_cf_formation"),
       (else_try),
          (eq,"$archerformationtype",2),
          (call_script,"script_cf_formation_wedge"),
       (else_try),
          (eq,"$archerformationtype",3),
          (call_script,"script_cf_formation_stagger"),
       (else_try),
          (call_script,"script_formation_end"),
       (end_try),], []),

     (0.2, 0, 0,
      [(get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (assign,reg1,grc_cavalry),
       (try_begin),
          (eq,"$cavalryformationtype",1),
          (call_script,"script_cf_formation"),
       (else_try),
          (eq,"$cavalryformationtype",2),
          (call_script,"script_cf_formation_wedge"),
       (else_try),
          (eq,"$cavalryformationtype",3),
          (call_script,"script_cf_formation_stagger"),
       (else_try),
          (call_script,"script_formation_end"),
       (end_try),], []),

     (0.2, 0, 0,
      [(try_for_agents,":agent"),
         (agent_is_human,":agent"),
         (neg|agent_is_ally,":agent"),
         (assign,":enemy",":agent"),
       (end_try),
       (gt,":enemy",-1),
       (agent_get_team  ,reg0, ":enemy"),
       (store_normalized_team_count,":num", reg0), 
       (gt,":num",5),
       (assign,reg1,grc_infantry),
       (call_script,"script_cf_formation"),
        ], []),

     (0.2, 0, 0,
      [(try_for_agents,":agent"),
         (agent_is_human,":agent"),
         (neg|agent_is_ally,":agent"),
         (assign,":enemy",":agent"),
       (end_try),
       (gt,":enemy",-1),
       (agent_get_team  ,reg0, ":enemy"),
       (store_normalized_team_count,":num", reg0), 
       (gt,":num",5),
       (assign,reg1,grc_archers),
       (call_script,"script_cf_formation_stagger"),
        ], []),

     (0.2, 0, 0,
      [(try_for_agents,":agent"),
         (agent_is_human,":agent"),
         (neg|agent_is_ally,":agent"),
         (assign,":enemy",":agent"),
       (end_try),
       (gt,":enemy",-1),
       (agent_get_team  ,reg0, ":enemy"),
       (store_normalized_team_count,":num", reg0), 
       (gt,":num",5),
       (assign,reg1,grc_cavalry),
       (call_script,"script_cf_formation_wedge"),
        ], []),

     (0.2, 0, 0,
      [(get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (val_add,reg0,2),
       (store_normalized_team_count,":num", reg0), 
       (gt,":num",5),
       (assign,reg1,grc_infantry),
       (call_script,"script_cf_formation"),
        ], []),

     (0.2, 0, 0,
      [(get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (val_add,reg0,2),
       (store_normalized_team_count,":num", reg0), 
       (gt,":num",5),
       (assign,reg1,grc_archers),
       (call_script,"script_cf_formation_stagger"),
        ], []),

     (0.2, 0, 0,
      [(get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (val_add,reg0,2),
       (store_normalized_team_count,":num", reg0), 
       (gt,":num",5),
       (assign,reg1,grc_cavalry),
       (call_script,"script_cf_formation_wedge"),
        ], []),


##########Tactical triggers above########


Scripts:
Code: [Select]
  ("cf_formation",
   [(team_get_leader, ":teamleader", reg0),
    (gt,":teamleader",-1),
    (assign,":leader",-1),
    (agent_get_class,":class",":teamleader"),
    (try_begin),
       (eq,":class",reg1),
       (get_player_agent_no,":player"),
       (neq,":teamleader",":player"),
       (assign,":leader",":teamleader"),
    (else_try),
       (call_script,"script_choose_formation_leader"),
       (gt,reg2,-1),
       (assign,":leader",reg2),
    (end_try), 
    (gt,":leader",-1), 
    (agent_get_position,1,":leader"),
    (position_move_x,1,100),
    (assign,":collumn",1),
    (try_for_agents,reg(5)),
       (neq,reg5,":leader"),
       (agent_is_alive,reg(5)),
       (agent_is_human,reg(5)),
       (agent_get_team  ,":team", reg5),
       (eq,":team",reg0),
       (agent_get_class ,":class", reg5),
       (eq,":class",reg1),                                   
       (agent_set_scripted_destination,reg(5),1),
       (position_move_x,1,100),
       (try_begin),
          (eq,":collumn",12),
          (position_move_x,1,-12*100),
          (position_move_y,1,-200),
          (assign,":collumn",1),
       (else_try),
          (val_add,":collumn",1),
       (end_try),
    (end_try)]),

  ("cf_formation_stagger",
   [(team_get_leader, ":teamleader", reg0),
    (gt,":teamleader",-1),
    (assign,":leader",-1),
    (agent_get_class,":class",":teamleader"),
    (try_begin),
       (eq,":class",reg1),
       (get_player_agent_no,":player"),
       (neq,":teamleader",":player"),
       (assign,":leader",":teamleader"),
    (else_try),
       (call_script,"script_choose_formation_leader"),
       (gt,reg2,-1),
       (assign,":leader",reg2),
    (end_try), 
    (gt,":leader",-1),
    (agent_get_position,1,":leader"),
    (position_move_x,1,100),
    (assign,":move_y",-100),
    (try_for_agents,reg(5)),
       (neq,reg5,":leader"),
       (agent_is_alive,reg(5)),
       (agent_is_human,reg(5)),
       (agent_get_team  ,":team", reg5),
       (eq,":team",reg0),
       (agent_get_class ,":class", reg5),
       (eq,":class",reg1),                                   
       (agent_set_scripted_destination,reg(5),1),
       (position_move_x,1,100),
       (position_move_y,1,":move_y"),
       (val_mul,":move_y",-1),
    (end_try)]),

  ("cf_formation_wedge",
   [(team_get_leader, ":teamleader", reg0),
    (gt,":teamleader",-1),
    (assign,":leader",-1),
    (agent_get_class,":class",":teamleader"),
    (try_begin),
       (eq,":class",reg1),
       (get_player_agent_no,":player"),
       (neq,":teamleader",":player"),
          (assign,":fail",0),
          (try_for_range,":ranged_item","itm_jarid","itm_flintlock_pistol"),
             (agent_has_item_equipped,":teamleader",":ranged_item"),
             (assign,":fail",1),
          (end_try),
          (eq,":fail",0),
       (assign,":leader",":teamleader"),
    (else_try),
       (assign,reg2,-1),
       (assign,":max_xp",0),
       (try_for_agents,":agent"),
          (agent_is_alive,":agent"),
          (agent_is_human,":agent"),
          (agent_get_team,":team",":agent"),
          (eq,":team",reg0),
          (agent_get_class,":class",":agent"),
          (eq,":class",reg1),
          (get_player_agent_no,":player"),
          (neq,":player",":agent"),
          (assign,":fail",0),
          (try_for_range,":ranged_item","itm_jarid","itm_flintlock_pistol"),
             (agent_has_item_equipped,":agent",":ranged_item"),
             (assign,":fail",1),
          (end_try),
          (eq,":fail",0),
          (agent_get_troop_id,":troop", ":agent"),
          (troop_get_xp, ":xp", ":troop"),
          (gt,":xp",":max_xp"),
          (assign,":max_xp",":xp"),
          (assign,reg2,":agent"),
       (end_try),
       (gt,reg2,-1),
       (assign,":leader",reg2),
    (end_try), 
    (gt,":leader",-1),
    (agent_get_position,1,":leader"),
    (assign,":collumn",1),
    (assign,":nc",3),
    (position_move_x,1,-150),
    (try_for_agents,reg(5)),
       (neq,reg5,":leader"),
       (agent_is_alive,reg(5)),
       (agent_is_human,reg(5)),
       (agent_get_team  ,":team", reg5),
       (eq,":team",reg0),
       (agent_get_class ,":class", reg5),
       (eq,":class",reg1),
          (assign,":fail",0),
          (try_for_range,":ranged_item","itm_jarid","itm_flintlock_pistol"),
             (agent_has_item_equipped,reg5,":ranged_item"),
             (assign,":fail",1),
          (end_try),
          (eq,":fail",0),
       (agent_set_scripted_destination,reg(5),1),
       (try_begin),
          (eq,":collumn",":nc"),
          (val_mul,":nc",-150),
          (position_move_x,1,":nc"),
          (position_move_y,1,-300),
          (assign,":collumn",1),
          (val_div,":nc",-150),
          (val_add,":nc",2),
       (else_try),
          (position_move_x,1,150),
          (val_add,":collumn",1),
       (end_try),
    (end_try)]),

  ("formation_end",
   [(try_for_agents,reg(5)),
       (agent_is_alive,reg(5)),
       (agent_is_human,reg(5)),
       (agent_get_team  ,":team", reg5),
       (eq,":team",reg0),
       (agent_get_class ,":class", reg5),
       (eq,":class",reg1), 
       (agent_clear_scripted_mode,reg5),
     (try_end),]),

  ("choose_formation_leader",
   [(assign,reg2,-1),
    (assign,":max_xp",0),
    (try_for_agents,":agent"),
        (agent_is_alive,":agent"),
        (agent_is_human,":agent"),
        (agent_get_team,":team",":agent"),
        (eq,":team",reg0),
        (agent_get_class,":class",":agent"),
        (eq,":class",reg1),
        (get_player_agent_no,":player"),
        (neq,":player",":agent"),
        (agent_get_troop_id,":troop", ":agent"),
        (troop_get_xp, ":xp", ":troop"),
        (gt,":xp",":max_xp"),
        (assign,":max_xp",":xp"),
        (assign,reg2,":agent"),
    (end_try),]),
« Last Edit: July 08, 2008, 02:24:07 AM by Mirathei »

vuk

  • Sergeant at Arms
  • *
  • Apocalypto
    • View Profile
  • Faction: Swadian
  • MP nick: Vuk
  • M&BWB
Re: Battlefield Tactics kit. Multiple formations per team+command revamp!
« Reply #154 on: July 07, 2008, 04:29:28 PM »
Do you have the code for formations by itsself? I am really dumb when it comes to code, and know that I would probably mess something up. :P

Mirathei

  • Sergeant Knight
  • *
    • View Profile
  • Faction: Vaegir
Re: Battlefield Tactics kit. Multiple formations per team+command revamp!
« Reply #155 on: July 07, 2008, 04:33:10 PM »
See above.

vuk

  • Sergeant at Arms
  • *
  • Apocalypto
    • View Profile
  • Faction: Swadian
  • MP nick: Vuk
  • M&BWB
Re: Battlefield Tactics kit. Multiple formations per team+command revamp!
« Reply #156 on: July 07, 2008, 04:40:50 PM »
SWEET! Thanks much! Do I have you your permission to use the script in a mod of mine if I give you full credit for it?

Mirathei

  • Sergeant Knight
  • *
    • View Profile
  • Faction: Vaegir
Re: Battlefield Tactics kit. Multiple formations per team+command revamp!
« Reply #157 on: July 07, 2008, 04:44:09 PM »
Of course.  :)

pentagathus

  • Sergeant Knight at Arms
  • *
  • Lord of Team Alpha Beta Supercool Wolf Squadron
    • View Profile
  • Faction: Vaegir
Re: Battlefield Tactics kit. Multiple formations per team+command revamp!
« Reply #158 on: July 07, 2008, 04:49:59 PM »
Yaaaaaaaaaaaaaay Rhodoks can fight proper like now.
Time to be a teaching those swadian ponces that horses be a bad idea.
Hit me at 40 and there's an 80% chance I'll die.
Hit me at 30 and there's an 80% chance I'll live.
Hit me at 80 and it's clear I shouldn't play on the motorway.

vuk

  • Sergeant at Arms
  • *
  • Apocalypto
    • View Profile
  • Faction: Swadian
  • MP nick: Vuk
  • M&BWB
Re: Battlefield Tactics kit. Multiple formations per team+command revamp!
« Reply #159 on: July 07, 2008, 04:54:46 PM »
Thanks much! I got another problem though. :P Where do I find the module_scripts.py file? :P I cannot find it anywhere.

Shik

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: irc://Shik
  • M&BWB
Re: Battlefield Tactics kit. Multiple formations per team+command revamp!
« Reply #160 on: July 07, 2008, 04:57:48 PM »
Thanks much! I got another problem though. :P Where do I find the module_scripts.py file? :P I cannot find it anywhere.

Download the module system.

Raziaar

  • Recruit
  • *
    • View Profile
  • Faction: Khergit
Re: Battlefield Tactics kit. Multiple formations per team+command revamp!
« Reply #161 on: July 07, 2008, 05:00:12 PM »
Thanks much! I got another problem though. :P Where do I find the module_scripts.py file? :P I cannot find it anywhere.

I think it's in with the module system folder after you've extracted the module system. Haven't tried this mod yet, but it looks interesting!

I want to get into M&B scripting... but at a glance it looks very confusing... and I'm a learning C# programmer.

vuk

  • Sergeant at Arms
  • *
  • Apocalypto
    • View Profile
  • Faction: Swadian
  • MP nick: Vuk
  • M&BWB
Re: Battlefield Tactics kit. Multiple formations per team+command revamp!
« Reply #162 on: July 07, 2008, 05:01:55 PM »
ahhh...thank you!

Chel

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Battlefield Tactics kit. Now includes Chel's morale scripts!
« Reply #163 on: July 07, 2008, 05:09:24 PM »

About the morale thing. It seems not very suited for solo gameplay. When I start the battle, being injured, it begins to spam 'Your troops flee in terror' message (and I don't have any troops). Maybe add some check, disabling this messages if there's no players troops?
Also, if I kill in such solo battle one enemy, and then just hang around, my rivals begin to flee. Is it how it should be?

I removed the messages about fleeing troops in the version that I released for 0.960, I guess Mirathei kept them.

it should work just fine for solo play, if you are facing a large army alone and start killing them, you get bravery bonus while they lose cohesion and start routing pretty soon -- facing a single killing machine is demoralizing.
However they should not start to rout if you kill just one, unless there are only 2-4 troops to begin with.


Is there anyway to get this without the morale script? I saw the morale script and like it very much, but I do not like the way that they go to the edge of the map and stay there.

Do they stay there or do they keep moving about the corner of the map?

In my testing they keep running around panicked, that was the 'fix' to stop them from bunching up in the corner. If that still happens, I guess the fix doesn't work every battle because position values on the battlefield are sometimes scaled in 100's sometimes in 1000's, sometimes maybe something else (but the random number generator is limited to 1-100,000)

I have a way to fix this, maybe later..

Zendarian

  • Sergeant at Arms
  • *
    • View Profile
  • Faction: Neutral
Re: Battlefield Tactics kit. Multiple formations per team+command revamp!
« Reply #164 on: July 07, 2008, 05:18:34 PM »
Where do you extract the Module System files?
The first normal guy on this forum. It's a 5/5