mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
use eventhandlers instead of PFH
This commit is contained in:
parent
ec6496ed2f
commit
4ea6b91e47
@ -99,6 +99,7 @@ GVAR(OldZeusDisplayIsOpen) = !(isNull findDisplay 312);
|
|||||||
GVAR(OldCameraView) = cameraView;
|
GVAR(OldCameraView) = cameraView;
|
||||||
GVAR(OldPlayerVehicle) = vehicle ACE_player;
|
GVAR(OldPlayerVehicle) = vehicle ACE_player;
|
||||||
GVAR(OldPlayerTurret) = [ACE_player] call FUNC(getTurretIndex);
|
GVAR(OldPlayerTurret) = [ACE_player] call FUNC(getTurretIndex);
|
||||||
|
GVAR(OldPlayerWeapon) = currentWeapon ACE_player;
|
||||||
|
|
||||||
// PFH to raise varios events
|
// PFH to raise varios events
|
||||||
[{
|
[{
|
||||||
@ -159,6 +160,14 @@ GVAR(OldPlayerTurret) = [ACE_player] call FUNC(getTurretIndex);
|
|||||||
["playerTurretChanged", [ACE_player, _newPlayerTurret]] call FUNC(localEvent);
|
["playerTurretChanged", [ACE_player, _newPlayerTurret]] call FUNC(localEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// "playerWeaponChanged" event
|
||||||
|
_newPlayerWeapon = currentWeapon ACE_player;
|
||||||
|
if (_newPlayerWeapon != GVAR(OldPlayerWeapon)) then {
|
||||||
|
// Raise ACE event locally
|
||||||
|
GVAR(OldPlayerWeapon) = _newPlayerWeapon;
|
||||||
|
["playerWeaponChanged", [ACE_player, _newPlayerWeapon]] call FUNC(localEvent);
|
||||||
|
};
|
||||||
|
|
||||||
}, 0, []] call cba_fnc_addPerFrameHandler;
|
}, 0, []] call cba_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
[QGVAR(StateArrested),false,true,QUOTE(ADDON)] call FUNC(defineVariable);
|
[QGVAR(StateArrested),false,true,QUOTE(ADDON)] call FUNC(defineVariable);
|
||||||
|
@ -29,3 +29,19 @@ class Extended_Init_EventHandlers {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Extended_Killed_EventHandlers {
|
||||||
|
class CAManBase {
|
||||||
|
class ADDON {
|
||||||
|
killed = QUOTE(_this call DFUNC(handleKilled));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
class Extended_AnimChanged_EventHandlers {
|
||||||
|
class CAManBase {
|
||||||
|
class ADDON {
|
||||||
|
animChanged = QUOTE(_this call DFUNC(handleAnimChanged));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
@ -15,15 +15,5 @@ if (isNil "ACE_maxWeightCarry") then {
|
|||||||
["isNotCarrying", {!((_this select 0) getVariable [QGVAR(isCarrying), false])}] call EFUNC(common,addCanInteractWithCondition);
|
["isNotCarrying", {!((_this select 0) getVariable [QGVAR(isCarrying), false])}] call EFUNC(common,addCanInteractWithCondition);
|
||||||
|
|
||||||
// release object on player change. This does work when returning to lobby, but not when hard disconnecting.
|
// release object on player change. This does work when returning to lobby, but not when hard disconnecting.
|
||||||
["playerChanged", {
|
["playerChanged", {_this call DFUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler);
|
||||||
private ["_newPlayer", "_oldPlayer"];
|
["playerWeaponChanged", {_this call DFUNC(handlePlayerWeaponChanged)}] call EFUNC(common,addEventhandler);
|
||||||
|
|
||||||
_newPlayer = _this select 0;
|
|
||||||
_oldPlayer = _this select 1;
|
|
||||||
|
|
||||||
{
|
|
||||||
if (_x getVariable [QGVAR(isDragging), false]) then {
|
|
||||||
[_x, _x getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject);
|
|
||||||
};
|
|
||||||
} forEach [_newPlayer, _oldPlayer];
|
|
||||||
}] call EFUNC(common,addEventhandler);
|
|
||||||
|
@ -13,6 +13,10 @@ PREP(dragObjectPFH);
|
|||||||
PREP(dropObject);
|
PREP(dropObject);
|
||||||
PREP(dropObject_carry);
|
PREP(dropObject_carry);
|
||||||
PREP(getWeight);
|
PREP(getWeight);
|
||||||
|
PREP(handleAnimChanged);
|
||||||
|
PREP(handleKilled);
|
||||||
|
PREP(handlePlayerChanged);
|
||||||
|
PREP(handlePlayerWeaponChanged);
|
||||||
PREP(handleScrollWheel);
|
PREP(handleScrollWheel);
|
||||||
PREP(initObject);
|
PREP(initObject);
|
||||||
PREP(isObjectOnObject);
|
PREP(isObjectOnObject);
|
||||||
|
@ -6,13 +6,8 @@ private ["_unit", "_target"];
|
|||||||
_unit = _this select 0 select 0;
|
_unit = _this select 0 select 0;
|
||||||
_target = _this select 0 select 1;
|
_target = _this select 0 select 1;
|
||||||
|
|
||||||
if (
|
// drop if the crate is destroyed
|
||||||
!([_unit] call EFUNC(common,isAlive)) // drop if the player is dead
|
if !([_target] call EFUNC(common,isAlive)) then {
|
||||||
|| {!([_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 {
|
|
||||||
[_unit, _target] call FUNC(dropObject_carry);
|
[_unit, _target] call FUNC(dropObject_carry);
|
||||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
@ -6,13 +6,8 @@ private ["_unit", "_target"];
|
|||||||
_unit = _this select 0 select 0;
|
_unit = _this select 0 select 0;
|
||||||
_target = _this select 0 select 1;
|
_target = _this select 0 select 1;
|
||||||
|
|
||||||
if (
|
// drop if the crate is destroyed
|
||||||
!([_unit] call EFUNC(common,isAlive)) // drop if the player is dead
|
if !([_target] call EFUNC(common,isAlive)) then {
|
||||||
|| {!([_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 {
|
|
||||||
[_unit, _target] call FUNC(dropObject);
|
[_unit, _target] call FUNC(dropObject);
|
||||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
31
addons/dragging/functions/fnc_handleAnimChanged.sqf
Normal file
31
addons/dragging/functions/fnc_handleAnimChanged.sqf
Normal 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);
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
20
addons/dragging/functions/fnc_handleKilled.sqf
Normal file
20
addons/dragging/functions/fnc_handleKilled.sqf
Normal 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);
|
||||||
|
};
|
17
addons/dragging/functions/fnc_handlePlayerChanged.sqf
Normal file
17
addons/dragging/functions/fnc_handlePlayerChanged.sqf
Normal 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];
|
31
addons/dragging/functions/fnc_handlePlayerWeaponChanged.sqf
Normal file
31
addons/dragging/functions/fnc_handlePlayerWeaponChanged.sqf
Normal 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);
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user