Jump to content
Sign in to follow this  
newiy

Crew positions

Recommended Posts

Is it possible to count the number of crew positions of any vehicle via script?

Also, is it possible to randomize the crew position a unit is assigned when boarding a vehicle?

Share this post


Link to post
Share on other sites

1- Hmmm try...

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

_Totalcrew = Count crew vehiclename

;debug

hint format ["There are %1 men in this vehicle",_totalcrew]

2- Randomise crew positions?

Yes, that's possible, but can you be more specific? What's the scenario?

Share this post


Link to post
Share on other sites

vehicles will always be entered in numerical order in the cargo positions.

Imagine the seats are numbered, 0 - 6, they will always be filled in the order.

lowest number seats are filled first.

if you say exactly what you want to do, then it will be easier to help you, that is, what effect do you want to acheive?

Share this post


Link to post
Share on other sites

Random cargo positions. More for eyecandy reasons, it seems weird especially when the civil bus is boarded and everyone seats according to row.

And count the cargo capacity of the vehicle. That is, how many passengers can this vehicle hold?

Sorry for not being specific, was very tired on that day (and still am) crazy_o.gif .

Share this post


Link to post
Share on other sites

You can put gamelogics in a vehicle's cargo, which will "take up" that spot so the next unit gets into the next spot over. As for counting the cargo capacity of a vehicle, you could have a script do something like count how many game logics it can put in the cargo of a vehicle. It would be easier though to just hard-code the values into a script, or have your script use an array that contains vehicle classes and the number of cargo seats they hold: [ ["skodared",3], ["bus", 15] ] etc.

Share this post


Link to post
Share on other sites

Heh, that worked biggrin_o.gif

Now, why didn't I think of that? Of course, now the problem is that not everyone gets to board the vehicle at the same time, but that's not a worry wink_o.gif

Here's a quick script! Comments anyone?

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

_veh = _this select 0

_freeslots = 1

_logicarray = []

_slots = 0

#fillcargo

_logic = "Logic" createVehicle getPos _veh

_logic MoveInCargo _veh

_logicarray = _logicarray + [_logic]

_slots = _slots + 1

?(_logic in _veh): goto "fillcargo"

_logicarray = _logicarray - [_logic]

deleteVehicle _logic

_slots = _slots - 1

_i = 0

#randomizeloop

_r = random (count _logicarray - 1)

_r = _r - _r mod 1

(_logicarray select _r) setPos getpos _veh

deleteVehicle (_logicarray select _r)

_logicarray set [_r, "DELETE"]

_logicarray = _logicarray - ["DELETE"]

_i = _i + 1

?(_i < _freeslots && count _logicarray != 0): goto "randomizeloop"

@(count ((crew _veh) - [driver _veh] - [commander _veh] - [gunner _veh]) == _slots)

?(getdammage _veh < 1): goto "fillcargo"

{deleteVehicle _x} forEach _logicarray

Share this post


Link to post
Share on other sites

In all weirdness... crazy_o.gif

Anywho here's an updated version:

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

_veh = _this select 0

_freeslots = _this select 1

_logicarray = []

_slots = 0

#countcargo

_logic = "logic" createVehicle [0,0,0]

_logic MoveInCargo _veh

_logicarray = _logicarray + [_logic]

_slots = _slots + 1

?(_logic in _veh): goto "countcargo"

_logicarray = _logicarray - [_logic]

deleteVehicle _logic

_slots = _slots - 1

#randomizeloop

?(count ((crew _veh) - [driver _veh] - [commander _veh] - [gunner _veh]) == _slots - _freeslots_ || count _logicarray == 0): goto "check"

_r = random (count _logicarray - 1)

_r = _r - _r mod 1

(_logicarray select _r) setPos [0,0,0]

deleteVehicle (_logicarray select _r)

_logicarray set [_r, "DELETE"]

_logicarray = _logicarray - ["DELETE"]

?(count ((crew _veh) - [driver _veh] - [commander _veh] - [gunner _veh]) > _slots - _freeslots && count _logicarray != 0): goto "randomizeloop"

#Check

@(count ((crew _veh) - [driver _veh] - [commander _veh] - [gunner _veh]) != _slots - _freeslots || getdammage _veh >= 1)

?(count ((crew _veh) - [driver _veh] - [commander _veh] - [gunner _veh]) > _slots - _freeslots && getdammage _veh < 1): goto "randomizeloop"

?(getdammage _veh < 1): goto "refill"

{deleteVehicle _x} forEach _logicarray

exit

#refill

?(count _logicarray == 0): goto "check"

_logic = "logic" createVehicle [0,0,0]

_logic MoveInCargo _veh

_logicarray = _logicarray + [_logic]

?(_logic in _veh): goto "refill"

_logicarray = _logicarray - [_logic]

deleteVehicle _logic

goto "randomizeloop"

Share this post


Link to post
Share on other sites
Sorry for not being specific, was very tired on that day (and still am) crazy_o.gif .

He didn't say you were not specific.

He just asked you to be more specific.

Share this post


Link to post
Share on other sites

wongkeanwah, if you got nothing better to contribute with then don't bother.

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  

×