Automatic cohesion test before the impact

Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2682
Joined: Wed May 29, 2019 3:23 pm

Automatic cohesion test before the impact

Post by Athos1660 »

Trying to mod non-light cavalry fights, I try to implement automatic cohesion test at the impact for both enemy units whatever the casualties are, without extra modifiers, the rest of the Vanilla rules of non-light cav impact/melee remaining the same.

So I simply inserted...

Code: Select all

									// My mod
									if ((IsMounted(me)) && (IsMounted(enemy)) && (IsLightTroops(me) == 0) && (isLightTroops(enemy) == 0) && (reason == 1))
										{
											test = 1;
										}
									//end o my mod
... into FUNCTION MoraleUpdate(me, enemy, reason, loser, combatLog, shot, notional_turn, fullReason) in MoraleTools.BSF there :

Code: Select all

							if ((reason == 1) || (reason == 2)) // Close combat
								{
									if (loser != me)
										{
											test = 0; // No test
										}
									// My mod
									if ((IsMounted(me)) && (IsMounted(enemy)) && (IsLightTroops(me) == 0) && (isLightTroops(enemy) == 0) && (reason == 1))
										{
											test = 1;
										}
									//end o my mod
								}

							if (reason == 5)  // Autodrop
Is it the correct way to do it ?

It seems to work according to the combat log (and seemed to provide interesting results during my first two testing).
But does it risk to interfere in the Vanilla process of cohesion test at the impact ?
No risk of double drop the first time from my automatic cohesion test during Impact and the second time because of a significant total close combat at the same impact ? Maybe my automatic cohesion test during my turn, the Vanilla cohesion test during the enemy turn ?
Do the Vanilla modifiers apply correctly ?

link to my MoraleTools.BSF : http://www.mediafire.com/file/2udfrxo46 ... s.BSF/file
Last edited by Athos1660 on Fri May 08, 2020 3:42 pm, edited 1 time in total.
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28323
Joined: Sun Dec 04, 2005 6:25 pm

Re: Automatic cohesion test at the impact

Post by rbodleyscott »

Looks as if it might work to me, but the only way to be sure is testing.
Richard Bodley Scott

Image
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2682
Joined: Wed May 29, 2019 3:23 pm

Re: Automatic cohesion test at the impact

Post by Athos1660 »

Nice. Thank you ! I will.

(I like the idea of giving some effect to the cavalry charge (prior to the actual impact and its outcome in terms of casualties.))
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2682
Joined: Wed May 29, 2019 3:23 pm

Re: Automatic cohesion test before the impact

Post by Athos1660 »

I think that what I try to achieve is creating an additional phase to the cav vs cav fights : the charge before the impact and the melee, so that :
  • 1) Charge (when the cav runs to the enemy, just after clicking the charge icon) : automatic cohesion test for both units. During that moment, a cav unit can lose heart, suffer a loss of density, making its impact less effective or might even flee, refusing the impact.
  • 2) Impact : as Vanilla
  • 3) Melee : as Vanilla

I’ll see if I can do it. Right now, in my mod, charge and impact are mixed.
Schweetness101
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 928
Joined: Tue Nov 29, 2016 6:12 am

Re: Automatic cohesion test before the impact

Post by Schweetness101 »

I haven't looked at the code yet, I will when I get a chance. But, the first thing that comes to mind is that there is an automatic cohesion test on impact for all fragmented units that receive a charge. I would look around in the code for where that happens and try to replicate it for cav vs cav. That's where I would start anyway.
My Mods:
Ancient Greek https://www.slitherine.com/forum/viewtopic.php?p=977908#p977908
Dark Ages Britain https://www.slitherine.com/forum/viewtopic.php?t=106417
Anarchy (Medieval) https://www.slitherine.com/forum/viewtopic.php?p=987488#p987488
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2682
Joined: Wed May 29, 2019 3:23 pm

Re: Automatic cohesion test before the impact

Post by Athos1660 »

Schweetness101 wrote: Fri May 08, 2020 3:48 pm I haven't looked at the code yet, I will when I get a chance.
Thank you very much :-)
Schweetness101 wrote: Fri May 08, 2020 3:48 pm But, the first thing that comes to mind is that there is an automatic cohesion test on impact for all fragmented units that receive a charge. I would look around in the code for where that happens and try to replicate it for cav vs cav. That's where I would start anyway.
in Assault.bsf, yes.

That's the file I tried to unsuccessfully mod
Schweetness101
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 928
Joined: Tue Nov 29, 2016 6:12 am

Re: Automatic cohesion test before the impact

Post by Schweetness101 »

Athos1660 wrote: Fri May 08, 2020 4:03 pm
Schweetness101 wrote: Fri May 08, 2020 3:48 pm I haven't looked at the code yet, I will when I get a chance.
Thank you very much :-)
Schweetness101 wrote: Fri May 08, 2020 3:48 pm But, the first thing that comes to mind is that there is an automatic cohesion test on impact for all fragmented units that receive a charge. I would look around in the code for where that happens and try to replicate it for cav vs cav. That's where I would start anyway.
in Assault.bsf, yes.

That's the file I tried to unsuccessfully mod
so did you get the mod working?
My Mods:
Ancient Greek https://www.slitherine.com/forum/viewtopic.php?p=977908#p977908
Dark Ages Britain https://www.slitherine.com/forum/viewtopic.php?t=106417
Anarchy (Medieval) https://www.slitherine.com/forum/viewtopic.php?p=987488#p987488
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2682
Joined: Wed May 29, 2019 3:23 pm

Re: Automatic cohesion test before the impact

Post by Athos1660 »

Schweetness101 wrote: Fri May 08, 2020 4:07 pm
Athos1660 wrote: Fri May 08, 2020 4:03 pm
Schweetness101 wrote: Fri May 08, 2020 3:48 pm I haven't looked at the code yet, I will when I get a chance.
Thank you very much :-)
Schweetness101 wrote: Fri May 08, 2020 3:48 pm But, the first thing that comes to mind is that there is an automatic cohesion test on impact for all fragmented units that receive a charge. I would look around in the code for where that happens and try to replicate it for cav vs cav. That's where I would start anyway.
in Assault.bsf, yes.

That's the file I tried to unsuccessfully mod
so did you get the mod working?
No.
But I didn't start from your idea of automatic cohesion test on impact for all fragmented units
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2682
Joined: Wed May 29, 2019 3:23 pm

Re: Automatic cohesion test before the impact

Post by Athos1660 »

For example, I tried in Assault. bsf :

Code: Select all

