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

Add speed limit attribute #648

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d5718c6
Add speed limit attribute
ampersand38 Oct 22, 2021
90c605a
Check player and vehicle type
ampersand38 Nov 19, 2021
e1fff80
Fix undefined variable in selectPosition function (#657)
sharplol Nov 20, 2021
cf26b06
Fix 3D rotations for attach to module (#658)
Kexanone Nov 30, 2021
36ed484
Common - Filter for ACRE radio IDs when serializing objects (#640)
mjc4wilton Feb 9, 2022
5143dc2
Fix attach offsets not being relative to the object's center (#663)
RedFoxIV Feb 25, 2022
9526266
Edited German Translation (#666)
Nilia119 Apr 27, 2022
3473e81
Prep 1.12.2 Build 30
mharis001 May 9, 2022
64fb5cd
Inventory - Use maxLoad command (#673)
mharis001 Aug 29, 2022
aa026ae
Add SQFC support (#674)
mharis001 Aug 29, 2022
ce592fc
Area Markers - Support editing all area markers (#676)
mharis001 Aug 29, 2022
f482937
Add fire mode option to Suppressive Fire module (#677)
mharis001 Aug 29, 2022
8b427e3
CBA Extended Loadouts (#669)
BrettMayson Oct 16, 2022
d79fa3b
Add snow option to Change Weather module (#682)
johnb432 Oct 26, 2022
dabbe64
Custom Modules - Various improvements (#685)
mharis001 Nov 16, 2022
5a4ccf6
Fix unit and group tree IDCs for updated RscDisplayCurator_sections (…
mharis001 Nov 16, 2022
1ee7ccf
Visibility - Add during placement only mode and max distance setting …
mharis001 Dec 3, 2022
2f08cf7
Add placement preview support to recent tree (#689)
mharis001 Dec 3, 2022
791e66f
Add mod icons to create unit trees (#684)
mharis001 Dec 3, 2022
527b200
Improve placement preview mouse position handling (#690)
mharis001 Dec 9, 2022
456fb74
Ignore .vscode folder (#694)
Kexanone Dec 24, 2022
9199403
Add attach/detach keybinds and allow editing attached objects directl…
mharis001 Dec 24, 2022
73946d8
Improve positioning of Teleport Players module (#693)
Kexanone Dec 24, 2022
a6a5d95
Inventory - Disable for CAManBase objects (#697)
mharis001 Dec 25, 2022
d08a6e7
Mark created groups for autodeletion (#698)
Kexanone Dec 27, 2022
4e21480
Add speed limit attribute
ampersand38 Oct 22, 2021
75e5118
Check player and vehicle type
ampersand38 Nov 19, 2021
eba2066
only for vehicles for now
ampersand38 Jan 10, 2023
7ed9fc3
add settings to toggle attributes
ampersand38 Jan 10, 2023
6e6130a
fix condition
ampersand38 Jan 10, 2023
d3126b1
allow negative speed
ampersand38 Jan 10, 2023
e85a16f
Merge branch 'speed-limit-attribute' of https://github.com/ampersand3…
ampersand38 Jan 10, 2023
6bc9818
add tooltip
ampersand38 Jan 10, 2023
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ hemtt*
!hemtt.toml
@zen
tools/armake.exe
ArmaScriptCompiler.exe
*.sqfc
.vscode/*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<p align="center">
<a href="https://github.com/zen-mod/ZEN/releases">
<img src="https://img.shields.io/badge/Version-1.12.1-blue.svg?style=flat-square" alt="Zeus Enhanced Version">
<img src="https://img.shields.io/badge/Version-1.12.2-blue.svg?style=flat-square" alt="Zeus Enhanced Version">
</a>
<a href="https://github.com/zen-mod/ZEN/issues">
<img src="https://img.shields.io/github/issues-raw/zen-mod/ZEN.svg?style=flat-square&label=Issues" alt="Zeus Enhanced Issues">
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.1.29
1.12.2.30
6 changes: 3 additions & 3 deletions addons/ai/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart));
};
};

class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
init = QUOTE(call COMPILE_SCRIPT(XEH_preInit));
};
};

class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
init = QUOTE(call COMPILE_SCRIPT(XEH_postInit));
};
};
148 changes: 99 additions & 49 deletions addons/ai/functions/fnc_suppressiveFire.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@
* 1: Target <OBJECT|ARRAY>
* - Position must be in ATL format.
* 2: Duration <NUMBER> (default: 20)
* 3: Stance <STRING> (default: "AUTO")
* 3: Fire Mode <NUMBER> (default: 4)
* - 0: Single shots (slow).
* - 1: Single shots (fast).
* - 2: Three round bursts (slow).
* - 3: Three round bursts (fast).
* - 4: Fully automatic (with pauses).
* - 5: Fully automatic (uninterrupted).
* - May not apply to weapons limited by long ammo reloading times.
* 4: Stance <STRING> (default: "AUTO")
* - Must be one of the modes used by the setUnitPos command.
*
* Return Value:
* None
Expand All @@ -27,6 +36,7 @@ params [
["_unit", objNull, [objNull, grpNull]],
["_target", [0, 0, 0], [[], objNull], 3],
["_duration", 20, [0]],
["_fireMode", 4, [0]],
["_stance", "AUTO", [""]]
];

Expand All @@ -36,7 +46,7 @@ if (!local _unit) exitWith {

if (_unit isEqualType grpNull) exitWith {
{
[_x, _target, _duration, _stance] call FUNC(suppressiveFire);
[_x, _target, _duration, _fireMode, _stance] call FUNC(suppressiveFire);
} forEach units _unit;
};

Expand Down Expand Up @@ -101,6 +111,16 @@ _unit lookAt _target;
_unit doWatch _target;
_unit doTarget _target;

// Get the rounds per burst and time between bursts based on the given fire mode
[
[1, [2, 3, 4]],
[1, [1, 1.5, 2]],
[3, [2, 3, 4]],
[3, [1, 1.5, 2]],
[10, [1.25, 1.5, 1.75]],
[10, [0, 0, 0]]
] select (0 max _fireMode min 5) params ["_roundsPerBurst", "_burstDelay"];

// Force the unit to fire their weapon for the specified duration. Works better than using the doSuppressiveFire
// command which does not make units realiably fire at the target, especially at longer distances. Small initial
// delay to give units time to aim at the target. We ignore reloading and give units infinite ammo to create a
Expand All @@ -109,7 +129,21 @@ private _endTime = CBA_missionTime + _duration + TARGETING_DELAY;

[{
[{
params ["_unit", "_target", "_isTempTarget", "_abilities", "_skills", "_behaviour", "_combatMode", "_unitPos", "_shotTime", "_endTime"];
params [
"_unit",
"_target",
"_isTempTarget",
"_abilities",
"_skills",
"_behaviour",
"_combatMode",
"_unitPos",
"_roundsPerBurst",
"_burstDelay",
"_currentBurstRounds",
"_shotTime",
"_endTime"
];

if (
!alive _unit
Expand Down Expand Up @@ -144,63 +178,79 @@ private _endTime = CBA_missionTime + _duration + TARGETING_DELAY;

if (CBA_missionTime >= _shotTime) then {
private _vehicle = vehicle _unit;
private _turretPath = _vehicle unitTurret _unit;

if (_vehicle == _unit) exitWith {
weaponState _unit params ["_weapon", "_muzzle", "_fireMode"];

_unit setAmmo [_weapon, 1e6];
_unit forceWeaponFire [_muzzle, _fireMode];
_this set [8, CBA_missionTime + 0.1];
};

if (_unit call EFUNC(common,isUnitFFV)) exitWith {
// Using UseMagazine action since forceWeaponFire command does not work for FFV units
// UseMagazine action doesn't seem to work with currently loaded magazine (currentMagazineDetail)
// Therefore, this relies on the unit having an extra magazine in their inventory
// but should be fine in most situations
private _weapon = currentWeapon _unit;
private _compatibleMagazines = _weapon call CBA_fnc_compatibleMagazines;
private _index = magazines _unit findIf {_x in _compatibleMagazines};
if (_index == -1) exitWith {};

private _magazine = magazinesDetail _unit select _index;
_magazine call EFUNC(common,parseMagazineDetail) params ["_id", "_owner"];

_unit setAmmo [_weapon, 1e6];
CBA_logic action ["UseMagazine", _unit, _unit, _owner, _id];
_this set [8, CBA_missionTime + 0.1];
};
switch (true) do {
// On foot
case (_vehicle == _unit): {
weaponState _unit params ["_weapon", "_muzzle", "_fireMode"];

private _turretPath = _vehicle unitTurret _unit;
private _muzzle = weaponState [_vehicle, _turretPath] select 1;
_unit setAmmo [_muzzle, 1e6];
_unit setAmmo [_weapon, 1e6];
_unit forceWeaponFire [_muzzle, _fireMode];
};

// Get the reload time for the current weapon state
weaponState [_vehicle, _turretPath] params ["_weapon", "_muzzle", "_fireMode", "_magazine", "_ammo"];
// FFV
case (_unit call EFUNC(common,isUnitFFV)): {
// Using UseMagazine action since forceWeaponFire command does not work for FFV units
// UseMagazine action doesn't seem to work with currently loaded magazine (currentMagazineDetail)
// Therefore, this relies on the unit having an extra magazine in their inventory
// but should be fine in most situations
private _weapon = currentWeapon _unit;
private _compatibleMagazines = _weapon call CBA_fnc_compatibleMagazines;
private _index = magazines _unit findAny _compatibleMagazines;
if (_index == -1) exitWith {};

private _magazine = magazinesDetail _unit select _index;
_magazine call EFUNC(common,parseMagazineDetail) params ["_id", "_owner"];

_unit setAmmo [_weapon, 1e6];
CBA_logic action ["UseMagazine", _unit, _unit, _owner, _id];
};

private _config = configFile >> "CfgWeapons" >> _weapon;
// Vehicle gunner
default {
private _muzzle = weaponState [_vehicle, _turretPath] select 1;
_unit setAmmo [_muzzle, 1e6];

if (_muzzle != _weapon) then {
_config = _config >> _muzzle;
private _magazine = _vehicle currentMagazineDetailTurret _turretPath;
_magazine call EFUNC(common,parseMagazineDetail) params ["_id", "_owner"];
_vehicle action ["UseMagazine", _vehicle, _unit, _owner, _id];
};
};

if (_muzzle != _fireMode) then {
_config = _config >> _fireMode;
};
// Set time until the next shot based on the weapon's ammo reloading time and whether the current burst is finished
private _reloadTime = [_vehicle, _turretPath] call EFUNC(common,getWeaponReloadTime);
_currentBurstRounds = _currentBurstRounds + 1;

private _reloadTime = getNumber (_config >> "reloadTime");
if (_currentBurstRounds >= _roundsPerBurst) then {
_currentBurstRounds = 0;

// Find the correct magazine id and owner and force the weapon to fire
{
_x params ["_xMagazine", "_xTurretPath", "_xAmmo", "_id", "_owner"];
// Calculate the delay until the next burst
// Use ammo reloading time if it is longer to prevent firing before the weapon is ready
private _nextBurstDelay = random _burstDelay max _reloadTime;
_shotTime = CBA_missionTime + _nextBurstDelay;
} else {
_shotTime = CBA_missionTime + _reloadTime;
};

if (_xTurretPath isEqualTo _turretPath && {_xMagazine == _magazine && {_xAmmo == _ammo && {_xAmmo != 0}}}) exitWith {
_vehicle action ["UseMagazine", _vehicle, _unit, _owner, _id];
_this set [8, CBA_missionTime + _reloadTime];
};
} forEach magazinesAllTurrets _vehicle;
_this set [10, _currentBurstRounds];
_this set [11, _shotTime];
};

false // Continue
}, {}, _this] call CBA_fnc_waitUntilAndExecute;
}, [_unit, _target, _isTempTarget, _abilities, _skills, _behaviour, _combatMode, _unitPos, 0, _endTime], TARGETING_DELAY] call CBA_fnc_waitAndExecute;
}, [
_unit,
_target,
_isTempTarget,
_abilities,
_skills,
_behaviour,
_combatMode,
_unitPos,
_roundsPerBurst,
_burstDelay,
0, // _currentBurstRounds
0, // _shotTime
_endTime
], TARGETING_DELAY] call CBA_fnc_waitAndExecute;
6 changes: 3 additions & 3 deletions addons/area_markers/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart));
};
};

class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
init = QUOTE(call COMPILE_SCRIPT(XEH_preInit));
};
};

class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
init = QUOTE(call COMPILE_SCRIPT(XEH_postInit));
};
};
7 changes: 7 additions & 0 deletions addons/area_markers/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
PREP(applyProperties);
PREP(configure);
PREP(createIcon);
PREP(createMarker);
PREP(deleteIcon);
PREP(initDisplayCurator);
PREP(isEditable);
PREP(module);
PREP(onDraw);
PREP(onKeyDown);
PREP(onMapToggled);
PREP(onMarkerCreated);
PREP(onMarkerDeleted);
PREP(onMarkerUpdated);
PREP(onMouseButtonDown);
PREP(onMouseButtonUp);
PREP(onMouseDblClick);
Expand Down
92 changes: 17 additions & 75 deletions addons/area_markers/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,82 +1,24 @@
#include "script_component.hpp"

if (isServer) then {
[QGVAR(create), {
params ["_position"];

private _marker = createMarker [format [QGVAR(%1), GVAR(nextID)], _position];
_marker setMarkerShape "RECTANGLE";
_marker setMarkerSize [50, 50];

GVAR(markers) pushBack _marker;
publicVariable QGVAR(markers);

GVAR(nextID) = GVAR(nextID) + 1;

[QGVAR(createIcon), _marker] call CBA_fnc_globalEvent;
}] call CBA_fnc_addEventHandler;

[QGVAR(delete), {
params ["_marker"];

private _index = GVAR(markers) find _marker;

if (_index != -1) then {
GVAR(markers) deleteAt _index;
publicVariable QGVAR(markers);

deleteMarker _marker;

[QGVAR(deleteIcon), _marker] call CBA_fnc_globalEvent;
};
}] call CBA_fnc_addEventHandler;
[QGVAR(createMarker), LINKFUNC(createMarker)] call CBA_fnc_addEventHandler;
};

if (hasInterface) then {
["zen_curatorDisplayLoaded", {
params ["_display"];

// Namespace of marker names and their corresponding icon controls
if (isNil QGVAR(icons)) then {
GVAR(icons) = [] call CBA_fnc_createNamespace;
};

// Add EH to update area marker icon positions when the map is shown
private _ctrlMap = _display displayCtrl IDC_RSCDISPLAYCURATOR_MAINMAP;
_ctrlMap ctrlAddEventHandler ["Draw", {call FUNC(onDraw)}];

// Add EH to handle deleting area marker by pressing the DELETE key
_display displayAddEventHandler ["KeyDown", {call FUNC(onKeyDown)}];

// Create area marker icons for all area markers
{
{
[_x] call FUNC(createIcon);
} forEach GVAR(markers);
} call CBA_fnc_execNextFrame;

// Add PFH to update visibility of area marker icons
GVAR(visiblePFH) = [{
params ["_args"];
_args params ["_visible"];

if (_visible isEqualTo visibleMap) exitWith {};

_visible = visibleMap;
{
private _ctrlIcon = GVAR(icons) getVariable [_x, controlNull];
_ctrlIcon ctrlShow _visible;
} forEach GVAR(markers);

_args set [0, _visible];
}, 0, [visibleMap]] call CBA_fnc_addPerFrameHandler;
}] call CBA_fnc_addEventHandler;

["zen_curatorDisplayUnloaded", {
GVAR(visiblePFH) call CBA_fnc_removePerFrameHandler;
}] call CBA_fnc_addEventHandler;

[QGVAR(createIcon), LINKFUNC(createIcon)] call CBA_fnc_addEventHandler;
[QGVAR(deleteIcon), LINKFUNC(deleteIcon)] call CBA_fnc_addEventHandler;
[QGVAR(updateIcon), LINKFUNC(updateIcon)] call CBA_fnc_addEventHandler;
["zen_curatorDisplayLoaded", LINKFUNC(initDisplayCurator)] call CBA_fnc_addEventHandler;

// Add EHs to update visibility of area marker icons when the map is toggled
// Need both activate and deactivate to deal with issues around rapidly toggling the map
addUserActionEventHandler ["showMap", "Activate", {call FUNC(onMapToggled)}];
addUserActionEventHandler ["showMap", "Deactivate", {call FUNC(onMapToggled)}];

// Add EHs to automatically make any area markers editable
addMissionEventHandler ["MarkerCreated", {call FUNC(onMarkerCreated)}];
addMissionEventHandler ["MarkerDeleted", {call FUNC(onMarkerDeleted)}];
addMissionEventHandler ["MarkerUpdated", {call FUNC(onMarkerUpdated)}];

// Manually trigger event for 3DEN placed and already existent (JIP) markers
{
_x call FUNC(onMarkerCreated);
} forEach allMapMarkers;
};
Loading