Dynamic groups

Users who are viewing this thread

Hughes

Sergeant
In the original M&B, Cavalry that lost their horses switched to the Infantry group. Is there any way to do this in Warband? In many of my battles, I've got unhorsed cavalry running around trying to catch the enemy; I'd rather have them join up with my infantry line.

It'd be nice if the player could even choose two groups for each unit rather than just one, depending on whether they are mounted or on foot. That way you could make unhorsed Khergits go join your archers, instead of your infantry, for example.
 
Hughes said:
In the original M&B, Cavalry that lost their horses switched to the Infantry group. Is there any way to do this in Warband? In many of my battles, I've got unhorsed cavalry running around trying to catch the enemy; I'd rather have them join up with my infantry line.

It'd be nice if the player could even choose two groups for each unit rather than just one, depending on whether they are mounted or on foot. That way you could make unhorsed Khergits go join your archers, instead of your infantry, for example.

...or stick your infantry that have found mounts in the cavalry group, rather than having them sitting pretty atop their horse in the infantry line.
 
Yeah that's kind of annoying.  I think they used to do it on the fly too, like the second they fell off the horse they made for the infantry line.  I remember covering their retreat in M&B.
 
Caba`drin said:
Hughes said:
In the original M&B, Cavalry that lost their horses switched to the Infantry group. Is there any way to do this in Warband? In many of my battles, I've got unhorsed cavalry running around trying to catch the enemy; I'd rather have them join up with my infantry line.

It'd be nice if the player could even choose two groups for each unit rather than just one, depending on whether they are mounted or on foot. That way you could make unhorsed Khergits go join your archers, instead of your infantry, for example.

...or stick your infantry that have found mounts in the cavalry group, rather than having them sitting pretty atop their horse in the infantry line.

I think the three starting groups should be as they were in M&B--automatic, based on the primary weapon (melee/ranged) and mounted status of the troop. There are several unit types, including many in the Manhunter track, Vaegir Veterans, Mountain Bandits, and others (I think) which are lumped together when really they may be infantry or cavalry. This is especially frustrating now in my Vaegir play-through, watching my unmounted Veterans get separated from the rest of the infantry as I order a cavalry charge (the die because they are unmounted and meet the enemy in small numbers, away from the main body of infantry) or watching my mounted Vets hang back as the rest of the cavalry charges because I've decided to keep the unmounted ones alive and have held them all back by designating them infantry.
 
Agreed. and this should also apply therefore to allied Lords, who always are designated Infantry in M&B regardless of whether they're on horseback. Cavalry charges therefore never benefit from having lords among their ranks.
 
I fully agree, with one exception.  Sometimes I dismount my cavalry.  In that case I'd like them to remain in the cavalry group.  For example, I think Swadian Knights are awful on the front line of a siege so I'll send them in on the second wave.  I just don't know if they'll be able to make it work both ways.    :neutral:
 
You're right, they can't make it work both ways - but they CAN make it editable by the player. Where there's a field now to designate a unit's category, I'm suggesting make two fields for us to use: one for mounted and one for foot.

That way you could keep your unmounted cavalry in your cavalry group during a siege, and switch it when in the field, for example.
 
I have this identical problem with unhorsed cavalry getting picked off instead of going to join the infantry as they did  in the old M&B. Is there any news on how to change this?
 
OddsBodkin said:
I have this identical problem with unhorsed cavalry getting picked off instead of going to join the infantry as they did  in the old M&B. Is there any news on how to change this?

News? Why, yes, yes there is!
The most recent patch included a command that will allow modders to add a line of code to accomplish this. I was planning to do a 'hot-fix'-style .TXT tweak line right away, but it slipped my mind. Stay tuned...hopefully I'll have something out in the next week or so. ...see below!

De-horsed Mounted Troops become Infantry
Alright, a simple, quick tweak to add an original M&B behavior to Warband: any mounted unit, upon losing their mount (not if they are ordered to dismount), gets reassigned to the Infantry division. This applies to both the player and the AI and to any mounted troop, regardless of the division it was assigned to previously.

Below I've included both a simple copy-paste tweak to add to one of your Native .txt files, as well as the Module System code to be added to the source directly. For best results outside of Native 1.134, always use the Module System code. (I'm not sure of the .txt tweak's effectiveness beyond Native, but with a backup as described, there's no pain to trying this with a mod.)

0) Go to your ...Warband\Modules\Native\ folder (or the ...\Modules\ folder of a mod you are trying to add this to)
1) Make a backup copy of mission_templates.txt
2) Open mission_templates.txt (if you use Notepad, be sure Wordwrap is turned off)
3) Find the line beinning with "mst_lead_charge"
4) A few lines below this, find a number by itself on a line (in Native, 21)
5) Add four to this number and replace it (in Native, change 21 to 25)
6) Immediately below this number, add the following four lines on their own line:
Code:
-25.000000 0.000000 0.000000  0  12 2071 1 1224979098644774912 4 0 2147485352 1 1224979098644774912 1715 2 1224979098644774913 1224979098644774912 30 2 1224979098644774913 0 1712 1 1224979098644774913 1702 1 1224979098644774913 1707 1 1224979098644774913 5 0 2133 2 1224979098644774913 -1 3 0 505 3 1224979098644774912 45 1224979098644774913 
-26.000000 0.000000 0.000000  0  9 2071 1 1224979098644774912 2147485352 1 1224979098644774912 525 3 1224979098644774913 1224979098644774912 45 30 2 1224979098644774913 0 1712 1 1224979098644774913 1702 1 1224979098644774913 1707 1 1224979098644774913 1783 2 1224979098644774913 0 505 3 1224979098644774913 46 0 
-25.000000 0.000000 0.000000  0  2 2071 1 1224979098644774912 505 3 1224979098644774912 46 -1 
1.000000 0.000000 0.000000  0  9 12 1 1224979098644774912 1712 1 1224979098644774912 565 3 1224979098644774912 46 0 1702 1 1224979098644774912 1773 2 1224979098644774913 1224979098644774912 2147484193 3 1224979098644774912 46 1224979098644774913 525 3 1224979098644774914 1224979098644774912 46 1783 2 1224979098644774912 1224979098644774914 3 0
7) If you wish, do the same with mst_village_attack_bandits and mst_village_raid, the two other mission templates it could apply for. (Add 4 to the number you find on a line by itself following the heading, then paste those four lines immediately following the number you changed.)
Save. Play!
1) Open module_mission_templates.py
2) Find the mission_template for "lead_charge"
3) Add the following two triggers to the triggers block for the template
Code:
(ti_on_agent_spawn, 0, 0, [], [(store_trigger_param_1, ":agent"),(agent_set_slot, ":agent", slot_agent_new_division, -1)]), #De-Horse trigger 0
(ti_on_agent_spawn, 0, 0, [], #De-Horse Trigger 1
  [
	(store_trigger_param_1, ":horse"),
	
	(try_begin),
		(neg|agent_is_human, ":horse"),	
		(agent_get_rider, ":rider", ":horse"),
		(ge, ":rider", 0), #I don't know if any of these checks are necessary
		(agent_is_active, ":rider"),
		(agent_is_alive, ":rider"),
		(agent_is_non_player, ":rider"),
	(else_try),
		(assign, ":rider", -1),
	(try_end),
	
	(agent_set_slot, ":horse", slot_agent_horse_rider, ":rider"),
  ]),

(ti_on_agent_killed_or_wounded, 0, 0, [], #De-Horse Trigger 2
  [
	(store_trigger_param_1, ":dead_horse"),
	(neg|agent_is_human, ":dead_horse"),
	
	(agent_get_slot, ":rider", ":dead_horse", slot_agent_horse_rider),
	(ge, ":rider", 0),
	(agent_is_active, ":rider"),
	(agent_is_alive, ":rider"),
	(agent_is_non_player, ":rider"),
	
	(agent_set_division, ":rider", grc_infantry),
        (agent_set_slot, ":rider", slot_agent_new_division, grc_infantry),
  ]),

(1, 0, 0, [],
   [
    (try_for_agents, ":agent"),
        (agent_is_active, ":agent"),
        (agent_slot_ge, ":agent", slot_agent_new_division, 0),
        (agent_is_alive, ":agent"),
        (agent_get_division, ":division", ":agent"),
        (neg|agent_slot_eq, ":agent", slot_agent_new_division, ":division"),
        (agent_get_slot, ":new_div", ":agent", slot_agent_new_division),
        (agent_set_division, ":agent", ":new_div"),
    (try_end),    
   ]),
4) If you wish, add those four triggers to the next two missions, too: village_attack_bandits and village_raid
5) Either replace the "slot_agent_horse_rider" and "slot_agent_new_division" with numbers (I used 45 and 46 here, but if you are adding this to Native, it could begin as low as 26) or define it at the top of module_mission_templates or in module_constants with two lines:
slot_agent_horse_rider = 45
slot_agent_new_division = 46
6) Save. Compile. Play.


EDIT: Code fixed to prevent potential script errors/bugs.
EDIT 2: Code altered to ensure division changes were permanent, not just temporary.
 
Thank you very much!!! That’s really useful!

Could you please also advise on how to make those knights join infantry during sieges? I use the module system.
 
To make any troop that is supposed to be mounted belong to the infantry group, the following trigger should be added to all siege mission templates:
Code:
(ti_on_agent_spawn, 0, 0, [],
  [
	(store_trigger_param_1, ":agent"),
	(agent_is_non_player, ":agent"),
	(agent_get_troop_id, ":troop", ":agent"),
	(troop_is_guarantee_horse, ":troop"),
	
	(agent_set_division, ":agent", grc_infantry),
  ]),

The siege mission templates include: "besiege_inner_battle_castle", "besiege_inner_battle_town_center", "castle_attack_walls_defenders_sally", "castle_attack_walls_belfry",  "castle_attack_walls_ladder"

Also, see the above post. The code is edited to fix some potential for errors/bugs.
 
I designated some khergit horse to the medic group to help protect them when at the back of my line. Imagine my suprise that when I have other lords accompany me too battle that the grouping still applies to their forces. Therefore I have half my cav sitting protecting the medics, which now don't need protection with their equipment. kinda annoying.
 
Herald said:
I designated some khergit horse to the medic group to help protect them when at the back of my line. Imagine my suprise that when I have other lords accompany me too battle that the grouping still applies to their forces. Therefore I have half my cav sitting protecting the medics, which now don't need protection with their equipment. kinda annoying.
You must have been marshal then?
 
Thank you for the siege tweak! I tried it in quick siege and it works as intended, but gives the following warning:
Warning.jpg


What could be the problem?

 
@Alex Kit...
There's a problem with that block of 4 lines that is supposed to be only applying the change to the player's team. It's trying to run before the player has spawned, but the 0.5 should prevent that.

Try adding (eq, 1, 1) inside of the closed brackets [] and see if that makes a difference.
So the first line would look like:  (ti_on_agent_spawn, 0.5, 0, [(eq, 1,1)],
If that doesn't work, there's another way to do it...but this would be far simpler.
 
Caba`drin,

I tried this solution and it didn’t help, but removing the optional lines as you suggested previously did the job. Anyway, why did you think it important to exclude the AI from this script? Do you suspect incorrect behavior or something? Why bother?

EDIT: I checked the AI behaviour during castle attack and defense and it seems OK to me.
 
Back
Top Bottom