FUNCTION UNIT_ASSAULT(me, unit, pursuit)
{
	int morale_state;
	int already_routed;
	int evaded;
	int route;
	int total;
	int adjacent_X;
	int adjacent_Y;
	int test;
	int enemy;

	// Set cannot control so tiles no longer highlighted as if unit could move
	SetCannotControl(me, 1); // This probably renders all other calls to SetCannotControl(me, 1); in Unit_Assault() and Resolve_Assault() redundant.

	// Prevent Undo Move (This should actually be redundant because of the line above).
	SetAttrib(me, "Irreversible", 1);
	
	ResetMovedLastFlags(GetUnitSide(me));

	// centre on the action
	if (pursuit == 0)
		{
			AddVizCamUnit(me);
			AddVizUnitText(me, "IDS_UNIT_CHARGING", "ffffff", 1);
			AddVizFunctionCall("PlayChargeSounds", me);
//			if ((IsMounted(me)) && (IsMounted(enemy)) && (IsLightTroops(me) == 0) && (isLightTroops(enemy) == 0))
//				{
//					test = 1;
//				}
		}
... and, later as another mod, in Moraletools.bsf :

Code: Select all

FUNCTION MoraleUpdate(me, enemy, reason, loser, combatLog, shot, notional_turn, fullReason)
{
	int morale_state;
	int test;
	int id;
	int pursuit;
	int route;

	//mon mod
	//if ((IsMounted(me)) && (IsMounted(enemy)) && (IsLightTroops(me) == 0) && (isLightTroops(enemy) == 0) && (route != 1) && (pursuit == 0))
	//	{
	//		test = 1;
	//	}
	//fin
Schweetness101
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 928
Joined: Tue Nov 29, 2016 6:12 am

Re: Automatic cohesion test before the impact

Post by Schweetness101 »

Athos1660 wrote: Fri May 08, 2020 4:24 pm For example, I tried...

so this seems to do it in FUNCTION UNIT_ASSAULT():

Code: Select all

	//if non light cav vs non light cav on impact then take a cohesion test:
	if ((IsMounted(me)) && (IsMounted(unit)) && (IsLightTroops(me) == 0) && (isLightTroops(me) == 0) && (isLightTroops(unit) == 0) && (route != 1) && (pursuit == 0))
		{
			morale_state = MoraleUpdate(unit, me, 3, -1, 0, 0, GetCurrentSide(), 8);//so right now this will just force a cohesion test and pretend like it was because of charging when fragmented
			//test to see if it does it, then add a new full reason, keeping 3 as reason, for non light cav charging non light cav
		}
*enemy is called unit in this method

I put that after line 109 after
SetAttrib(unit, "TargetY", adjacent_Y);
and before
morale_state = GetAttrib(unit,"MoraleState");
but your line numbers might be a bit different

as described in the comments there it just does the cohesion test as if charging an already fragmented unit. If you want it to give a new message you would also have to add a new fullreason == 10 for non light cav vs non light cav impact, and then account for that in cohesiontest(). I can do that as well and upload it as a mod if you like.

One thing is, especially with the other parts of the mod, is that it's quite common to win or lose close combat very badly on impact, and take a cohesion test from that as well, so you get a kind of visually confusing effect of two cohesion tests happening on top of one another. That's not necessarily bad, just something to note. It might just not be clear to the player what is happening. Additionally, if this cav charge was against a fragmented non light cav unit by a non light cav then it might take 3 cohesion tests now on impact (assuming it passed the first 2), not sure.

The above is perhaps not the right placement of the call. Maybe fragmented cav units should CT for that first, and then for the new auto impact CT, and finally for losing impact badly CT.

EDIT: this looks like it's only affecting the unit receiving the charge, so would have to figure out that as well

EDIT 2:
you have to call it twice, like this:

Code: Select all

                        morale_state = MoraleUpdate(unit, me, 3, -1, 0, 0, GetCurrentSide(), 8);
			morale_state = MoraleUpdate(me, unit, 3, -1, 0, 0, GetCurrentSide(), 8);
			
for unit vs me AND for me vs unit
My Mods:
Ancient Greek https://www.slitherine.com/forum/viewtopic.php?p=977908#p977908
Dark Ages Britain https://www.slitherine.com/forum/viewtopic.php?t=106417
Anarchy (Medieval) https://www.slitherine.com/forum/viewtopic.php?p=987488#p987488
Schweetness101
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 928
Joined: Tue Nov 29, 2016 6:12 am

Re: Automatic cohesion test before the impact

Post by Schweetness101 »

I think I'll try out a version of the cav mod that does the above and gets rid of the vs medium foot changes (just to try out one thing at a time)

And from testing, what values for ct and casualty changes did you find worked best? impact and melee? just one?
My Mods:
Ancient Greek https://www.slitherine.com/forum/viewtopic.php?p=977908#p977908
Dark Ages Britain https://www.slitherine.com/forum/viewtopic.php?t=106417
Anarchy (Medieval) https://www.slitherine.com/forum/viewtopic.php?p=987488#p987488
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2682
Joined: Wed May 29, 2019 3:23 pm

Re: Automatic cohesion test before the impact

Post by Athos1660 »

Schweetness101 wrote: Fri May 08, 2020 5:12 pm as described in the comments there it just does the cohesion test as if charging an already fragmented unit. If you want it to give a new message you would also have to add a new fullreason == 10 for non light cav vs non light cav impact, and then account for that in cohesiontest(). I can do that as well and upload it as a mod if you like.
I must admit I wouldn’t be able to do it myself.

Besides, if I want to make ct changes to the charge cohesion test, I need to create a new phase for CloseCombatLogic, don’t I ?
Schweetness101 wrote: Fri May 08, 2020 5:12 pm Additionally, if this cav charge was against a fragmented non light cav unit by a non light cav then it might take 3 cohesion tests now on impact (assuming it passed the first 2), not sure.
I will look at it during testing.
Schweetness101 wrote: Fri May 08, 2020 5:48 pm I think I'll try out a version of the cav mod that does the above and gets rid of the vs medium foot changes (just to try out one thing at a time)

And from testing, what values for ct and casualty changes did you find worked best? impact and melee? just one?
iirc, it was ct=-1 and +10% additional casualties for impact only, which is too low if your objective is to shorten the times of the cav fights significantly and systematically. (for comparison, iirc, the values of your mod were ct=-1 and +33% additional casualties for impact and melee, which really reduce the times of fights.)

What I'd test is :
- Charge : Cohesion drop = rare (so with positive modifiers, right ?)
- Impact : Vanilla (ct=0 and +0% additional casualties)
- Melee : Vanilla

I think it would provide both cases of short fights (say 3 turns) and longer ones (say 8 turns), a bit like my mod in OP with everything else Vanilla btw.

If I were you, I'd start with that and then increase the effect progressively up to what you wish.
Schweetness101
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 928
Joined: Tue Nov 29, 2016 6:12 am

Re: Automatic cohesion test before the impact

Post by Schweetness101 »

alright I updated the cav mod with a 1.4 version that gets rid of the medium foot changes and adds the auto CT for non light cav vs non light cav charges

https://www.dropbox.com/sh/jovvwuj2eesf ... 2Y1Va?dl=0

it still has all the other elements of the mod, including the infantry zoc/ap bits and the -1 CT/33% casualty increase on impact and melee, so just edit all of that if you like for testing (all of those things together make cav fights over too fast, but the idea of course is to test and see what works).

We should debate which of the three things to keep and at what numbers exactly. Really what matters is the goal of getting cav vs cav fights over faster by some means to be more historical (i think...) and so they can get onto the flanking business
My Mods:
Ancient Greek https://www.slitherine.com/forum/viewtopic.php?p=977908#p977908
Dark Ages Britain https://www.slitherine.com/forum/viewtopic.php?t=106417
Anarchy (Medieval) https://www.slitherine.com/forum/viewtopic.php?p=987488#p987488
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2682
Joined: Wed May 29, 2019 3:23 pm

Re: Automatic cohesion test before the impact

Post by Athos1660 »

Athos1660 wrote: Fri May 08, 2020 7:22 pm What I'd test is :
- Charge : Cohesion drop = rare (so with positive modifiers, right ?)
- Impact : Vanilla (ct=0 and +0% additional casualties)
- Melee : Vanilla
To make cohesion loss because of charge rarer, I added this bit of script in MoraleTools.bsf after line 508, ie after the Close combat test :

Code: Select all

	// Charge of Non-light cav test
	if ((IsMounted(me)) && (IsMounted(enemy)) && (IsLightTroops(me) == 0) && (isLightTroops(enemy) == 0) && (reason == 3 ))
		{
			modifiers += 1;
			PrintStringLiteralX(UIString, 0, "\n");
			PrintStringLiteralX(UIString, 0, "Charge of Non-light cav: +1");
			Log("Charge of Non-light cav", me);
		}
	//end

Is it correct ?

If so, my question is : has reason 3 already been used in the scripts for another situation in game, so that my code will unintentionally give this modifier to this situation, or is it written in a way that prevents it to happen (with : if ((IsMounted(me)) && (IsMounted(enemy)) && (IsLightTroops(me) == 0) && (isLightTroops(enemy) == 0)) ?
Schweetness101 wrote: Sat May 09, 2020 3:15 am We should debate which of the three things to keep and at what numbers exactly. Really what matters is the goal of getting cav vs cav fights over faster by some means to be more historical (i think...) and so they can get onto the flanking business
I think I have already expressed my opinions on this subject quite often.

I guess we both have different objectives :
- you : systematically shortening the times of cav fights
- me : give charges more weight while allowing some/most melees to last
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2682
Joined: Wed May 29, 2019 3:23 pm

Re: Automatic cohesion test before the impact

Post by Athos1660 »

I have a question. Here is the combat log of a first impact/melee between 2 fresh opponents during turn 1 :

1) The Charge :
("being charged when fragmented" doesn't mean they are. Both opponents are actually steady.

Image

2) The impact :

Image

Image

What does "additional modifier for the above' means ? Does it mean that the cohesion test during the charge automatically add a modifier -1 during the possible cohesion test of the following impact ? If so, it is not what I wish (as the charge cohesion test is automatic). Does the engine consider that both units were fragmented during the impact ? Do I have to offset it with an extra +1 during the cohesion test of the impact ?

Or does "for the above" is about "fighting lancers" ?

(edit)

I guess I have the answer : among the modifiers -1, there is “Any troops testing for having lost impact phase combat even partly against lancers".

However, that and the risk of a cohesion loss during the charge = a lot of risk !
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28323
Joined: Sun Dec 04, 2005 6:25 pm

Re: Automatic cohesion test before the impact

Post by rbodleyscott »

Athos1660 wrote: Sat May 09, 2020 6:47 am
Image

What does "additional modifier for the above' means ? Does it mean that the cohesion test during the charge automatically add a modifier -1 during the possible cohesion test of the following impact ? If so, it is not what I wish (as the charge cohesion test is automatic). Does the engine consider that both units were fragmented during the impact ? Do I have to offset it with an extra +1 during the cohesion test of the impact ?
It is worded that way because there are a number of CT modifiers that will only give a maximum of -1 however many of them apply. The ones shown as "Any one of..." in the chart in the Manual.

e.g.

If a medium foot unit was testing for losing an impact vs lancers in open terrain then
1) Fighting lancers
2) MF fighting mounted in open terrain
would both apply, but the actual total modifier for both would still be only -1
Richard Bodley Scott

