Page MenuHomeFeedback Tracker

Add a new eventHandler "vehicleChanged"
Acknowledged, WishlistPublic

Description

I would like to request a new eventHandler that fires locally on the machine where it is attached to a unit (in this example the player itself) when ever the unit changes vehicle.

This eventHandler would be very useful, because we could get rid of infinite loops like:
waitUntil{vehicle player != player};
And vice versa, only to check if a player has entered a vehicle.

The eventHandler could then return the following:
0 = Object the eventHandler is attached to.
1 = Vehicle that the unit was in.
2 = Vehicle that the unit has entered.

Example:
player addEventHandler["vehicleChanged",{ hint str _this }];

Result if the player enters a vehicle:
"[BIS_fnc_objectVar_obj1, BIS_fnc_objectVar_obj1, 46328100# 5: mrap_01_unarmed_f.p3d]"

Result if the player leaves the vehicle:
"[BIS_fnc_objectVar_obj1, 46328100# 5: mrap_01_unarmed_f.p3d, BIS_fnc_objectVar_obj1]"

It would be perfect if the eventHandler would also fire, when the unit changes its position inside a vehicle and return the current turret or assignedVehicleRole with the eventHandler!

Example which returns "assignedVehicleRole":
player addEventHandler["vehicleChanged",{ hint str _this }];

Result if the player enters a vehicle as driver:
"[BIS_fnc_objectVar_obj1, BIS_fnc_objectVar_obj1, 46328100# 5: mrap_01_unarmed_f.p3d, ["driver"]]"

Result if the player changes seat to passenger:
"[46328100# 5: mrap_01_unarmed_f.p3d, 46328100# 5: mrap_01_unarmed_f.p3d, ["cargo"]]"

Result if the player leaves the vehicle:
"[46328100# 5: mrap_01_unarmed_f.p3d, BIS_fnc_objectVar_obj1, ["cargo"]]"

The assignedVehicleRole does not change if a player leaves a vehicle (even thou he becomes the "driver" of the units body), so one would have to check within a script or function inside the eventHandlers Code, if the player has entered or left a vehicle by using (vehicle player == player) or (_this select 1 == player).

Therefore it would be better to have a more complex return as I will describe in the next part:

Another, more complex example, with a bit of scripting (which could be integrated inside the eventHandler code, to make it run native == faster):

player addEventHandler["vehicleChanged",{
_this select 0 Unit the eventHandler is attached to.
_this select 1
Previous unit vehicle.
_this select 2 Current unit vehicle.
_this select 3
(fullCrew [vehicle (_this select 0), ((assignedVehicleRole (_this select 0) select 0)]) select 0)select 1
}];

Result if the player enters a vehicle as driver:
[BIS_fnc_objectVar_obj1, BIS_fnc_objectVar_obj1, 46328100# 5: mrap_01_unarmed_f.p3d, [BIS_fnc_objectVar_obj1,"driver",-1,[],false]]

Result if the player changes seat to passenger:
[BIS_fnc_objectVar_obj1, 46328100# 5: mrap_01_unarmed_f.p3d, 46328100# 5: mrap_01_unarmed_f.p3d, [BIS_fnc_objectVar_obj1,"cargo",0,[],false]]

Result if the player leaves the vehicle:
[BIS_fnc_objectVar_obj1, 46328100# 5: mrap_01_unarmed_f.p3d, BIS_fnc_objectVar_obj1, (Nil or empty string "")]

In the end, the most perfect eventHandler that offers the most usability for scripters would look like this:

_unit addEventHandler["vehicleChanged",{
_this select 0 Unit the eventHandler is attached to.
_this select 1
Previous unit vehicle.
_this select 2 Current unit vehicle.
_this select 3
assignedVehicleRole (also returns "driver" correctly if player leaves a vehicle!).
_this select 4 // Turret or empty String
}];

This eventHandler would be extremely helpful in certain scenarios and could help to improve client performance by getting rid of many useless loops.

Details

Legacy ID
4025582148
Severity
None
Resolution
Open
Reproducibility
N/A
Category
Feature Request

Event Timeline

KiloSwiss set Category to Feature Request.Jul 22 2015, 5:57 PM
KiloSwiss set Reproducibility to N/A.
KiloSwiss set Severity to None.
KiloSwiss set Resolution to Open.
KiloSwiss set Legacy ID to 4025582148.May 8 2016, 12:25 PM