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 - Mini-Rewrite #9758

Merged
merged 46 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
46 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
3418196
Merge branch 'master' into pr/9758
johnb432 Apr 7, 2024
03babe0
Update initSettings.inc.sqf
johnb432 Apr 17, 2024
ce73a26
Merge branch 'master' into pr/9758
johnb432 Apr 28, 2024
fb12ef5
Update events-framework.md
johnb432 May 13, 2024
52bd10f
Update addons/cookoff/functions/fnc_cookOffEffect.sqf
johnb432 May 24, 2024
ff1fdac
Merged main
johnb432 May 25, 2024
2f51261
Merge branch 'cookoff-refactor' of https://github.com/johnb432/ACE3 i…
johnb432 May 25, 2024
841e76d
Restructured, redid API events
johnb432 May 25, 2024
2c614cf
Fix effect for JIP, minor optimisations
johnb432 May 29, 2024
865e8ba
Merge branch 'master' into pr/9758
johnb432 Jun 2, 2024
74137e0
Removed `cbaSettings_settingChanged`
johnb432 Jun 2, 2024
2b2c95a
Renamed variables, tweaked string table entries
johnb432 Jun 5, 2024
e720537
Merge branch 'master' into pr/9758
johnb432 Jun 5, 2024
0f69c3b
Merge branch 'master' into pr/9758
johnb432 Jun 5, 2024
1ec7ca4
Update fire damage #9991
johnb432 Jun 5, 2024
1c93107
Capitalize comments again
johnb432 Jun 5, 2024
821dddd
Fix cookoff for very short durations and fix effect removal being too…
johnb432 Jun 5, 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
3 changes: 1 addition & 2 deletions addons/cookoff/ACE_Settings.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

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
11 changes: 5 additions & 6 deletions addons/cookoff/CfgEden.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

class Cfg3DEN {
class Object {
class AttributeCategories {
Expand All @@ -7,9 +6,9 @@ class Cfg3DEN {
class GVAR(enable) {
property = QGVAR(enable);
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(enable_name);
tooltip = CSTRING(enable_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)]);
Expand All @@ -19,10 +18,10 @@ class Cfg3DEN {
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};
};
};
11 changes: 6 additions & 5 deletions addons/cookoff/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

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

[QGVAR(engineFire), FUNC(engineFire)] call CBA_fnc_addEventHandler;
[QGVAR(cookOff), {
params ["_vehicle"];
if (local _vehicle) then {
_this call FUNC(cookOff);
};
}] call CBA_fnc_addEventHandler;
[QGVAR(cookOffEffect), FUNC(cookOffEffect)] call CBA_fnc_addEventHandler;
[QGVAR(smoke), FUNC(smoke)] call CBA_fnc_addEventHandler;
[QGVAR(cookOffBox), FUNC(cookOffBox)] 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;

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;
};

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

// 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"];
// Don't add a new EH if cook-off is run multiple times
if (!isNil {_object getVariable QGVAR(deletedEH)}) exitWith {};

[QGVAR(cleanupEffects), [_vehicle]] call CBA_fnc_localEvent;
}];

_vehicle setVariable [QGVAR(deletedEH), _deletedEH];
};
_object setVariable [QGVAR(deletedEH),
_object addEventHandler ["Deleted", {
[QGVAR(cleanupEffects), _this select 0] call CBA_fnc_localEvent;
}]
];
}] call CBA_fnc_addEventHandler;

[QGVAR(cleanupEffects), {
params ["_vehicle", ["_effects", []]];
params ["_object"];

if (isServer) then {
// Reset, so that the object can cook-off again
_object setVariable [QGVAR(isCookingOff), nil, true];

_effects = _effects + (_vehicle getVariable [QGVAR(effects), []]);
if (_effects isNotEqualTo []) then {
{ deleteVehicle _x } count _effects;
// Remove effects from JIP
{
_x call CBA_fnc_removeGlobalEventJIP;
} forEach (_object getVariable [QGVAR(jipIDs), []]);

_object setVariable [QGVAR(jipIDs), nil];
};

// All effects are local (apart from sound, which is global, but is handled by server)
{
deleteVehicle _x;
} forEach (_object getVariable [QGVAR(effects), []]);

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

["ReammoBox_F", "init", {
(_this select 0) addEventHandler ["HandleDamage", {
if ((_this select 0) getVariable [QGVAR(enableAmmoCookoff), GVAR(enableAmmobox)]) then {
_this call FUNC(handleDamageBox);
};
}];
// 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)}];
}, nil, nil, true] call CBA_fnc_addClassEventHandler;

// secondary explosions
["AllVehicles", "killed", {
// Secondary explosions
["AllVehicles", "Killed", {
if (!GVAR(enableAmmoCookoff) || {GVAR(ammoCookoffDuration) == 0}) exitWith {};

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 {
[QGVAR(detonateAmmunition), [_vehicle, false, objNull, objNull, (random MAX_AMMO_DETONATION_START_DELAY) max MIN_AMMO_DETONATION_START_DELAY]] call CBA_fnc_serverEvent;
};
}, nil, ["Man","StaticWeapon"]] call CBA_fnc_addClassEventHandler;
}, nil, ["CAManBase", "StaticWeapon"]] 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 +74,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