Image
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2682
Joined: Wed May 29, 2019 3:23 pm

Re: Automatic cohesion test before the impact

Post by Athos1660 »

rbodleyscott wrote: Sat May 09, 2020 10:16 am It is worded that way because there are a number of CT modifiers that will only give a maximum of -1 however many of them apply. The ones shown as "Any one of..." in the chart in the Manual.

e.g.

If a medium foot unit was testing for losing an impact vs lancers in open terrain then
1) Fighting lancers
2) MF fighting mounted in open terrain
would both apply, but the actual total modifier for both would still be only -1
Thank you for the info.
Schweetness101 wrote: Fri May 08, 2020 5:48 pm And from testing, what values for ct and casualty changes did you find worked best? impact and melee? just one?
I am testing something I find interesting :
1) Charge : cohesion test ; +1 modifier (no additional casualty)
2) Impact : +1 modifier (no additional casualty)
3) Melee : Vanilla

PS : these are indeed '+' not '-'.
Schweetness101
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 928
Joined: Tue Nov 29, 2016 6:12 am

Re: Automatic cohesion test before the impact

Post by Schweetness101 »

Athos1660 wrote: Sat May 09, 2020 5:46 am
Athos1660 wrote: Fri May 08, 2020 7:22 pm What I'd test is :
- Charge : Cohesion drop = rare (so with positive modifiers, right ?)
- Impact : Vanilla (ct=0 and +0% additional casualties)
- Melee : Vanilla
To make cohesion loss because of charge rarer, I added this bit of script in MoraleTools.bsf after line 508, ie after the Close combat test :

