Page 1 of 1
Units in combat modification (shot at)
Posted: Sat Feb 04, 2023 1:19 pm
by lurumagno
Gretings,
I would like to know what I have to change so that units that are in close combat can be shot by missile units.
I have tried to edit the "shooting" file in the lines:
"// Can't shoot if in Close Combat or Pursuing.
if ((IsInCloseCombat(me) == 0) && (MightPursue(me) == 0))"
but no luck.
thanks for advance,
Re: Units in combat modification (shot at)
Posted: Sat Feb 04, 2023 5:48 pm
by Femto
I happen to have made a modding to such effect. The lines between 255 and 322 says:
// Can't shoot at friends
if ((GetUnitSide(me) != GetUnitSide(unit)))
{
// Can't shoot if in Close Combat or Pursuing.
if ((IsInCloseCombat(me) == 0) && (MightPursue(me) == 0))
{
// instead of hiding, only disable button if we got this far. SetShootingString() should give explanatory messages for all cases where ret = -1
ret = -1 ;
distance = GetDistanceBetween(me, unit);
if (distance <= maxRange)
{
// Check whether unit has terrain LOS to target. Need to do this before next test or shooting tooltip will be wrong for artillery that have already shot.
terrainLOSClear = GetUnitLOSToUnit(me, unit);
if((IsArtillery(me) == 1) && (GetAttrib(me, "moved") != 0))
{
// Artillery that moved cannot fire
}
else
{
// Check whether units blocking LOS to target and whether shooter has shots left
unitBlocksLOS = UnitBlockingLOS(me, unit);
if (((terrainLOSClear != 0) || (GetAttrib (me, "LOS") >= 2000)) && ((unitBlocksLOS == 0) || (GetAttrib (me, "LOS") >= 2000)) && (shots > 0))
{
// Troops in close combat cannot be shot at
if (IsInCloseCombat(me) == 0)
{
// Pursued routers cannot be shot at
if (IsInCloseCombat(me) == 0)
{
// Check whether in arc of fire
volley = ArcOfFire(me, unit);
if (volley > 0)
{
if ((reaction == 1) && (GetAttrib(me, "ReactionRange") == 0))
{
SetAttrib(me, "ReactionRange", distance);
SetAttrib(me, "ReactionArc", volley);
}
ret = 0;
if ((GetCannotControl(me) == 0) && (GetUnitSide(unit) != GetShowSide()) && (doNotSetIcons == 0))
{
if (volley == 3)
{
SetUnitIconMask(unit, 1 << 22); // Will be full arc icon
SetShootableFlag(unit, 2);
}
else
{
SetUnitIconMask(unit, 1 << 23); // Will be half arc icon
SetShootableFlag(unit, 1);
}
SetIndicatorEnemyFacing(unit, CorrectedFacing(me));
}
}
}
}
}
}
}
}
}
}
Re: Units in combat modification (shot at)
Posted: Sat Feb 04, 2023 8:44 pm
by lurumagno
Seems to work! thanks mate.
Have you noticed if the AI takes advantage of this well?...
Re: Units in combat modification (shot at)
Posted: Sun Feb 05, 2023 7:05 am
by Femto
You are welcome.
As for AI taking advantage of the modding, I cannot remember. Sorry.
Re: Units in combat modification (shot at)
Posted: Sun Feb 05, 2023 10:53 am
by lurumagno
ok... if you can help me with one last thing plz...
If what I want is that the troops do not block the vision of missile units, but do not shoot when they are in combat?
I try to edit it myself, but icons "disappear"...
I'm just looking for a slightly more challenging IA on the battlefield, if you help me I'd be very grateful.
Regards.
Re: Units in combat modification (shot at)
Posted: Sun Feb 05, 2023 12:48 pm
by Femto
So, overhead shooting not in-combat precision shooting, yes?
For that, you have to revert the entry I posted previously and tweak the "FUNCTION CheckRouteForBlockingUnit(me, checkTerrain)" in CombatTools.
In the said entry, you will find two "if (shooter_height > blocker_height)". Replace the second one with "if (blocker_height < 65535)".
It's been years since I tweaked FOG2. Hopefully it still works.

Re: Units in combat modification (shot at)
Posted: Sun Feb 05, 2023 10:05 pm
by lurumagno
Done!
At the moment it works great....
You're still a great moder.
ty!
Re: Units in combat modification (shot at)
Posted: Thu Feb 16, 2023 11:21 am
by Latro
I've made a slight modification so that they can't shoot over troops in combat, by reasoning that that would put their own troops in danger of being hit. Shots from the side or rear are still okay.
if ((blocker_height < 65535) && (IsInCloseCombat(blocker) == 0))
But I think they shouldn't be able to shoot over cavalry.
Any idea what the height difference is between infantry and cavalry?
Also, maybe the effectiveness should be reduced somewhat for overshooting.
Re: Units in combat modification (shot at)
Posted: Fri Feb 17, 2023 6:35 am
by Femto
Latro wrote: ↑Thu Feb 16, 2023 11:21 am
But I think they shouldn't be able to shoot over cavalry.
Any idea what the height difference is between infantry and cavalry?
If I were you, I would try limiting "unitBlocksLOS = UnitBlockingLOS(me, unit);" conditional on the said unit having the attribute "3DViewHeight" over 700.
Re: Units in combat modification (shot at)
Posted: Fri Feb 17, 2023 8:24 am
by Latro
Will try and fiddle with that.
Thanks!