ACE3/addons/arsenal/missions/Arsenal.VR/initPlayerLocal.sqf
johnb432 c8404f496e
Arsenal - Add/Fix/Improve/Change numerous aspects (#9040)
* Arsenal update

* Fixes

* Update fnc_onSelChangedLeft.sqf

* Update fnc_updateUniqueItemsList.sqf

* Header fixes

* Fix for defines.hpp

Co-authored-by: Dystopian <sddex@ya.ru>

* Moved fnc_baseWeapon, filtered invalid items

* Update addons/arsenal/functions/fnc_scanConfig.sqf

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>

* Fixes and tweaks

- Sorting is guaranteed to give a fixed order
- Dog tags no longer throw errors when reloading the ACE arsenal mission when you had some saved in your loadout before quitting the last time you played.

* Cleanup, bug fixes and additions

- Added the ability to add items from "CfgMagazines" into the "Misc. items" or custom tabs.
- Added "baseWeapon" class support for weapon attachments. If a weapon attachment has the config property "baseWeapon" defined, it will take that item and show that in the arsenal.
- Added stronger filtering on item scopes (scope > 0 at least for every item)
- Added "descending" (default, as it is now) and "ascending" sort order as a drop down menu,
- Unique backpacks in containers can now be removed with either the "-" or "clear all items" button.
- When sorting by a number, 2 decimal points have been added, so that when you sort by weight it returns the correct order.

* More fixes and tweaks

- Converted the arsenal to partially work with hashmaps instead of arrays (for configItems and virtualItems, currentItems is still an array).
- Because of the above, performance of FUNC(addVirtualItems) and FUNC(removeVirtualItems) has improved immensely.
- Sorting now caches results, reducing repeated sorting times drastically.
- CBA disposable launchers are handled differently now: Within the arsenal, you can change weapon attachments on disposable launchers, but you can't change their magazines (primary or secondary). Item info on the right and the stats show correct information.
- FUNC(addSort) now checks if the new sorting method already exists and doesn't add it if it does.
- FUNC(removeSort) now exists. You can't remove the default sort type (alphabetically) to avoid problems with the arsenal.
- Both FUNC(addStat) and FUNC(compileStats) actually taken priority into account now. Because of that priority on several stats needed to be tweaked.
- FUNC(removeStat) ensures that there are no gaps within the stat array (so if there is an empty spot in the stats page, it's because there is a stat, but the condition for it being shown hasn't been met).

* Update fnc_replaceUniqueItemsLoadout.sqf

* Update fnc_onSelChangedLeft.sqf

* Update fnc_scanConfig.sqf

* Update docs/wiki/framework/arsenal-framework.md

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>

* Minor cleanup

* Baseweapon filtering

* Improvements + better unique items support

* Update fnc_fillRightPanel.sqf

* Update fnc_onSelChangedLeft.sqf

Fixed: Switching between weapons with incompatible primary magazines while a compatible secondary magazine is loaded doesn't equip the new weapon's primary magazine.

* Update addons/common/functions/fnc_uniqueUnitItems.sqf

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* undefined variable

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* fix undefined loadout var

* Update fnc_fillLoadoutsList.sqf

---------

Co-authored-by: Dystopian <sddex@ya.ru>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2023-07-21 21:25:25 +03:00

186 lines
5.3 KiB
Plaintext

#include "script_component.hpp"
#include "\z\ace\addons\arsenal\defines.hpp"
params ["_unit"];
private _loadout = profileNamespace getVariable QGVAR(missionLastLoadout);
// Load loadout from previous arsenal mission session
if (!isNil "_loadout") then {
[_unit, _loadout] call CBA_fnc_setLoadout;
};
_unit allowDamage false;
// Static targets at various distances
{
["O_Soldier_VR_F", _unit getRelPos [_x, _forEachIndex]] call FUNC(createTarget);
} forEach [10, 20, 30, 40, 50, 100, 500, 1000, 2000];
// Target line to the left of the player
private _position = _unit getRelPos [20, -90];
for "_i" from 0 to 5 do {
["O_Soldier_VR_F", _position vectorAdd [0, -3 + _i, 0]] call FUNC(createTarget);
};
// Target cluster to the right of the player
_position = _unit getRelPos [20, 90];
for "_i" from 0 to 8 do {
private _index = floor (_i / 3);
private _target = ["O_Soldier_VR_F", _position vectorAdd [_index * 1.5, 1.5 + (_i % 3), 0]] call FUNC(createTarget);
_target switchMove (["aidlpercmstpslowwrfldnon", "aidlpknlmstpslowwrfldnon_ai", "aidlppnemstpsraswrfldnon_ai"] select _index);
_target setUnitPos (["UP", "MIDDLE", "DOWN"] select _index);
};
// Target patrol: Spawn waypoints around player
private _group = createGroup east;
{
private _position = _unit getRelPos [10, _x];
private _waypoint = _group addWaypoint [_position, 0];
if (_forEachIndex == 4) then {
_waypoint setWaypointType "CYCLE";
};
} forEach [0, 90, 180, 270, 0];
_position = _unit getRelPos [10, 180];
// Spawn in AI for patrol
for "_i" from 0 to 1 do {
private _target = ["O_Soldier_VR_F", _position] call FUNC(createTarget);
[_target] join _group;
_target stop false;
_target enableAI "MOVE";
_target setSpeedMode "LIMITED";
};
// Armored vehicles to the rear of the player
private _vehicles = [];
private _step = 15;
_position = _unit getRelPos [30, 180];
{
private _row = _forEachIndex;
private _rowCount = (count _x - 1) * 0.5;
{
private _position = _position vectorAdd [(-_rowCount + _forEachIndex) * _step, _row * _step, 0];
private _vehicle = createVehicle [_x, _position, [], 0, "NONE"];
_vehicle setPos _position;
_vehicle setDir 180;
_vehicle setVelocity [0, 0, -1];
_vehicle call BIS_fnc_VRHitpart;
private _marker = _vehicle call BIS_fnc_boundingBoxMarker;
_marker setMarkerColor "ColorOrange";
_vehicles pushBack _vehicle;
} forEach _x;
} forEach [[
"Land_VR_Target_MRAP_01_F",
"Land_VR_Target_APC_Wheeled_01_F",
"Land_VR_Target_MBT_01_cannon_F"
], [
"Land_VR_Target_MRAP_01_F",
"Land_VR_Target_APC_Wheeled_01_F",
"Land_VR_Target_MBT_01_cannon_F"
]];
private _massDestructionAchieved = getStatValue "MarkMassVirtualDestruction";
// Don't check for achievement conditions if achievement already aquired
if (!isNil "_massDestructionAchieved" && {_massDestructionAchieved isEqualTo 1}) then {
_vehicles spawn {
waitUntil {
private _allDisabled = true;
{
_hitAlive = _x getVariable ["BIS_fnc_VRHitParts_hitalive", []];
_allDisabled = _allDisabled && ({!_x} count _hitAlive >= 2);
sleep 0.1;
} forEach _this;
_allDisabled
};
setStatValue ["MarkMassVirtualDestruction", 1];
};
};
// Cover objects
private _coverObjects = [
"Land_VR_CoverObject_01_kneel_F",
"Land_VR_CoverObject_01_kneelHigh_F",
"Land_VR_CoverObject_01_kneelLow_F",
"Land_VR_CoverObject_01_stand_F",
"Land_VR_CoverObject_01_standHigh_F"
];
private _coverObjectsCount = count _coverObjects;
// Set up cover objects
for "_i" from 5 to 11 do {
private _direction = 180 + _i * 45;
private _position = _unit getRelPos [(abs sin _direction + abs cos _direction) * 3, _direction];
private _block = createVehicle [_coverObjects select (_i % _coverObjectsCount), _position, [], 0, "NONE"];
_block setPos _position;
};
// Starting point
private _square = createVehicle ["VR_Area_01_square_1x1_grey_F", position _unit, [], 0, "NONE"];
_square setPosASL getPosASL _unit;
private _marker = createMarker [QGVAR(start), getPosWorld _unit];
_marker setMarkerType "mil_start";
// Init Arsenal
[_unit, true, false] call FUNC(initBox);
// Wait until the mission screen is available
[{!isNull findDisplay IDD_MISSION}, {
[_this, _this, true] call FUNC(openBox);
}, _unit] call CBA_fnc_waitUntilAndExecute;
// Salute
_unit addEventHandler ["AnimChanged", {
params ["_unit", "_anim"];
if ("salute" in (_anim splitString "_")) then {
{
_x playAction "salute";
} forEach ((_unit nearObjects ["CAManBase", 10]) - [_unit]);
};
}];
["#(argb,8,8,3)color(0,0,0,1)", false, nil, 0.1, [0, 0.5]] spawn BIS_fnc_textTiles;
// Target markers
private _markers = [];
{
private _marker = createMarker [vehicleVarName _x, position _x];
_marker setMarkerType "mil_dot";
_marker setMarkerColor "ColorOrange";
_markers pushBack _marker;
} forEach (allMissionObjects "CAManBase" - [_unit]);
// Make the markers move with the targets
_markers spawn {
while {true} do {
{
private _target = missionNamespace getVariable _x;
_x setMarkerPos position _target;
} forEach _this;
sleep 0.1;
};
};