Code: Select all

	// Charge of Non-light cav test
	if ((IsMounted(me)) && (IsMounted(enemy)) && (IsLightTroops(me) == 0) && (isLightTroops(enemy) == 0) && (reason == 3 ))
		{
			modifiers += 1;
			PrintStringLiteralX(UIString, 0, "\n");
			PrintStringLiteralX(UIString, 0, "Charge of Non-light cav: +1");
			Log("Charge of Non-light cav", me);
		}
	//end

Is it correct ?

If so, my question is : has reason 3 already been used in the scripts for another situation in game, so that my code will unintentionally give this modifier to this situation, or is it written in a way that prevents it to happen (with : if ((IsMounted(me)) && (IsMounted(enemy)) && (IsLightTroops(me) == 0) && (isLightTroops(enemy) == 0)) ?
reason 3 is 'other reason', which includes another 0-9 'fullReasons', where 8 is charged while fragmented. I added a 10th reason that is cohesion check from non light cav vs non light cav

I added to the explanation comment like this:

// fullReason: 0 = Shooting, 1 = Impact Close Combat, 2 = Melee Close combat, 4 = Bolster/Rally, 5 = automatic morale drop, 6 = Seeing rout, 7 = Seeing general fall, 8 = Charged while Fragmented, 9 = Fall back
//10 = auto CT from non light cav charging non light cav

at the top of moraletools.bsf

if reason is 3 in MoraleUpdate(), then it calls CohesionTest() which has a bunch of checks for the full reasons at the bottom, where I added an extra one like

//added for cav mod
if (fullReason == 10)
{
PrintStringLiteralX(UIString, 0, " ");
PrintStringLiteralX(UIString, 0, "Non-Light Cavalry Charged Non-Light Cavalry, auto CT");
//I have no idea where the above actually prints out though
}
//added for cav mod

not sure if it is fully working but if it is you call it like this from Assault.bsf:

morale_state = MoraleUpdate(unit, me, 3, -1, 0, 0, GetCurrentSide(), 10);
morale_state = MoraleUpdate(me, unit, 3, -1, 0, 0, GetCurrentSide(), 10);

notice the bold 10, not 8, because that last parameter is for the fullReason

not sure if every other parameter is correct or if you want this cohesion check to happen on routing or pursuing units

it also seems like it might not be happening on units that are already in combat.
My Mods:
Ancient Greek https://www.slitherine.com/forum/viewtopic.php?p=977908#p977908
Dark Ages Britain https://www.slitherine.com/forum/viewtopic.php?t=106417
Anarchy (Medieval) https://www.slitherine.com/forum/viewtopic.php?p=987488#p987488
Schweetness101
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 928
Joined: Tue Nov 29, 2016 6:12 am

Re: Automatic cohesion test before the impact

Post by Schweetness101 »

Athos1660 wrote: Sat May 09, 2020 5:46 am
Schweetness101 wrote: Sat May 09, 2020 3:15 am We should debate which of the three things to keep and at what numbers exactly. Really what matters is the goal of getting cav vs cav fights over faster by some means to be more historical (i think...) and so they can get onto the flanking business
I think I have already expressed my opinions on this subject quite often.

I guess we both have different objectives :
- you : systematically shortening the times of cav fights
- me : give charges more weight while allowing some/most melees to last
yes, I like both ideas, and yours seems to make sense in that cavalry vs cavalry charges would be more likely to be decisive than infantry vs infantry charges. But, assuming neither side does break, are cavalry vs cavalry melees still faster than infantry vs infantry melees? Just not by as much of a margin? I guess they would be but I am not an historian.

Ultimately, it would be neat I think if we ended up with a situation where:

1) infantry combat lasted a little bit longer and did not involve the same weird mid-line flanks from 45 degree units (flank angle mod and pike mod)
2) cavalry combat did not last as long and cav could get around infantry a little bit faster and could not be so readily zoc trapped by them (cav mod)

