Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- StartingCords = {}
- FirstStart = true
- ReAfMiss = false
- Gunship = false
- Transport = false
- GroundAtObj = false
- Package = false
- BombBay = false
- DeployCargo = false
- BombingRun = false
- MissionCompleted = false
- EnableWeapons = false
- function onTick()
- Orders = input.getBool(1)
- if Orders == true then
- GetDetails()
- end
- end
- function GetDetails()
- X1 = input.getNumber(1)
- Y1 = input.getNumber(2)
- X2 = input.getNumber(3)
- Y2 = input.getNumber(4)
- if MissionCompleted == true and ReAfMiss == true then
- X2 = StartingCords[1]
- Y2 = StartingCords[2]
- end
- if FirstStart = true then
- FirstStart = false
- StartingCords = {X1,Y1}
- end
- Package = true
- CHeading = input.getNumber(5)
- Height = input.getNumber(6)
- Ground = input.getBool(2)
- GunshipMission = input.getBool(3)
- GroundAtObj = input.getBool(4)
- Transport = input.getBool(5)
- BombsLoaded = input.getBool(6)
- CargoLoaded = input.getBool(7)
- MissionType = input.getNumber(8) '0-Gunship,1=BombingRun,2-Transport'
- if MissionType == 1 then
- Package = BombsLoaded
- elseif MissionType == 2 then
- Package = CargoLoaded
- end
- Heading = 0
- XD = X1 - X2
- YD = Y1 - Y2
- AXD = math.arct(XD)
- AYD = math.arct(YD)
- Dir = 0
- Move = false
- Land = false
- Dis = 1000
- Q = 1
- if XD > 0 and YD > 0 then
- Q = 1
- else if XD < 0 and YD > 0 then
- Q = 2
- else if XD < 0 and YD < 0 then
- Q = 3
- else if XD > 0 and YD < 0 then
- Q = 4
- end
- Dis = math.sqrt(math.pow(XD,2)+math.pow(YD,2))
- DegAt = (math.atan(AXD/AYD)) * 180/math.pi
- if Q == 1 then
- Heading = DegAt
- elseif Q == 2 then
- Heading = (180 - DegAt)XD - 1
- elseif Q == 3 then
- Heading = 180 + DegAt
- elseif Q == 4 then
- Heading = (360 - DegAt)x - 1
- end
- Heading = Heading - 90
- if Heading < 90 then
- Heading = Heading + 270
- end
- TDegrees = CHeading - Heading
- if TDegrees < 90 then
- TDegrees = TDegrees + 270
- end
- if CHeading - 5 < Heading and CHeading + 5 > Heading then
- Move = true
- else
- Move = false
- end
- if Dis < 6 and GroundAtObj == true and Package == true then
- Land = true
- elseif Package == false then
- Land = false
- end
- if Land == true and Package == true and MissionType == 2 and Height < 5 then
- DeployCargo = true
- elseif Dis < 10 and Height > 10 and Package == true and MissionType == 1 then
- BombBay = true
- end
- if MissionCompleted == false and Dis < 300 then
- EnableWeapons = true
- else
- EnableWeapons = false
- end
- output.setBool(1,Land)
- output.setBool(2,Move)
- output.setBool(3,BombBay)
- output.setBool(4,DeployCargo)
- output.setBool(5,EnableWeapons)
- output.setNumber(3,TDegrees)
- CheckMission()
- end
- function CheckMission()
- if MissionType == 2 and Land == false and Package == false then
- MissionCompleted = true
- elseif MissionType == 1 and Package == false then
- MissionCompleted = true
- end
- if MissionCompleted == true then
- BombBay = false
- DeployCargo = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement