Jump to content
Sign in to follow this  
kocrachon

Humvee wont leave.

Recommended Posts

Ok so I am making a mission where my units extract by vehicle. The condition I have for the vehicle to move is (Soldier1 in HV1) AND (Soldier2 in HV1).

However if Soldier 2 dies, and I get in the humvee, it wont leave. How do I make it leave even if one of the soldiers in my group dies?

EDIT: Would it be possible for me to just give the group a name like Group1, and then just say (Group1 in HV1)? And if so, how on earth do I name a group? I have been trying to figure this all out for a while.

Share this post


Link to post
Share on other sites

I'm not sure if i'll get this right because i'm still a newb mission maker/scripter myself, and i'm trying to get this off the biki, so here goes:

First, pick the soldier you want to be the leader of the group and name him something, and in his init field, put Alpha = group this.

Then for the other soldiers you want to be in the group, put this join "leaders name" without the quotes. If that doesn't work, here is the biki link I was using, and you can try to see what i've done wrong. http://community.bistudio.com/wiki/join for the join command, and http://community.bistudio.com/wiki/group for the groups. Good luck with your mission!

Share this post


Link to post
Share on other sites

Unfortunately that doesn't work, it gives me this error

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> This |#| join soldier1

Error join: Type Object, expected arra

It does that also if I put join team1, which is what I named the group.

Share this post


Link to post
Share on other sites

As the error message tells you, the join command expects an array:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[player] join grp

You gave it a single object instead of an array, which doesn't work.

Why it wants an array? Well it is handy because you can join many units at once:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[player, theotherguy, thegirl, themom] join grp

Wonderful isn't it.

Share this post


Link to post
Share on other sites

now the only other question is, how do I make it so that the humvee will leave when team1 (as I named the group) is in the vehicle? is it just

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Condition: Team1 in HV1

Activation: (Group HV1) setcurrentwaypoint [group HV1, 4]

EDIT: Actually I know that doesn't work because once the game starts I get this error

