Which sqf is handling tent pitch on 0.2.5?

Rexxenexx

Member
It's not tent_pitch.sqf anymore. I changed the player_tentPitch = compile pr..."...tent_pitch.sqf" to point to my tweaked one (from custom compiles.sqf) and it doesn't change.

It's still I guess using the Build Object system used for constructing bases etc.
 
Found it/them: player_build.sqf and object_build.sqf. Just need to add custom ones to compiles.sqf and tweak. You need player_build to point to object_build.

All I want is tents to be able to be deployed anywhere/ ignore collision w other objects. Cleanup will fix ppl who F' up their tents. Too many tents isn't a problem on the server either. Just a matter of bypassing "_inside" checks if _object is a tent...Wish me luck!
 
Here is how I did it:

In the mission folder:

I already have the init.sqf pointing to a custom fixes\compiles.sqf. I changed these lines:

Code:
player_build = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_build.sqf";
object_build = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\object_build.sqf";

to this:

Code:
player_build = compile preprocessFileLineNumbers "scripts\player_build.sqf";
object_build = compile preprocessFileLineNumbers "scripts\object_build.sqf";

then I added the two files:
 
scripts\player_build.sqf:

Code:
private ["_item","_classname","_require","_text","_location","_sfx","_object","_string","_onLadder","_isWater","_boundingBox","_maxPoint","_actionBuild","_actionCancel"];
 
call gear_ui_init;
 
closeDialog 1;
 
if (r_action_count != 1) exitWith { cutText [localize "str_player_actionslimit", "PLAIN DOWN"]; };
 
_item = _this;
_classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create");
_require = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "require");
_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
_onLadder =        (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_isWater =        (surfaceIsWater (getPosATL player)) or dayz_isSwimming;
 
if(_isWater) exitWith {
    r_action_count = 0;
    cutText [localize "str_player_26", "PLAIN DOWN"];
};
 
if(_onLadder) exitWith {
    r_action_count = 0;
    cutText [localize "str_player_21", "PLAIN DOWN"];
};
 
// item is missing
if ((!(_item IN magazines player))) exitWith {
    r_action_count = 0;
    _string = switch true do {
        case (_object isKindOf "Land_A_tent"): {"str_player_31_pitch"};
        default {"str_player_31_build"};
    };
    cutText [format[(localize "str_player_31"),_text,(localize _string)] , "PLAIN DOWN"];
    diag_log(format["player_build: item:%1 require:%2  Player items:%3  magazines:%4", _item, _require, (items player), (magazines player)]);
};
 
// tools are missing
if ((_require != "") and {(!(_require IN items player))}) exitWith {
    r_action_count = 0;
    cutText [format[(localize "str_player_31_missingtools"),_text,_require] , "PLAIN DOWN"];
};
 
if (!isNull (player getVariable "constructionObject")) exitWith {
    r_action_count = 0;
    cutText [localize "str_already_building", "PLAIN DOWN"];
};
 
player setVariable ["constructionObject", player]; //Quick fix to stop multi build bug
 
player removeMagazine _item;
 
cutText [localize "str_player_build_rotate", "PLAIN DOWN"];
 
_location = getMarkerpos "respawn_west";
_object = createVehicle [_classname, _location, [], 0, "NONE"];
_boundingBox = boundingBox _object;
_maxPoint = ([[0,0], _boundingBox select 1] call BIS_fnc_distance2D) + 1;
//_object attachTo [player, [0, _maxPoint + 1, 0]];
 
player setVariable ["constructionObject", _object];
_object setVariable ["characterID",dayz_characterID,true];
 
_sfx = switch true do {
    case (_object isKindOf "Land_A_tent"): {"tentunpack"};
    default {"repair"};
};
 
_actionBuild = player addAction [localize "str_player_build_complete", "scripts\object_build.sqf", [_object, _item, _classname, _text, true, 20, _sfx], 1, true, true, "", "!isNull (_target getVariable [""constructionObject"", objNull])"];
_actionCancel = player addAction [localize "str_player_build_cancel", "scripts\object_build.sqf", [_object, _item, _classname, _text, false, 0, "none"], 1, true, true, "", "!isNull (_target getVariable [""constructionObject"", objNull])"];
 
_position = [0,0,0];
while {!isNull (player getVariable "constructionObject")} do {
    if (vehicle player != player) then {
        player action ["eject", vehicle player];
    };
 
    if (speed player > 10 or speed player <= -8) then {
        cutText [localize "str_player_build_movingfast", "PLAIN DOWN"];
        player playMove "amovpercmstpssurwnondnon";
    };
 
    if (!((count ((getPosATL player) - _position)) == 0)) then {
        _position = getPosATL player;
        _object setPosATL [(_position select 0) + _maxPoint * sin(getDir player), (_position select 1) + _maxPoint * cos(getDir player), 0.01];
    };
 
    sleep 0.01;
     
    if ((!alive player) or {((getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1)}) then {
        [[],[],[],[_object, _item, _classname, _text, false, 0, "none"]] call object_build;
    };
};
 
player removeAction _actionBuild;
player removeAction _actionCancel;
 
scripts\object_build.sqf:

Code:
private ["_array","_object","_item","_classname","_text","_build","_inside","_location","_nearObjects","_dis","_sfx"];
_array = _this select 3;
_object = _array select 0;
_item = _array select 1;
_classname = _array select 2;
_text = _array select 3;
_build = _array select 4;
_dis = _array select 5;
_sfx = _array select 6;
 
if (isNull _object) exitWith {};
 
player setVariable ["constructionObject", objNull];
 
_createPoints = {
    private ["_unit","_boundingBox","_points"];
    _unit = _this select 0;
    _scale = _this select 1;
    _boundingBox = boundingBox _unit;
    _boundingBox =[[((_boundingBox select 0) select 0) * _scale, ((_boundingBox select 0) select 1) * _scale, (_boundingBox select 0) select 2], [((_boundingBox select 1) select 0) * _scale, ((_boundingBox select 1) select 1) * _scale, (_boundingBox select 1) select 2]];
   
    _points = [getPosATL _unit];
   
    for "_i" from 1 to 0 step -0.5 do {
        for "_j" from 0 to 1 do {
            _points set [count _points, _unit modelToWorld [0, ((_boundingBox select 0) select 1) * _i, 0]];
            _points set [count _points, _unit modelToWorld [0, ((_boundingBox select 1) select 1) * _i, 0]];
            _points set [count _points, _unit modelToWorld [((_boundingBox select 0) select 0) * 0.5, ((_boundingBox select _j) select 1) * _i, 0]];
            _points set [count _points, _unit modelToWorld [((_boundingBox select 1) select 0) * 0.5, ((_boundingBox select _j) select 1) * _i, 0]];
            _points set [count _points, _unit modelToWorld [((_boundingBox select 0) select 0) * 1, ((_boundingBox select _j) select 1) * _i, 0]];
            _points set [count _points, _unit modelToWorld [((_boundingBox select 1) select 0) * 1, ((_boundingBox select _j) select 1) * _i, 0]];
        };
    };
    _points;
};
 
_insideCheck = {
    private ["_x","_inside","_myX","_myY","_building","_unit","_boundingBox","_points","_min","_max"];
    _building = _this select 0;
    _unit = _this select 1;
   
    _inside = false;
    //Change these to tweak collision detection
    _scale = switch (_this select 2) do {
        case "building": { 0.65 };
        case "tree": { 0.25 };
        case "picea": { 0.0 };
    };
   
    _points = [_unit, _scale] call _createPoints;
   
    _boundingBox = boundingBox _building;
    _min = _building modelToWorld (_boundingBox select 0);
    _max = _building modelToWorld (_boundingBox select 1);
    //diag_log format["boundingBox: %1    min: %2    max: %3", _boundingBox, _min, _max];
   
    {
        _myX = _x select 0;
        _myY = _x select 1;
 
        if ((_myX > ((_min select 0) min (_max select 0))) and {(_myX < ((_max select 0) max (_min select 0)))}) then {
            if ((_myY > ((_min select 1) min (_max select 1))) and {(_myY < ((_max select 1) max (_min select 1)))}) then {
                _inside = true;
                //diag_log format["result: %1", _inside];
            };
        };
       
        if (_inside) exitWith {};
    } forEach _points;
   
    _inside;
};
 
if (_build) then {
 
    _inside = false;
   
    if (_object isKindOf "TentStorage") then {
   
        //Skip Bounds Check
       
    } else {
   
        _nearObjects = nearestObjects [player, [], 15];
        //diag_log format["nearObjects: %1", _nearObjects];
        {
            if ((!isNull _x) and (!(_x == player)) and (!(_x == _object))) then {
                //diag_log format["object: %1    type: %2    string: %3    t_: %4    b_: %5    building: %6    vehicle: %7", _x, typeOf _x, str(_x), [": t_", str(_x)] call fnc_inString, [": b_", str(_x)] call fnc_inString, _x isKindOf "Building", _x isKindOf "AllVehicles"];
                switch true do {
                    case ((_x isKindOf "Building") or (_x isKindOf "AllVehicles") or (["rock", str(_x)] call fnc_inString)): { //Building or Vehicle or Rock
                        _inside = [_x, _object, "building"] call _insideCheck;
                        if (!_inside) then {
                            _inside = [_object, _x, "building"] call _insideCheck;
                        };
                        //diag_log "BUILDING";
                    };
                    case ([": t_picea", str(_x)] call fnc_inString): {
                        _inside = [_object, _x, "picea"] call _insideCheck;
                        //diag_log "PICEA";
                    };
 
                    case (([": t_", str(_x)] call fnc_inString) or ([": b_", str(_x)] call fnc_inString)): { //Tree or Bush
                            _inside = [_object, _x, "tree"] call _insideCheck;
                            //diag_log "TREE";
                    };
                };
                //diag_log format["result: %1", _inside];
            };
            if (_inside) exitWith {};
        }forEach _nearObjects;
   
    };
   
    if ( !_inside ) then {
        [player,_sfx,0,false,_dis] call dayz_zombieSpeak;
        [player,_dis,true,(getPosATL player)] call player_alertZombies;
 
        player playActionNow "Medic";
 
        sleep 5;
       
        _location = getPosATL _object;
        _object setPosATL [_location select 0, _location select 1, 0.01];
        _object setDir (getDir _object);
 
        player reveal _object;
 
        _object setVariable ["characterID",dayz_characterID,true];
 
        if (_object isKindOf "TrapItems") then {
            if (getNumber (configFile >> "CfgVehicles" >> typeOf _object >> "initState") > 0) then {
                _object setVariable ["armed", true, true];
            } else {
                _object setVariable ["armed", false, true];
            };
        };
 
        cutText [format[localize "str_build_01",_text], "PLAIN DOWN"];
 
        PVDZ_obj_Publish = [dayz_characterID,_object,[getDir _object, getPosATL _object],_classname];
        publicVariableServer "PVDZ_obj_Publish";
 
        r_action_count = 0;
        cutText [format[localize "str_build_01",_text], "PLAIN DOWN"];
    } else {
        r_action_count = 0;
        deleteVehicle _object;
        player addMagazine _item;
        cutText [format[localize "str_build_failed_01",_text], "PLAIN DOWN"];
    };
} else {
    r_action_count = 0;
    deleteVehicle _object;
    player addMagazine _item;
    cutText [format[localize "str_build_failed_01",_text], "PLAIN DOWN"];
};
 
Your folders (scripts/fixes) may be different. If you don't have a compiles.sqf then search this website in the "Script/Addon releases" section. Any of those will show first thing how to rip it out of dayz_code.pbo.

Hope this helps!
 
Back
Top