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

Users who are viewing this thread

Dain Ironfoot said:
So if I replace :distance with an integer that is a little more or less than half the distance between troops, that would have the desired effect?
But... but... what if the player orders "spread out" or "close ranks?"
Dain Ironfoot said:
Actually, this is a problem I haven't solved. The AI makes similar decisions based on the average position of the troops -- not terribly ideal. I suppose you could write a script that would loop through all agents, pick the ones in the formation, and compare position with scripted destination, then make some judgments about how many are how close...

Eep. Sounds tricky. What I'm trying to do is fire off a script which causes the front rank to brace spears, easy enough to do.. except they become immobile, which can result in the first rank getting left behind. And I guess I'd need a stand up script for every movment etc. Flibbertigibbet.
Actually, when I wrote about that script, I thought it would be easy enough to put in script_battlegroup_get_data, adding slots for distance to scripted destination and averaging for each division as a whole. Then you'd simply pull that slot, see if it were under, say, minimum_distance_between_troops, then set the front rank. Or pull the corresponding slot for each agent in the front rank and do the same on an agent basis. It's a great idea!

Maybe I can take a break from BW after the weekend to set you up.
 
motomataru said:
Dain Ironfoot said:
So if I replace :distance with an integer that is a little more or less than half the distance between troops, that would have the desired effect?
You know, :distance IS the distance between troops. So you'd want to move HALF of that right or left as rank changes, right in the code you quoted:
Code:
				 (gt, ":column", ":rank_dimension"),	 #next rank?
				 (position_move_y, pos1, ":neg_distance", 0),
				 (try_begin),
					 (neq, ":form_left", 1),
					 (assign, ":form_left", 1),
***					 (position_move_x, pos1, ":HALF_neg_distance", 0),
				 (else_try),
					 (assign, ":form_left", 0),
***					 (position_move_x, pos1, ":HALF_distance", 0),
				 (try_end),			
				 (assign, ":column", 1),
				 (val_add, ":rank", 1),
motomataru said:
Actually, when I wrote about that script, I thought it would be easy enough to put in script_battlegroup_get_data, adding slots for distance to scripted destination and averaging for each division as a whole. Then you'd simply pull that slot, see if it were under, say, minimum_distance_between_troops, then set the front rank. Or pull the corresponding slot for each agent in the front rank and do the same on an agent basis. It's a great idea!

Maybe I can take a break from BW after the weekend to set you up.
You know, a new slot would be overkill. I suggest the following making your calls to the brace spear functions in your section of script_form_infantry. Such as:
Code:
					(try_begin),
						(eq, ":rank", 1),
						(call_script, "script_equip_best_melee_weapon", ":agent", 0, 0, ":fire_order"),
vvv						(try_begin),
							agent has spear?,
							(agent_get_scripted_destination, <position_A>, ":agent"),
							(agent_get_position, <position_B>, ":agent"),
							(get_distance_between_positions,<distance>,<position_A>,<position_B>),
							(try_begin),
								(le, <distance>, formation_minimum_spacing),
								(spear is not braced?),
								(brace spear),
							(else_try),
								(gt, <distance>, formation_minimum_spacing),
								(spear is braced?),
								(unbrace spear),
							(try_end),
^^^						(try_end),
					(else_try),
						(call_script, "script_equip_best_melee_weapon", ":agent", 0, 1, ":fire_order"),
					(try_end),

The periodic reform of the formation every five seconds calls this...
 
You know, :distance IS the distance between troops. So you'd want to move HALF of that right or left as rank changes, right in the code you quoted:

Great, that worked perfectly! Thanks!

You know, a new slot would be overkill. I suggest the following making your calls to the brace spear functions in your section of script_form_infantry. Such as:

That sounds good! Given me an idea about stopping archers firing until they've formed up too!

EDIT: Ok, done various experiments and I think the check that the game doesn't know when the agents are in formation as they just keep acting as if they haven't formed up yet (using the method you posted above)

Regards bracing scripts: I'll give it a go, but here's a stupid question (As I said, I'm very new to coding)

when you refer to

Code:
(spear is not braced?),
								(brace spear),

How do I check for the bracing without checking for a slot?
 
Dain Ironfoot said:
EDIT: Ok, done various experiments and I think the check that the game doesn't know when the agents are in formation as they just keep acting as if they haven't formed up yet (using the method you posted above)
Hm, that's disappointing...
Dain Ironfoot said:
Regards bracing scripts: I'll give it a go, but here's a stupid question (As I said, I'm very new to coding) when you refer to

Code:
(spear is not braced?),
								(brace spear),
How do I check for the bracing without checking for a slot?
I don't know the brace spear mod. I imagine there's a slot, but if not, just add a unique agents slot for it in module_constants. The mechanism for tracking braced spear would be in the mission_templates trigger that captures the player order...
 
I'm going to continue experimenting. Perhaps it also needs to check for negative distance too? Perhaps we should use the pos1 already defined in the forming up scripts, rather than getting a new position with the get_scripted_location. There seems to be one agent in the centre which can detect that it is in formation. Perhaps some sort of debug script may be in order to work out exactly what is going on.

EDIT: Bah, no. Here is my current script, using the equip melee weapon as a test. If it works, the unit will switch to melee once they form up.

Code:
(gt, ":column", ":rank_dimension"),	#next rank?
				(position_move_y, pos1, ":neg_distance", 0),
				(try_begin),
					(neq, ":form_left", 1),
					(assign, ":form_left", 1),
					(position_move_x, pos1, ":neg_distance", 0),
				(else_try),
					(assign, ":form_left", 0),
					(position_move_x, pos1, ":distance", 0),
				(try_end),			
				(assign, ":column", 1),
				(val_add, ":rank", 1),
			(end_try),
			(try_begin),
(agent_get_position, pos2, ":agent"),
						(get_distance_between_positions,":dist",pos1,pos2),
						(eq, ":rank", 1),
(try_begin),
(le, ":dist", formation_minimum_spacing),
(call_script, "script_equip_best_melee_weapon", ":agent", 0, 1),
(else_try),
(gt, ":dist", formation_minimum_spacing),
(try_end),
       (else_try),
       (agent_get_position, pos2, ":agent"),
						(get_distance_between_positions,":dist",pos1,pos2),
						(eq, ":rank", 1),
						(try_begin),
(le, ":dist", formation_minimum_spacing),
(call_script, "script_equip_best_melee_weapon", ":agent", 0, 1),
(else_try),
(gt, ":dist", formation_minimum_spacing),
	(try_end),	
		(try_end),
		(end_try),
 
so just wondering, does this work for warband in the same way? its just coz warband already has a morale system, or is this one more advanced?

Many thanks.
 
Dain Ironfoot said:
I'm going to continue experimenting. Perhaps it also needs to check for negative distance too? Perhaps we should use the pos1 already defined in the forming up scripts, rather than getting a new position with the get_scripted_location.
Got a point!
Dain Ironfoot said:
There seems to be one agent in the centre which can detect that it is in formation. Perhaps some sort of debug script may be in order to work out exactly what is going on.
You know how to do it? At your check point, assign variables to registers and then display_message. For example:

(assign, reg0, ":agent"),
(assign, reg1, ":dist"),
(display_message, "@Agent {reg0} is {reg1} from scripted destination"),

Dain Ironfoot said:
EDIT: Bah, no. Here is my current script, using the equip melee weapon as a test. If it works, the unit will switch to melee once they form up.
No, message is better. Otherwise you will have to decide whether each agent should have switched weapons as you watch to see if they do.

Also, I don't understand why you repeat the test section of your code.

EDIT: BTW, I forgot to mention, brace spear could use some polishing. See http://forums.taleworlds.com/index.php/topic,191590.msg4622537.html#msg4622537
Tsubodai said:
so just wondering, does this work for warband in the same way? its just coz warband already has a morale system, or is this one more advanced?
Hail Fist of the Great Khan!

Both M&B and Warband are supported, although at this point I'm only developing Warband. I don't touch morale; only replace AI if you decide to include that part. The base mod only provides formations in different manner than TW has since developed.
 
Also, I don't understand why you repeat the test section of your code.

I was trying to work out if the 2nd rank could detect they were in position as well, I was experimenting with preventing all archers in a formation from firing until they came into position initially before deciding to rewrite it. Will try it with the debug script!
 
Dain Ironfoot said:
Ok, so here's a question, should we be making the distance check before or after pos1 is moved?
Aha! Should be before. The current position of the agent should be compared to destination, so right after

(agent_set_scripted_destination, ":agent", pos1, 1),

The algorithm is to then go on and set up the destination for the next agent. Sorry I didn't catch that...
 
Ok, the debug reveals what I suspected, that each agent tries to use the same pos1 (first agents position) rather than their own modified pos1, as changed later in the script. While they are all in within 100 of this position, even when in a larger formation, I suspect this would break if we tried to use :dist > 100 as a check as they shuffle past pos1.

So I guess we need to have the script looking for pos1 after it has been moved for each agent?

 
Dain Ironfoot said:
Ok, the debug reveals what I suspected, that each agent tries to use the same pos1 (first agents position) rather than their own modified pos1, as changed later in the script. While they are all in within 100 of this position, even when in a larger formation, I suspect this would break if we tried to use :dist > 100 as a check as they shuffle past pos1.

So I guess we need to have the script looking for pos1 after it has been moved for each agent?

??? I don't understand how all agents in a large formation could possibly be within 100 cm of the same position.

***

In other news, I attempted to force thrust attack from inside formations without success. The problem was trying to "insert" the attack. What I tried to do was detect agent_get_attack_action 1 (prepping attack) and then agent_set_attack_action to 0 (thrust).

EDIT: but maybe I'll put the code back in there. It doesn't seem to make things worse...

But along the way I did discover that spreading the formation out to free up swinging attacks does improve formation performance. The distance required to swing free seems to be weapon length + 100 cm.
 
motomataru said:
Dain Ironfoot said:
Ok, the debug reveals what I suspected, that each agent tries to use the same pos1 (first agents position) rather than their own modified pos1, as changed later in the script. While they are all in within 100 of this position, even when in a larger formation, I suspect this would break if we tried to use :dist > 100 as a check as they shuffle past pos1.

So I guess we need to have the script looking for pos1 after it has been moved for each agent?

??? I don't understand how all agents in a large formation could possibly be within 100 cm of the same position.

It is a weird one. Perhaps it's not cm?
 
Dain Ironfoot said:
motomataru said:
??? I don't understand how all agents in a large formation could possibly be within 100 cm of the same position.
It is a weird one. Perhaps it's not cm?
get_distance_between_positions  = 710 # gets distance in centimeters. # (get_distance_between_positions,<destination>,<position_no_1>,<position_no_2>),
get_distance_between_positions_in_meters  = 711 # gets distance in meters. # (get_distance_between_positions_in_meters,<destination>,<position_no_1>,<position_no_2>),
 
Ah, bugger. It is a weird one then. That's what the script returns. In which case it is checking it to the modified pos1.. which means the script should work.. formation_minimum_spacing is in cm right?

Less than 100 is working fine it seems Have yet to try it with a script that immobilises an agent when they are in position, but my hold fire when unformed script is working nicely.
 
Only thing I've noticed is that archers in formation have a tendency to move their formation without orders, player formations and AI tend to end up circling each other sometimes. Could be due to my buggy attempt at getting AI archers to use the new archer formations.
 
Dain Ironfoot said:
Only thing I've noticed is that archers in formation have a tendency to move their formation without orders,
Actually, that ought to happen with infantry as well. My best solution to dealing with crazy rotations at close ranges was to basically put them on a 20m radius. So when player formations reform, they shift to face the enemy as if they were circling in front of a point 20m behind them. See wherever you see the number 2000 in my code. I suppose you could limit this to whenever a formation is referencing another close by. Part of the work I'm doing now is to try (yet again) to find a better solution (now that slots allow me to check the rotation of the nearest enemy formation).
Dain Ironfoot said:
player formations and AI tend to end up circling each other sometimes. Could be due to my buggy attempt at getting AI archers to use the new archer formations.
It's almost certainly script_get_centering_amount. For example, this started happening to me again when I allowed AI formations to spread out a bit, because the assumption in the code I've put here is that the AI formations are at their minimum spacing. Changing the call fixed my problem, but I think you changed the content of that script, right?
 
Doesn't work on 1.143 as for me.  :neutral:
Pressing F4 does nothing.
Tried either compiled, and source version. doesn't work.
The only thing I noticed it does, is putting units in formation at the beginning of battle. :sad:

In addition, I get such errors when building.
Code:
Initializing...
Compiling all global variables...
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting map icons...
Creating new tag_uses.txt file...
Creating new quick_strings.txt file...
Exporting faction data...
Exporting item data...
Exporting scene data...
Exporting troops data
Exporting particle data...
Exporting scene props...
Exporting tableau materials data...
Exporting presentations...
Exporting party_template data...
Exporting parties
Exporting quest data...
Exporting info_page data...
Exporting scripts...
Error: Unable to find object:script_battlegroup_get_position
ERROR: Illegal Identifier:script_battlegroup_get_position
Error: Unable to find object:script_battlegroup_get_position
ERROR: Illegal Identifier:script_battlegroup_get_position
Exporting mission_template data...
Exporting game menus data...
exporting simple triggers...
exporting triggers...
exporting dialogs...
Checking global variable usages...
WARNING: Global variable never used: team0_archers_have_ammo
WARNING: Global variable never used: team0_percent_ranged_throw
WARNING: Global variable never used: team0_percent_cavalry_are_archers
WARNING: Global variable never used: team1_archers_have_ammo
WARNING: Global variable never used: team1_percent_ranged_throw
WARNING: Global variable never used: team1_percent_cavalry_are_archers
WARNING: Global variable never used: team2_archers_have_ammo
WARNING: Global variable never used: team2_percent_ranged_throw
WARNING: Global variable never used: team2_percent_cavalry_are_archers
WARNING: Global variable never used: team3_archers_have_ammo
WARNING: Global variable never used: team3_percent_ranged_throw
WARNING: Global variable never used: team3_percent_cavalry_are_archers
WARNING: Global variable never used: team0_weapon_length_infantry
WARNING: Global variable never used: team1_weapon_length_infantry
WARNING: Global variable never used: team2_weapon_length_infantry
WARNING: Global variable never used: team3_weapon_length_infantry
WARNING: Global variable never used: team0_weapon_length_archers
WARNING: Global variable never used: team1_weapon_length_archers
WARNING: Global variable never used: team2_weapon_length_archers
WARNING: Global variable never used: team3_weapon_length_archers
WARNING: Global variable never used: team0_weapon_length_cavalry
WARNING: Global variable never used: team1_weapon_length_cavalry
WARNING: Global variable never used: team2_weapon_length_cavalry
WARNING: Global variable never used: team3_weapon_length_cavalry
WARNING: Global variable never used: teamp_weapon_length_group3
WARNING: Global variable never used: teamp_weapon_length_group4
WARNING: Global variable never used: teamp_weapon_length_group5
WARNING: Global variable never used: teamp_weapon_length_group6
WARNING: Global variable never used: teamp_weapon_length_group7
WARNING: Global variable never used: teamp_weapon_length_group8
WARNING: Global variable never used: team0_level
WARNING: Global variable never used: team1_level
WARNING: Global variable never used: team2_level
WARNING: Global variable never used: team3_level
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .
 
The compiled version does not have the F-key interface. It uses the old j,k,l,; keys.

From the compiler output, it looks like you want formations but not the AI. You can ignore all those unused globals used by AI. However, when I moved script_battlegroup_get_data to the formations mod, I didn't realize I needed to move script battlegroup_get_position, too.

If you're using modmerger, move that script from formAI_scripts to formations_scripts. If you manually edited module_scripts, copy that script from formAI_scripts.

I'm still not sure why you're not getting a response from F4, particularly if you're compiling using modmerger. Unless you set it to compile for MB 1.011, in which case F4 is not supported.
 
Back
Top Bottom