OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: BRAVO-TWO on 18 Jan 2006, 20:20:08
-
hi guys ....
i want a script to activate on any unit within a trigger area...
i think it should be along the lines of ..
[] exec"scriptname"forEach thislist
obviously this isnt the correct code .. can anyone point me in the right direction ...
thanx in advance
shark attack
-
in the trigger on activation field put something like this
trig_units = thislist; [] exec "script_name.sqs"
then in your script use
{do action to _x} foreach trig_units
EDIT - you could also try {_x exec "script_name.sqs"} foreach thislist, but you'd need a _unit = _this in the script...
-
bedges
i tried your suggestion but to no avail..
think something in the script is causing probs
ive modified a fire sqs to work on ai . works fine if called on one unit but having trouble getting it to work on all units within trigger area..
heres the script......
_time = 0
_object = _this select 0
#burn
drop ["cl_fire" , "", "Billboard", random(2) ,random(0.9), [ random(1), random(1), random(1)] , [random(1), random(1), 1] , 0 ,random(0.1)+.1, 0.2 , random(0.2), [random(2),random(2),random(1)] ,[[1,1,1,1],[1,1,1,0]] , - , 0 , 0 ,"" , "" , _object]
drop ["cl_basic", "", "Billboard", 1 ,random(1) , [0,0,0] , [random(1), random(1), random(1)] , 0 ,random(1.0)+1 , 1.5 , random(0.1), [random(1),random(1)+1 ,random(1)+1] ,[[0,0,0,0.25],[0.45,0.45,0.45,0.75]] , - , 0 , 0 ,"" , "" , _object]
;To increase the time the fire lasts for, increase the numerical value in the next line.
?_time >=5000:goto "exit"
_time = _time + 1
goto "burn"
#exit
have been calling the script with
[ter6] exec "aifire.sqs";
can anyone tell me what im doing wrong .... ???
-
_time is a reserved local variable which indicates the number of seconds since the script was run. try using another variable - _t would do. in fact, looking at the script, you don't need to increment _time, it does so automatically.
also, as far as i know, drop commands should never include spaces between commas - there always has to be something between the commas, even if it's just a 0 or "" . there should also be 19 values to a drop command. yours had 20 ;) some of the values are pretty screwy too. see the effect.... :-\
so, the new script:
_obj = _this
#burn
drop ["cl_fire","","Billboard",1,random 2,[random 1,random 1,random 1],[random 1,random 1,1],0,(random 0.1) +0.1,0.2,random 0.2,[random 2,random 2,random 1],[[1,1,1,1],[0,0,0,1]],[0],0,0,"","",_obj]
drop ["cl_basic","","Billboard",1,random 1,[0,0,0],[random 1,random 1,random 1],0,(random 1) +1,1.5, random 0.1,[random 1,(random 1)+1,(random 1)+1],[[1,1,1,1],[0,0,0,1]],[0.45,0.45,0.45,0.75],0.01,0,"","",_obj]
;To increase the time the fire lasts for, increase the numerical value in the next line.
?_time >=5000:goto "exit"
;always a good idea to put a small delay in loops, to prevent crashing...
~0.1
goto "burn"
#exit
call it using
unit exec "script_name.sqs"
***
also, a wee hint for you. when calling scripts, you use brackets right? like this -
[something here] exec "script.sqs"
that's great for when you have a few things to pass to the script, like so -
[one_thing, "string", 123, another_thing] exec "script.sqs"
super. but if there's only one thing to pass, putting it in brackets creates an array, which is a waste of flashpoint's limited resources. when there's only one thing, especially when it's a unit, use
unit exec "script.sqs"
with no brackets. at the top of the script, instead of using select to get at the different bits of the array, you only need
_thing = _this
that's it. no arrays, no waste of resources. if that's incorrect or misleading, everyone feel free to comment.
EDIT - one final comment. if you want a good fire script, use general barron's (http://www.ofpec.com/editors/resource_view.php?id=690). it's easy to use, looks stunning and most importantly - it works.
-
bedges
thank you very much for sorting script and many thanxs for youre advice on executing scripts i will remember it in future..
....... top man ........
thanx again
sharkattack