SaveLootPositions_v2

This commit is contained in:
He-Man 2019-06-08 20:21:24 +02:00
parent 35dfd71d13
commit 1759983d93
3 changed files with 498 additions and 0 deletions

View File

@ -0,0 +1,57 @@
Instruction:
You can run this code in Multiplayer on a Server or in Editor.
If running in editor, make sure you have loaded the Epoch mission to have access to the current Loot Configs.
In Multiplayer on a Server, you are able to work in a group. The Variables are broadcasted, so several players can define parallel the Positions.
1. Run the whole codes (copy/paste) within "saveLootPositions_v2_Codes.sqf" on all clients, who want to work on the LootBuilder. This code will:
- Add MapMarkers for all Building Types without defined Loot Positions
- Add the needed Display Eventhandlers to Place loot and save it.
2. Do your work - There are 2 procedures how you can work:
1.
- Jump between random buildings with not defined Loot with F11
- The Building you are at is automatically defined as your Loot Building.
- Choose and place your Loot (see next chapter) or if no Loot is needed here, skip this Building with F9 (Marker will be removed)
- Switch to the next random Building with F11...
2.
- Move to a Mapmarker where you want to define the Loot
- Look on the Building and press Enter to select the Building (a hint should come up with the defined Building)
- Choose and place your Loot (see next chapter) or if no Loot is needed here, skip this Building with F9 (Marker will be removed)
- You can now travel to the next not defined Building and repeat the above procedure
Choose and place Loot:
- Choose a LootContainer for positioning with Home/End (Pos1/End)
- Move the LootContainer to the wanted Position with the numbers on Numpad
- Num8 -> Move LootContainer Fwd
- Num2 -> Move LootContainer Back
- Num4 -> Move LootContainer left
- Num6 -> Move LootContainer right
- Num7 -> Rotate LootContainer counter clockwise
- Num9 -> Rotate LootContainer Clockwise
- PageUp -> Lift LootContainer
- PageDown -> Lower LootContainer
- Save this LootContainer to the Building type with Space Bar
- The MapMarker for this Building should now get removed automatically
- Choose the next Loot Container with Pos1/End and repeat the procedure
Shortcuts Overwiew:
- LootPositioning:
- ENTER -> Select a Building
- F9 -> Remove Marker for selected Building (without defining Loot Positions)
- home (pos1) -> Select (switch to) next LootContainer
- end -> Select (switch to) previous Loot Container
- ESC -> Abort (Remove LootContainer)
- Num8 -> Move LootContainer Fwd
- Num2 -> Move LootContainer Back
- Num4 -> Move LootContainer left
- Num6 -> Move LootContainer right
- Num7 -> Rotate LootContainer counter clockwise
- Num9 -> Rotate LootContainer Clockwise
- PageUp -> Lift LootContainer
- PageDown -> Lower LootContainer
- ctrl -> Speed up movement for LootContainer
- Space Bar -> Save LootContainer to current BuildingType
- Player Movement
- F11 -> teleport to next undefined Marker
- 4 -> Fly Up (to get faster in higher Buildings for example)
- 5 -> Teleport 10m infront (in case you are stucked or want to move faster)
- CTRL + Mouseclick (on Map) -> Teleport to cursor position
3. Export the config entries by running the code within saveLootPositions_v2_ExportConfig.sqf
- If in Editor, the config should be in your clipboard.
- If on a Server, read out the Variable "LootarrayStr" (only one CLient have to run it to get the String)

View File

