Jump to content
Sign in to follow this  
davidoss

Explosion eventhandler

Recommended Posts

Hi.

I created a function to spawn roadblock using LARs 3den composition spawn system.

It spawn a composition well but i want to give the player possibility to remove the composition by simple blew it up.

Therefore i use an eventhandler on one of the composition object which is an flag.

This should trigger and remove the composition. Unfortunately it works only if previewed in editor. On dedicated we cant blew up the roadblock no matter what count of explosives we set. Its very strange because the whole code runs server side (one pc)  also in the same way when previewed in editor.

Looks like the flag in MP environment has no simulation enabled or something.

I used the flag because it occurs in every composition to spawn.

 

fnc_spawnRoadblock = {

	params ["_trigger"];
	
	private _position = position _trigger;
	
	private _roadblocks = [
	"roadblock1",
	"roadblock2",
	"roadblock3",
	"roadblock4",
	"roadblock5",
	"roadblock6"
	];

	private _fnc_distfilter = { 
	
		params ["_anchor", "_array"]; 
		
		private _return = [];
		{
				if ( ((getPos _x) distance _anchor) > 100 ) then {
					
					if !((getPos _x) isFlatEmpty  [15, -1, 0.1, 15, -1, false, objNull] isEqualTo []) then {
					_return pushback _x;
					};
				}; 
		} forEach _array;
		_return
	}; 
	private _roadblock = "";
	private _roads = _position nearRoads 300; 

		if !(_roads isEqualTo []) then {
		
			private _filteredRoads = [_position,_roads] call _fnc_distfilter;
			
			if !(_filteredRoads isEqualTo []) then {
		
				private _selectedRoad = selectRandom _filteredRoads;
				private _nextRoad = (roadsConnectedTo _selectedRoad) select 0;
				private _direction = _selectedRoad getDir _nextRoad;
				private _pos = getPosATL _selectedRoad;
				_roadblock = [ selectRandom _roadblocks, _pos, [1.5,-3,-0.05], _direction, true ] call LARs_fnc_spawnComp;
				_flag = ((([_roadblock] call LARs_fnc_getCompObjects) select {_x isKindOf "Flag_TKINS_F"}) select 0);
				_flag setVariable ["idx",_roadblock,false];
				_flag setVariable ["trg",_trigger,false];
				
				_flag addEventHandler ["Explosion",{
				
					params ["_object"];
					_object removeAllEventHandlers "Explosion";
					private _id = _object getVariable "idx";
					private _trgr = _object getVariable "trg";
					[_id] call LARs_fnc_deleteComp;
					[getPos _object, "ammocache", "ROADBLOCK"] call fnc_sendNotif;
					_trgr setVariable ["roadblock","", false];
				
				}];
			};
		};	
		
		
	_roadblock
};

 

Can you guys  help with please?

Share this post


Link to post
Share on other sites

Have do some tests and believe or not explosion eventhandler fires only if explosion is made server side. Looks like  bug.

 

Share this post


Link to post
Share on other sites
14 hours ago, davidoss said:

Have do some tests and believe or not explosion eventhandler fires only if explosion is made server side. Looks like  bug.

 

It seems it only triggers EH local to the explosion. I will update the biki for now

Share this post


Link to post
Share on other sites

Not familiar with the following event handlers, but would HitPart or MPHit be an appropriate substitute?

Share this post


Link to post
Share on other sites

No chance, hit does not work, damage does not work, firednear  triggers when bomb planted.

I need something that detect near charge explosion and trigger code on server side.

Since the explosion eventhandler no more working in that way i have no idea how to accomplish this.

Share this post


Link to post
Share on other sites

I dont understand THIS in eventHandlers:

 

Hit: The hit EH will not necessarily fire if only minor damage occurred (e.g. firing a bullet at a tank), even though the damage increased.

Dammaged: The Dammaged EH will not necessarily fire if only minor damage occurred (e.g. firing a bullet at a tank), even though the damage increased.

HandleDamage: "HandleDamage" can trigger "twice" per damage event. Once for direct damage, once for indirect damage (explosive damage). This can happen even in the same frame, but is unlikely.

(source: Wiki)

 

WHY, just WHY ... how the hell I suppose to detect if someone try to hit something when eventHandler dont even bother to activate?

 

Edit: 

damage _object

is your friend

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  

×