mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge branch 'master' of github.com:KoffeinFlummi/ACE3
This commit is contained in:
@ -15,63 +15,74 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_affected", "_strength", "_posGrenade", "_posUnit", "_angleGrenade", "_angleView", "_angleDiff", "_light"];
|
private ["_affected", "_strength", "_posGrenade", "_posUnit", "_angleGrenade", "_angleView", "_angleDiff", "_light", "_losCount"];
|
||||||
|
|
||||||
PARAMS_1(_grenade);
|
PARAMS_1(_grenade);
|
||||||
|
|
||||||
_affected = _grenade nearEntities ["CAManBase", 50];
|
_affected = _grenade nearEntities ["CAManBase", 20];
|
||||||
|
|
||||||
{
|
{
|
||||||
if ((local _x) && {alive _x}) then {
|
if ((local _x) && {alive _x}) then {
|
||||||
|
|
||||||
_strength = 1 - ((_x distance _grenade) min 15) / 15;
|
_strength = 1 - ((_x distance _grenade) min 15) / 15;
|
||||||
|
|
||||||
|
TRACE_3("FlashBangEffect Start",_x,(_x distance _grenade),_strength);
|
||||||
|
|
||||||
if (_x != ACE_player) then {
|
if (_x != ACE_player) then {
|
||||||
//must be AI
|
//must be AI
|
||||||
_x disableAI "MOVE";
|
[_x, true] call EFUNC(common,disableAI);
|
||||||
_x disableAI "ANIM";
|
|
||||||
_x disableAI "AUTOTARGET";
|
|
||||||
_x disableAI "TARGET";
|
|
||||||
_x disableAI "FSM";
|
|
||||||
_x setSkill ((skill _x) / 50);
|
_x setSkill ((skill _x) / 50);
|
||||||
|
|
||||||
[{
|
[{
|
||||||
PARAMS_1(_unit);
|
PARAMS_1(_unit);
|
||||||
_unit enableAI "MOVE";
|
//Make sure we don't enable AI for unconscious units
|
||||||
_unit enableAI "ANIM";
|
if (!(_unit getVariable ["ace_isunconscious", false])) then {
|
||||||
_unit enableAI "AUTOTARGET";
|
[_unit, false] call EFUNC(common,disableAI);
|
||||||
_unit enableAI "TARGET";
|
};
|
||||||
_unit enableAI "FSM";
|
|
||||||
_unit setSkill (skill _unit * 50);
|
_unit setSkill (skill _unit * 50);
|
||||||
}, [_x], (7 * _strength), 0.1] call EFUNC(common,waitAndExecute); //0.1 precision is fine for AI
|
}, [_x], (7 * _strength), 0.1] call EFUNC(common,waitAndExecute); //0.1 precision is fine for AI
|
||||||
} else {
|
} else {
|
||||||
//Do effects for player
|
//Do effects for player
|
||||||
// is there line of sight to the grenade?
|
// is there line of sight to the grenade?
|
||||||
_posGrenade = getPosASL _grenade;
|
_posGrenade = getPosASL _grenade;
|
||||||
|
_eyePos = eyePos ACE_player; //PositionASL
|
||||||
_posGrenade set [2, (_posGrenade select 2) + 0.2]; // compensate for grenade glitching into ground
|
_posGrenade set [2, (_posGrenade select 2) + 0.2]; // compensate for grenade glitching into ground
|
||||||
if (lineIntersects [_posGrenade, getPosASL _x, _grenade, _x]) then {
|
|
||||||
|
_losCount = 0;
|
||||||
|
//Check for line of sight (check 4 points in case grenade is stuck in an object or underground)
|
||||||
|
{
|
||||||
|
if (!lineIntersects [(_posGrenade vectorAdd _x), _eyePos, _grenade, ACE_player]) then {
|
||||||
|
_losCount = _losCount + 1;
|
||||||
|
};
|
||||||
|
} forEach [[0,0,0], [0,0,0.2], [0.1, 0.1, 0.1], [-0.1, -0.1, 0.1]];
|
||||||
|
TRACE_1("Line of sight count (out of 4)",_losCount);
|
||||||
|
if (_losCount == 0) then {
|
||||||
_strength = _strength / 10;
|
_strength = _strength / 10;
|
||||||
};
|
};
|
||||||
|
|
||||||
// beeeeeeeeeeeeeeeeeeeeeeeeeeeeep
|
//Add ace_hearing ear ringing sound effect
|
||||||
if (isClass (configFile >> "CfgPatches" >> "ACE_Hearing") and _strength > 0) then {
|
if ((isClass (configFile >> "CfgPatches" >> "ACE_Hearing")) && {_strength > 0}) then {
|
||||||
[_x, 0.5 + (_strength / 2)] call EFUNC(hearing,earRinging);
|
[_x, 0.5 + (_strength / 2)] call EFUNC(hearing,earRinging);
|
||||||
};
|
};
|
||||||
|
|
||||||
// account for people looking away by slightly
|
// account for people looking away by slightly
|
||||||
// reducing the effect for visual effects.
|
// reducing the effect for visual effects.
|
||||||
_posUnit = getPos _x;
|
_eyeDir = (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]);
|
||||||
_posGrenade = getPos _grenade;
|
_dirToUnitVector = _eyePos vectorFromTo _posGrenade;
|
||||||
_angleGrenade = ((_posGrenade select 0) - (_posUnit select 0)) atan2 ((_posGrenade select 1) - (_posUnit select 1));
|
_angleDiff = acos (_eyeDir vectorDotProduct _dirToUnitVector);
|
||||||
_angleGrenade = (_angleGrenade + 360) % 360;
|
|
||||||
|
|
||||||
_angleView = (eyeDirection ACE_player select 0) atan2 (eyeDirection ACE_player select 1);
|
//From 0-45deg, full effect
|
||||||
_angleView = (_angleView + 360) % 360;
|
if (_angleDiff > 45) then {
|
||||||
|
_strength = _strength - _strength * ((_angleDiff - 45) / 120);
|
||||||
|
};
|
||||||
|
|
||||||
_angleDiff = 180 - abs (abs (_angleGrenade - _angleView) - 180);
|
TRACE_1("Final strength for player",_strength);
|
||||||
_angleDiff = ((_angleDiff - 45) max 0);
|
|
||||||
|
|
||||||
_strength = _strength - _strength * (_angleDiff / 135);
|
|
||||||
|
//Add ace_medical pain effect:
|
||||||
|
if ((isClass (configFile >> "CfgPatches" >> "ACE_Medical")) && {_strength > 0}) then {
|
||||||
|
[ACE_player, (_strength / 2)] call EFUNC(medical,adjustPainLevel);
|
||||||
|
};
|
||||||
|
|
||||||
// create flash to illuminate environment
|
// create flash to illuminate environment
|
||||||
_light = "#lightpoint" createVehicleLocal (getPos _grenade);
|
_light = "#lightpoint" createVehicleLocal (getPos _grenade);
|
||||||
|
@ -17,6 +17,7 @@ PREP(addToLog);
|
|||||||
PREP(addToTriageCard);
|
PREP(addToTriageCard);
|
||||||
PREP(addUnconsciousCondition);
|
PREP(addUnconsciousCondition);
|
||||||
PREP(addUnloadPatientActions);
|
PREP(addUnloadPatientActions);
|
||||||
|
PREP(adjustPainLevel);
|
||||||
PREP(canAccessMedicalEquipment);
|
PREP(canAccessMedicalEquipment);
|
||||||
PREP(canTreat);
|
PREP(canTreat);
|
||||||
PREP(canTreatCached);
|
PREP(canTreatCached);
|
||||||
|
40
addons/medical/functions/fnc_adjustPainLevel.sqf
Normal file
40
addons/medical/functions/fnc_adjustPainLevel.sqf
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Author: PabstMirror
|
||||||
|
* Interface to allow external modules to safely adjust pain levels.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: The patient <OBJECT>
|
||||||
|
* 1: Added ammount of pain (can be negative) <NUMBER>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* The new pain level <NUMBER>
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [guy, 0.5] call ace_medical_fnc_adjustPainLevel
|
||||||
|
*
|
||||||
|
* Public: Yes
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
private ["_pain"];
|
||||||
|
|
||||||
|
PARAMS_2(_unit,_addedPain);
|
||||||
|
|
||||||
|
//Only run on local units:
|
||||||
|
if (!local _unit) exitWith {ERROR("unit is not local");};
|
||||||
|
|
||||||
|
//Ignore if medical system disabled:
|
||||||
|
if (GVAR(level) == 0) exitWith {};
|
||||||
|
|
||||||
|
_pain = _unit getVariable [QGVAR(pain), 0];
|
||||||
|
|
||||||
|
_pain = _pain + _addedPain;
|
||||||
|
if (GVAR(level) == 1) then {_pain = _pain min 1;}; //for basic, cap at 1
|
||||||
|
_pain = _pain max 0;
|
||||||
|
|
||||||
|
_unit setVariable [QGVAR(pain), _pain];
|
||||||
|
|
||||||
|
//Start up the vital watching (if not already running)
|
||||||
|
[_unit] call FUNC(addToInjuredCollection);
|
||||||
|
|
||||||
|
_pain
|
Reference in New Issue
Block a user