@ -0,0 +1,383 @@
if (isnil "LootMarkersPositions" && isnil "LootMarkers") then {
_Skipbuildings = [
"Land_Mil_Barracks_L",
"Land_Mil_Guardhouse",
"Land_Mil_ControlTower_ruins",
"Land_Mil_ControlTower",
"Land_Mil_Barracks",
"Land_Mil_House",
"Land_SS_hangar",
"Land_a_stationhouse",
"Land_Misc_WaterStation",
"Land_HouseV_3I4",
"Land_HouseV_3I3",
"Land_HouseV_3I2",
"Land_HouseV_3I1",
"Land_HouseV_2T2",
"Land_HouseV_2T1",
"Land_HouseV_2L",
"Land_HouseV_2I",
"Land_HouseV_1t",
"Land_HouseV_1L2",
"Land_StoneWell_01_F", "Land_FeedRack_01_F", "Land_HighVoltageTower_largeCorner_F", "Land_HighVoltageTower_large_F", "Land_Hutch_01_F", "Land_Communication_F", "Land_ChickenCoop_01_F", "Land_MysteriousBell_01_F", "Land_Calvary_03_F", "Land_Chapel_02_white_ruins_F", "Land_Sawmill_01_illuminati_tower_F", "Land_DryToilet_01_F", "Land_House_2B02_ruins_F", "Land_House_1W08_ruins_F", "Land_FuelStation_Shed_F", "Land_FuelStation_Feed_F", "Land_Greenhouse_01_damaged_F", "Land_Slums02_4m",
"Land_Metal_Shed_ruins_F", "Land_FeedShack_01_F", "Land_TBox_ruins_F", "Land_Slum_House03_ruins_F", "Land_Smokestack_03_ruins_F", "Land_Slum_House02_ruins_F", "Land_TTowerSmall_2_F", "Land_Chapel_02_yellow_ruins_F", "Land_Radar_01_antenna_F", "Land_FeedStorage_01_F", "Land_House_1W04_ruins_F"
];
_skipstrings = [
"land_containerline",
"land_telephoneline",
"land_power_pole",
"land_netfence",
"land_woodenwall",
"land_brickwall",
"land_grave",
"sign",
"powerline",
"stairs",
"protection",
"invisible",
"concrete",
"light",
"lamp",
"runway",
"pier",
"pipe",
"cargo",
"bridge",
"boat",
"castle",
"mirror",
"gate",
"wreck",
"powerlines",
"tank",
"plot",
"garbage",
"wired",
"barrier",
"bagfence",
"luggage",
"helipad"
];
LootMarkersPositions = [];
LootMarkers = [];
if (isnil 'LootArray') then {LootArray = []};
_allbuildingtypes = [];
_allmapbuildings = nearestobjects [player,['building'],40000];
_masterConfig = (missionConfigFile >> "CfgBuildingLootPos");
_c = 1;
{
_building = _x;
if !(typeof _building in _Skipbuildings) then {
if !(typeof _building in _allbuildingtypes) then {
if ({typeof _building == (_x select 0)} count LootArray == 0) then {
_config = _masterConfig >> (typeOf _building);
if !(isClass(_config)) then {
_skip = false;
{
if (tolower (typeOf _building) find _x > -1) exitwith {
_skip = true;
};
} foreach _skipstrings;
if !(_skip) then {
_allbuildingtypes pushback (typeof _building);
_marker = createMarker [typeof _building, (getpos _building)];
_marker setmarkertype "mil_dot";
_marker setMarkerColor 'ColorRed';
_marker setMarkerText (typeof _building);
LootMarkersPositions pushback (getpos _building);
LootMarkers pushback (typeof _building);
_c = _c+1;
};
};
};
};
};
} foreach _allmapbuildings;
publicvariable "LootMarkersPositions";
publicvariable "LootMarkers";
};
Itemarray = ["toilet_epoch","Shelf_EPOCH","Fridge_EPOCH","Bunk_EPOCH","Couch_EPOCH","wardrobe_epoch","cooker_epoch","ChairRed_EPOCH","Filing_epoch","Pelican_EPOCH","Table_EPOCH","Locker_EPOCH","ToolRack_EPOCH","Shoebox_EPOCH","Tarp_EPOCH","Freezer_EPOCH","Cabinet_EPOCH","KitchenSink_epoch"];
Skipbuildings = ["Land_Mil_Barracks_L","Land_Mil_Guardhouse","Land_Mil_ControlTower_ruins","Land_Mil_ControlTower","Land_Mil_Barracks","Land_Mil_House","Land_SS_hangar","Land_a_stationhouse","Land_Misc_WaterStation","Land_HouseV_3I4","Land_HouseV_3I3","Land_HouseV_3I2","Land_HouseV_3I1","Land_HouseV_2T2","Land_HouseV_2T1","Land_HouseV_2L","Land_HouseV_2I","Land_HouseV_1t","Land_HouseV_1L2"];
ItemArrayCount = count Itemarray;
SkippedBuildings = [];
Item = objNull;
Building = ObjNull;
SelectedItem = 0;
if (isnil 'LootArray') then {LootArray = []};
player allowdamage false;
(findDisplay 12 displayCtrl 51) ctrlAddEventHandler ['MouseButtonDown',{
params ["_displayorcontrol", "_button", "_xPos", "_yPos", "_shift", "_ctrl", "_alt"];
if (_ctrl) then {
params ["","",""];
_pos = (_displayorcontrol posScreenToWorld [_xPos, _yPos]);
vehicle player setPosATL _pos;
};
}];
(findDisplay 12 displayCtrl 51) ctrlAddEventHandler['Draw',{
params ["_control"];
_veh = vehicle player;
_type = typeOf _veh;
_icon = getText(configFile >> 'CfgVehicles' >> _type >> 'icon');
_clr = [0,0,1,1];
_txt = (name player);
_control drawIcon [
_icon,
_clr,
getPosASL _veh,
((1 - ctrlMapScale _control) max .2) * 28,
((1 - ctrlMapScale _control) max .2) * 28,
getdir _veh,
_txt
];
}];
(findDisplay 46) displayAddEventHandler ["KeyDown",
{
params ["_ctrl", "_dikCode", "_shift", "_ctrlKey", "_alt"];
_handled = false;
_stepspeed = if (_ctrlKey) then {0.15} else {0.05};
_dirspeed = if (_ctrlKey) then {1.5} else {0.5};
switch _dikCode do {
case 0x1C: {
if (cursorobject iskindof 'building') then {
Building = cursorobject;
}
else {
Building = nearestbuilding player;
};
if (isClass(missionConfigFile >> "CfgBuildingLootPos" >> (typeof cursorobject)) || (typeof Building) in Skipbuildings) then {
systemchat format ['WARNING !!! %1 is already in LootList!!!',typeof Building];
hint format ['WARNING !!! %1 is already in LootList!!!',typeof Building];
Building = ObjNull;
}
else {
systemchat format ['Selected Building = %1',typeof Building];
hint format ['Selected Building = %1',typeof Building];
};
};
case 0x4B: {
if (!isNull Item) then {
_oldPos = getposasl Item;
_newpos = (getposasl Item) getPos [_stepspeed,(getdir player)-90];
_newpos set [2,_oldPos select 2];
Item setposasl _newpos;
_handled = true;
};
};
case 0x4D: {
if (!isNull Item) then {
_oldPos = getposasl Item;
_newpos = (getposasl Item) getPos [_stepspeed,(getdir player)+90];
_newpos set [2,_oldPos select 2];
Item setposasl _newpos;
_handled = true;
};
};
case 0x48: {
if (!isNull Item) then {
_oldPos = getposasl Item;
_newpos = (getposasl Item) getPos [_stepspeed,(getdir player)];
_newpos set [2,_oldPos select 2];
Item setposasl _newpos;
_handled = true;
};
};
case 0x50: {
if (!isNull Item) then {
_oldPos = getposasl Item;
_newpos = (getposasl Item) getPos [_stepspeed,(getdir player)+180];
_newpos set [2,_oldPos select 2];
Item setposasl _newpos;
_handled = true;
};
};
case 0xC7: {
SelectedItem = ((SelectedItem + 1) min (ItemArrayCount-1)) max 0;
if !(isNull Item) then {
deletevehicle Item;
};
_pos = player modeltoworld [0,5,0];
_selectedClass = Itemarray select SelectedItem;
Item = createVehicle [_selectedClass, _pos, [], 0, "CAN_COLLIDE"];
Item setvectorup [0,0,1];
if (surfaceiswater _pos) then {
Item setposasl _pos;
};
};
case 0xCF: {
SelectedItem = ((SelectedItem - 1) min (ItemArrayCount-1)) max 0;
if !(isNull Item) then {
deletevehicle Item;
};
_pos = player modeltoworld [0,5,0];
_selectedClass = Itemarray select SelectedItem;
Item = createVehicle [_selectedClass, _pos, [], 0, "CAN_COLLIDE"];
Item setvectorup [0,0,1];
if (surfaceiswater _pos) then {
Item setposasl _pos;
};
};
case 0xC9: {
if (!isNull Item) then {
_newpos = getposasl Item;
_newpos set [2,((getposasl Item) select 2)+_stepspeed];
Item setposasl _newpos;
_handled = true;
};
};
case 0xD1: {
if (!isNull Item) then {
_newpos = getposasl Item;
_newpos set [2,((getposasl Item) select 2)-_stepspeed];
Item setposasl _newpos;
_handled = true;
};
};
case 0x47: {
if (!isNull Item) then {
_dir = getdir Item;
_newdir = _dir - _dirspeed;
Item setdir _newdir;
_handled = true;
};
};
case 0x49: {
if (!isNull Item) then {
_dir = getdir Item;
_newdir = _dir + _dirspeed;
Item setdir _newdir;
_handled = true;
};
};
case 0x39: {
if (!isNull Item && !isnull Building) then {
if !(Building distance Item > 80) then {
_c = 0;
_found = false;
{
if (typeof Building == (_x select 0)) exitwith {_found = true;};
_c = _c+1;
} foreach Lootarray;
if (_found) then {
_Buildingarray = Lootarray select _c;
_allitemsarray = _Buildingarray select 1;
_d = 0;
_found2 = false;
{
if (typeof Item == (_x select 0)) exitwith {_found2 = true};
_d = _d+1;
} foreach _allitemsarray;
if (_found2) then {
_Itemarray = _allitemsarray select _d;
_Itemsposarray = _Itemarray select 1;
_Itemsposarray pushback [Building worldToModel (getposatl Item),getdir Item - getdir Building];
}
else {
_allitemsarray pushback [typeof Item,[[Building worldToModel (getposatl Item),getdir Item - getdir Building]]];
};
}
else {
Lootarray pushback [typeof Building, [[typeof Item,[[Building worldToModel (getposatl Item),getdir Item - getdir Building]]]]];
_idx = LootMarkers find (typeof Building);
if (_idx > -1) then {
LootMarkers deleteat _idx;
LootMarkersPositions deleteat _idx;
publicvariable "LootMarkersPositions";
publicvariable "LootMarkers";
};
deleteMarker (typeof Building);
};
systemchat format ['saved %1 position to %2',typeof Item, typeof Building];
hint format ['saved %1 position to %2',typeof Item, typeof Building];
{diag_log str (lootarray select _foreachindex)}foreach lootarray;
publicvariable 'lootarray';
Item = ObjNull;
}
else {
systemchat format ['WARNING, the Item is to far away from the Building! - not safed!'];
hint format ['WARNING, the Item is to far away from the Building! - not saved!'];
};
_handled = true;
}
else {
if (isnull Building) exitwith {
systemchat format ['Select a Building first!'];
hint format ['Select a Building first!'];
};
if (isnull Item) exitwith {
systemchat format ['Place a Loot-Item first!'];
hint format ['Place a Loot-Item first!'];
};
};
};
case 1: {
if (!isNull Item) then {
deletevehicle Item;
Item = ObjNull;
_handled = true;
};
};
case 0x57: {
if (count LootMarkersPositions > 0) then {
_idx = round (random ((count LootMarkersPositions)-1));
systemchat format ["Index = %1",_idx];
player setpos (LootMarkersPositions select _idx);
Building = nearestObject [player, LootMarkers select _idx];
systemchat format ['Selected Building = %1',typeof Building];
hint format ['Selected Building = %1',typeof Building];
}
else {
hint "No more positions found!";
};
};
case 0x43: {
if (isnull Building) exitwith {
hint "No Building selected to remove from List";
};
if (Building distance2D player > 20) exitwith {
hint "Building too far away to remove from List";
};
_idx = LootMarkers find (typeof Building);
if (_idx > -1) then {
LootMarkers deleteat _idx;
LootMarkersPositions deleteat _idx;
publicvariable "LootMarkersPositions";
publicvariable "LootMarkers";
};
deleteMarker (typeof Building);
SkippedBuildings pushback (typeof Building);
publicvariable "SkippedBuildings";
Building = objnull;
hint "Building removed from list without defining lootpositions";
};
case 0x06: {
_plr = vehicle player;
_dir = getdir _plr;
_dist = 10;
if (surfaceIsWater position _plr) then {
_pos = getPosASL _plr;
_pos = [(_pos select 0)+_dist*sin(_dir),(_pos select 1)+_dist*cos(_dir),(_pos select 2)];
_plr setPosASL _pos;
}
else {
_pos = getPosATL _plr;
_pos = [(_pos select 0)+_dist*sin(_dir),(_pos select 1)+_dist*cos(_dir),(_pos select 2)];
_plr setPosATL _pos;
};
player setdamage 0;
};
case 0x05: {
player allowdamage false;
_vel = velocity player;
player setVelocity [(_vel select 0),(_vel select 1),8];
player setdamage 0;
};
};
_handled
}
];

