Home   Help Search Login Register  

Author Topic: Create Target, wait until Destroyed, and continue  (Read 1039 times)

0 Members and 1 Guest are viewing this topic.

Offline somerville

  • Members
  • *
Create Target, wait until Destroyed, and continue
« on: 23 Sep 2008, 15:51:00 »
Hi all,

I'm trying to make a new Anti-tank training range. It used to be SQS, and based on something along the lines of:

Code: [Select]
_random = random 3

?(_randomup <= 1): goto "tank1"
?(_randomup <= 2): goto "tank2"
?(_randomup <= 3): goto "tank3"
?(_randomup <= 4): goto "tank4"
?(_randomup <= 5): goto "tank5"
?(_randomup <= 6): goto "tank6"

#tank1
tanktarget setpos (getpos pos1)
~18
goto "start"

.. And so on. Of course, I've been virtually slapped, spat on, and bullied for using SQS (Possibly a slight over-exaggeration). Anyway, I'm now attempting to move to SQF, as I hear it's much better for scripting when you're doing a fair bit of waiting between commands.

So, I've read up on a few commands, such as waitUntil, to see if I can make it work. In SQS, I had something along the lines of:

Code: [Select]
_veh = "BMP2" createVehicle (getpos arpt1);
_veh lock TRUE;
_veh addeventhandler ["hit", {hint "That's a hit"; ([_veh] exec "cleanup.sqs")}]

The CleanUp.sqs is just a script to make sure the wreck gets deleted. So anyway.. I'm wondering if there's a better way to do this in SQF? Say, using WaitUntil !alive _veh, then blah blah.. I'm happy using the count feature, so that you can get a maximum number of tanks, then you have to 'reset' the range. But I'm a bit lost thus far.. any help would be greatly appreciated :)

Offline i0n0s

  • Former Staff
  • ****
Re: Create Target, wait until Destroyed, and continue
« Reply #1 on: 23 Sep 2008, 16:27:16 »
You can switch to "killed" to make sure the vehicle is destroyed.
Eventhandler are better then the waitUntil since they don't consume cpu time when waiting.
The only 'problem' on eventhandler is their locality in multi player.

About the first code you presenting: Take a look at the switch-statement.