Hi ferstaberinde,
I've been makindg some small missions with BASf for the last few weeks and I have a question about the FIFO body remover sqf.
A key limitation of this component is that it cannot automatically add the event handler to
units which are created dynamically during the mission (for example, if you use a script to
generate enemies or civilians dynamically). However, you can add the event handler by
ensuring that any dynamically-created units have the following code in their Init: line:
this addEventHandler ["killed",
{
if (local BAS_Server_Logic) then
{
f_abrFIFO = f_abrFIFO + [_this select 0];
} else
{
_this execVM "f\common\f_abrAddToFIFO.sqf"
};
}];
I'm creating AI throughout the mission with arrays and "call compile and create".
this is one of the arrays:
_embsyUSMCrt = createGroup west;
_ebassySec_setup = [];
//[["unit name", [create unit array], setdir, ["disableAI"], "setUnitPos", allowFleeing, "setBehavior", [final pos],]];
//************************USMC Rooftop snipers**************************************
_ebassySec_setup = _ebassySec_setup + [["eUSMCrt",["ACE_USMC0302",getPos USMC,[],0,"seargent"],270,["MOVE","TARGET"],"up",0,"AWARE",[5072,6527.25,36.8],"_embsyUSMCrt"]];
_ebassySec_setup = _ebassySec_setup + [["eUSMCrt1", ["ACE_USMC0302",getPos USMC,[],0,"seargent"],90,["MOVE","TARGET"],"up",0,"AWARE",[5086.58,6526.51,36.8],"_embsyUSMCrt"]];
{
//Create your unit in group _embsyUSMCrt with createUnit array.
call compile format["%1 = %2 createUnit %3;",_x select 0,_x select 8,_x select 1];
//Assign your unit to the group _embsyUSMCrt.
call compile format["[%1] join %2;", _x select 0,_x select 8];
//Set unitys INIT field
call compile format["%1 setVehicleInit ""%1 = this;"";",_x select 0];
//Set the direction your unit faces when created.
call compile format["%1 setDir %2;", _x select 0, _x select 2];
//Disable unit atributes. "MOVE" ,"TARGET" ,"AUTOTARGET" , and"ANIM".
_disableAINumElements = count (_x select 3);
for [{_i = 0}, {_i < _disableAINumElements}, {_i = _i + 1}] do {
call compile format["%1 disableAI ""%2"";", _x select 0, (_x select 3) select _i];
};
//Set stance of unit you created. "UP", "DOWN", and "MIDDLE".
if ((_x select 4) != "") then {
call compile format["%1 setUnitPos ""%2"";", _x select 0, _x select 4];
};
//Sets the level of courage you unit has. 0-1, "0" max courage. "1" min courage and runs at the sight of emeny.
call compile format["%1 allowFleeing %2;", _x select 0, _x select 5];
//Checks if element 7 is empty. If not then set units behavior to whats entered.
if ((_x select 6) != "") then {
call compile format["%1 setBehaviour %2;", _x select 0, _x select 6];
};
//Sets unit in final position ready to fight.
call compile format["%1 setPos %2;", _x select 0, _x select 7];
} foreach _ebassySec_setup;
//selects leader of given group.
call compile format["_embsyUSMCrt selectLeader %1;", (_ebassySec_setup select 0) select 0];
_ebassySec_setup;
I know the setVehicleInit command, but every time I try to use it in this script I get all kinds of errors. I know it has to to do with the "quotes".
This is what I think it should be:
call compile format["%1 setVeicleInit ""this addEventHandler [""killed"",
{
if (local BAS_Server_Logic) then
{
f_abrFIFO = f_abrFIFO + [_this select 0];
} else
{
_this execVM ""f\common\f_abrAddToFIFO.sqf""
};
}];"";", _x select 0];
Anyone have any thoughts?