Jump to content
Sign in to follow this  
evans d [16aa]

Place Maker when Explosives Planted

Recommended Posts

Ladies and gentlemen, hello again.

I'm making a mission where players fight against each other in a terrorist versus special forces lineup and the idea is that the police have to react to the threats that the terrorists decide to create.

Now, since the mission is taking place on Altis, I want to make it fair for the police. Terrorists planting a bomb and the police then having to scour 207 kilometers to find it before it explodes is a tad challenging, as I'm sure you'll agree.

Therefore, I have a plan! Markers! But these will not just be any old regular markers, these will be DYNAMIC markers (hold for applause)!

The only problem that I have is that I'm not sure how I would go about it. Event handlers are a certainty. The createMarker command will, of course be used, but in what combination?

Bellow I've created some code that I haven't tested and I'm not even sure if this is how I'd go about it anyway, but if you fine people could cast your eyes over it and tell me where I'm going right or wrong then I would be very grateful.

init.sqf

bombPlantedEvent = player addEventHandler ["fired", {_this execVM "scripts\events\bombPlanted.sqf"}];

bombPlanted.sqf

_bomb = getpos player;
_bombMarker = createMarker [markerName, _bomb];
_bombMarker setMarkerColour = colourOPFOR;
_bombMarker setMarkerShape "ELLIPSE";
_bombMarker setMarkerSize [75,75];
hint "Explosives reported in marked area.";

Many thanks,

Bashkire.

Share this post


Link to post
Share on other sites

this addEventHandler ["FIRED", { if (_this select 4 == "democharge_remote_Ammo") then {execVM "moveMarker.sqf"}}];

((count ((markerpos "bombMrk") nearObjects ["democharge_remote_Ammo", 50]))

Rather than creating a marker everytime you can just move one around thats on the map already.

Edited by cobra4v320

Share this post


Link to post
Share on other sites

How would I code it so that I could have multiple markers on the map if I wanted it? This is one way, it's just nice to have multiple ways of handling things so I have options.

Share this post


Link to post
Share on other sites

This would give dynamic markers for each explosive.

this addEventHandler ["FIRED", { if (_this select 4 == "democharge_remote_Ammo") then {_this execVM "moveMarker.sqf"}}];

You could create an array for different types of explosive

ied_array =  ["democharge_remote_Ammo","add here ect"];// add more if you wish
this addEventHandler ["FIRED", { if (_this select 4 in ied_array) then {_this execVM "moveMarker.sqf"}}];

_inc = missionnamespace getvariable ["bomb",1];// _inc = 1 if no bombs else find actual number
player sidechat  (_this select 4)+ " number " + str _inc;// for debug

_bomb = getpos player;
_bombMarker = createMarker ["bomb" + str _inc,_bomb];//name bomb :- bomb1,bomb2 ect
_bombMarker setMarkerColor "colorRed";
_bombMarker setMarkerShape "ELLIPSE";
_bombMarker setMarkerSize [75,75];

_inc=_inc+1;// increase bomb number
missionnamespace setvariable ["bomb",_inc];// set bomb variable to correct number
hint "Explosives reported in marked area."; 

sleep 1;
player sidechat   _bombMarker;//marker name check debug

Share this post


Link to post
Share on other sites

Fantastic! I've changed this addEventHandler... to player addEventHandler... so hopefully that'll work for all the OPFOR players.

As a final request, do you think you could furnish me with a way that I would be able to delete the markers when the bombs have been defused, or would that be too challenging and I should stick with this for now?

Share this post


Link to post
Share on other sites

Why did I think you were going to ask that.

It should be possible, you could keep a track of all the bombs planted in an array and I guess there's a way to find out when they are disarmed and so can be removed from the array and the markers deleted.

I think though the marker would still need some work, you should only spawn one marker even if it contains several ied/mines, I think there is a function for area check.

If no one replies I'll try and take a look tonight.

Share this post


Link to post
Share on other sites

Cheers, I'll do some looking myself and some experimenting, but I don't even know where to begin so I'm not too hopeful.

Again, thanks for the help your offering. This is really helpful, mate!

Share this post


Link to post
Share on other sites

I did get a little further although not really happy with it.

save as moveMarker.sqf

private ["_bombMarker"];

_inc = missionnamespace getvariable ["bomb",0];// _inc = 1 if no bombs else find actual number
if (_inc == 0) then {execvm "remove_marker.sqf"};// this starts remove script
_inarea = [getmarkerpos ("bomb" + str _inc),getmarkersize ("bomb" + str _inc),getpos (_this select 0)] call BIS_fnc_isInsideArea;

if (!_inarea) then {

_inc=_inc+1;// increase bomb number
_bomb = getpos player;
_bombMarker = createMarker ["bomb" + str _inc,_bomb];//name bombmarker :- bomb1,bomb2 ect
_bombMarker setMarkerColor "colorRed";
_bombMarker setMarkerShape "ELLIPSE";
_bombMarker setMarkerSize [75,75];

};
player sidechat  (_this select 4)+ " number " + str _inc;// for debug
missionnamespace setvariable ["bomb",_inc];// set bomb variable to correct number
hint "Explosives reported in marked area."; 
sleep 1;
player sidechat   _bombMarker;//marker name check debug

save as remove_marker.sqf

while {true} do {
_inc = missionnamespace getvariable ["bomb",0];
_mines = 0;

for "_i" from 1 to _inc step 1 do 
{
_mines = nearestobjects [getmarkerpos ("bomb" + str _i),[],(getmarkersize ("bomb" + str _i)) select 0]-nearestobjects [getmarkerpos ("bomb" + str _i),["all"],(getmarkersize ("bomb" + str _i)) select 0 ];
//hint str _mines;
sleep 1;
if ( { typeof _x == "democharge_remote_Ammo"}  count _mines == 0) then {;deletemarker  ("bomb" + str _i)};
};
sleep 1;
};

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×