## 360 deg arc of fire and charging

Moderators: rbodleyscott, Slitherine Core, Gothic Labs

companion
Corporal - 5 cm Pak 38 Posts: 46
Joined: Fri Jul 08, 2016 2:16 pm

### 360 deg arc of fire and charging

Full function code is this:

Code: Select all

``````FUNCTION ArcOfFireToTile(me, x, y)
{
int angle;
int facing;
int volley;
int new_facing1;
int new_facing2;
int new_angle1;
int new_angle2;

facing = GetUnitFacing(me);

// Get angle
angle = GetAngleFromTile(x, y, me);

// DEBUG
//StartString() ;
//PrintStringLiteral("\nFACING = ");
//PrintInt(facing);
//PrintStringLiteral(", ANGLE = ") ;
//PrintInt(angle) ;
// END DEBUG

{
if (angle > 47)
{
volley = 0;
}

else
{
if (angle < 23)
// The idea is thast you should be able to shoot at full effect against the square 3 squares away and offset one, but not against the squares 1 or 2 squares away and offset one.
{
volley = 3;
}
else
{
// Clunky way to determine whether enemy is to left or right of straight ahead.
new_facing1 = facing + angle;
if (new_facing1 > 359)
{
new_facing1 -= 360;
}

new_facing2 = facing - angle;
if (new_facing2 < 0)
{
new_facing2 += 360;
}

SetUnitFacing(me, new_facing1);
new_angle1 = GetAngleFromTile(x, y, me);
SetUnitFacing(me, new_facing2);
new_angle2 = GetAngleFromTile(x, y, me);
SetUnitFacing(me, facing);

if (new_angle1 < new_angle2)
{
volley = 1;
}
else
{
volley = 2;
}

// Log("Angle, NA1, NA2, volley", angle, new_angle1, new_angle2, volley);
}
}
}
else
{
if ((angle < 42) || (angle > 138))
{
volley = 0;
}
else
{
volley = 3;
}
}

if (GetAttrib (me, "EarlyTercio") == 1)
{
if (angle < 23)
// The idea is thast you should be able to shoot at full effect against the square 3 squares away and offset one, but not against the squares 1 or 2 squares away and offset one.
{
volley = 3;
}
else
{
// Clunky way to determine whether enemy is to left or right of straight ahead.
new_facing1 = facing + angle;
if (new_facing1 > 359)
{
new_facing1 -= 360;
}

new_facing2 = facing - angle;
if (new_facing2 < 0)
{
new_facing2 += 360;
}

SetUnitFacing(me, new_facing1);
new_angle1 = GetAngleFromTile(x, y, me);
SetUnitFacing(me, new_facing2);
new_angle2 = GetAngleFromTile(x, y, me);
SetUnitFacing(me, facing);

if (new_angle1 < new_angle2)
{
volley = 1;
}
else
{
volley = 2;
}
}
}

//  if (volley == 0) // If not wanted on main tooltip, should be if ((volley == 0) && (UseAdvancedTT() == 1))
//    {
//      StartString() ;
//      PrintString("IDS_OUTOFARC");
//      PrintStringLiteral("\n");