Jump to content
3LGStevo

Vehicle HandleDamage not returning ...well Anything at all!

Recommended Posts

diag_log format ["HANDLE DAMAGE: %1",_this];

^ my handle (ton_fnc_onVehicleDamage) just to try get something back :(

private ["_vehicle"];
_vehicle = _this select 0;
_vehicle addEventHandler ["HandleDamage",{_this call TON_fnc_onVehicleDamage;}];

[_vehicle] spawn {
	_vehicle = _this select 0;
	waitUntil {!alive _vehicle};
	_vehicle removeAllEventHandlers "HandleDamage";
};

^ what calls it (Ton_fnc_addVehicleEH)

 

...
_vehicle = createVehicle [_className,[0,0,999],[], 0, "NONE"];
...
[_vehicle] spawn TON_fnc_addVehicleEH;

^ the initial part after the vehicle is created.

_vehicle is created on the server.
The Event Handler code is executed only on the server - so surely this can't be a locality issue?

What am I missing? Why isn't this "HandleDamage" eventHandler triggering? It worked with "Dammaged" EH, but that doesn't return the projectile, or the person who fired it (always <Null-Object>)
 

  • Like 1

Share this post


Link to post
Share on other sites

I rarely work with eventhandlers so I might be wrong but in "ton_fnc_onVehicleDamage" what is _this? Wouldn't you need something like "_this select 0" or such:
 

Quote

 

this addEventHandler ["HandleDamage", { params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"]; }];
 

unit: Object - Object the event handler is assigned to.

hitSelection: String - Name of the selection where the unit was damaged. "" for over-all structural damage, "?" for unknown selections.

damage: Number - Resulting level of damage for the selection.

source: Object - The source unit that caused the damage.

projectile: String - Classname of the projectile that caused inflicted the damage. ("" for unknown, such as falling damage.)

 hitPartIndex: Number - Hit part index of the hit point, -1 otherwise.

 instigator: Object - Person who pulled the trigger

 hitPoint: String - hit point Cfg name

 

 

As I said, I can be completely wrong with this and just not understand what is going on right now.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, 3LGStevo said:

just to try get something back 😞

 

Hello there Guys !

 

If i remember it was kind of working , if you ( allowdamage false; )

but i didn't made it there , have a look :

 

Share this post


Link to post
Share on other sites

I am not sure what kinda testing environment you have setup, and from the information given to use it looks like it should work perfectly fine. So rather wasting time playing 20 questions I went ahead and created an example mission for you, recreating exactly what you are trying to do with what you have showed us from your script. My assumption is that your diag_logs are going to a server rpt file and you are just looking in the wrong place because the event handler is assigned to a globally created vehicle and not a player but they would show up in your own rpt files if you ran the mission as the host. Hopefully this helps!

https://drive.google.com/open?id=1h4yG0cNClq3MR8-phCTtcA6HHzc_mYnG

  • Like 1

Share this post


Link to post
Share on other sites

I solved this issue myself. I didn't know the locality of the vehicles changed upon a player entering the driver seat.

1. Vehicles only allow eventhandlers ("HandleDamage" ones anyway) to fire on the entity that considers the vehicle local to the client. I.e. if you create the vehicle on the server, and attach an eventhandler to it on the server, the eventhandler triggers.
2. As soon as you enter the vehicle's driver position, vehicle locality switches, which as a result means the eventhandler created on the server no longer fires when the same action is provided.
3. As a workaround, I added an eventhandler to player objects which handles the "getInMan" event. When the player gets in a vehicle as a driver, the eventhandler for the damage is created for that vehicle.
4. While this now rectifies the locality issue, it also means that unless you can specfically assign the eventhandler to a global variable, and delete this global variable on exiting the vehicle (which isn't what I needed), it means the event handler then defaults to the player... so, the Unit then receives the custom eventHandler, which means you need to write inside the onVehicleDamage script that if the _vehicle entity isKindOf "Man", to exit... allowing the standard "Man" damageHandler to apply.

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

×