From e7c67922fc937d1cd2da3f41be9297526c746e2f Mon Sep 17 00:00:00 2001 From: diwako Date: Sun, 8 Jul 2018 13:45:34 +0200 Subject: [PATCH] Mod version updated license Most cba integration with functions and settings --- ace_ragdoll_unconscious.VR/description.ext | 15 +++++ .../initPlayerLocal-EnableForEveryThing.sqf | 36 ---------- .../initPlayerLocal.sqf | 36 ---------- .../scripts/diwako/ragdoll/cba_settings.sqf | 26 +++++++ .../scripts/diwako/ragdoll/fn_initRagdoll.sqf | 67 +++++++++++++++++++ license.txt | 11 +-- mod/$PBOPREFIX$ | 1 + mod/cfgFunctions.hpp | 9 +++ mod/config.cpp | 28 ++++++++ mod/functions/diwako/ragdoll/cba_settings.sqf | 26 +++++++ .../diwako/ragdoll/fn_initRagdoll.sqf | 67 +++++++++++++++++++ mod/license.txt | 5 ++ 12 files changed, 247 insertions(+), 80 deletions(-) create mode 100644 ace_ragdoll_unconscious.VR/description.ext delete mode 100644 ace_ragdoll_unconscious.VR/initPlayerLocal-EnableForEveryThing.sqf delete mode 100644 ace_ragdoll_unconscious.VR/initPlayerLocal.sqf create mode 100644 ace_ragdoll_unconscious.VR/scripts/diwako/ragdoll/cba_settings.sqf create mode 100644 ace_ragdoll_unconscious.VR/scripts/diwako/ragdoll/fn_initRagdoll.sqf create mode 100644 mod/$PBOPREFIX$ create mode 100644 mod/cfgFunctions.hpp create mode 100644 mod/config.cpp create mode 100644 mod/functions/diwako/ragdoll/cba_settings.sqf create mode 100644 mod/functions/diwako/ragdoll/fn_initRagdoll.sqf create mode 100644 mod/license.txt diff --git a/ace_ragdoll_unconscious.VR/description.ext b/ace_ragdoll_unconscious.VR/description.ext new file mode 100644 index 0000000..c4141ae --- /dev/null +++ b/ace_ragdoll_unconscious.VR/description.ext @@ -0,0 +1,15 @@ +class Extended_PreInit_EventHandlers { + class diwako_ragdoll { + init = "call compile preprocessFileLineNumbers 'scripts\diwako\ragdoll\cba_settings.sqf'"; + }; +}; + +class cfgFunctions { + class diwako_ragdoll { + tag="diwako_ragdoll"; + class functions { + file = "scripts\diwako\ragdoll"; + class initRagdoll{}; + }; + }; +}; \ No newline at end of file diff --git a/ace_ragdoll_unconscious.VR/initPlayerLocal-EnableForEveryThing.sqf b/ace_ragdoll_unconscious.VR/initPlayerLocal-EnableForEveryThing.sqf deleted file mode 100644 index faecfe3..0000000 --- a/ace_ragdoll_unconscious.VR/initPlayerLocal-EnableForEveryThing.sqf +++ /dev/null @@ -1,36 +0,0 @@ -["ace_unconscious", { - params [["_unit", objNull],["_state", false]]; - // if(_unit != player) exitWith {}; // only ragdoll players - if(_state && {vehicle _unit == _unit && {!([_unit] call ace_medical_fnc_isBeingCarried) && {!([_unit] call ace_medical_fnc_isBeingDragged)}}}) then { - // ragdoll player - _unit setUnconscious true; - }; - if(!_state) then { - // player woke up before ragdolling was finished - _unit setUnconscious false; - }; -}] call CBA_fnc_addEventHandler; - -["CAManBase", "AnimChanged", { - params ["_unit","_anim"]; - if(_anim == "unconsciousrevivedefault" && {alive _unit && {_unit getVariable ["ACE_isUnconscious",false] && {vehicle _unit == _unit}}}) then { - // unit stopped ragdolling, apply ace_death animation to unit - _unit setUnconscious false; - [_unit, [_unit] call ace_common_fnc_getDeathAnim, 2, true] call ace_common_fnc_doAnimation; - if(isMultiplayer) then { - // combat sync issues - [_unit] spawn { - params["_unit"]; - sleep 5; - // in some cases the server does not sync that a unit is up and running or still down but with wrong animations, so reapply some things - if(!(_unit getVariable ["ACE_isUnconscious",false])) then { - // unit is not unconscious anymore - _unit setUnconscious false; - } else { - // unit is still unconscious, reapply death animation just in case and sync it again to all clients - [_unit, [_unit] call ace_common_fnc_getDeathAnim, 2, true] call ace_common_fnc_doAnimation; - }; - }; - }; - }; -}] call CBA_fnc_addClassEventHandler; \ No newline at end of file diff --git a/ace_ragdoll_unconscious.VR/initPlayerLocal.sqf b/ace_ragdoll_unconscious.VR/initPlayerLocal.sqf deleted file mode 100644 index e1db2c8..0000000 --- a/ace_ragdoll_unconscious.VR/initPlayerLocal.sqf +++ /dev/null @@ -1,36 +0,0 @@ -["ace_unconscious", { - params [["_unit", objNull],["_state", false]]; - if(_unit != player) exitWith {}; // only ragdoll players - if(_state && {vehicle _unit == _unit && {!([_unit] call ace_medical_fnc_isBeingCarried) && {!([_unit] call ace_medical_fnc_isBeingDragged)}}}) then { - // ragdoll player - _unit setUnconscious true; - }; - if(!_state) then { - // player woke up before ragdolling was finished - _unit setUnconscious false; - }; -}] call CBA_fnc_addEventHandler; - -player addEventHandler ["AnimChanged", { - params ["_unit","_anim"]; - if(_anim == "unconsciousrevivedefault" && {alive _unit && {_unit getVariable ["ACE_isUnconscious",false] && {vehicle _unit == _unit}}}) then { - // unit stopped ragdolling, apply ace_death animation to unit - _unit setUnconscious false; - [_unit, [_unit] call ace_common_fnc_getDeathAnim, 2, true] call ace_common_fnc_doAnimation; - if(isMultiplayer) then { - // combat sync issues - [_unit] spawn { - params["_unit"]; - sleep 5; - // in some cases the server does not sync that a unit is up and running or still down but with wrong animations, so reapply some things - if(!(_unit getVariable ["ACE_isUnconscious",false])) then { - // unit is not unconscious anymore - _unit setUnconscious false; - } else { - // unit is still unconscious, reapply death animation just in case and sync it again to all clients - [_unit, [_unit] call ace_common_fnc_getDeathAnim, 2, true] call ace_common_fnc_doAnimation; - }; - }; - }; - }; -}]; \ No newline at end of file diff --git a/ace_ragdoll_unconscious.VR/scripts/diwako/ragdoll/cba_settings.sqf b/ace_ragdoll_unconscious.VR/scripts/diwako/ragdoll/cba_settings.sqf new file mode 100644 index 0000000..a0033ea --- /dev/null +++ b/ace_ragdoll_unconscious.VR/scripts/diwako/ragdoll/cba_settings.sqf @@ -0,0 +1,26 @@ +#define SETTINGS "Diwako's ACE Ragdolling" + +[ + "diwako_ragdoll_ragdolling", // Internal setting name, should always contain a tag! This will be the global variable which takes the value of the setting. + "CHECKBOX", // setting type + ["Enable ragdolling", "Enables ragdolling for players upon going unconscious"], // Pretty name of the category where the setting can be found. Can be stringtable entry. + SETTINGS, // Pretty name shown inside the ingame settings menu. Can be stringtable entry. + false, // data for this setting + true, // "_isGlobal" flag. Set this to true to always have this setting synchronized between all clients in multiplayer + { + params ["_value"]; + if (_value isEqualTo true) then { + [] call diwako_ragdoll_fnc_initRagdoll; + }; + } // function that will be executed once on mission start and every time the setting is changed. +] call CBA_Settings_fnc_init; + +[ + "diwako_ragdoll_ai", // Internal setting name, should always contain a tag! This will be the global variable which takes the value of the setting. + "CHECKBOX", // setting type + ["Enable for AI", "Enables ragdolling for AI as well"], // Pretty name of the category where the setting can be found. Can be stringtable entry. + SETTINGS, // Pretty name shown inside the ingame settings menu. Can be stringtable entry. + false, // data for this setting + true, // "_isGlobal" flag. Set this to true to always have this setting synchronized between all clients in multiplayer + {} // function that will be executed once on mission start and every time the setting is changed. +] call CBA_Settings_fnc_init; \ No newline at end of file diff --git a/ace_ragdoll_unconscious.VR/scripts/diwako/ragdoll/fn_initRagdoll.sqf b/ace_ragdoll_unconscious.VR/scripts/diwako/ragdoll/fn_initRagdoll.sqf new file mode 100644 index 0000000..61a09c0 --- /dev/null +++ b/ace_ragdoll_unconscious.VR/scripts/diwako/ragdoll/fn_initRagdoll.sqf @@ -0,0 +1,67 @@ +/* + Author: diwako + + Description: + Adds ragdolling for players upon going unconscious + + Parameter(s): + none + + Examples: + (begin) + [] call diwako_ragdoll_fnc_initRagdoll; + (end) + + Returns: + none +*/ + +if(!hasInterface) exitWith {}; + +// no need to initialise ragdolling twice! +if (!isNil 'diwako_ragdoll_ragdollRunning') exitWith {}; +diwako_ragdoll_ragdollRunning = true; + +["ace_unconscious", { + params [["_unit", objNull],["_state", false]]; + if(!diwako_ragdoll_ragdolling) exitWith {}; // ragdolling if it active + if( (_unit != player && {!diwako_ragdoll_ai}) || (!local _unit)) exitWith {}; // only ragdoll players and only ragdolling if it active + if(_state && {vehicle _unit == _unit && {!([_unit] call ace_medical_fnc_isBeingCarried) && {!([_unit] call ace_medical_fnc_isBeingDragged)}}}) then { + // ragdoll player + _unit setUnconscious true; + }; + if(!_state) then { + // player woke up before ragdolling was finished + _unit setUnconscious false; + }; +}] call CBA_fnc_addEventHandler; + +["CAManBase", "AnimChanged", { + params ["_unit","_anim"]; + if(!diwako_ragdoll_ragdolling) exitWith {}; // disable ragdolling mid mission + if( (_unit != player && {!diwako_ragdoll_ai}) || !(local _unit)) exitWith {}; // only run on players if ai setting is disabled + if(_anim == "unconsciousrevivedefault" && {alive _unit && {_unit getVariable ["ACE_isUnconscious",false] && {vehicle _unit == _unit}}}) then { + // unit stopped ragdolling, apply ace_death animation to unit + _unit setUnconscious false; + [_unit, [_unit] call ace_common_fnc_getDeathAnim, 2, true] call ace_common_fnc_doAnimation; + if(isMultiplayer) then { + // combat sync issues + [ + { + params ["_unit"]; + if(!(_unit getVariable ["ACE_isUnconscious",false])) then { + // unit is not unconscious anymore + _unit setUnconscious false; + } else { + // unit is still unconscious, reapply death animation just in case and sync it again to all clients + [_unit, [_unit] call ace_common_fnc_getDeathAnim, 2, true] call ace_common_fnc_doAnimation; + }; + }, // code + [_unit], // params + 5 // delay + ] call CBA_fnc_waitAndExecute; + }; + }; +}] call CBA_fnc_addClassEventHandler; + +player createDiaryRecord ["CBA_docs", ["Ragdolling", "Ragdolling has been activated in this mission! Better check those bodies!"]]; \ No newline at end of file diff --git a/license.txt b/license.txt index 09ce176..8f66b40 100644 --- a/license.txt +++ b/license.txt @@ -1,10 +1,5 @@ -Copyright 2017 diwako +Copyright 2018 diwako -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +This work (diwako_ace_ragdoll or the like) uses the license Arma Public License Share Alike (APL-SA) -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Exception to the above license: -You are not allowed to use these scripts on any monetised server which offers services or rewards in exchange of real life currency. \ No newline at end of file +https://www.bohemia.net/community/licenses/arma-public-license-share-alike \ No newline at end of file diff --git a/mod/$PBOPREFIX$ b/mod/$PBOPREFIX$ new file mode 100644 index 0000000..111f0f1 --- /dev/null +++ b/mod/$PBOPREFIX$ @@ -0,0 +1 @@ +diwako_ragdoll \ No newline at end of file diff --git a/mod/cfgFunctions.hpp b/mod/cfgFunctions.hpp new file mode 100644 index 0000000..5caf0ba --- /dev/null +++ b/mod/cfgFunctions.hpp @@ -0,0 +1,9 @@ +class cfgFunctions { + class diwako_ragdoll { + tag="diwako_ragdoll"; + class functions { + file = "diwako_ragdoll\functions\diwako\ragdoll"; + class initRagdoll{}; + }; + }; +}; \ No newline at end of file diff --git a/mod/config.cpp b/mod/config.cpp new file mode 100644 index 0000000..6d9e216 --- /dev/null +++ b/mod/config.cpp @@ -0,0 +1,28 @@ +#define REQUIRED_VERSION 1.82 +#define VERSION "1.0" + +class CfgPatches { + class diwako_ragdoll { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = { + "ace_medical" + ,"cba_common" + ,"ace_common" + }; + author[] = {"diwako"}; + authorUrl = "https://github.com/diwako/a3AceRagdoll"; + version = VERSION; + versionStr = VERSION; + license = "https://www.bohemia.net/community/licenses/arma-public-license-share-alike"; + }; +}; + +class Extended_PreInit_EventHandlers { + class diwako_ragdoll { + init = "call compile preprocessFileLineNumbers 'diwako_ragdoll\functions\diwako\ragdoll\cba_settings.sqf'"; + }; +}; + +#include "cfgFunctions.hpp" \ No newline at end of file diff --git a/mod/functions/diwako/ragdoll/cba_settings.sqf b/mod/functions/diwako/ragdoll/cba_settings.sqf new file mode 100644 index 0000000..a0033ea --- /dev/null +++ b/mod/functions/diwako/ragdoll/cba_settings.sqf @@ -0,0 +1,26 @@ +#define SETTINGS "Diwako's ACE Ragdolling" + +[ + "diwako_ragdoll_ragdolling", // Internal setting name, should always contain a tag! This will be the global variable which takes the value of the setting. + "CHECKBOX", // setting type + ["Enable ragdolling", "Enables ragdolling for players upon going unconscious"], // Pretty name of the category where the setting can be found. Can be stringtable entry. + SETTINGS, // Pretty name shown inside the ingame settings menu. Can be stringtable entry. + false, // data for this setting + true, // "_isGlobal" flag. Set this to true to always have this setting synchronized between all clients in multiplayer + { + params ["_value"]; + if (_value isEqualTo true) then { + [] call diwako_ragdoll_fnc_initRagdoll; + }; + } // function that will be executed once on mission start and every time the setting is changed. +] call CBA_Settings_fnc_init; + +[ + "diwako_ragdoll_ai", // Internal setting name, should always contain a tag! This will be the global variable which takes the value of the setting. + "CHECKBOX", // setting type + ["Enable for AI", "Enables ragdolling for AI as well"], // Pretty name of the category where the setting can be found. Can be stringtable entry. + SETTINGS, // Pretty name shown inside the ingame settings menu. Can be stringtable entry. + false, // data for this setting + true, // "_isGlobal" flag. Set this to true to always have this setting synchronized between all clients in multiplayer + {} // function that will be executed once on mission start and every time the setting is changed. +] call CBA_Settings_fnc_init; \ No newline at end of file diff --git a/mod/functions/diwako/ragdoll/fn_initRagdoll.sqf b/mod/functions/diwako/ragdoll/fn_initRagdoll.sqf new file mode 100644 index 0000000..61a09c0 --- /dev/null +++ b/mod/functions/diwako/ragdoll/fn_initRagdoll.sqf @@ -0,0 +1,67 @@ +/* + Author: diwako + + Description: + Adds ragdolling for players upon going unconscious + + Parameter(s): + none + + Examples: + (begin) + [] call diwako_ragdoll_fnc_initRagdoll; + (end) + + Returns: + none +*/ + +if(!hasInterface) exitWith {}; + +// no need to initialise ragdolling twice! +if (!isNil 'diwako_ragdoll_ragdollRunning') exitWith {}; +diwako_ragdoll_ragdollRunning = true; + +["ace_unconscious", { + params [["_unit", objNull],["_state", false]]; + if(!diwako_ragdoll_ragdolling) exitWith {}; // ragdolling if it active + if( (_unit != player && {!diwako_ragdoll_ai}) || (!local _unit)) exitWith {}; // only ragdoll players and only ragdolling if it active + if(_state && {vehicle _unit == _unit && {!([_unit] call ace_medical_fnc_isBeingCarried) && {!([_unit] call ace_medical_fnc_isBeingDragged)}}}) then { + // ragdoll player + _unit setUnconscious true; + }; + if(!_state) then { + // player woke up before ragdolling was finished + _unit setUnconscious false; + }; +}] call CBA_fnc_addEventHandler; + +["CAManBase", "AnimChanged", { + params ["_unit","_anim"]; + if(!diwako_ragdoll_ragdolling) exitWith {}; // disable ragdolling mid mission + if( (_unit != player && {!diwako_ragdoll_ai}) || !(local _unit)) exitWith {}; // only run on players if ai setting is disabled + if(_anim == "unconsciousrevivedefault" && {alive _unit && {_unit getVariable ["ACE_isUnconscious",false] && {vehicle _unit == _unit}}}) then { + // unit stopped ragdolling, apply ace_death animation to unit + _unit setUnconscious false; + [_unit, [_unit] call ace_common_fnc_getDeathAnim, 2, true] call ace_common_fnc_doAnimation; + if(isMultiplayer) then { + // combat sync issues + [ + { + params ["_unit"]; + if(!(_unit getVariable ["ACE_isUnconscious",false])) then { + // unit is not unconscious anymore + _unit setUnconscious false; + } else { + // unit is still unconscious, reapply death animation just in case and sync it again to all clients + [_unit, [_unit] call ace_common_fnc_getDeathAnim, 2, true] call ace_common_fnc_doAnimation; + }; + }, // code + [_unit], // params + 5 // delay + ] call CBA_fnc_waitAndExecute; + }; + }; +}] call CBA_fnc_addClassEventHandler; + +player createDiaryRecord ["CBA_docs", ["Ragdolling", "Ragdolling has been activated in this mission! Better check those bodies!"]]; \ No newline at end of file diff --git a/mod/license.txt b/mod/license.txt new file mode 100644 index 0000000..8f66b40 --- /dev/null +++ b/mod/license.txt @@ -0,0 +1,5 @@ +Copyright 2018 diwako + +This work (diwako_ace_ragdoll or the like) uses the license Arma Public License Share Alike (APL-SA) + +https://www.bohemia.net/community/licenses/arma-public-license-share-alike \ No newline at end of file