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

Damage for props (WIP) #303

Draft
wants to merge 1 commit into
base: dev
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
10 changes: 7 additions & 3 deletions addons/armaos/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class CfgVehicles
openActionCondition = "isNull (_this getVariable ['AE3_computer_mutex', objNull])";
closeAction = "_this call AE3_interaction_fnc_laptop_close;";
closeActionCondition = "isNull (_this getVariable ['AE3_computer_mutex', objNull])";

maxDamage = 3;
damagedAction = "_this call AE3_interaction_fnc_laptop_damaged";
destroyedAction = "_this call AE3_interaction_fnc_laptop_destroyed";
};

class AE3_Device
Expand All @@ -43,11 +47,11 @@ class CfgVehicles
init = "_this call AE3_filesystem_fnc_initFilesystem; _this call AE3_armaos_fnc_link_init; _this call AE3_network_fnc_initNetworkDevice;";

turnOnAction = "_this call AE3_network_fnc_dhcp_onTurnOn; _this call AE3_armaos_fnc_computer_turnOn;";
turnOnActionCondition = "isNull (_this getVariable ['AE3_computer_mutex', objNull])";
turnOnActionCondition = "(isNull (_this getVariable ['AE3_computer_mutex', objNull])) && (!(_target getVariable ['AE3_isDestroyed', false]))";
turnOffAction = "_this call AE3_armaos_fnc_computer_turnOff;";
turnOffActionCondition = "isNull (_this getVariable ['AE3_computer_mutex', objNull])";
turnOffActionCondition = "isNull (_this getVariable ['AE3_computer_mutex', objNull]) && (!(_target getVariable ['AE3_isDestroyed', false]))";
standByAction = "_this call AE3_armaos_fnc_computer_standby;";
standByActionCondition = "isNull (_this getVariable ['AE3_computer_mutex', objNull])";
standByActionCondition = "isNull (_this getVariable ['AE3_computer_mutex', objNull]) && (!(_target getVariable ['AE3_isDestroyed', false]))";

class AE3_Consumer
{
Expand Down
16 changes: 15 additions & 1 deletion addons/armaos/dialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AE3_ArmaOS_Main_Dialog
idd = 15984;
movingEnable = true;
enableSimulation = true;
class controls
class controlsBackground
{
class RscText_1000: RscText
{
Expand Down Expand Up @@ -77,6 +77,20 @@ class AE3_ArmaOS_Main_Dialog
font = "EtelkaMonospaceProBold";
};
};
class controls
{
class RscPicture_1500: RscPicture
{
// Damaged Overlay; size max 40x25 GUI_GRID
idc = 1500;
text = "";
x = 0 * GUI_GRID_W + GUI_GRID_X;
y = 0 * GUI_GRID_H + GUI_GRID_Y;
w = 40 * GUI_GRID_W;
h = 25 * GUI_GRID_H;
colorBackground[] = {0,0,0,0}; // transparent
};
};
};

/* ================================================================================ */
Expand Down
47 changes: 25 additions & 22 deletions addons/armaos/functions/fnc_computer_turnOff.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,42 @@

params ["_computer", ["_silent", false]];

