Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookoff - Use getShotInfo for tracer detection #9911

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4f33c32
Cook-off improvements
johnb432 Jan 27, 2024
a999c81
Merge branch 'master' into cookoff-refactor
johnb432 Jan 27, 2024
d7dafa4
More changes
johnb432 Feb 3, 2024
e52990d
Update fnc_getVehicleAmmo.sqf
johnb432 Feb 3, 2024
c0a9514
Better engine fire placement
johnb432 Feb 3, 2024
26f73e1
Update fnc_detonateAmmunition.sqf
johnb432 Feb 3, 2024
c927c0e
Merged main
johnb432 Feb 4, 2024
49ca715
Update XEH_postInit.sqf
johnb432 Feb 4, 2024
16ffa2f
Update fnc_getVehicleAmmo.sqf
johnb432 Feb 4, 2024
0de629e
Update events-framework.md
johnb432 Feb 5, 2024
ed4cea6
Various improvements
johnb432 Feb 5, 2024
0ec391a
Merged main
johnb432 Feb 5, 2024
51aa46c
Separate effect handling
johnb432 Feb 6, 2024
d277fa9
Tweaks
johnb432 Feb 6, 2024
2646cc1
Update XEH_postInit.sqf
johnb432 Feb 6, 2024
db3fc19
Merge branch 'master' into pr/9758
johnb432 Feb 7, 2024
0deada7
Prevent double ammo detonation
johnb432 Feb 7, 2024
370f141
Merge branch 'master' into pr/9758
johnb432 Feb 8, 2024
e541b33
Fixed objects not being able to cook-off again
johnb432 Feb 8, 2024
0663bd1
Added incendiary rounds as source of box cookoff
johnb432 Feb 11, 2024
2cdc40a
Converted enable setting to bool
johnb432 Feb 13, 2024
bdb33d4
Fixed brackets
johnb432 Feb 13, 2024
07b73c9
Update fnc_cookOff.sqf
johnb432 Feb 13, 2024
9a7c293
Update CfgEden.hpp
johnb432 Feb 13, 2024
a2909a9
Merge branch 'master' into pr/9758
johnb432 Feb 13, 2024
cc06b37
Removed GVAR(enable), added GVAR(enableFire) back
johnb432 Feb 14, 2024
39a84be
Merge branch 'master' into pr/9758
johnb432 Mar 9, 2024
33999a0
Merge branch 'master' into pr/9758
johnb432 Apr 1, 2024
cea3f6e
Merge branch 'master' into pr/9758
johnb432 Apr 2, 2024
9cd62fc
Update fnc_handleDamageBox.sqf
johnb432 Apr 2, 2024
24d49d1
Update fnc_handleDamageBox.sqf
johnb432 Apr 2, 2024
ca49d8a
Merge branch 'master' into cookoff-tracer
johnb432 Apr 7, 2024
51c7a0f
Update fnc_handleDamageBox.sqf
johnb432 May 9, 2024
a3aeb92
Merge branch 'master' into cookoff-tracer
johnb432 May 9, 2024
87c876e
Update fnc_handleDamageBox.sqf
johnb432 May 29, 2024
d7d6eb0
Merge branch 'master' into cookoff-tracer
johnb432 Jun 5, 2024
389e1c7
Update fnc_handleDamageBox.sqf
johnb432 Jun 5, 2024
ffd07a7
Update fnc_handleDamageBox.sqf
johnb432 Jun 17, 2024
e4b2499
Merge branch 'master' into cookoff-tracer
johnb432 Aug 11, 2024
aac4675
Update addons/cookoff/functions/fnc_handleDamageBox.sqf
johnb432 Aug 11, 2024
8afffee
Merge branch 'master' into cookoff-tracer
johnb432 Oct 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ if (isServer) then {
[QGVAR(switchMove), {(_this select 0) switchMove (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(setVectorDirAndUp), {(_this select 0) setVectorDirAndUp (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(addWeaponItem), {(_this select 0) addWeaponItem [(_this select 1), (_this select 2)]}] call CBA_fnc_addEventHandler;
[QGVAR(removeMagazinesTurret), {(_this select 0) removeMagazinesTurret [_this select 1, _this select 2]}] call CBA_fnc_addEventHandler;

[QGVAR(setVanillaHitPointDamage), {
params ["_object", "_hitPointAnddamage"];
Expand Down
6 changes: 1 addition & 5 deletions addons/cookoff/ACE_Settings.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@

class ACE_Settings {
class GVAR(enable) {
movedToSqf = 1;
};
class GVAR(enableAmmobox) {
movedToSQF = 1;
};
class GVAR(enableAmmoCookoff) { // For CBA Setting Switch: we can eliminate and just use (ammoCookoffDuration == 0)
class GVAR(enableAmmoCookoff) {
movedToSQF = 1;
};
class GVAR(ammoCookoffDuration) {
Expand Down
1 change: 0 additions & 1 deletion addons/cookoff/CfgCloudlets.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

class CfgCloudlets {
class GVAR(CookOff) {
interval = 0.004;
Expand Down
17 changes: 8 additions & 9 deletions addons/cookoff/CfgEden.hpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@

class Cfg3DEN {
class Object {
class AttributeCategories {
class ace_attributes {
class Attributes {
class GVAR(enable) {
property = QGVAR(enable);
class GVAR(enable) { // setting was previously GVAR(enable), so maintain for backwards compatiblity with missions
property = QGVAR(enable); // same as above
control = "Checkbox";
displayName = CSTRING(enable_hd_name);
tooltip = CSTRING(enable_hd_tooltip);
expression = QUOTE(if !(_value) then {_this setVariable [ARR_3('%s',_value,true)];};);
displayName = CSTRING(enableFire_name);
tooltip = CSTRING(enableFire_tooltip);
expression = QUOTE(if (!_value) then {_this setVariable [ARR_3('%s',_value,true)]});
typeName = "BOOL";
condition = "objectVehicle";
defaultValue = QUOTE((GETMVAR(QGVAR(enable),0)) in [ARR_2(1,2)]);
defaultValue = QUOTE(GETMVAR(QGVAR(enableFire),true));
};
class GVAR(enableAmmoCookoff) {
property = QGVAR(enableAmmoCookoff);
control = "Checkbox";
displayName = CSTRING(enableAmmoCookoff_name);
tooltip = CSTRING(enableAmmoCookoff_tooltip);
expression = QUOTE(if !(_value) then {_this setVariable [ARR_3('%s',_value,true)];};);
expression = QUOTE(if (!_value) then {_this setVariable [ARR_3('%s',_value,true)]});
typeName = "BOOL";
condition = "objectHasInventoryCargo";
defaultValue = QUOTE(if (_this isKindOf 'ReammoBox_F') then { GETMVAR(QGVAR(enableAmmobox),true) } else { GETMVAR(QGVAR(enableAmmoCookoff),true) };);
defaultValue = QUOTE(if (_this isKindOf 'ReammoBox_F') then {GETMVAR(QGVAR(enableAmmobox),true)} else {GETMVAR(QGVAR(enableAmmoCookoff),true)});
};
};
};
Expand Down
1 change: 0 additions & 1 deletion addons/cookoff/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart));
Expand Down
1 change: 0 additions & 1 deletion addons/cookoff/CfgSFX.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

class CfgSFX {
class GVAR(CookOff_low) {
name = QGVAR(cookoff_low);
Expand Down
37 changes: 1 addition & 36 deletions addons/cookoff/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

class CfgVehicles {
class Sound;
class GVAR(Sound_low): Sound {
Expand All @@ -7,7 +6,6 @@ class CfgVehicles {
scope = 1;
sound = QGVAR(CookOff_low);
};

class GVAR(Sound_mid): GVAR(Sound_low) {
sound = QGVAR(CookOff_mid);
};
Expand All @@ -17,47 +15,14 @@ class CfgVehicles {

class Tank;
class Tank_F: Tank {
GVAR(ammoLocation) = "HitHull";
GVAR(cookoffSelections)[] = {"poklop_gunner","poklop_commander"};
GVAR(probability) = 0.5;
};
class MBT_02_base_F: Tank_F {
GVAR(ammoLocation) = "HitTurret";
};

class Car_F;
class Wheeled_APC_F: Car_F {
GVAR(ammoLocation) = "HitHull";
GVAR(cookoffSelections)[] = {"poklop_gunner","poklop_commander"};
GVAR(probability) = 0.8;

// big explosions for wheeled APCs (same as for tanks)
// Big explosions for wheeled APCs (same as for tanks)
explosionEffect = "FuelExplosionBig";
};


class MRAP_01_base_F: Car_F {
GVAR(engineSmokeOffset)[] = {0,-2,0};
};

class MRAP_02_base_F: Car_F {
GVAR(engineSmokeOffset)[] = {0,-2,0};
};

class MRAP_03_base_F: Car_F {
GVAR(engineSmokeOffset)[] = {0,-2,0};
};

class Quadbike_01_base_F: Car_F {
GVAR(engineSmokeOffset)[] = {0,1,0};
};

class Truck_F;
class Truck_02_base_F: Truck_F {
GVAR(engineSmokeOffset)[] = {0,-2.6,-0.1};
};

class Truck_02_MRL_base_F: Truck_02_base_F {
GVAR(engineSmokeOffset)[] = {0,0.3,-0.1};
};
};
12 changes: 7 additions & 5 deletions addons/cookoff/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

PREP(handleDamageBox);
PREP(engineFire);
PREP(cookOff);
PREP(smoke);
PREP(cookOffEffect);
PREP(cookOffBox);
PREP(cookOffBoxLocal);
PREP(cookOffEffect);
PREP(detonateAmmunition);
PREP(detonateAmmunitionServer);
PREP(engineFire);
PREP(engineFireLocal);
PREP(getVehicleAmmo);
PREP(handleDamageBox);
PREP(isMagazineFlare);
PREP(smoke);
91 changes: 46 additions & 45 deletions addons/cookoff/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,63 +1,64 @@
#include "script_component.hpp"

[QGVAR(engineFire), LINKFUNC(engineFire)] call CBA_fnc_addEventHandler;
[QGVAR(cookOff), {
params ["_vehicle"];
if (local _vehicle) then {
_this call FUNC(cookOff);
};
}] call CBA_fnc_addEventHandler;
[QGVAR(cookOffBoxLocal), LINKFUNC(cookOffBoxLocal)] call CBA_fnc_addEventHandler;
[QGVAR(cookOffEffect), LINKFUNC(cookOffEffect)] call CBA_fnc_addEventHandler;
[QGVAR(engineFireLocal), LINKFUNC(engineFireLocal)] call CBA_fnc_addEventHandler;
[QGVAR(smoke), LINKFUNC(smoke)] call CBA_fnc_addEventHandler;
[QGVAR(cookOffBox), LINKFUNC(cookOffBox)] call CBA_fnc_addEventHandler;

// handle cleaning up effects when vehicle is deleted mid-cookoff
[QGVAR(addCleanupHandlers), {
params ["_vehicle"];

// Don't add a new EH if cookoff is run multiple times
if ((_vehicle getVariable [QGVAR(deletedEH), -1]) == -1) then {
private _deletedEH = _vehicle addEventHandler ["Deleted", {
params ["_vehicle"];
if (isServer) then {
[QGVAR(cookOff), LINKFUNC(cookOff)] call CBA_fnc_addEventHandler;
[QGVAR(cookOffBox), LINKFUNC(cookOffBox)] call CBA_fnc_addEventHandler;
[QGVAR(engineFire), LINKFUNC(engineFire)] call CBA_fnc_addEventHandler;
[QGVAR(detonateAmmunition), LINKFUNC(detonateAmmunition)] call CBA_fnc_addEventHandler;
};

[QGVAR(cleanupEffects), [_vehicle]] call CBA_fnc_localEvent;
}];
// Handle cleaning up effects when objects are deleted mid cook-off
["AllVehicles", "Deleted", {
{
deleteVehicle _x;
} forEach ((_this select 0) getVariable [QGVAR(effects), []]);
}, true, ["CAManBase", "StaticWeapon"], true] call CBA_fnc_addClassEventHandler;

_vehicle setVariable [QGVAR(deletedEH), _deletedEH];
};
}] call CBA_fnc_addEventHandler;
["ReammoBox_F", "Deleted", {
{
deleteVehicle _x;
} forEach ((_this select 0) getVariable [QGVAR(effects), []]);
}, true, [], true] call CBA_fnc_addClassEventHandler;

// Raised when the flames have subsided or after the ammo of a box has finished cooking off
[QGVAR(cleanupEffects), {
params ["_vehicle", ["_effects", []]];
params ["_object"];

_effects = _effects + (_vehicle getVariable [QGVAR(effects), []]);
if (_effects isNotEqualTo []) then {
{ deleteVehicle _x } count _effects;
};
{
deleteVehicle _x;
} forEach (_object getVariable [QGVAR(effects), []]);

_object setVariable [QGVAR(effects), nil];
}] call CBA_fnc_addEventHandler;

// Ammo box damage handling
["ReammoBox_F", "init", {
(_this select 0) addEventHandler ["HandleDamage", {
if ((_this select 0) getVariable [QGVAR(enableAmmoCookoff), GVAR(enableAmmobox)]) then {
_this call FUNC(handleDamageBox);
};
}];
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
// Calling this function inside curly brackets allows the usage of "exitWith", which would be broken with "HandleDamage" otherwise
(_this select 0) addEventHandler ["HandleDamage", {_this call FUNC(handleDamageBox)}];
}, true, [], true] call CBA_fnc_addClassEventHandler;

// Vehicle ammo cook-off (secondary explosions)
["AllVehicles", "Killed", {
if (!GVAR(enableAmmoCookoff) || {GVAR(ammoCookoffDuration) == 0}) exitWith {};

// secondary explosions
["AllVehicles", "killed", {
params ["_vehicle", "", "", "_useEffects"];
if (
_useEffects &&
_vehicle getVariable [QGVAR(enableAmmoCookoff), GVAR(enableAmmoCookoff)]
) then {
if (GVAR(ammoCookoffDuration) == 0) exitWith {};
([_vehicle] call FUNC(getVehicleAmmo)) params ["_mags", "_total"];

private _delay = (random MAX_AMMO_DETONATION_START_DELAY) max MIN_AMMO_DETONATION_START_DELAY;
[FUNC(detonateAmmunition), [_vehicle, _mags, _total], _delay] call CBA_fnc_waitAndExecute;

if (_useEffects && {_vehicle getVariable [QGVAR(enableAmmoCookoff), true]}) then {
// We don't need to pass source and instigator, as vehicle is already dead
[QGVAR(detonateAmmunition), [
_vehicle,
false,
objNull,
objNull,
random [MIN_AMMO_DETONATION_START_DELAY, (MIN_AMMO_DETONATION_START_DELAY + MAX_AMMO_DETONATION_START_DELAY) / 2, MAX_AMMO_DETONATION_START_DELAY]
]] call CBA_fnc_serverEvent;
};
}, nil, ["Man","StaticWeapon"]] call CBA_fnc_addClassEventHandler;
}, true, ["CAManBase", "StaticWeapon"], true] call CBA_fnc_addClassEventHandler;

if (hasInterface) then {
// Plays a sound locally, so that different sounds can be used for various distances
Expand All @@ -68,7 +69,7 @@ if (hasInterface) then {

private _distance = _object distance (positionCameraToWorld [0, 0, 0]);

TRACE_3("",_object,_sound,_maxDistance);
TRACE_2("",_object,_sound);

// 3 classes of distances: close, mid and far, each having different sound files
private _classDistance = switch (true) do {
Expand Down
Loading
Loading