Page MenuHomeFeedback Tracker

Delete event does not get triggered when a mine is deactivated.
Feedback, NormalPublic

Description

"delete" event handler does not get triggered when a mine is deactivated. It does get activated when it explodes.

The mines are projectiles and not objects. So they use the new event handlers.

Details

Severity
Feature
Resolution
Open
Reproducibility
Always
Operating System
Windows 11 x64
Operating System Version
2.12.150301
Category
General
Steps To Reproduce
  1. Make a new mission
  2. Place down a few UXOs
  3. Put them in a layer called 'UXO'
  4. Put down a mine specialist as player
  5. create init.sqf
  6. Add the code:
	addUXOHandlers= {
		getMissionLayerEntities "UXO" params ["_uxo", "_markers"];

		{

			_x addEventHandler ["Explode", {
				params ["_projectile", "_pos", "_velocity"];
				_x setVariable ["exploded",true];
				diag_log "explosion";
				// [_pos, 3] execVM "scripts\huntGroup.sqf";
			}];

			_x addEventHandler ["Deflected", {
				params ["_projectile", "_pos", "_velocity", "_hitObject"];

				diag_log "Deflected";
			}];

			_x addEventHandler ["Deleted", {
				params ["_projectile"];

				diag_log('Deleted event');

				_projectile spawn {
					sleep 5;
					_exploded = _this getVariable["exploded",false];
					diag_log format["mine deleted:%1",_exploded];

					if(!_exploded) then {
						diag_log format["_projectile:%1", _this];
						diag_log format["getPosATL:%1", getPosATL _this];
						private _playerList = allPlayers apply {[ (getPosATL _this) distanceSqr _x, _x]};
						_playerList sort true;
						private _closestPlayer = (_playerList select 0) param [1, objNull];
						_closestPlayer addItemCargoGlobal ["gm_explosive_plnp_charge",1];
						diag_log format["_closestPlayer:%1", _closestPlayer];
					}
				};
			}];
		} forEach _uxo;
	};

	[] spawn addUXOHandlers;
  1. Play the game. Go to the UXO press the action list deactivate mine.

Actual result: No 'delete' event handler triggered
Expected result: The 'delete' event handler triggered.

Event Timeline

Darkbelg created this task.May 17 2023, 7:55 PM

I think i found the issue. The mine doesn't actually get deleted. It just gets deactivated but still exists. While mines that explode get deleted.

I guess it is no longer a bug but a feature request.
Can we get an event "deactivated" if a projectile gets deactivated?

Darkbelg changed Severity from Minor to Feature.May 18 2023, 2:53 PM
dedmen added a subscriber: dedmen.May 22 2023, 10:33 AM

Ok I see how that works.
In the same place we can also get activation.
But I don't know if mine activation is that different from just placement

I guess I will add
"MineActivation" eventhandler with ["_projectile", "_activation"]
which will just throw a false for your case

Actually.. When you deactivate the mine, a new one is spawned in a weapon holder, and the old one gets deleted.
AND the deletion handler should be triggered.. So thats a bug

Cannot reproduce

Go into eden as explosives specialist, place down claymore mine
run
cursorObject addEventhandler ["Deleted", {systemChat str _this;}]
deactivate claymore mine, observe log message in chat.

Seems to be working just fine for me. So the feature is there, it just doesn't work right for UXO

Yes tested, UXO doesn't trigger eventhandler. So no feature request then

Uhh interesting engine bug. If it cannot spawn a new magazine into a ground holder, the original mine is never deleted, it just becomes invisible and.. stays there.
So the bug is UXO's not getting deleted when deactivated

Ah when its deactivated, its supposed to switch to a deactivated state model, but for UXO's that model is empty.
So it just gets turned into a invisible model, but keeps laying there and keeps being simulated each frame

dedmen set Ref Ticket to AIII-55690.May 22 2023, 10:55 AM
dedmen changed the task status from New to Feedback.EditedMay 22 2023, 11:29 AM

cursorObject addEventhandler ["Deleted", {systemChat str [_thisEvent, _this];}];
cursorObject addEventhandler ["MineActivated", {systemChat str [_thisEvent, _this];}]

Deleted now fires for UXOs (if mineModelDisabled and defaultMagazine are empty, we now delete it after deactivating)

But there may still be mines that actually have a deactivated model thats not empty, in that case MineActivated will fire.
MineActivated can also fire with true

For example Naval Mines can be deactivated and reactivated

Darkbelg added a comment.EditedMay 22 2023, 6:59 PM

Can you also add the person who deactivated the mine?
The scenario i have in mind is. I want to add explosives to the person who deactivated it. I could run a script to check wo is the closes to the mine when it gets deactivated but it would be handy if it was in the eventhandler.

Do you delete the UXO after it is deactivated? Might not be backwards compatible if you did.
Now you have to run mineActive on a UXO to figure out if it has been deactivated or not.
I think most people had to do loops to see when a mine became deactivated. So deleting that might break it.

Can you also add the person who deactivated the mine

ooof.. eh.. not easily no.
In addition to checking nearest, you can probably check their animation. They will be in deactivation animation when the EH triggers.

Do you delete the UXO after it is deactivated? Might not be backwards compatible if you did.

It might, its in testing on profiling. If it causes issues we'll remove that again

After downloading this monster once again. I replayed the Laws of war DLC to test it and did not experience any issues with the demining missions i played.