jomni wrote:Currently, my Japanese infantry don't charge horses. Is this mainly due to them being warrior or medium foot? what do I change in the code so that they can attack horses? I don't want to resort to changing their unit type.
What is the logic of this rule in Renaissance?
The logic is that they didn't do it. While later pike and shot units had enough pikes to fend off cavalry if they were ready for them, they did not have enough to aggressively advance against them - instead relying on shooting to drive them off.
Because of the IGOUGO nature of the game, cavalry combats are far more static in-game than they would be in reality, so the notion of pike and shot charging cavalry in the rear owes much to a miscomprehension of the reality the cavalry combat is representing.
In your mod you can easily change the rules so that they can charge. You need to mod the ChargePermitted() function in CombatTools.BSF. For example, the additional code in red will allow Warriors to charge cavalry.
// Returns 1 if unit would be permitted to charge enemy (NOT taking into account morale, charge target priority or move distance), otherwise 0.
FUNCTION ChargePermitted(me, enemy)
{
int ret;
ret = 1;
// These types can never charge
if ((IsArtillery(me) == 1) || (IsUnitSquadType(me,"Battle_Wagons") == 1) || (IsUnitSquadType(me,"Train") == 1) || (IsUnitSquadType(me,"Boat") == 1)) // Amphibious left out as probably don't exist
{
ret = 0;
}
// Foot (other than keils) cannot charge mounted (other than light troops)
if ((IsFoot(me) == 1) && (IsMounted(enemy) == 1))
{
if ((PercentKeil(me) == 0) && (IsLightTroops(enemy) == 0)
&& (IsUnitSquadType(me, "Warriors") == 0))
{
ret = 0;
}
}
if ((IsLightTroops(enemy) == 0) && (IsArtillery(enemy) == 0) && (IsOpen(GetUnitX(enemy), GetUnitY(enemy)) == 1))
{
// Light foot and commanded shot cannot charge unbroken non-artillery non-light troops in open
if ((IsUnitSquadType(me, "Light_Foot") == 1) || (IsUnitSquadType(me, "Commanded_Shot") == 1))
{
if (GetAttrib(enemy, "MoraleState") < 3)
{
ret = 0;
}
}
// Dragoons cannot charge unfragmented non-artillery non-light troops in open
if (IsUnitSquadType(me, "Dragoons") == 1)
{
if (GetAttrib(enemy, "MoraleState") < 2)
{
ret = 0;
}
}
}
return ret;
}
Formatted version:
Code: Select all
// Returns 1 if unit would be permitted to charge enemy (NOT taking into account morale, charge target priority or move distance), otherwise 0.
FUNCTION ChargePermitted(me, enemy)
{
int ret;
ret = 1;
// These types can never charge
if ((IsArtillery(me) == 1) || (IsUnitSquadType(me,"Battle_Wagons") == 1) || (IsUnitSquadType(me,"Train") == 1) || (IsUnitSquadType(me,"Boat") == 1)) // Amphibious left out as probably don't exist
{
ret = 0;
}
// Foot (other than keils) cannot charge mounted (other than light troops)
if ((IsFoot(me) == 1) && (IsMounted(enemy) == 1))
{
if ((PercentKeil(me) == 0) && (IsLightTroops(enemy) == 0) && (IsUnitSquadType(me, "Warriors") == 0))
{
ret = 0;
}
}
if ((IsLightTroops(enemy) == 0) && (IsArtillery(enemy) == 0) && (IsOpen(GetUnitX(enemy), GetUnitY(enemy)) == 1))
{
// Light foot and commanded shot cannot charge unbroken non-artillery non-light troops in open
if ((IsUnitSquadType(me, "Light_Foot") == 1) || (IsUnitSquadType(me, "Commanded_Shot") == 1))
{
if (GetAttrib(enemy, "MoraleState") < 3)
{
ret = 0;
}
}
// Dragoons cannot charge unfragmented non-artillery non-light troops in open
if (IsUnitSquadType(me, "Dragoons") == 1)
{
if (GetAttrib(enemy, "MoraleState") < 2)
{
ret = 0;
}
}
}
return ret;
}