Jump to content
Sign in to follow this  
Holy Smoke

Help creating a script

Recommended Posts

This is for a stealthy infiltration training mission.

The idea is to simulate a MILES system within the possibilities of the engine. No weapons involved, only detection, so it is possible.

So, the idea is player is west and instructor OPFOR are resistance (or east) without carrying any ammo at all. When a unit of one side is detected by a unit of the oposing side, detected unit is marked as hit and eliminated from the exercise. I did this using a trigger tied with the unit:

OPFOR

Condition: Detected by West

On activation: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">h="smokeshellgreen" camCreate (getPos OPFOR1); OPFOR1 disableAI "target"; OPFOR1 disableAI "move"

Trigger must be the size of the exercise area. I'm not sure if disableAI "target" prevents them from detecting more units once hit, but you can deleteVehicle them anyway.

WEST (other units in players group)

Condition: Detected by Resistance

On activation: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">h="smokeshellred" camCreate (getPos w2); w2 disableAI "target"; w2 sidechat "i'm hit"; [w2] join bustdgrp

*bustdgrp is an empty group previously created to detach eliminated units under your command.

create a unit and then on init field <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">bustdgrp = groupThis; deleteVehicle this

In sum, this involves a trigger for every unit performing the exercise, so I'll much appreciate if anyone can figure how to put all of these in a script.

Thanks smile_o.gif

Share this post


Link to post
Share on other sites

It's done by script detect.sqs and function detect.sqf. You need at least OFP v.1.85 because of function. But it can be changed to script easily if you want.

(0.7s is average human react time)

detect.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;array of opfor (resistance?) units: (no limit)

_opfor=(units opfor1)+[opfor13,opfor14]

;array of west units: (max 12 units)

_west=[w1,w2,w3,w4]

#start

~0.35

?count _opfor == 0 :goto "end1"

;west are detected by opfor

_out=[_opfor,_west,true] call loadFile "detect.sqf"

_west=_west-_out

~0.35

?count _west==0:goto "end2"

;opfor are detected by west

_out=[_west,_opfor,false] call loadFile "detect.sqf"

_opfor=_opfor-_out

goto "start"

#end1

hintC "west wins"

exit

#end2

hintC "opfor wins"

exit

detect.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_g1","_g2","_out","_x","_i","_who"];

_g1=_this select 0;

_g2=_this select 1;

_out=[];

{_i=count _g2;

while "_i>0" do {

_i=_i-1;_who=_g2 select _i;

if (_x knowsAbout _who > 3) then {

if (!(_who in _out)) then {_out=_out+[_who]}}

}} forEach _g1;

if (_this select 2) then {{_i="smokeshellred" camCreate (getPos _x);

_x disableAI "target";_x sidechat "i'm hit";

[_x] join bustdgrp} forEach _out}

else {{_i="smokeshellgreen" camCreate (getPos _x);

_x disableAI "target";_x disableAI "move";

} forEach _out};

_out

tested

Share this post


Link to post
Share on other sites

Thanks a lot!

Impressive job m8, I'm afraid you've created the first "MILES system script" around. I'm eager to try it. Again, thanks.

Regards

Share this post


Link to post
Share on other sites

I tested and it works as I expected. Cool!

Besides, using the "knowsAbout" command introduced an "effective range" factor. 3 seems to be a low number for the purpose, since there's no way you can "hit" (or be hit by) units further than 50-75 m, so I set it at 2 (increasing range to 100m) and even 1. Did not test that much using a value of 1, but I recon a knows About factor of 1 means that a unit has just been spoted, and that will be useful if the ROE in the exercise require complete stealth.

Regards

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  

×