Quote[/b] ] (Team1 in |#| in HB1)

Error Generic Error in Expression

Im not a coding genius so I have no clue wht that means.

Share this post


Link to post
Share on other sites

Ok so some one told me to try this script

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{alive _X && !(_X in crew VehicleName)} count units team1 <= 0

But for some reason the Humvee still doesn't move at all. Am I naming my group the wrong way?

Share this post


Link to post
Share on other sites

I'm in a hurry and I'll just point you to a function at http://www.ofpec.com/

groupInVehicle

Edit: Heck, I'll also copy&paste the function here just in case OFPEC disappears:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// ******************************************************************************************

// groupInVehicle.sqf

// There are two possible ways how to use this function:

// #1: You pass only group to the function. In this case, the function returns true if all

// group members are in any vehicle, false if at least 1 member is not in any vehicle.

//     The vehicle isn't necessarily the same vehicle for all.

// #2: You pass group and vehicle to the function. In this case, all group members

// need to be in the vehicle passed to the function for true to be returned,

// otherwise the function returns false.

// USAGE:

// init: groupInVehicle = preprocessFile "groupInVehicle.sqf"

// calling #1: [<group>] call groupInVehicle

// calling #2: [<group>, <vehicle>] call groupInVehicle

// returns: <boolean>

// example #1:

// if ( [grpWest1] call groupInVehicle ) then { hint "All are in vehicles!" }

// example #2:

// if ( [grpWest1, truck] call groupInVehicle ) then { hint "All are in truck!" }

// Credits: bardosy, bedges, THobson (inspired by their forum posts)

// Baddo 2005

// You can contact me through www.ofpec.com

// ******************************************************************************************

private "_grpInVehicle";

_grpInVehicle = true;

if ( count _this > 1 ) then

{

if ( {vehicle _x != _this select 1} count units (_this select 0) > 0  ) then

{

_grpInVehicle = false;

};

}

else

{

if ( {_x == vehicle _x} count units (_this select 0) > 0 ) then

{

_grpInVehicle = false;

};

};

_grpInVehicle

The groupInVehicle function will tell you if all members of a group are in any vehicle, OR if they are in the same vehicle. Depends on the arguments you pass for the function. See comments in the function for instructions how to use it. I wrote it for OFP but I bet it works for ArmA too.

Always check the OFPEC Editors Depot first when you have a question about scripting.

Share this post


Link to post
Share on other sites

But what I am still getting hung up on in the first place is what is the name of my group?

Say in the editor I create a squad of 8 guys. How do I give them a name as a group and not individual soldiers?

Also that big ol script you posted. I hardly even understand what its trying to tell me what to do to make it work.

Share this post


Link to post
Share on other sites

just give the leader of the group a name, the rest of the squad fall under that name as far as I know, with out having to name every unit

Share this post


Link to post
Share on other sites

if ((!(alive soldier 1) or (soldier1 in HV1)) and (!(alive soldier 2) or (soldier2 in HV1))) then {RollOut = true};

Although if you're wanting to use a group, Baddo's function is better.

@Baddo and potential users:

1: That script does not account for dead people still attached to the group. Basically, they stay attached until someone calls out "oh NO. seVEN IS down!!!11!eleventy-one!". If you're familiar with the command interface and have ever lost an isolated guy, you'll know that it can take several minutes before the team realizes that something's amiss. Note that the teamate not acknowledging the getin order would tip the ai off (I think). Suppose though, a hypothetical casualty occurred after the order was issued and acknowledged. With the ai being what it is, players being an impatient lot, and givin that in some cases the whole mission may just have to wait on that check, this should probably be considered a bug. The simple fix is to also pass a group member as OK when they're not alive.

Example (note, not syntax checked, but unlikely to contain errors):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// ******************************************************************************************

// groupInVehicle.sqf

// There are two possible ways how to use this function:

// #1: You pass only group to the function. In this case, the function returns true if all

// group members are in any vehicle, false if at least 1 member is not in any vehicle.

// The vehicle isn't necessarily the same vehicle for all.

// #2: You pass group and vehicle to the function. In this case, all group members

// need to be in the vehicle passed to the function for true to be returned,

// otherwise the function returns false.

// USAGE:

// init: groupInVehicle = preprocessFile "groupInVehicle.sqf"

// calling #1: [<group>] call groupInVehicle

// calling #2: [<group>, <vehicle>] call groupInVehicle

// returns: <boolean>

// example #1:

// if ( [grpWest1] call groupInVehicle ) then { hint "All are in vehicles!" }

// example #2:

// if ( [grpWest1, truck] call groupInVehicle ) then { hint "All are in truck!" }

// Credits: bardosy, bedges, THobson (inspired by their forum posts)

// Baddo 2005

// You can contact me through www.ofpec.com

// ******************************************************************************************

private "_grpInVehicle";

_grpInVehicle = true;

if ( count _this > 1 ) then

{

if ({(vehicle _x != _this select 1) or !(alive _x)} count units (_this select 0) > 0 ) then

{

_grpInVehicle = false;

};

}

else

{

if ( {(_x == vehicle _x) or !(alive _x)} count units (_this select 0) > 0 ) then

{

_grpInVehicle = false;

};

};

_grpInVehicle

A more sophisticated method would be to force a status check for anybody not in the vehicle somehow. Maybe recurring getin orders? Anyways, that's all just food for thought.

2: Substitute the tabs with 3-6 spaces (by preference), to keep your indentation readable on the forums. wink_o.gif You probably already knew that and just forgot though, being the cool savvy Bado, but I'm just stating it to make sure.

Share this post


Link to post
Share on other sites

Actually I found out something that takes ALOT less effort..

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">({ (not (_x in Humvee1)) and (alive _x) } count (units (group player))) == 0;

Share this post


Link to post
Share on other sites

Yup yup smile_o.gif

Means yes I knew, both points.

The functions I have placed into ofpec are meant to be as simple as possible by intention, prefereably only one task per function, like one function for "is group in vehicle" (well okay, it's "is group in this or in any vehicle") and another for "is group alive". For convenience an alive check can be placed into the groupInVehicle function but I would say that functionally (logically, semantically? heck pick your word, I don't know! ) it doesn't belong there. But it's a safety check which can be put there and it doesn't cause any harm.

Actually, it could be good overall to have a killed event handler or a looping function/script to kick the dead units out of their groups as soon after death as possible. In OFP multiplayer I recall this can become very important (leader of group is dead but group doesn't get new leader if [leader group] join grpNull is not used manually). I don't know how ArmA is in this regard.

The "tabs into spaces" conversion for code posted to forums... it is maybe something forum developers could think about. It's not problematic. If you use some tab width in your editor and forum uses another, then again the formatting is messed up.

It seems HavocDemon got his problem solved. HavocDemon you should consider what actually takes more effort in the long run. Using a function call such as BDO_myGroup call BDO_groupInVehicle versus using ({ (not (_x in Humvee1)) and (alive _x) } count (units (group player))) == 0;

An obvious problem is that when you need to do it many times in your code, it gets messy. And you write the same function over and over again, and everytime you need to remember how to write ({ (not (_x in Humvee1)) and (alive _x) } count (units (group player))) == 0; instead of having to remember how to write BDO_myGroup call BDO_groupInVehicle. Which one is easier to remember? Just something to consider for the future, for this particular problem of yours your solution is perfectly acceptable.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×