converting to ace standards

This commit is contained in:
commy2 2017-12-22 15:09:06 +01:00
parent ac09c0f75a
commit 33c2b96bb3
11 changed files with 244 additions and 283 deletions

View File

@ -0,0 +1,11 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call compile preprocessFileLineNumbers 'XEH_preInit.sqf');
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call compile preprocessFileLineNumbers 'XEH_postInit.sqf');
};
};

View File

@ -0,0 +1,77 @@
#include "script_component.hpp"
enableSaving [false, false];
[QGVAR(displayOpened), {
private _player = player;
// player pose
[{
switch (true) do {
case (primaryWeapon _this != ""): {
[_this, "amovpercmstpslowwrfldnon", 2] call EFUNC(common,doAnimation);
};
case (handgunWeapon _this != ""): {
[_this, "amovpercmstpslowwpstdnon", 2] call EFUNC(common,doAnimation);
};
default {
[_this, "amovpercmstpsnonwnondnon", 2] call EFUNC(common,doAnimation);
};
};
}, _player] call CBA_fnc_execNextFrame;
// hide everything except the player
{
_x enableSimulation false;
_x hideObject true;
} forEach (entities [[], [], true] - [_player]);
_player call CBA_fnc_removeUnitTrackProjectiles;
_player setFatigue 0;
}] call CBA_fnc_addEventHandler;
[QGVAR(displayClosed), {
private _player = player;
// unhide everthing
{
_x enableSimulation true;
_x hideObject false;
} forEach entities [[], [], true];
// update VR unit gear
{
private _unit = _x;
removeVest _unit;
_unit addVest vest _player;
removeBackpack _unit;
_unit addBackpack backpack _player;
removeHeadgear _unit;
_unit addHeadgear headgear _player;
removeGoggles _unit;
_unit addGoggles goggles _player;
removeAllWeapons _unit;
_unit addWeapon primaryWeapon _player;
{
_unit addPrimaryWeaponItem _x;
} forEach primaryWeaponItems _player;
_unit addWeapon secondaryWeapon _player;
{
_unit addSecondaryWeaponItem _x;
} forEach secondaryWeaponItems _player;
_unit addWeapon handgunWeapon _player;
{
_unit addHandgunItem _x;
} forEach handgunItems _player;
} forEach (entities [["B_Soldier_VR_F", "O_Soldier_VR_F", "I_Soldier_VR_F"], [], true]);
_player call CBA_fnc_addUnitTrackProjectiles;
}] call CBA_fnc_addEventHandler;

View File

@ -0,0 +1,4 @@
#include "script_component.hpp"
PREP(onPause);
PREP(createTarget);

View File

@ -12,15 +12,6 @@ debriefing = 0;
enableDebugConsoleSP = 1; enableDebugConsoleSP = 1;
doneKeys[] = {"BIS_Arsenal.Map_VR_done"}; doneKeys[] = {"BIS_Arsenal.Map_VR_done"};
onPauseScript[] = {"arsenal_fnc_onPauseScript"}; onPauseScript[] = {QFUNC(onPause)};
class CfgFunctions { #include "CfgEventHandlers.hpp"
class Arsenal {
class Misc {
class createTarget {file = "fn_createTarget.sqf";};
class onPauseScript {file = "fn_onPauseScript.sqf";};
class opened {file = "fn_opened.sqf";};
class closed {file = "fn_closed.sqf";};
};
};
};

View File

@ -1,33 +0,0 @@
if !(_this select 1) then {
{
{
if (_x iskindof "VR_CoverObject_base_F") then {
[_x,0] call bis_fnc_setheight;
} else {
_x enablesimulation true;
_x hideobject false;
};
} foreach ([_x] + crew _x);
} foreach (allmissionobjects "All");
{
_unit = _x;
removevest _unit;
removebackpack _unit;
removeheadgear _unit;
removegoggles _unit;
removeallweapons _unit;
_unit addvest vest player;
_unit addbackpack backpack player;
_unit addheadgear headgear player;
_unit addgoggles goggles player;
_unit addweapon primaryweapon player;
_unit addweapon secondaryweapon player;
_unit addweapon handgunweapon player;
{_unit addprimaryweaponitem _x;} foreach (primaryweaponitems player);
{_unit addsecondaryweaponitem _x;} foreach (secondaryweaponitems player);
{_unit addhandgunitem _x;} foreach (handgunitems player);
} foreach (entities "B_Soldier_VR_F" + entities "O_Soldier_VR_F" + entities "I_Soldier_VR_F");
("RscVRMeta" call bis_fnc_rscLayer) cutrsc ["RscVRMeta","plain"];
};
player setvariable ["BIS_drawLines",true];

View File

