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", "", [""]],
|
||||
"", // Muzzle
|
||||
"", // Mode
|
||||
"", // Ammo
|
||||
["_ammo", "", [""]], // Ammo
|
||||
"", // Magazine
|
||||
["_projectile", objNull, [objNull]]
|
||||
];
|
||||
@ -36,13 +36,14 @@ if (isNil QGVAR(entitiesToDraw) || {!(_unit in GVAR(entitiesToDraw))}) exitWith
|
||||
// Fire time used for unit icon highlighting
|
||||
_unit setVariable [QGVAR(highlightTime), time + FIRE_HIGHLIGHT_TIME];
|
||||
|
||||
// Store projectiles / grenades for drawing
|
||||
if (GVAR(drawProjectiles) && {!isNull _projectile}) then {
|
||||
if (_weapon == "Throw") then {
|
||||
if (count GVAR(grenadesToDraw) > MAX_GRENADES) then { GVAR(grenadesToDraw) deleteAt 0; };
|
||||
GVAR(grenadesToDraw) pushBack _projectile;
|
||||
} else {
|
||||
if (count GVAR(projectilesToDraw) > MAX_PROJECTILES) then { GVAR(projectilesToDraw) deleteAt 0; };
|
||||
GVAR(projectilesToDraw) pushBack [_projectile, [[getPosVisual _projectile, [1,0,0,0]]]];
|
||||
};
|
||||
// expensive, but any non local units might have this as null for 'global' projectiles (like grenades)
|
||||
if (isNull _projectile) then {
|
||||
_projectile = nearestObject [_unit, _ammo];
|
||||
};
|
||||
|
||||
// Store projectiles / grenades for drawing
|
||||
if (_weapon == "Throw") then {
|
||||
[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_updateWidget);
|
||||
}, 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 {
|
||||
// Stop updating the list and focus widget
|
||||
[GVAR(uiPFH)] call CBA_fnc_removePerFrameHandler;
|
||||
@ -116,6 +149,18 @@ if (_init) then {
|
||||
[GVAR(collectPFH)] call CBA_fnc_removePerFrameHandler;
|
||||
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
|
||||
SPEC_DISPLAY closeDisplay 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user