'' AttackDrone2_AI '' '' AD-2 FUNCTION AttackDrone2_DrawShip ( BYVAL ShipData AS DrawShipData ) AS INTEGER static r as double = 0 dim as double c, s with ShipData '' Draw the body circle (.PosX, .PosY ), 5, .Colour-8 circle (.PosX, .PosY ), 4, .Colour '' Draw the cannon c = cos( .Angle * DEG_TO_RAD) s = sin( .Angle * DEG_TO_RAD) Pset (.PosX + c * 4, .PosY + s * 4 ), .Colour Line -(.PosX + c * 8, .PosY + s * 8 ), .Colour '' Draw the animate c = cos( (r - .Angle * .Power * 0.02) * DEG_TO_RAD) s = sin( (r - .Angle * .Power * 0.02) * DEG_TO_RAD) Pset (.PosX - c * 4, .PosY - s * 4 ), .Colour Line -(.PosX + c * 4, .PosY + s * 4 ), .Colour end with '' Update our counter for animation r -= 1 if r < 0 then r = 359 END FUNCTION FUNCTION AttackDrone2_AI ( BYVAL ShipData AS ShipData, _ Flag() AS DOUBLE) AS MessageAI ' Hold the return MessageAI DIM AS MessageAI ReturnAI dim as double relAngle, relDist '' a counter flag(0) -= 1 if flag(0) < 0 then flag(0) = 100 with ShipData relAngle = .Angle + atan2(.PosY - .EnemyY, .EnemyX - .PosX ) * RAD_TO_DEG if relAngle < -180 then relAngle += 360 if relAngle > 180 then relAngle -= 360 relDist = ((.EnemyY - .PosY) * (.EnemyY - .PosY) + (.EnemyX - .PosX) * (.EnemyX - .PosX)) if relangle < -5 then ReturnAI.Message = "Turning" ReturnAI.Action = TURNCW elseif relangle > 5 then ReturnAI.Message = "Turning" ReturnAI.Action = TURNCCW elseif .Power >= 99 then ReturnAI.Message = "Fire!" ReturnAI.Action = SHOOT elseif reldist < 150 then if flag(0) < 20 then ReturnAI.Message = "Backing off" ReturnAI.Action = BACKTHRUST end if elseif reldist > 300 then if flag(0) < 20 then ReturnAI.Message = "Engaging Target" ReturnAI.Action = THRUST end if end if end with RETURN ReturnAI END FUNCTION AI( AI_ID ).Callsign = "AttackDrone2" AI( AI_ID ).Colour = 14 AI( AI_ID ).AI = @AttackDrone2_AI AI( AI_ID ).DrawShip = @AttackDrone2_DrawShip AI( AI_ID ).WeaponName = "Standard Issue LAS-Cannon" AI( AI_ID ).ShipDetails = "AD-2: Slightly faster response than the AD-1 " + "with minimal attack capabilities. " _