(I should have known it...)
Kuirassiers A can charge the Horse. Kuirassiers B can't.
The horses can charge A and B or go past them.

Moderators: rbodleyscott, Slitherine Core, Gothic Labs
- (a) enemy within two map squares directly to their front (one square if the chargers are facing diagonally) and facing within 45 degrees of directly towards them,
- or (b) enemy ZOCing them.
Code: Select all
if (IsInCloseCombat(unit) == 0) // Can't ZOC when in close combat
{
}
knowing that there is secondary ZoC in FoG2...The difference in the scripts is great.
I would say so: knowing that there is secondary ZoC in FoG2 I am surprised that the P&S script is much more than FoG2 one.
Code: Select all
FUNCTION PriorityChargeTargetAtTile(x, y, facing, me, current_target)
{
int potential_target;
int frontalX;
int frontalY;
int current_target_qualifies;
int priorityTarget1;
int priorityTarget2;
int j;
int k;
int ret;
ret = -1;
priorityTarget1 = -1;
priorityTarget2 = -1;
current_target_qualifies = 0;
frontalX = AdjacentX(x, facing);
frontalY = AdjacentY(y, facing);
potential_target = GetUnitOnTile(frontalX, frontalY);
// If no unit there, look in the next tile forward (orthogonal directions only). (So that units in chequerboard formation can protect each other from being ganged up on)
// I am not entirely sure about reducing the distance to 1 square in diagonal directions.
// However, making it 2 squares diagonally looks odd on the map, it just looks too far away to be the priority target.
// It might also cause issues with the method (see below) of checking for the diagonal move being blocked by an existing combat if "me" is not already in the adjacent square.
// On the other hand , making it 1 square diagonally means that the effects of a chequerboard are lost in diagonal directions.
// However, as the battle lines are normally drawn up orthogonally, I think that probably doesn't matter as much as getting it to look right.
// Of course, I can easily change it back if it causes problems.
if (potential_target == -1)
{
if ((facing == 0) || (facing == 90) || (facing == 180) || (facing == 270)) // Orthogonal directions
{
potential_target = GetUnitOnTile(AdjacentX(frontalX, facing), AdjacentY(frontalY, facing));
}
}
// Log("Facing before turn, unit in that direction", facing, potential_target);
if (potential_target > -1)
{
if ((GetUnitSide(potential_target) != GetUnitSide(me)) && (GetAttrib(potential_target, "MoraleState") < 3))
{
// If potential target facing within 45 degrees of directly towards us
if (GetAngleFromTile(x, y, potential_target) < 50)
{
// If potential target is in close combat then it isn't a priority target if it isn't a permitted charge target.
if ((IsInCloseCombat(potential_target) == 1) && (ChargePermitted(me, potential_target) == 0))
{
potential_target = -1;
}
// If potential target is blocked off from the testing unit by a diagonal close combat, then it isn't a priority target.
// Cannot use if (CallUnitFunctionDirect(me, "CHECK_UNIT_ASSAULT", me, potential_target) < 0) as test because it causes a crash bug - presumably due to recursive function calls
// The test below may not work perfectly for units that have to move to get to the adjacent position - if the program finds a different route, which is unlikely.
// Attempting to shift the unit before testing will cause bugs owing to this function being called from Check_Unit_Assault().
GetRouteCost(me, GetUnitX(potential_target), GetUnitY(potential_target), 0, 1);
if (CheckRouteDiagonalStepNotBlocked(me, 4) == -2)
{
potential_target = -1;
}
if ((IsArtillery(potential_target) == 1) && (IsProtectedArtillery(potential_target) == 1))
{
potential_target = -1;
}
if (potential_target != -1)
{
// Non light troops ignore light troops except commanded shot protected by mounted
if ((IsLightTroops(potential_target) == 0) || (IsProtectedCommShot(potential_target, 0) == 1) || (IsLightTroops(me) == 1))
{
if ((current_target == -1) || (potential_target == current_target))
{
ret = potential_target;
}
else
{
priorityTarget1 = potential_target;
}
}
}
}
}
}
if (ret == -1)
{
// If current_target has not yet qualified as a priority target, check for ZOCers
for (j = x-1; j <= x+1; j++)
{
for (k = y-1; k <= y+1; k++)
{
potential_target = IsTileZOCing(me, x, y, j, k, 1);
if (potential_target >= 0)
{
if ((current_target == -1) || (potential_target == current_target))
{
ret = potential_target;
}
else
{
if (priorityTarget2 == -1)
{
priorityTarget2 = potential_target;
}
}
}
}
}
}
if (ret == -1)
{
if (priorityTarget2 >= 0)
{
ret = priorityTarget2;
}
else
{
if (priorityTarget1 >= 0)
{
ret = priorityTarget1;
}
else
{
ret = current_target;
}
}
}
// Log("Unit, Priority Target", me, ret);
return ret;
}
Code: Select all
FUNCTION PriorityChargeTargetAtTile(x, y, facing, me, current_target)
{
int priority_target;
int j;
int k;
int ret;
ret = -1;
if (ret == -1)
{
// Check for ZOCers
for (j = x-1; j <= x+1; j++)
{
for (k = y-1; k <= y+1; k++)
{
priority_target = IsTileZOCing(me, x, y, j, k, 1, 0);
if (priority_target >= 0)
{
ret = priority_target;
if (ret == current_target)
{
// Jump out of loops
j = x + 2;
k = y + 2;
}
}
}
}
}
if (ret == -1)
{
ret = current_target;
}
// Log("Unit, Priority Target", me, ret);
return ret;
}
... or, at least, about having this opportunity to rear/flank charge.a) an enemy within two map squares directly to their front (one square if the chargers are facing diagonally) and facing within 45 degrees of directly towards them,
(b) enemy ZOCing them.
... as cleverly suggested by Cronos above, how about adding a third rule to the priority charge rules :if ((IsInCloseCombat(potential_target) == 1) && (ChargePermitted(me, potential_target) == 0)) and replace it with if (IsInCloseCombat(potential_target) == 1) //&& (ChargePermitted(me, potential_target) == 0)). That is to remove the second part of this condition.
(c) enemy can be rear/flank charged when in one of the 3 squares in front of them (from A to B) :
(a) an enemy on the next nearest map square directly to their front and facing towards them,
(b) an enemy ZoCing them,
(c) an enemy in the 3 tiles to their “front” and in a position of being rear/flank charged.