Home   Help Search Login Register  

Author Topic: making automatic target  (Read 1047 times)

0 Members and 1 Guest are viewing this topic.

Offline moritus

  • Members
  • *
making automatic target
« on: 25 Feb 2008, 14:08:43 »
Hi, I'm triying to make an automatic shooting range

I have 18 target the first part is ok, when all target is down i can restore them.

But I want to make automatic target...with random target comming up

i try to make a script but it doesn't work

so this is the code


targetshooting_1 SetDammage 1.0
targetshooting_2 SetDammage 1.0
targetshooting_3 SetDammage 1.0
targetshooting_4 SetDammage 1.0
targetshooting_5 SetDammage 1.0
targetshooting_6 SetDammage 1.0
targetshooting_7 SetDammage 1.0
targetshooting_8 SetDammage 1.0
targetshooting_9 SetDammage 1.0
targetshooting_10 SetDammage 1.0
targetshooting_11 SetDammage 1.0
targetshooting_12 SetDammage 1.0
targetshooting_13 SetDammage 1.0
targetshooting_14 SetDammage 1.0
targetshooting_15 SetDammage 1.0
targetshooting_16 SetDammage 1.0
targetshooting_17 SetDammage 1.0
targetshooting_18 SetDammage 1.0

#startt
? _stop == 1 :goto "end"

_number= (random 18) + 1

_string = "targetshooting_" + _number + " SetDammage 0.0"
call _string
~3.0

goto "start"

#end

exit



I hope that someone can help me

Seeya

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: making automatic target
« Reply #1 on: 25 Feb 2008, 15:07:26 »
Code: [Select]
;Add as many targets as needed to the array (18?)
_targets = [targetshooting_1, targetshooting_2, targetshooting_3, targetshooting_4]
"_x setDamage 1" forEach _targets


#startt
? _stop == 1 :goto "end"

_number= random (count _targets)
_number = _number - (_number % 1);
(_targets select _number) setDamage 0
~3.0
(_targets select _number) setDamage 1
goto "start"

#end

exit

Offline moritus

  • Members
  • *
Re: making automatic target
« Reply #2 on: 26 Feb 2008, 13:56:04 »
thanks a lot for your fast and clear answer

it's work fine