Units in combat modification (shot at)

Post Reply
lurumagno
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 4
Joined: Fri Oct 08, 2021 9:20 am

Units in combat modification (shot at)

Post 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,
Femto
Lance Corporal - SdKfz 222
Lance Corporal - SdKfz 222
Posts: 25
Joined: Mon Dec 31, 2018 7:59 am

Re: Units in combat modification (shot at)

Post 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));
}
}
}
}
}
}
}
}
}
}
lurumagno
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 4
Joined: Fri Oct 08, 2021 9:20 am

Re: Units in combat modification (shot at)

Post by lurumagno »

Seems to work! thanks mate. :D

Have you noticed if the AI takes advantage of this well?...
Femto
Lance Corporal - SdKfz 222
Lance Corporal - SdKfz 222
Posts: 25
Joined: Mon Dec 31, 2018 7:59 am

Re: Units in combat modification (shot at)

Post by Femto »

You are welcome.

As for AI taking advantage of the modding, I cannot remember. Sorry.
lurumagno
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 4
Joined: Fri Oct 08, 2021 9:20 am

Re: Units in combat modification (shot at)

Post by lurumagno »

ok... if you can help me with one last thing plz... :oops:

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.
Femto
Lance Corporal - SdKfz 222
Lance Corporal - SdKfz 222
Posts: 25
Joined: Mon Dec 31, 2018 7:59 am

Re: Units in combat modification (shot at)

Post 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. :D
lurumagno
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 4
Joined: Fri Oct 08, 2021 9:20 am

Re: Units in combat modification (shot at)

Post by lurumagno »

Done!

At the moment it works great....

You're still a great moder. :)

ty!
Latro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 328
Joined: Wed Dec 19, 2012 4:05 pm

Re: Units in combat modification (shot at)

Post 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.
Femto
Lance Corporal - SdKfz 222
Lance Corporal - SdKfz 222
Posts: 25
Joined: Mon Dec 31, 2018 7:59 am

Re: Units in combat modification (shot at)

Post 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.
Latro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 328
Joined: Wed Dec 19, 2012 4:05 pm

Re: Units in combat modification (shot at)

Post by Latro »

Will try and fiddle with that.
Thanks!
Post Reply

Return to “Field of Glory II: Modding”