360 deg arc of fire and charging

Moderators: rbodleyscott, Slitherine Core, Gothic Labs

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

360 deg arc of fire and charging

Post by companion » Wed Jun 16, 2021 7:42 pm

I made a simple copy-paste adjustment to the ArcOfFireToTile Function
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) ;
	//AddTileTooltip() ;
	// END DEBUG

	if (IsUnitSquadType(me, "Ship") == 0)
		{
			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");
//      AddTileTooltip() ;
//    }

	return volley;
}
This made the early tercios able to fire in full 360 degree angle at half shot strength while still allowing full strength shooting in the front arc. This is what I intended.

However, this also made the early tercios able to charge in any direction of full 360 deg circle if the target is in an adjacent tile. This is NOT what I intended.

How do I fix the charging ability back to normal while retaining the 360 deg shooting angle?

Post Reply

Return to “Modders Corner”