Modding horse ?

Moderators: rbodleyscott, Slitherine Core, Gothic Labs

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

Modding horse ?

Post by Athos1660 »

Does someone know how to... ?

Here is the result I'd like to test/play with (don't look at the highlighted squares, they are of no meaning):

Image

It comes to adding the 4 squares boxed in red to their current possibilities of moving :

Image

as if :
(1) rotating backwards and moving to A would cost 6 x 2 = 12 AP
(2) rotating backwards and moving to B would cost 4 x 2 = 8 AP
(3) rotating backwards and moving to C would cost 8 + 8 = 16 AP

(or as if horse could move backwards as a light unit that would have only 8 AP.)

Image

PS :
(1) ability to fall back as in current game would remain unchanged.
(2) moving to A, B or C does mean rotating backwards as light units do, not falling back without changing orientation.
Cronos09
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 326
Joined: Thu Feb 22, 2018 4:28 pm

Re: Modding horse ?

Post by Cronos09 »

Athos1660 wrote: Wed Nov 13, 2024 5:55 am Does someone know how to... ?
Just change the cost of turn at an angle more than 99 degrees for Mounted units in Tools.BSF - something like this:

Code: Select all

			if (angle >= 100) // More than 90 degrees + margin for error
				{
					if (IsLightTroops(me) == 1)
						{
							if (GetAttrib(me, "MadeLargeTurn") == 0)
								{
									cost = 0;
								}
							else
								{
									cost = 8;
								}
						}
					else
						{
							if ((IsUnitSquadType(me, "Artillery") == 1) || ((IsMounted(me) == 1) && (IsUnitSquadType(me, "Light_Horse") == 0)))
								{
									cost = 8; // Arbitrary cost to stop Medium and Heavy Artillery turning more than 45 degrees
								}
							else
								{
									cost = GetBaseAttrib(me, "AP"); // Otherwise takes full movement allowance
								}
						}

					if (test == 0)
						{
							SetAttrib(me, "MadeLargeTurn", 1);
						}
				}
One string is only changed - if ((IsUnitSquadType(me, "Artillery") == 1) || ((IsMounted(me) == 1) && (IsUnitSquadType(me, "Light_Horse") == 0)))
and all works fine.
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2678
Joined: Wed May 29, 2019 3:23 pm

Re: Modding horse ?

Post by Athos1660 »

Fantastique ! Thank you very much, Cronos. Still as effective !

Btw, it also allows other "Mounted" (such as Reiters, Kurassiers or Gendarmes) to have this behaviour. No big deal of course, as the mod can just to be turned on/off, according to one's own taste (or in SP you can just decide to ignore the '4 squares behind' ; in friendly MP too).

It'll even let me fullfill an old fantasy of mine : playing the Troop type 'Cavalry' in FoG2A and FoG2M as in OP :-)

