OSP MP Troops Retreat / Pseudo Skirmish

Users who are viewing this thread

Fat Cat

Recruit
Hello all, my 1st released OSP, but it won't let me post it in OSP section though (insufficient privileges), hope someone can make use of it, if it sounds right for your mod.

Here are codes for making your Multiplayer AI Troops Retreat from the battlefield and to Stand Ground (cancels Retreat), on a LAN Server the Host and Client (Player 1 and 2, with the mod / code) was able to make their troops Retreat and Stand Ground.

Retreaters don't walk backwards facing the enemy, they turn and run fast to the nearest Scene Edge and will disappear - only if the Scene edge is open / No Props in way, doesn't work best in cities / alleyways.
Riding down fleeing enemy / covering a retreat, tasty.
You can also use it to semi skirmish or tempt defenders from a position.

The 1st code works smoothly, but will make all of the Player's Groups retreat, regardless of Group the order is given to.

Host - Works and Tested (Player 1)
Client - Works and Tested (Player 2)

Note, how this code works I imagine if Player 1 and 2 are same team, then both Players' Troops will retreat from 1 of Player's Orders - NOT Tested

Python:
multiplayer_troops_control_adaptive_v1 = (
  ti_on_order_issued, 0, 0,
  [
  (this_or_next|multiplayer_is_server),#
  (neg|multiplayer_is_server),#
  (store_trigger_param_1, ":order_no"),# FC can be removed
  (this_or_next|eq, ":order_no", mordr_retreat),# FC can be removed
  (eq, ":order_no", mordr_stand_ground),# FC can be removed
  ],
  [
  (store_trigger_param_1, ":order_no"),
  (store_trigger_param_2, ":agent_id"),# the player
  (agent_get_team, ":team_id", ":agent_id"),

  (try_for_agents, ":agent_no"),
    (agent_is_active, ":agent_no"),
    (agent_is_human, ":agent_no"),
    (agent_is_non_player, ":agent_no"),
    (agent_is_alive, ":agent_no"),
    (agent_get_team, ":team_no", ":agent_no"),
    (eq, ":team_no", ":team_id"),
    (try_begin),#
      (eq, ":order_no", mordr_retreat),#
      (agent_start_running_away, ":agent_no"),
      (agent_set_slot, ":agent_no",  slot_agent_is_running_away, 1),
      (agent_play_sound, ":agent_no", "snd_man_yell"),# FC can be removed
    (else_try),
      (eq, ":order_no", mordr_stand_ground),#
      (agent_stop_running_away, ":agent_no"),
      (agent_set_slot, ":agent_no",  slot_agent_is_running_away, 0),
      (agent_play_sound, ":agent_no", "snd_man_warcry"),# FC can be removed
    (try_end),
  (try_end),
  ]
  )


The 2nd code works smoothly, and gives the Order (Retreat / Stand Ground) to any of the 4 Selected Groups (Infantry, Archers, Cavalry and 1 Custom),
NOT yet Client tested as ran into a big / unforeseen problem;

as Host on Team 1 - Works, no problems or error warnings, works with any or all groups selected. All good...

as Host on Team 2 (no Clients, just myself as Host) - makes all Groups Retreat / Stand, the same as Code 1 Basic above, but with bonus Invalid Group error messages, even if restart the game / PC.

I really can not figure this one out and would be grateful of any input.

