Payden Posted June 24, 2017 Report Share Posted June 24, 2017 On our ESLK PVE servers, players are not required to claim or mark missions where bandits are not present. They are encouraged but not required to let other players know that they've looted the mission crate. Since this caused a surprising amount of friction when a player would travel across the map only to find an empty crate, we added code to the standard missions that puts a "crate-visited" mark on the map when a player gets within 10M of the crate. The crate may or may not be empty but at least everyone knows someone has been to the mission crate. Here are the present and visit loops (idea lifted from the @juandayz Bombcrate mission): Spoiler // Wait for a player to be "present" while {_waitTime > (_currentTime - _startTime) && !_playerPresent} do { uisleep _presentLoopTime; _currentTime = floor(time); {if((isPlayer _x) && (_x distance _lootBox <= _presentDistance)) then {_playerPresent = true};}forEach playableUnits; }; // Wait for player to visit the crate while {_waitTime > (_currentTime - _startTime) && !_visitedCrate} do { uisleep _visitLoopTime; _currentTime = floor(time); {if((isPlayer _x) && (_x distance _lootBox <= _visitDistance)) then {_visitedCrate = true};}forEach playableUnits; }; Here is our complete version of the Construction mission - thanks to @salival for all the help with the coding details. Spoiler private ["_spawnChance","_spawnRoll","_markerRadius","_loot","_lootAmount","_lootBox","_position","_eventMarker", "_lootPos","_presentDistance","_visitDistance","_startTime","_waitTime","_timeLeft","_visitMarker","_presentLoopTime","_visitLoopTime"]; _spawnChance = 0.8; // Percentage chance of event happening _markerRadius = 350; // Radius the loot can spawn and used for the marker _waitTime = 1200; // Time to wait before despawning mission _presentDistance = 80; // Distance from crate before a player is considered "present" _visitDistance = 10; // Distance from crate before crate is considered "visited" _presentLoopTime = 10; // Sleep timer for loop watching for players to be present _visitLoopTime = 4; // Sleep timer for loop watching for players to visit the crate // Random chance of event happening _spawnRoll = random 1; if (_spawnRoll > _spawnChance) exitWith {}; _startTime = floor(time); // Random location _position = [getMarkerPos 'center',0,5000,10,0,2000,0] call BIS_fnc_findSafePos; _lootPos = [_position,0,(_markerRadius - 100),10,0,2000,0] call BIS_fnc_findSafePos; diag_log format["%1: Creating Construction box at %2",__FILE__,_lootPos]; _clutter = createVehicle ["ClutterCutter_small_2_EP1", _lootPos, [], 0, "CAN_COLLIDE"]; _clutter setPos _lootPos; // Create box _lootBox = createVehicle ["USVehicleBox",_lootPos,[], 0, "NONE"]; clearMagazineCargoGlobal _lootBox; clearWeaponCargoGlobal _lootBox; _lootLists = [ [ ["M9_SD_DZ"], [["15Rnd_9x19_M9SD",3],["ItemWoodStairs",3],["MortarBucket",7],["CinderBlocks", 24]] ], [ ["M9_SD_DZ"], [["15Rnd_9x19_M9SD",3],["ItemWoodStairs",4],["PartPlankPack",21],["PartPlywoodPack",21]] ], [ ["M9_SD_DZ"], [["15Rnd_9x19_M9SD",2],["metal_floor_kit",11],["ItemWoodFloor",11]] ], [ ["M9_SD_DZ"], [["15Rnd_9x19_M9SD",2],["metal_floor_kit",14],["ItemWoodFloor",14]] ], [ ["M9_SD_DZ"], [["15Rnd_9x19_M9SD",2],["outhouse_kit",2],["half_cinder_wall_kit",7],["full_cinder_wall_kit",4]] ], [ ["M9_SD_DZ"], [["15Rnd_9x19_M9SD",2],["outhouse_kit",2],["ItemWoodStairs",4],"workbench_kit",["ItemComboLock",2], ["ItemWoodWallLg",4],"ItemWoodWallGarageDoor","ItemWoodWallWindowLg"] ], [ ["M9_SD_DZ"], [["15Rnd_9x19_M9SD",2],["ItemWoodStairs",4],"workbench_kit",["ItemComboLock",2],["ItemWoodWallLg",4], "ItemWoodWallGarageDoor","ItemWoodWallWindowLg"] ], [ ["M9_SD_DZ"], [["15Rnd_9x19_M9SD",3],["PartGeneric",11],["metal_floor_kit",11],"Itemvault"] ], [ ["M9_SD_DZ"], [["15Rnd_9x19_M9SD",3],["ItemWoodWallGarageDoor",4],["ItemWoodWallWindowLg",4],["ItemWoodWallLg",9]] ], [ ["M9_SD_DZ"], [["15Rnd_9x19_M9SD",3],"workbench_kit","Itemvault",["full_cinder_wall_kit",7],["ItemComboLock",2], ["cinder_garage_kit",2],["cinder_door_kit",2]] ], [ ["M9_SD_DZ"], [["15Rnd_9x19_M9SD",3],"workbench_kit",["ItemWoodStairs",3],["wood_shack_kit",3],["deer_stand_kit",2], ["ItemWoodLadder",4],["desert_net_kit",5],["forest_net_kit",2],["ItemSandbagLarge",2],"Itemvault","ItemLockbox"] ] ]; _loot = _lootLists call BIS_fnc_selectRandom; // Add loot { if (typeName (_x) == "ARRAY") then { _lootBox addWeaponCargoGlobal [_x select 0,_x select 1]; } else { _lootBox addWeaponCargoGlobal [_x,1]; }; } forEach (_loot select 0); { if (typeName (_x) == "ARRAY") then { _lootBox addMagazineCargoGlobal [_x select 0,_x select 1]; } else { _lootBox addMagazineCargoGlobal [_x,1]; }; } forEach (_loot select 1); _startTime = time; _eventMarker = createMarker [ format ["loot_eventMarker_%1", _startTime], _position]; _eventMarker setMarkerShape "ELLIPSE"; _eventMarker setMarkerColor "ColorGreen"; _eventMarker setMarkerAlpha 0.5; _eventMarker setMarkerSize [(_markerRadius + 50), (_markerRadius + 50)]; // Send center message to users [nil,nil,rTitleText,"Ikea Truck lost its Cargo, Check your Map for the Location!", "PLAIN",10] call RE; diag_log(format["%1: Loot event setup, waiting for %2 seconds", __FILE__,_waitTime]); _playerPresent = false; _visitedCrate = false; _currentTime = floor(time); // Wait for a player to be "present" while {_waitTime > (_currentTime - _startTime) && !_playerPresent} do { uisleep _presentLoopTime; _currentTime = floor(time); {if((isPlayer _x) && (_x distance _lootBox <= _presentDistance)) then {_playerPresent = true};}forEach playableUnits; }; // Wait for player to visit the crate while {_waitTime > (_currentTime - _startTime) && !_visitedCrate} do { uisleep _visitLoopTime; _currentTime = floor(time); {if((isPlayer _x) && (_x distance _lootBox <= _visitDistance)) then {_visitedCrate = true};}forEach playableUnits; }; // Add the pickup marker to the center of the mission of the crate has been visited if (_visitedCrate) then { _visitMarker = createMarker [ format ["loot_event_visitMarker_%1", _startTime], _position]; _visitMarker setMarkerShape "ICON"; _visitMarker setMarkerType "hd_pickup"; _visitMarker setMarkerColor "ColorBlack"; _visitMarker setMarkerAlpha 1; }; // Wait for full mission time before cleaning up _timeLeft = _waitTime - (_currentTime-_startTime); if (_timeLeft > 0) then uisleep _timeLeft; // Clean up crate and markers deleteMarker _eventMarker; deleteVehicle _lootBox; deleteVehicle _clutter; if !(isNil "_visitMarker") then {deleteMarker _visitMarker;}; gernika, theduke, juandayz and 2 others 5 Link to comment Share on other sites More sharing options...
DAKA Posted August 8, 2017 Report Share Posted August 8, 2017 So not all the events are scripted the same. I love this idea. Can I place the above code anywhere within the event or does it have to follow after a certain statement or line of code? Link to comment Share on other sites More sharing options...
Payden Posted August 8, 2017 Author Report Share Posted August 8, 2017 Second version is the complete mission showing where we placed the new code. Code can't just go anywhere - has to be after the variables are defined and crate has spawned but before the cleanup code. Link to comment Share on other sites More sharing options...
DAKA Posted September 3, 2017 Report Share Posted September 3, 2017 So here is the error that I am getting 23:08:06 Error in expression <; } forEach (_loot5 select 1); while {_waitTime > (_currentTime - _startTime) > 23:08:06 Error position: <_waitTime > (_currentTime - _startTime) > 23:08:06 Error Undefined variable in expression: _waittime Link to comment Share on other sites More sharing options...
salival Posted September 3, 2017 Report Share Posted September 3, 2017 12 minutes ago, DAKA said: So here is the error that I am getting 23:08:06 Error in expression <; } forEach (_loot5 select 1); while {_waitTime > (_currentTime - _startTime) > 23:08:06 Error position: <_waitTime > (_currentTime - _startTime) > 23:08:06 Error Undefined variable in expression: _waittime The variable is definitely defined there, make sure you are running the correct version from the OP. theduke 1 Link to comment Share on other sites More sharing options...
DAKA Posted September 3, 2017 Report Share Posted September 3, 2017 well I wasn't sure of the epoch event that its in is correct, so i actually copied the one from here and will test it. thanks for the tip Sal. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now