colonel_klink 0 Posted June 10, 2004 Not much hair left to pull out now! Scenario: Helo (player) finds liferaft with several wretched souls on board. Problem 1: How to determine how many of these souls are on the liferaft? Problem 2: How to get them on board the hovering chopper? (Getting the driver off is no problem, but rescuing the others is a problem) Any suggestions? Share this post Link to post Share on other sites
Scud 0 Posted June 10, 2004 Probably of no use to you but the ComRef list a few count commands. count array unit countEnemy array unit countFriendly array side countSide array typeName countType array unit countUnknown array Share this post Link to post Share on other sites
Footmunch 0 Posted June 10, 2004 Klink - Are the peeps on the life-raft 'crew' (ie in cargo proxy positions), or just standing on it? If it's the former, there's a crew _unit function that returns an array, IIRC. If it's the latter, I think you'll need to get 'trigger-happy'. Share this post Link to post Share on other sites
colonel_klink 0 Posted June 10, 2004 @Footmunch They are cargo positions.. Funny how I dragged right trough the comref and didn't see the crew statement. Was looking for cargo @Scud tried the count array but couldn't get it to work. The others seem to only work with triggers. Tahnks fellas.. Will try the crew statement and if it works the fishing boats are closer to re release. Share this post Link to post Share on other sites
colonel_klink 0 Posted June 10, 2004 Ok. _crew = crew _raft gives me the names of the crew i.e Black:1, Black:2 etc etc. I tried this to get the number of the crew: _crew = count[crew _raft] gives me just 1 Hmm must be an easy way of doing this Share this post Link to post Share on other sites
Scud 0 Posted June 10, 2004 If it gives you the names I assume in an array then can't you use the count array to give you the number in the boat. By the wat I know nothing of what I am talking about Share this post Link to post Share on other sites
colonel_klink 0 Posted June 10, 2004 Yep Scud you are correct: .. an update: This gives you the units in the vehicle by name _ArraySouls = crew _NearestBoat And this ..finally.. gives me the number of units _newNum = count _arraysouls Next bit will be defining them as a group and getting them on board the chopper. Share this post Link to post Share on other sites
hardrock 1 Posted June 10, 2004 if you want to count how many of them are blessed, you can use the second type of count function: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"(damage _x)>0" count (crew _raft) A very good function in your case is forEach: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x moveInCargo _heli; _x assignAsCargo _heli} forEach (crew _raft) this way you don't have to change the groups of the people. If you want an array of all the blessed people, also use forEach: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_blessed = [] {if ((damage _x)>0) then {_blessed=_blessed+[_x]}} forEach (crew _raft) Share this post Link to post Share on other sites
BraTTy 0 Posted June 10, 2004 Good stuff Hardrock, I had fun in the past trying to do what Klink is doing also Share this post Link to post Share on other sites
colonel_klink 0 Posted June 10, 2004 Thanks Hardrock, I will try those out. I'm thinking however I will need getout and unassign functions. Share this post Link to post Share on other sites
hardrock 1 Posted June 10, 2004 You're right, I forgot that before. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x action ["getout",_raft]; unassignVehicle _x; _x moveInCargo _heli; _x assignAsCargo _heli} forEach (crew _raft) Share this post Link to post Share on other sites
colonel_klink 0 Posted June 10, 2004 Touche Hardrock.. as I was typing you beat me to it Here they are after being rescued: I'm placing a global variable so that once they are on board it loads a script that will give me a command to unload them when I land. Share this post Link to post Share on other sites
Footmunch 0 Posted June 10, 2004 I'm placing a global variable so that once they are on board it loads a script that will give me a command to unload them when I land. Perhaps easier to do it via the condition variable? Something like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> condition = "count (crew _this) > 2 && (getpos _this select 2) < 30" where the '>2' means more than pilot and co-pilot. Sorry, just my own aversion to globals (from my C++ background). Oh, and <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> count [crew _raft] returns 1, because the square brackets create a new array, the first entry of which is the crew array. So, the count works on the 'outer' array, rather than the 'inner'. Share this post Link to post Share on other sites
colonel_klink 0 Posted June 10, 2004 Yeah I might use something like that, Footmunch Code Sample : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> condition = "count (crew _this) > 2 && (getpos _this select 2) < 30" And even instigate it with a user action that comes up when the chopper speed is less than say 2 and the height is less than 5. "Passengers get out" Great fun this experimenting Share this post Link to post Share on other sites
hardrock 1 Posted June 10, 2004 But I would rather use: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">condition = "count ((crew _this)-[driver _this]-[gunner _this]) > 0 && (getpos _this select 2) < 5 && (speed _this) > 2" since otherwise you won't get the option if you've got no co-pilot but only one soldier in the cargo. Share this post Link to post Share on other sites