Home   Help Search Login Register  

Author Topic: ordergetin (and other) queries  (Read 2204 times)

0 Members and 1 Guest are viewing this topic.

deaddog

  • Guest
Re:ordergetin (and other) queries
« Reply #15 on: 28 Nov 2003, 19:12:29 »
Or you can do this:

Just use the group name instead of each indiviual unit name:

Code: [Select]
loaded=false

#wait
~1

_count="alive _x" count (units groupname)

?("alive _x && vehicle _x != _x" count (units groupname)) != _count:goto "wait"

loaded=true

This is a foolproof way to check if all units in a group are in a vehicle.  It will take into account any units that get killed while trying to board (or already boarded), and you don't have to name each individual unit this way.

The reason to use "alive _x" count (units groupname) instead of just count (units groupname) is that the first way will give an instant, accurate count of all units alive in a group.  The second way only gives an accurate result if the leader of the group knows about a dead player.  In other words, if a unit dies and the leader doesn't know it yet, count (units groupname) will give an inaccurate count.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:ordergetin (and other) queries
« Reply #16 on: 28 Nov 2003, 19:24:11 »
Yep deaddog, but the count for the vehicle of the unit in combination with west countside would also wait until
all of the living guys are not their own vehicle anymore.

When a unit dies, it's no more assigned to the side, where
it was before.

Also the loaded = false at the beginning of the script would
be at the wrong place, as it would already be too late for
that.

At the time, when the script starts, there would already a
condition be waiting for: loaded
If you initialise a variable, after you ask for it, the whole
condition would become ignored => not work

Therefore: loaded = false

should stand somewhere at the start of the mission
(init.sqs or so)

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

blutacis

  • Guest
Re:ordergetin (and other) queries
« Reply #17 on: 28 Nov 2003, 19:36:53 »
uurgh, more stuff to struggle to understand  :) i had a feeling i was making things difficult for myself, much thankage for your suggestions
 i tried to simplify the earlier version, it doesnt work but if it did i think it would do exactly what i want: check that certain units, if not dead, are loaded on a truck

Code: [Select]
_unit1 = _this select 0

convoyloaded = 0

_a = 0
_l = 0
;a=aliveunitcache, l=loadedunitcache

?(alive _unit1): {_a=_a+1} else {_a=_a-1}

?vehicle _unit1 != _unit1: _l=_l+1


@"_a == _l":convoyloaded=1

I get the feeling i should be doing something easier =/
what i think the code does is this: counts the number of alive units, subtracts the number of dead units, counts the number of loaded units, when the number of alive units is equal to the number of units in a vehicle it sets convoyloaded as 1

Anyway, ill implement your suggestion


EDIT: ok, if you could tell me if i understand your script correctly id be very grateful:
_units_default = _this <this sets all the defined units in the editor init field (man1, man2...etc) as an array called _units_default?>

_units_array = [] <this creates an array called _units_array, and sets its value as null>

"if (alive _x) then {_units_array = _units_array + [_x]}" foreach _units_default <i'm not sure what _x refers to...but if _x is alive then the null array _units_array is set to _x, this line is gathering all the alive units and putting them into _units_array?>

@"vehicle _x == _x" count _units_array == 0 <ok, vehicle _x==_x will determing if a unit is not in a vehicle, so when no units of the _units_array array are in a vehicle this line will be passed, setting convoyloaded to 1... genius =)

convoyloaded = 1

exit




« Last Edit: 28 Nov 2003, 22:05:38 by blutacis »

deaddog

  • Guest
Re:ordergetin (and other) queries
« Reply #18 on: 28 Nov 2003, 19:38:22 »
Quote
Therefore: loaded = false

should stand somewhere at the start of the mission

Yeah, you're right, I've run into that problem a couple of times.  The Golden Rule for global variables should be:

Thou Shalt Always Initialize Globals At The Start Of The Mission

 :)