mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
96f81f1c9b
* Add actions based on animations * Add setting * Add ability to set items for users * Add actions for 1.82 changes Add actions for backpacks, canisters, entrench tool. Move items and backpack to WeaponHolder. * Add RHS 0.4.6 ZIL spare * Update to new standards * Handle RHS BTR retread system * Make init faster: move condition to configClasses * Fix CUP fake anims * Refactor * Rework * Rename init function * Decrease number of classes to init * Fix merge mistake * Apply suggestions from code review * Updated code for current mod structure * Multiple fixes & tweaks - Made anim setting require a mission restart - Handle more types of items that can be spawned - Prioritise adding items to inventory and only drop on ground if no inventory space - Add more position checks to make certain no valid position are present before stopping - If 1 item was spawned in, it's considered as success - Disable RHS' wheel replacement only if ace_repair is loaded * Update CfgVehicles.hpp * cache config lookup at preStart * Fix error * Add text config entry for progress bar title * Restructure interactions, improved some locations & added interaction to some missing vehicles * Reverted preInit change --------- Co-authored-by: jonpas <jonpas33@gmail.com> Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
190 lines
6.7 KiB
Plaintext
190 lines
6.7 KiB
Plaintext
// by commy2 and esteldunedain
|
|
#include "script_component.hpp"
|
|
|
|
ACE_Modifier = 0;
|
|
|
|
[QGVAR(pardon), {(_this select 0) addRating -rating (_this select 0)}] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(getDown), {
|
|
params ["_target"];
|
|
|
|
_target setUnitPos "DOWN";
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(sendAway), {
|
|
params ["_unit", "_position"];
|
|
|
|
_unit setUnitPos "AUTO";
|
|
_unit doMove _position;
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(flip), {
|
|
params ["_vehicle"];
|
|
private _position = getPosATL _vehicle;
|
|
_vehicle setVectorUp surfaceNormal _position;
|
|
_vehicle setPosATL _position;
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(setLight), {
|
|
params ["_lamp", "_state"];
|
|
private _hitpoints = _lamp call EFUNC(common,getReflectorsWithSelections) select 1;
|
|
{
|
|
private _damage = _lamp getHit _x;
|
|
if (_state) then {
|
|
if (_damage == DISABLED_LAMP_DAMAGE) then {
|
|
_lamp setHit [_x, 0];
|
|
};
|
|
} else {
|
|
if (_damage < DISABLED_LAMP_DAMAGE) then {
|
|
_lamp setHit [_x, DISABLED_LAMP_DAMAGE];
|
|
};
|
|
};
|
|
} forEach _hitpoints;
|
|
_lamp setVariable [QGVAR(isLightOn), _state, true];
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(setCollisionLight), {
|
|
(_this select 0) setCollisionLight (_this select 1);
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
// Zeus action events
|
|
[QGVAR(zeusStance),{
|
|
{ _x setUnitPos (_this select 0); } forEach (_this select 1);
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
// The following 3 events handle both waypoints and groups
|
|
[QGVAR(zeusBehaviour),{
|
|
if (param [2,false]) then {
|
|
{ _x setWaypointBehaviour (_this select 0); } forEach (_this select 1);
|
|
} else {
|
|
{ _x setBehaviour (_this select 0); } forEach (_this select 1);
|
|
};
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(zeusSpeed),{
|
|
if (param [2,false]) then {
|
|
{ _x setWaypointSpeed (_this select 0); } forEach (_this select 1);
|
|
} else {
|
|
{ _x setSpeedMode (_this select 0); } forEach (_this select 1);
|
|
};
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(zeusFormation),{
|
|
if (param [2,false]) then {
|
|
{ _x setWaypointFormation (_this select 0); } forEach (_this select 1);
|
|
} else {
|
|
{ _x setFormation (_this select 0); } forEach (_this select 1);
|
|
};
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
if (isServer) then {
|
|
[QGVAR(replaceTerrainObject), LINKFUNC(replaceTerrainObject)] call CBA_fnc_addEventHandler;
|
|
};
|
|
|
|
if (!hasInterface) exitWith {};
|
|
|
|
GVAR(isOpeningDoor) = false;
|
|
|
|
[QEGVAR(interact_menu,renderNearbyActions), {
|
|
if (!GVAR(interactWithTerrainObjects)) exitWith {};
|
|
{
|
|
if (
|
|
isObjectHidden _x // after hiding on server
|
|
|| {_x getVariable [QGVAR(terrainObjectReplaced), false]} // after checking but before hiding
|
|
|| {typeOf _x isNotEqualTo ""}
|
|
) then {continue};
|
|
private _model = getModelInfo _x select 1;
|
|
private _class = GVAR(replaceTerrainModels) get _model;
|
|
if (isNil "_class") then {continue};
|
|
_x setVariable [QGVAR(terrainObjectReplaced), true];
|
|
[QGVAR(replaceTerrainObject), [_x, _class]] call CBA_fnc_serverEvent;
|
|
} forEach nearestTerrainObjects [ACE_player, [], 5, false];
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(tapShoulder), {
|
|
params ["_unit", "_shoulderNum"];
|
|
|
|
if (_unit == ACE_player) then {
|
|
addCamShake [4, 0.5, 5];
|
|
private _message = parseText format ([["%1 >", localize LSTRING(YouWereTappedRight)], ["< %1", localize LSTRING(YouWereTappedLeft)]] select (_shoulderNum == 1));
|
|
[_message] call EFUNC(common,displayTextStructured);
|
|
};
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
// add keybinds
|
|
["ACE3 Common", QGVAR(openDoor), localize LSTRING(OpenDoor), {
|
|
// Conditions: canInteract
|
|
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
|
// Conditions: specific
|
|
if (GVAR(isOpeningDoor) || {[MACRO_DOOR_REACH_DISTANCE] call FUNC(getDoor) select 1 == ''}) exitWith {false};
|
|
|
|
// Statement
|
|
call EFUNC(interaction,openDoor);
|
|
true
|
|
}, {
|
|
//Probably don't want any conditions here, so variable never gets locked down
|
|
// Statement
|
|
GVAR(isOpeningDoor) = false;
|
|
true
|
|
},
|
|
[57, [false, true, false]], false] call CBA_fnc_addKeybind; //Key CTRL+Space
|
|
|
|
["ACE3 Common", QGVAR(tapShoulder), localize LSTRING(TapShoulder), {
|
|
// Conditions: canInteract
|
|
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
|
// Conditions: specific
|
|
if !([ACE_player, cursorTarget] call FUNC(canTapShoulder)) exitWith {false};
|
|
|
|
//Tap whichever shoulder is closest
|
|
private _shoulderNum = parseNumber (([cursorTarget, ACE_player] call BIS_fnc_relativeDirTo) > 180);
|
|
|
|
// Statement
|
|
[ACE_player, cursorTarget, _shoulderNum] call FUNC(tapShoulder);
|
|
true
|
|
},
|
|
{false},
|
|
[20, [true, false, false]], false] call CBA_fnc_addKeybind;
|
|
|
|
["isNotSwimming", {!(_this call EFUNC(common,isSwimming))}] call EFUNC(common,addCanInteractWithCondition);
|
|
["isNotOnLadder", {getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> animationState (_this select 0) >> "ACE_isLadder") != 1}] call EFUNC(common,addCanInteractWithCondition);
|
|
|
|
["CBA_settingsInitialized", {
|
|
TRACE_2("settingsInitialized",GVAR(disableNegativeRating),GVAR(enableAnimActions));
|
|
|
|
if (GVAR(disableNegativeRating)) then {
|
|
player addEventHandler ["HandleRating", {
|
|
(_this select 1) max 0
|
|
}];
|
|
};
|
|
|
|
if (!GVAR(enableAnimActions)) exitWith {};
|
|
|
|
// Don't add inherited anim actions (but actions are added to child classes)
|
|
{
|
|
[_x, "InitPost", LINKFUNC(initAnimActions), true, [], true] call CBA_fnc_addClassEventHandler;
|
|
} forEach (keys (uiNamespace getVariable QGVAR(animActionsClasses)));
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
{
|
|
[_x, {
|
|
[QGVAR(clearWeaponAttachmentsActionsCache)] call CBA_fnc_localEvent;
|
|
}] call CBA_fnc_addPlayerEventHandler;
|
|
} forEach ["loadout", "weapon"];
|
|
|
|
// add "Take _weapon_" action to dropped weapons
|
|
private _action = [
|
|
// action display name will be overwritten in modifier function
|
|
QGVAR(takeWeapon), "take", "\A3\ui_f\data\igui\cfg\actions\take_ca.paa",
|
|
{_player action ["TakeWeapon", _target, weaponCargo _target select 0]},
|
|
{(count weaponCargo _target == 1) && {[_player, objNull, []] call EFUNC(common,canInteractWith)}}, // Not checking if container is claimed
|
|
nil, nil, nil, nil, nil,
|
|
{
|
|
params ["_target", "", "", "_actionData"];
|
|
_actionData set [1, format [localize "STR_ACTION_TAKE_BAG", getText (configfile >> "CfgWeapons" >> weaponCargo _target select 0 >> "displayName")]];
|
|
}
|
|
] call EFUNC(interact_menu,createAction);
|
|
|
|
{
|
|
[_x, 0, ["ACE_MainActions"], _action, true] call EFUNC(interact_menu,addActionToClass);
|
|
} forEach ["WeaponHolder", "WeaponHolderSimulated"];
|