Jump to content
JerryAtricks

Adding Friendly AI? *SOLVED*

Recommended Posts

Hey guys!

I'm trying to add a few Blufor AI to my base, hoping they would be friendly, but they shoot me on sight. I'm assuming it's because the player character isn't Blufor? Does anyone know how to get the AI to recognize friendlies? Should I be using a different faction? Or is there something I need  to do with the player character?

Share this post


Link to post
Share on other sites
6 hours ago, Sgt Smash said:

Independent green should work

 

Hey! That worked! Thanks! But I have another problem. When the AI spawn in, they're spawning in doubled. In other words, I have 4 spawning, but I get 8. I don't see in the code where it states how many spawn in, or maybe I'm overlooking it? 

Here's the code:

Spoiler

// Export of 'PN_Guards.Altis' by JerryAtricks on v0.9

///////////////////////////////////////////////////////////////////////////////////////////
// Init
params [["_layerWhiteList",[],[[]]],["_layerBlacklist",[],[[]]],["_posCenter",[0,0,0],[[]]],["_dir",0,[0]],["_idBlacklist",[],[[]]]];
private _allWhitelisted = _layerWhiteList isEqualTo [];
private _layerRoot = (_allWhitelisted || {true in _layerWhiteList}) && {!(true in _layerBlackList)};


///////////////////////////////////////////////////////////////////////////////////////////
// Groups
private _groups = [];
private _groupIDs = [];

private _item38 = grpNull;
if (_layerRoot) then {
    _item38 = createGroup resistance;
    _this = _item38;
    _groups pushback _this;
    _groupIDs pushback 38;
};

private _item41 = grpNull;
if (_layerRoot) then {
    _item41 = createGroup resistance;
    _this = _item41;
    _groups pushback _this;
    _groupIDs pushback 41;
};

private _item42 = grpNull;
if (_layerRoot) then {
    _item42 = createGroup resistance;
    _this = _item42;
    _groups pushback _this;
    _groupIDs pushback 42;
};

private _item44 = grpNull;
if (_layerRoot) then {
    _item44 = createGroup resistance;
    _this = _item44;
    _groups pushback _this;
    _groupIDs pushback 44;
};


///////////////////////////////////////////////////////////////////////////////////////////
// Objects

private _item37 = objNull;
if (_layerRoot) then {
    _item37 = _item38 createUnit ["O_G_Soldier_AR_F",[17806.2,14371.4,4.358],[],0,"CAN_COLLIDE"];
    _item38 selectLeader _item37;
    _this = _item37;
    _objects pushback _this;
    _objectIDs pushback 37;
    _this setPosWorld [17806.2,14371.4,18.4816];
    _this setVectorDirAndUp [[0,1,0],[0,0,1]];
    _this setSkill 1;
    _this setRank "CORPORAL";
    _this setUnitPos "UP";
    _this setname "Juan Epstein";;
    _this setface "GreekHead_A3_03";;
    _this setspeaker "Male04GRE";;
    _this setpitch 0.99;;
};

private _item40 = objNull;
if (_layerRoot) then {
    _item40 = _item41 createUnit ["B_G_Soldier_A_F",[17809.2,14371.3,4.362],[],0,"CAN_COLLIDE"];
    _item41 selectLeader _item40;
    _this = _item40;
    _objects pushback _this;
    _objectIDs pushback 40;
    _this setPosWorld [17809.2,14371.4,18.4817];
    _this setVectorDirAndUp [[0,1,0],[0,0,1]];
    _this setSkill 1;
    _this setRank "CORPORAL";
    _this setUnitPos "UP";
    _this setname "Arnold Horshack";;
    _this setface "Mavros";;
    _this setspeaker "Male06GRE";;
    _this setpitch 1.01;;
};

private _item43 = objNull;
if (_layerRoot) then {
    _item43 = _item42 createUnit ["O_G_Soldier_AR_F",[17809.4,14332.4,12.509],[],0,"CAN_COLLIDE"];
    _item42 selectLeader _item43;
    _this = _item43;
    _objects pushback _this;
    _objectIDs pushback 43;
    _this setPosWorld [17809.4,14332.5,26.7143];
    _this setVectorDirAndUp [[0,1,0],[0,0,1]];
    _this setSkill 1;
    _this setRank "CORPORAL";
    _this setUnitPos "UP";
    _this setname "Vinnie Barbarino";;
    _this setface "GreekHead_A3_01";;
    _this setspeaker "Male06GRE";;
    _this setpitch 1;;
};

private _item45 = objNull;
if (_layerRoot) then {
    _item45 = _item44 createUnit ["O_G_Soldier_AR_F",[17788.7,14355.1,12.4231],[],0,"CAN_COLLIDE"];
    _item44 selectLeader _item45;
    _this = _item45;
    _objects pushback _this;
    _objectIDs pushback 45;
    _this setPosWorld [17788.7,14355.1,26.7127];
    _this setVectorDirAndUp [[0,1,0],[0,0,1]];
    _this setSkill 1;
    _this setRank "CORPORAL";
    _this setUnitPos "UP";
    _this setname "Freddie 'Boom Boom' Washington";;
    _this setface "Ioannou";;
    _this setspeaker "Male04GRE";;
    _this setpitch 0.97;;
};


///////////////////////////////////////////////////////////////////////////////////////////
// Group attributes (applied only once group units exist)
_this = _item38;
if !(units _this isEqualTo []) then {
    [_this,0] setWaypointPosition [position leader _this,0];
    [_this, "Alpha 1-1"] call CBA_fnc_setCallsign;
};
_this = _item41;
if !(units _this isEqualTo []) then {
    [_this,0] setWaypointPosition [position leader _this,0];
    [_this, "Alpha 1-2"] call CBA_fnc_setCallsign;
};
_this = _item42;
if !(units _this isEqualTo []) then {
    [_this,0] setWaypointPosition [position leader _this,0];
    [_this, "Alpha 1-3"] call CBA_fnc_setCallsign;
};
_this = _item44;
if !(units _this isEqualTo []) then {
    [_this,0] setWaypointPosition [position leader _this,0];
    [_this, "Alpha 1-4"] call CBA_fnc_setCallsign;
};


///////////////////////////////////////////////////////////////////////////////////////////
// Inits (executed only once all entities exist; isNil used to ensure non-scheduled environment)
isNil {
};


///////////////////////////////////////////////////////////////////////////////////////////
// Module activations (only once everything is spawned and connected)


///////////////////////////////////////////////////////////////////////////////////////////
[[_objects,_groups,_triggers,_waypoints,_logics,_markers],[_objectIDs,_groupIDs,_triggerIDs,_waypointIDs,_logicIDs,_markerIDs]]
 

 

Share this post


Link to post
Share on other sites

Figured it out! Turns out I had to execute the script like this:

 

if (isServer) then { execVM "scriptfile.sqf"; };

 

Now it works fine. 🙂

Share this post


Link to post
Share on other sites

×