Here is the result with cost = 6 (instead of the Vanilla '8' as in Cronos' mod above) on the line 734 (it seems to change nothing to Artillery as written) :

Image
Cronos09
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 326
Joined: Thu Feb 22, 2018 4:28 pm

Re: Modding horse ?

Post by Cronos09 »

Athos1660 wrote: Wed Nov 13, 2024 11:32 am
Btw, it also allows other "Mounted" (such as Reiters, Kurassiers or Gendarmes) to have this behaviour. No big deal of course, as the mod can just to be turned on/off, according to one's own taste (or in SP you can just decide to ignore the '4 squares behind' ; in friendly MP too).
I do not see the problem - you can point the necessary Squad types instead of all Mounted units:
if ((IsUnitSquadType(me, Cavalry") == 1) && (IsUnitSquadType(me, "Determined_Horse") == 1))
{
}
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2678
Joined: Wed May 29, 2019 3:23 pm

Re: Modding horse ?

Post by Athos1660 »

+1. Thanks
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2678
Joined: Wed May 29, 2019 3:23 pm

Re: Modding horse ?

Post by Athos1660 »

For the record, when the unit faces "diagonally" :

(1) with cost = 8

Image

(2) with cost = 6

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

Re: Modding horse ?

Post by Athos1660 »

Still for the record, when the unit faces "diagonally" in Vanilla game :
Image
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2678
Joined: Wed May 29, 2019 3:23 pm

Re: Modding horse ?

Post by Athos1660 »

The issue (from my point of view) with this mod as it is currently is that it breaks the ZoC :

Image

ie. an unit within charge reach of a non-routing non-light enemy unit can freely flee without any damage or risk,
which is not realistic imho, unless an "opportunity charge" from the enemy ZOCing unit could be randomly triggered (or not) during the turn of the ZOCed unit on its move (which would count as a rear attack).

So, is it possible to add the following contraint (in the absence of "opportunity charge") ?
"When within charge reach of a non-routing non-light enemy unit, the unit can't "move backwards", so that it would be 'trapped' this way (and like in Vanilla game)" :

Image

(and when NOT within charge reach of a non-routing non-light enemy unit, the unit can "move backwards")

Any tip would be amazing.
Cronos09
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 326
Joined: Thu Feb 22, 2018 4:28 pm

Re: Modding horse ?

Post by Cronos09 »

Athos1660 wrote: Sat Nov 16, 2024 9:09 am The issue (from my point of view) with this mod as it is currently is that it breaks the ZoC :
The ZoC option works in the original game in this way. Add an extra condition in TurnCost function, eg.

if ((IsUnitSquadType(me, "Cavalry") == 1) && (SquareZOCd(x, y, me, 1) == -1))
{
}


x and y should be described at the start of the function:
..
int x;
int y;

x = GetUnitX(me);
y = GetUnitY(me);


If you want ro count 'within charge reach' you must add a new function instead of the condition (you can take as a base of it FUNCTION ALL_FALLBACK(me, tilex, tiley) from FallBack.BSF
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2678
Joined: Wed May 29, 2019 3:23 pm

Re: Modding horse ?

Post by Athos1660 »

Thanks, Cronos !!!!
Cronos09 wrote: The ZoC option works in the original game in this way. Add an extra condition in TurnCost function, eg.

if ((IsUnitSquadType(me, "Cavalry") == 1) && (SquareZOCd(x, y, me, 1) == -1))
{
}


x and y should be described at the start of the function:
..
int x;
int y;

x = GetUnitX(me);
y = GetUnitY(me);
It does not work with me. I certainly did a mistake, maybe misplaced the piece of code :

Code: Select all

FUNCTION TurnCost(me, tilex, tiley, test)
{
int angle ;
int cost ;
int already_had_free_turn ;
int x;
int y;
x = GetUnitX(me);
y = GetUnitY(me);

    // Has unit already used its free turn this move?

    already_had_free_turn = GetAttrib(me, "MadeFreeTurn") ;

    // Get angle of turn, and cost move accordingly. Note that 45 degree move will be free if the unit has not used its free move yet.
    angle = GetAngleFromTile(tilex, tiley, me) ; //get the angle the unit is presenting to the denoted tile, 0=looking straight at it, 180= it is directly behind them.

    if ((IsUnitSquadType(me, "Determined_Horse") == 1)  && (SquareZOCd(x,y,me,1) == -1) || (IsUnitSquadType(me, "Horse") == 1)  && (SquareZOCd(x,y,me,1) == -1))
    //if ((IsUnitSquadType(me, "Horse") == 1)  && (SquareZOCd(x,y,me,1) == -1))
        {
        }

    if (already_had_free_turn == 1)
        {
            angle += 45;
        }

Last edited by Athos1660 on Sat Nov 16, 2024 12:49 pm, edited 2 times in total.
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2678
Joined: Wed May 29, 2019 3:23 pm

Re: Modding horse ?

Post by Athos1660 »

I found the good spot :

Code: Select all

            if (angle >= 100) // More than 90 degrees + margin for error
                {
                    if (IsLightTroops(me) == 1)
                        {
                            if (GetAttrib(me, "MadeLargeTurn") == 0)
                                {
                                    cost = 0;
                                }
                            else
                                {
                                    cost = 8;
                                }
                        }
                    else
                        {
                            //if ((IsUnitSquadType(me, "Artillery") == 1) || ((IsMounted(me) == 1) && (IsUnitSquadType(me, "Light_Horse") == 0))) // ligne changée
                            if ((IsUnitSquadType(me, "Artillery") == 1) || (IsUnitSquadType(me, "Determined_Horse") == 1) || (IsUnitSquadType(me, "Horse") == 1)) // ligne changée
                                {
                                    cost = 6; // Arbitrary cost to stop Medium and Heavy Artillery turning more than 45 degrees // j'ai changé le cost initial de 8
                                }
                            if ((IsUnitSquadType(me, "Determined_Horse") == 1)  && (SquareZOCd(x,y,me,1) == -1) || (IsUnitSquadType(me, "Horse") == 1)  && (SquareZOCd(x,y,me,1) == -1))
                                {
                                }
                            else
                                {
                                    cost = GetBaseAttrib(me, "AP"); // Otherwise takes full movement allowance
                                }

I will be able to test it. Thank you very much.
Cronos09
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 326
Joined: Thu Feb 22, 2018 4:28 pm

Re: Modding horse ?

Post by Cronos09 »

Athos1660 wrote: Sat Nov 16, 2024 12:42 pm
It does not work with me. I certainly did a mistake, maybe misplaced the piece of code :
The condition must be used in the code block with an angle more than 99 degrees like this:

Code: Select all

			if (angle >= 100) // More than 90 degrees + margin for error
				{
					if (IsLightTroops(me) == 1)
						{
							if (GetAttrib(me, "MadeLargeTurn") == 0)
								{
									cost = 0;
								}
							else
								{
									cost = 8;
								}
						}
					else
						{
							if (IsUnitSquadType(me, "Artillery") == 1)
								{
									cost = 8; // Arbitrary cost to stop Medium and Heavy Artillery turning more than 45 degrees
								}
							else
								{ 
									if ((IsUnitSquadType(me, "Determined_Horse") == 1) && (SquareZOCd(x, y, me, 1) == -1))
										{
											cost = 6;
										}
									else
										{
											cost = GetBaseAttrib(me, "AP"); // Otherwise takes full movement allowance
										}
								}
						}

					if (test == 0)
						{
							SetAttrib(me, "MadeLargeTurn", 1);
						}
				}
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2678
Joined: Wed May 29, 2019 3:23 pm

Re: Modding horse ?

Post by Athos1660 »

+1. Super !
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2678
Joined: Wed May 29, 2019 3:23 pm

Re: Modding horse ?

Post by Athos1660 »

This change in cav behaviour needs from me more testing. However, I do like the greater mobility of the cav, the ability to go back and forth in a more fluid way alllowing 'quick' changes in direction (instead of the current '180° turn on the spot' click as currently in Vanilla games).

For now, I've tested it on 'Horse' and 'Determined Horse' in P&S and 'Cavalry' in FoG2A/M with a turn cost of 6. But I will test it with Gendarmes in P&S and MAA in FoG2M too. Here is the modded range of motion for Gendarmes with 14 AP and a turn cost of 6 :

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

Re: Modding horse ?

Post by Athos1660 »

Tried it on 14-AP Gendarmes against Swiss 1494. I like it.
Post Reply

Return to “Modders Corner”