Detecting specific object in an area

clifdayz

Well-Known Member
So I've been using the DZMS package for missions and its great. I'd like to have missions that are more specific to the terrain - like in a city. I know how to place the mission wherever I want - say on the heli landing pad in Elektro. I can place the AI around it.

The issue is that if the players clear it and don't move the vehicles (or I put some junk vehicles), the next iteration will dump on top of the old one. One solution is to only run this particular mission once per server session. The other would be to see if the objects are still there(within a radius) and not spawn them again or skip it altogether. Looking at the various APIs, nothing stands out.

?doesVehicleExist [coords, radius]?
 
Look up "Arma 2 Script Commands" for all the commands.

You are looking for nearobjects or nearestobjects depending on how you want to do this.
 
thanks, that was it! I read through that whole damn API list and looking for vehicle*, find*, locate*.

In the 2 missions I've created movable objects (heli, ural, humvee), but also unmovable objects(crates and wrecks). The first thing the mission does is see if any of the objects of that type are in the radius and if so, then bail.

I think DZMS will clean up the unmovable objects eventually, so the only gotcha is if a player drove/flew a different object of the same type into the radius. That's an edge case, so I'm not going to worry about it.
 
DZMS wont delete the object a player drove/flew in because it creates the objects with variable names (_heli, _weaponcrate etc etc) and it deletes those named objects only.
 
ok, that makes sense. I was testing this last night. 3 missions in rotation. 1 that it puts randomly(standard dzms), 2 that are fixed in the city(new ones).

Mission 1 - 1 Heli, 1 AmmoBox, 1 Medbox. [fixed location in Cherno]
Mission 2 - 2 humvee, 2 ural, 1 humvee wreck, 1 ural wreck. [fixed location in elektro]
Mission 3- - 1 ural [random]

eventually I get #1 and clear it but leave the heli in place
then I get #3 clear it and leave the vehicles in place.

In my log file I'v seen the msgs that the mission will not run again since I added logic to look for any of the items in the location first using nearestobjects. I figure even if the good vehicles get moved, the wrecks cannot.

I forget that DZMS has some cleanup code. Eventually #2 runs again and I expect to find double the vehicles and wrecks. I don't. only single. Strange. I clear it.

Then I decide to fly to #1 and see that the heli is there, but the boxes have been cleaned up. I read the code and and I see where they are cleaned up. Ok, I move the heli, but the mission doesn't seem to come back. I think it should, since the boxes are gone and the heli. Maybe I didn't wait long enough, but this doesn't worry me.

The case where it looks like my #2 mission ran again and I didn't see doubled up objects is the puzzling one. I appreciate your help on all of my posts. I'm still messing around with this, but I wanted to throw this out there.

private ["_missName","_coords","_ranChopper","_chopper","_truck","_trash","_trash2","_crate","_crate2"];


//Name of the Mission
_missName = "US Army Transport Helicopter Landing";

//DZMSFindPos loops BIS_fnc_findSafePos until it gets a valid result
//_coords = call DZMSFindPos;
_coords = [6776.46,2719.04,0]; // cherno landing pad

// Check for the heli nearby and exit if its still there.
_boxNear = nearestObjects [_coords, ["MedBox0", "AmmoBoxBig"], 50];
_boxcnt = count _boxNear;

_vehNear = nearestObjects [_coords, DZMSChoppers, 25];
_vehcnt = count _vehNear;

if ((_vehcnt+_boxcnt) > 0) then {
diag_log text format["[DZMS]: Exiting. SM4_HeliCherno has already run once this session."];
} else {


[nil,nil,rTitleText,"A US Army Transport Helicopter has landed!\n(CLEAR TO UNLOCK VEHICLES)", "PLAIN",10] call RE;

//DZMSAddMajMarker is a simple script that adds a marker to the location
[_coords,_missname] ExecVM DZMSAddMajMarker;




//We create the vehicles like normal
_ranChopper = ["heli"] call DZMSGetVeh;
_chopper = createVehicle [_ranChopper,_coords,[], 0, "NONE"];

//DZMSSetupVehicle prevents the vehicle from disappearing and sets fuel and such
[_chopper] call DZMSSetupVehicle;
_chopper setDir 312;
_chopper setVehicleLock "LOCKED";
/**
_truck = createVehicle ["HMMWV_DZ",[(_coords select 0) - 8.7802,(_coords select 1) + 6.874,0],[], 0, "CAN_COLLIDE"];
[_truck] call DZMSSetupVehicle;
**/

_bcoords1 = [6775.12,2734.87,0.001];
_bcoords2 = [6775.16,2715.56,0.001];
//DZMSBoxFill fills the box, DZMSProtectObj prevents it from disappearing

_crate = createVehicle ["MedBox0",[(_bcoords1 select 0) ,(_bcoords1 select 1), (_bcoords1 select 2)],[], 0, "CAN_COLLIDE"];
[_crate,"medical"] ExecVM DZMSBoxSetup;
[_crate] call DZMSProtectObj;

_crate2 = createVehicle ["AmmoBoxBig",[(_bcoords2 select 0) ,(_bcoords2 select 1), (_bcoords2 select 2)],[], 0, "CAN_COLLIDE"];
[_crate2,"weapons_heli_large"] ExecVM DZMSBoxSetup;
[_crate2] call DZMSProtectObj;

>>>>I left out the part where it spawns the AI and where the ELSE statement is closed above.
 
Okay so let me get this straight: you ran mission 2 and then it rain again at some later time and you anticipated to see to sets of boxes and helicopters. The code you pasted above is the code from your mission -. If you look there's a line that is commented to say exit if there is a nearby heli. And there is a line of code that checks the number of Haley's and the number of boxes and if it is greater than 0 it exits the code with a line saying so in your log.

Code:
// Check for the heli nearby and exit if its still there.
_boxNear = nearestObjects [_coords, ["MedBox0", "AmmoBoxBig"], 50];
_boxcnt = count _boxNear;

_vehNear = nearestObjects [_coords, DZMSChoppers, 25];
_vehcnt = count _vehNear;

if ((_vehcnt+_boxcnt) > 0) then {
diag_log text format["[DZMS]: Exiting. SM4_HeliCherno has already run once this session."];
} else {

So while the mission might actually run a second time it exits before creating any objects if any of the previous objects are still at that location
 
No, sortof the opposite.
It should exit if it finds the heli or boxes. The log file shows it did a couple of times. Eventually the boxes got cleaned up by DZMS but it still didn't run again since the heli was there. Then I moved the heli. It still did not run again. Not sure why.

Related, in the other mission there were 4 vehicles, 2 wrecks. I cleared the mission, but didn't move the vehicles. It seems as thought DZMS cleaned it all up since it ran again, but I didn't see a mess up vehicles and wrecks.

From my quick scanning of the code, DZMS only cleans up boxes and the like, not anything else. maybe I missed something. I'll have time to go over it this weekend some more.
 
Back
Top