I'm looking to set up a mission that mimics what happened in Black Hawk Down/Mogadishu. However, I'm having a problem with figuring out how to set up the helicop ter crash. I have tried the ideas posted here (http://forums.bistudio.com/showthread.php?117064-Looking-for-Helicopter-crash-script), but none of them really worked for me. I want to set it up so that I can set a trigger on the crash site that once activated, completes the task of finding the crash site. I also want to have one location that I can set for the AI to attack.
If you don't feel like going through the motions of creating a script you can:
First: place a trigger in the corner of the map and name it 'crashTrig', give that trigger the parameters you want e.g. 'Condition: player in thisList - Activation: Blufor\Opfor etc.' - (This is for the find Helicopter task)
Second: Make a trigger set the A/B axis to '0' and make the condition '!alive *<heloName>' - (This is for the enemy attack position and getting the trigger to the helicopter)
Third: In the onActivation of the Second trigger put: *<name of enemy squad> doMove getPos <heloName>; crashTrig attachTo ["<heloName>",0,0,0]; (This will get your other trigger for finding the Helo attached to the crashed helo and get the enemy forces to move to the crashed Helicopter).
Edit: to name enemy squads just go into the init of the squad leader and put: *enmyGrp = group this;
#Rabid Squirell :
If you don't feel like going through the motions of creating a script you can:
First: place a trigger in the corner of the map and name it 'crashTrig', give that trigger the parameters you want e.g. 'Condition: player in thisList - Activation: Blufor\Opfor etc.' - (This is for the find Helicopter task)
Second: Make a trigger set the A/B axis to '0' and make the condition '!alive *<heloName>' - (This is for the enemy attack position and getting the trigger to the helicopter)
Third: In the onActivation of the Second trigger put: *<name of enemy squad> doMove getPos <heloName>; crashTrig attachTo ["<heloName>",0,0,0]; (This will get your other trigger for finding the Helo attached to the crashed helo and get the enemy forces to move to the crashed Helicopter).
Edit: to name enemy squads just go into the init of the squad leader and put: *enmyGrp = group this;
*Put any name you want here
Ok I think I can do that. I'll post on here later and see if/how it works for me.
Thanks!
Added later:
#Rabid Squirell :
If you don't feel like going through the motions of creating a script you can:
First: place a trigger in the corner of the map and name it 'crashTrig', give that trigger the parameters you want e.g. 'Condition: player in thisList - Activation: Blufor\Opfor etc.' - (This is for the find Helicopter task)
Second: Make a trigger set the A/B axis to '0' and make the condition '!alive *<heloName>' - (This is for the enemy attack position and getting the trigger to the helicopter)
Third: In the onActivation of the Second trigger put: *<name of enemy squad> doMove getPos <heloName>; crashTrig attachTo ["<heloName>",0,0,0]; (This will get your other trigger for finding the Helo attached to the crashed helo and get the enemy forces to move to the crashed Helicopter).
Edit: to name enemy squads just go into the init of the squad leader and put: *enmyGrp = group this;
*Put any name you want here
Ok I think I can do that. I'll post on here later and see if/how it works for me.
Thanks!
Added 1 hour 35 minutes later:
Also, I didn't quite understand the first step. Could you explain that again?
This post was edited by Anaximandross (2015-03-31 18:34, ago)
Rabid Squirell said you can place your first trigger where you want - in a corner of the map - because this trigger is finally attached to helo in the 3rd step. But you have to decide what you want to do with it: which conditions want you triggering the task?
For your objective, you have 2 options:
- let the helo crash in a "random" position (after a setHitPointDamage for instance) and follow this solution to attach the trigger to the helo,
- or decide for (a) definite crash site(s) and you can simplify all of this. Just place the trigger(s) on it(them).
pro/cons solutions:
Crashing a helo with Vrotor damage is more realistic but a little bit more difficult.
That means you can script with setHitPointDamage, SurfaceIsWater test to avoid a crash at sea, waituntil conditions, spread crew in vicinity of the crash, create/attach crash site trigger as Rabid Squirell said.
On the other hand, you can manage a "fake crash" out of sight of players, mount your scenery with a helo explosion (setdamage 1), spawn or setpos each crew member where you want. Place simple trigger.
An alternate solution is to define 3 or 4 crash sites, and randomize the site. It's a mix of these above.
Btw, what solution you choose, you can also simply add a marker area on the map:
For example, the center of marker is in a 50 m radius of the true position of helo. More if you want.
_approx_pos = [(getPosATL <heloName> select 0) + random 50, (getPosATL <heloName> select 1) + random 50,0 ];
marker_crash = createMarker ["Ghost_Crashed", _approx_pos];
marker_crash setMarkerShape "ELLIPSE";
marker_crash setMarkerSize [70, 70]; // 70 m of radius (more than randomized radius to be sure helo is inside)
marker_crash setMarkerColor "ColorBlue";
marker_crash setMarkerBrush "FDiagonal" ;
marker_crash setMarkerText "Approx. Ghost crash position";
and addwaypoint to getmarkerpos for your different units:
_wp = (group player) addWaypoint [getmarkerpos "Ghost_crashed", 0];
_wpt_opfor = (group _bad_units) addwaypoint [getmarkerpos "Ghost_crashed", 20]; // optional: 20 for radius of opfor destination
PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS
Actually Pierre, that's exactly what I'm doing (with adding the the marker to the crash site). The only problem I'm having is that I can't figure out how to set the marker as the task destination, but it looks like you included that. I have this frankenstein of a mission, but its awesome! This is the first time I've messed around with any coding, but its a lot of fun!
Thanks!
Also, do I just add the code that you posted above to a trigger?
Oh and another, what is the code to set the countermeasure level? I want to make sure that the heli gets shot down, as I'm using a UH-60, and its seemingly impossible to shoot down on one try
Added 3 hours 23 minutes later:
Also, Pierre, would you mind retyping your sequence in global commands instead of local? I keep getting various errors regarding that, and this will be for a multiplayer mission
This post was edited by Anaximandross (2015-03-31 23:30, ago)
wow! countermeasure!
I guess your helo is flying to a waypoint. If you script, tell me, if not in your editor :
- Set your helo skill to 0 (editor) and waypoint behavior to "safe", (speed "limited" is better)
- Place an AA specialist Opfor with: this allowfleeing 0; in his init field. (You can add also this allowdamage false if you're afraid this unit could die before shooting at helo but you'll have to allowdamage true on a second time).
- Set this AA unit skill to max. Be sure AA is in sight of helo. Normally it's sufficient to make the AA unit shooting at helo.
Problem could be AA fires too soon. (but you must keep a good distance for firing a missile. If not your AA unit will fire with his riffle).
To prevent this case, add in init field of the unit this setcombatmode "blue"; but also add a trigger grouped to your helo (trigger will act when this vehicle enter the trigger zone)
- in on act field of the trigger :
manpad setCombatMode "red"; // at this step, you need to give name to helo (helo) and AA unit (manpad).
Shooting just one missile :
add in init field of the AA specialist: removebackpack this; without backpack the unit is unable to reload. The other solution is to leave just one magazine "Titan_AA" for the unit (not so simple).
Optional: scene for a vertical rotor hit and an emergency landing/crash:
You don't want the helo takes damage too fast, too heavy:
You need to detect the AA fire. The best way is what is called an Event handler;
Your trigger now will looks like (copy/paste, and change names helo & manpad if you want):
manpad setCombatMode "red"; helo addEventHandler ["Hit", {if (manpad == _this select 1) then {helo setDamage 0; helo setHitPointDamage ["HitVRotor", 1]; helo setfuel 0.001; for "_i" from 0 to 4 do {_flare = "Smokeshell" createVehicle position helo; _flare attachTo [helo,[0,-6,1]]}; helo allowDamage false}}];
Name this trigger Trig1 for example (it will be checked by a second one).
That's it. You have a more realistic crash. Your helo will go to the ground without exploding (helo allowdamage false)
- Add your second trigger, trig2, where you want because only the conditions are important:
In condition field:
((getposatl helo select 2) < 3) && speed helo <2 && triggerActivated trig1
Set trigger timer to countdown min mid max to 5 (seconds) This help crew to disembark.
Variables are global. Marker will be visible on each player's map. crash site is approximative. You can enlarge it as you need (random 100, random 200...)
helo allowdamage true for re-enabling helo destruction
Hope this help.
This post was edited by Pierre MGI (2015-04-01 08:19, ago)
PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS
Ok cool. So what I eventually did was I added in an event handler so that when a missile is shot at the heli, it just blows up. This circumvented the issue with the CMs. Then< i use the getPos code to find the position of the heli, and send the attacking units there. I have a massive Frankenstein of different ideas, but it works! Thanks for the help
I updated the trig2 (see above) for better event in mountainous site
and for moving bad guys on site crash, it's better to add a 3rd trigger: trig3
condition: triggerActivated trig2 with a countdown set to 3 sec for example,
then on act:
opfor_group setCombatMode "red"; wpt_red = opfor_group addWaypoint [getPosATL helo,30]; wpt_red setWaypointType "SAD"; wpt_red setWaypointSpeed "full";
PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS
It's absolutely huge!
Scripts running by triggers have to struggle with Arma's engine scheduler (to make it short).
Yours probably never ends.
If you're sure with your groups (no error hanging the process):
You should change also the waypoint name wpt_red1, wpt_red2?.. for each group.
and
edit / split into other triggers (activated by each other with a small countdown) and put the code for other 2 or 3 groups.
Start with 3 groups, test, add more, (cry for your playability)
PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS
Haha while I was testing it a minute ago I went form 60 FPS down to about 15-25. So I should start by splitting that code across three different triggers?
Added 41 seconds later:
Would it help if I made it into a script? I have no idea how to do that, but I probably could (with a lot of guidance)
It would help if you spawn units as long as they dies. And yes, you can run a script with a on act. trigger:
Just put in on act: 0= [] execVm "my_script.sqf"
0 is a handle you don't need to care. [] is empty array parameter but you could use to introduce variables in the script.
execVm means you're writing an sqf (not old sqs) and you "spawn" it. That means this script will run in parallel with others. It's the best thing to do with heavy scenarios.
So, you need to write & add your my_file.sqf in the mission folder (where the mission.sqm is) (or precise path but that doesn't improve anything).
In you sqf file, you can write the same things than in a on act.trigger, and more... Because, you're now in a scheduled script, you can use the waitUntil conditions for example.
First, when you manage triggers in editor and variables in scripts, choose global variables (available for all scripts/triggers/anything) during your mission. A simple rule is: use local variables (beginning with underscore like _my_unit) only in a same script (for a current task with no idea to throw it into another script).
Second, when you write a condition in a trigger. For example !alive JohnDoe && triggerActivated first_trig;
you create an implicit loop checking for this occurrence twice per second. Sometime it's sufficient and it's save FPS, sometime it's far too slow and you can miss a firing of trigger due to other script load. In an sqf, you must write your loop to check an event.
Little script to spawn an opfor group in your map and move it to crash site:
- place 4 (empty or else) markers on map.
- name them spwnred1... spwnred4 (or change names both on map & following script)
- choose a definite number of spawning teams (10 in this script) or infinite loop with while {true} instead of while {_counter < 10}
- in this script, you spawn a 8 man team each time enemies are less than 4 in 1200 m radius of helo's position. Feel free to add more teams at the same time (copy/paste) and/or spawn them earlier, changing the remaining alive opfor units.
- i randomized some of kinds for my red units. You can simplify. see https://community.bistudio.com/wiki/BIS_fnc_spawnGroup
Well, I thought I was ready to try to create a script. HOwever, I now know I'm not. That is way over my head. But thats ok
Thanks anyway!
Added 1 hour 5 minutes later:
Well, I seem to have a wall. I have finally gotten the helicopter to get shot down, and it spawns a marker on top of the crash site. However, now I'm having a problem with getting enough AI units to move to the crash site. I have met limited success by using opfor_group doMove (getMarkerPos "Blackhawk_Crashed"), but it will only work for one unit at a time. Not the entire faction. Any ideas?
Added later:
Well, I seem to have a wall. I have finally gotten the helicopter to get shot down, and it spawns a marker on top of the crash site. However, now I'm having a problem with getting enough AI units to move to the crash site. I have met limited success by using opfor_group doMove (getMarkerPos "Blackhawk_Crashed"), but it will only work for one unit at a time. Not the entire faction. Any ideas?
This post was edited by Anaximandross (2015-04-02 18:58, ago)
Sorry to check this point :What is your opfor_group ?
If you write this in a unit name field, you just create a variable for this unit, even if it's the leader of the group. To create a variable for a group, write in the init (not name) field of the leader:
opfor_group = group this
So, all grouped units will move each time you order something to this group, even if leader dies after that.
If this step is OK, you can't use doMove with a group name. BI functions are precise and you must have a look each time you want to script. There are so much differences with the move , doMove, addWaypoint....
doMove is waiting for a unit or an array of units. So, for a group you must write:
units opfor_group doMove ....
If you don't want to cope with your tons of groups just write:
{ if (side _x == east) then {units _x doMove (getMarkerPos "Blackhawk_Crashed")}} forEach allGroups;
Be sure all red groups (all red units in fact because a unit is also a group) present on map will move to your position.
If you want to restrict at some locla units, add a radius condition:
{ if (side _x == east && (leader _x distance ((getMarkerPos "Blackhawk_Crashed") < 600) then {units _x doMove (getMarkerPos "Blackhawk_Crashed")}} forEach allGroups; // limited up to 600 m
PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS
Wow ok. I completely messed up on that, and I imagine that's what the problem is. That explains why that was happening the way it was. I am going to try to mess around with the all units command instead. i feel like that'll be easier