use eventhandlers instead of PFH

This commit is contained in:
commy2
2015-03-18 15:42:33 +01:00
parent ec6496ed2f
commit 4ea6b91e47
10 changed files with 134 additions and 26 deletions

View File

@ -6,13 +6,8 @@ private ["_unit", "_target"];
_unit = _this select 0 select 0;
_target = _this select 0 select 1;
if (
!([_unit] call EFUNC(common,isAlive)) // drop if the player is dead
|| {!([_target] call EFUNC(common,isAlive))} // drop if the crate is destroyed
|| {currentWeapon _unit != ""}
|| {stance _unit != "STAND"} // drop when crouching or inside a vehicle
|| {!([_unit] call EFUNC(common,isPlayer))}
) then {
// drop if the crate is destroyed
if !([_target] call EFUNC(common,isAlive)) then {
[_unit, _target] call FUNC(dropObject_carry);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};

View File

@ -6,13 +6,8 @@ private ["_unit", "_target"];
_unit = _this select 0 select 0;
_target = _this select 0 select 1;
if (
!([_unit] call EFUNC(common,isAlive)) // drop if the player is dead
|| {!([_target] call EFUNC(common,isAlive))} // drop if the crate is destroyed
|| {!(animationState _unit in DRAG_ANIMATIONS)} // drop if not in dragging anim. This also exits when entering a vehicle.
|| {currentWeapon _unit != primaryWeapon _unit}
|| {!([_unit] call EFUNC(common,isPlayer))}
) then {
// drop if the crate is destroyed
if !([_target] call EFUNC(common,isAlive)) then {
[_unit, _target] call FUNC(dropObject);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};

View File

@ -0,0 +1,31 @@
// by commy2
#include "script_component.hpp"
private ["_unit", "_anim"];
_unit = _this select 0;
_anim = _this select 1;
if (_unit getVariable [QGVAR(isDragging), false]) then {
// drop dragged object when not in valid animation
if !(_anim in DRAG_ANIMATIONS) then {
private "_draggedObject";
_draggedObject = _unit getVariable [QGVAR(draggedObject), objNull];
[_unit, _draggedObject] call FUNC(dropObject);
};
};
if (_unit getVariable [QGVAR(isCarrying), false]) then {
// drop carried object when not standing
if (stance _unit != "STAND") then {
private "_carriedObject";
_carriedObject = _unit getVariable [QGVAR(carriedObject), objNull];
[_unit, _carriedObject] call FUNC(dropObject_carry);
};
};

View File

@ -0,0 +1,20 @@
// by commy2
#include "script_component.hpp"
private "_unit";
_unit = _this select 0;
if (_unit getVariable [QGVAR(isDragging), false]) then {
private "_draggedObject";
_draggedObject = _unit getVariable [QGVAR(draggedObject), objNull];
[_unit, _draggedObject] call FUNC(dropObject);
};
if (_unit getVariable [QGVAR(isCarrying), false]) then {
private "_carriedObject";
_carriedObject = _unit getVariable [QGVAR(carriedObject), objNull];
[_unit, _carriedObject] call FUNC(dropObject_carry);
};

View File

@ -0,0 +1,17 @@
// by commy2
#include "script_component.hpp"
private ["_newPlayer", "_oldPlayer"];
_newPlayer = _this select 0;
_oldPlayer = _this select 1;
{
if (_x getVariable [QGVAR(isDragging), false]) then {
[_x, _x getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject);
};
if (_x getVariable [QGVAR(isCarrying), false]) then {
[_x, _x getVariable [QGVAR(carriedObject), objNull]] call FUNC(dropObject_carry);
};
} forEach [_newPlayer, _oldPlayer];

View File

@ -0,0 +1,31 @@
// by commy2
#include "script_component.hpp"
private ["_unit", "_weapon"];
_unit = _this select 0;
_weapon = _this select 1;
if (_unit getVariable [QGVAR(isDragging), false]) then {
// drop dragged object when selecting a non-primary weapon
if (_weapon != primaryWeapon _unit) then {
private "_draggedObject";
_draggedObject = _unit getVariable [QGVAR(draggedObject), objNull];
[_unit, _draggedObject] call FUNC(dropObject);
};
};
if (_unit getVariable [QGVAR(isCarrying), false]) then {
// drop carried object when selecting any weapon
if (_weapon != "") then {
private "_carriedObject";
_carriedObject = _unit getVariable [QGVAR(carriedObject), objNull];
[_unit, _carriedObject] call FUNC(dropObject_carry);
};
};