so that infantry lines were a bit more cohesive and battles were decided a bit more by larger cavalry flanks. That is of course all very controversial and there is no guarantee that I could a) achieve such a thing or that b) such a thing would be desirable. But, it's all just for fun you know, and I'm willing to try it out.

Once all the pieces are well tested I'll try to combine them. Then I can make people extra angry at me :wink:
My Mods:
Ancient Greek https://www.slitherine.com/forum/viewtopic.php?p=977908#p977908
Dark Ages Britain https://www.slitherine.com/forum/viewtopic.php?t=106417
Anarchy (Medieval) https://www.slitherine.com/forum/viewtopic.php?p=987488#p987488
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2682
Joined: Wed May 29, 2019 3:23 pm

Re: Automatic cohesion test before the impact

Post by Athos1660 »

Schweetness101 wrote: Sat May 09, 2020 5:45 pm
Athos1660 wrote: Sat May 09, 2020 5:46 am
Athos1660 wrote: Fri May 08, 2020 7:22 pm What I'd test is :
- Charge : Cohesion drop = rare (so with positive modifiers, right ?)
- Impact : Vanilla (ct=0 and +0% additional casualties)
- Melee : Vanilla
To make cohesion loss because of charge rarer, I added this bit of script in MoraleTools.bsf after line 508, ie after the Close combat test :

