OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Resources Beta Testing & Submission => Topic started by: Mr.Peanut on 01 Jul 2008, 16:37:20

Title: HCA - Helicopter Collision Avoidance - ArmA Version (ACCEPTED)
Post by: Mr.Peanut on 01 Jul 2008, 16:37:20
If you have ever made a mission with more than one AI helicopter, you are well aware of how skilled the AI are at flying into one another. Here is a solution.

HCA - Helicopter Collision Avoidance
ArmA Version
by Mr.Peanut
Version 1.1 : July 1, 2008
Formerly called HeliCAS, before I knew CAS meant Close Air Support.

DESCRIPTION:
This script works by predicting each helicopter's position _dt seconds from present.  If any of the helicopters are
closer to each other than distance _dist they are nudged apart from each other with a speed based on the value
of _spd. The _delay variable is the loop delay between collision checks.  There is a degree of randomness involved.
The helicopters will not always successfully avoid collision. In the demo provided there are eight AI helicopters,
one of which will crash about 50% of the time in the first thirty seconds.

MP USAGE:
HCA will work in multiplayer if is run with the same arguments on all nodes i.e. server and clients.
It will also work with helicopters piloted by players, and AI helicopters under player command.
There are limitations. Two helicopters approaching collision at high speed might crash. A player trying very hard
to crash his helicopter into another will eventually succeed.

I would be greatful if someone would test the demo mission on a dedicated server. I don't have the horsepower to do so myself.

http://ca.youtube.com/watch?v=Eexpx1BvRMs (http://ca.youtube.com/watch?v=Eexpx1BvRMs)
Here is the embed object info for the youtube link. I don't have a clue what to do with it.
Code: [Select]
<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/Eexpx1BvRMs"></param><embed src="http://www.youtube.com/v/Eexpx1BvRMs" type="application/x-shockwave-flash" width="425" height="350"></embed></object>

;======================================================================
;
; OFPEC Keywords: helicas,helicopter,helicopters,heli,helis,chopper,choppers,collision,collide,avoid,avoidance,crash
; SMUC Code: M for Multiplayer
; Originally released on www.ofpec.com
;
; Thanks to Mandoble for ArmA conversion advice and prodding me to re-release.
;
;Changelog
;2008/06/10 - Optimised code for sqs syntax. Added prefix tags to all global variables.
;             Tested for MP compatibility including player and player controlled pilots.
;             Functions no longer need to be initialised in init.sqs
;2008/07/01 - ArmA conversion. Tweaked default values for ArmA.

Get HCA v1.1 (http://www.ofpec.com/ed_depot/index.php?action=details&id=557&page=0&cat=xyz)
Title: Re: HCA - Helicopter Collision Avoidance - ArmA Version (READY)
Post by: kju on 06 Jul 2008, 20:14:18
Quite impressive.  :)
Title: Re: HCA - Helicopter Collision Avoidance - ArmA Version (READY)
Post by: Mr.Peanut on 07 Jul 2008, 04:52:10
Thanks. It is funny. The OFP version of this script is several years old, and as far as I know it was only used by a couple people. Hopefully the new ArmA version will find a little more use. It would work with fixed winged aircraft but it would take experimentation with the parameters.
Title: Re: HCA - Helicopter Collision Avoidance - ArmA Version (ACCEPTED)
Post by: loki72 on 08 Jul 2008, 06:08:33
very nice :clap:
Title: Re: HCA - Helicopter Collision Avoidance - ArmA Version (ACCEPTED)
Post by: bedges on 08 Jul 2008, 19:59:07
Might be interesting to see a version without the script in action, y'know, just for comparison...  :whistle:
Title: Re: HCA - Helicopter Collision Avoidance - ArmA Version (ACCEPTED)
Post by: Mr.Peanut on 10 Jul 2008, 16:49:25
I leave that as an exercise for the user. Let them comment out the line in the init.sqf and see what happens.
Title: Re: HCA - Helicopter Collision Avoidance - ArmA Version (ACCEPTED)
Post by: kju on 23 Jul 2011, 18:21:21
Updated this to the latest ArmA version (1.59).

Changes:

Code: [Select]
SMB_HCA_NewHelicopters set [count SMB_HCA_NewHelicopters,_chopper];
Is Mr.Peanut still around?
If so, he may wants to update the readme and make an official release.

Enjoy.  :good:

---

> Standard ArmA Helicopter Collision
http://www.youtube.com/watch?v=bD_LTYEC5tg
vs
> HCA - Helicopter Collision Avoidance
http://www.youtube.com/watch?v=sKShVx4RL9k

---

Edit:

2.1 for a few fixes..  :whistle: