raymix Posted June 2, 2014 Report Share Posted June 2, 2014 Download Snap: GitHub Quick Update 2 (July 4th) - Full support for water, code optimization, all known bugs fixed, menus and snapping fully functional as intended. Quick Update (July 4th) - Support for water added. Quick Update (July 2nd) - Download the code from GitHub, Safe to use snap building on live servers. Any suggestions, bug reports or fixes are welcome. I couldn't come up with better name for mod, so yeah, there's that. A small tutorial tip will pop up first time client builds something, it is disabled afterwards, so runs only once per log in, however if you still want to disable it, add this somewhere in your init.sqf: Update #3 (July 1st) - Snap Build and code walk-trough Here's snap building in action. Probably unusual video, but damn I wish someone else did something like this when I started on coding, would have saved me days of headache! Code is now changed quite a bit, however video still explains bits and peaces of how and why it works. Update #2 (June 17) - Extended build Today's showcase - integrating extension to player_build that lets you press F and drop a preview object which lets players to freely move around and adjust height/rotation without being limited by sight. This will potentially be a huge help for people running first person-only servers. Next update will be showcasing snap building, please refer to video on theory behind it. This type of snap building will allow server mods to create their own snap points easily on any object they want, even house models. (The rotation bug shown at the end of video has been fixed) Update #1 (June 02) - Object export (all broken LODs in video are fixed now) Hey guys, finished exporting more models today, decided to shoot a quick preview video for you to enjoy. Basically, objects you see in video will have either cosmetic or actual functionality to it. TODO list is quite big, so this project will take a while and won't be released together with 1.0.5 patch (as I am too late anyway). This is not really bad news, it just means I have more time to finish what I have in mind: Current state: DZEi is developed as @mod atm, that uses similar file structure that epoch uses. Integrating into @epoch when finished should be super simple. Few ideas: Craftable ceiling lamps (object in game already) that will have attachable colored bulbs that players can change. Will probably require generator nearby. Wall Trophy - will contain a memory point that will allow to attach weapon model to it (not weapohholder, just a non-lootable 3D item). Still have to figure this out wether it's possible to spawn them in as vehicles or not. Worst case scenario - only certain few weapon models will be used. Chair - ability to sit on chair. More non-craftable chairs and color variations will be added. Lootable interior objects - these will be found around in world and will have color variations. (refer to emerald interior) Spray paint - to paint your own helipad. Snap building - These objects will snap to each other and to Epoch wooden walls/floors only. No plans to add snapping to cinder or metal as they have different dimensions and will cause problems. Any ideas are welcome. Don't go too crazy tho, be realistic, lol. Most of objects also has their own wreck models (altho you can't see them in video, since they are not added to allowed building wrecks). All of objects has ghost preview, but alpha is broken for whatever reason, but these things happen when exporting in bulk without testing. ruubje11, lmapper, hogscraper and 2 others 5 Link to comment Share on other sites More sharing options...
Kenturrac Posted June 2, 2014 Report Share Posted June 2, 2014 That looks really really cool, but I am really concered about the performance impact to the server. Besides AI, object count seems to be the second most appearing reason for bad performance. Anyway, cool idea if I ignore performance! :D Link to comment Share on other sites More sharing options...
raymix Posted June 2, 2014 Author Report Share Posted June 2, 2014 That's true. Polycount wise these objects have similar size to epoch wooden walls, so technically it wouldn't make difference which object is added. To keep database clean, admins should be running object decay. All of these objects shown also has multiple resolution LODs (2-4 depends on complexity or size) with seperate textures, they were designed with performance in mind, geometry, view/fire geometry and shadow lods are very basic. One of ways to fight amount of objects spawned is simply increasing their crafting costs, I guess. For interior objects - reducing armor, where a simple grenade could take out the whole room. Link to comment Share on other sites More sharing options...
PetuniaEpoch Posted June 8, 2014 Report Share Posted June 8, 2014 Hey Raymix! VERY very cool! Love it! Keep up the good work man, this is looking awesome! raymix 1 Link to comment Share on other sites More sharing options...
raymix Posted June 8, 2014 Author Report Share Posted June 8, 2014 Thanks, mate. All of the bugs in video has been fixed as of yesterday, currently helping my mate setting up overpoch server and will continue with scripts on this There will be new video showing actual building soon PetuniaEpoch 1 Link to comment Share on other sites More sharing options...
PetuniaEpoch Posted June 8, 2014 Report Share Posted June 8, 2014 Cool! Need any help with testing etc, just say the word :D Thanks, mate. All of the bugs in video has been fixed as of yesterday, currently helping my mate setting up overpoch server and will continue with scripts on this There will be new video showing actual building soon raymix 1 Link to comment Share on other sites More sharing options...
raymix Posted June 12, 2014 Author Report Share Posted June 12, 2014 Small update to keep this forum alive, i guess. Generating some snap points otherwise building these without it would be a nightmare, lol. Problem is - few hours after taking this picture, I only now realize how limited current snap building is - you can only snap objects to themselves or similar structured ones, pretty much forced to redesign it to fit this style of building. Huge thanks to Awol for this awesome tool provided with source, although I ended up tweaking it a bit to work with MP, hope he won't mind (just the addaction part) :ph34r: Creep 1 Link to comment Share on other sites More sharing options...
STENCHOVDETH Posted June 12, 2014 Report Share Posted June 12, 2014 Very nice raymix! Very nice indeed :) Link to comment Share on other sites More sharing options...
Kimzer Posted June 17, 2014 Report Share Posted June 17, 2014 Any news on this? Link to comment Share on other sites More sharing options...
raymix Posted June 17, 2014 Author Report Share Posted June 17, 2014 Any news on this? Yes there will be video later today showcasing extended build system I am working on right now. It will also explain theory on new snap building and how it will work with ghost preview models. I think you guys gonna love it. Link to comment Share on other sites More sharing options...
raymix Posted June 17, 2014 Author Report Share Posted June 17, 2014 New video is up! Check out the first post for details. Link to comment Share on other sites More sharing options...
STENCHOVDETH Posted June 17, 2014 Report Share Posted June 17, 2014 WOW raymix! just watched preview#2 :) this should be well worth the wait,keep up the good work. STENCH raymix 1 Link to comment Share on other sites More sharing options...
calamity Posted June 17, 2014 Report Share Posted June 17, 2014 is very expert. Link to comment Share on other sites More sharing options...
TheVampire Posted June 17, 2014 Report Share Posted June 17, 2014 That new way of using the Epoch building system is a very cool idea, especially for solo players to be able to detach and eyeball their work before placing it. Link to comment Share on other sites More sharing options...
fr1nk Posted June 17, 2014 Report Share Posted June 17, 2014 Lookin good raymix :) Link to comment Share on other sites More sharing options...
raymix Posted June 17, 2014 Author Report Share Posted June 17, 2014 WOW raymix! just watched preview#2 :) this should be well worth the wait,keep up the good work. STENCH is very expert. That new way of using the Epoch building system is a very cool idea, especially for solo players to be able to detach and eyeball their work before placing it. Lookin good raymix :) Thanks, guys. Good to see you approve this, helps with decisions on project. Link to comment Share on other sites More sharing options...
raymix Posted June 18, 2014 Author Report Share Posted June 18, 2014 Got permission to share the code. Please keep in mind there will be no support for this code as it is only posted for experimental or educational reasons (that includes me - let me know if you spot something you think shouldn't be there or suggest an improvement). This is not a release, so only for experienced people only, do not ask how to install it... You will need custom compiles for this: compiles.sqf dayz_spaceInterrupt = compile preprocessFileLineNumbers "dayz_spaceInterrupt.sqf"; if (!isDedicated) then { player_build = compile preprocessFileLineNumbers "player_build.sqf"; }; dayz_spaceInterrupt.sqf (to enable F key, remap as you please, look at DIK_Codes): private ["_dikCode","_handled","_primaryWeapon","_secondaryWeapon","_nearbyObjects","_nill","_shift","_ctrl","_alt","_dropPrimary","_dropSecondary","_iItem","_removed","_iPos","_radius","_item"]; _dikCode = _this select 1; _handled = false; if (_dikCode in[0x02,0x03,0x04,0x58,0x57,0x44,0x43,0x42,0x41,0x40,0x3F,0x3E,0x3D,0x3C,0x3B,0x0B,0x0A,0x09,0x08,0x07,0x06,0x05]) then { _handled = true; }; if ((_dikCode == 0x3E or _dikCode == 0x0F or _dikCode == 0xD3)) then { if(diag_tickTime - dayz_lastCheckBit > 10) then { dayz_lastCheckBit = diag_tickTime; call dayz_forceSave; }; call dayz_EjectPlayer; }; // esc if (_dikCode == 0x01) then { DZE_cancelBuilding = true; call dayz_EjectPlayer; }; // surrender if (_dikCode in actionKeys "Surrender") then { _vehicle = vehicle player; _inVehicle = (_vehicle != player); _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; _canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder and !_inVehicle); if (_canDo and !DZE_Surrender and !(player isKindOf "PZombie_VB")) then { DZE_Surrender = true; _dropPrimary = false; _dropSecondary = false; _primaryWeapon = primaryWeapon player; if (_primaryWeapon != "") then {_dropPrimary = true;}; _secondaryWeapon = ""; { if ((getNumber (configFile >> "CfgWeapons" >> _x >> "Type")) == 2) exitWith { _secondaryWeapon = _x; }; } forEach (weapons player); if (_secondaryWeapon != "") then {_dropSecondary = true;}; if (_dropPrimary or _dropSecondary) then { player playActionNow "PutDown"; _iPos = getPosATL player; _radius = 1; _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; _item setposATL _iPos; if (_dropPrimary) then { _iItem = _primaryWeapon; _removed = ([player,_iItem,1] call BIS_fnc_invRemove); if (_removed == 1) then { _item addWeaponCargoGlobal [_iItem,1]; }; }; if (_dropSecondary) then { _iItem = _secondaryWeapon; _removed = ([player,_iItem,1] call BIS_fnc_invRemove); if (_removed == 1) then { _item addWeaponCargoGlobal [_iItem,1]; }; }; player reveal _item; }; // set publicvariable that allows other player to access gear player setVariable ["DZE_Surrendered", true, true]; // surrender animation player playMove "AmovPercMstpSsurWnonDnon"; }; _handled = true; }; if (_dikCode in actionKeys "MoveForward") exitWith {r_interrupt = true; if (DZE_Surrender) then {call dze_surrender_off};}; if (_dikCode in actionKeys "MoveLeft") exitWith {r_interrupt = true; if (DZE_Surrender) then {call dze_surrender_off};}; if (_dikCode in actionKeys "MoveRight") exitWith {r_interrupt = true; if (DZE_Surrender) then {call dze_surrender_off};}; if (_dikCode in actionKeys "MoveBack") exitWith {r_interrupt = true; if (DZE_Surrender) then {call dze_surrender_off};}; //Prevent exploit of drag body if ((_dikCode in actionKeys "Prone") and r_drag_sqf) exitWith { force_dropBody = true; }; if ((_dikCode in actionKeys "Crouch") and r_drag_sqf) exitWith { force_dropBody = true; }; _shift = _this select 2; _ctrl = _this select 3; _alt = _this select 4; //diag_log format["Keypress: %1", _this]; if ((_dikCode in actionKeys "Gear") and (vehicle player != player) and !_shift and !_ctrl and !_alt && !dialog) then { createGearDialog [player, "RscDisplayGear"]; _handled = true; }; if (_dikCode in (actionKeys "GetOver")) then { if (player isKindOf "PZombie_VB") then { _handled = true; DZE_PZATTACK = true; } else { _nearbyObjects = nearestObjects[getPosATL player, dayz_disallowedVault, 8]; if (count _nearbyObjects > 0) then { if((diag_tickTime - dayz_lastCheckBit > 4)) then { [objNull, player, rSwitchMove,"GetOver"] call RE; player playActionNow "GetOver"; dayz_lastCheckBit = diag_tickTime; } else { _handled = true; }; }; }; }; //if (_dikCode == 57) then {_handled = true}; // space //if (_dikCode in actionKeys 'MoveForward' or _dikCode in actionKeys 'MoveBack') then {r_interrupt = true}; if (_dikCode == 210) then { _nill = execvm "\z\addons\dayz_code\actions\playerstats.sqf"; }; if (_dikCode in actionKeys "ForceCommandingMode") then {_handled = true}; if (_dikCode in actionKeys "PushToTalk" and (diag_tickTime - dayz_lastCheckBit > 10)) then { dayz_lastCheckBit = diag_tickTime; [player,50,true,(getPosATL player)] spawn player_alertZombies; }; if (_dikCode in actionKeys "VoiceOverNet" and (diag_tickTime - dayz_lastCheckBit > 10)) then { dayz_lastCheckBit = diag_tickTime; [player,50,true,(getPosATL player)] spawn player_alertZombies; }; if (_dikCode in actionKeys "PushToTalkDirect" and (diag_tickTime - dayz_lastCheckBit > 10)) then { dayz_lastCheckBit = diag_tickTime; [player,15,false,(getPosATL player)] spawn player_alertZombies; }; if (_dikCode in actionKeys "Chat" and (diag_tickTime - dayz_lastCheckBit > 10)) then { dayz_lastCheckBit = diag_tickTime; [player,15,false,(getPosATL player)] spawn player_alertZombies; }; if (_dikCode in actionKeys "User20" and (diag_tickTime - dayz_lastCheckBit > 5)) then { dayz_lastCheckBit = diag_tickTime; _nill = execvm "\z\addons\dayz_code\actions\playerstats.sqf"; }; // numpad 8 0x48 now pgup 0xC9 1 if ((_dikCode == 0xC9 and (!_alt or !_ctrl)) or (_dikCode in actionKeys "User15")) then { DZE_Q = true; }; // numpad 2 0x50 now pgdn 0xD1 if ((_dikCode == 0xD1 and (!_alt or !_ctrl)) or (_dikCode in actionKeys "User16")) then { DZE_Z = true; }; // numpad 8 0x48 now pgup 0xC9 0.1 if ((_dikCode == 0xC9 and (_alt and !_ctrl)) or (_dikCode in actionKeys "User13")) then { DZE_Q_alt = true; }; // numpad 2 0x50 now pgdn 0xD1 if ((_dikCode == 0xD1 and (_alt and !_ctrl)) or (_dikCode in actionKeys "User14")) then { DZE_Z_alt = true; }; // numpad 8 0x48 now pgup 0xC9 0.01 if ((_dikCode == 0xC9 and (!_alt and _ctrl)) or (_dikCode in actionKeys "User7")) then { DZE_Q_ctrl = true; }; // numpad 2 0x50 now pgdn 0xD1 if ((_dikCode == 0xD1 and (!_alt and _ctrl)) or (_dikCode in actionKeys "User8")) then { DZE_Z_ctrl = true; }; // numpad 4 0x4B now Q 0x10 if (_dikCode == 0x10 or (_dikCode in actionKeys "User17")) then { DZE_4 = true; }; // numpad 6 0x4D now E 0x12 if (_dikCode == 0x12 or (_dikCode in actionKeys "User18")) then { DZE_6 = true; }; // numpad 5 0x4C now space 0x39 if (_dikCode == 0x39 or (_dikCode in actionKeys "User19")) then { DZE_5 = true; }; // F key if ((_dikCode == 0x21 and (!_alt and !_ctrl)) or (_dikCode in actionKeys "User6")) then { DZE_F = true; }; _handled player_build.sqf /* DayZ Base Building Made for DayZ Epoch please ask permission to use/edit/distrubute email [email protected]. Modified by Raymix. Experimental, please be careful if using on live servers Shared for code and experiments only, there will be no support regarding errors on this */ private ["_objectHelper","_helperColor","_helperDetach","_objectHelperDir","_objectHelperPos","_canDo", "_location","_dir","_classname","_item","_hasrequireditem","_missing","_hastoolweapon","_cancel","_reason","_started","_finished","_animState","_isMedic","_dis","_sfx","_hasbuilditem","_tmpbuilt","_onLadder","_isWater","_require","_text","_offset","_IsNearPlot","_isOk","_location1","_location2","_counter","_limit","_proceed","_num_removed","_position","_object","_canBuildOnPlot","_friendlies","_nearestPole","_ownerID","_findNearestPoles","_findNearestPole","_distance","_classnametmp","_ghost","_isPole","_needText","_lockable","_zheightchanged","_rotate","_combination_1","_combination_2","_combination_3","_combination_4","_combination","_combination_1_Display","_combinationDisplay","_zheightdirection","_abort","_isNear","_need","_objHupDiff","_needNear","_vehicle","_inVehicle","_requireplot","_objHDiff","_isLandFireDZ","_isTankTrap"]; if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_40") , "PLAIN DOWN"]; }; DZE_ActionInProgress = true; // disallow building if too many objects are found within 30m if((count ((getPosATL player) nearObjects ["All",30])) >= DZE_BuildingLimit) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_41"), "PLAIN DOWN"];}; _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; _isWater = dayz_isSwimming; _cancel = false; _reason = ""; _canBuildOnPlot = false; _vehicle = vehicle player; _inVehicle = (_vehicle != player); //snap _helperDetach = false; _canDo = (!r_drag_sqf and !r_player_unconscious); //snapToggle = "OFF"; //snapToggleSwitch = true; DZE_Q = false; DZE_Z = false; DZE_Q_alt = false; DZE_Z_alt = false; DZE_Q_ctrl = false; DZE_Z_ctrl = false; DZE_5 = false; DZE_4 = false; DZE_6 = false; DZE_F = false; DZE_cancelBuilding = false; call gear_ui_init; closeDialog 1; if (_isWater) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_26", "PLAIN DOWN"];}; if (_inVehicle) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_42"), "PLAIN DOWN"];}; if (_onLadder) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_21", "PLAIN DOWN"];}; if (player getVariable["combattimeout", 0] >= time) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_43"), "PLAIN DOWN"];}; _item = _this; // Need Near Requirements _abort = false; _distance = 3; _reason = ""; _needNear = getArray (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "neednearby"); { switch(_x) do{ case "fire": { _isNear = {inflamed _x} count (getPosATL player nearObjects _distance); if(_isNear == 0) then { _abort = true; _reason = "fire"; }; }; case "workshop": { _isNear = count (nearestObjects [player, ["Wooden_shed_DZ","WoodShack_DZ","WorkBench_DZ"], _distance]); if(_isNear == 0) then { _abort = true; _reason = "workshop"; }; }; case "fueltank": { _isNear = count (nearestObjects [player, dayz_fuelsources, _distance]); if(_isNear == 0) then { _abort = true; _reason = "fuel tank"; _distance = 30; }; }; }; } forEach _needNear; if(_abort) exitWith { cutText [format[(localize "str_epoch_player_135"),_reason,_distance], "PLAIN DOWN"]; DZE_ActionInProgress = false; }; _classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create"); _classnametmp = _classname; _require = getArray (configFile >> "cfgMagazines" >> _this >> "ItemActions" >> "Build" >> "require"); _text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName"); _ghost = getText (configFile >> "CfgVehicles" >> _classname >> "ghostpreview"); _lockable = 0; if(isNumber (configFile >> "CfgVehicles" >> _classname >> "lockable")) then { _lockable = getNumber(configFile >> "CfgVehicles" >> _classname >> "lockable"); }; _requireplot = DZE_requireplot; if(isNumber (configFile >> "CfgVehicles" >> _classname >> "requireplot")) then { _requireplot = getNumber(configFile >> "CfgVehicles" >> _classname >> "requireplot"); }; _isAllowedUnderGround = 1; if(isNumber (configFile >> "CfgVehicles" >> _classname >> "nounderground")) then { _isAllowedUnderGround = getNumber(configFile >> "CfgVehicles" >> _classname >> "nounderground"); }; _offset = getArray (configFile >> "CfgVehicles" >> _classname >> "offset"); if((count _offset) <= 0) then { _offset = [0,1.5,0]; }; _isPole = (_classname == "Plastic_Pole_EP1_DZ"); _isLandFireDZ = (_classname == "Land_Fire_DZ"); _distance = DZE_PlotPole select 0; _needText = localize "str_epoch_player_246"; if(_isPole) then { _distance = DZE_PlotPole select 1; }; // check for near plot _findNearestPoles = nearestObjects [(vehicle player), ["Plastic_Pole_EP1_DZ"], _distance]; _findNearestPole = []; { if (alive _x) then { _findNearestPole set [(count _findNearestPole),_x]; }; } foreach _findNearestPoles; _IsNearPlot = count (_findNearestPole); // If item is plot pole and another one exists within 45m if(_isPole and _IsNearPlot > 0) exitWith { DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_44") , "PLAIN DOWN"]; }; if(_IsNearPlot == 0) then { // Allow building of plot if(_requireplot == 0 or _isLandFireDZ) then { _canBuildOnPlot = true; }; } else { // Since there are plots nearby we check for ownership and then for friend status // check nearby plots ownership and then for friend status _nearestPole = _findNearestPole select 0; // Find owner _ownerID = _nearestPole getVariable["CharacterID","0"]; // diag_log format["DEBUG BUILDING: %1 = %2", dayz_characterID, _ownerID]; // check if friendly to owner if(dayz_characterID == _ownerID) then { //Keep ownership // owner can build anything within his plot except other plots if(!_isPole) then { _canBuildOnPlot = true; }; } else { // disallow building plot if(!_isPole) then { _friendlies = player getVariable ["friendlyTo",[]]; // check if friendly to owner if(_ownerID in _friendlies) then { _canBuildOnPlot = true; }; }; }; }; // _message if(!_canBuildOnPlot) exitWith { DZE_ActionInProgress = false; cutText [format[(localize "STR_EPOCH_PLAYER_135"),_needText,_distance] , "PLAIN DOWN"]; }; _missing = ""; _hasrequireditem = true; { _hastoolweapon = _x in weapons player; if(!_hastoolweapon) exitWith { _hasrequireditem = false; _missing = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); } } forEach _require; _hasbuilditem = _this in magazines player; if (!_hasbuilditem) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_player_31"),_text,"build"] , "PLAIN DOWN"]; }; if (!_hasrequireditem) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_epoch_player_137"),_missing] , "PLAIN DOWN"]; }; if (_hasrequireditem) then { _location = [0,0,0]; _isOk = true; // get inital players position _location1 = getPosATL player; _dir = getDir player; // if ghost preview available use that instead if (_ghost != "") then { _classname = _ghost; }; _object = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"]; //Build gizmo _objectHelper = createVehicle ["Sign_sphere10cm_EP1", _location, [], 0, "CAN_COLLIDE"]; _helperColor = "#(argb,8,8,3)color(0.38,0.93,0.93,0,ca)"; _objectHelper setobjecttexture [0,_helperColor]; _objectHelper attachTo [player,_offset]; _object attachTo [_objectHelper,[0,0,0]]; _position = getPosATL _objectHelper; cutText [(localize "str_epoch_player_45"), "PLAIN DOWN"]; _objHDiff = 0; while {_isOk} do { _zheightchanged = false; _zheightdirection = ""; _rotate = false; if (DZE_Q) then { DZE_Q = false; _zheightdirection = "up"; _zheightchanged = true; }; if (DZE_Z) then { DZE_Z = false; _zheightdirection = "down"; _zheightchanged = true; }; if (DZE_Q_alt) then { DZE_Q_alt = false; _zheightdirection = "up_alt"; _zheightchanged = true; }; if (DZE_Z_alt) then { DZE_Z_alt = false; _zheightdirection = "down_alt"; _zheightchanged = true; }; if (DZE_Q_ctrl) then { DZE_Q_ctrl = false; _zheightdirection = "up_ctrl"; _zheightchanged = true; }; if (DZE_Z_ctrl) then { DZE_Z_ctrl = false; _zheightdirection = "down_ctrl"; _zheightchanged = true; }; if (DZE_4) then { _rotate = true; DZE_4 = false; if (_helperDetach) then { _dir = -45; } else { _dir = 180; }; }; if (DZE_6) then { _rotate = true; DZE_6 = false; if (_helperDetach) then { _dir = 45; } else { _dir = 0; }; }; if (DZE_F and _canDo) then { if (_helperDetach) then { _objectHelperDir = getDir _objectHelper; _objectHelper attachTo [player]; _objectHelper setDir _objectHelperDir-(getDir player); _helperDetach = false; } else { _objectHelperPos = getPosATL _objectHelper; detach _objectHelper; _objectHelper setPosATL _objectHelperPos; _objectHelperDir = getDir _objectHelper; _objectHelper setVelocity [0,0,0]; //fix sliding glitch _helperDetach = true; }; DZE_F = false; }; if(_rotate) then { if (!_helperDetach) then { _objectHelper setDir _dir; _objectHelper setPosATL _position; //diag_log format["DEBUG Rotate BUILDING POS: %1", _position]; }else{ _objectHelperDir = getDir _objectHelper; _objectHelperPos = getPosATL _objectHelper; _objectHelper setDir _objectHelperDir+_dir; _objectHelper setPosATL _objectHelperPos; }; }; if(_zheightchanged) then { if (!_helperDetach) then { detach _objectHelper; }; _position = getPosATL _objectHelper; if(_zheightdirection == "up") then { _position set [2,((_position select 2)+0.1)]; _objHDiff = _objHDiff + 0.1; }; if(_zheightdirection == "down") then { _position set [2,((_position select 2)-0.1)]; _objHDiff = _objHDiff - 0.1; }; if(_zheightdirection == "up_alt") then { _position set [2,((_position select 2)+1)]; _objHupDiff = _objHupDiff + 1; }; if(_zheightdirection == "down_alt") then { _position set [2,((_position select 2)-1)]; _objHDiff = _objHDiff - 1; }; if(_zheightdirection == "up_ctrl") then { _position set [2,((_position select 2)+0.01)]; _objHupDiff = _objHupDiff + 0.01; }; if(_zheightdirection == "down_ctrl") then { _position set [2,((_position select 2)-0.01)]; _objHDiff = _objHDiff - 0.01; }; _objectHelper setDir (getDir _objectHelper); if((_isAllowedUnderGround == 0) and ((_position select 2) < 0)) then { _position set [2,0]; }; _objectHelper setPosATL _position; //diag_log format["DEBUG Change BUILDING POS: %1", _position]; if (!_helperDetach) then { _objectHelper attachTo [player]; }; }; sleep 0.5; _location2 = getPosATL player; if(DZE_5) exitWith { _isOk = false; detach _object; _dir = getDir _object; _position = getPosATL _object; //diag_log format["DEBUG BUILDING POS: %1", _position]; deleteVehicle _object; detach _objectHelper; deleteVehicle _objectHelper; }; if(_location1 distance _location2 > 10) exitWith { _isOk = false; _cancel = true; _reason = "You've moved to far away from where you started building (within 10 meters)"; detach _object; deleteVehicle _object; detach _objectHelper; deleteVehicle _objectHelper; }; if(abs(_objHDiff) > 5) exitWith { _isOk = false; _cancel = true; _reason = "Cannot move up or down more than 5 meters"; detach _object; deleteVehicle _object; detach _objectHelper; deleteVehicle _objectHelper; }; if (player getVariable["combattimeout", 0] >= time) exitWith { _isOk = false; _cancel = true; _reason = (localize "str_epoch_player_43"); detach _object; deleteVehicle _object; detach _objectHelper; deleteVehicle _objectHelper; }; if (DZE_cancelBuilding) exitWith { _isOk = false; _cancel = true; _reason = "Cancelled building."; detach _object; deleteVehicle _object; detach _objectHelper; deleteVehicle _objectHelper; }; /* // DO NOT ENABLE THIS if (isClass (missionConfigFile >> "SnapBuilding" >> _classname) and snapToggleSwitch) then { s_player_toggleSnap = player addaction [format[("<t color=""#ffffff"">" + ("Snap: %1") +"</t>"),snapToggle],"snap_build.sqf",[_object,_classname],6,true,true]; snapToggleSwitch = false; }; */ }; //No building on roads unless toggled if (!DZE_BuildOnRoads) then { if (isOnRoad _position) then { _cancel = true; _reason = "Cannot build on a road."; }; }; // No building in trader zones if(!canbuild) then { _cancel = true; _reason = "Cannot build in a city."; }; if(!_cancel) then { _classname = _classnametmp; // Start Build _tmpbuilt = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"]; _tmpbuilt setdir _dir; // Get position based on object _location = _position; if((_isAllowedUnderGround == 0) and ((_location select 2) < 0)) then { _location set [2,0]; }; _tmpbuilt setPosATL _location; cutText [format[(localize "str_epoch_player_138"),_text], "PLAIN DOWN"]; _limit = 3; if (DZE_StaticConstructionCount > 0) then { _limit = DZE_StaticConstructionCount; } else { if (isNumber (configFile >> "CfgVehicles" >> _classname >> "constructioncount")) then { _limit = getNumber(configFile >> "CfgVehicles" >> _classname >> "constructioncount"); }; }; _isOk = true; _proceed = false; _counter = 0; while {_isOk} do { [10,10] call dayz_HungerThirst; player playActionNow "Medic"; _dis=20; _sfx = "repair"; [player,_sfx,0,false,_dis] call dayz_zombieSpeak; [player,_dis,true,(getPosATL player)] spawn player_alertZombies; r_interrupt = false; _animState = animationState player; r_doLoop = true; _started = false; _finished = false; while {r_doLoop} do { _animState = animationState player; _isMedic = ["medic",_animState] call fnc_inString; if (_isMedic) then { _started = true; }; if (_started and !_isMedic) then { r_doLoop = false; _finished = true; }; if (r_interrupt or (player getVariable["combattimeout", 0] >= time)) then { r_doLoop = false; }; if (DZE_cancelBuilding) exitWith { r_doLoop = false; }; sleep 0.1; }; r_doLoop = false; if(!_finished) exitWith { _isOk = false; _proceed = false; }; if(_finished) then { _counter = _counter + 1; }; cutText [format[(localize "str_epoch_player_139"),_text, _counter,_limit], "PLAIN DOWN"]; if(_counter == _limit) exitWith { _isOk = false; _proceed = true; }; }; if (_proceed) then { _num_removed = ([player,_item] call BIS_fnc_invRemove); if(_num_removed == 1) then { cutText [format[localize "str_build_01",_text], "PLAIN DOWN"]; if (_isPole) then { [] spawn player_plotPreview; }; _tmpbuilt setVariable ["OEMPos",_location,true]; if(_lockable > 1) then { _combinationDisplay = ""; switch (_lockable) do { case 2: { // 2 lockbox _combination_1 = (floor(random 3)) + 100; // 100=red,101=green,102=blue _combination_2 = floor(random 10); _combination_3 = floor(random 10); _combination = format["%1%2%3",_combination_1,_combination_2,_combination_3]; dayz_combination = _combination; if (_combination_1 == 100) then { _combination_1_Display = "Red"; }; if (_combination_1 == 101) then { _combination_1_Display = "Green"; }; if (_combination_1 == 102) then { _combination_1_Display = "Blue"; }; _combinationDisplay = format["%1%2%3",_combination_1_Display,_combination_2,_combination_3]; }; case 3: { // 3 combolock _combination_1 = floor(random 10); _combination_2 = floor(random 10); _combination_3 = floor(random 10); _combination = format["%1%2%3",_combination_1,_combination_2,_combination_3]; dayz_combination = _combination; _combinationDisplay = _combination; }; case 4: { // 4 safe _combination_1 = floor(random 10); _combination_2 = floor(random 10); _combination_3 = floor(random 10); _combination_4 = floor(random 10); _combination = format["%1%2%3%4",_combination_1,_combination_2,_combination_3,_combination_4]; dayz_combination = _combination; _combinationDisplay = _combination; }; }; _tmpbuilt setVariable ["CharacterID",_combination,true]; PVDZE_obj_Publish = [_combination,_tmpbuilt,[_dir,_location],_classname]; publicVariableServer "PVDZE_obj_Publish"; cutText [format[(localize "str_epoch_player_140"),_combinationDisplay,_text], "PLAIN DOWN", 5]; } else { _tmpbuilt setVariable ["CharacterID",dayz_characterID,true]; // fire? if(_tmpbuilt isKindOf "Land_Fire_DZ") then { _tmpbuilt spawn player_fireMonitor; } else { PVDZE_obj_Publish = [dayz_characterID,_tmpbuilt,[_dir,_location],_classname]; publicVariableServer "PVDZE_obj_Publish"; }; }; } else { deleteVehicle _tmpbuilt; cutText [(localize "str_epoch_player_46") , "PLAIN DOWN"]; }; } else { r_interrupt = false; if (vehicle player == player) then { [objNull, player, rSwitchMove,""] call RE; player playActionNow "stop"; }; deleteVehicle _tmpbuilt; cutText [(localize "str_epoch_player_46") , "PLAIN DOWN"]; }; } else { cutText [format[(localize "str_epoch_player_47"),_text,_reason], "PLAIN DOWN"]; }; }; DZE_ActionInProgress = false; Link to comment Share on other sites More sharing options...
Mystic Joker Posted June 19, 2014 Report Share Posted June 19, 2014 Got permission to share the code. Please keep in mind there will be no support for this code as it is only posted for experimental or educational reasons (that includes me - let me know if you spot something you think shouldn't be there or suggest an improvement). This is not a release, so only for experienced people only, do not ask how to install it... You will need custom compiles for this: compiles.sqf dayz_spaceInterrupt = compile preprocessFileLineNumbers "dayz_spaceInterrupt.sqf"; if (!isDedicated) then { player_build = compile preprocessFileLineNumbers "player_build.sqf"; }; dayz_spaceInterrupt.sqf (to enable F key, remap as you please, look at DIK_Codes): private ["_dikCode","_handled","_primaryWeapon","_secondaryWeapon","_nearbyObjects","_nill","_shift","_ctrl","_alt","_dropPrimary","_dropSecondary","_iItem","_removed","_iPos","_radius","_item"]; _dikCode = _this select 1; _handled = false; if (_dikCode in[0x02,0x03,0x04,0x58,0x57,0x44,0x43,0x42,0x41,0x40,0x3F,0x3E,0x3D,0x3C,0x3B,0x0B,0x0A,0x09,0x08,0x07,0x06,0x05]) then { _handled = true; }; if ((_dikCode == 0x3E or _dikCode == 0x0F or _dikCode == 0xD3)) then { if(diag_tickTime - dayz_lastCheckBit > 10) then { dayz_lastCheckBit = diag_tickTime; call dayz_forceSave; }; call dayz_EjectPlayer; }; // esc if (_dikCode == 0x01) then { DZE_cancelBuilding = true; call dayz_EjectPlayer; }; // surrender if (_dikCode in actionKeys "Surrender") then { _vehicle = vehicle player; _inVehicle = (_vehicle != player); _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; _canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder and !_inVehicle); if (_canDo and !DZE_Surrender and !(player isKindOf "PZombie_VB")) then { DZE_Surrender = true; _dropPrimary = false; _dropSecondary = false; _primaryWeapon = primaryWeapon player; if (_primaryWeapon != "") then {_dropPrimary = true;}; _secondaryWeapon = ""; { if ((getNumber (configFile >> "CfgWeapons" >> _x >> "Type")) == 2) exitWith { _secondaryWeapon = _x; }; } forEach (weapons player); if (_secondaryWeapon != "") then {_dropSecondary = true;}; if (_dropPrimary or _dropSecondary) then { player playActionNow "PutDown"; _iPos = getPosATL player; _radius = 1; _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; _item setposATL _iPos; if (_dropPrimary) then { _iItem = _primaryWeapon; _removed = ([player,_iItem,1] call BIS_fnc_invRemove); if (_removed == 1) then { _item addWeaponCargoGlobal [_iItem,1]; }; }; if (_dropSecondary) then { _iItem = _secondaryWeapon; _removed = ([player,_iItem,1] call BIS_fnc_invRemove); if (_removed == 1) then { _item addWeaponCargoGlobal [_iItem,1]; }; }; player reveal _item; }; // set publicvariable that allows other player to access gear player setVariable ["DZE_Surrendered", true, true]; // surrender animation player playMove "AmovPercMstpSsurWnonDnon"; }; _handled = true; }; if (_dikCode in actionKeys "MoveForward") exitWith {r_interrupt = true; if (DZE_Surrender) then {call dze_surrender_off};}; if (_dikCode in actionKeys "MoveLeft") exitWith {r_interrupt = true; if (DZE_Surrender) then {call dze_surrender_off};}; if (_dikCode in actionKeys "MoveRight") exitWith {r_interrupt = true; if (DZE_Surrender) then {call dze_surrender_off};}; if (_dikCode in actionKeys "MoveBack") exitWith {r_interrupt = true; if (DZE_Surrender) then {call dze_surrender_off};}; //Prevent exploit of drag body if ((_dikCode in actionKeys "Prone") and r_drag_sqf) exitWith { force_dropBody = true; }; if ((_dikCode in actionKeys "Crouch") and r_drag_sqf) exitWith { force_dropBody = true; }; _shift = _this select 2; _ctrl = _this select 3; _alt = _this select 4; //diag_log format["Keypress: %1", _this]; if ((_dikCode in actionKeys "Gear") and (vehicle player != player) and !_shift and !_ctrl and !_alt && !dialog) then { createGearDialog [player, "RscDisplayGear"]; _handled = true; }; if (_dikCode in (actionKeys "GetOver")) then { if (player isKindOf "PZombie_VB") then { _handled = true; DZE_PZATTACK = true; } else { _nearbyObjects = nearestObjects[getPosATL player, dayz_disallowedVault, 8]; if (count _nearbyObjects > 0) then { if((diag_tickTime - dayz_lastCheckBit > 4)) then { [objNull, player, rSwitchMove,"GetOver"] call RE; player playActionNow "GetOver"; dayz_lastCheckBit = diag_tickTime; } else { _handled = true; }; }; }; }; //if (_dikCode == 57) then {_handled = true}; // space //if (_dikCode in actionKeys 'MoveForward' or _dikCode in actionKeys 'MoveBack') then {r_interrupt = true}; if (_dikCode == 210) then { _nill = execvm "\z\addons\dayz_code\actions\playerstats.sqf"; }; if (_dikCode in actionKeys "ForceCommandingMode") then {_handled = true}; if (_dikCode in actionKeys "PushToTalk" and (diag_tickTime - dayz_lastCheckBit > 10)) then { dayz_lastCheckBit = diag_tickTime; [player,50,true,(getPosATL player)] spawn player_alertZombies; }; if (_dikCode in actionKeys "VoiceOverNet" and (diag_tickTime - dayz_lastCheckBit > 10)) then { dayz_lastCheckBit = diag_tickTime; [player,50,true,(getPosATL player)] spawn player_alertZombies; }; if (_dikCode in actionKeys "PushToTalkDirect" and (diag_tickTime - dayz_lastCheckBit > 10)) then { dayz_lastCheckBit = diag_tickTime; [player,15,false,(getPosATL player)] spawn player_alertZombies; }; if (_dikCode in actionKeys "Chat" and (diag_tickTime - dayz_lastCheckBit > 10)) then { dayz_lastCheckBit = diag_tickTime; [player,15,false,(getPosATL player)] spawn player_alertZombies; }; if (_dikCode in actionKeys "User20" and (diag_tickTime - dayz_lastCheckBit > 5)) then { dayz_lastCheckBit = diag_tickTime; _nill = execvm "\z\addons\dayz_code\actions\playerstats.sqf"; }; // numpad 8 0x48 now pgup 0xC9 1 if ((_dikCode == 0xC9 and (!_alt or !_ctrl)) or (_dikCode in actionKeys "User15")) then { DZE_Q = true; }; // numpad 2 0x50 now pgdn 0xD1 if ((_dikCode == 0xD1 and (!_alt or !_ctrl)) or (_dikCode in actionKeys "User16")) then { DZE_Z = true; }; // numpad 8 0x48 now pgup 0xC9 0.1 if ((_dikCode == 0xC9 and (_alt and !_ctrl)) or (_dikCode in actionKeys "User13")) then { DZE_Q_alt = true; }; // numpad 2 0x50 now pgdn 0xD1 if ((_dikCode == 0xD1 and (_alt and !_ctrl)) or (_dikCode in actionKeys "User14")) then { DZE_Z_alt = true; }; // numpad 8 0x48 now pgup 0xC9 0.01 if ((_dikCode == 0xC9 and (!_alt and _ctrl)) or (_dikCode in actionKeys "User7")) then { DZE_Q_ctrl = true; }; // numpad 2 0x50 now pgdn 0xD1 if ((_dikCode == 0xD1 and (!_alt and _ctrl)) or (_dikCode in actionKeys "User8")) then { DZE_Z_ctrl = true; }; // numpad 4 0x4B now Q 0x10 if (_dikCode == 0x10 or (_dikCode in actionKeys "User17")) then { DZE_4 = true; }; // numpad 6 0x4D now E 0x12 if (_dikCode == 0x12 or (_dikCode in actionKeys "User18")) then { DZE_6 = true; }; // numpad 5 0x4C now space 0x39 if (_dikCode == 0x39 or (_dikCode in actionKeys "User19")) then { DZE_5 = true; }; // F key if ((_dikCode == 0x21 and (!_alt and !_ctrl)) or (_dikCode in actionKeys "User6")) then { DZE_F = true; }; _handled player_build.sqf /* DayZ Base Building Made for DayZ Epoch please ask permission to use/edit/distrubute email [email protected]. Modified by Raymix. Experimental, please be careful if using on live servers Shared for code and experiments only, there will be no support regarding errors on this */ private ["_objectHelper","_helperColor","_helperDetach","_objectHelperDir","_objectHelperPos","_canDo", "_location","_dir","_classname","_item","_hasrequireditem","_missing","_hastoolweapon","_cancel","_reason","_started","_finished","_animState","_isMedic","_dis","_sfx","_hasbuilditem","_tmpbuilt","_onLadder","_isWater","_require","_text","_offset","_IsNearPlot","_isOk","_location1","_location2","_counter","_limit","_proceed","_num_removed","_position","_object","_canBuildOnPlot","_friendlies","_nearestPole","_ownerID","_findNearestPoles","_findNearestPole","_distance","_classnametmp","_ghost","_isPole","_needText","_lockable","_zheightchanged","_rotate","_combination_1","_combination_2","_combination_3","_combination_4","_combination","_combination_1_Display","_combinationDisplay","_zheightdirection","_abort","_isNear","_need","_objHupDiff","_needNear","_vehicle","_inVehicle","_requireplot","_objHDiff","_isLandFireDZ","_isTankTrap"]; if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_40") , "PLAIN DOWN"]; }; DZE_ActionInProgress = true; // disallow building if too many objects are found within 30m if((count ((getPosATL player) nearObjects ["All",30])) >= DZE_BuildingLimit) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_41"), "PLAIN DOWN"];}; _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; _isWater = dayz_isSwimming; _cancel = false; _reason = ""; _canBuildOnPlot = false; _vehicle = vehicle player; _inVehicle = (_vehicle != player); //snap _helperDetach = false; _canDo = (!r_drag_sqf and !r_player_unconscious); //snapToggle = "OFF"; //snapToggleSwitch = true; DZE_Q = false; DZE_Z = false; DZE_Q_alt = false; DZE_Z_alt = false; DZE_Q_ctrl = false; DZE_Z_ctrl = false; DZE_5 = false; DZE_4 = false; DZE_6 = false; DZE_F = false; DZE_cancelBuilding = false; call gear_ui_init; closeDialog 1; if (_isWater) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_26", "PLAIN DOWN"];}; if (_inVehicle) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_42"), "PLAIN DOWN"];}; if (_onLadder) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_21", "PLAIN DOWN"];}; if (player getVariable["combattimeout", 0] >= time) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_43"), "PLAIN DOWN"];}; _item = _this; // Need Near Requirements _abort = false; _distance = 3; _reason = ""; _needNear = getArray (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "neednearby"); { switch(_x) do{ case "fire": { _isNear = {inflamed _x} count (getPosATL player nearObjects _distance); if(_isNear == 0) then { _abort = true; _reason = "fire"; }; }; case "workshop": { _isNear = count (nearestObjects [player, ["Wooden_shed_DZ","WoodShack_DZ","WorkBench_DZ"], _distance]); if(_isNear == 0) then { _abort = true; _reason = "workshop"; }; }; case "fueltank": { _isNear = count (nearestObjects [player, dayz_fuelsources, _distance]); if(_isNear == 0) then { _abort = true; _reason = "fuel tank"; _distance = 30; }; }; }; } forEach _needNear; if(_abort) exitWith { cutText [format[(localize "str_epoch_player_135"),_reason,_distance], "PLAIN DOWN"]; DZE_ActionInProgress = false; }; _classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create"); _classnametmp = _classname; _require = getArray (configFile >> "cfgMagazines" >> _this >> "ItemActions" >> "Build" >> "require"); _text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName"); _ghost = getText (configFile >> "CfgVehicles" >> _classname >> "ghostpreview"); _lockable = 0; if(isNumber (configFile >> "CfgVehicles" >> _classname >> "lockable")) then { _lockable = getNumber(configFile >> "CfgVehicles" >> _classname >> "lockable"); }; _requireplot = DZE_requireplot; if(isNumber (configFile >> "CfgVehicles" >> _classname >> "requireplot")) then { _requireplot = getNumber(configFile >> "CfgVehicles" >> _classname >> "requireplot"); }; _isAllowedUnderGround = 1; if(isNumber (configFile >> "CfgVehicles" >> _classname >> "nounderground")) then { _isAllowedUnderGround = getNumber(configFile >> "CfgVehicles" >> _classname >> "nounderground"); }; _offset = getArray (configFile >> "CfgVehicles" >> _classname >> "offset"); if((count _offset) <= 0) then { _offset = [0,1.5,0]; }; _isPole = (_classname == "Plastic_Pole_EP1_DZ"); _isLandFireDZ = (_classname == "Land_Fire_DZ"); _distance = DZE_PlotPole select 0; _needText = localize "str_epoch_player_246"; if(_isPole) then { _distance = DZE_PlotPole select 1; }; // check for near plot _findNearestPoles = nearestObjects [(vehicle player), ["Plastic_Pole_EP1_DZ"], _distance]; _findNearestPole = []; { if (alive _x) then { _findNearestPole set [(count _findNearestPole),_x]; }; } foreach _findNearestPoles; _IsNearPlot = count (_findNearestPole); // If item is plot pole and another one exists within 45m if(_isPole and _IsNearPlot > 0) exitWith { DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_44") , "PLAIN DOWN"]; }; if(_IsNearPlot == 0) then { // Allow building of plot if(_requireplot == 0 or _isLandFireDZ) then { _canBuildOnPlot = true; }; } else { // Since there are plots nearby we check for ownership and then for friend status // check nearby plots ownership and then for friend status _nearestPole = _findNearestPole select 0; // Find owner _ownerID = _nearestPole getVariable["CharacterID","0"]; // diag_log format["DEBUG BUILDING: %1 = %2", dayz_characterID, _ownerID]; // check if friendly to owner if(dayz_characterID == _ownerID) then { //Keep ownership // owner can build anything within his plot except other plots if(!_isPole) then { _canBuildOnPlot = true; }; } else { // disallow building plot if(!_isPole) then { _friendlies = player getVariable ["friendlyTo",[]]; // check if friendly to owner if(_ownerID in _friendlies) then { _canBuildOnPlot = true; }; }; }; }; // _message if(!_canBuildOnPlot) exitWith { DZE_ActionInProgress = false; cutText [format[(localize "STR_EPOCH_PLAYER_135"),_needText,_distance] , "PLAIN DOWN"]; }; _missing = ""; _hasrequireditem = true; { _hastoolweapon = _x in weapons player; if(!_hastoolweapon) exitWith { _hasrequireditem = false; _missing = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); } } forEach _require; _hasbuilditem = _this in magazines player; if (!_hasbuilditem) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_player_31"),_text,"build"] , "PLAIN DOWN"]; }; if (!_hasrequireditem) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_epoch_player_137"),_missing] , "PLAIN DOWN"]; }; if (_hasrequireditem) then { _location = [0,0,0]; _isOk = true; // get inital players position _location1 = getPosATL player; _dir = getDir player; // if ghost preview available use that instead if (_ghost != "") then { _classname = _ghost; }; _object = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"]; //Build gizmo _objectHelper = createVehicle ["Sign_sphere10cm_EP1", _location, [], 0, "CAN_COLLIDE"]; _helperColor = "#(argb,8,8,3)color(0.38,0.93,0.93,0,ca)"; _objectHelper setobjecttexture [0,_helperColor]; _objectHelper attachTo [player,_offset]; _object attachTo [_objectHelper,[0,0,0]]; _position = getPosATL _objectHelper; cutText [(localize "str_epoch_player_45"), "PLAIN DOWN"]; _objHDiff = 0; while {_isOk} do { _zheightchanged = false; _zheightdirection = ""; _rotate = false; if (DZE_Q) then { DZE_Q = false; _zheightdirection = "up"; _zheightchanged = true; }; if (DZE_Z) then { DZE_Z = false; _zheightdirection = "down"; _zheightchanged = true; }; if (DZE_Q_alt) then { DZE_Q_alt = false; _zheightdirection = "up_alt"; _zheightchanged = true; }; if (DZE_Z_alt) then { DZE_Z_alt = false; _zheightdirection = "down_alt"; _zheightchanged = true; }; if (DZE_Q_ctrl) then { DZE_Q_ctrl = false; _zheightdirection = "up_ctrl"; _zheightchanged = true; }; if (DZE_Z_ctrl) then { DZE_Z_ctrl = false; _zheightdirection = "down_ctrl"; _zheightchanged = true; }; if (DZE_4) then { _rotate = true; DZE_4 = false; if (_helperDetach) then { _dir = -45; } else { _dir = 180; }; }; if (DZE_6) then { _rotate = true; DZE_6 = false; if (_helperDetach) then { _dir = 45; } else { _dir = 0; }; }; if (DZE_F and _canDo) then { if (_helperDetach) then { _objectHelperDir = getDir _objectHelper; _objectHelper attachTo [player]; _objectHelper setDir _objectHelperDir-(getDir player); _helperDetach = false; } else { _objectHelperPos = getPosATL _objectHelper; detach _objectHelper; _objectHelper setPosATL _objectHelperPos; _objectHelperDir = getDir _objectHelper; _objectHelper setVelocity [0,0,0]; //fix sliding glitch _helperDetach = true; }; DZE_F = false; }; if(_rotate) then { if (!_helperDetach) then { _objectHelper setDir _dir; _objectHelper setPosATL _position; //diag_log format["DEBUG Rotate BUILDING POS: %1", _position]; }else{ _objectHelperDir = getDir _objectHelper; _objectHelperPos = getPosATL _objectHelper; _objectHelper setDir _objectHelperDir+_dir; _objectHelper setPosATL _objectHelperPos; }; }; if(_zheightchanged) then { if (!_helperDetach) then { detach _objectHelper; }; _position = getPosATL _objectHelper; if(_zheightdirection == "up") then { _position set [2,((_position select 2)+0.1)]; _objHDiff = _objHDiff + 0.1; }; if(_zheightdirection == "down") then { _position set [2,((_position select 2)-0.1)]; _objHDiff = _objHDiff - 0.1; }; if(_zheightdirection == "up_alt") then { _position set [2,((_position select 2)+1)]; _objHupDiff = _objHupDiff + 1; }; if(_zheightdirection == "down_alt") then { _position set [2,((_position select 2)-1)]; _objHDiff = _objHDiff - 1; }; if(_zheightdirection == "up_ctrl") then { _position set [2,((_position select 2)+0.01)]; _objHupDiff = _objHupDiff + 0.01; }; if(_zheightdirection == "down_ctrl") then { _position set [2,((_position select 2)-0.01)]; _objHDiff = _objHDiff - 0.01; }; _objectHelper setDir (getDir _objectHelper); if((_isAllowedUnderGround == 0) and ((_position select 2) < 0)) then { _position set [2,0]; }; _objectHelper setPosATL _position; //diag_log format["DEBUG Change BUILDING POS: %1", _position]; if (!_helperDetach) then { _objectHelper attachTo [player]; }; }; sleep 0.5; _location2 = getPosATL player; if(DZE_5) exitWith { _isOk = false; detach _object; _dir = getDir _object; _position = getPosATL _object; //diag_log format["DEBUG BUILDING POS: %1", _position]; deleteVehicle _object; detach _objectHelper; deleteVehicle _objectHelper; }; if(_location1 distance _location2 > 10) exitWith { _isOk = false; _cancel = true; _reason = "You've moved to far away from where you started building (within 10 meters)"; detach _object; deleteVehicle _object; detach _objectHelper; deleteVehicle _objectHelper; }; if(abs(_objHDiff) > 5) exitWith { _isOk = false; _cancel = true; _reason = "Cannot move up or down more than 5 meters"; detach _object; deleteVehicle _object; detach _objectHelper; deleteVehicle _objectHelper; }; if (player getVariable["combattimeout", 0] >= time) exitWith { _isOk = false; _cancel = true; _reason = (localize "str_epoch_player_43"); detach _object; deleteVehicle _object; detach _objectHelper; deleteVehicle _objectHelper; }; if (DZE_cancelBuilding) exitWith { _isOk = false; _cancel = true; _reason = "Cancelled building."; detach _object; deleteVehicle _object; detach _objectHelper; deleteVehicle _objectHelper; }; /* // DO NOT ENABLE THIS if (isClass (missionConfigFile >> "SnapBuilding" >> _classname) and snapToggleSwitch) then { s_player_toggleSnap = player addaction [format[("<t color=""#ffffff"">" + ("Snap: %1") +"</t>"),snapToggle],"snap_build.sqf",[_object,_classname],6,true,true]; snapToggleSwitch = false; }; */ }; //No building on roads unless toggled if (!DZE_BuildOnRoads) then { if (isOnRoad _position) then { _cancel = true; _reason = "Cannot build on a road."; }; }; // No building in trader zones if(!canbuild) then { _cancel = true; _reason = "Cannot build in a city."; }; if(!_cancel) then { _classname = _classnametmp; // Start Build _tmpbuilt = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"]; _tmpbuilt setdir _dir; // Get position based on object _location = _position; if((_isAllowedUnderGround == 0) and ((_location select 2) < 0)) then { _location set [2,0]; }; _tmpbuilt setPosATL _location; cutText [format[(localize "str_epoch_player_138"),_text], "PLAIN DOWN"]; _limit = 3; if (DZE_StaticConstructionCount > 0) then { _limit = DZE_StaticConstructionCount; } else { if (isNumber (configFile >> "CfgVehicles" >> _classname >> "constructioncount")) then { _limit = getNumber(configFile >> "CfgVehicles" >> _classname >> "constructioncount"); }; }; _isOk = true; _proceed = false; _counter = 0; while {_isOk} do { [10,10] call dayz_HungerThirst; player playActionNow "Medic"; _dis=20; _sfx = "repair"; [player,_sfx,0,false,_dis] call dayz_zombieSpeak; [player,_dis,true,(getPosATL player)] spawn player_alertZombies; r_interrupt = false; _animState = animationState player; r_doLoop = true; _started = false; _finished = false; while {r_doLoop} do { _animState = animationState player; _isMedic = ["medic",_animState] call fnc_inString; if (_isMedic) then { _started = true; }; if (_started and !_isMedic) then { r_doLoop = false; _finished = true; }; if (r_interrupt or (player getVariable["combattimeout", 0] >= time)) then { r_doLoop = false; }; if (DZE_cancelBuilding) exitWith { r_doLoop = false; }; sleep 0.1; }; r_doLoop = false; if(!_finished) exitWith { _isOk = false; _proceed = false; }; if(_finished) then { _counter = _counter + 1; }; cutText [format[(localize "str_epoch_player_139"),_text, _counter,_limit], "PLAIN DOWN"]; if(_counter == _limit) exitWith { _isOk = false; _proceed = true; }; }; if (_proceed) then { _num_removed = ([player,_item] call BIS_fnc_invRemove); if(_num_removed == 1) then { cutText [format[localize "str_build_01",_text], "PLAIN DOWN"]; if (_isPole) then { [] spawn player_plotPreview; }; _tmpbuilt setVariable ["OEMPos",_location,true]; if(_lockable > 1) then { _combinationDisplay = ""; switch (_lockable) do { case 2: { // 2 lockbox _combination_1 = (floor(random 3)) + 100; // 100=red,101=green,102=blue _combination_2 = floor(random 10); _combination_3 = floor(random 10); _combination = format["%1%2%3",_combination_1,_combination_2,_combination_3]; dayz_combination = _combination; if (_combination_1 == 100) then { _combination_1_Display = "Red"; }; if (_combination_1 == 101) then { _combination_1_Display = "Green"; }; if (_combination_1 == 102) then { _combination_1_Display = "Blue"; }; _combinationDisplay = format["%1%2%3",_combination_1_Display,_combination_2,_combination_3]; }; case 3: { // 3 combolock _combination_1 = floor(random 10); _combination_2 = floor(random 10); _combination_3 = floor(random 10); _combination = format["%1%2%3",_combination_1,_combination_2,_combination_3]; dayz_combination = _combination; _combinationDisplay = _combination; }; case 4: { // 4 safe _combination_1 = floor(random 10); _combination_2 = floor(random 10); _combination_3 = floor(random 10); _combination_4 = floor(random 10); _combination = format["%1%2%3%4",_combination_1,_combination_2,_combination_3,_combination_4]; dayz_combination = _combination; _combinationDisplay = _combination; }; }; _tmpbuilt setVariable ["CharacterID",_combination,true]; PVDZE_obj_Publish = [_combination,_tmpbuilt,[_dir,_location],_classname]; publicVariableServer "PVDZE_obj_Publish"; cutText [format[(localize "str_epoch_player_140"),_combinationDisplay,_text], "PLAIN DOWN", 5]; } else { _tmpbuilt setVariable ["CharacterID",dayz_characterID,true]; // fire? if(_tmpbuilt isKindOf "Land_Fire_DZ") then { _tmpbuilt spawn player_fireMonitor; } else { PVDZE_obj_Publish = [dayz_characterID,_tmpbuilt,[_dir,_location],_classname]; publicVariableServer "PVDZE_obj_Publish"; }; }; } else { deleteVehicle _tmpbuilt; cutText [(localize "str_epoch_player_46") , "PLAIN DOWN"]; }; } else { r_interrupt = false; if (vehicle player == player) then { [objNull, player, rSwitchMove,""] call RE; player playActionNow "stop"; }; deleteVehicle _tmpbuilt; cutText [(localize "str_epoch_player_46") , "PLAIN DOWN"]; }; } else { cutText [format[(localize "str_epoch_player_47"),_text,_reason], "PLAIN DOWN"]; }; }; DZE_ActionInProgress = false; thank you soo much i was looking for something like this for my server Link to comment Share on other sites More sharing options...
Mystic Joker Posted June 20, 2014 Report Share Posted June 20, 2014 i put everything in the complies and made everything and everything is correct not working :/ no ghost previews and nothing happens when we hit f Link to comment Share on other sites More sharing options...
STENCHOVDETH Posted June 20, 2014 Report Share Posted June 20, 2014 Working well for me only started testing yesterday though. I am compiling test report on the weekend for you raymix. raymix 1 Link to comment Share on other sites More sharing options...
Mystic Joker Posted June 20, 2014 Report Share Posted June 20, 2014 yuup sry i put something in wrong i got fixed Link to comment Share on other sites More sharing options...
Mystic Joker Posted June 20, 2014 Report Share Posted June 20, 2014 EDIT: nvm Link to comment Share on other sites More sharing options...
calamity Posted June 21, 2014 Report Share Posted June 21, 2014 working great. tested verry little. howz the snapping going ??? I see you disabled it here /* // DO NOT ENABLE THIS if (isClass (missionConfigFile >> "SnapBuilding" >> _classname) and snapToggleSwitch) then { s_player_toggleSnap = player addaction [format[("<t color=""#ffffff"">" + ("Snap: %1") +"</t>"),snapToggle],"snap_build.sqf",[_object,_classname],6,true,true]; snapToggleSwitch = false; }; */ Link to comment Share on other sites More sharing options...
raymix Posted June 21, 2014 Author Report Share Posted June 21, 2014 Multiple Addaction toggling is finished, took me 2 full days (they are awful, awful thing to deal with). Followed Halv's, ebaynoob's and Otter's suggestions about using functions with args, works pretty well.. also discovered that you can actually call own file within addaction if you don't like creating ton of smaller files to deal with actions, so only 1 is required... rest of it is magic with switch and functions. Script will be released as soon as I make a working prototype of snap building. Today I am working on actually generating visual gizmos that will change their color according on distance to a closest whitelisted object's point and snap together, so far so good. Hopefully will be able to do a video this weekend. I am actually thinking of releasing this part as a script for people who wants to extend their build systems and see the reaction. See if people loves it and would like it in official release... that'd be cool. Ofcourse it is still designed also for people who are against it - basically toggle-able feature that does not change current build system, it rather expands it with a press of a button. Link to comment Share on other sites More sharing options...
NorthyPark Posted June 22, 2014 Report Share Posted June 22, 2014 +1! this is very nice! i can finally rotate a wooden stair in any direction i want Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now