OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: LCD on 22 Oct 2007, 01:15:36
-
simple thing... shud b... i wanna know wich number da unit is in da group (as in 1,2,3... ya know.... da number da unit gets b4 its radio chatter :D)
LCD OUT
-
I thought there was a new ArmA command that did this, but if there isn't Gen Barron wrote the following function (http://www.ofpec.com/ed_depot/index.php?action=details&id=139&page=1&game=OFP&type=fu&cat=xyz) for OFP.
-
A short look in the ofpec comref showed me this:
http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=f#formationPosition
Unsure if it is what you need.
Myke out
-
formationposition returns a posirion (an array)... doesnt seem 2 b a command...
thjx 4 da help Pnut :P :D
LCD OUT
-
It must be an FSM command.
-
The only place I've seen it (formationposition) is in the FSMs, but I don't think that makes it a "FSM command" as such. I think it gives the position of the individual relative to the group leader, based on the current formation, and the standard FSM uses this information to correct the individual AI's positions as the group leader moves.
-
(units group) find (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=f#find) unitname
-
Your number isn't always the same as your number in the units array. What about when someone dies or changes group? If the leader dies, then soldier 2 become 1 in the group array, but this new leader should still have the group number 2 they had at the start, not 1 (I'm numbering from 1 here, since this is where the group numbers start counting, not the 0 that arrays start at). I think adapting Gen Barron's function (http://www.ofpec.com/ed_depot/index.php?action=details&id=139&page=1&game=OFP&type=fu&cat=xyz) from the OPF version is the best bet, as Mr Peanut suggested (Needs changing, since ArmA has no 12-man group-limit, though I can't imagine why I'd want a larger group *shrugs*).
-
ok i tried it... doesnt seem 2 work :P
if ny1 can edit da script 2 go good with ArmA ? i tried modifing it myself also... and it wont work also ::)
LCD OUT
[edit] ok it seems dat it works 4 unit dat dont have variable name.... or somin like that...
-
Yes, as far as I can see it is not MP compatible (since it assumes that only the local player can have a name), whereas in an MP game, any player can have a name. Simplest fix for that is just to replace:
if (_this == player) then {if(format ["%1",_this] == format["%1:%2 (%3)", _grp, _i, name _this]) then {_ret = true;};};
with:
if (isPlayer _this) then {if(format ["%1",_this] == format["%1:%2 (%3)", _grp, _i, name _this]) then {_ret = true;};};
If it still causes problems with AI with identities set (not used them myself, so I can't say whether it would), just use:
if(format ["%1",_this] == format["%1:%2 (%3)", _grp, _i, name _this]) then {_ret = true;};
In case it wasn't obvious, you might need to increase the "13" in "while {!_ret AND _i <= 13} do" to a higher number, since that limits the result to 1 to 12 (i.e. 12-man groups).
**EDIT**
Actually, what that actually does is limit the number to 1 to 14 (14-man groups) in ArmA, but that wasn't an issue in OFP so the faulty logic wasn't an problem!
-
da prob aint MP compatibilty :P heres da fix i found (dis how new file looks)
private ["_i", "_grp", "_ret"];
_ret = false;
_grp = group _this;
_i = 0;
_var = vehicleVarName _this;
_this setvehiclevarname "";
while {!_ret AND (_i < count units group _this)} do
{
_i = _i + 1;
if (format ["%1",_this] == format["%1:%2", _grp, _i]) then {_ret = true;};
if (_this == player) then {if(format ["%1",_this] == format["%1:%2 (%3)", _grp, _i, name _this]) then {_ret = true;};};
};
_this setvehiclevarname _var;
_i
i had 2 remove da vehiclevariable and return it back after it finds da vehicle...
LCD OUT
-
Well, there will be MP issues if you use the script in MP, even if you haven't had them yet ;P All you need is "isPlayer _this" rather than "_this == player" though.
You are right about the vehicle var name issue though and I can see that your solution sorts that out. I hadn't understood what you meant.
Alas, using "_i < count units group _this" won't work in OFP or ArmA, since, as I explained earlier, the current number of units in a group doesn't tell you how many it had originally. e.g. If you started off with a group of 10 men and the first 9 died, then check the group number of the 10th man, then that function will actually return 1, not 10. This is why the original author used a specific value, not the size of the group to limit the loop.
-
Alas, using "_i < count units group _this" won't work in OFP or ArmA, since, as I explained earlier, the current number of units in a group doesn't tell you how many it had originally. e.g. If you started off with a group of 10 men and the first 9 died, then check the group number of the 10th man, then that function will actually return 1, not 10. This is why the original author used a specific value, not the size of the group to limit the loop.
right... didnt actualy think bout it :D thx 4 reminding me ;) :D
LCD OUT