Home   Help Search Login Register  

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

0 Members and 4 Guests are viewing this topic.

blutacis

  • Guest
ordergetin (and other) queries
« on: 27 Nov 2003, 13:06:22 »
woo, first post. ive searched and cant find an answer.
can i use the foreach units command to make a unit board a vehicle, as i can assignascargo, or do i have to ordergetin each individual unit?

eg. "_x assignascargo truck" foreach units delta; [delta, delta1, delta2, delta3, delta4] ordergetin true
« Last Edit: 27 Nov 2003, 23:08:09 by blutacis »

deaddog

  • Guest
Re:ordergetin query
« Reply #1 on: 27 Nov 2003, 14:51:41 »
Yep, or even easier:

"_x assignascargo truck" foreach units delta; (units delta) ordergetin true  
 
No need to name each individual soldier in a group, this way.

 :)
 
 

Offline ACF

  • Members
  • *
  • Llama?? Ain't that French for tanks?
Re:ordergetin query
« Reply #2 on: 27 Nov 2003, 14:52:03 »
Welcome aboard!

What you've got is pretty much the answer - first you need to AssignAs... each unit (which you can do with ForEach), then OrderGetIn the array of those units.

Because OrderGetIn works on an array you don't need to use ForEach:
{[_x] OrderGetIn true} ForEach [thearrayofunits] is a bit redundant.

A likely error is that the variable 'delta' is assigned twice - as the name of the group AND the leader of the group - they are not the same thing. Try it with your leader named delta0 or somesuch.

nb. the curly brackets replacing the quotes do the same job but better - they don't interfere with quotes in the code string, e.g. {_x SetUnitPos "AUTO"} works, "_x SetUnitPos "AUTO"" doesn't.

blutacis

  • Guest
Re:ordergetin query
« Reply #3 on: 27 Nov 2003, 17:47:12 »
Wonderful, thank you very much, that makes things much easier deaddog=)

re. ACF, am i right in thinking that to name a group (create an array) i would use

grp1 = [unit1, unit2, unit3]

in an init field or external script

ta muchly  :D

Offline ACF

  • Members
  • *
  • Llama?? Ain't that French for tanks?
Re:ordergetin query
« Reply #4 on: 27 Nov 2003, 19:54:31 »
No - that's the trap!  That's why you have to use:

Units groupname

to get an array of the units in the group.  To name a group, stick this in the init field of the group leader in the editor:

groupname = Group this

Use the name field of each of the units to define their names if you need to reference them individually.

Leader groupname is quite handy if you want the current group leader to do things if the original leader is killed.

blutacis

  • Guest
Re:ordergetin query
« Reply #5 on: 27 Nov 2003, 20:11:07 »
hehe, i just found the group command, thanks very much for the help

blutacis

  • Guest
Re:ordergetin query
« Reply #6 on: 27 Nov 2003, 22:11:41 »
for my next trick... is it possible to detect when unit has boarded vehicle, in order to activate a wapoint for example.

would it go along the lines of:

if (unit = ???) then setpos (x,x)

edit: if anyone could suggest a way to remove an object from a map via its id id give them lots of love  ;D
another edit: more love to anyone suggesting a way to detect whether a unit is part of a specific group, ie
if unit is in group1 then wp1=1
« Last Edit: 27 Nov 2003, 23:07:20 by blutacis »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:ordergetin (and other) queries
« Reply #7 on: 28 Nov 2003, 01:34:30 »
Read the section "Scripting topics" in the official command reference.

? loon1 in tank1:whatever

object 1234 setdammage 1    
(won't remove it - I don't think you can - but it might help)

loon1 in (units grp1)


Syntax not guaranteed.   Check all the commands.

Oh, and

Welcome to the forum!



« Last Edit: 28 Nov 2003, 01:35:06 by macguba »
Plenty of reviewed ArmA missions for you to play

deaddog

  • Guest
Re:ordergetin (and other) queries
« Reply #8 on: 28 Nov 2003, 01:39:52 »
You can also do this:

?group unitname == groupname :hint "i'm in that group" (or whatever you want to do)

Also, get to know the "vehicle" function:

?vehicle player == player:hint "player is not in a vehicle"
or
?vehicle unitname == unitname:"Unit is not in a vehicle"


?vehicle player != player:hint "player IS in a vehicle"

This way, you don't necessarily have to know the vehicles name.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:ordergetin (and other) queries
« Reply #9 on: 28 Nov 2003, 03:17:23 »
hmm - i don't understand why you want to check in
which group a unit actually is, as the only one who has
control about which unit is in which group is the mission
maker.

Therefore i'd suggest you (for whatever you wanna do
with that) to: sort the event you want to start, when
changing the group assignment of the unit.

removing objects from a map did work in one of the previous
versions than somewhere around 1.8x
This option was disabled (fortunately) because of the possibility
to use it for cheating.
:note - at the time when it was possible to remove an object
from the map, it was required to restart ofp to get that object
back onto the map - so imagine how easy it would have been
in multiplayer to remove objects where others could have
been hiding behind  ;)

And to complete deaddogs excellent suggestion about
vehicles;

if you want to capture any vehicle, where a unit is, without
pre-knowledge about it use:

myvehicle = vehicle unitname

~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 #10 on: 28 Nov 2003, 13:36:07 »
Many thanks
im doing something completly wrong, and i feel like a moron, but i cant use the
?vehicle player != player:hint "player IS in a vehicle"
script at all. sorry for asking such basic questions here, im sure theres a good tutorial for this but ive been looking for hours and havent come across anything. if anyone could point me to one id be very grateful =)  :-\
edit:  ;D just got it working, woo and yay! thank you all muchly for your help
« Last Edit: 28 Nov 2003, 13:43:34 by blutacis »

Offline Tomb

  • Contributing Member
  • **
  • in2 Metal? Go 2 my sig
Re:ordergetin (and other) queries
« Reply #11 on: 28 Nov 2003, 16:57:51 »
aah, one smells fresh meat  :) well, then ya need one of those...


[size=12]Welcome to the Sewers of Editing, blutacis[/size]


  :thumbsup:  8) ;D have a neat stay m8  :-*







blutacis

  • Guest
Re:ordergetin (and other) queries
« Reply #12 on: 28 Nov 2003, 17:31:27 »
thank you =) i think... im not too sure editing is doing my sanity much good...
*bangs head repeatedly on desk*
scripts, aagh, can anyone at a quick glance point out any obvious errors in this?
edit: just noticed several silly mistakes, will repost script when ive corrected
Code: [Select]

_unit1 = _this select 0
_unit2 = _this select 1
_unit3 = _this select 2
_unit4 = _this select 3
_unit5 = _this select 4
_unit6 = _this select 5
_i = 0
_m = 0
;m is alive units
;i is units loaded

;counts live units and assigns them new variable
?(alive _unit1) : _aliveunit1 = [_aliveunit1] + [_unit1],_m = _m +1
?(alive _unit2) : _aliveunit2 = [_aliveunit2] + [_unit2],_m = _m +1
?(alive _unit3) : _aliveunit3 = [_aliveunit3] + [_unit3],_m = _m +1
?(alive _unit4) : _aliveunit4 = [_aliveunit4] + [_unit4],_m = _m +1
?(alive _unit5) : _aliveunit5 = [_aliveunit5] + [_unit5],_m = _m +1
?(alive _unit6) : _aliveunit6 = [_aliveunit6] + [_unit6],_m = _m +1




;if units are not in vehicle, repeats until they are
#loop
?vehicle _unit1 ==_unit1:goto "loop"
?vehicle _unit2 ==_unit2:goto "loop"
?vehicle _unit3 ==_unit3:goto "loop"
?vehicle _unit4 ==_unit4:goto "loop"
?vehicle _unit5 ==_unit5:goto "loop"
?vehicle _unit6 ==_unit6:goto "loop"


