Hi,
Ive been plating around creating a new profile from script and assignin it an activeCommand.
The profiles are spawning ok on start and assuming their roles as desired. So I guess params are being passed ok to Alive fnc.
I'm just using this modules: Virtual Ai System, Alive required and Player Options.
This is the fnc i'm using:
params ["_comm","_pat_area","_g_mrkr","_g_type","_g_size","_g_ia","_g_rinf"];
private _g_side = format ["%1",_comm getVariable "side"];
private _c_faction = _comm getVariable "faction";
private _g_pos = markerpos _g_mrkr;waitUntil {!isNil "ALIVE_profileSystemInit"};
private _g_units = call compile format ["%1_%2_%3", _c_faction, _g_type, _g_size];
private _g_faction = call compile format ["%1_FACTION", _c_faction];private _g_profile = [_g_units, _g_side, _g_faction, _g_pos] call ALIVE_fnc_createProfileEntity;
private _g_profile_id = [_g_profile, "profileID"] call ALIVE_fnc_hashGet;waitUntil {sleep 0.03; !isNil "_g_profile_id"};
switch (_g_ia) do {
case "BASE_GUARD": {
[_g_profile, "setActiveCommand", ["ALIVE_fnc_garrison","spawn",[25,"false"]]] call ALIVE_fnc_profileEntity;
};
case "BASE_PATROL": {
[_g_profile, "setActiveCommand", ["ALIVE_fnc_ambientMovement","spawn",[150,"SAFE"]]] call ALIVE_fnc_profileEntity;
};
default {};
};if (!_g_rinf) exitWith {};
while {
_g_profile_id in ([ALIVE_profileHandler, "getProfilesBySide", _g_side] call ALIVE_fnc_profileHandler)
} do {
sleep 10;
};sleep 10;
[_comm,_pat_area,_g_mrkr,_g_type,_g_size,_g_ia,_g_rinf] spawn grp_spawn;
I can check if the profile is alive or not, as soon it gets unregistered I should be able to re-create it (in the example im removing all conditions like player distance to base, or side control, etc, just existence of the profile)
So, here's the problem.
I kill the spawned groups, it gets unregistered, and the while-do loop gets its time to recreate it. The new iteration of the function creates the profile in its starting position and then teleport it to [0,0,0]. Shouldn't it work like in the first iteration?
Im having an additional error sometimes when groups spawn/despawn by player distance, the profile gets unregistered and tries to recreate (of this get me to the first problem).
This the error it shows in RPT:
10:41:00 Error in expression < (_units select 0));
_units = _units - [_leader];if (count _units == 0) exitwi>
10:41:00 Error position: <_leader];if (count _units == 0) exitwi>
10:41:00 Error Undefined variable in expression: _leader
10:41:00 File x\alive\addons\x_lib\functions\behaviour\fnc_groupGarrison.sqf, line 40
Any help, please? Or is it just this can't be done?
Thx in advance.
B.