mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Add spectator handling of grenades (#6012)
* Handle non-local vanilla grenade tosses * handle advanced throwing grenades * Track through events * Add missing calls
This commit is contained in:
parent
46a31e1f9c
commit
8ba81c53a3
@ -21,7 +21,7 @@ params [
|
|||||||
["_weapon", "", [""]],
|
["_weapon", "", [""]],
|
||||||
"", // Muzzle
|
"", // Muzzle
|
||||||
"", // Mode
|
"", // Mode
|
||||||
"", // Ammo
|
["_ammo", "", [""]], // Ammo
|
||||||
"", // Magazine
|
"", // Magazine
|
||||||
["_projectile", objNull, [objNull]]
|
["_projectile", objNull, [objNull]]
|
||||||
];
|
];
|
||||||
@ -36,13 +36,14 @@ if (isNil QGVAR(entitiesToDraw) || {!(_unit in GVAR(entitiesToDraw))}) exitWith
|
|||||||
// Fire time used for unit icon highlighting
|
// Fire time used for unit icon highlighting
|
||||||
_unit setVariable [QGVAR(highlightTime), time + FIRE_HIGHLIGHT_TIME];
|
_unit setVariable [QGVAR(highlightTime), time + FIRE_HIGHLIGHT_TIME];
|
||||||
|
|
||||||
// Store projectiles / grenades for drawing
|
// expensive, but any non local units might have this as null for 'global' projectiles (like grenades)
|
||||||
if (GVAR(drawProjectiles) && {!isNull _projectile}) then {
|
if (isNull _projectile) then {
|
||||||
if (_weapon == "Throw") then {
|
_projectile = nearestObject [_unit, _ammo];
|
||||||
if (count GVAR(grenadesToDraw) > MAX_GRENADES) then { GVAR(grenadesToDraw) deleteAt 0; };
|
};
|
||||||
GVAR(grenadesToDraw) pushBack _projectile;
|
|
||||||
} else {
|
// Store projectiles / grenades for drawing
|
||||||
if (count GVAR(projectilesToDraw) > MAX_PROJECTILES) then { GVAR(projectilesToDraw) deleteAt 0; };
|
if (_weapon == "Throw") then {
|
||||||
GVAR(projectilesToDraw) pushBack [_projectile, [[getPosVisual _projectile, [1,0,0,0]]]];
|
[QGVAR(addToGrenadeTracking), [_projectile]] call CBA_fnc_localEvent;
|
||||||
};
|
} else {
|
||||||
|
[QGVAR(addToProjectileTracking), [_projectile]] call CBA_fnc_localEvent;
|
||||||
};
|
};
|
||||||
|
@ -103,6 +103,39 @@ if (_init) then {
|
|||||||
[] call FUNC(ui_updateListEntities);
|
[] call FUNC(ui_updateListEntities);
|
||||||
[] call FUNC(ui_updateWidget);
|
[] call FUNC(ui_updateWidget);
|
||||||
}, 5] call CBA_fnc_addPerFrameHandler;
|
}, 5] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
|
// register grenade track EH
|
||||||
|
GVAR(grenadeTrackingEH) = [
|
||||||
|
QGVAR(addToGrenadeTracking), {
|
||||||
|
params [["_projectile", objNull, [objNull]]];
|
||||||
|
if (GVAR(drawProjectiles) && {!isNull _projectile}) then {
|
||||||
|
if (count GVAR(grenadesToDraw) > MAX_GRENADES) then { GVAR(grenadesToDraw) deleteAt 0; };
|
||||||
|
GVAR(grenadesToDraw) pushBack _projectile;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
|
// register projectile track EH
|
||||||
|
GVAR(projectileTrackingEH) = [
|
||||||
|
QGVAR(addToProjectileTracking), {
|
||||||
|
params [["_projectile", objNull, [objNull]]];
|
||||||
|
if (GVAR(drawProjectiles) && {!isNull _projectile}) then {
|
||||||
|
if (count GVAR(projectilesToDraw) > MAX_PROJECTILES) then { GVAR(projectilesToDraw) deleteAt 0; };
|
||||||
|
GVAR(projectilesToDraw) pushBack [_projectile, [[getPosVisual _projectile, [1,0,0,0]]]];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
|
// register advanced throwing EH
|
||||||
|
GVAR(advancedThrowingEH) = [
|
||||||
|
QEGVAR(advanced_throwing,throwFiredXEH), {
|
||||||
|
// Fire time used for unit icon highlighting
|
||||||
|
(_this select 0) setVariable [QGVAR(highlightTime), time + FIRE_HIGHLIGHT_TIME];
|
||||||
|
|
||||||
|
// add grenade to tracking
|
||||||
|
[QGVAR(addToGrenadeTracking), [_this select 6]] CBA_fnc_localEvent;
|
||||||
|
}
|
||||||
|
] call CBA_fnc_addEventHandler;
|
||||||
} else {
|
} else {
|
||||||
// Stop updating the list and focus widget
|
// Stop updating the list and focus widget
|
||||||
[GVAR(uiPFH)] call CBA_fnc_removePerFrameHandler;
|
[GVAR(uiPFH)] call CBA_fnc_removePerFrameHandler;
|
||||||
@ -116,6 +149,18 @@ if (_init) then {
|
|||||||
[GVAR(collectPFH)] call CBA_fnc_removePerFrameHandler;
|
[GVAR(collectPFH)] call CBA_fnc_removePerFrameHandler;
|
||||||
GVAR(collectPFH) = nil;
|
GVAR(collectPFH) = nil;
|
||||||
|
|
||||||
|
// remove advanced throwing EH
|
||||||
|
[QEGVAR(advanced_throwing,throwFiredXEH), GVAR(advancedThrowingEH)] call CBA_fnc_removeEventHandler;
|
||||||
|
GVAR(advancedThrowingEH) = nil;
|
||||||
|
|
||||||
|
// remove projectile track EH
|
||||||
|
[QGVAR(addToProjectileTracking), GVAR(projectileTrackingEH)] call CBA_fnc_removeEventHandler;
|
||||||
|
GVAR(projectileTrackingEH) = nil;
|
||||||
|
|
||||||
|
// remove grenade track EH
|
||||||
|
[QGVAR(addToGrenadeTracking), GVAR(grenadeTrackingEH)] call CBA_fnc_removeEventHandler;
|
||||||
|
GVAR(grenadeTrackingEH) = nil;
|
||||||
|
|
||||||
// Destroy the display
|
// Destroy the display
|
||||||
SPEC_DISPLAY closeDisplay 1;
|
SPEC_DISPLAY closeDisplay 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user