Loot drop event based on sensors?

Inkko

Valued Member!
I always come up with random ideas and end up dropping them haha... but not this time!

Oh ya and this idea is for dayz 1.8.5

I was thinking about something like an event for players, not like the crash sites how they'll randomly spawn around the map, but more like an area specific event for the player activating it and nearby players.

So here is what I got basically:

mission.sqm has sensors in a couple cities that cover about 1km. When a player enters the zone it'll run a script. The player will generate a random number and if its less then a certain number it'll continue. If the event in that area has already been done then it'll exit the script. (someone could find the edge of the zone and repeatedly enter and leave till it spawns but highly doubt someone would find the edge)

Trying to figure out what I want the event(s) to be... but at the moment I have randomized loot crate types (medical,military,food *also have vehicles with working hive write instead of a box) that parachute in that are spawned within 100-1000m of the activating player. A smoke is attached to the box to make it more visible while the parachute is dropping for those in the area. A message is broadcast to all players about which city the event is happening and what type of loot it offers.


What do you all think about this idea? Or have any suggestions on what the event should have or things i should do differently with it?
 
XkEzILE.jpg
QoOOjuc.jpg


the box looks kinda lame compared to the parachute... but not really anything bigger available with 1.8.5...
 
Anyone know if it'd be better to make this all server side with a mission side trigger? That way its not the activating player that is handling the whole script?
 
What would be the best way to make a sensor for someone entering the area? Just use a sensor in the mission.sqm and broadcast a PV that'll start the script server side?
most likely, otherwise you can make an sqf that's local that activates within certain distances of certain coords, wouldnt be too performance heavy as it wouldnt take much to send a pub var within a certain distance
 
most likely, otherwise you can make an sqf that's local that activates within certain distances of certain coords, wouldnt be too performance heavy as it wouldnt take much to send a pub var within a certain distance
At the moment I already have the full script completed now... but then I thought about it and was like "hmmm... the activating player is having to do all this... maybe i should make it serverside somehow". So i guess I'll try and figure out how to get it to work server side. This is the code that I have so far minus the sensors that just send a location name for now.

Code:
/*---------------------Config--------------------------*/
_eventchance = 10;
_eventrandomnumber = 100;
// if random number between 0 and _eventrandomnumber is less then _eventchance. Start event

/*----------------------Loot---------------------------*/
// all weapons in list put into loot crate; 1 of each.
DZES_Weapons = ["M4A1_AIM_SD_camo","M24","MP5A5","M40A3","MakarovSD","M4A1_HWS_GL_SD_Camo","G36K","AK_74_GL","AK_107_pso","M4A3_RCO_GL_EP1","AK_107_kobra","AK_107_GL_kobra","RPK_74"];
// all magazines in list put into loot crate; 10 of each
DZES_Magazines = ["30Rnd_556x45_StanagSD","30Rnd_556x45_Stanag","30Rnd_556x45_G36","30Rnd_545x39_AK","75Rnd_545x39_RPK","5Rnd_762x51_M24","5Rnd_762x51_M24","30Rnd_9x19_MP5","1Rnd_HE_GP25"];
// all food and drink in list put into loot crate; 5 of each
DZES_FoodnDrink = ["FoodCanPasta","FoodCanBadguy","FoodCanBoneboy","FoodCanCorn","FoodCanCurgon","FoodCanDemon","FoodCanFraggleos","FoodCanBeef","ItemWaterbottleUnfilled","ItemWaterbottle","ItemWaterbottleDmg","ItemSodaLirik","ItemSodaPeppsy"];
// all medical supplies in list put into loot crate; 5 of each
DZES_Medical = ["ItemBandage","ItemPainkiller","ItemMorphine","ItemEpinephrine","ItemAntibacterialWipe","ItemAntibiotic","emptyBloodBag","bloodBagOPOS","equip_gauze","bloodTester","transfusionKit"];
// For DZES_Weapons,DZES_Magazines,DZES_FoodnDrink and DZES_Medical. If you double up items in the array it will double the ammount of given item when adding it to box.


// random vehicle will parachute in; writes to the hive so the player can keep the vehicle forever.
DZES_Vehicles = ["MH6J_DZ","UH1H_DZ","HMMWV_DZ","UralCivil"];
// For DZES_Vehicles, duplicate vehicles in the list will increase the chance of that vehicle being chosen.

/*-----------------Object Customization------------------*/
// smoke shell type (random or name of smoke)
DZES_SmokeType = "random"; //DZES_SmokeType = "SmokeShellRed";
// add different smoke colors for random array.
DZES_SmokeColors = ["SmokeShellRed","SmokeShellYellow","SmokeShellGreen","SmokeShellPurple","SmokeShellBlue","SmokeShellOrange"];
//parachut type
DZES_ParaType = "ParachuteMediumEast";

/*-------------------------------------------------------*/
/*Don't change below here unless u know what u are doing */
/*-------------------------------------------------------*/

//get location passed from sensor
_location = _this select 0;

