Page 1 of 1
Mount during battle,SwapUnitType,and CallunitFunction not work
Posted: Sun Dec 04, 2022 12:15 pm
by locustmustdie
design for pursuit stage action:Mount the Dismounted MAA to pursue the enemy on the blink of collapse.
Tried SwapUnitType(id,0); and CallUnitFunctionDirect(id,"ALL_DISMOUNT",id,GetUnitX(id),GetUnitY(id));
neither works.
Gentlemen,any idea?

Re: Mount during battle,SwapUnitType,and CallunitFunction not work
Posted: Sun Dec 04, 2022 1:23 pm
by Cronos09
locustmustdie wrote: ↑Sun Dec 04, 2022 12:15 pm
design for pursuit stage action:Mount the Dismounted MAA to pursue the enemy on the blink of collapse.
Tried SwapUnitType(id,0); and CallUnitFunctionDirect(id,"ALL_DISMOUNT",id,GetUnitX(id),GetUnitY(id));
neither works.
Gentlemen,any idea?
Why do you use "ALL_DISMOUNT" instead of "ALL_REMOUNT"?
I tried to use something like that in FoG2 before:
Code: Select all
if (evade == 1)
{
if ((IsUnitSquadType(me, "Foot_Dragoons") == 1) && (IsMounted(enemy) == 1))
{
CallUnitFunctionDirect(me, "ALL_REMOUNT", me, GetUnitX(me), GetUnitY(me));
}
...
and it worked fine there.
Re: Mount during battle,SwapUnitType,and CallunitFunction not work
Posted: Sun Dec 04, 2022 1:52 pm
by locustmustdie
Cronos09 wrote: ↑Sun Dec 04, 2022 1:23 pm
locustmustdie wrote: ↑Sun Dec 04, 2022 12:15 pm
design for pursuit stage action:Mount the Dismounted MAA to pursue the enemy on the blink of collapse.
Tried SwapUnitType(id,0); and CallUnitFunctionDirect(id,"ALL_DISMOUNT",id,GetUnitX(id),GetUnitY(id));
neither works.
Gentlemen,any idea?
Why do you use "ALL_DISMOUNT" instead of "ALL_REMOUNT"?
I tried to use something like that in FoG2 before:
Code: Select all
if (evade == 1)
{
if ((IsUnitSquadType(me, "Foot_Dragoons") == 1) && (IsMounted(enemy) == 1))
{
CallUnitFunctionDirect(me, "ALL_REMOUNT", me, GetUnitX(me), GetUnitY(me));
}
...
and it worked fine there.
lol,I misspelled

,thx,Cronos
but,can it work for side0? I want Dis_Foot_MAA on my side to remount
I swich the side for remount,still doesn't work,some thing wrong
mine
Code: Select all
for (i = 0; i < GetUnitCount(0); i++) //MAAs Remount to Pursue the defeated
{
id = GetUnitID(0,i);
if (id != -1)
{
if ((IsUnitValid(id) == 1) && (GetAttrib(id, "MoraleState") < 2))
{
if (StringCompare(GetWorkString(), "DIS_FOOT_MAA") == 1)
{
CallUnitFunctionDirect(id,"ALL_REMOUNT",id,GetUnitX(id),GetUnitY(id));
}
}
}
}
Re: Mount during battle,SwapUnitType,and CallunitFunction not work
Posted: Sun Dec 04, 2022 4:04 pm
by locustmustdie
Let me guess,Richard forbidden it by coercive measures.

But I have an idea to play trick.
Re: Mount during battle,SwapUnitType,and CallunitFunction not work
Posted: Sun Dec 04, 2022 6:13 pm
by Cronos09
locustmustdie wrote: ↑Sun Dec 04, 2022 1:52 pm
...but,can it work for side0? I want Dis_Foot_MAA on my side to remount
I swich the side for remount,still doesn't work,some thing wrong
mine
Code: Select all
for (i = 0; i < GetUnitCount(0); i++) //MAAs Remount to Pursue the defeated
{
id = GetUnitID(0,i);
if (id != -1)
{
if ((IsUnitValid(id) == 1) && (GetAttrib(id, "MoraleState") < 2))
{
if (StringCompare(GetWorkString(), "DIS_FOOT_MAA") == 1)
{
CallUnitFunctionDirect(id,"ALL_REMOUNT",id,GetUnitX(id),GetUnitY(id));
}
}
}
}
Sorry, I forgot to point out that you must fill
FUNCTION CHECK_ALL_REMOUNT(me, tilex, tiley) for it. You can take the function body from
FUNCTION DEPLOYCHECK_ALL_REMOUNT(me, tilex, tiley) without
if (gForceSelection[GetUnitSide(me)] == 0).
But it will be better, if you write
FUNCTION ALL_REMOUNT1(me, tilex, tiley) in your
Scenario.BSF and will use
ALL_REMOUNT1 operator in your scripts.
Re: Mount during battle,SwapUnitType,and CallunitFunction not work
Posted: Sun Dec 04, 2022 11:34 pm
by locustmustdie
Cronos09 wrote: ↑Sun Dec 04, 2022 6:13 pm
Sorry, I forgot to point out that you must fill
FUNCTION CHECK_ALL_REMOUNT(me, tilex, tiley) for it. You can take the function body from
FUNCTION DEPLOYCHECK_ALL_REMOUNT(me, tilex, tiley) without
if (gForceSelection[GetUnitSide(me)] == 0).
But it will be better, if you write
FUNCTION ALL_REMOUNT1(me, tilex, tiley) in your
Scenario.BSF and will use
ALL_REMOUNT1 operator in your scripts.
I see,just like stakes,check_all first,then deploy
Re: Mount during battle,SwapUnitType,and CallunitFunction not work
Posted: Mon Dec 05, 2022 7:28 am
by locustmustdie
@cronos09
I got the bug now,it's cuz of
Code: Select all
if (StringCompare(GetWorkString(), "DIS_FOOT_MAA") == 1)
Can't figure out why,as the "DIS_FOOT_MAA"was copy&pasted from Scenario.BAM.
I fix that by alter it with
Code: Select all
if(IsMounted(id) == 0)
{
GetAttribString(GetUnitTypeIndex(id), 0); //to swap if has a mounted version
if (StringCompare(GetWorkString(), "") == 0)
works fine now.
Still confused about the reason.
Re: Mount during battle,SwapUnitType,and CallunitFunction not work
Posted: Mon Dec 05, 2022 10:32 am
by Cronos09
locustmustdie wrote: ↑Mon Dec 05, 2022 7:28 am
@cronos09
I got the bug now,it's cuz of
Code: Select all
if (StringCompare(GetWorkString(), "DIS_FOOT_MAA") == 1)
Can't figure out why,as the "DIS_FOOT_MAA"was copy&pasted from Scenario.BAM.
I fix that by alter it with
Code: Select all
if(IsMounted(id) == 0)
{
GetAttribString(GetUnitTypeIndex(id), 0); //to swap if has a mounted version
if (StringCompare(GetWorkString(), "") == 0)
works fine now.
Still confused about the reason.
I can't explain the reason, because working with strings in scripts is not clear to me. It is the best option to use the current script constructions.
Re: Mount during battle,SwapUnitType,and CallunitFunction not work
Posted: Sat Dec 10, 2022 7:38 am
by locustmustdie
After increased Elan,experience and ammo for English;add Morale drop and a high proportion of raw troops for French,still can't win the battle of herrings. Those French were genius to lose such a battle that so hard to lose.
The program AI seemed enhanced that will avoid assaulting towards light fortifications as cavalry.Hence I added a segment forcing Lord Darnley launching kamikaze attack to make walk through possible.Sth. similar to AutomaticMove.