Jump to content
Sign in to follow this  
Kyeburger

Safe Zone Scripting Help

Recommended Posts

At the beginning of my mission i wanted my squad to spawn in a drop pod from The Eridanus Insurrection mod but the AI aren't able to do the action which sets off a script which lets you survive the landing. So anyway i wanted my squad to land without dying and then be able to continue the mission with them being able to die. I am not very good with scripting could someone please give me some sort of script that works for this? Any help is greatly appreciated.

Share this post


Link to post
Share on other sites

A way to create a 100% customizable safe zone is to create a trigger where every unit entering the triggerArea gets allowDamage false and every unit leaving that area gets allowDamage true. Here how it goes:

[color=#FF8040]fnc_triggerUnitsChanged [color=#8B3E2F][b]=[/b][/color]
[color=#8B3E2F][b]{[/b][/color]
   [color=#1874CD]_thisList[/color]        [color=#8B3E2F][b]=[/b][/color] [color=#000000]_this[/color] [color=#191970][b]select[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b];[/b][/color]
   [color=#1874CD]_thisListPrev[/color]    [color=#8B3E2F][b]=[/b][/color] [color=#000000]_this[/color] [color=#191970][b]select[/b][/color] [color=#FF0000]1[/color][color=#8B3E2F][b];[/b][/color]

   [color=#8B3E2F][b]{[/b][/color]
       [color=#006400][i]//for each entering unit[/i][/color]
       [color=#000000]_x[/color] [color=#191970][b]allowDamage[/b][/color] [color=#000000]false[/color][color=#8B3E2F][b];[/b][/color]
   [color=#8B3E2F][b]}[/b][/color] [color=#191970][b]forEach[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#1874CD]_thisList[/color] [color=#8B3E2F][b]-[/b][/color] [color=#1874CD]_thisListPrev[/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b];[/b][/color]

   [color=#8B3E2F][b]{[/b][/color]
       [color=#006400][i]//for each leaving unit[/i][/color]
       [color=#000000]_x[/color] [color=#191970][b]allowDamage[/b][/color] [color=#000000]true[/color][color=#8B3E2F][b];[/b][/color]
   [color=#8B3E2F][b]}[/b][/color] [color=#191970][b]forEach[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#1874CD]_thisListPrev[/color] [color=#8B3E2F][b]-[/b][/color] [color=#1874CD]_thisList[/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b];[/b][/color]
[color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color]

[color=#1874CD]_trigger[/color] [color=#8B3E2F][b]=[/b][/color] [color=#191970][b]createTrigger[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"EmptyDetector"[/color][color=#8B3E2F][b],[/b][/color] [color=#191970][b]getPosATL[/b][/color] [color=#000000]player[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color]
[color=#1874CD]_trigger[/color] [color=#191970][b]setTriggerArea[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#FF0000]10[/color][color=#8B3E2F][b],[/b][/color] [color=#FF0000]10[/color][color=#8B3E2F][b],[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b],[/b][/color] [color=#000000]false[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color]
[color=#1874CD]_trigger[/color] [color=#191970][b]setTriggerActivation[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"ANY"[/color][color=#8B3E2F][b],[/b][/color] [color=#7A7A7A]"PRESENT"[/color][color=#8B3E2F][b],[/b][/color] [color=#000000]true[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color]
[color=#1874CD]_trigger[/color] [color=#191970][b]setVariable[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"toggle"[/color][color=#8B3E2F][b],[/b][/color] [color=#000000]false[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color]
[color=#1874CD]_trigger[/color] [color=#191970][b]setTriggerStatements[/b][/color]
[color=#8B3E2F][b][[/b][/color]
   [color=#7A7A7A]"
       isServer
       &&
       {
           comment 'if thisList changed compared to previous check, do stuff';
           if !(thisList isEqualTo (thisTrigger getVariable ['thisList', []])) then
           {
               comment 'set list of last check to thisListPrev and thisList to current list';
               thisTrigger setVariable ['thisListPrev', +(thisTrigger getVariable ['thisList', []])];
               thisTrigger setVariable ['thisList', +thisList];

               comment 'toggle variable state';
               thisTrigger setVariable ['toggle', !(thisTrigger getVariable 'toggle')];
           };
           thisTrigger getVariable 'toggle'
       }
   "[/color][color=#8B3E2F][b],[/b][/color]
   [color=#7A7A7A]"
       [thisList, thisTrigger getVariable 'thisListPrev'] call fnc_triggerUnitsChanged;
       systemChat 'toggle activation';
   "[/color][color=#8B3E2F][b],[/b][/color]
   [color=#7A7A7A]"
       [thisTrigger getVariable 'thisList', thisTrigger getVariable 'thisListPrev'] call fnc_triggerUnitsChanged;
       systemChat 'toggle deactivation';
   "[/color]
[color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color][/color]

(I should create an own thread for that trigger by now...)

---------- Post added at 22:08 ---------- Previous post was at 21:59 ----------

Hereby done:

http://forums.bistudio.com/showthread.php?189948-Handle-units-entering-and-leaving-an-area

Edited by Heeeere's Johnny!

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  

×