;if unit1 is in vehicle, then add 1 to variable i
?vehicle _unit1 != _unit1:_i =_i +1
?vehicle _unit2 != _unit2:_i =_i +1
?vehicle _unit3 != _unit3:_i =_i +1
?vehicle _unit4 != _unit4:_i =_i +1
?vehicle _unit5 != _unit5:_i =_i +1
?vehicle _unit6 != _unit6:_i =_i +1

;if all alive units are loaded then variable convoyloaded is true
?_i == _m:convoyloaded=1

exit
i'm coupling this with assigncargo and ordergetin to make a scripted convoy pick up of 6 units, with a variable (convoyloaded) activated when all alive units are in the truck, or atleast im trying to...
« Last Edit: 28 Nov 2003, 17:45:49 by blutacis »

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:ordergetin (and other) queries
« Reply #13 on: 28 Nov 2003, 18:44:42 »
Well, that's a lil bit too much what you've done here.

Why do you put those guys each into it's seperate array?

Also, _aliveunit1 = [_aliveunit1] + [_unit1]
is some kind'a mismatch, as you say:

variable = [variable] + [unit]

Result would look like:

_aliveunit1 = [_aliveunit1,_unit1]

And that doesn't make sense

Then again it wouldn't work, as you cannot add anything to
something what you didn't have pre-defined.

_aliveunit1 = _unit1

would work, as it would be pre-defining (initialising) of the
variable: _aliveunit1

But: _aliveunit1 = [something] + [something_else] wouldn't
work, as _aliveunit1 is not assigned to be anything. Therefore
you cannot add something to another thing which doesn't
exist.

_aliveunit1 = []

would pre-define _aliveunit1 to be an empty array

Followed by: _aliveunit1 = [something] + [something_else]

would then work.

look:
[man1,man2,man3,man4,man5,man6] exec "scriptname.sqs"

already features an array.

Therefore in your script you could say:

_units_default = _this

would be equal to:

_units_default = [man1,man2,man3,man4,man5,man6]

The whole part where you are checking wether a unit
is alive or not could be shorten up to a one-liner:

For that you would also need to initialise another array, where
to put all the living guys into:

_units_array = []

"if (alive _x) then {_units_array = _units_array + [_x]}" foreach _units_default

Now the array: _units_array would consist of only the guys
who are alive.

Now have a look onto the next part, where you check wether
the guys are inside a vehicle, or if not, go back to the start
of the loop until all are inside:

This could aswell be done with only one single line:

@"vehicle _x == _x" count _units_array == 0

This line would sit and wait there, until the count result of the
alive guys not inside a vehicle returns 0.

And now it's time for the next line of your script:

convoyloaded = 1


Finished

:edit - and the whole script would then look like that:

Code: [Select]
_units_default = _this

_units_array = []

"if (alive _x) then {_units_array = _units_array + [_x]}" foreach _units_default

@"vehicle _x == _x" count _units_array == 0

convoyloaded = 1

exit

hope this helps

~S~ CD
« Last Edit: 28 Nov 2003, 19:00:19 by Chris Death »
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:ordergetin (and other) queries
« Reply #14 on: 28 Nov 2003, 18:56:06 »
btw - just had the syntax of your script cleaned outt'a
my brain, and then i noticed that this would be easier
done by a simple trigger:

size: 0/0
activation: none/once
condition:

"vehicle _x == _x" count [man1,man2,man3,man4,man5,man6]
== west countside [man1,man2,man3,man4,man5,man6]

onActivation: convoyloaded = 1

:note - in the trigger example above i'm expecting 6 western
units, if you need other sides, then you would also need to
change the: west to the side you want.

1 more btw - convoyloaded = 1 does not make the variable
true, it does assign the value 1 to it. And again, if you have
not pre-defined the variable convoyloaded before, it might
not work.

So you would need to pre-define: convoyloaded = 0
somewhere at the start of the mission  ;)

~S~ CD
« Last Edit: 28 Nov 2003, 19:03:40 by Chris Death »
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

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

 :)