OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: ONoSixIsDown on 13 Jan 2006, 16:45:35

Title: just wait already!!
Post by: ONoSixIsDown on 13 Jan 2006, 16:45:35
 >:(


ok heres the deal... i found a script here that is supposed to make a vehicle stop at a waypoint, wait untill all members of a group are aboard then go about it buisness...

well, when i implemented it into my mission, it just does not seem to work correctly.  


heres the script (named bradwait.sqs)
Quote

; BEGIN
_vehicle = _this select 0

; loop until all of the players squad have got in
#for1

~0.5

; make the vehicle wait until the whole squad is in
_lead = leader player
_playerArr = units group _lead
_num = count _playerArr

_incount = 0
_tmp = 0

#for2
? vehicle (_playerArr select _tmp) == _vehicle: _incount = _incount + 1
? _tmp < (_num - 1) : _tmp = _tmp + 1; goto "for2"

? _incount != _num : goto "for1"

; the vehicle will move off on it's waypoints
_vehicle setfuel 1

; END SCRIPT


first, i put a logic(named bradlogic) at the move waypoint where i want the vehicle(named brad) to stop and wait for the group to board.  I then made a trigger with these parameters

condition: brad distance bradlogic <5

activation: brad setfuel 0; [brad] exec "bradwait.sqs" this is how i get the vehicle to stop at the move waypoint...

from what the script tells me is that once the vehicle is out of fuel it will then be refueled once all the members of a group are aboard.  now i did see that part at the top of the script that says "_vehicle = _this select 0" but i didn't see an array thingy ??? that specifies the group that is to get in....  :help:

sorry for the long winded post... just trying to explain as best i can
Title: Re:just wait already!!
Post by: Planck on 13 Jan 2006, 17:48:22
Isn't this bit the array of the groups units, in this case it is referring to the players group?:

Code: [Select]
; make the vehicle wait until the whole squad is in
_lead = leader player
_playerArr = units group _lead
_num = count _playerArr
...
...
...


Planck
Title: Re:just wait already!!
Post by: ONoSixIsDown on 13 Jan 2006, 18:04:01
i thought so but was thrown off by the lack of a "select this"... would i need to call the script like this?

  activation: [brad,player] exec "bradwait.sqs"


Title: Re:just wait already!!
Post by: The-Architect on 13 Jan 2006, 18:28:24
I'm sure you don't need a big script to get a vehicle to wait. Surely there's a simple way. I'll try.

I'll assume the vehicle isn't the player's and also that it isn't in your group.

Vehicle gets to waypoint.

Code: [Select]
[] exec "BradWait.sqs"
In BradWait.sqs.

Code: [Select]
Brad SetFuel 0

#Loop
? Not (MyGroup In Brad): GoTo "Loop"
GoTo "Fuel"

#Fuel
Brad SetFuel 1
Exit

You might want to check the bit where it checks for the group, it may be wrong.
Title: Re:just wait already!!
Post by: Trapper on 13 Jan 2006, 18:29:15
The current script (first post) is able to stop any vehicle you wish but only for the player's group.
Title: Re:just wait already!!
Post by: ONoSixIsDown on 13 Jan 2006, 19:06:59

Code: [Select]
[] exec "BradWait.sqs"
In BradWait.sqs.

Code: [Select]
Brad SetFuel 0

#Loop
? Not (MyGroup In Brad): GoTo "Loop"
GoTo "Fuel"

#Fuel
Brad SetFuel 1
Exit

You might want to check the bit where it checks for the group, it may be wrong.

tried it and got an error saying "gereric error in expression"... what ever that means :-\

any other ideas?
Title: Re:just wait already!!
Post by: macguba on 14 Jan 2006, 01:58:05
Can you give the error exactly?   Including the #, which usually marks exactly where in the code the error occurs.
Title: Re:just wait already!!
Post by: Triggerhappy on 14 Jan 2006, 03:27:12
you need to name the group you're waiting to get in named mygroup

althought i do spot an error:
Code: [Select]
? Not (MyGroup In Brad): GoTo "Loop"
you have to check for each unit in the group individual


Code: [Select]
_All_In = true
"?! (_x in brad):_All_In = false" foreach mygroup
?!_All_In:goto "loop"

although looking at the original script, it should work, so long as its a player group
Title: Re:just wait already!!
Post by: THobson on 14 Jan 2006, 10:45:53
Sometimes a group will still contain dead units - for a while until the leader knows they are dead.  For that reason I would do something like this in a script:
Code: [Select]
@({_x in Brad} count units mygroup == {alive _x} count units mygroup)
In a waypoint condition field the following will do it:

{_x in Brad} count units mygroup == {alive _x} count units mygroup

Putting it in the condition field of a waypoint means the vehicle will wait at the waypoint until the condition is true and so you do not need to play around with fuel levels and you don't need a script!  All you need is that one line in your waypoint (it replaces the word 'true')

See attached missionette
Title: Re:just wait already!!
Post by: THobson on 14 Jan 2006, 13:18:47
The reason for the new post is that I want to attach a new file.  

As I was stepping away at the gym earlier it occurred to me that there was a subtle problem with the solution I posted above.  That solution counts the number of units that are in the Bradley and compares it with the number of units that are alive.  There may be a problem if one of the units in the Bradley is dead.  The following is a better line to put in the waypoint condition field:

{(alive _x) and not (_x in Brad)} count units mygroup < 1

What this does is counts the number of living units that are not inthe Bradley and allows the vehicle to continue once that count is < 1
Title: Re:just wait already!!
Post by: ONoSixIsDown on 16 Jan 2006, 23:14:07
thanks, works great now ;D