Home   Help Search Login Register  

Author Topic: Arrays getting one command  (Read 1024 times)

0 Members and 1 Guest are viewing this topic.

Dubieman

  • Guest
Arrays getting one command
« on: 03 Aug 2004, 04:41:41 »
Hey there I'm makin a script and I'm not the best scriptor in the world so I need some help.

The start of this script deals with a group so I'm also confused on this too. Should I put

_group = _this select 0
OR
_group = group this

then my other variables and names....
_enemypos = _this select 1
_Eamount = _this select 2
_Famount = _this select 3

Anyways  need an explanation on the group part.

Now when my group from above gets to the "safe" area I want to heal every group member. How can I do that?

I'm using "_group group setdammage 0" and I'm not quite sure if it will work. :-\

Now the math syntax thing. Again I'm not sure how I'm gonna test this so I'm askin if I'm doin it right from the get go.

Code: [Select]
_Famount CountFriendly _Flist
_Eamount CountEnemy _Elist
_i = _Elist+5
_Elist > _Flist+_i goto "leave"

Now Elist is enemy list and Flist is friendly list. And if the enemy has 5 more men than the friendlies than the script goes to leave... :P

Will that work? And should I make it a random number picking instead? :-\


Finally what's the check going to look like, if I have

Code: [Select]
_group domove getpos marker1
I want to find out when they get there to iniate the rest part and then move them to the next marker. :-\

thanks in advance ;)

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Arrays getting one command
« Reply #1 on: 03 Aug 2004, 09:38:57 »
1)   _this select 0 is the first element in the array passed to the script.

[element1, element2] exec "myScript.sqs"

In this case it would be element1.  Get clear in your head what array is being passed to the script.    At the top of a script you should always put a few comments explaining how to call it and what array it requires.


2)   _group = group this makes no sense at all.


3)  "_x setDammage 0" forEach units _group


4)  The counting bit might work, try it.    Only you can decide if you want it to be 5 more or random.  


5)  doMove is a command for a single unit within a group.   If you want the group to move use the command move.




Plenty of reviewed ArmA missions for you to play

Offline Mud_Spike

  • Contributing Member
  • **
Re:Arrays getting one command
« Reply #2 on: 03 Aug 2004, 09:41:44 »
The start of this script deals with a group so I'm also confused on this too. Should I put

_group = _this select 0

This puts the first argument in _group, if supplied with a group-variable,
you will have it in _group, if supplied with an array, that array will be there instead.

Code: [Select]
[my_grp, flubber] exec "foo.sqs"
vs
[[my_grp,the_other_grp], flubber] exec "foo.sqs"


I'm using "_group group setdammage 0" and I'm not quite sure if it will work. :-\

Read up on the SetDammage, Group, Units and Foreach commands in the command reference, then you'll understand this:

Code: [Select]
"_x SetDammage 0" foreach units _group

Will heal all units in _group, even the dead ones, which might not be what you want. There are a number of ways around this, but the most simple is using an extended foreach-function. I wrote a grpForeach that lets you perform commands on all units in a group with some conditions, i.e., is the unit alive, is he the leader. I'll attach it here if I figure out how.

It would go like:
Code: [Select]
[_group, "_x SetDammage 0"] call grpForeach
(since "_alive=1" is default)


Now the math syntax thing. Again I'm not sure how I'm gonna test this so I'm askin if I'm doin it right from the get go.

Code: [Select]
_Famount CountFriendly _Flist
_Eamount CountEnemy _Elist
_i = _Elist+5
_Elist > _Flist+_i goto "leave"

Now Elist is enemy list and Flist is friendly list. And if the enemy has 5 more men than the friendlies than the script goes to leave... :P

Will that work? And should I make it a random number picking instead? :-\

Code: [Select]
? ((count _Flist) + 5 < (count _Elist)): goto "leave"


Finally what's the check going to look like, if I have

Code: [Select]
_group domove getpos marker1
I want to find out when they get there to iniate the rest part and then move them to the next marker. :-\

First:
Code: [Select]
leader _group doMove getMarkerPos marker1

The trigger part:
Condition:
Code: [Select]
([GetPos leader _group, getMarkerPos marker1] call distancePos) < 5
I.e., the distance between the leader of the group and the marker is less than 5 meters.

You'll need snypir's distancePos function (See the OFPEC function library)
for that one.


Dubieman

  • Guest
Re:Arrays getting one command
« Reply #3 on: 04 Aug 2004, 01:20:00 »
Well thanks for replying, I just found the script I was gonna create has already been done.... ::) :P

So no point in continueing, but your info is a help, just info I might need in the future or something....
 :)
thanks anyways :P ;)

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Arrays getting one command
« Reply #4 on: 04 Aug 2004, 10:14:20 »
Even if a script has been made before there's no harm in creating your own version if you want to.    It's a good learning experience and your version may have features the other does not.
Plenty of reviewed ArmA missions for you to play

Dubieman

  • Guest
Re:Arrays getting one command
« Reply #5 on: 04 Aug 2004, 15:52:29 »
Ahh this one has already been made well...

I was thinking of a few things I could script but, hell everything is made already!  ::)

Which is a good and bad thing I suppose. ;D

Actually it may be a while but I'm in the starting stages of a sporadic gunfire script. Dunno if it'll get finished... :P :-\