//variable defines (if you use more sensors add more variables)
if (isnil "eventcherno") then {
eventcherno = false;
};

if (isnil "eventelektro") then {
eventelektro = false;
};

if (isnil "eventberezino") then {
eventberezino = false;
};

//event completed check, exits if the event has been done. (if you use more sensors add more)
if ((_location == "Berezino") && eventberezino) exitwith {diag_log 'DZES: event already completed';};
if ((_location == "Cherno") && eventelektro) exitwith {diag_log 'DZES: event already completed';};
if ((_location == "Elektro") && eventcherno) exitwith {diag_log 'DZES: event already completed';};

//create percentage properties for event start or skip.
_eventrng = round (random _eventrandomnumber);
if (_eventrng > _eventchance) exitwith {diag_log 'DZES: Event chance failed';};

//smoke color
if (DZES_SmokeType == "random") then {
DZES_Smoke = DZES_SmokeColors call BIS_fnc_selectRandom;
} else {
DZES_Smoke = DZES_SmokeType;
};

// WIP Random Loot 40|40|20 food|medical|military
_loottype = ["Medical","Food","Medical","Food","Military","Vehicle","Vehicle"] call BIS_fnc_selectRandom;

//get position for event
_position = getPos player;
_nearbyposition = [_position, 100, 400, 20, 0, 0, 0] call BIS_fnc_findSafePos; //event within 100-1000m of activating player
_eventposition = [(_nearbyposition select 0), (_nearbyposition select 1), 100];

//Vehicle check for alternate setup
if (_loottype == "Vehicle") then {
_randomvehicle = DZES_Vehicles call BIS_fnc_selectRandom;

//double check that vehicle is in DayZ_SafeObjects so that it can be written to the hive.
if (!(_randomvehicle in DayZ_SafeObjects)) then {
DayZ_SafeObjects = DayZ_SafeObjects + [_randomvehicle];
publicVariable "DayZ_SafeObjects";
};

eventcrate = createVehicle [_randomvehicle, _eventposition, [], 0, "CAN_COLLIDE"];

//additional setup to write vehicle to hive and make it not blow up
_dir = getdir eventcrate;
PVDZ_obj_Publish = [0,eventcrate,[_dir,_eventposition],[]];
publicVariableServer "PVDZ_obj_Publish";
} else {
// box for other loot types
eventcrate = "AmmoBoxBig" createVehicle _eventposition;
};

//event setup
_eventpara = createVehicle [DZES_ParaType, _eventposition, [], 0, "FLY"];
_eventsmoke = createVehicle [DZES_Smoke, _eventposition, [], 0, "FLY"];

//clear event crate
clearWeaponCargoGlobal eventcrate;
clearMagazineCargoGlobal eventcrate;

//attach smoke to crate
_eventsmoke attachto [eventcrate, [0,0,0]];

/*-------------------
    Crate Setup
-------------------*/

//Military
if (_loottype == "Military") then {
{eventcrate addWeaponCargoGlobal [_x,1]} foreach DZES_Weapons;
{eventcrate addMagazineCargoGlobal [_x,10]} foreach DZES_Magazines;
};

//Food
if (_loottype == "Food") then {
{eventcrate addMagazineCargoGlobal [_x,5]} foreach DZES_FoodnDrink;
};

//Medical
if (_loottype == "Medical") then {
{eventcrate addMagazineCargoGlobal [_x,5]} foreach DZES_Medical;
};

//attach crate to chute
if (_loottype == "Vehicle") then {
eventcrate attachTo [_eventpara, [0,0,-1.6]];
} else {
eventcrate attachTo [_eventpara, [0,0,.3]];
};

// detach object before ground
[_eventpara,eventcrate,_eventsmoke] spawn {
_para = _this select 0;
_object = _this select 1;
_smoke = _this select 2;

_dropping = true;
while {_dropping} do {
_pos = getpos _object;
// .4m above ground is about right for vehicles and boxes since it detaches shortly after hitting that point.
if ((_pos select 2) < .4) then {
_dropping = false;
};
};
waituntil {!_dropping};
detach _object;
deletevehicle _para;
deletevehicle _smoke;
//create secondary somke for better visibility for short period of time
_pos = getpos eventcrate;
_eventsmoke2 = createVehicle [DZES_Smoke, _pos, [], 0, "FLY"];
_eventsmoke2 attachto [eventcrate, [0,0,0]];
uisleep 30;
deletevehicle _eventsmoke2;
};


// getname of vehicle and send out message to all players on type of loot and general location
if (_loottype == "Vehicle") then {
_veh = typeOf eventcrate;
_loottype = getText (configFile >> 'CfgVehicles' >> _veh >> 'displayName');
[nil,nil,rTitleText,format["A carepackage with a %2 has been dropped near %1, find it before anyone else!",_location,_loottype], "PLAIN",20] call RE;
} else {
[nil,nil,rTitleText,format["A carepackage with %2 supplies has been dropped near %1, find it before anyone else!",_location,_loottype], "PLAIN",20] call RE;
};