View File

@ -0,0 +1,58 @@
_string = "";
{
_x params ["_BuildingType","_LootArray"];
if (_foreachindex > 0) then {
_string = _string + "
";
};
_string = _string + "class " + _BuildingType + " : Default
{";
{
_x params ["_loottype","_positionsarray"];
_postype = switch _loottype do {
case "Bunk_EPOCH": {"bedPos"};
case "Shelf_EPOCH": {"shelfPos"};
case "Fridge_EPOCH": {"fridgePos"};
case "Bed_EPOCH": {"bedPos"};
case "Couch_EPOCH": {"couchPos"};
case "wardrobe_epoch": {"wardrobePos"};
case "cooker_epoch": {"cookerPos"};
case "Chair_EPOCH": {"chairPos"};
case "ChairRed_EPOCH": {"chairPos"};
case "Filing_EPOCH": {"filingPos"};
case "Pelican_EPOCH": {"pelicanPos"};
case "Table_EPOCH": {"tablePos"};
case "locker_epoch": {"lockerPos"};
case "ToolRack_EPOCH": {"toolRackPos"};
case "Shoebox_EPOCH": {"shoeboxPos"};
case "Tarp_EPOCH": {"palletPos"};
case "Freezer_EPOCH": {"freezerPos"};
case "Cabinet_EPOCH": {"cabinetPos"};
case "toilet_epoch": {"toiletPos"};
case "KitchenSink_epoch": {"kitchenSinkPos"};
default {systemchat _loottype};
};
_string = _string + "
" + " " + _postype + "[] = {";
{
_x params ["_pos","_dir"];
if (_foreachindex > 0) then {
_string = _string + ",";
};
_string = _string + "{{";
_string = _string + str (_pos select 0);
_string = _string + ",";
_string = _string + str (_pos select 1);
_string = _string + ",";
_string = _string + str (_pos select 2);
_string = _string + "},";
_string = _string + str _dir;
_string = _string + "}";
} foreach _positionsarray;
_string = _string + "};";
} foreach _LootArray;
_string = _string + "
};";
} foreach Lootarray;
LootarrayStr = _string;
copytoclipboard LootarrayStr;