Log in

UnevenRanger #8 [324.6]

324 rounds, 261 wins, 63 losses, 0 draws

Ships

Second Ship V.2

{"name": "Second Ship V.2", "parts": [{"type": "brain","pos": [0,0],"rot": 0,"welds": [9,11,15,16]},{"type": "reinforced_hull","pos": [-2,0],"rot": 0,"welds": [15,22,17]},{"type": "reinforced_hull","pos": [-3,-1],"rot": 0,"welds": [24,12]},{"type": "reinforced_hull","pos": [2,0],"rot": 0,"welds": [16,18,20]},{"type": "reinforced_hull","pos": [3,-1],"rot": 0,"welds": [13,23]},{"name": "left1","type": "thruster","pos": [-4,0],"rot": 2},{"name": "left2","type": "thruster","pos": [-1,-2],"rot": 0,"welds": [21]},{"name": "right1","type": "thruster","pos": [4,0],"rot": 2},{"name": "right2","type": "thruster","pos": [1,-2],"rot": 0},{"name": "gyro","type": "gyroscope","pos": [0,-1],"rot": 0,"welds": [19,21]},{"name": "rocketR","type": "rocket_launcher","pos": [1,1],"rot": 0,"welds": [16]},{"name": "ranger","type": "ranger","pos": [0,1],"rot": 0},{"name": "rocketL2","type": "rocket_launcher","pos": [-3,0],"rot": 0},{"name": "rocketR2","type": "rocket_launcher","pos": [3,0],"rot": 0},{"name": "rocketL","type": "rocket_launcher","pos": [-1,1],"rot": 0,"welds": [15]},{"type": "reinforced_hull","pos": [-1,0],"rot": 0,"welds": [21]},{"type": "reinforced_hull","pos": [1,0],"rot": 0,"welds": [19]},{"name": "rocketL3","type": "rocket_launcher","pos": [-2,1],"rot": 0},{"name": "rocketR3","type": "rocket_launcher","pos": [2,1],"rot": 0},{"type": "reinforced_hull","pos": [1,-1],"rot": 0,"welds": [20,8]},{"type": "reinforced_hull","pos": [2,-1],"rot": 0,"welds": [4]},{"type": "reinforced_hull","pos": [-1,-1],"rot": 0,"welds": [22]},{"type": "reinforced_hull","pos": [-2,-1],"rot": 0,"welds": [2]},{"type": "reinforced_hull","pos": [4,-1],"rot": 0,"welds": [7]},{"type": "reinforced_hull","pos": [-4,-1],"rot": 0,"welds": [5]}]}
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