mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
added cse_f_eh source
This commit is contained in:
parent
dc3610adb8
commit
efbe49d904
20
TO_MERGE/cse/f_eh/CfgFunctions.h
Normal file
20
TO_MERGE/cse/f_eh/CfgFunctions.h
Normal file
@ -0,0 +1,20 @@
|
||||
class CfgFunctions {
|
||||
class CSE {
|
||||
class eventhandlers {
|
||||
file = "cse\cse_f_eh\functions";
|
||||
class initialization_f {
|
||||
preInit = 1;
|
||||
postInit = 1;
|
||||
recompile = 1;
|
||||
};
|
||||
class eventHandler_f { recompile = 1; };
|
||||
class HandleHeal_EH_F { recompile = 1; };
|
||||
class HandleDamage_EH_F { recompile = 1; };
|
||||
class customEventHandler_F { recompile = 1; };
|
||||
class getCustomResults_F { recompile = 1; };
|
||||
class setEventhandler_f { recompile = 1; };
|
||||
class removeEventHandler_f { recompile = 1; };
|
||||
class addModuleEventHandlers_f { recompile = 1; };
|
||||
};
|
||||
};
|
||||
};
|
180
TO_MERGE/cse/f_eh/CfgVehicles.h
Normal file
180
TO_MERGE/cse/f_eh/CfgVehicles.h
Normal file
@ -0,0 +1,180 @@
|
||||
class CfgVehicles {
|
||||
class All;
|
||||
class AllVehicles : All {
|
||||
class EventHandlers {
|
||||
handleDamage = "[_this,'handleDamage'] call CSE_fnc_HandleDamage_EH_F;";
|
||||
HandleHeal = "[_this,'handleHeal'] call CSE_fnc_HandleHeal_EH_F;";
|
||||
local = "_this call cse_eh_cba_compat_local;";
|
||||
killed = "_this call cse_eh_cba_compat_Killed";
|
||||
firedNear = "_this call cse_eh_cba_compat_FiredNear";
|
||||
fired = "_this call cse_eh_cba_compat_Fired";
|
||||
respawn = "_this call cse_eh_cba_compat_Respawn";
|
||||
Take = "_this call cse_eh_cba_compat_Take";
|
||||
Put = "_this call cse_eh_cba_compat_Put";
|
||||
GetIn = "_this call cse_eh_cba_compat_GetIn";
|
||||
GetOut = "_this call cse_eh_cba_compat_GetOut";
|
||||
};
|
||||
};
|
||||
|
||||
class Man;
|
||||
class CAManBase: Man {
|
||||
class EventHandlers {
|
||||
handleDamage = "[_this,'handleDamage'] call CSE_fnc_HandleDamage_EH_F;";
|
||||
HandleHeal = "[_this,'handleHeal'] call CSE_fnc_HandleHeal_EH_F;";
|
||||
local = "_this call cse_eh_cba_compat_local;";
|
||||
killed = "_this call cse_eh_cba_compat_Killed";
|
||||
firedNear = "_this call cse_eh_cba_compat_FiredNear";
|
||||
fired = "_this call cse_eh_cba_compat_Fired";
|
||||
respawn = "_this call cse_eh_cba_compat_Respawn";
|
||||
Take = "_this call cse_eh_cba_compat_Take";
|
||||
Put = "_this call cse_eh_cba_compat_Put";
|
||||
GetIn = "_this call cse_eh_cba_compat_GetIn";
|
||||
GetOut = "_this call cse_eh_cba_compat_GetOut";
|
||||
};
|
||||
};
|
||||
|
||||
class SoldierGB : CAManBase{
|
||||
class EventHandlers {
|
||||
handleDamage = "[_this,'handleDamage'] call CSE_fnc_HandleDamage_EH_F;";
|
||||
HandleHeal = "[_this,'handleHeal'] call CSE_fnc_HandleHeal_EH_F;";
|
||||
local = "_this call cse_eh_cba_compat_local;";
|
||||
killed = "_this call cse_eh_cba_compat_Killed";
|
||||
firedNear = "_this call cse_eh_cba_compat_FiredNear";
|
||||
fired = "_this call cse_eh_cba_compat_Fired";
|
||||
respawn = "_this call cse_eh_cba_compat_Respawn";
|
||||
Take = "_this call cse_eh_cba_compat_Take";
|
||||
Put = "_this call cse_eh_cba_compat_Put";
|
||||
GetIn = "_this call cse_eh_cba_compat_GetIn";
|
||||
GetOut = "_this call cse_eh_cba_compat_GetOut";
|
||||
};
|
||||
};
|
||||
class SoldierWB : CAManBase {
|
||||
class EventHandlers {
|
||||
handleDamage = "[_this,'handleDamage'] call CSE_fnc_HandleDamage_EH_F;";
|
||||
HandleHeal = "[_this,'handleHeal'] call CSE_fnc_HandleHeal_EH_F;";
|
||||
local = "_this call cse_eh_cba_compat_local;";
|
||||
killed = "_this call cse_eh_cba_compat_Killed";
|
||||
firedNear = "_this call cse_eh_cba_compat_FiredNear";
|
||||
fired = "_this call cse_eh_cba_compat_Fired";
|
||||
respawn = "_this call cse_eh_cba_compat_Respawn";
|
||||
Take = "_this call cse_eh_cba_compat_Take";
|
||||
Put = "_this call cse_eh_cba_compat_Put";
|
||||
GetIn = "_this call cse_eh_cba_compat_GetIn";
|
||||
GetOut = "_this call cse_eh_cba_compat_GetOut";
|
||||
};
|
||||
};
|
||||
class SoldierEB : CAManBase{
|
||||
class EventHandlers {
|
||||
handleDamage = "[_this,'handleDamage'] call CSE_fnc_HandleDamage_EH_F;";
|
||||
HandleHeal = "[_this,'handleHeal'] call CSE_fnc_HandleHeal_EH_F;";
|
||||
local = "_this call cse_eh_cba_compat_local;";
|
||||
killed = "_this call cse_eh_cba_compat_Killed";
|
||||
firedNear = "_this call cse_eh_cba_compat_FiredNear";
|
||||
fired = "_this call cse_eh_cba_compat_Fired";
|
||||
respawn = "_this call cse_eh_cba_compat_Respawn";
|
||||
Take = "_this call cse_eh_cba_compat_Take";
|
||||
Put = "_this call cse_eh_cba_compat_Put";
|
||||
GetIn = "_this call cse_eh_cba_compat_GetIn";
|
||||
GetOut = "_this call cse_eh_cba_compat_GetOut";
|
||||
};
|
||||
};
|
||||
class B_Soldier_base_F: SoldierWB {
|
||||
class EventHandlers {
|
||||
handleDamage = "[_this,'handleDamage'] call CSE_fnc_HandleDamage_EH_F;";
|
||||
HandleHeal = "[_this,'handleHeal'] call CSE_fnc_HandleHeal_EH_F;";
|
||||
local = "_this call cse_eh_cba_compat_local;";
|
||||
killed = "_this call cse_eh_cba_compat_Killed";
|
||||
firedNear = "_this call cse_eh_cba_compat_FiredNear";
|
||||
fired = "_this call cse_eh_cba_compat_Fired";
|
||||
respawn = "_this call cse_eh_cba_compat_Respawn";
|
||||
Take = "_this call cse_eh_cba_compat_Take";
|
||||
Put = "_this call cse_eh_cba_compat_Put";
|
||||
GetIn = "_this call cse_eh_cba_compat_GetIn";
|
||||
GetOut = "_this call cse_eh_cba_compat_GetOut";
|
||||
};
|
||||
};
|
||||
class B_Soldier_03_f: B_Soldier_base_F {
|
||||
class EventHandlers {
|
||||
handleDamage = "[_this,'handleDamage'] call CSE_fnc_HandleDamage_EH_F;";
|
||||
HandleHeal = "[_this,'handleHeal'] call CSE_fnc_HandleHeal_EH_F;";
|
||||
local = "_this call cse_eh_cba_compat_local;";
|
||||
killed = "_this call cse_eh_cba_compat_Killed";
|
||||
firedNear = "_this call cse_eh_cba_compat_FiredNear";
|
||||
fired = "_this call cse_eh_cba_compat_Fired";
|
||||
respawn = "_this call cse_eh_cba_compat_Respawn";
|
||||
Take = "_this call cse_eh_cba_compat_Take";
|
||||
Put = "_this call cse_eh_cba_compat_Put";
|
||||
GetIn = "_this call cse_eh_cba_compat_GetIn";
|
||||
GetOut = "_this call cse_eh_cba_compat_GetOut";
|
||||
};
|
||||
};
|
||||
|
||||
class LandVehicle;
|
||||
class Car: LandVehicle {
|
||||
class EventHandlers {
|
||||
local = "_this call cse_eh_cba_compat_local;";
|
||||
killed = "_this call cse_eh_cba_compat_Killed";
|
||||
firedNear = "_this call cse_eh_cba_compat_FiredNear";
|
||||
fired = "_this call cse_eh_cba_compat_Fired";
|
||||
respawn = "_this call cse_eh_cba_compat_Respawn";
|
||||
Take = "_this call cse_eh_cba_compat_Take";
|
||||
Put = "_this call cse_eh_cba_compat_Put";
|
||||
GetIn = "_this call cse_eh_cba_compat_GetIn";
|
||||
GetOut = "_this call cse_eh_cba_compat_GetOut";
|
||||
};
|
||||
};
|
||||
class Tank: LandVehicle {
|
||||
class EventHandlers {
|
||||
local = "_this call cse_eh_cba_compat_local;";
|
||||
killed = "_this call cse_eh_cba_compat_Killed";
|
||||
firedNear = "_this call cse_eh_cba_compat_FiredNear";
|
||||
fired = "_this call cse_eh_cba_compat_Fired";
|
||||
respawn = "_this call cse_eh_cba_compat_Respawn";
|
||||
Take = "_this call cse_eh_cba_compat_Take";
|
||||
Put = "_this call cse_eh_cba_compat_Put";
|
||||
GetIn = "_this call cse_eh_cba_compat_GetIn";
|
||||
GetOut = "_this call cse_eh_cba_compat_GetOut";
|
||||
};
|
||||
};
|
||||
|
||||
class Air;
|
||||
class Helicopter: Air {
|
||||
class EventHandlers {
|
||||
local = "_this call cse_eh_cba_compat_local;";
|
||||
killed = "_this call cse_eh_cba_compat_Killed";
|
||||
firedNear = "_this call cse_eh_cba_compat_FiredNear";
|
||||
fired = "_this call cse_eh_cba_compat_Fired";
|
||||
respawn = "_this call cse_eh_cba_compat_Respawn";
|
||||
Take = "_this call cse_eh_cba_compat_Take";
|
||||
Put = "_this call cse_eh_cba_compat_Put";
|
||||
GetIn = "_this call cse_eh_cba_compat_GetIn";
|
||||
GetOut = "_this call cse_eh_cba_compat_GetOut";
|
||||
};
|
||||
};
|
||||
class Plane: Air {
|
||||
class EventHandlers {
|
||||
local = "_this call cse_eh_cba_compat_local;";
|
||||
killed = "_this call cse_eh_cba_compat_Killed";
|
||||
firedNear = "_this call cse_eh_cba_compat_FiredNear";
|
||||
fired = "_this call cse_eh_cba_compat_Fired";
|
||||
respawn = "_this call cse_eh_cba_compat_Respawn";
|
||||
Take = "_this call cse_eh_cba_compat_Take";
|
||||
Put = "_this call cse_eh_cba_compat_Put";
|
||||
GetIn = "_this call cse_eh_cba_compat_GetIn";
|
||||
GetOut = "_this call cse_eh_cba_compat_GetOut";
|
||||
};
|
||||
};
|
||||
class Ship: AllVehicles {
|
||||
class EventHandlers {
|
||||
local = "_this call cse_eh_cba_compat_local;";
|
||||
killed = "_this call cse_eh_cba_compat_Killed";
|
||||
firedNear = "_this call cse_eh_cba_compat_FiredNear";
|
||||
fired = "_this call cse_eh_cba_compat_Fired";
|
||||
respawn = "_this call cse_eh_cba_compat_Respawn";
|
||||
Take = "_this call cse_eh_cba_compat_Take";
|
||||
Put = "_this call cse_eh_cba_compat_Put";
|
||||
GetIn = "_this call cse_eh_cba_compat_GetIn";
|
||||
GetOut = "_this call cse_eh_cba_compat_GetOut";
|
||||
};
|
||||
};
|
||||
};
|
13
TO_MERGE/cse/f_eh/Combat_Space_Enhancement.h
Normal file
13
TO_MERGE/cse/f_eh/Combat_Space_Enhancement.h
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
class Combat_Space_Enhancement {
|
||||
class EventHandlers {
|
||||
class PreInit_EventHandlers {
|
||||
class cse_xeh_fired_eventHandler_Compat {
|
||||
init = "call compile preprocessFile 'cse\cse_f_eh\cba_compat_init.sqf';";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class CustomResults {};
|
||||
class CustomEventHandlers {};
|
||||
};
|
103
TO_MERGE/cse/f_eh/Extended_Init_EventHandlers.h
Normal file
103
TO_MERGE/cse/f_eh/Extended_Init_EventHandlers.h
Normal file
@ -0,0 +1,103 @@
|
||||
class Extended_Fired_Eventhandlers
|
||||
{
|
||||
class AllVehicles
|
||||
{
|
||||
class cse_CBA_COMPAT_XEH
|
||||
{
|
||||
Fired = "[_this,'fired'] call cse_fnc_eventHandler_F;";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_HandleDamage_Eventhandlers
|
||||
{
|
||||
class AllVehicles
|
||||
{
|
||||
class cse_CBA_COMPAT_XEH
|
||||
{
|
||||
handleDamage = "[_this,'handleDamage'] call CSE_fnc_HandleDamage_EH_F;";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_FiredNear_Eventhandlers
|
||||
{
|
||||
class AllVehicles
|
||||
{
|
||||
class cse_CBA_COMPAT_XEH
|
||||
{
|
||||
FiredNear = "[_this,'firedNear'] call cse_fnc_eventHandler_F;";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_Killed_Eventhandlers
|
||||
{
|
||||
class AllVehicles
|
||||
{
|
||||
class cse_CBA_COMPAT_XEH
|
||||
{
|
||||
Killed = "[_this,'killed'] call cse_fnc_eventHandler_F;";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_Local_Eventhandlers
|
||||
{
|
||||
class AllVehicles
|
||||
{
|
||||
class cse_CBA_COMPAT_XEH
|
||||
{
|
||||
Local = "[_this,'local'] call cse_fnc_eventHandler_F;";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_Respawn_Eventhandlers
|
||||
{
|
||||
class AllVehicles
|
||||
{
|
||||
class cse_CBA_COMPAT_XEH {
|
||||
Respawn = "[_this,'respawn'] call cse_fnc_eventHandler_F;";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_Take_Eventhandlers
|
||||
{
|
||||
class AllVehicles
|
||||
{
|
||||
class cse_CBA_COMPAT_XEH {
|
||||
Take = "[_this,'take'] call cse_fnc_eventHandler_F;";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_Put_Eventhandlers
|
||||
{
|
||||
class AllVehicles
|
||||
{
|
||||
class cse_CBA_COMPAT_XEH {
|
||||
Put = "[_this,'put'] call cse_fnc_eventHandler_F;";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_GetIn_Eventhandlers
|
||||
{
|
||||
class AllVehicles
|
||||
{
|
||||
class cse_CBA_COMPAT_XEH {
|
||||
GetIn = "[_this,'getIn'] call cse_fnc_eventHandler_F;";
|
||||
};
|
||||
};
|
||||
};
|
||||
class Extended_GetOut_EventHandlers
|
||||
{
|
||||
class AllVehicles
|
||||
{
|
||||
class cse_CBA_COMPAT_XEH {
|
||||
GetOut = "[_this,'getOut'] call cse_fnc_eventHandler_F;";
|
||||
};
|
||||
};
|
||||
};
|
19
TO_MERGE/cse/f_eh/cba_compat_init.sqf
Normal file
19
TO_MERGE/cse/f_eh/cba_compat_init.sqf
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* cba_compat_init.sqf
|
||||
* @Descr: CBA compatability wrapper.
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return: void
|
||||
* @PublicAPI: false
|
||||
*/
|
||||
|
||||
cse_eh_cba_compat_local = if (!isClass (configFile >> 'CfgPatches' >> 'CBA_main')) then { {[_this,'local'] call cse_fnc_eventHandler_F;} } else {{}};
|
||||
cse_eh_cba_compat_Respawn = if (!isClass (configFile >> 'CfgPatches' >> 'CBA_main')) then { {[_this,'respawn'] call cse_fnc_eventHandler_F;} } else {{}};
|
||||
cse_eh_cba_compat_Killed = if (!isClass (configFile >> 'CfgPatches' >> 'CBA_main')) then { {[_this,'killed'] call cse_fnc_eventHandler_F;} } else {{}};
|
||||
cse_eh_cba_compat_FiredNear = if (!isClass (configFile >> 'CfgPatches' >> 'CBA_main')) then { {[_this,'firedNear'] call cse_fnc_eventHandler_F;} } else {{}};
|
||||
cse_eh_cba_compat_Fired = if (!isClass (configFile >> 'CfgPatches' >> 'CBA_main')) then { {[_this,'fired'] call cse_fnc_eventHandler_F;} } else {{}};
|
||||
cse_eh_cba_compat_Take = if (!isClass (configFile >> 'CfgPatches' >> 'CBA_main')) then { {[_this,'Take'] call cse_fnc_eventHandler_F;} } else {{}};
|
||||
cse_eh_cba_compat_Put = if (!isClass (configFile >> 'CfgPatches' >> 'CBA_main')) then { {[_this,'Put'] call cse_fnc_eventHandler_F;} } else {{}};
|
||||
cse_eh_cba_compat_GetIn = if (!isClass (configFile >> 'CfgPatches' >> 'CBA_main')) then { {[_this,'GetIn'] call cse_fnc_eventHandler_F;} } else {{}};
|
||||
cse_eh_cba_compat_GetOut = if (!isClass (configFile >> 'CfgPatches' >> 'CBA_main')) then { {[_this,'GetOut'] call cse_fnc_eventHandler_F;} } else {{}};
|
31
TO_MERGE/cse/f_eh/config.cpp
Normal file
31
TO_MERGE/cse/f_eh/config.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
class CfgPatches
|
||||
{
|
||||
class cse_f_eh
|
||||
{
|
||||
units[] = {};
|
||||
weapons[] = {};
|
||||
requiredVersion = 0.1;
|
||||
requiredAddons[] = {/*"cba_extended_eventhandlers", "cba_xeh", "extended_eventhandlers"*/ "A3_Characters_F","A3_Boat_F","A3_animals_f","A3_air_f","A3_soft_f","A3_static_f","A3_weapons_f","a3_structures_f"};
|
||||
version = "0.10.0_rc";
|
||||
author[] = {"Combat Space Enhancement"};
|
||||
authorUrl = "http://csemod.com";
|
||||
};
|
||||
};
|
||||
class CfgAddons {
|
||||
class PreloadAddons {
|
||||
class cse_f_eh {
|
||||
list[] = {"cse_f_eh"};
|
||||
};
|
||||
};
|
||||
};
|
||||
/* Event handlers */
|
||||
#include "CfgVehicles.h"
|
||||
|
||||
/* For CBA Compatability */
|
||||
#include "Extended_Init_EventHandlers.h"
|
||||
|
||||
/* Ensures that the functions are being compiled */
|
||||
#include "CfgFunctions.h"
|
||||
|
||||
/* To ensure that the custom eventhandler classes exist */
|
||||
#include "Combat_Space_Enhancement.h"
|
54
TO_MERGE/cse/f_eh/functions/fn_HandleHeal_eh_f.sqf
Normal file
54
TO_MERGE/cse/f_eh/functions/fn_HandleHeal_eh_f.sqf
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* fn_HandleHeal_eh_f.sqf
|
||||
* @Descr: Execute the handleHeal Eventhandlers. Is currently bugged due to Arma Engine problem?
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return: BOOL Returns true if handleHeal has been fully handled
|
||||
* @PublicAPI: false
|
||||
*/
|
||||
|
||||
private ["_vehicle","_allPreInitHandlers","_handle","_totalValue","_cfg","_amountOfHandlers", "_newCfg","_returnValue","_ehCfg"];
|
||||
_vehicle = (_this select 0) select 1;
|
||||
_handle = _this select 1;
|
||||
_allPreInitHandlers = [];
|
||||
|
||||
if (!local _vehicle) exitwith {};
|
||||
if (isnil "CSE_fnc_HandleHeal_EH_F") then {
|
||||
CSE_fnc_HandleHeal_EH_F = compile preProcessFileLineNumbers '\cse\cse_f_eh\fn_HandleHeal_EH_F.sqf';
|
||||
};
|
||||
|
||||
if (isnil "CSE_F_MODULE_OBJ_EH") then {
|
||||
CSE_F_MODULE_OBJ_EH = [];
|
||||
};
|
||||
{
|
||||
|
||||
_cfg = (ConfigFile >> "Combat_Space_Enhancement" >> "CfgModules" >> _x);
|
||||
if (isClass _cfg) then {
|
||||
if (isClass (_cfg >> "EventHandlers")) then {
|
||||
_numberOfEH = count (_cfg >> "EventHandlers");
|
||||
for "_j" from 0 to (_numberOfEH -1) /* step +1 */ do {
|
||||
//for [{_j=0}, {_j< _numberOfEH}, {_j=_j+1}] do {
|
||||
_ehCfg = ((_cfg >> "EventHandlers") select _j);
|
||||
if (isClass _ehCfg) then {
|
||||
if (_vehicle isKindOf (ConfigName _ehCfg)) then {
|
||||
_allPreInitHandlers pushback compile getText(_ehCfg >> _handle);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}foreach CSE_F_MODULE_OBJ_EH;
|
||||
{
|
||||
private ["_returnValue"];
|
||||
_returnValue = (_this select 0) call _x;
|
||||
}foreach _allPreInitHandlers;
|
||||
[_allPreInitHandlers] call cse_fnc_debug;
|
||||
|
||||
AISFinishHeal [(_this select 0) select 0, (_this select 0) select 1, (_this select 0) select 2];
|
||||
|
||||
if (count _allPreInitHandlers > 0) then {
|
||||
true;
|
||||
} else {
|
||||
false;
|
||||
};
|
64
TO_MERGE/cse/f_eh/functions/fn_addModuleEventhandlers_f.sqf
Normal file
64
TO_MERGE/cse/f_eh/functions/fn_addModuleEventhandlers_f.sqf
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* fn_addModuleEventhandlers_f.sqf
|
||||
* @Descr: N/A
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: false
|
||||
*/
|
||||
|
||||
private ["_entity", "_handle", "_eventHandlerName", "_eventHandlerCollection", "_cfg", "_numberOfEH", "_ehCfg", "_classType", "_text", "_code", "_eventHandlerCollection","_collectedEHIDs", "_collectedID_VarName"];
|
||||
_entity = _this select 0;
|
||||
_handle = _this select 1;
|
||||
|
||||
_eventHandlerName = ("cse_f_eventhandler_" + _handle);
|
||||
|
||||
_eventHandlerCollection = missionNamespace getvariable _eventHandlerName;
|
||||
if (isnil "_eventHandlerCollection") then {
|
||||
_eventHandlerCollection = [];
|
||||
{
|
||||
_cfg = (ConfigFile >> "Combat_Space_Enhancement" >> "CfgModules" >> _x >> "EventHandlers");
|
||||
if (isClass (_cfg)) then {
|
||||
_numberOfEH = count (_cfg);
|
||||
|
||||
for "_EHiterator" from 0 to (_numberOfEH -1) do {
|
||||
_ehCfg = ((_cfg) select _EHiterator);
|
||||
if (isClass _ehCfg) then {
|
||||
_classType = (ConfigName _ehCfg);
|
||||
_text = getText(_ehCfg >> _handle);
|
||||
if (_text != "") then {
|
||||
_code = (compile _text);
|
||||
_eventHandlerCollection pushBack [_classType, _code, _x];
|
||||
true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}count CSE_F_MODULE_OBJ_EH;
|
||||
missionNamespace setvariable [_eventHandlerName, _eventHandlerCollection];
|
||||
if (isnil "cse_f_eventhandlers_collection") then {
|
||||
cse_f_eventhandlers_collection = [];
|
||||
};
|
||||
cse_f_eventhandlers_collection pushBack _eventHandlerName;
|
||||
};
|
||||
|
||||
_collectedID_VarName = format["cse_addModuleEventHandlers_f_%1_ids", _handle];
|
||||
|
||||
// clear all module eventhandlers first
|
||||
_collectedEHIDs = _entity getvariable [_collectedID_VarName, []];
|
||||
{
|
||||
[_entity, _handle, _x] call cse_fnc_removeEventHandler_F;
|
||||
}foreach _collectedEHIDs;
|
||||
|
||||
// now we add the new ones
|
||||
_collectedEHIDs = [];
|
||||
{
|
||||
if (_entity isKindOf (_x select 0)) then {
|
||||
_collectedEHIDs pushback (format["cse_moduleEventhandlerID_", _foreachIndex]);
|
||||
[_entity, _handle, format["cse_moduleEventhandlerID_", _foreachIndex], _x select 1] call cse_fnc_setEventhandler_f;
|
||||
};
|
||||
}foreach _eventHandlerCollection;
|
||||
|
||||
// Store the new IDs
|
||||
_entity setvariable [_collectedID_VarName, _collectedEHIDs];
|
61
TO_MERGE/cse/f_eh/functions/fn_customEventHandler_f.sqf
Normal file
61
TO_MERGE/cse/f_eh/functions/fn_customEventHandler_f.sqf
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* fn_customEventHandler_f.sqf
|
||||
* @Descr: Execute a custom defined eventhandler.
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: [arguments ANY, handle STRING (The name of the eventhandler)]
|
||||
* @Return: ARRAY Array containing the results of the called eventhandlers.
|
||||
* @PublicAPI: true
|
||||
*/
|
||||
|
||||
|
||||
private ["_arguments","_handle","_ehCfg","_eventHandlerCollection","_eventHandlerName","_cfg","_code","_classType", "_return"];
|
||||
_arguments = _this select 0;
|
||||
_handle = _this select 1;
|
||||
|
||||
_eventHandlerName = ("cse_f_custom_eventhandler_" + _handle);
|
||||
_eventHandlerCollection = missionNamespace getvariable _eventHandlerName;
|
||||
if (isnil "_eventHandlerCollection") then {
|
||||
_eventHandlerCollection = [];
|
||||
[format["caching Custom Eventhandler: %1",_handle]] call cse_fnc_debug;
|
||||
_cfg = (ConfigFile >> "Combat_Space_Enhancement" >> "CustomEventHandlers" >> _handle);
|
||||
if (isClass _cfg) then {
|
||||
_numberOfEH = count _cfg;
|
||||
|
||||
for "_EHiterator" from 0 to (_numberOfEH -1) /* step +1 */ do {
|
||||
//for [{_EHiterator=0}, {(_EHiterator< _numberOfEH)}, {_EHiterator=_EHiterator+1}] do {
|
||||
_ehCfg = _cfg select _EHiterator;
|
||||
if (isClass _ehCfg) then {
|
||||
_classType = (ConfigName _ehCfg);
|
||||
_code = (compile getText(_ehCfg >> "onCall"));
|
||||
_eventHandlerCollection pushback [_classType, _code];
|
||||
true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
_cfg = (MissionConfigFile >> "Combat_Space_Enhancement" >> "CustomEventHandlers" >> _handle);
|
||||
if (isClass _cfg) then {
|
||||
_numberOfEH = count _cfg;
|
||||
for "_EHiterator" from 0 to (_numberOfEH -1) /* step +1 */ do {
|
||||
//for [{_EHiterator=0}, {(_EHiterator< _numberOfEH)}, {_EHiterator=_EHiterator+1}] do {
|
||||
_ehCfg = _cfg select _EHiterator;
|
||||
if (isClass _ehCfg) then {
|
||||
_classType = (ConfigName _ehCfg);
|
||||
_code = (compile getText(_ehCfg >> "onCall"));
|
||||
_eventHandlerCollection pushback [_classType, _code];
|
||||
true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
missionNamespace setvariable [_eventHandlerName, _eventHandlerCollection];
|
||||
[format["Custom Eventhandler: %1 cache: %2",_handle, _eventHandlerCollection]] call cse_fnc_debug;
|
||||
};
|
||||
|
||||
_return = [];
|
||||
{
|
||||
_return pushback (_arguments call (_x select 1));
|
||||
}foreach _eventHandlerCollection;
|
||||
|
||||
_return
|
65
TO_MERGE/cse/f_eh/functions/fn_eventHandler_f.sqf
Normal file
65
TO_MERGE/cse/f_eh/functions/fn_eventHandler_f.sqf
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* fn_eventHandler_f.sqf
|
||||
* @Descr: Execute eventhandlers
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return: void
|
||||
* @PublicAPI: false
|
||||
*/
|
||||
|
||||
private ["_args","_handle","_entity","_cfgFile","_cfg","_numberOfEH","_ehCfg","_value", "_code", "_eventHandlerCollection", "_classType", "_eventHandlerName"];
|
||||
_args = _this select 0;
|
||||
_handle = _this select 1;
|
||||
_entity = _args select 0;
|
||||
|
||||
if (isnil "CSE_F_MODULE_OBJ_EH") then {
|
||||
CSE_F_MODULE_OBJ_EH = [];
|
||||
};
|
||||
|
||||
if (!(local _entity) && _handle != "fired") exitwith {};
|
||||
_eventHandlerName = ("cse_f_eventhandler_" + _handle);
|
||||
|
||||
_eventHandlerCollection = missionNamespace getvariable _eventHandlerName;
|
||||
if (isnil "_eventHandlerCollection") then {
|
||||
_eventHandlerCollection = [];
|
||||
{
|
||||
_cfg = (ConfigFile >> "Combat_Space_Enhancement" >> "CfgModules" >> _x >> "EventHandlers");
|
||||
if (isClass (_cfg)) then {
|
||||
_numberOfEH = count (_cfg);
|
||||
|
||||
for "_EHiterator" from 0 to (_numberOfEH -1) do {
|
||||
_ehCfg = ((_cfg) select _EHiterator);
|
||||
if (isClass _ehCfg) then {
|
||||
_classType = (ConfigName _ehCfg);
|
||||
_text = getText(_ehCfg >> _handle);
|
||||
if (_text != "") then {
|
||||
_code = (compile _text);
|
||||
_eventHandlerCollection pushBack [_classType, _code, _x];
|
||||
true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}count CSE_F_MODULE_OBJ_EH;
|
||||
missionNamespace setvariable [_eventHandlerName, _eventHandlerCollection];
|
||||
if (isnil "cse_f_eventhandlers_collection") then {
|
||||
cse_f_eventhandlers_collection = [];
|
||||
};
|
||||
cse_f_eventhandlers_collection pushBack _eventHandlerName;
|
||||
};
|
||||
|
||||
_setHandler = _entity getvariable ("cse_f_setEventhandler_" + _handle);
|
||||
if (isnil "_setHandler") then {
|
||||
{
|
||||
if (_entity isKindOf (_x select 0)) then {
|
||||
_args call (_x select 1);
|
||||
};
|
||||
false;
|
||||
}count _eventHandlerCollection;
|
||||
} else {
|
||||
{
|
||||
_args call (_X select 1);
|
||||
false;
|
||||
}count _setHandler;
|
||||
};
|
42
TO_MERGE/cse/f_eh/functions/fn_getCustomResults_f.sqf
Normal file
42
TO_MERGE/cse/f_eh/functions/fn_getCustomResults_f.sqf
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* fn_getCustomResults_f.sqf
|
||||
* @Descr: Executes custom results eventhandlers, collects their output and returns this.
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: [arguments ANY, handle STRING]
|
||||
* @Return: ARRAY Collection of all return values of all executed CustomResult handlers
|
||||
* @PublicAPI: true
|
||||
*/
|
||||
|
||||
|
||||
private ["_arguments","_handle","_ehCfg","_eventHandlerCollection","_eventHandlerName","_cfg","_code","_classType", "_return"];
|
||||
_arguments = _this select 0;
|
||||
_handle = _this select 1;
|
||||
|
||||
_eventHandlerName = ("cse_f_custom_results_eventhandler_" + _handle);
|
||||
_eventHandlerCollection = missionNamespace getvariable _eventHandlerName;
|
||||
if (isnil "_eventHandlerCollection") then {
|
||||
_eventHandlerCollection = [];
|
||||
|
||||
_cfg = (ConfigFile >> "Combat_Space_Enhancement" >> "CustomResults" >> _handle);
|
||||
if (isClass _cfg) then {
|
||||
_numberOfEH = count _cfg;
|
||||
for [{_EHiterator=0}, {(_EHiterator< _numberOfEH)}, {_EHiterator=_EHiterator+1}] do {
|
||||
_ehCfg = _cfg select _EHiterator;
|
||||
if (isClass _ehCfg) then {
|
||||
_classType = (ConfigName _ehCfg);
|
||||
_code = (compile getText(_ehCfg >> "onCall"));
|
||||
_eventHandlerCollection set [ count _eventHandlerCollection, [_classType, _code]];
|
||||
true;
|
||||
};
|
||||
};
|
||||
};
|
||||
missionNamespace setvariable [_eventHandlerName, _eventHandlerCollection];
|
||||
};
|
||||
|
||||
_return = [];
|
||||
{
|
||||
_return set [ count _return, _arguments call (_x select 1) ];
|
||||
}foreach _eventHandlerCollection;
|
||||
|
||||
_return
|
79
TO_MERGE/cse/f_eh/functions/fn_handleDamage_eh_f.sqf
Normal file
79
TO_MERGE/cse/f_eh/functions/fn_handleDamage_eh_f.sqf
Normal file
@ -0,0 +1,79 @@
|
||||
/**
|
||||
* fn_handleDamage_eh_f.sqf
|
||||
* @Descr: Execute the handleDamage Eventhandler
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return: NUMBER Returns a number based on output of executed eventhandlers
|
||||
* @PublicAPI: false
|
||||
*/
|
||||
|
||||
private ["_vehicle","_allPreInitHandlers","_handle","_totalValue","_cfg","_amountOfHandlers", "_newCfg","_returnValue","_ehCfg", "_fullDamage", "_returnDamage"];
|
||||
_vehicle = (_this select 0) select 0;
|
||||
_handle = _this select 1;
|
||||
if (!local _vehicle) exitwith {};
|
||||
if (_vehicle isKindOf "CAManBase") then {
|
||||
_name = _vehicle getVariable "cse_name";
|
||||
if (isNil "_name") then {
|
||||
_vehicle setvariable ["cse_name", name _vehicle, true];
|
||||
};
|
||||
};
|
||||
|
||||
_eventHandlerName = "cse_f_eventhandler_handleDamage";
|
||||
_eventHandlerCollection = missionNamespace getvariable _eventHandlerName;
|
||||
if (isnil "_eventHandlerCollection") then {
|
||||
_eventHandlerCollection = [];
|
||||
if (isnil "CSE_F_MODULE_OBJ_EH") then {
|
||||
CSE_F_MODULE_OBJ_EH = [];
|
||||
};
|
||||
{
|
||||
_cfg = (ConfigFile >> "Combat_Space_Enhancement" >> "CfgModules" >> _x);
|
||||
if (isClass _cfg) then {
|
||||
if (isClass (_cfg >> "EventHandlers")) then {
|
||||
_numberOfEH = count (_cfg >> "EventHandlers");
|
||||
|
||||
for "_j" from 0 to (_numberOfEH -1) /* step +1 */ do {
|
||||
//for [{_j=0}, {_j< _numberOfEH}, {_j=_j+1}] do {
|
||||
_ehCfg = ((_cfg >> "EventHandlers") select _j);
|
||||
if (isClass _ehCfg) then {
|
||||
if (getText(_ehCfg >> _handle) != "") then {
|
||||
_eventHandlerCollection pushBack [(ConfigName _ehCfg), compile getText(_ehCfg >> _handle)];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}foreach CSE_F_MODULE_OBJ_EH;
|
||||
missionNamespace setvariable [_eventHandlerName, _eventHandlerCollection];
|
||||
|
||||
if (isnil "cse_f_eventhandlers_collection") then {
|
||||
cse_f_eventhandlers_collection = [];
|
||||
};
|
||||
cse_f_eventhandlers_collection pushBack _eventHandlerName;
|
||||
};
|
||||
_returnDamage = (_this select 0) select 2;
|
||||
{
|
||||
if (_vehicle isKindOf (_x select 0)) then {
|
||||
private "_returnValue";
|
||||
_returnValue = (_this select 0) call (_x select 1);
|
||||
if (!isnil "_returnValue") then {
|
||||
if (typeName _returnValue == typeName 0) then {
|
||||
_returnDamage = _returnValue;
|
||||
};
|
||||
};
|
||||
};
|
||||
}foreach _eventHandlerCollection;
|
||||
|
||||
if (typeName _returnDamage == typeName 0) then {
|
||||
if (_returnDamage >= 0.9) then {
|
||||
if (isnil "CSE_ENABLE_REVIVE_F") then {
|
||||
CSE_ENABLE_REVIVE_F = 0;
|
||||
};
|
||||
if ((CSE_ENABLE_REVIVE_F == 1 && isPlayer _vehicle) || (CSE_ENABLE_REVIVE_F == 2)) then {
|
||||
_returnDamage = 0.9;
|
||||
};
|
||||
};
|
||||
} else {
|
||||
_returnDamage = (_this select 0) select 2;
|
||||
};
|
||||
_returnDamage
|
55
TO_MERGE/cse/f_eh/functions/fn_initialization_f.sqf
Normal file
55
TO_MERGE/cse/f_eh/functions/fn_initialization_f.sqf
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
* fn_initialization_f.sqf
|
||||
* @Descr: Grabs all pre and post init defined events from the config files and executes those.
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: [setToExecute STRING]
|
||||
* @Return: void
|
||||
* @PublicAPI: false
|
||||
*/
|
||||
|
||||
private ["_allPreInitHandlers","_cfg","_cfgOpt","_text"];
|
||||
_allPreInitHandlers = [];
|
||||
|
||||
if ((_this select 0) == "preInit") then {
|
||||
_cfg = (ConfigFile >> "Combat_Space_Enhancement" >> "EventHandlers" >> "PreInit_EventHandlers");
|
||||
|
||||
for "_i" from 0 to ((count _cfg)-1) /* step +1 */ do {
|
||||
_this spawn (compile (getText ((_cfg select _i) >> "init")));
|
||||
};
|
||||
} else {
|
||||
if ((_this select 0) == "postInit") then {
|
||||
_cfg = (ConfigFile >> "Combat_Space_Enhancement" >> "EventHandlers" >> "PostInit_EventHandlers");
|
||||
|
||||
for "_i" from 0 to ((count _cfg)-1) /* step +1 */ do {
|
||||
_this spawn (compile (getText ((_cfg select _i) >> "init")));
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
if (isnil "CSE_F_EH_ALLOW_MISSION_CONFIG") then {
|
||||
CSE_F_EH_ALLOW_MISSION_CONFIG = true;
|
||||
};
|
||||
|
||||
if (CSE_F_EH_ALLOW_MISSION_CONFIG) then {
|
||||
_allPreInitHandlers = [];
|
||||
if ((_this select 0) == "preInit") then {
|
||||
_cfg = (missionConfigFile >> "Combat_Space_Enhancement" >> "EventHandlers" >> "PreInit_EventHandlers");
|
||||
|
||||
for "_i" from 0 to ((count _cfg)-1) /* step +1 */ do {
|
||||
_this spawn (compile (getText ((_cfg select _i) >> "init")));
|
||||
};
|
||||
} else {
|
||||
if ((_this select 0) == "postInit") then {
|
||||
_cfg = (missionConfigFile >> "Combat_Space_Enhancement" >> "EventHandlers" >> "PostInit_EventHandlers");
|
||||
|
||||
for "_i" from 0 to ((count _cfg)-1) /* step +1 */ do {
|
||||
_this spawn (compile (getText ((_cfg select _i) >> "init")));
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
if ((_this select 0) == "postInit") then {
|
||||
cse_postInit = true;
|
||||
};
|
33
TO_MERGE/cse/f_eh/functions/fn_removeEventhandler_f.sqf
Normal file
33
TO_MERGE/cse/f_eh/functions/fn_removeEventhandler_f.sqf
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* fn_removeEventhandler_f.sqf
|
||||
* @Descr: Removes an eventhandler with the specified ID
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: [object OBJECT, handler STRING, id STRING]
|
||||
* @Return: nil
|
||||
* @PublicAPI: true
|
||||
*/
|
||||
|
||||
private ["_obj", "_handler", "_id", "_varName", "_handlers", "_newHandlers"];
|
||||
_obj = _this select 0;
|
||||
_handler = _this select 1;
|
||||
_id = _this select 2;
|
||||
|
||||
_varName = "cse_f_setEventhandler_" + _handler;
|
||||
_handlers = _obj getvariable [_varName, []];
|
||||
|
||||
_newHandlers = [];
|
||||
{
|
||||
if (_x select 0 != _id) then {
|
||||
_newHandlers pushback _x;
|
||||
};
|
||||
}foreach _handlers;
|
||||
|
||||
if (count _newHandlers > 0) then {
|
||||
_obj setvariable [_varName, _newHandlers];
|
||||
} else {
|
||||
// remove and default to original CSE handlers
|
||||
_obj setvariable [_varName, nil];
|
||||
};
|
||||
|
||||
true;
|
35
TO_MERGE/cse/f_eh/functions/fn_setEventhandler_f.sqf
Normal file
35
TO_MERGE/cse/f_eh/functions/fn_setEventhandler_f.sqf
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* fn_setEventhandler_f.sqf
|
||||
* @Descr: Set the event handler for a specific object. Stacks. Overwrites the CSE module eventhandlers.
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: [object OBJECT, handler STRING, id STRING, code CODE]
|
||||
* @Return: nil
|
||||
* @PublicAPI: true
|
||||
*/
|
||||
|
||||
private ["_obj", "_handler", "_id", "_code", "_varName", "_handlers", "_found"];
|
||||
_obj = _this select 0;
|
||||
_handler = _this select 1;
|
||||
_id = _this select 2;
|
||||
_code = _this select 3;
|
||||
|
||||
_varName = "cse_f_setEventhandler_" + _handler;
|
||||
_handlers = _obj getvariable [_varName, []];
|
||||
|
||||
_found = -1;
|
||||
{
|
||||
if (_x select 0 == _id) exitwith {
|
||||
_found = _foreachIndex;
|
||||
};
|
||||
}foreach _handlers;
|
||||
|
||||
if (_found < 0) then {
|
||||
_handlers pushback [_id, _code];
|
||||
} else {
|
||||
_handlers set [_found, [_id, _code]];
|
||||
};
|
||||
|
||||
_obj setvariable [_varName, _handlers];
|
||||
|
||||
true;
|
7
TO_MERGE/cse/f_eh/stringtable.xml
Normal file
7
TO_MERGE/cse/f_eh/stringtable.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Project name="Combat Space Enhancement">
|
||||
<Package name="cse_sys_weaponrest">
|
||||
<Container ID="WeaponResting">
|
||||
</Container>
|
||||
</Package>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user