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

Add injury module #585

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions addons/damage/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -655,5 +655,14 @@
<Korean>슬랫 뒤</Korean>
<Japanese>スラット 後部</Japanese>
</Key>
<Key ID="STR_ZEN_Damage_HitHead">
<English>Head</English>
</Key>
<Key ID="STR_ZEN_Damage_HitHands">
<English>Arms</English>
</Key>
<Key ID="STR_ZEN_Damage_HitLegs">
<English>Legs</English>
</Key>
</Package>
</Project>
5 changes: 5 additions & 0 deletions addons/modules/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ class CfgVehicles {
displayName = CSTRING(ModuleHideZeus);
function = QFUNC(moduleHideZeus);
};
class GVAR(moduleInjure): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = CSTRING(ModuleInjure);
function = QFUNC(moduleInjure);
};
class GVAR(moduleLightSource): GVAR(moduleBase) {
category = "Effects";
displayName = CSTRING(ModuleLightSource);
Expand Down
1 change: 1 addition & 0 deletions addons/modules/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ PREP(moduleGroupSide);
PREP(moduleHeal);
PREP(moduleHideTerrainObjects);
PREP(moduleHideZeus);
PREP(moduleInjure);
PREP(moduleLightSource);
PREP(moduleMakeInvincible);
PREP(moduleNuke);
Expand Down
9 changes: 9 additions & 0 deletions addons/modules/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,12 @@ if (isServer) then {
_unit assignAsGunner _vehicle;
[_unit] orderGetIn true;
}] call CBA_fnc_addEventHandler;

[QGVAR(injureUnit), {
params ["_unit", "_damageValues"];

{
_x params ["_hitpoint", "_damage"];
_unit setHit [_hitpoint, _damage];
} forEach _damageValues;
}] call CBA_fnc_addEventHandler;
1 change: 1 addition & 0 deletions addons/modules/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class CfgPatches {
QGVAR(moduleHeal),
QGVAR(moduleHideTerrainObjects),
QGVAR(moduleHideZeus),
QGVAR(moduleInjure),
QGVAR(moduleLightSource),
QGVAR(moduleMakeInvincible),
QGVAR(moduleNuke),
Expand Down
112 changes: 112 additions & 0 deletions addons/modules/functions/fnc_moduleInjure.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#include "script_component.hpp"
/*
* Author: CreepPork
* Zeus module function to injure a player or an AI.
*
* Arguments:
* 0: Logic <OBJECT>
*
* Return Value:
* None
*
* Example:
* [LOGIC] call zen_modules_fnc_moduleInjure
*
* Public: No
*/

params ["_logic"];

private _unit = attachedTo _logic;
deleteVehicle _logic;

if (isNull _unit) exitWith {
[LSTRING(NoUnitSelected)] call EFUNC(common,showMessage);
};

if !(_unit isKindOf "CAManBase") exitWith {
[LSTRING(OnlyInfantry)] call EFUNC(common,showMessage);
};

if (!alive _unit) exitWith {
[LSTRING(OnlyAlive)] call EFUNC(common,showMessage);
};

private _fnc_getDamageDefault = {
params ["_unit", "_hitpoint"];

private _damage = _unit getHit _hitpoint;

// Ranges are used if a unit gets shot and it's not the precise value anymore
if (_damage == 0) exitWith { 0 }; // No damage
if (_damage > 0 && _damage < 0.5) exitWith { 1 }; // Low damage
if (_damage >= 0.5 && _damage < 0.9) exitWith { 2 }; // Medium (limping) damage
if (_damage >= 0.9) exitWith { 3 }; // Severe damage
};

[
LSTRING(ModuleInjure),
[
[
"TOOLBOX",
ELSTRING(damage,HitHead),
[
[_unit, "head"] call _fnc_getDamageDefault,
1,
4,
["None", "Low", "Medium", "Severe"]
],
true
],
[
"TOOLBOX",
ELSTRING(damage,HitBody),
[
[_unit, "body"] call _fnc_getDamageDefault,
1,
4,
["None", "Low", "Medium", "Severe"]
],
true
],
[
"TOOLBOX",
ELSTRING(damage,HitHands),
[
[_unit, "hands"] call _fnc_getDamageDefault,
1,
4,
["None", "Low", "Medium", "Severe"]
],
true
],
[
"TOOLBOX",
ELSTRING(damage,HitLegs),
[
[_unit, "legs"] call _fnc_getDamageDefault,
1,
4,
["None", "Low", "Limping", "Severe"]
],
true
]
],
{
params ["_dialogValues", "_unit"];
_dialogValues params ["_head", "_body", "_hands", "_legs"];
private _damageValues = [0, 0.49, 0.7, 0.9];

[QGVAR(injureUnit), [
_unit,
[
["head", _damageValues select _head],
["body", _damageValues select _body],
["hands", _damageValues select _hands],
["legs", _damageValues select _legs]
]
], _unit] call CBA_fnc_targetEvent;
},
{},
_unit
] call EFUNC(dialog,create);
3 changes: 3 additions & 0 deletions addons/modules/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2444,5 +2444,8 @@
<English>Vehicle must have other crew available</English>
<Japanese>車両には空いている乗員席がありません</Japanese>
</Key>
<Key ID="STR_ZEN_Modules_ModuleInjure">
<English>Injure</English>
</Key>
</Package>
</Project>