Merge branch 'master' of https://github.com/KoffeinFlummi/ACE3 into rallypointfix

This commit is contained in:
commy2 2015-04-15 06:51:59 +02:00
commit 44fad81fe1
22 changed files with 221 additions and 108 deletions

View File

@ -15,63 +15,74 @@
*/
#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);
_affected = _grenade nearEntities ["CAManBase", 50];
_affected = _grenade nearEntities ["CAManBase", 20];
{
if ((local _x) && {alive _x}) then {
_strength = 1 - ((_x distance _grenade) min 15) / 15;
TRACE_3("FlashBangEffect Start",_x,(_x distance _grenade),_strength);
if (_x != ACE_player) then {
//must be AI
_x disableAI "MOVE";
_x disableAI "ANIM";
_x disableAI "AUTOTARGET";
_x disableAI "TARGET";
_x disableAI "FSM";
[_x, true] call EFUNC(common,disableAI);
_x setSkill ((skill _x) / 50);
[{
PARAMS_1(_unit);
_unit enableAI "MOVE";
_unit enableAI "ANIM";
_unit enableAI "AUTOTARGET";
_unit enableAI "TARGET";
_unit enableAI "FSM";
//Make sure we don't enable AI for unconscious units
if (!(_unit getVariable ["ace_isunconscious", false])) then {
[_unit, false] call EFUNC(common,disableAI);
};
_unit setSkill (skill _unit * 50);
}, [_x], (7 * _strength), 0.1] call EFUNC(common,waitAndExecute); //0.1 precision is fine for AI
} else {
//Do effects for player
// is there line of sight to the grenade?
_posGrenade = getPosASL _grenade;
_eyePos = eyePos ACE_player; //PositionASL
_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;
};
// beeeeeeeeeeeeeeeeeeeeeeeeeeeeep
if (isClass (configFile >> "CfgPatches" >> "ACE_Hearing") and _strength > 0) then {
//Add ace_hearing ear ringing sound effect
if ((isClass (configFile >> "CfgPatches" >> "ACE_Hearing")) && {_strength > 0}) then {
[_x, 0.5 + (_strength / 2)] call EFUNC(hearing,earRinging);
};
// account for people looking away by slightly
// reducing the effect for visual effects.
_posUnit = getPos _x;
_posGrenade = getPos _grenade;
_angleGrenade = ((_posGrenade select 0) - (_posUnit select 0)) atan2 ((_posGrenade select 1) - (_posUnit select 1));
_angleGrenade = (_angleGrenade + 360) % 360;
_eyeDir = (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]);
_dirToUnitVector = _eyePos vectorFromTo _posGrenade;
_angleDiff = acos (_eyeDir vectorDotProduct _dirToUnitVector);
_angleView = (eyeDirection ACE_player select 0) atan2 (eyeDirection ACE_player select 1);
_angleView = (_angleView + 360) % 360;
//From 0-45deg, full effect
if (_angleDiff > 45) then {
_strength = _strength - _strength * ((_angleDiff - 45) / 120);
};
_angleDiff = 180 - abs (abs (_angleGrenade - _angleView) - 180);
_angleDiff = ((_angleDiff - 45) max 0);
TRACE_1("Final strength for player",_strength);
_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
_light = "#lightpoint" createVehicleLocal (getPos _grenade);

View File

@ -50,3 +50,6 @@ addMissionEventHandler ["Draw3D", DFUNC(render)];
GVAR(actionSelected) = false;
[] call FUNC(keyUp);
}] call EFUNC(common,addEventhandler);
// disable firing while the interact menu is is is opened
["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventHandler);

View File

@ -9,6 +9,7 @@ PREP(compileMenuSelfAction);
PREP(collectActiveActionTree);
PREP(createAction);
PREP(findActionNode);
PREP(handlePlayerChanged);
PREP(isSubPath);
PREP(keyDown);
PREP(keyUp);

View File

@ -26,7 +26,7 @@ class ACE_Settings {
class GVAR(UseListMenu) {
value = 0;
typeName = "BOOL";
isClientSetable = 1;
isClientSettable = 1;
displayName = "$STR_ACE_Interact_Menu_UseListMenu";
};
};

View File

@ -0,0 +1,27 @@
/*
* Author: commy2
* Disables firing while the menu is opened. Called from playerChanged eh.
*
* Argument:
* 0: New unit to add the addAction eh <OBJECT>
* 1: Old unit to remove the addAction eh <STRING>
*
* Return value:
* None
*/
#include "script_component.hpp"
EXPLODE_2_PVT(_this,_newUnit,_oldUnit);
// add to new unit
private "_ehid";
_ehid = [_newUnit, "DefaultAction", {EGVAR(interact_menu,openedMenuType) >= 0}, {}] call EFUNC(common,addActionEventHandler);
_newUnit setVariable [QGVAR(AAEHID), _ehid];
// remove from old unit
_ehid = _oldUnit getVariable [QGVAR(AAEHID), -1];
[_oldUnit, "DefaultAction", _ehid] call EFUNC(common,removeActionEventHandler);
_oldUnit setVariable [QGVAR(AAEHID), -1];

View File

@ -14,50 +14,56 @@
GVAR(currentOptions) = [];
private ["_player","_numInteractObjects","_numInteractions","_actionsVarName","_classActions","_objectActions","_target","_player","_action","_actionData","_active"];
private ["_player","_numInteractObjects","_numInteractions","_actionsVarName","_classActions","_objectActions","_target","_player","_action","_actionData","_active","_cameraPos","_cameraDir"];
_player = ACE_player;
_fnc_renderNearbyActions = {
// Render all nearby interaction menus
#define MAXINTERACTOBJECTS 3
_cameraPos = (positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL);
_cameraDir = ((positionCameraToWorld [0, 0, 1]) call EFUNC(common,positionToASL)) vectorDiff _cameraPos;
_numInteractObjects = 0;
_nearestObjects = nearestObjects [ACE_player, ["All"], 15];
_nearestObjects = nearestObjects [((getPosASL ACE_player) vectorAdd (_cameraDir vectorMultiply 5)) call EFUNC(common,ASLToPosition), ["All"], 8];
{
_target = _x;
_numInteractions = 0;
// Prevent interacting with yourself or your own vehicle
if (_target != ACE_player && {_target != vehicle ACE_player}) then {
// Quick oclussion test. Skip objects more than 1 m behind the camera plane
_lambda = ((getPosASL _x) vectorDiff _cameraPos) vectorDotProduct _cameraDir;
if (_lambda > -1) then {
_numInteractions = 0;
// Prevent interacting with yourself or your own vehicle
if (_target != ACE_player && {_target != vehicle ACE_player}) then {
// Iterate through object actions, find base level actions and render them if appropiate
_actionsVarName = format [QGVAR(Act_%1), typeOf _target];
GVAR(objectActionList) = _target getVariable [QGVAR(actions), []];
{
// Only render them directly if they are base level actions
if (count (_x select 1) == 0) then {
// Try to render the menu
// Iterate through object actions, find base level actions and render them if appropiate
_actionsVarName = format [QGVAR(Act_%1), typeOf _target];
GVAR(objectActionList) = _target getVariable [QGVAR(actions), []];
{
// Only render them directly if they are base level actions
if (count (_x select 1) == 0) then {
// Try to render the menu
_action = _x;
if ([_target, _action] call FUNC(renderBaseMenu)) then {
_numInteractions = _numInteractions + 1;
};
};
} forEach GVAR(objectActionList);
// Iterate through base level class actions and render them if appropiate
_classActions = missionNamespace getVariable [_actionsVarName, []];
{
_action = _x;
// Try to render the menu
if ([_target, _action] call FUNC(renderBaseMenu)) then {
_numInteractions = _numInteractions + 1;
};
};
} forEach GVAR(objectActionList);
} forEach _classActions;
// Iterate through base level class actions and render them if appropiate
_classActions = missionNamespace getVariable [_actionsVarName, []];
{
_action = _x;
// Try to render the menu
if ([_target, _action] call FUNC(renderBaseMenu)) then {
_numInteractions = _numInteractions + 1;
// Limit the amount of objects the player can interact with
if (_numInteractions > 0) then {
_numInteractObjects = _numInteractObjects + 1;
};
} forEach _classActions;
// Limit the amount of objects the player can interact with
if (_numInteractions > 0) then {
_numInteractObjects = _numInteractObjects + 1;
};
};
if (_numInteractObjects >= MAXINTERACTOBJECTS) exitWith {};

View File

@ -9,4 +9,6 @@
#define DEBUG_SETTINGS DEBUG_SETTINGS_INTERACT_MENU
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#include "\z\ace\addons\main\script_macros.hpp"
#define ENABLE_PERFORMANCE_COUNTERS

View File

@ -10,6 +10,10 @@
<Polish>Zawsze wyświetlaj kursor dla własnej interakcji</Polish>
<French>Toujours afficher le curseur pour les interactions sur soi-même</French>
</Key>
<Key ID="STR_ACE_Interact_Menu_UseListMenu">
<English>Display interaction menus as lists</English>
<Spanish>Mostrar los menus de interacción como listas</Spanish>
</Key>
<Key ID="STR_ACE_Interact_Menu_InteractKey">
<English>Interact Key</English>
<German>Fremdinteraktionsmenü-Taste</German>

View File

@ -17,6 +17,7 @@ PREP(addToLog);
PREP(addToTriageCard);
PREP(addUnconsciousCondition);
PREP(addUnloadPatientActions);
PREP(adjustPainLevel);
PREP(canAccessMedicalEquipment);
PREP(canTreat);
PREP(canTreatCached);

View 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

View File

@ -1,9 +1,10 @@
class ACE_Settings {
class GVAR(enabled) {
value = 1;
typeName = "BOOL";
isClientSetable = 1;
value = 2;
typeName = "SCALAR";
isClientSettable = 1;
displayName = "$STR_ACE_MissileGuidance";
description = "$STR_ACE_MissileGuidance_Desc";
values[] = {"Off", "Player Only", "Player and AI"};
};
};

View File

@ -12,6 +12,12 @@ class Extended_PostInit_EventHandlers {
class Extended_FiredBIS_EventHandlers {
class All {
ADDON = QUOTE(_this call FUNC(fired));
ADDON = QUOTE(_this call FUNC(onFired));
};
};
class Extended_IncomingMissile_EventHandlers {
class All {
ADDON = QUOTE(_this call FUNC(onIncomingMissile));
};
};

View File

@ -7,7 +7,8 @@ PREP(changeMissileDirection);
PREP(checkSeekerAngle);
PREP(checkLos);
PREP(fired);
PREP(onFired);
PREP(onIncomingMissile);
PREP(guidancePFH);
PREP(doAttackProfile);

View File

@ -43,12 +43,8 @@ switch( (_state select 0) ) do {
};
case STAGE_CLIMB: {
TRACE_1("STAGE_CLIMB","");
_cruisAlt = 60;
if(_distanceShooterToTarget < w) then {
_cruisAlt = 60 * (_distanceShooterToTarget/2000);
TRACE_1("_cruisAlt", _cruisAlt);
};
_cruisAlt = 60 * (_distanceShooterToTarget/2000);
if( ((ASLToATL _projectilePos) select 2) - ((ASLToATL _seekerTargetPos) select 2) >= _cruisAlt) then {
_state set[0, STAGE_TERMINAL];
} else {

View File

@ -57,7 +57,8 @@ switch( (_state select 0) ) do {
};
case STAGE_COAST: {
TRACE_1("STAGE_COAST","");
if(_distanceShooterToTarget < 1250 || _distanceToTarget < ( ((ASLToATL _projectilePos) select 2) - (( ASLToATL _seekerTargetPos) select 2) )) then {
TRACE_1("", ((ASLToATL _projectilePos) select 2) - (( ASLToATL _seekerTargetPos) select 2) );
if(_distanceShooterToTarget < 1250 || _distanceToTarget < ( ((ASLToATL _projectilePos) select 2) - (( ASLToATL _seekerTargetPos) select 2) ) * 1.5) then {
_state set[0, STAGE_TERMINAL];
};
_returnTargetPos = _seekerTargetPos vectorAdd [0,0,(_projectilePos select 2)];

View File

@ -2,10 +2,10 @@
#include "script_component.hpp"
// Bail if guidance is disabled
if(!GVAR(enabled)) exitWith { false };
// Bail on locality of the projectile, it should be local to us
if(!local _projectile) exitWith { false };
if(GVAR(enabled) < 1 || {!local _projectile} ) exitWith { false };
if( !isPlayer _shooter && { GVAR(enabled) < 2 } ) exitWith { false };
private["_config", "_enabled", "_target", "_seekerType", "_attackProfile"];
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
@ -20,10 +20,13 @@ _enabled = getNumber ( _config >> "enabled");
if(isNil "_enabled" || {_enabled != 1}) exitWith { false };
_target = (vehicle _shooter) getVariable [QGVAR(target), nil];
_targetPos = (vehicle _shooter) getVariable [QGVAR(targetPosition), nil];
_seekerType = (vehicle _shooter) getVariable [QGVAR(seekerType), nil];
_attackProfile = (vehicle _shooter) getVariable [QGVAR(attackProfile), nil];
_lockMode = (vehicle _shooter) getVariable [QGVAR(lockMode), nil];
_launchPos = getPosASL (vehicle _shooter);
TRACE_3("Begin guidance", _target, _seekerType, _attackProfile);
if ( isNil "_seekerType" || { ! ( _seekerType in (getArray (_config >> "seekerTypes" ) ) ) } ) then {
@ -38,21 +41,28 @@ if ( isNil "_lockMode" || { ! ( _lockMode in (getArray (_config >> "seekerLockMo
// If we didn't get a target, try to fall back on tab locking
if(isNil "_target") then {
_canUseLock = getNumber (_config >> "canVanillaLock");
if(_canUseLock > 0) then {
// @TODO: Get vanilla target
_vanillaTarget = cursorTarget;
TRACE_1("Using Vanilla Locking", _vanillaTarget);
if(!isNil "_vanillaTarget") then {
_target = _vanillaTarget;
if(!isPlayer _shooter) then {
// This was an AI shot, lets still guide it on the AI target
_target = _shooter getVariable[QGVAR(vanilla_target), nil];
TRACE_1("Detected AI Shooter!", _target);
} else {
_canUseLock = getNumber (_config >> "canVanillaLock");
if(_canUseLock > 0) then {
// @TODO: Get vanilla target
_vanillaTarget = cursorTarget;
TRACE_1("Using Vanilla Locking", _vanillaTarget);
if(!isNil "_vanillaTarget") then {
_target = _vanillaTarget;
};
};
};
};
TRACE_4("Beginning ACE guidance system",_target,_ammo,_seekerType,_attackProfile);
[FUNC(guidancePFH), 0, [_this,
[ACE_player,
[_shooter,
[_target, _targetPos, _launchPos],
_seekerType,
_attackProfile,

View File

@ -0,0 +1,8 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_3(_target,_ammo,_shooter);
if(GVAR(enabled) < 1) exitWith {}; // bail if enabled
if !(local (gunner _shooter) || {local _shooter}) exitWith {}; // bail if not shooter
_shooter setVariable [QGVAR(vanilla_target),_target, false];

View File

@ -8,10 +8,14 @@ _launchParams = _this select 1;
_seekerParams = _launchParams select 3;
_angleFov = _seekerParams select 0;
_laserResult = [(getPosASL _projectile), (velocity _projectile), _angleFov, [ACE_DEFAULT_LASER_WAVELENGTH,ACE_DEFAULT_LASER_WAVELENGTH], ACE_DEFAULT_LASER_CODE] call EFUNC(laser,seekerFindLaserSpot);
_foundTargetPos = _laserResult select 0;
TRACE_1("Search", _laserResult);
if(!isNil "_target") then {
// Handle AI or moving vanilla lasers
_foundTargetPos = getPosASL _target;
} else {
_laserResult = [(getPosASL _projectile), (velocity _projectile), _angleFov, [ACE_DEFAULT_LASER_WAVELENGTH,ACE_DEFAULT_LASER_WAVELENGTH], ACE_DEFAULT_LASER_CODE] call EFUNC(laser,seekerFindLaserSpot);
_foundTargetPos = _laserResult select 0;
TRACE_1("Search", _laserResult);
};
if(!isNil "_foundTargetPos") then {
//_canSeeTarget = [_projectile, _foundTargetPos, _angleFov] call FUNC(checkSeekerAngle);

View File

@ -13,18 +13,6 @@
<Hungarian>Részletes rakéta irányító</Hungarian>
<Russian>Расширенный ракетой</Russian>
</Key>
<Key ID="STR_ACE_MissileGuidance_Desc">
<English>Enables advanced guidance mechanics and selection for different missiles and fire modes.</English>
<Spanish></Spanish>
<French></French>
<Polish>Włącza zaawansowaną mechanikę i wybór dla różnych rakiet i trybów strzału.</Polish>
<German>Aktiviert die erweiterten Mechaniken für unterschiedliche Raketen und Feuermodi.</German>
<Czech>Povoluje pokročilou mechaniku řízení střel.</Czech>
<Italian></Italian>
<Portuguese></Portuguese>
<Hungarian></Hungarian>
<Russian></Russian>
</Key>
<Key ID="STR_ACE_Hydra70_DAGR">
<English>Hydra-70 DAGR Missile</English>
<Spanish></Spanish>

View File

@ -1,23 +1,23 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
units[] = {"ACE_moduleAllowConfigExport"};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
author[] = {"Glowbal", "PabstMirror"};
authorUrl = "http://github.com/Glowbal";
VERSION_CONFIG;
};
class ADDON {
units[] = {"ACE_moduleAllowConfigExport"};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
author[] = {"Glowbal", "PabstMirror"};
authorUrl = "http://github.com/Glowbal";
VERSION_CONFIG;
};
};
class CfgAddons {
class PreloadAddons {
class ADDON {
list[] = {QUOTE(ADDON)};
class PreloadAddons {
class ADDON {
list[] = {QUOTE(ADDON)};
};
};
};
};

View File

@ -96,11 +96,14 @@ class RscDisplayInterruptEditor3D: RscStandardDisplay {
};
};
class RscDisplayMain: RscStandardDisplay {
//Hide the button if there is no world (-world=empty)
//Seems odd to use onMouseMoving, but I don't want to overload onLoad
onMouseMoving = "((_this select 0) displayCtrl 80085) ctrlShow (missionName != '');";
class controls {
class ACE_Open_settingsMenu_Btn : ACE_Open_SettingsMenu_BtnBase {
action = "if (missionName != '') then {createDialog 'ACE_settingsMenu';};";
y = "4 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + safezoneY";
idc = 80085;
};
};
};

View File

@ -27,7 +27,7 @@ include_directories(AFTER "common")
# Add extensions to build here
add_subdirectory(fcs)
add_subdirectory(breakline)
add_subdirectory(breakLine)
add_subdirectory(advanced_ballistics)
message("Build Type: ${CMAKE_BUILD_TYPE}")