Jump to content

Loot event - With AI - Experimental


Recommended Posts

This script ain't perfect i'm sharing my alterations to see if there is a better way to spawn the AI.

private ["_spawnChance", "_spawnMarker", "_spawnRadius", "_markerRadius", "_item", "_debug", "_start_time", "_loot", "_loot_amount", "_loot_box", "_wait_time", "_spawnRoll", "_position", "_event_marker", "_loot_pos", "_debug_marker","_loot_box", "_hint"];

_spawnChance =  0.50; // Percentage chance of event happening
_markerRadius = 400; // Radius the loot can spawn and used for the marker
_debug = false; // Puts a marker exactly were the loot spawns

_loot_box = "RUBasicWeaponsBox";
_loot_lists = [
[
["DMR","BAF_LRR_scoped","M40A3"], 
["20Rnd_762x51_DMR","5Rnd_86x70_L115A1","5Rnd_86x70_L115A1","5Rnd_762x51_M24","5Rnd_762x51_M24","5Rnd_762x51_M24","5Rnd_762x51_M24","ItemMorphine","ItemMorphine","ItemBloodbag","ItemBloodbag","ItemPainkiller","ItemPainkiller","ItemBandage","ItemBandage","ItemBandage","ItemBandage","DZ_GunBag_EP1","ItemGoldBar10oz","Skin_Sniper1_DZ"]
],
[
["SVD","M4A3_CCO_EP1","UZI_EP1"], 
["30Rnd_9x19_UZI","30Rnd_9x19_UZI","10Rnd_762x54_SVD","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","ItemMorphine","ItemMorphine","ItemBloodbag","ItemBloodbag","ItemPainkiller","ItemPainkiller","ItemBandage","ItemBandage","ItemBandage","ItemBandage","Skin_Sniper2_DZ","DZ_GunBag_EP1"]
],
[
["M240_DZ","AK_74"], 
["30Rnd_762x39_AK47","30Rnd_762x39_AK47","HandGrenade_west","100Rnd_762x51_M240","Skin_Soldier1_DZ","revolver_gold_EP1","6Rnd_45ACP","6Rnd_45ACP","FoodmuttonCooked","ItemSodaCoke","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemMorphine","ItemMorphine","DZ_ALICE_Pack_EP1"]
],
[
["M4A1_AIM_SD_camo","G36K_camo","glock17_EP1","glock17_EP1"], 
["20Rnd_762x51_SB_SCAR","20Rnd_762x51_SB_SCAR","17Rnd_9x19_glock17","17Rnd_9x19_glock17","17Rnd_9x19_glock17","17Rnd_9x19_glock17","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","SmokeShellYellow","SmokeShellRed","SmokeShellGreen","SmokeShellPurple","SmokeShellBlue","SmokeShellOrange","FoodmuttonCooked","ItemSodaCoke","ItemBloodbag","ItemBloodbag","Skin_Camo1_DZ","Skin_Camo1_DZ"]
],
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","ItemBloodbag","ItemBloodbag","ItemBloodbag","ItemBloodbag","ItemBloodbag","ItemBloodbag","ItemBloodbag","ItemBloodbag","ItemBloodbag","ItemBloodbag","ItemEpinephrine","ItemEpinephrine","ItemEpinephrine","ItemEpinephrine","ItemMorphine","ItemMorphine","ItemMorphine","ItemMorphine","ItemMorphine","ItemMorphine","ItemMorphine","ItemMorphine","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemAntibiotic","ItemAntibiotic","ItemPainkiller","ItemPainkiller","ItemPainkiller","ItemPainkiller","SmokeShellYellow","SmokeShellRed","SmokeShellGreen","SmokeShellPurple","SmokeShellBlue","SmokeShellOrange","FoodCanPasta","FoodCanPasta","FoodCanPasta","FoodCanPasta","FoodCanPasta","FoodCanPasta","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","Skin_Rocker1_DZ","Skin_Soldier_Bodyguard_AA12_PMC_DZ"]
],
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","FoodCanPasta","FoodCanPasta","FoodCanPasta","FoodCanPasta","FoodCanPasta","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","CinderBlocks","CinderBlocks","CinderBlocks","ItemSandbag","ItemPole","ItemPole","ItemToolbox","ItemCrowbar","ItemJerrycanEmpty","ItemJerrycanEmpty","ItemJerrycanEmpty","PartGeneric","PartGeneric","PartPlankPack","PartPlankPack","PartPlankPack","PartPlankPack","MortarBucket","PartPlywoodPack","Bulk_empty"]
],
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","FoodCanPasta","FoodCanPasta","FoodCanPasta","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","CinderBlocks","CinderBlocks","ItemPole","ItemToolbox","ItemCrowbar","ItemJerrycanEmpty","ItemJerrycanEmpty","PartGeneric","PartPlankPack","PartPlankPack","PartPlywoodPack","Bulk_empty","ItemBriefcaseEmpty"]
],
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","FoodCanPasta","FoodCanPasta","ItemSodaCoke","ItemSodaCoke","CinderBlocks","ItemToolbox","ItemCrowbar","ItemJerrycanEmpty","PartGeneric","PartPlankPack","MortarBucket","PartPlywoodPack","PartWoodPlywood","PartWoodPlywood","PartWoodLumber","PartWoodLumber","PartWoodLumber","Bulk_empty"]
]
];
_loot = _loot_lists call BIS_fnc_selectRandom;

_loot_amount = 75;
_wait_time = 900; 

// Dont mess with theses unless u know what yours doing
_start_time = time;
_spawnRadius = 5000;
_spawnMarker = 'center';

if (isNil "EPOCH_EVENT_RUNNING") then {
	EPOCH_EVENT_RUNNING = false;
};

// Check for another event running
if (EPOCH_EVENT_RUNNING) exitWith {
	diag_log("Event already running");
};

// Random chance of event happening
_spawnRoll = random 1;
if (_spawnRoll > _spawnChance and !_debug) exitWith {};

// Random location
_position = [getMarkerPos _spawnMarker,0,_spawnRadius,10,0,2000,0] call BIS_fnc_findSafePos;

diag_log(format["Spawning loot event at %1", _position]);

_event_marker = createMarker [ format ["loot_event_marker_%1", _start_time], _position];
_event_marker setMarkerShape "ELLIPSE";
_event_marker setMarkerColor "ColorRed";
_event_marker setMarkerAlpha 0.5;
_event_marker setMarkerSize [(_markerRadius + 50), (_markerRadius + 50)];

_loot_pos = [_position,0,(_markerRadius - 100),10,0,2000,0] call BIS_fnc_findSafePos;

if (_debug) then {
	_debug_marker = createMarker [ format ["loot_event_debug_marker_%1", _start_time], _loot_pos];
	_debug_marker setMarkerShape "ICON";
	_debug_marker setMarkerType "mil_dot";
	_debug_marker setMarkerColor "ColorBlue";
	_debug_marker setMarkerAlpha 1;
};

diag_log(format["Creating ammo box at %1", _loot_pos]);

// Create ammo box
_loot_box = createVehicle [_loot_box,_loot_pos,[], 0, "NONE"];
clearMagazineCargoGlobal _loot_box;
clearWeaponCargoGlobal _loot_box;

// Create Defensive Squad
military = [getPos _loot_box, EAST, ["GER_Soldier_MG_EP1", "GER_Soldier_MG_EP1", "GER_Soldier_MG_EP1", "GER_Soldier_MG_EP1", "GER_Soldier_MG_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Scout_EP1"],[],[],[0.6,0.6]] call BIS_fnc_spawnGroup;
//antitank = [getPos _loot_box, EAST, ["TK_Soldier_AAT_EP1", "TK_Soldier_AAT_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Scout_EP1", "GER_Soldier_Medic_EP1", "GER_Soldier_Medic_EP1"],[],[],[0.6,0.6]] call BIS_fnc_spawnGroup;

// Cut the grass around the loot position
_clutter = createVehicle ["ClutterCutter_small_2_EP1", _loot_pos, [], 0, "CAN_COLLIDE"];
_clutter setPos _loot_pos;
// cut the grass    end

// Add loot
{
_loot_box addWeaponCargoGlobal [_x,1];
} forEach (_loot select 0);
{
_loot_box addMagazineCargoGlobal [_x,1];
} forEach (_loot select 1);

// Send message to users
[nil,nil,rTitleText,"A weapons cache has been located within the shaded area on the map, you have 15 minutes to grab the loot. - Red", "PLAIN",10] call RE;
[nil,nil,rGlobalRadio,"A weapons cache has been located within the shaded area on the map, you have 15 minutes to grab the loot. - Red"] call RE;
[nil,nil,rHINT,"A weapons cache has been located within the shaded area on the map, you have 15 minutes to grab the loot. - Red"] call RE;

diag_log(format["Loot event setup, waiting for %1 seconds", _wait_time]);

// Wait
sleep _wait_time;

// Clean up
EPOCH_EVENT_RUNNING = false;
deleteVehicle _loot_box;
deleteMarker _event_marker;
if (_debug) then {
	deleteMarker _debug_marker;
};

//Remove Squads
{deleteVehicle _x} foreach units military;
deleteGroup military;
{deleteVehicle _x} foreach units antitank;
deleteGroup antitank;

// Send message to users 
[nil,nil,rTitleText,"The Weapons Cache is gone and everything that was around is gone with it. You missed your chance.", "PLAIN",10] call RE;
[nil,nil,rGlobalRadio,"The Weapons Cache is gone and everything that was around is gone with it. You missed your chance."] call RE;
[nil,nil,rHINT,"The Weapons Cache is gone and everything that was around is gone with it. You missed your chance."] call RE;

As you can see im using Arma2 premade units found here http://community.bistudio.com/wiki/ArmA_2_OA:_Infantry it works, but obviously get various errors regarding their loadouts.

 

Any ideas on the best way to have an AI patrol protect the lootbox?

Link to comment
Share on other sites

I think it's possible. The parachute is a vehicle of sorts, from what I read a good while back, is an object can be fixed to using attachTo.

Have been in a server Wher a hacker spawned in hundreds of cows parachuting from the sky.. a bizarre sight..

I've seen that one, must admit, it's kinda funny

 

Bags

Link to comment
Share on other sites

Hi all,

 

I contacted "Buttface" the creator of DZAI (Bandit AI) https://github.com/dayzai/DayZBanditAI which I must say is the best AI.

 

He quoted:

"About your situation, any AI spawned using non-DZAI functions won't be related to or managed by DZAI at all. If you want to ensure the AI spawn on ground and not in air, break your code into these parts:

_spawnPos = getPosATL _loot_box; //Using getPosATL because it's 2x faster than getPos
_spawnPos set [2,0]; //Forces z coordinate (height) to zero
military = [_spawnPos , EAST, 20] call BIS_fnc_spawnGroup;

If you want to use DZAI-managed units you can call fnc_createGroup like this:

_spawnPos = getPosATL _loot_box; //Using getPosATL because it's 2x faster than getPos
_spawnPos set [2,0]; //Forces z coordinate (height) to zero
military = [1,grpNull,_spawnPos,objNull,2] call fnc_createGroup;

The 1 is the number of AI units to spawn, the 2 is the weapongrade value. Leave the two null values alone. I haven't ever tested using the fnc_createGroup function independently so I have no idea what are the side effects of doing so."

 

I have tested the second option as I do use DZAI and it works beautifully and its AMAZING. Put 15 AI with weapon grade 3 and they are hardcore.

 

Hope this helps

Link to comment
Share on other sites

Thats how I did it in the end.

 

 

 

How was this achieved, I've got the standard :

Looters = [getPos _loot_box, EAST, 10] call BIS_fnc_spawnGroup;

But would love to have the ability to customise them like in axeman's Cherno Mission AI. I tried running the add_unit_server.sqf's directly but it wasn't very impressed by this attempt. The above spawns in 10 random CDF infantry but ideally I would like to pick and choose equipment, give backpacks and perhaps add an Ai vehicle to provide top cover for them. Although I could add a static Kord or something for them if they would use it. 

Link to comment
Share on other sites

I basically used the mission system spawn AI functions, created another add unit sqf and customised it for my self, then called the AI that way same as in the missions.

//Spawn Ai
_aispawn = [_loot_pos,80,6,6,1] execVM "\z\addons\dayz_server\missions\add_unit_server_event.sqf";//AI Guards
sleep 5;

Link to comment
Share on other sites

Hmmm I take I would, after installing the AI pack just use the call in Snstr86's post then? Think I'll give that a go, I've always used Sarge but this particular server doesn't really require that sort of customisation. 

 

Does DayZAI use vehicles or statics or is it just limited to foot and heli's?

Link to comment
Share on other sites

Yep all works in the Epoch Event also changed the AI in the Chernarus mission pack to use the DayZAI all works very well.

 

Only issue I have is when you kill the AI and put a couple rounds into their corpses they tend to re-animate the death sequence and sometimes use the newly added unconscious animation after being killed.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

ive tried a few different suggestions as to get AI in with my missions and all it does it break them i get no anouncment any more and the loot pile doesnt spawn. i just get a colored circle placed on the map. running Sarge AI, and i would love to have AI at my missions as my players are asking for it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...