Home   Help Search Login Register  

Author Topic: for each unit in trigger area  (Read 836 times)

0 Members and 1 Guest are viewing this topic.

BRAVO-TWO

  • Guest
for each unit in trigger area
« 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

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:for each unit in trigger area
« Reply #1 on: 18 Jan 2006, 20:45:56 »
in the trigger on activation field put something like this

Code: [Select]
trig_units = thislist; [] exec "script_name.sqs"
then in your script use

Code: [Select]
{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...
« Last Edit: 18 Jan 2006, 20:49:40 by bedges »

BRAVO-TWO

  • Guest
Re:for each unit in trigger area
« Reply #2 on: 19 Jan 2006, 13:37:22 »
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 .... ???
« Last Edit: 19 Jan 2006, 13:39:14 by [B.C.2] SHARK ATTACK »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:for each unit in trigger area
« Reply #3 on: 19 Jan 2006, 13:59:30 »
_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:

Code: [Select]
_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

Code: [Select]
unit exec "script_name.sqs"
***

also, a wee hint for you. when calling scripts, you use brackets right? like this -

Code: [Select]
[something here] exec "script.sqs"
that's great for when you have a few things to pass to the script, like so -

Code: [Select]
[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

Code: [Select]
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

Code: [Select]
_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. it's easy to use, looks stunning and most importantly - it works.
« Last Edit: 19 Jan 2006, 14:24:18 by bedges »

BRAVO-TWO

  • Guest
Re:for each unit in trigger area
« Reply #4 on: 20 Jan 2006, 18:34:12 »
 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
« Last Edit: 20 Jan 2006, 18:36:10 by [B.C.2] SHARK ATTACK »