UnevenRanger #8 [324.6]
324 rounds, 261 wins, 63 losses, 0 draws
Ships
Second Ship V.2
local turnLeft = false
function Update()
-- Store our angular velocity in a variable to make it easier to use
local angVel = gyro:AngVel()
--If we see an enemy ship
if ranger:IsAlly() == false then
if ranger:Range() > 0 then
-- We see another ship, stop spinning, start ramming,
-- and remember which way to turn if we lose it again
-- Use the standard thrusters to cancel out our angular velocity
--side1:SetThrust(-angVel)
--side2:SetThrust(angVel)
left1:SetThrust(angVel)
left2:SetThrust(angVel)
right1:SetThrust(angVel)
right2:SetThrust(angVel)
-- Fire the Rockets
rocketL:Fire()
rocketR:Fire()
rocketL2:Fire()
rocketR2:Fire()
rocketL3:Fire()
rocketR3:Fire()
-- Fire the Lasers
laserL:Fire()
laserR:Fire()
-- Ignite the ramming thruster
--ramThrustL:Ignite()
--ramThrustR:Ignite()
--Figure out which way to turn if we lose the ship again
if angVel > 0 then
-- We were spinning left when we saw this target,
-- so we should turn right if we lose it.
turnLeft = false
else
-- We were spinning right when we saw this target,
-- so we should turn left if we lose it.
turnLeft = true
end
else
-- We don't see another ship, spin around to find one
-- Figure out which way to turn
local desiredAngVel = turnLeft and 45 or -45
-- Use the standard thrusters to spin the ship at the desired angular speed.
--side1:SetThrust(desiredAngVel - angVel)
--side2:SetThrust(desiredAngVel - angVel)
right1:SetThrust(angVel - desiredAngVel)
left2:SetThrust(angVel - desiredAngVel)
left1:SetThrust(desiredAngVel - angVel)
right2:SetThrust(desiredAngVel - angVel)
end
end
end