Home   Help Search Login Register  

Author Topic: randomly camcreate anywhere in trigger  (Read 769 times)

0 Members and 1 Guest are viewing this topic.

_hammy_

  • Guest
randomly camcreate anywhere in trigger
« on: 23 Nov 2002, 06:03:26 »
I am making a very simple script, just camcreate smokeshells in a trigger, but i want it to randomly camcreate in random spots in the trigger so they are not all camcreated in the same spot.

crosshair

  • Guest
Re:randomly camcreate anywhere in trigger
« Reply #1 on: 24 Nov 2002, 01:36:54 »
Hi Hammy,
   What you are trying to do is highly dependent on the geometry of the trigger.  Here's an example of what you might do with a circular trigger 'cause it's easiest IMO.

Create a trigger and set the Name to trigger1.
Then in the On Activiation do something like this:
Code: [Select]
  [trigger1, 50] exec "smokescreen.sqs"

Where trigger1 is the trigger and 50 is the radius of the trigger.

Then create a script that does something like this:
Code: [Select]
_trigger = _this select 0
_triggerRadius = _this select 1
_position = getPos _trigger
_x = _position select 0
_y = _position select 1
_angle = Random 359.9
_distance = Random (_triggerRadius - .1)
_newx = _x + (sin _angle * _distance)
_newy = _y + (cos _angle * _distance)
_smoke = "smokeshell" CamCreate [_newx, _newy, 0]

The script get's the position of the trigger and then chooses a random angle and distance from the center.  It determines a new x and y coordinate and drops the smokeshell there.  I have this as a little script with a loop.  It seems to work well.

Remember that different trigger geometry will require a different algorithm.

Regards,
crosshair