rewrite Caching in overpressure

update code to params command
update Comments
This commit is contained in:
jokoho48 2015-08-30 07:35:58 +02:00
parent 41edf3dd38
commit 35b6e04345
8 changed files with 128 additions and 83 deletions

View File

@ -3,6 +3,7 @@ class CfgWeapons {
class LauncherCore;
class Launcher: LauncherCore {
GVAR(priority) = 1;
GVAR(angle) = 60;
GVAR(range) = 10;
GVAR(damage) = 0.7;
@ -11,6 +12,7 @@ class CfgWeapons {
class Launcher_Base_F: Launcher {};
class launch_Titan_base: Launcher_Base_F {
GVAR(priority) = 1;
GVAR(angle) = 40;
GVAR(range) = 8;
GVAR(damage) = 0.5;
@ -18,6 +20,7 @@ class CfgWeapons {
class launch_Titan_short_base: launch_Titan_base {
// Titan is a soft-launch launcher
GVAR(priority) = 1;
GVAR(angle) = 30;
GVAR(range) = 2;
GVAR(damage) = 0.5;
@ -25,12 +28,14 @@ class CfgWeapons {
class launch_NLAW_F: Launcher_Base_F {
// NLAW is a soft-launch launcher
GVAR(priority) = 1;
GVAR(angle) = 30;
GVAR(range) = 2;
GVAR(damage) = 0.6;
};
class launch_RPG32_F: Launcher_Base_F {
GVAR(priority) = 1;
GVAR(angle) = 60;
GVAR(range) = 15;
GVAR(damage) = 0.7;
@ -38,12 +43,14 @@ class CfgWeapons {
class CannonCore;
class cannon_120mm: CannonCore {
GVAR(priority) = 1;
GVAR(angle) = 90;
GVAR(range) = 50;
GVAR(damage) = 0.85;
};
class mortar_155mm_AMOS: CannonCore {
GVAR(priority) = 1;
GVAR(angle) = 90;
GVAR(range) = 60;
GVAR(damage) = 1;

View File

@ -4,30 +4,57 @@
* Handle fire of local launchers
*
* Argument:
* 0: Magazine (String)
* 1:
* 0: Weapon <STRING>
* 1: Magazine <STRING>
* 2: Ammo <STRING>
*
* Return value:
* Array:
* 0:
* 1:
* 2:
* 0: Angle <Number>
* 1: Range <Number>
* 2: Damage <Number>
*
*/
#include "script_component.hpp"
EXPLODE_2_PVT(_this,_weapon,_magazine);
if !(isNil (QGVAR(Damage) + _magazine)) exitWith {};
private ["_damage","_angle","_range"];
_damage = getNumber (configFile >> "CfgMagazines" >> _magazine >> QGVAR(damage));
if (_damage == 0) then {
_angle = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(angle)) / 2;
_range = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(range));
_damage = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(damage));
} else {
_angle = getNumber (configFile >> "CfgMagazines" >> _magazine >> QGVAR(angle)) / 2;
_range = getNumber (configFile >> "CfgMagazines" >> _magazine >> QGVAR(range));
};
params ["_weapon", "_magazine", "_ammo"];
missionNameSpace setVariable [(QGVAR(values) + _magazine),[_angle, _range,_damage]];
[_angle,_range,_damage]
private ["_array", "_type", "_return", "_config"];
// get Priority Array from Config
_array = [
getNumber (configFile >> "CfgWeapons" >> QGVAR(priority)),
getNumber (configFile >> "CfgMagazines" >> QGVAR(priority)),
getNumber (configFile >> "CfgAmmo" >> QGVAR(priority))
];
// define Fist Values for Types
_type = 0;
_array params ["_max"];
// get Highest Entry out the the Priority Array
{
if (_max < _x) then {
_max = _x;
_type = _forEachIndex;
};
} forEach _array;
// create the Config entry Point
[
(configFile >> "CfgWeapons" >> _weapon),
(configFile >> "CfgMagazines" >> _magazine),
(configFile >> "CfgMagazines" >> _ammo)
] select _type;
// get the Variables out of the Configes and create a array with then
_return = [
(getNumber (_config >> QGVAR(angle))),
(getNumber (_config >> QGVAR(range))),
(getNumber (_config >> QGVAR(damage)))
];
missionNameSpace setVariable [format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine], _return];
_return

View File

@ -3,14 +3,14 @@
*
* Handle fire of local launchers
*
* Argument:
* 0: Unit that fired (Object)
* 1: Weapon fired (String)
* 2: Muzzle (String)
* 3: Mode (String)
* 4: Ammo (String)
* 5: Magazine (String)
* 6: Projectile (Object)
* Arguments:
* 0: Unit that fired <OBJECT>
* 1: Weapon fired <STRING>
* 2: Muzzle <STRING>
* 3: Mode <STRING>
* 4: Ammo <STRING>
* 5: Magazine <STRING>
* 6: Projectile <OBJECT>
*
* Return value:
* None
@ -18,7 +18,7 @@
#include "script_component.hpp"
EXPLODE_7_PVT(_this,_firer,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
params ["_firer", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"];
// Prevent AI from causing backblast damage
if !([_firer] call EFUNC(common,isPlayer)) exitWith {};
@ -29,7 +29,7 @@ _position = getPosASL _projectile;
_direction = [0, 0, 0] vectorDiff (vectorDir _projectile);
private ["_var","_varName","_backblastAngle", "_backblastRange", "_backblastDamage"];
_varName = (QGVAR(values) + _magazine);
_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
_var = if (isNil _varName) then {
[_weapon,_magazine] call FUNC(cacheOverPressureVales);
} else {

View File

@ -3,14 +3,14 @@
*
* Handle fire of local vehicle weapons creating overpressure zones
*
* Argument:
* 0: Unit that fired (Object)
* 1: Weapon fired (String)
* 2: Muzzle (String)
* 3: Mode (String)
* 4: Ammo (String)
* 5: Magazine (String)
* 6: Projectile (Object)
* Arguments:
* 0: Unit that fired <OBJECT>
* 1: Weapon fired <STRING>
* 2: Muzzle <STRING>
* 3: Mode <STRING>
* 4: Ammo <STRING>
* 5: Magazine <STRING>
* 6: Projectile <OBJECT>
*
* Return value:
* None
@ -18,8 +18,7 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
EXPLODE_7_PVT(_this,_firer,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
params ["_firer", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"];
// Prevent AI from causing overpressure damage
if !([gunner _firer] call EFUNC(common,isPlayer)) exitWith {}; //@todo non-maingun turrets?
@ -28,10 +27,12 @@ private ["_position", "_direction"];
_position = getPosASL _projectile;
_direction = vectorDir _projectile;
private ["_var","_dangerZoneAngle", "_dangerZoneRange", "_dangerZoneDamage"];
_varName = (QGVAR(values) + _magazine);
private ["_var", "_varName", "_dangerZoneAngle", "_dangerZoneRange", "_dangerZoneDamage"];
// Bake Variablen Name and Check if the Variable Exist else call the Cache Function
_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
_var = if (isNil _varName) then {
[_weapon,_magazine] call FUNC(cacheOverPressureVales);
[_weapon, _ammo, _magazine] call FUNC(cacheOverPressureVales);
} else {
missionNameSpace getVariable _varName;
};
@ -42,7 +43,7 @@ private "_affected";
_affected = getPos _projectile nearEntities ["CAManBase", _dangerZoneRange];
// Let each client handle their own affected units
["overpressure", _affected, [_firer, _position, _direction, _weapon,_magazine]] call EFUNC(common,targetEvent);
["overpressure", _affected, [_firer, _position, _direction, _weapon, _magazine, _ammo]] call EFUNC(common,targetEvent);
// Draw debug lines
#ifdef DEBUG_MODE_FULL

View File

@ -3,25 +3,29 @@
*
* Handle fire of local launchers
*
* Argument:
* 0: Unit that fired (Object)
* 1: Weapon fired (String)
* 2: Muzzle (String)
* 3: Mode (String)
* 4: Ammo (String)
* 5: Magazine (String)
* 6: Projectile (Object)
* Arguments:
* 0: Unit that fired <OBJECT>
* 1: Weapon fired <STRING>
* 2: Muzzle <STRING>
* 3: Mode <STRING>
* 4: Ammo <STRING>
* 5: Magazine <STRING>
* 6: Projectile <OBJECT>
*
* Return value:
* None
*/
private ["_var","_varName"];
_varName = (QGVAR(values) + _this select 1);
_var = if (isNil _varName) then {
([_this select 1,_this select 5] call FUNC(cacheOverPressureVales)) select 2;
} else {
(missionNameSpace getVariable _varName) select 2;
};
if (_var > 0) then {
private ["_var","_varName"];
params ["", "_weapon", "", "", "_ammo", "_magazine", ""];
// Bake Variable Name and Check if the Variable Exist else call the Cache Function
_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
_var = if (isNil _varName) then {
([_weapon, _ammo, _magazine] call FUNC(cacheOverPressureVales)) select 2;
} else {
(missionNameSpace getVariable _varName) select 2;
};
if (_var > 0) then {
_this call DFUNC(fireLauncherBackblast)
};
};

View File

@ -3,26 +3,29 @@
*
* Handle fire of Other Weapons
*
* Argument:
* 0: Unit that fired (Object)
* 1: Weapon fired (String)
* 2: Muzzle (String)
* 3: Mode (String)
* 4: Ammo (String)
* 5: Magazine (String)
* 6: Projectile (Object)
* Arguments:
* 0: Unit that fired <OBJECT>
* 1: Weapon fired <STRING>
* 2: Muzzle <STRING>
* 3: Mode <STRING>
* 4: Ammo <STRING>
* 5: Magazine <STRING>
* 6: Projectile <OBJECT>
*
* Return value:
* None
*/
private ["_var","_varName"];
_varName = (QGVAR(values) + _this select 1);
params ["", "_weapon", "", "", "_ammo", "_magazine", ""];
// Bake Variable Name and Check if the Variable Exist else call the Cache Function
_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
_var = if (isNil _varName) then {
([_this select 1,_this select 5] call FUNC(cacheOverPressureVales)) select 2;
([_weapon, _ammo, _magazine] call FUNC(cacheOverPressureVales)) select 2;
} else {
(missionNameSpace getVariable _varName) select 2;
};
if (_var > 0) then {
_this call DFUNC(fireOverpressureZone)
};

View File

@ -3,13 +3,13 @@
*
* Calculate the distance to the first intersection of a line
*
* Argument:
* 0: Pos ASL of origin (Array)
* 1: Direction (Array)
* 2: Max distance to search (Number)
* Arguments:
* 0: Pos ASL of origin (ARRAY>
* 1: Direction <ARRAY>
* 2: Max distance to search <Number>
*
* Return value:
* Distance to intersection (+- 0.1 m)
* Distance to intersection (+- 0.1 m) <NUMBER>
*/
#include "script_component.hpp"

View File

@ -4,20 +4,23 @@
* Calculate and apply backblast damage to potentially affected local units
*
* Argument:
* 0: Unit that fired (Object)
* 1: Pos ASL of the projectile (Array)
* 2: Direction of the projectile (Array)
* 3: Weapon fired (String)
* 0: Unit that fired <OBJECT>
* 1: Pos ASL of the projectile <ARRAY>
* 2: Direction of the projectile <ARRAY>
* 3: Weapon fired <STRING>
* 4: Magazine <STRING>
* 5: Ammo <STRING>
*
* Return value:
* None
*/
#include "script_component.hpp"
EXPLODE_4_PVT(_this,_firer,_posASL,_direction,_weapon,_magazine);
private ["_var","_overpressureAngle", "_overpressureRange", "_overpressureDamage"];
_varName = (QGVAR(values) + _magazine);
params ["_firer", "_posASL", "_direction", "_weapon", "_magazine", "_ammo"];
// Bake Variablen Name and Check if the Variable Exist else call the Cache Function
_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
_var = if (isNil _varName) then {
[_weapon,_magazine] call FUNC(cacheOverPressureVales);
} else {