Home   Help Search Login Register  

Author Topic: Random Unit as an Objective  (Read 1012 times)

0 Members and 1 Guest are viewing this topic.

Offline peyres123

  • Members
  • *
Random Unit as an Objective
« on: 02 Aug 2007, 22:00:32 »
I'm doing an Assasination mission.

There will be several body doubles in suspected locations. I'd like one of the doubles to be the objective, but I'd also like this to change randomly each time the mission is played.

I know how to make Units appear in random positions, but I want this body double element (ala sadamn hussein)

How would I go about doing this?


Cheers!

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Random Unit as an Objective
« Reply #1 on: 02 Aug 2007, 22:29:47 »
hmmm..i think the easiest way is to collect them in an array and the choose on by random

Code: [Select]
_targetsarray = [namedunit1, namedunit2, namedunit3, namedunit4]
_realtarget = _targetsarray select (floor (random (count _targetsarray)))
...
...
...
?! (alive _realtarget): "1" objstatus "DONE"

untested so don't blame me if it doesn't work from scratch


Myke out

Offline peyres123

  • Members
  • *
Re: Random Unit as an Objective
« Reply #2 on: 02 Aug 2007, 23:14:08 »
hehe, no chance of me blaming someone trying to help me :D

Will give it a go, cheers.

Offline peyres123

  • Members
  • *
Re: Random Unit as an Objective
« Reply #3 on: 03 Aug 2007, 01:08:02 »
actually, I'm not sure how to implement it into the game.

Would that code be a SQS or a SQF, or just something to put in an Init field. Or is it a gamelogic code?

I'm a newbie :(

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Random Unit as an Objective
« Reply #4 on: 03 Aug 2007, 02:03:19 »
well, ok, didn't knew you're "noob" (no offence intended)

Here's a how to by using a really short script:

Code: (primary_target.sqs) [Select]
?! (isServer): exit
_dude_array = _this select 0

_my_dude = _dude_array select (floor (random (count _dude_array)))

@ !(alive _my_dude)
"1" ObjStatus "DONE"
exit

This little sqs script you can call from wherever you want...init.sqs would be a good place for.
Name all possible targets (doubles) as you like, i'll take the examples from my first reply:

[[namedunit1, namedunit2, namedunit3, namedunit4]] exec "primary_target.sqs"

you can add as many possible targets as you like to, one of them will be selected as the "true" target and therefor set the objective to "DONE"

Hope this helps

Myke out