add cookoff via dummy

This commit is contained in:
Steve Zhao 2022-01-09 23:50:29 -05:00
parent 20299f4b6d
commit 217536cebe
3 changed files with 59 additions and 1 deletions

View File

@ -1,3 +1,6 @@
// testing, update fncs on the fly
#undef PREP
#define PREP(var1) TRIPLES(ADDON,fnc,var1) = { call compile preProcessFileLineNumbers '\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT_F\functions\DOUBLES(fnc,var1).sqf' }
PREP(calculateCooling);
PREP(canUnjam);
@ -8,6 +11,7 @@ PREP(checkSpareBarrelsTemperatures);
PREP(checkTemperature);
PREP(clearJam);
PREP(cookoffWeapon);
PREP(cookoffWeaponDummy);
PREP(coolWeaponWithItem);
PREP(coolWeaponWithWaterSource);
PREP(displayTemperature);

View File

@ -49,7 +49,13 @@ if !(_mode in _modes) then {
params ["_unit", "_mode", "_muzzle", "_muzzleCache"];
// fire the cookoff
_unit forceWeaponFire [_muzzle, _mode];
private _canFire = false; // check for animation here
if (_canFire) then {
_unit forceWeaponFire [_muzzle, _mode];
} else {
[_unit, _mode, _muzzle] call FUNC(cookoffWeaponDummy);
};
// switch back to the cached muzzle if required
if (_muzzle != _muzzleCache) then {

View File

@ -0,0 +1,48 @@
#include "script_component.hpp"
/*
* Author: Ampersand
* Create dummy with weapon that is cooking off for when actual weapon will not fire
*
* Arguments:
* 0: Input <BOOLEAN>
*
* Return Value:
* NONE
*
* Example:
* [player, currentWeaponMode player, currentMuzzle player] call ace_overheating_fnc_cookoffWeaponDummy
*/
params ["_unit", "_mode", "_muzzle", ["_loadout", []], ["_animation", ""], ["_proxy", ""]];
private _unitLoadout = getUnitLoadout _unit;
if (_muzzle == primaryWeapon _unit) then {
_loadout = [_unitLoadout select 0,[],[],[],[],[],"","",[],["","","","","",""]];
_proxy = "proxy:\a3\characters_f\proxies\weapon.001";
_animation = "AmovPercMstpSrasWrflDnon";
} else {
_loadout = [[],[],_unitLoadout select 2,[],[],[],"","",[],["","","","","",""]];
_proxy = "proxy:\a3\characters_f\proxies\pistol.001";
_animation = "AmovPercMstpSrasWpstDnon";
};
private _dummy = _unit getVariable [format [QGVAR(%1_dummy), _muzzle], objNull];
if (isNull _dummy) then {
_dummy = createAgent [QGVAR(dummy), [0, 0, 0], [], 0, "CAN_COLLIDE"];
};
_dummy setUnitLoadout _loadout;
_dummy disableAI "ALL";
_dummy allowDamage false;
_dummy switchmove _animation;
_dummy attachTo [_unit, [0, 0, 0], _proxy, true];
//_dummy addEventHandler ["Deleted", {}];
_dummy forceWeaponFire [_muzzle, _mode];
_unit setAmmo [_muzzle, (_unit ammo _muzzle) - 1];
private _isNextRoundCool = true; // reuse dummy if next round is also going to be cooked off
if (_isNextRoundCool) then {
deleteVehicle _dummy;
} else {
_unit setVariable [format [QGVAR(%1_dummy), _muzzle], _dummy];
};