[_computer] spawn {
params["_computer"];
[_computer, _silent] spawn
{
params["_computer", "_silent"];

private _powerState = _computer getVariable 'AE3_power_powerState';
if (!_silent) then
{
private _powerState = _computer getVariable "AE3_power_powerState";

private _turnOffTime = 0;
private _elapsedTime = 0;
private _color = "#(argb,8,8,3)color(0,0,0,0.0,co)";
private _turnOffTime = 0;
private _elapsedTime = 0;

if (_powerState == 1) then
{
_turnOffTime = 15;
}
else
{
_turnOffTime = 10;
};
if (_powerState == 1) then
{
_turnOffTime = 15;
}
else
{
_turnOffTime = 10;
};

if (AE3_DebugMode) then { _turnOffTime = 3; };
if (AE3_DebugMode) then { _turnOffTime = 3; };

for "_i" from 3 to 0 step -1 do
{
_computer setObjectTextureGlobal [1, format ["\z\ae3\addons\armaos\textures\Laptop_4_to_3_Shutting_Down_%1.paa", _i]];
for "_i" from 3 to 0 step -1 do
{
_computer setObjectTextureGlobal [1, format ["\z\ae3\addons\armaos\textures\Laptop_4_to_3_Shutting_Down_%1.paa", _i]];

sleep (_turnOffTime / 4.0);
_elapsedTime = _elapsedTime + (_turnOffTime / 4.0);
sleep (_turnOffTime / 4.0);
_elapsedTime = _elapsedTime + (_turnOffTime / 4.0);
};

private _handle = [_computer] spawn AE3_armaos_fnc_computer_playSoundStop;
};

private _color = "#(argb,8,8,3)color(0,0,0,0.0,co)";
_computer setObjectTextureGlobal [1, _color];

private _handle = [_computer] spawn AE3_armaos_fnc_computer_playSoundStop;

_computer setVariable ["AE3_terminal", nil, [clientOwner, 2]];
};

Expand Down
14 changes: 13 additions & 1 deletion addons/armaos/functions/fnc_terminal_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,16 @@ if (_terminalBuffer isEqualTo []) then

_computer setVariable ["AE3_terminal", _terminal];

[_computer, false] remoteExecCall ["ace_dragging_fnc_setCarryable", 0, true];
[_computer, false] remoteExecCall ["ace_dragging_fnc_setCarryable", 0, true];

/* ================================================================================ */

private _damage = _computer getVariable "AE3_damage";

if (_damage > 0) then
{
private _damagedFnc = _computer getVariable "AE3_fnc_damagedWrapper";
[_computer] call _damagedFnc;
};

/* ================================================================================ */
Binary file added addons/armaos/textures/AE3_Terminal_broken.paa
Binary file not shown.
7 changes: 5 additions & 2 deletions addons/interaction/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Init */
PREP(initEquipment);
PREP(initLamp);
PREP(initLaptop);
PREP(initDesk);
Expand All @@ -11,14 +12,16 @@ PREP(laptop_close);
PREP(desk_open);
PREP(desk_close);

/* Damage */
PREP(laptop_damaged);
PREP(laptop_destroyed);

/* Compile */
PREP(compileConfig);
PREP(compileEquipment);

/* Animation */
PREP(animateInteraction);
PREP(initInteraction);

PREP(animateAction);

/* ACE3 Workaround */
Expand Down
11 changes: 7 additions & 4 deletions addons/interaction/functions/fnc_compileConfig.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ params["_equipmentCfg", "_config"];

_config set
[
'equipment',
"equipment",
[
getText (_equipmentCfg >> "displayName"),
getNumber (_equipmentCfg >> "closeState"),
compile (getText (_equipmentCfg >> "init")),
compile (getText (_equipmentCfg >> "openAction")),
compile ([_equipmentCfg, "openActionCondition", "true"] call BIS_fnc_returnConfigEntry),
compile (getText (_equipmentCfg >> "closeAction")),
compile ([_equipmentCfg, "closeActionCondition", "true"] call BIS_fnc_returnConfigEntry)
compile ([_equipmentCfg, "closeActionCondition", "true"] call BIS_fnc_returnConfigEntry),
[_equipmentCfg, "maxDamage", 1] call BIS_fnc_returnConfigEntry,
compile ([_equipmentCfg, "damagedAction", "true"] call BIS_fnc_returnConfigEntry),
compile ([_equipmentCfg, "destroyedAction", "true"] call BIS_fnc_returnConfigEntry)
]
];

Expand Down Expand Up @@ -128,7 +131,7 @@ if(!isNull _aceWorkaround) then
{
_config set
[
'aceDragging',
"aceDragging",
[
getNumber (_aceDragging >> "ae3_dragging_canDrag"),
getArray (_aceDragging >> "ae3_dragging_dragPosition"),
Expand All @@ -142,7 +145,7 @@ if(!isNull _aceWorkaround) then
{
_config set
[
'aceCarrying',
"aceCarrying",
[
getNumber (_aceCarrying >> "ae3_dragging_canCarry"),
getArray (_aceCarrying >> "ae3_dragging_carryPosition"),
Expand Down
2 changes: 1 addition & 1 deletion addons/interaction/functions/fnc_compileEquipment.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private _config = missionNamespace getVariable _equipmentConfigVarName;

if(_config isEqualType "") exitWith {};

[_equipment] + (_config get "equipment") + [(_config get "animationPoints")] call AE3_interaction_fnc_initInteraction;
[_equipment] + (_config get "equipment") + [(_config get "animationPoints")] call AE3_interaction_fnc_initEquipment;

/* ---------------------------------------- */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
/**
* Animates interactive equipment by user-defined input.
* Inits equipment for animation interaction and damage.
*
* Arguments:
* 0: Equipment <OBJECT>
* 1: Name <STRING> (Optional)
* 2: Close State <Number> (Optional)
* 2: Close State <NUMBER> (Optional)
* 3: Init <FUNCTION> (Optional)
* 4: Open Function <FUNCTION> (Optional)
* 5: Close Function <FUNCTION> (Optional)
* 6: Animation Points <ARRAY> (Optional)
* 5: Open Condition Function <FUNCTION> (Optional)
* 6: Close Function <FUNCTION> (Optional)
* 7: Close Condition Function <FUNCTION> (Optional)
* 8: Max Damage <NUMBER> (Optional)
* 9: Damaged Function <FUNCTION> (Optional)
* 10: Destroyed Function <FUNCTION> (Optional)
* 11: Animation Points <ARRAY> (Optional)
*
* Returns:
* none
*/

params["_equipment", ["_name", "Equipment"], ["_closeState", 0], ["_initFnc", {}], ["_openFnc", {}], ["_openCondition", {true}], ["_closeFnc", {}], ["_closeCondition", {true}], ["_animationPoints", []]];
params
[
"_equipment",
["_name", "Equipment"],
["_closeState", 0],
["_initFnc", {}],
["_openFnc", {}],
["_openCondition", {true}],
["_closeFnc", {}],
["_closeCondition", {true}],
["_maxDamage", 1],
["_damagedFnc", {}],
["_destroyedFnc", {}],
["_animationPoints", []]
];

/* ---------------------------------------- */

Expand Down Expand Up @@ -50,6 +69,38 @@ private _closeWrapper =

/* ---------------------------------------- */

private _damagedWrapper =
{
params["_target", ["_args", []]];

_damagedFnc = _target getVariable "AE3_fnc_damaged";
_result = [_target] + _args call _damagedFnc;
if (isNil "_result") then { _result = false; };

if (_result) then
{
//_target setVariable ["AE3_interaction_closeState", 0, true];
};
};

/* ---------------------------------------- */

private _destroyedWrapper =
{
params["_target", ["_args", []]];

_destroyedFnc = _target getVariable "AE3_fnc_destroyed";
_result = [_target] + _args call _destroyedFnc;
if (isNil "_result") then { _result = false; };

if (_result) then
{
//_target setVariable ["AE3_interaction_closeState", 1, true];
};
};

/* ---------------------------------------- */

if (!isDedicated) then
{
{
Expand Down Expand Up @@ -150,4 +201,53 @@ _equipment setVariable ["AE3_interaction_fnc_close", _closeFnc];
_equipment setVariable ["AE3_interaction_fnc_closeActionCondition", _closeCondition];
_equipment setVariable ["AE3_interaction_fnc_closeWrapper", _closeWrapper];

_equipment setVariable ["AE3_damage", 0, true];
_equipment setVariable ["AE3_maxDamage", _maxDamage, true];
_equipment setVariable ["AE3_isDestroyed", false, true];

_equipment setVariable ["AE3_fnc_damaged", _damagedFnc];
_equipment setVariable ["AE3_fnc_damagedWrapper", _damagedWrapper];
_equipment setVariable ["AE3_fnc_destroyed", _destroyedFnc];
_equipment setVariable ["AE3_fnc_destroyedWrapper", _destroyedWrapper];

/* ---------------------------------------- */

_equipment addEventHandler
[
"HitPart",
{
{
_x params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"];
//systemChat format ["HitPart: selection: %1 - isDirect: %2 - Ammo: %3", _selection, _isDirect, _ammo];

// increase damage counter
private _ae3Damage = _target getVariable ["AE3_damage", 0];
_ae3Damage = _ae3Damage + 1;
_target setVariable ["AE3_damage", _ae3Damage];

// calculate health
private _ae3MaxDamage = _target getVariable ["AE3_maxDamage", 1];
private _health = 1 / _ae3MaxDamage * _ae3Damage;
if (_health > 1) then { _health = 1; };

if (_ae3Damage >= _ae3MaxDamage) then
{
_target setVariable ["AE3_isDestroyed", true];

private _destroyedFnc = _target getVariable "AE3_fnc_destroyedWrapper";
[_target] call _destroyedFnc;
systemChat format ["Target: %1 destroyed (Health: %2)", _target, _health];
}
else
{
private _damagedFnc = _target getVariable "AE3_fnc_damagedWrapper";
[_target] call _damagedFnc;
systemChat format ["Target: %1 damaged (Health: %2)", _target, _health];
};
} forEach _this;
}
];

/* ---------------------------------------- */

[_equipment] call _initFnc;
3 changes: 2 additions & 1 deletion addons/interaction/functions/fnc_initLaptop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ if(!isDedicated) then
params ["_target", "_player", "_params"];

(alive _target) && (_target getVariable "AE3_power_powerState" == 1) &&
(isNull (_target getVariable ["AE3_computer_mutex", objNull]))
(isNull (_target getVariable ["AE3_computer_mutex", objNull])) &&
(!(_target getVariable ["AE3_isDestroyed", false]))
}
] call ace_interact_menu_fnc_createAction;
[_laptop, 0, ["ACE_MainActions", "AE3_ArmaOSAction"], _useAction] call ace_interact_menu_fnc_addActionToObject; // 0 = action; 1 = self-action
Expand Down
22 changes: 22 additions & 0 deletions addons/interaction/functions/fnc_laptop_damaged.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Sets effects on damaged laptop
*
* Arguments:
* 0: Laptop <OBJECT>
*
* Returns:
* true
*/

params["_laptop"];

// if terminal is open, set the broken display overlay
private _consoleDialog = findDisplay 15984;
if (!isNull _consoleDialog) then
{
// enable broken display overlay
private _overlay = _consoleDialog displayCtrl 1500;
_overlay ctrlSetText "\z\ae3\addons\armaos\textures\AE3_Terminal_broken.paa";
};

true;
Loading