newiy 0 Posted September 1, 2004 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
Blanco 0 Posted September 1, 2004 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
T J 0 Posted September 1, 2004 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
newiy 0 Posted September 2, 2004 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) . Share this post Link to post Share on other sites
General Barron 0 Posted September 3, 2004 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
newiy 0 Posted September 3, 2004 Heh, that worked 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 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
wongkeanwah 0 Posted September 9, 2004 Nice,newiy and i are the same family,and she emailed it to me. edit:Cuz' i'm too lazy to script Share this post Link to post Share on other sites
newiy 0 Posted September 9, 2004 In all weirdness... 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
wongkeanwah 0 Posted September 21, 2004 Sorry for not being specific, was very tired on that day (and still am) . 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
shadow 6 Posted September 21, 2004 wongkeanwah, if you got nothing better to contribute with then don't bother. Share this post Link to post Share on other sites