Companion Order System (partially functional, in progress)

Users who are viewing this thread

CryptoCactus

Sergeant Knight
Feel free to advise or take it and run with it. Or make fun of it, I suppose. :razz:

Right now all I've got is a "hold position" type command (move to current player position) and a "dismiss" command, which returns them to default behavior. I'm just cobbling this together as I go, it's very hit-and-miss finding out what works and what doesn't, heh. Keys were pseudo-arbitrarily picked (I'm used to using them from Mirathei's formations, which I drew a lot of inspiration from). Right now I just have this tossed into lead_charge (though it should work, if you can call it that, in any mission template as far as I know).

  (0, 0, 0, [],
  [
(key_clicked, key_j),
(display_message,"@Companions, to me!"),
        (get_player_agent_no,":player"),
  (agent_get_team,":playerteam",":player"),
  (agent_is_alive,":player"),
  (agent_get_position,pos1,":player"),
  (try_for_agents,reg(5)),
(neq,reg(5),":player"),
(agent_is_alive,reg(5)),
(agent_is_human,reg(5)),
(agent_get_team  ,":team", reg(5)),
(eq,":team",":playerteam"), #check if on player's team
(agent_get_troop_id,":trp_id", reg(5)), #get troop id of agent
(is_between,":trp_id",companions_begin,companions_end), #check if companion
(agent_set_scripted_destination,reg(5),pos1), #move to player position
  (end_try),
    ], []),
    (0, 0, 0,
      [(key_clicked, key_u),
      (display_message,"@Companions, as you were!"),
      (get_player_agent_no,":player"),
  (agent_get_team,":playerteam",":player"),
  (agent_is_alive,":player"),
  (agent_get_position,pos1,":player"),
  (try_for_agents,reg(5)),
(neq,reg(5),":player"),
(agent_is_alive,reg(5)),
(agent_is_human,reg(5)),
(agent_get_team  ,":team", reg(5)),
(eq,":team",":playerteam"), #check if on player's team
(agent_get_troop_id,":trp_id", reg(5)), #get troop id of agent
(is_between,":trp_id",companions_begin,companions_end), #check if companion
(agent_clear_scripted_mode,reg(5)),                    #clear scripted modes, return to default behavior
(end_try),
        ], []),

The good:
- Companions quickly respond to the command, moving to the player position completely separate of any other orders the rest of the troops have.
- They still shoot at any enemies in range, and will defend against and attack anyone who walks within their swing radius

The bad:
- They will not respond to any default orders at all until dismissed
- They will not move one inch, pretty much no matter what, until dismissed. They won't even take a single step to attack an enemy generally.
- Haven't bothered making them form a line or anything yet, so right now they all just bunch up on each other.



To do:
-Companion charge
-Companion advance/fall back
-Companion (dis)mount
-Form line (should be default action on holding a position, like the vanilla hold command)


Right now, at the very least this enables me to hold my companions back from the frontlines until I'm ready for them to go in. Then I can just dismiss them and they'll charge (or whatever the current infantry orders are, or cavalry orders if they're on horse).


I'll update the OP as I figure stuff out.

And anyone, please, feel free to advise me (particularly on how to fix "the bad" or streamline my sloppy code) or to take it and run with it if you can do it better. I'm not jealous, I just want it to work and be freely available to everyone. :grin:


And yes, I know, Warband will make this pseudo-obsolete. I, for one, plan to still play both though, and have always wanted this kind of functionality in-game (not sure why they ever took it out).
 
Hope you're successful with this! This is a feature I miss from the older versions too.  If you have enough companions, they can make up a 4th tactical group (aside from infantry/archers/cavalry), which adds some very welcome flexibility.

Would it also be possible to create 'bodyguard' troops that come with your companions, and always follow them?  Or if not, is it possible to have more than x (I think it's 20) hero-type troops in your party?
 
dariel said:
Would it also be possible to create 'bodyguard' troops that come with your companions, and always follow them?

I'm quite certain it's possible. Whether or not I can do it is another matter. :razz:

dariel said:
Or if not, is it possible to have more than x (I think it's 20) hero-type troops in your party?

No idea if there's any sort of hard-coded limit, if that's what you're asking. I'm very much a Python noob compared to a lot of the guys and gals around here, and up until now all my mod hackery has just been slamming other peoples' code wherever it would fit until it worked, heh.
 
CryptoCactus said:
No idea if there's any sort of hard-coded limit, if that's what you're asking. I'm very much a Python noob compared to a lot of the guys and gals around here, and up until now all my mod hackery has just been slamming other peoples' code wherever it would fit until it worked, heh.

Looks like we're in the same boat with coding skills, that's all I can do too  :smile:.  Did some research though, it seems you can have up to 20 companions, there's an entry in the module.ini file that says so.  The hardest limit is 32 troop types in any party's stack, so even if you can have more than 20 in your party that's eating into the number of slots you can have for troops. 
 
Back
Top Bottom