orcthrasher
Well-Known Member
This is the bit I'm stuck on.. I don't understand how it works.. What do I change to spawn both bandits and survivors and how do I ensure only bandits spawn at NWA and survivors at Cherno for example? Sorry for the dumb question, it's just at the moment I'm not sure whether its spawning all bandits or a mixture, I mean is it just random?
Oh and when you've got the bus script working, I'll gladly make a small donation if you share it![]()
I have good guys and bad guys - with TK skins and BAF skins (and different weapons and skill levels). They all shoot zombies. This is how I hacked it together (and it can be imporoved, but I was trying to just go for basic function testing).
Add this line to your init.sqf under factions:
Code:
waitUntil{initialized};
//0Day
createCenter east;
createCenter resistance;
//Survivors
WEST setFriend [RESISTANCE,0];
WEST setFriend [EAST,0];
//Bandits
EAST setFriend [RESISTANCE,0];
EAST setFriend [WEST,0];
//AI Units
RESISTANCE setFriend [WEST,0.6];
RESISTANCE setFriend [EAST,0];
RESISTANCE setFriend [CIVILIAN,0];//AI Units attack zeds
EAST setFriend [CIVILIAN,0];//AI Units attack zeds // <---- THIS LINE FOR BANDITS TO ATTACK ZEDS
CIVILIAN setFriend [RESISTANCE,0];//Zeds attack Hero units
CIVILIAN setFriend [EAST,0];//Zeds attack Bandit units
Then, you can either modify your add_unit_server to accept a bandit/hero parameter to change the center, or just (like I did for testing) duplicate it.
Code:
//add_unit_server_bandit.sqf
private["_aiunit","_xpos","_ypos","_unitpos","_aiGroup","_wppos","_wpradius","_wpnum","_numunits","_rndLOut","_ailoadout","_aiwep","_aiammo","_wp","_aispawnpos"];
_aiunit = objNull;
_aiGroup = createGroup EAST; // <----THIS MAKES THEM HATE PLAYERS!
_aispawnpos =_this select 0;
_wpradius = _this select 1;
_wpnum = _this select 2;
_numunits = _this select 3;
_xpos = _aispawnpos select 0;
_ypos = _aispawnpos select 1;
diag_log format ["AIUNIT: Spawn initiated: Centre:%1 | Radius in m:%2 | Waypoint number:%3",_aispawnpos,_wpradius,_wpnum];
for [{ x=1 },{ x < _numunits+1 },{ x = x + 1; }] do {
_unitpos = [_xpos+x,_ypos+x,0];
//Generate what the main weapon and ammo will be
_rndLOut=floor(random 8);
_ailoadout=
switch (_rndLOut) do
{
case 0: {["LeeEnfield","10x_303"]};
case 1: {["AKS_74U","30Rnd_545x39_AK"]};
case 2: {["AK_74","30Rnd_545x39_AK"]};
case 3: {["AKS_74_kobra","30Rnd_545x39_AK"]};
case 4: {["AK_47_M","30Rnd_762x39_AK47"]};
case 5: {["Winchester1866","15Rnd_W1866_Slug"]};
case 6: {["MP5A5","30Rnd_9x19_MP5"]};
case 7: {["huntingrifle","5x_22_LR_17_HMR"]};
};
//Generate what the sidearm and ammo will be
_rndLOut=floor(random 3);
_aiside=
switch (_rndLOut) do
{
case 0: {["UZI_EP1","15Rnd_9x19_M9"]};
case 1: {["Makarov","8Rnd_9x18_Makarov"]};
case 2: {["revolver_EP1","6Rnd_45ACP"]};
};
//Generate what the equipment will be - it's likely to be antibiotics, but maybe.... :)
_rndLOut=floor(random 7);
_aiequipspawn=
switch (_rndLOut) do
{
case 0: {["Binocular_Vector"]};
case 1: {["ItemGPS"]};
case 2: {["ItemMap"]};
case 3: {["ItemCompass"]};
case 4: {["ItemWatch"]};
case 5: {["NVGoggles"]};
case 6: {["Binocular"]};
};
"TK_INS_Soldier_EP1" createUnit [_unitpos, _aiGroup, "_aiunit=this;",0.6,"Private"];
diag_log format ["AIUNIT: Creating TK_INS_Soldier_EP1 by %1 at %2. Result:%3 | Loadout:%4 / Num:%5",player,_unitpos,_aiunit,_ailoadout,_rndLOut];
_aiunit enableAI "TARGET";
_aiunit enableAI "AUTOTARGET";
_aiunit enableAI "MOVE";
_aiunit enableAI "ANIM";
_aiunit enableAI "FSM";
_aiunit allowDammage true;
_aiunit setCombatMode "RED";
_aiunit setBehaviour "COMBAT";
//clear default weapons / ammo
removeAllWeapons _aiunit;
removeAllItems _aiunit;
//add random selection
_aiwep = _ailoadout select 0; //Main Weapon
_aiammo = _ailoadout select 1; // Main Weap Ammo
_aisidearm = _aiside select 0; //Sidearm
_aisidearmammo = _aiside select 1; //Sideaerm Ammo
_aigear = _aiequipspawn select 0; //Equipment
_aiunit addweapon _aiwep;
_aiunit addMagazine _aiammo;
_aiunit addMagazine _aiammo;
_aiunit addMagazine _aiammo;
_aiunit addMagazine _aiammo;
_aiunit addMagazine _aiammo;
_aiunit addMagazine _aiammo;
_aiunit addMagazine _aiammo;
_aiunit addMagazine _aiammo;
// Add sidearm and mags
_aiunit addweapon _aisidearm;
_aiunit addMagazine _aisidearmammo;
_aiunit addMagazine _aisidearmammo;
_aiunit addMagazine _aisidearmammo;
// add gear
_aiunit addWeapon _aigear;
//_aiunit addMagazine _aigear;
//set skills
_aiunit setSkill ["aimingAccuracy",0.25];
_aiunit setSkill ["aimingShake",0.25];
_aiunit setSkill ["aimingSpeed",0.25];
_aiunit setSkill ["endurance",0.25];
_aiunit setSkill ["spotDistance",0.24];
_aiunit setSkill ["spotTime",0.3];
_aiunit setSkill ["courage",0.3];
_aiunit setSkill ["reloadSpeed",0.25];
_aiunit setSkill ["commanding",0.25];
_aiunit setSkill ["general",0.25];
sleep 0.5;
} ;
//generate waypoints
for [{ x=1 },{ x < _wpnum },{ x = x + 1; }] do {
_wppos = [_xpos+(x*20),_ypos+(x*20),_wpradius];
_wp = _aiGroup addWaypoint [_wppos, _wpradius];
_wp setWaypointType "MOVE";
};
_wp = _aiGroup addWaypoint [[_xpos,_ypos,0], _wpradius];
_wp setWaypointType "CYCLE";
diag_log format ["AIUNIT: Last Waypoint %1 at %2",_wp,_wppos];
Now, call them from your chernarus mission init.sqf the same way, and choose if you want to spawn a bandit or soldier.
Code:
_aispawn = [[4780.92,2500.74,0.001],20,1,5] execVM "units\add_unit_server.sqf";//Balota
_aispawn = [[4703.12,2525.5,0.001],20,1,5] execVM "units\add_unit_server_Bandit.sqf";//Balota
I still need to change the equipment loadout - those items are addWeapons, but I think medical supplies and blood bags are addMagazine. I was fucking around with them until like 5AM.
Also, the select case is no good; I want to have like a ran(100) and have it select a map if the output is > 10, select compass if > 25... all the way up to NVGs/GPS/Rangefinders if like > 95 - just to make sure that they're still kind of rare. Haven't figured out how to do that in this scripting language yet