Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul Tracers module #491

Merged
merged 51 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
342cf2e
Add attributes for Tracers effects module
ampersand38 Dec 18, 2020
863eb63
tooltip stringtable
ampersand38 Dec 18, 2020
c2fb4ed
Add Dispersion attribute
ampersand38 Dec 18, 2020
7a402d6
Unscheduled
ampersand38 Dec 18, 2020
c4f8d77
Tabs
ampersand38 Dec 22, 2020
8bcede3
Module
ampersand38 Dec 22, 2020
7b4eaae
Hide vanilla module
ampersand38 Dec 22, 2020
a587fa2
Cursor target option
ampersand38 Dec 22, 2020
7601f15
Use serverEvent
ampersand38 Dec 28, 2020
78a3da4
`select` instead. Missing private.
ampersand38 Dec 28, 2020
d9991b1
`_values` instead.
ampersand38 Dec 28, 2020
96976b1
Multi-line like 1moduleWeather` function.
ampersand38 Dec 28, 2020
de941b2
Can spawn at [0, 0, 0] if attaching
ampersand38 Dec 28, 2020
ac4bb8b
Tooltips for min and max
ampersand38 Dec 28, 2020
836902c
order should be: random, camera, and cursor.
ampersand38 Dec 28, 2020
3d94e66
5 options for dispersion
ampersand38 Dec 28, 2020
1745dea
Remove unused `_targetType`
ampersand38 Dec 28, 2020
df9b368
Using `CBA_fnc_waitUntilAndExecute` for bursts
ampersand38 Dec 28, 2020
82aee70
pass _dispersion to `selectPosition`
ampersand38 Dec 28, 2020
c5de4e9
remove comment
ampersand38 Dec 28, 2020
d724fda
Update modules_list.md
ampersand38 Dec 28, 2020
f48079b
Use colours instead of side
ampersand38 Dec 28, 2020
6c467ab
use `select`
ampersand38 Dec 28, 2020
40a7592
Fix case of strings
ampersand38 Dec 28, 2020
ea1fb6e
Remove blank line
ampersand38 Dec 28, 2020
729ce56
`_pfhID` instead of `_handle`
ampersand38 Dec 28, 2020
c2c6844
`findIf` instead of `count`
ampersand38 Dec 28, 2020
85a4683
Stringtables
ampersand38 Dec 28, 2020
861ec24
parameters can be part of the event and then the server broadcasts them
ampersand38 Dec 28, 2020
e08acbb
Fix first shot off target
ampersand38 Dec 28, 2020
12e8b52
tracers renamed to moduleTracersServer
ampersand38 Dec 28, 2020
9cc064a
Update waitUntil params instead of using object variable for shots
ampersand38 Dec 28, 2020
b4e75a7
Multi-line and spaces after commas in arrays.
ampersand38 Jan 8, 2021
82337d4
saveID for dialog
ampersand38 Jan 8, 2021
67e355d
Fix indentation
ampersand38 Jan 8, 2021
cb7908e
Fix example
ampersand38 Jan 10, 2021
65eae5e
force toolbox defaults and default to keep current target
ampersand38 Jan 10, 2021
5614c75
Merge branch 'master' into tracers
ampersand38 Feb 25, 2021
dffc49f
Add custom dialog for Tracers module
mharis001 Feb 26, 2021
7c23726
Add tooltipPerColumn entry
mharis001 Feb 26, 2021
fa335ed
add _vectorToTarget, fix format of _dispersion, _delay
ampersand38 Feb 26, 2021
34a382f
no need for variable
ampersand38 Feb 26, 2021
70907cb
aim is done on line 93
ampersand38 Feb 26, 2021
8a8d5d3
Wait until on-target before starting burst
ampersand38 Feb 26, 2021
3c89e31
header comment
ampersand38 Feb 26, 2021
ea6b1dd
revert dispersion
ampersand38 Mar 1, 2021
46055f0
remove unused _vectorToTarget
ampersand38 Mar 1, 2021
766cf88
Update addons/modules/functions/fnc_moduleTracers.sqf
ampersand38 Mar 4, 2021
496f546
remove unused code
ampersand38 Mar 4, 2021
2e58fa8
Clean up tracers PFH
mharis001 Apr 16, 2021
1a0985c
Fix CBA_missionTime variable name
mharis001 Apr 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions addons/attributes/stringtable.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ZEN">
<Package name="Attributes">
<Key ID="STR_ZEN_Attributes_Dispersion">
<English>Dispersion</English>
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
</Key>
<Key ID="STR_ZEN_Attributes_Engine">
<English>Engine</English>
<French>Moteur</French>
Expand Down
6 changes: 6 additions & 0 deletions addons/common/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@
<Japanese>目標</Japanese>
<Korean>목표</Korean>
</Key>
<Key ID="STR_ZEN_Common_SelectPosition">
<English>Select Position</English>
</Key>
<Key ID="STR_ZEN_Common_SelectedUnit">
<English>Selected Unit</English>
<German>Ausgewählte Einheit</German>
Expand Down Expand Up @@ -610,5 +613,8 @@
<Polish>Kontroluje czy orzeł podążający za kamerą Zeusa jest aktywowany.</Polish>
<Korean>Zeus 카메라를 따라다니는 독수리의 생성 여부를 제어합니다</Korean>
</Key>
<Key ID="STR_ZEN_Common_Cursor">
<English>Cursor</English>
</Key>
</Package>
</Project>
10 changes: 10 additions & 0 deletions addons/modules/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class CfgVehicles {
class ModuleArsenal_F: Module_F {
scopeCurator = 1;
};
class ModuleTracers_F: Module_F {
scopeCurator = 1;
};

class ModuleCAS_F;
class ModuleCASGun_F: ModuleCAS_F {
Expand Down Expand Up @@ -422,6 +425,13 @@ class CfgVehicles {
function = QFUNC(moduleToggleLamps);
icon = QPATHTOF(ui\street_lamp_ca.paa);
};
class GVAR(moduleTracers): GVAR(moduleBase) {
category = "Effects";
displayName = "$STR_a3_cfgvehicles_moduletracers_f_0";
curatorInfoType = QGVAR(RscTracersHelper);
icon = "\a3\modules_f_curator\Data\iconTracers_ca.paa";
portrait = "\a3\modules_f_curator\Data\portraitTracers_ca.paa";
};
class GVAR(moduleTurretOptics): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(Equipment);
Expand Down
2 changes: 2 additions & 0 deletions addons/modules/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ PREP(moduleTeleportPlayers);
PREP(moduleToggleFlashlights);
PREP(moduleToggleIRLasers);
PREP(moduleToggleLamps);
PREP(moduleTracers);
PREP(moduleTurretOptics);
PREP(moduleUnGarrison);
PREP(moduleVisibility);
PREP(moduleWeather);
PREP(tracers);
1 change: 1 addition & 0 deletions addons/modules/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class CfgPatches {
QGVAR(moduleToggleFlashlights),
QGVAR(moduleToggleIRLasers),
QGVAR(moduleToggleLamps),
QGVAR(moduleTracers),
QGVAR(moduleTurretOptics),
QGVAR(moduleUnGarrison),
QGVAR(moduleVisibility),
Expand Down
75 changes: 75 additions & 0 deletions addons/modules/functions/fnc_moduleTracers.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include "script_component.hpp"
/*
* Author: Ampersand
* Zeus module function to shoot tracers.
*
* Arguments:
* 0: Display <DISPLAY>
*
* Return Value:
* None
*
* Example:
* [DISPLAY] call zen_modules_fnc_moduleTracers
*
* Public: No
*/

params ["_display"];

private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objNull);
_display closeDisplay IDC_CANCEL; // Close helper display

// Need to delay dialog creation by one frame to avoid weird input blocking bug
[{
params ["_logic"];

// Default values: green tracers, 10-20s between bursts
private _tracersParams = _logic getVariable [QGVAR(tracersParams), [east, 10, 20, 0.05, "", "", 0, ""]];
_tracersParams params ["_side", "_min", "_max", "_dispersion", "_weapon", "_magazine", "_targetType", "_target"];

["str_a3_cfgvehicles_moduletracers_f_0", [
["SIDES", ELSTRING(attributes,ChangeSide), _side, true],
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
["SLIDER", "str_3den_attributes_timeout_titlemin_text", [0, 120, _min, 0], true],
["SLIDER", "str_3den_attributes_timeout_titlemax_text", [0, 120, _max, 0], true],
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
["SLIDER", ELSTRING(attributes,Dispersion), [0.001, 0.300, _dispersion, 3], true],
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
["EDIT", "str_a3_itemtype_category_weapon", _weapon, true],
["EDIT", "str_a3_itemtype_category_magazine", _magazine, true],
[
"TOOLBOX",
["str_a3_cfgvehicles_modulelivefeedsettarget_f_arguments_targettype_0", LSTRING(Tracers_TargetType_Tooltip)],
[0, 1, 3, [ELSTRING(common,Cursor), ELSTRING(camera,DisplayName), "str_a3_no_target"]]
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
]
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
], {
params ["_dialogValues", "_logic"];
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
_dialogValues params ["_side", "_min", "_max", "_dispersion", "_weapon", "_magazine", "_targetType"];

private _target = objNull;
// select tracer target using cursor
if (_targetType == 0) exitWith {
[_logic, {
params ["_successful", "_logic", "_position", "_args"];
_args params ["_side", "_min", "_max", "_dispersion", "_weapon", "_magazine", "_targetType"];

if (_successful) then {
curatorMouseOver params ["_type", "_entity"];

_target = if (_type == "OBJECT") then {
_entity;
} else {
_position;
};
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved

_logic setVariable [QGVAR(tracersParams), [_side, _min, _max, _dispersion, _weapon, _magazine, _targetType, _target], true];
[_logic] call FUNC(tracers);
};
}, _dialogValues, ELSTRING(common,SelectPosition)] call EFUNC(common,selectPosition);
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
};

if (_targetType == 1) then {_target = AGLToASL positionCameraToWorld [0,0,0]};
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved

_logic setVariable [QGVAR(tracersParams), [_side, _min, _max, _dispersion, _weapon, _magazine, _targetType, _target], true];
[_logic] call FUNC(tracers);
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved

}, {}, _logic] call EFUNC(dialog,create);
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
}, _logic] call CBA_fnc_execNextFrame;
156 changes: 156 additions & 0 deletions addons/modules/functions/fnc_tracers.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#include "script_component.hpp"
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
/*
* Author: Ampersand
* Internal function to shoot tracers at a gamelogic's location.
*
* Arguments:
* 0: Logic <DISPLAY>
*
* Return Value:
* None
*
* Example:
* [LOGIC] call zen_modules_fnc_moduleTracers
*
* Public: No
*/

params [ "_logic"];

private _tracersParams = _logic getVariable [QGVAR(tracersParams), [east, 10, 20, 0.05, "", "", 0, ""]];
_tracersParams params ["_side", "_min", "_max", "_dispersion", "_weapon", "_magazine", "_targetType", "_target"];
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved

_max = _max - _min;

if (_weapon != "" ) then {
// Validate weapon
private _weaponCfg = configFile >> "CfgWeapons" >> _weapon;
if (!isClass _weaponCfg)exitWith
{
if (_weapon != "") then {["'%1' not found in CfgWeapons", _weapon] call BIS_fnc_error;};
};
private _compatibileMagazine = [_weapon] call BIS_fnc_compatibleMagazines;
// Automatically add first compatibile magazine
if (_magazine == "")then
{
if (_compatibileMagazine isEqualTo [])exitWith
{
if (_weapon != "") then {["'%1' doesn't have any valid magazines", _weapon] call BIS_fnc_error;};
};
_magazine = _compatibileMagazine # 0;
} else
{
// Validate magazine manually selected magazine
if (! (_magazine in _compatibileMagazine) )exitWith
{
if (_magazine != "") then {["'%1' is not compatible with '%2'", _magazine, _weapon] call BIS_fnc_error;};
};
};
} else {
_weapon = "FakeWeapon_moduleTracers_F";
_magazine = (["200Rnd_65x39_belt_Tracer_Green", "200Rnd_65x39_belt_Tracer_Red", "200Rnd_65x39_belt_Tracer_Yellow", "200Rnd_65x39_belt_Tracer_Yellow"] select (_side call BIS_fnc_sideID));
};

private _gunner = _logic getVariable [QGVAR(tracersGunner), objNull];
deleteVehicle _gunner;
_gunner = createAgent ["b_soldier_f", position _logic, [], 0, "none"];
_gunner attachTo [_logic, [0,0,0]];
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
_gunner setCaptive true;
_gunner hideObjectGlobal true;
_gunner allowDamage false;
_gunner switchMove "amovpercmstpsraswrfldnon";
_gunner disableAI "anim";
_gunner disableAI "move";
_gunner disableAI "target";
_gunner disableAI "autotarget";
_gunner setBehaviour "careless";
_gunner setCombatMode "blue";
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
removeAllWeapons _gunner;
_gunner addMagazine _magazine;
_gunner addWeapon _weapon;
_gunner selectWeapon _weapon;
_logic setVariable [QGVAR(tracersGunner), _gunner, true];
_logic setVariable [QGVAR(nextBurstTime), 0];

[{
params ["_args", "_handle"];
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
_args params ["_logic", "_gunner", "_min", "_max", "_dispersion", "_weapon", "_target"];

if (isNull _gunner || {isNull _logic}) exitWith {
[_handle] call CBA_fnc_removePerFrameHandler;
deleteVehicle _gunner;
};

private _nextBurstTime = _logic getVariable [QGVAR(nextBurstTime), 0];
if (
CBA_MissionTime >= _nextBurstTime && {
{_gunner distance _x < 100} count (playableunits + switchableunits) == 0
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
}
) then {
if (_target isEqualType "") then {
_target = call compile _target;
};
if (isNil "_target") then {_target = objNull};

private _vectorToTarget = [0, 0, 0];
private _targetPos = [0, 0, 0];
private _logicPos = getPosASLVisual _logic;
private _dir = 0;
private _pitch = 0;

// Sets vector to the target if it's specified
if (!(_target isEqualTo objNull)) then {
// Refresh target
if (_target isEqualType objNull) then {
_targetPos = getPosASLVisual _target;
} else {
_targetPos = _target;
};
_vectorToTarget = _logicPos vectorFromTo _targetPos;

// Vector randomization
_vectorToTarget = _vectorToTarget vectorAdd [random [-_dispersion, 0, _dispersion], random [-_dispersion, 0, _dispersion], random [-_dispersion, 0, _dispersion]];
_logic setVectorDirAndUp [_vectorToTarget, _vectorToTarget vectorCrossProduct [-(_vectorToTarget # 1), _vectorToTarget # 0, 0]];
} else {
// Random firing (old behavior)
_dir = -5 + random 10;
_pitch = 30 + random 60;
_gunner setdir (random 360);
[_gunner, _pitch, 0] call BIS_fnc_setpitchbank;
};

private _shotDelay = 0.05 + random 0.1;
private _burstEndTime = CBA_MissionTime + 0.1 + random 0.9;
_logic setVariable [QGVAR(nextShotTime), 0];

[{
params ["_args", "_handle"];
_args params ["_logic", "_gunner", "_dispersion", "_weapon", "_shotDelay", "_burstEndTime", "_shotDelay"];

if (CBA_MissionTime >= _burstEndTime) exitWith {
[_handle] call CBA_fnc_removePerFrameHandler;
};

// Restore ammo
private _nextShotTime = _logic getVariable [QGVAR(nextShotTime), CBA_MissionTime + _shotDelay];
if (CBA_MissionTime >= _nextShotTime) then {
_gunner setAmmo [_weapon, 999];
[_gunner, _weapon] call BIS_fnc_fire;
_logic setVariable [QGVAR(nextShotTime), CBA_MissionTime + _shotDelay];
};

if (!(_target isEqualTo objNull)) then {
_vectorToTarget = _vectorToTarget vectorAdd [random [-_dispersion, 0, _dispersion], random [-_dispersion, 0, _dispersion], random [-_dispersion, 0, _dispersion]];
_logic setVectorDirAndUp [_vectorToTarget, _vectorToTarget vectorCrossProduct [-(_vectorToTarget # 1), _vectorToTarget # 0, 0]];
} else {
_gunner setdir (direction _gunner + _dir);
[_gunner, _pitch, 0] call BIS_fnc_setpitchbank;
};

}, _shotDelay, [_logic, _gunner, _dispersion, _weapon, _shotDelay, _burstEndTime]] call CBA_fnc_addPerFrameHandler;
ampersand38 marked this conversation as resolved.
Show resolved Hide resolved

_nextBurstTime = CBA_MissionTime + (_min + random _max);
_logic setVariable [QGVAR(nextBurstTime), _nextBurstTime];
};

ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
}, 0.1, [_logic, _gunner, _min, _max, _dispersion, _weapon, _target]] call CBA_fnc_addPerFrameHandler;
5 changes: 5 additions & 0 deletions addons/modules/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ class GVAR(RscLightSourceHelper) {
onLoad = QUOTE(call FUNC(moduleLightSource));
};

class GVAR(RscTracersHelper) {
idd = -1;
onLoad = QUOTE(call FUNC(moduleTracers));
};

class GVAR(RscAmbientFlyby): GVAR(RscDisplay) {
function = QFUNC(gui_ambientFlyby);
class controls: controls {
Expand Down
3 changes: 3 additions & 0 deletions addons/modules/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,9 @@
<Korean>전등이 켜질때 부러진 것들을 수리합니다.</Korean>
<Polish>Napraw zepsute lampy przed włączeniem.</Polish>
</Key>
<Key ID="STR_ZEN_Modules_Tracers_TargetType_Tooltip">
<English>Tracers shoot at target cursor, current camera position, or randomly upward.</English>
</Key>
<Key ID="STR_ZEN_Modules_CustomFire">
<English>Custom Fire</English>
<German>Benutzerdefiniertes Feuer</German>
Expand Down