Jump to content
Sign in to follow this  
IndeedPete

Chopper Support Script

Recommended Posts

Hi,

i've just made a little Script to call in a Chopper wich attacks enemies in a certain area and then flys back to base to refuel and rearm. It's not really balanced yet, but it works so far. It's written in SQS (i know, old language, but i'm too lazy to learn SQF :rolleyes: ) and you're free to use/change/improve it ( or convert into SQF ;) ). I don't know if someone else already wrote such a script, but anyways, here's mine. :D

How to get it work:

1) Place a Helicopter of your side anywhere on the map and call it e.g. "Heli". Put in it's "init" line:

[this] exec "refuel.sqs"; support=true;

2) Place a trigger which is activated by "Radio Whatever" on the map, put in it's "condition" field:

support

and on activation:

[heli] exec "support.sqs"

.

3) Place an "invisible H" called "Base" on the map.

4) Place an "invisible H" called "Target" and a marker called "Marker" anywhere on the map.

5) Create the script "refuel.sqs":

_chopper = _this select 0

#Check
?!(alive _chopper):goto "End"
?fuel _chopper < 0.2: _chopper setfuel 1
~10
goto "Check"

#End
exit

6) Create the script "support.sqs":

; Define
_chopper = _this select 0
setfire = true;
hint "Click on the map to choose your target!"
onMapSingleClick "Target setPos _pos; setfire=false";
@!setfire;
"Marker" setmarkerpos getPos Target;
onMapSingleClick "";
support = false
_x = getPos Target select 0
_y = getPos Target select 1
_z = getPos Target select 2 
_z = _z + 100
_counter = 0

; Fly/Attack
titletext ["Roger, i'm on my way.","plain down"]
_chopper FlyInHeight 100
_chopper doMove [_x,_y,_z]
_chopper setBehaviour "Combat"

#Check1
?!(alive _chopper):goto "End2"
? _chopper distance Target <= 150:goto "Cycle"
~10
goto "Check1"

#Cycle
_chopper doMove [_x+((random 500)-random 250),_y+((random 500)-random 250),_z]
?!(alive _chopper):goto "End2"
~random 5

?!(alive _chopper):goto "End2"
_counter = _counter + 1
? _counter >= 40:goto "BRB"
?!(someAmmo _chopper):goto "BRB"
goto "Cycle"

; Back To Base
#BRB
?!(alive _chopper):goto "End2"
titletext ["I need to rearm and refuel, brb!","plain down"]
Target setPos [0,0,0]
"Marker" setmarkerpos getPos Target
_chopper doMove getPos Base
_chopper setBehaviour "Aware"

#Check2
?!(alive _chopper):goto "End2"
? _chopper distance Base <= 150:goto "Rearm"
~10
goto "Check2"

#Rearm
_chopper setDamage 0
_chopper setVehicleAmmo 1
_chopper setFuel 1

; Happy End :)
#End1
~Random 20
support = true
titletext ["Back in business, give us a target!","plain down"]
exit

; Bad End 
#End2
hint "The chopper is down!"
Target setPos [0,0,0]
"Marker" setmarkerpos getPos Target
exit

7) Enjoy... ;)

Any ideas to improve this small script will be appreciated!

Here you can find an example mission.

Regards

IndeedPete

P.S. I hope it works proper...

Edited by IndeedPete

Share this post


Link to post
Share on other sites

Thankyou very much indeedpete, I will try to work this into some missions in the near future :)

Seems to work well

Share this post


Link to post
Share on other sites

Would it be possible to create a Demo Mission for us? Always good to have an example made by the expert. :)

---------- Post added at 06:21 AM ---------- Previous post was at 06:20 AM ----------

Thanks for the Script, very good to have. :)

Share this post


Link to post
Share on other sites

Uh, there's a small demo mission - link.

Ant thanks for the thanks. ;) By the way, i'm not an expert, i'm just trying to learn scripting and sometimes, something useful comes up.^^

Edited by IndeedPete

Share this post


Link to post
Share on other sites

In the mission editor or hosting on own PC the Chopper script works well. I have made a map with it on. However when it is hosted on our dedi server it doesn't work. If you click the radio twice the game crashes (server still runs however) http://www.armaholic.com/page.php?id=7403 you can get the map there, any fix to get it playing on MP dedi would be cool and apols as I never mentioned you in the credits :-( when / if I get it fixed I will add your name to it :-) I have found this issue of things not working on dedi for a lot of things

Share this post


Link to post
Share on other sites

Ah ok. I can take a look on it but maybe you want to use this instead, it's much more professional than my script is. ;)

Share this post


Link to post
Share on other sites

There are issues with Radio Triggers with anything but 'this' as their conditions. You should move the support == true into the script itself rather than controlling it form the Radio trigger. That's why it's crashing I bet.

As far as working on a dedicated server, all the movement logic needs to be run by the server, so check for that before running the script on all clients.

Share this post


Link to post
Share on other sites

Yes, i think that is the problem. When i wrote it i had no idea of multiplayer editing or dedicated servers.:rolleyes:

Share this post


Link to post
Share on other sites

hi there when i put the support script in it says missing ; or something??

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  

×