//event completed, set variable true and broadcast. (if you use more sensors add more)
if ((_location == "Berezino") && !eventberezino) then {eventberezino = true; publicVariable "eventberezino";diag_log 'DZES: Event started, Berezino true.';};
if ((_location == "Elektro") && !eventelektro) then {eventelektro = true; publicVariable "eventelektro";diag_log 'DZES: Event started, Elektro true.';};
if ((_location == "Cherno") && !eventcherno) then {eventcherno = true; publicVariable "eventcherno";diag_log 'DZES: Event started, Cherno true.';};
 
I haven't really done much with sensors but would it be possible to have some statements and checks in the activation portion of the script?

Code:
class Item1
        {
            position[]={6901,0,2509};  // database cords, xyz
            a=1000;
            b=1000;
            activationBy="ANY";
            repeating=1;  // every one who enters the area after this spawns an additional horde
            interruptable=1;
            age="UNKNOWN";
            name="EventTriggerCherno";
            expCond="(vehicle player) in thislist;";
            expActiv="_number = round (random 100); if (_number < 10) then {EventCherno = [player,""Cherno""];publicVariable ""EventCherno"";};";
            expDesactiv="";
            class Effects
            {
            };
        };

Nvm had time to test it and something like that does work, so I have a way to broadcast the PV now without having to execute a script on the player. So I'll try and finish up the script and make it server side and add all the mission side stuff into a file.

*it worked one time and hasn't worked since...
 
Last edited:
I haven't really done much with sensors but would it be possible to have some statements and checks in the activation portion of the script?

Code:
class Item1
        {
            position[]={6901,0,2509};  // database cords, xyz
            a=1000;
            b=1000;
            activationBy="ANY";
            repeating=1;  // every one who enters the area after this spawns an additional horde
            interruptable=1;
            age="UNKNOWN";
            name="EventTriggerCherno";
            expCond="(vehicle player) in thislist;";
            expActiv="_number = round (random 100); if (_number < 10) then {EventCherno = [player,""Cherno""];publicVariable ""EventCherno"";};";
            expDesactiv="";
            class Effects
            {
            };
        };

Nvm had time to test it and something like that does work, so I have a way to broadcast the PV now without having to execute a script on the player. So I'll try and finish up the script and make it server side and add all the mission side stuff into a file.

*it worked one time and hasn't worked since...
it would be easier to do this in sqf format
 
it would be easier to do this in sqf format
scratch that it was working with everything in the sensor I just misnamed and didn't have the right file path for the server side script. So I have the sensors that handle stuff, have a couple variables in the init.sqf. Then server side I have a publicvariableeventhandler that does the server side stuff. Once it reaches the server tho and runs the script nothing seems to be occuring... but the RPT output shows that the variables are correct when it reaches the script, just nothing happens. "17:25:32 "DZES: [12040.1,9094.62,0.00144196] | Berezino"" (cordinates of player and location area to make it so the same area can't spawn again).

So I'm guessing the mission side script I created doesn't work server side. Is there anything noticeably different between the 2 that would make it not work?
 
scratch that it was working with everything in the sensor I just misnamed and didn't have the right file path for the server side script. So I have the sensors that handle stuff, have a couple variables in the init.sqf. Then server side I have a publicvariableeventhandler that does the server side stuff. Once it reaches the server tho and runs the script nothing seems to be occuring... but the RPT output shows that the variables are correct when it reaches the script, just nothing happens. "17:25:32 "DZES: [12040.1,9094.62,0.00144196] | Berezino"" (cordinates of player and location area to make it so the same area can't spawn again).

So I'm guessing the mission side script I created doesn't work server side. Is there anything noticeably different between the 2 that would make it not work?
I dont see anything blatantly obvious, I would set up some diag_log's every so often and see where the script actually stops or breaks
 
I would have thought that the script would throw an error or something if it stopped at some point.. but nothing. I setup a bunch of diag_logs throught the file so I can see what its doing step by step and where it is stopping. Also made some changes so maybe that'll fix the issues.
 
Finally got it working. Still needs some work, but it'll work once then not again no matter what sensor is triggered... so just something I messed up somewhere with it thinking the events are all triggered after only one is or maybe something else that is stopping it.

Well... I feel stupid on why it was only working once haha... i had exitwiths that were exiting if a variable came back true when it was suppose to be the variable + the location name. I'll probably make a release once I test it all out and make sure its running okay.
 
Last edited:
Well i dunno why but I got it all setup for server side, its still a little buggy but the parachute just isn't being created. Nothing in the RPT about it as well. Test it mission side and it works perfectly fine without any bugs... so i might just make it all mission side if its not gonna work out server side.
 
Well i dunno why but I got it all setup for server side, its still a little buggy but the parachute just isn't being created. Nothing in the RPT about it as well. Test it mission side and it works perfectly fine without any bugs... so i might just make it all mission side if its not gonna work out server side.
look at WAI, im pretty sure they have something chute related
 
Back
Top