Added init event handlers instead of fired

This commit is contained in:
lambdatiger 2024-01-08 21:38:15 -06:00
parent 14e7ef7cba
commit 596240a57d
3 changed files with 27 additions and 35 deletions

View File

@ -17,16 +17,11 @@
// Debug info
#ifdef DEBUG_MODE_FULL
if (hasInterface && GVAR(debugOptions)) then
{
private _h = [LINKFUNC(dev_drawTrace), 0] call CBA_fnc_addPerFrameHandler;
missionNamespace setVariable [QGVAR(dev_drawPFEH), _h];
["unit", LINKFUNC(dev_switchUnitHandle), true] call CBA_fnc_addPlayerEventHandler;
[objNull, ace_player] call FUNC(dev_switchUnitHandle);
["ace_firedPlayer", LINKFUNC(fired)] call CBA_fnc_addEventHandler;
["ace_firedNonPlayer", LINKFUNC(fired)] call CBA_fnc_addEventHandler;
["ace_firedPlayerVehicle", LINKFUNC(fired)] call CBA_fnc_addEventHandler;
["ace_firedNonPlayerVehicle", LINKFUNC(fired)] call CBA_fnc_addEventHandler;
if (hasInterface && GVAR(debugOptions)) then {
private _h = [LINKFUNC(dev_drawTrace), 0] call CBA_fnc_addPerFrameHandler;
missionNamespace setVariable [QGVAR(dev_drawPFEH), _h];
["unit", LINKFUNC(dev_switchUnitHandle), true] call CBA_fnc_addPlayerEventHandler;
[objNull, ace_player] call FUNC(dev_switchUnitHandle);
};
#endif
}] call CBA_fnc_addEventHandler;

View File

@ -1,6 +1,6 @@
#define ACE_FRAG_ADD_EH class EventHandlers {\
class ADDON {\
init = QUOTE(_this call FUNC(initRound));\
init = QUOTE(_this call FUNC(initRound););\
};\
}
@ -9,7 +9,8 @@ class Bo_Mk82: BombCore {
ACE_FRAG_ADD_EH;
};
class BulletCore;
// We need this since autocannons generally inherit from BulletBase
class BulletCore;
class BulletBase: BulletCore {
ACE_FRAG_ADD_EH;
};

View File

@ -1,37 +1,32 @@
#include "script_component.hpp"
/*
* Author: Lambda.Tiger
* This function checks whether an ammunition type should cause fragmentation
* and whether any submunitions exist
*
* This function adds rounds using their config init EH
* Arguments:
* 0: _ammo <STRING> - cfgAmmo type of ammo to check
* 0: _projectile <OBJECT> - The object created
*
* Return Value:
* _shouldFrag <ARRAY>
* 0 - Should the specific round fragment
* 1 - Does the munition have a child submunition
* None
*
* Example:
* ["B_556x45_Ball"] call ace_frag_fnc_shouldFrag;
* [_proj] call ace_frag_fnc_initRound;
*
* Public: No
*/
params ["_projectile"];
private _ammo = typeOf _proj;
systemChat (str _ammo + " " + str _projectile);
if (isNil "_ammo" ||
params ["_projectile"];
private _ammo = typeOf _projectile;
if (isNil "_ammo" ||
{_ammo isEqualTo "" ||
{isNil "_projectile" ||
{isNull _projectile}}}) exitWith {
WARNING("bad ammo or projectile");
TRACE_2("bad ammo or projectile",_ammo,_projectile);
};
/******* _shouldFrag format *****/
// 0: doFragmnent - will the piece fragment
// 1: hasSubmuntion - will the round create submunitions
private _shouldFrag = _ammo call FUNC(shouldFrag);
_shouldFrag params ["_doFrag", "_doSubmunit"];
_shouldFrag params ["_doFrag"];
if (_doFrag) then {
// wait for frag damage to kill units before spawning fragments
@ -45,18 +40,19 @@ if (_doFrag) then {
];
};
if (_doSubmunit && {GVAR(enSubMunit)> 0}) then {
_projectile addEventHandler ["SubmunitionCreated", {_this call FUNC(submunition)}];
};
private _shouldSpall = _ammo call FUNC(shouldSpall);
if (GVAR(spallEnabled) && {_shouldSpall}) then
{_projectile addEventHandler [
{
_projectile addEventHandler [
"HitPart",
{
[LINKFUNC(doSpallMomentum), _this] call CBA_fnc_execNextFrame;
[QGVAR(spall_eh), [_this]] call CBA_fnc_serverEvent;
if (isServer) then {
[LINKFUNC(doSpallMomentum), _this] call CBA_fnc_execNextFrame;
} else {
[QGVAR(spall_eh), [_this]] call CBA_fnc_serverEvent;
};
}
];
};