Code:
multiplayer_troops_control_adaptive_v2 = (
  ti_on_order_issued, 0, 0,
  [
  (this_or_next|multiplayer_is_server),#
  (neg|multiplayer_is_server),#
  ],
  [
  (store_trigger_param_1, ":order"),
  (store_trigger_param_2, ":leader_agent"),# is the player - this IS the agent GIVING the order (not bots recieving)
  (store_trigger_param_3, ":class"),
  (agent_get_team, ":playerteam", ":leader_agent"),#

        (assign,":group_no",-1),
        (assign,":order_type",-1),

        (try_for_range, ":class", 0, 4),# try 1-1
          (class_is_listening_order, ":playerteam", ":class"),

          (try_begin),
            (eq, ":class", 0),# infantry
            (eq, ":order", mordr_retreat),
            (assign,":group_no",0),
            (assign,":order_type",0),
          (else_try),
            (eq, ":class", 0),# infantry
            (eq, ":order", mordr_stand_ground),
            (assign,":group_no",0),
            (assign,":order_type",1),
          (try_end),
          (try_begin),
            (eq, ":class", 1),# archers
            (eq, ":order", mordr_retreat),
            (assign,":group_no",1),
            (assign,":order_type",0),
          (else_try),
            (eq, ":class", 1),# archers
            (eq, ":order", mordr_stand_ground),
            (assign,":group_no",1),
            (assign,":order_type",1),
          (try_end),
          (try_begin),
            (eq, ":class", 2),# caavalry
            (eq, ":order", mordr_retreat),
            (assign,":group_no",2),
            (assign,":order_type",0),
          (else_try),
            (eq, ":class", 2),# cavalry
            (eq, ":order", mordr_stand_ground),
            (assign,":group_no",2),
            (assign,":order_type",1),
          (try_end),
          (try_begin),
            (eq, ":class", 3),# group 4
            (eq, ":order", mordr_retreat),
            (assign,":group_no",3),
            (assign,":order_type",0),
          (else_try),
            (eq, ":class", 3),# group 4
            (eq, ":order", mordr_stand_ground),
            (assign,":group_no",3),
            (assign,":order_type",1),
          (try_end),

          (neq,":group_no",-1),
          (neq,":order_type",-1),

            (try_begin),# try 2-1
              (eq, ":group_no", 0),# infantry
              (eq,":order_type",0),
                (try_for_agents, ":agent_id"),#
                  (agent_is_alive, ":agent_id"),
                  (agent_is_human, ":agent_id"),
                  (agent_get_team, ":agent_team", ":agent_id"),#
                  (eq, ":agent_team",":playerteam"),#
                  (agent_get_division, ":group", ":agent_id"),#
                  (eq, ":group", 0),#
                  (agent_start_running_away, ":agent_id"),
                  (agent_set_slot, ":agent_id",  slot_agent_is_running_away, 1),
                (try_end),
                (display_message, "@group 1 is selected retreat"),
            (else_try),
              (eq, ":group_no", 0),# infantry
              (eq,":order_type",1),
                (try_for_agents, ":agent_id"),#
                  (agent_is_alive, ":agent_id"),
                  (agent_is_human, ":agent_id"),
                  (agent_get_team, ":agent_team", ":agent_id"),#
                  (eq, ":agent_team",":playerteam"),#
                  (agent_get_division, ":group", ":agent_id"),#
                  (eq, ":group", 0),#
                  (agent_stop_running_away, ":agent_id"),
                  (agent_set_slot, ":agent_id",  slot_agent_is_running_away, 0),
                (try_end),
                (display_message, "@group 1 is selected stand"),
            (else_try),
              (eq, ":group_no", 1),# archers
              (eq,":order_type",0),
                (try_for_agents, ":agent_id_2"),#
                  (agent_is_alive, ":agent_id_2"),
                  (agent_is_human, ":agent_id_2"),
                  (agent_get_team, ":agent_team", ":agent_id_2"),#
                  (eq, ":agent_team",":playerteam"),#
                  (agent_get_division, ":group", ":agent_id_2"),#
                  (eq, ":group", 1),#
                  (agent_start_running_away, ":agent_id_2"),
                  (agent_set_slot, ":agent_id_2",  slot_agent_is_running_away, 1),
                (try_end),
                (display_message, "@group 2 is selected retreat"),
            (else_try),
              (eq, ":group_no", 1),# archers
              (eq,":order_type",1),
                (try_for_agents, ":agent_id_2"),#
                  (agent_is_alive, ":agent_id_2"),
                  (agent_is_human, ":agent_id_2"),
                  (agent_get_team, ":agent_team", ":agent_id_2"),#
                  (eq, ":agent_team",":playerteam"),#
                  (agent_get_division, ":group", ":agent_id_2"),#
                  (eq, ":group", 1),#
                  (agent_stop_running_away, ":agent_id_2"),
                  (agent_set_slot, ":agent_id_2",  slot_agent_is_running_away, 0),
                (try_end),
                (display_message, "@group 2 is selected stand"),
            (else_try),
              (eq, ":group_no", 2),# cavalry
              (eq,":order_type",0),
                (try_for_agents, ":agent_id_3"),#
                  (agent_is_alive, ":agent_id_3"),
                  (agent_is_human, ":agent_id_3"),
                  (agent_get_team, ":agent_team", ":agent_id_3"),#
                  (eq, ":agent_team",":playerteam"),#
                  (agent_get_division, ":group", ":agent_id_3"),#
                  (eq, ":group", 2),#
                  (agent_start_running_away, ":agent_id_3"),
                  (agent_set_slot, ":agent_id_3",  slot_agent_is_running_away, 1),
                (try_end),
                (display_message, "@group 3 is selected retreat"),
            (else_try),
              (eq, ":group_no", 2),# cavalry
              (eq,":order_type",1),
                (try_for_agents, ":agent_id_3"),# try 1
                  (agent_is_alive, ":agent_id_3"),
                  (agent_is_human, ":agent_id_3"),
                  (agent_get_team, ":agent_team", ":agent_id_3"),#
                  (eq, ":agent_team",":playerteam"),#
                  (agent_get_division, ":group", ":agent_id_3"),#
                  (eq, ":group", 2),#
                  (agent_stop_running_away, ":agent_id_3"),
                  (agent_set_slot, ":agent_id_3",  slot_agent_is_running_away, 0),
                (try_end),
                (display_message, "@group 3 is selected stand"),
            (else_try),
              (eq, ":group_no", 3),# group 4
              (eq,":order_type",0),
                (try_for_agents, ":agent_id_4"),#
                  (agent_is_alive, ":agent_id_4"),
                  (agent_is_human, ":agent_id_4"),
                  (agent_get_team, ":agent_team", ":agent_id_4"),#
                  (eq, ":agent_team",":playerteam"),#
                  (agent_get_division, ":group", ":agent_id_4"),#
                  (eq, ":group", 3),#
                  (agent_start_running_away, ":agent_id_4"),
                  (agent_set_slot, ":agent_id_4",  slot_agent_is_running_away, 1),
                (try_end),
                (display_message, "@group 4 is selected retreat"),
            (else_try),
              (eq, ":group_no", 3),# group 4
              (eq,":order_type",1),
                (try_for_agents, ":agent_id_4"),#
                  (agent_is_alive, ":agent_id_4"),
                  (agent_is_human, ":agent_id_4"),
                  (agent_get_team, ":agent_team", ":agent_id_4"),#
                  (eq, ":agent_team",":playerteam"),#
                  (agent_get_division, ":group", ":agent_id_4"),#
                  (eq, ":group", 3),#
                  (agent_stop_running_away, ":agent_id_4"),
                  (agent_set_slot, ":agent_id_4",  slot_agent_is_running_away, 0),
                (try_end),
                (display_message, "@group 4 is selected stand"),
            (try_end),# try 2-1
        (try_end),# try 1-1
  ]
  )


You are totally free to use and or edit in your Mod/s and Servers, Credit would be appreciated, along with any inputters' names. If possible I would like to know if it has been any use to you / criticisms just out of curiosity and motivation to make and release more over time, also, there's still a lot I don't fully understand in modding, so if this would be better as a script or more streamlined in any way please say.

Thank you for reading, any help and suggestions appreciated.

PS - if understand Server\Client events, please could you have a look at this, this is for Clients' MP Groups 4-7, got it to work for the Host, could not get it to work for Client. I think it is a Event Issue. I Tried to make own Events from scratch... would not let me even start/Host a game after compile XD / o_O
https://forums.taleworlds.com/index...o-execute-code-pre-o-s-p.457090/#post-9856216

PS - is there a tutorial or examples for adding New Orders to the Normal / Advanced Formations Orders Pages (1-Move, 2-Formation, 3-Fire Orders, 4 Weapon Orders), Presentations is still feels quite new to me. If I remember right the "Formations Mod" had new Orders in for Normal Commands, I would like to add new to the Advanced Commands (activated in Module.ini and language files).
 
Back
Top Bottom