@ -1,15 +0,0 @@
_player = missionnamespace getvariable ["BIS_fnc_arsenal_center",player];
{
{
if (_x iskindof "VR_CoverObject_base_F") then {
[_x,-10] call bis_fnc_setheight; //--- Move cover objects below ground instead, they have unexplainable problem with hideObject
} else {
_x enablesimulation false;
_x hideobject true;
};
} foreach ([_x] + crew _x - [_player]);
} foreach (allmissionobjects "All" - [_player]);
("RscVRMeta" call bis_fnc_rscLayer) cuttext ["","plain"];
player setvariable ["BIS_drawLines",false];
player setfatigue 0;

View File

@ -1,3 +1,5 @@
#include "script_component.hpp"
private ["_pos","_side","_obj","_grp","_type","_target"]; private ["_pos","_side","_obj","_grp","_type","_target"];
_pos = [_this,0,[],[[],objnull]] call bis_fnc_param; _pos = [_this,0,[],[[],objnull]] call bis_fnc_param;
_type = [_this,1,"B_Soldier_VR_F",["",objnull]] call bis_fnc_param; _type = [_this,1,"B_Soldier_VR_F",["",objnull]] call bis_fnc_param;
@ -7,13 +9,13 @@ _grp = grpnull;
_var = ""; _var = "";
if (typename _obj == typename objnull) then { if (typename _obj == typename objnull) then {
_grp = group _obj; _grp = group _obj;
_type = typeof _obj; _type = typeof _obj;
_pos = _obj getvariable ["pos",position objnull]; _pos = _obj getvariable ["pos",position objnull];
_var = _obj getvariable ["var",""]; _var = _obj getvariable ["var",""];
[_obj,true] call bis_fnc_VREffectKilled; [_obj,true] call bis_fnc_VREffectKilled;
} else { } else {
_grp = creategroup east; _grp = creategroup east;
}; };
if (_var == "") then {_var = "t" + str round random 999999;}; if (_var == "") then {_var = "t" + str round random 999999;};
@ -48,7 +50,7 @@ missionnamespace setvariable [_var,_target];
_target switchmove "amovpercmstpslowwrfldnon"; _target switchmove "amovpercmstpslowwrfldnon";
_target setvariable ["pos",_pos]; _target setvariable ["pos",_pos];
_target setvariable ["var",_var]; _target setvariable ["var",_var];
_target addeventhandler ["killed",{_this spawn arsenal_fnc_createTarget;}]; _target addeventhandler ["killed", FUNC(createTarget)];
[_target] call bis_fnc_VRHitpart; [_target] call bis_fnc_VRHitpart;
_target _target

View File

@ -8,7 +8,7 @@ _ctrlButtonAbort ctrlSetEventHandler [
"ButtonClick", { "ButtonClick", {
params ["_control"]; params ["_control"];
ctrlParent _control closeDisplay 2; ctrlParent _control closeDisplay 2;
["Open", true] spawn (uiNamespace getVariable "bis_fnc_arsenal"); //@todo {[player, player, true] call FUNC(openBox)} call CBA_fnc_execNextFrame;
true true
} call EFUNC(common,codeToString) } call EFUNC(common,codeToString)
]; ];

View File

