mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Grenades - Fix how incendiary grenades do damage to vehicles (#9983)
* Allow incendiary grenades to damage multiple vehicles Disable incendiaries damaging invulnerable vehicles * Apply fire damage to vehicles even after grenade detonation * Update fnc_damageEngineAndWheels.sqf * Update fnc_incendiary.sqf * Update fnc_damageEngineAndWheels.sqf * british people don't exist --------- Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
This commit is contained in:
parent
2bd1f39de7
commit
9760095c42
@ -1,4 +1,4 @@
|
|||||||
|
PREP(damageEngineAndWheels);
|
||||||
PREP(flare);
|
PREP(flare);
|
||||||
PREP(flashbangExplosionEH);
|
PREP(flashbangExplosionEH);
|
||||||
PREP(flashbangThrownFuze);
|
PREP(flashbangThrownFuze);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
["ace_flashbangExploded", LINKFUNC(flashbangExplosionEH)] call CBA_fnc_addEventHandler;
|
["ace_flashbangExploded", LINKFUNC(flashbangExplosionEH)] call CBA_fnc_addEventHandler;
|
||||||
|
[QGVAR(damageEngineAndWheels), LINKFUNC(damageEngineAndWheels)] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
// Register fired event handlers
|
// Register fired event handlers
|
||||||
["ace_firedPlayer", LINKFUNC(throwGrenade)] call CBA_fnc_addEventHandler;
|
["ace_firedPlayer", LINKFUNC(throwGrenade)] call CBA_fnc_addEventHandler;
|
||||||
|
60
addons/grenades/functions/fnc_damageEngineAndWheels.sqf
Normal file
60
addons/grenades/functions/fnc_damageEngineAndWheels.sqf
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#include "..\script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: commy2, johnb43
|
||||||
|
* Damage a vehicle's wheels and engine.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Vehicle <OBJECT>
|
||||||
|
* 1: Incendiary position AGL <ARRAY>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [cursorObject, position cursorObject] call ace_grenades_fnc_damageEngineAndWheels
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
params ["_vehicle", "_position"];
|
||||||
|
TRACE_1("damageWheelsAndEngine",_vehicle);
|
||||||
|
|
||||||
|
// Vehicle needs to be local and vulnerable
|
||||||
|
if !(local _vehicle && {isDamageAllowed _vehicle}) exitWith {};
|
||||||
|
|
||||||
|
// Burn tires
|
||||||
|
private _fnc_isWheelHitPoint = {
|
||||||
|
params ["_selectionName"];
|
||||||
|
// Wheels must use a selection named "wheel_X_Y_steering" for PhysX to work
|
||||||
|
_selectionName select [0, 6] == "wheel_" && {
|
||||||
|
_selectionName select [count _selectionName - 9] == "_steering"
|
||||||
|
} // return
|
||||||
|
};
|
||||||
|
|
||||||
|
private _config = configOf _vehicle >> "HitPoints";
|
||||||
|
|
||||||
|
{
|
||||||
|
private _wheelSelection = getText (_config >> _x >> "name");
|
||||||
|
|
||||||
|
if (_wheelSelection call _fnc_isWheelHitPoint) then {
|
||||||
|
private _wheelPosition = _vehicle modelToWorld (_vehicle selectionPosition _wheelSelection);
|
||||||
|
|
||||||
|
if (_position distance _wheelPosition < EFFECT_SIZE * 2) then {
|
||||||
|
_vehicle setHit [_wheelSelection, 1];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} forEach (getAllHitPointsDamage _vehicle param [0, []]);
|
||||||
|
|
||||||
|
// Burn car engines only
|
||||||
|
if (_vehicle isKindOf "Wheeled_APC_F") exitWith {};
|
||||||
|
|
||||||
|
private _engineSelection = getText (_config >> "HitEngine" >> "name");
|
||||||
|
private _enginePosition = _vehicle modelToWorld (_vehicle selectionPosition _engineSelection);
|
||||||
|
|
||||||
|
if (_position distance _enginePosition < EFFECT_SIZE * 2) then {
|
||||||
|
_vehicle setHit [_engineSelection, 1];
|
||||||
|
|
||||||
|
if (["ace_cookoff"] call EFUNC(common,isModLoaded)) then {
|
||||||
|
[QEGVAR(cookoff,engineFireServer), _vehicle] call CBA_fnc_serverEvent;
|
||||||
|
};
|
||||||
|
};
|
@ -30,11 +30,11 @@
|
|||||||
#define PARTICLE_SMOKE_LIFTING 1
|
#define PARTICLE_SMOKE_LIFTING 1
|
||||||
#define PARTICLE_SMOKE_WIND_EFFECT 1
|
#define PARTICLE_SMOKE_WIND_EFFECT 1
|
||||||
|
|
||||||
#define EFFECT_SIZE 1
|
|
||||||
#define ORIENTATION 5.4
|
#define ORIENTATION 5.4
|
||||||
#define EXPANSION 1
|
#define EXPANSION 1
|
||||||
|
|
||||||
#define DESTRUCTION_RADIUS 1.8
|
#define DESTRUCTION_RADIUS 1.8
|
||||||
|
#define SEARCH_RADIUS 5
|
||||||
|
|
||||||
params ["_projectile", "_timeToLive", "_center"];
|
params ["_projectile", "_timeToLive", "_center"];
|
||||||
|
|
||||||
@ -157,7 +157,24 @@ if (isServer) then {
|
|||||||
_sound = createSoundSource ["Sound_Fire", _position, [], 0];
|
_sound = createSoundSource ["Sound_Fire", _position, [], 0];
|
||||||
private _radius = 1.5 * getNumber (configOf _projectile >> "indirectHitRange");
|
private _radius = 1.5 * getNumber (configOf _projectile >> "indirectHitRange");
|
||||||
private _intensity = getNumber (configOf _projectile >> "hit");
|
private _intensity = getNumber (configOf _projectile >> "hit");
|
||||||
[QEGVAR(fire,addFireSource), [_projectile, _radius, _intensity, _projectile, {CBA_missionTime < _this}, CBA_missionTime + _timeToLive]] call CBA_fnc_serverEvent;
|
[QEGVAR(fire,addFireSource), [_projectile, _radius, _intensity, _projectile, {
|
||||||
|
params ["_endTime", "_projectile"];
|
||||||
|
|
||||||
|
// If incendiary no longer exists, exit
|
||||||
|
if (isNull _projectile) exitWith {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
|
||||||
|
// Need to get the position every time, as grenade might have been moved
|
||||||
|
private _position = position _projectile;
|
||||||
|
|
||||||
|
{
|
||||||
|
// Damage vehicles
|
||||||
|
[QGVAR(damageEngineAndWheels), [_x, _position], _x] call CBA_fnc_targetEvent;
|
||||||
|
} forEach (_position nearEntities ["Car", SEARCH_RADIUS]);
|
||||||
|
|
||||||
|
CBA_missionTime < _endTime // return
|
||||||
|
}, [CBA_missionTime + _timeToLive, _projectile]]] call CBA_fnc_serverEvent;
|
||||||
};
|
};
|
||||||
|
|
||||||
[{
|
[{
|
||||||
@ -196,45 +213,7 @@ if (isServer) then {
|
|||||||
};
|
};
|
||||||
} forEach (_position nearObjects DESTRUCTION_RADIUS);
|
} forEach (_position nearObjects DESTRUCTION_RADIUS);
|
||||||
|
|
||||||
// --- damage local vehicle
|
|
||||||
private _vehicle = _position nearestObject "Car";
|
|
||||||
|
|
||||||
if (!local _vehicle) exitWith {};
|
|
||||||
|
|
||||||
private _config = configOf _vehicle;
|
|
||||||
|
|
||||||
// --- burn tyres
|
|
||||||
private _fnc_isWheelHitPoint = {
|
|
||||||
params ["_selectionName"];
|
|
||||||
|
|
||||||
// wheels must use a selection named "wheel_X_Y_steering" for PhysX to work
|
|
||||||
_selectionName select [0, 6] == "wheel_" && {
|
|
||||||
_selectionName select [count _selectionName - 9] == "_steering"
|
|
||||||
} // return
|
|
||||||
};
|
|
||||||
|
|
||||||
{
|
{
|
||||||
private _wheelSelection = getText (_config >> "HitPoints" >> _x >> "name");
|
// Damage vehicles (locality is checked in FUNC(damageEngineAndWheels))
|
||||||
|
[_x, _position] call FUNC(damageEngineAndWheels);
|
||||||
if (_wheelSelection call _fnc_isWheelHitPoint) then {
|
} forEach (_position nearEntities ["Car", SEARCH_RADIUS]);
|
||||||
private _wheelPosition = _vehicle modelToWorld (_vehicle selectionPosition _wheelSelection);
|
|
||||||
|
|
||||||
if (_position distance _wheelPosition < EFFECT_SIZE * 2) then {
|
|
||||||
_vehicle setHit [_wheelSelection, 1];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
} forEach (getAllHitPointsDamage _vehicle param [0, []]);
|
|
||||||
|
|
||||||
// --- burn car engine
|
|
||||||
if (_vehicle isKindOf "Wheeled_APC_F") exitWith {};
|
|
||||||
|
|
||||||
private _engineSelection = getText (_config >> "HitPoints" >> "HitEngine" >> "name");
|
|
||||||
private _enginePosition = _vehicle modelToWorld (_vehicle selectionPosition _engineSelection);
|
|
||||||
|
|
||||||
if (_position distance _enginePosition < EFFECT_SIZE * 2) then {
|
|
||||||
_vehicle setHit [_engineSelection, 1];
|
|
||||||
|
|
||||||
if (["ace_cookoff"] call EFUNC(common,isModLoaded)) then {
|
|
||||||
[QEGVAR(cookoff,engineFireServer), _vehicle] call CBA_fnc_serverEvent;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
@ -21,4 +21,6 @@
|
|||||||
#define EFFECT_STAGE_PARTIALRECOVERY 2
|
#define EFFECT_STAGE_PARTIALRECOVERY 2
|
||||||
#define EFFECT_STAGE_FULLRECOVERY 3
|
#define EFFECT_STAGE_FULLRECOVERY 3
|
||||||
|
|
||||||
|
#define EFFECT_SIZE 1
|
||||||
|
|
||||||
#define MIN_EXPLOSION_TIME_FOR_ROLL 1
|
#define MIN_EXPLOSION_TIME_FOR_ROLL 1
|
||||||
|
Loading…
Reference in New Issue
Block a user