Jump to content
Sign in to follow this  
thermos

Airfield Repair Rearm Refuel Script

Recommended Posts

Hi all, i'm just learning how to do the scripting for ARMA, but I am having a blast. I made this one script that i wanted to share with anyone who wants it. It works really well. The directions to use it and set it up are in the comments of the script.

There is one problem with it that maybe someone can help me with. The truck bumping into the aircraft. While it doesn't affect the functionality of the script its annoying.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;;

;;V1.2

;;

;;Aircraft services script by Thermos (younghay@hotmail.com) for ARMA 6-8-2007

;;Works well for airplanes and choppers.

;;

;;---------------------Setup Trigger-------------------------

;;Create a trigger around 40x40 that triggers when players side present.

;;This will be the service area that the aircraft needs to be in for servicing.

;;Set trigger for repeatedly.

;;Place: this exec "groundcrew.sqs" into the On Act box of the trigger.

;;I like to make the trigger square and CLEARLY MARK the corners of service area with road cones or the like.

;;Make sure this script is located in the directory of the mission and named "groundcrew.sqs".

;;

;;---------------------Setup Players-------------------------

;;Create a 5t truck named repairtruck and an invisible H named truckspot.

;;Place truck and H on top of eachother in an open spot not more than 150 meters but more than 30 meters from the service area trigger.

;;Make sure the path between the service area and the truck and H is clear and an easy drive for the AI.

;;

;;-----------------Realism and Realism Variables-------------------

;;I'm not sure if its realistic to have to turn off the aircraft engine to rearm or refuel. I don't think it is.

;;However I made it where engine must be off to get services cause i'm pretty sure aircraft would have to

;;be off to get most repairs.

;;For those that like to try for more realistic repair, rearm, and refuel times

;;set the following variables to the amount of seconds that you think would be realistic for each operation.

_repairtime = 10

_rearmtime = 10

_refueltime = 10

;;-----------------Multiplayer------------------------

;;Should work in multiplayer but has not been tested AT ALL.

;;The service truck should become locked when player enters trigger area.

;;If another player enters service area, they should get message to exit

;;service area and wait for ready message.

;;One thing that is cool for multiplayer is if repairtruck is destroyed

;;no more repairs-rearming-refueling of aircraft. This gives some strategic

;;relevance to protecting your airfield.

;;

;;---------------Public Variables----------------------

;;Script uses two public variables chump and truckbusy

;;

;;-----------------Known Issues------------------------

;;The repair truck will bop into the aircraft when it approaches. Have not had

;;any real problems with this. It's just a little annoying.

;;Funny things may happen if the pilot gets out of aircraft during the servicing procedure

;;so make sure to taxi the craft out of the service area before parking it and getting out

;;I may have fixed this but havn't tested much.

;;

? truckbusy == 2: goto "truckinuse"

? not alive repairtruck: exit

? vehicle player == player: exit

chump = player

publicVariable "chump"

_parking = truckspot

_truck = repairtruck

_y = 1

_z = 1

truckbusy = 1

publicVariable "truckbusy"

_aircraft = vehicle chump

chump sidechat "Aircraft services required."

~2

? not canMove repairtruck : goto "imdamaged"

repairtruckd sidechat "Roger that."

truckbusy = 2

publicVariable "truckbusy"

~2

goto "youstop"

#youstop

repairtruckd sidechat "Please bring aircraft to a complete stop Sir."

~15

? speed _aircraft < 1: goto "movetruck"

_y = _y + 1

? _y >= 3: goto "stopnot"

goto "youstop"

#movetruck

repairtruckd sidechat "On my way Sir. Please switch off your engines."

_truck doMove getPos _aircraft

@ _truck distance _aircraft < 20

goto "checkengine"

#checkengine

_running = isEngineOn _aircraft

? not _running: goto "allready"

repairtruckd sidechat "Sir, Please switch off your engine."

~10

_z = _z + 1

? _z >= 4: goto "enginenot"

goto "checkengine"

#allready

repairtruckd sidechat "Commencing services. Starting with repairs."

goto "giverepairs"

#giverepairs

? _truck distance _aircraft > 30: goto "toofar"

~_repairtime

_aircraft setDammage 0

repairtruckd sidechat "Aircraft repaired Sir. Loading up your weapons."

_running = isEngineOn _aircraft

? _running: goto "enginenot"

goto "giveweapons"

#giveweapons

~_rearmtime

_aircraft setvehicleammo 1

~2

repairtruckd sidechat "Weapons rearmed Sir. Beginning refueling."

_running = isEngineOn _aircraft

? _running: goto "enginenot"

goto "givefuel"

#givefuel

~_refueltime

_aircraft setfuel 1

~2

repairtruckd sidechat "Tank topped off. Your all set. Please exit service area ASAP. Bring them hell Sir."

goto "sendtruckhome"

#stopnot

repairtruckd sidechat "You are not coming to a stop Sir. Cancelling."

goto "sendtruckhome"

#enginenot

repairtruckd sidechat "You are not turning off the engine Sir. Cancelling."

goto "sendtruckhome"

#toofar

repairtruckd sidechat "You are too far away Sir. Cancelling."

goto "sendtruckhome"

#truckinuse

repairtruckd sidechat "Service truck in use Sir. Please exit service area and wait for ready message."

exit

#sendtruckhome

_truck doMove (getPos _parking)

? _truck distance _parking < 15: goto "makeready"

@ _truck distance _parking < 15

goto "makeready"

#imdamaged

repairtruckd sidechat "My trucks been damaged Sir. I can not comply."

exit

#makeready

truckbusy = 1

publicVariable "truckbusy"

repairtruckd sidechat "Aircraft service truck available again."

exit

Also if someone trys it in multiplayer let me know if anything funny happens as i have not really tested it.

Peace out,

Thermos

made some improvements-

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×