@ -1,215 +0,0 @@
"init" call bis_fnc_startloadingscreen;
//enableenvironment false;
enablesaving [false,false];
player allowdamage false;
activateKey format ["BIS_%1.%2_done", missionName, worldName];
cuttext ["","black in",1e10];
waituntil {!isnull (finddisplay 46)};
player switchmove "amovpercmstpslowwrfldnon";
player call bis_fnc_traceBullets;
//--- Static targets in various distance
{
_pos = [player,_x,180 + _foreachindex] call bis_fnc_relpos;
[_pos,"O_Soldier_VR_F"] call arsenal_fnc_createTarget;
} foreach [10,20,30,40,50,100,500,1000,2000];
//--- Target line
_pos = [player,20,90] call bis_fnc_relpos;
for "_i" from 0 to 5 do {
_iPos = [(_pos select 0),(_pos select 1) - 3 + _i,0];
[_ipos,"O_Soldier_VR_F"] call arsenal_fnc_createTarget;
};
//--- Target cluster
_pos = [player,20,-90] call bis_fnc_relpos;
for "_i" from 0 to 8 do {
_index = floor (_i / 3);
_iPos = [
(_pos select 0) + _index * 1.5,
(_pos select 1) + 1.5 + (_i % 3),
0
];
_target = [_ipos,"O_Soldier_VR_F"] call arsenal_fnc_createTarget;
_target switchmove (["aidlpercmstpslowwrfldnon","aidlpknlmstpslowwrfldnon_ai","aidlppnemstpsraswrfldnon_ai"] select _index);
_target setunitpos (["up","middle","down"] select _index);
};
//--- Target patrol
_grp = creategroup east;
{
_wp = _grp addwaypoint [[player,10,_x] call bis_fnc_relpos,0];
if (_foreachindex == 4) then {_wp setwaypointtype "cycle";};
} foreach [0,90,180,270,0];
_pos = [player,10,0] call bis_fnc_relpos;
for "_i" from 0 to 1 do {
_target = [_pos,"O_Soldier_VR_F"] call arsenal_fnc_createTarget;
[_target] join _grp;
_target stop false;
_target enableai "move";
_target setspeedmode "limited";
};
//--- Armored vehicles
_vehicles = [];
if (isclass (configfile >> "cfgvehicles" >> "Land_VR_Target_MRAP_01_F")) then {
_step = 15;
_posCenter = [position player select 0,(position player select 1) + 30,0];
{
_row = _foreachindex;
_rowCount = (count _x - 1) * 0.5;
{
_pos = [
(_posCenter select 0) + (-_rowCount + _foreachindex) * _step,
(_posCenter select 1) + _row * _step,
0
];
_veh = createvehicle [_x,_pos,[],0,"none"];
_veh setpos _pos;
_veh setdir 180;
_veh setvelocity [0,0,-1];
[_veh] call bis_fnc_VRHitpart;
_marker = _veh call bis_fnc_boundingboxmarker;
_marker setmarkercolor "colororange";
_vehicles pushback _veh;
} 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"
]
];
};
_vehicles spawn {
waituntil {
_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
_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"
];
_dis = 3;
for "_i" from 5 to 11 do {
_dir = _i * 45;
_pos = [position player,(abs sin _dir + abs cos _dir) * _dis,_dir] call bis_fnc_relpos;
_block = createvehicle [_coverObjects select (_i % count _coverObjects),_pos,[],0,"none"];
_block setpos _pos;
};
//--- Starting point
_square = createvehicle ["VR_Area_01_square_1x1_grey_F",position player,[],0,"none"];
_square setpos position player;
_marker = createmarker ["bis_start",position player];
_marker setmarkertype "mil_start";
//--- Garage position
_centerPos = [player,[16,16,0] vectorDistance [0,0,0],135] call bis_fnc_relpos;
_squareGarage = createvehicle ["VR_Area_01_square_4x4_grey_F",_centerPos,[],0,"none"];
_squareGarage setpos _centerPos;
BIS_fnc_garage_center = createvehicle ["Land_HelipadEmpty_F",_centerPos,[],0,"none"];
BIS_fnc_garage_center setpos _centerPos;
BIS_fnc_garage_center enablesimulation false;
player addeventhandler [
"animchanged",
{
_unit = _this select 0;
_anim = _this select 1;
_animSplit = [_anim,"_"] call bis_fnc_splitstring;
if ("salute" in _animSplit) then {
{
_x playaction "salute";
} foreach ((position _unit nearobjects ["man",10]) - [player]);
};
}
];
disableserialization;
"init" call bis_fnc_endloadingscreen;
bis_typeLast = 0;
[
missionnamespace,
"arsenalOpened",
{
_this call arsenal_fnc_opened;
bis_typeLast = 0;
}
] call bis_fnc_addscriptedeventhandler;
[
missionnamespace,
"arsenalClosed",
{
_this call arsenal_fnc_closed;
}
] call bis_fnc_addscriptedeventhandler;
[
missionnamespace,
"garageOpened",
{
_this call arsenal_fnc_opened;
bis_typeLast = 1;
}
] call bis_fnc_addscriptedeventhandler;
[
missionnamespace,
"garageClosed",
{
_this call arsenal_fnc_closed;
}
] call bis_fnc_addscriptedeventhandler;
//--- Open Arsenal
bis_fnc_arsenal_fullArsenal = true;
bis_fnc_arsenal_fullGarage = true;
if ((uinamespace getvariable ["bis_fnc_arsenal_typeDefault",0]) > 0) then {
["Open",true] spawn bis_fnc_garage;
} else {
["Open",true] spawn bis_fnc_arsenal;
};
uinamespace setvariable ["bis_fnc_arsenal_typeDefault",nil];
["#(argb,8,8,3)color(0,0,0,1)",false,nil,0.1,[0,0.5]] spawn bis_fnc_textTiles;
//--- Target markers
[] spawn {
_targets = [];
{
_targets pushback vehiclevarname _x;
_var = vehiclevarname _x;
_marker = createmarker [_var,position _x];
_marker setmarkertype "mil_dot";
_marker setmarkercolor "colororange";
} foreach (allmissionobjects "man") - [player];
while {true} do {
{
_t = missionnamespace getvariable _x;
(vehiclevarname _t) setmarkerpos position _t;
} foreach _targets;
sleep 0.1;
};
};

View File

@ -0,0 +1,137 @@
#include "script_component.hpp"
params ["_unit"];
_unit allowDamage false;
/*
//--- Static targets in various distance
{
_pos = [_unit,_x,180 + _foreachindex] call bis_fnc_relpos;
[_pos,"O_Soldier_VR_F"] call arsenal_fnc_createTarget;
} foreach [10,20,30,40,50,100,500,1000,2000];
//--- Target line
_pos = [_unit,20,90] call bis_fnc_relpos;
for "_i" from 0 to 5 do {
_iPos = [(_pos select 0),(_pos select 1) - 3 + _i,0];
[_ipos,"O_Soldier_VR_F"] call arsenal_fnc_createTarget;
};
//--- Target cluster
_pos = [_unit,20,-90] call bis_fnc_relpos;
for "_i" from 0 to 8 do {
_index = floor (_i / 3);
_iPos = [
(_pos select 0) + _index * 1.5,
(_pos select 1) + 1.5 + (_i % 3),
0
];
_target = [_ipos,"O_Soldier_VR_F"] call arsenal_fnc_createTarget;
_target switchmove (["aidlpercmstpslowwrfldnon","aidlpknlmstpslowwrfldnon_ai","aidlppnemstpsraswrfldnon_ai"] select _index);
_target setunitpos (["up","middle","down"] select _index);
};
//--- Target patrol
_grp = creategroup east;
{
_wp = _grp addwaypoint [[_unit,10,_x] call bis_fnc_relpos,0];
if (_foreachindex == 4) then {_wp setwaypointtype "cycle";};
} foreach [0,90,180,270,0];
_pos = [_unit,10,0] call bis_fnc_relpos;
for "_i" from 0 to 1 do {
_target = [_pos,"O_Soldier_VR_F"] call arsenal_fnc_createTarget;
[_target] join _grp;
_target stop false;
_target enableai "move";
_target setspeedmode "limited";
};
//--- Armored vehicles
_vehicles = [];
if (isclass (configfile >> "cfgvehicles" >> "Land_VR_Target_MRAP_01_F")) then {
_step = 15;
_posCenter = [position _unit select 0,(position _unit select 1) + 30,0];
{
_row = _foreachindex;
_rowCount = (count _x - 1) * 0.5;
{
_pos = [
(_posCenter select 0) + (-_rowCount + _foreachindex) * _step,
(_posCenter select 1) + _row * _step,
0
];
_veh = createvehicle [_x,_pos,[],0,"none"];
_veh setpos _pos;
_veh setdir 180;
_veh setvelocity [0,0,-1];
[_veh] call bis_fnc_VRHitpart;
_marker = _veh call bis_fnc_boundingboxmarker;
_marker setmarkercolor "colororange";
_vehicles pushback _veh;
} 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"
]
];
};
_vehicles spawn {
waituntil {
_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
_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"
];
_dis = 3;
for "_i" from 5 to 11 do {
_dir = _i * 45;
_pos = [position _unit,(abs sin _dir + abs cos _dir) * _dis,_dir] call bis_fnc_relpos;
_block = createvehicle [_coverObjects select (_i % count _coverObjects),_pos,[],0,"none"];
_block setpos _pos;
};
//--- Starting point
_square = createvehicle ["VR_Area_01_square_1x1_grey_F",position _unit,[],0,"none"];
_square setpos position _unit;
_marker = createmarker ["bis_start",position _unit];
_marker setmarkertype "mil_start";
//--- Garage position
_centerPos = [_unit,[16,16,0] vectorDistance [0,0,0],135] call bis_fnc_relpos;
_squareGarage = createvehicle ["VR_Area_01_square_4x4_grey_F",_centerPos,[],0,"none"];
_squareGarage setpos _centerPos;
BIS_fnc_garage_center = createvehicle ["Land_HelipadEmpty_F",_centerPos,[],0,"none"];
BIS_fnc_garage_center setpos _centerPos;
BIS_fnc_garage_center enablesimulation false;
*/
[_unit, true, false] call FUNC(initBox);
[{!isNull findDisplay 46}, {
[player, player, true] call FUNC(openBox);
}] call CBA_fnc_waitUntilAndExecute;

View File

@ -1 +1,3 @@
#include "\z\ace\addons\arsenal\script_component.hpp" #include "\z\ace\addons\arsenal\script_component.hpp"
#define PREP(var) FUNC(var) = compileFinal preprocessFileLineNumbers format ["fnc_%1.sqf", QUOTE(var)]