Code: Select all

	// Charge of Non-light cav test
	if ((IsMounted(me)) && (IsMounted(enemy)) && (IsLightTroops(me) == 0) && (isLightTroops(enemy) == 0) && (reason == 3 ))
		{
			modifiers += 1;
			PrintStringLiteralX(UIString, 0, "\n");
			PrintStringLiteralX(UIString, 0, "Charge of Non-light cav: +1");
			Log("Charge of Non-light cav", me);
		}
	//end

Is it correct ?

If so, my question is : has reason 3 already been used in the scripts for another situation in game, so that my code will unintentionally give this modifier to this situation, or is it written in a way that prevents it to happen (with : if ((IsMounted(me)) && (IsMounted(enemy)) && (IsLightTroops(me) == 0) && (isLightTroops(enemy) == 0)) ?
reason 3 is 'other reason', which includes another 0-9 'fullReasons', where 8 is charged while fragmented. I added a 10th reason that is cohesion check from non light cav vs non light cav

I added to the explanation comment like this:

// fullReason: 0 = Shooting, 1 = Impact Close Combat, 2 = Melee Close combat, 4 = Bolster/Rally, 5 = automatic morale drop, 6 = Seeing rout, 7 = Seeing general fall, 8 = Charged while Fragmented, 9 = Fall back
//10 = auto CT from non light cav charging non light cav

at the top of moraletools.bsf

if reason is 3 in MoraleUpdate(), then it calls CohesionTest() which has a bunch of checks for the full reasons at the bottom, where I added an extra one like

//added for cav mod
if (fullReason == 10)
{
PrintStringLiteralX(UIString, 0, " ");
PrintStringLiteralX(UIString, 0, "Non-Light Cavalry Charged Non-Light Cavalry, auto CT");
//I have no idea where the above actually prints out though
}
//added for cav mod

not sure if it is fully working but if it is you call it like this from Assault.bsf:

morale_state = MoraleUpdate(unit, me, 3, -1, 0, 0, GetCurrentSide(), 10);
morale_state = MoraleUpdate(me, unit, 3, -1, 0, 0, GetCurrentSide(), 10);

notice the bold 10, not 8, because that last parameter is for the fullReason

not sure if every other parameter is correct or if you want this cohesion check to happen on routing or pursuing units

it also seems like it might not be happening on units that are already in combat.
Sorry I was not clear.

If I added this...

Code: Select all

	// Charge of Non-light cav test
	if ((IsMounted(me)) && (IsMounted(enemy)) && (IsLightTroops(me) == 0) && (isLightTroops(enemy) == 0) && (reason == 3 ))
		{
			modifiers += 1;
			PrintStringLiteralX(UIString, 0, "\n");
			PrintStringLiteralX(UIString, 0, "Charge of Non-light cav: +1");
			Log("Charge of Non-light cav", me);
		}
	//end

... It was not meant to provide a title to the automatic charge cohesion tests before the impact. It was meant to add a modifier +1 to those very charge cohesion tests which it actually does :

Image

My question was actually :

If I write...

Code: Select all

	if ((IsMounted(me)) && (IsMounted(enemy)) && (IsLightTroops(me) == 0) && (isLightTroops(enemy) == 0) && (reason == 3 ))
... will this +1 modifier apply :
- when and only when a Non-Light Cavalry charges a Non-Light Cavalry ?
- or to any "other reason" including the 0-9 'fullReasons' (fall back, rally, charged when fragmented...) whenever 1 or 2 (?) non-light cav are involved ?

I fear the latter. If so, is there a way to solve the issue ?
Post Reply

Return to “Field of Glory II: Modding”