Sleeping in tents

Audio Rejectz

Well-Known Member
Having a play around with this, but to no avail. Im going to keep at it, but here is the basis for it if anyone wants to try and have a play with it

in the ini

Code:
if (!isDedicated) then {
    [] execVM "tentsleep.sqf"
};
tentsleep.sqf

Code:
// action - dream
_find = nearestObjects [player, ["TentStorage"], 20];
{
    _rts = _x getVariable ["rtosleep", -1];
    if(_rts < 0) then {
        _x addAction ["sleep", "sleep1.sqf"];
        _x setVariable ["rtosleep", 1];
    };
};
sleep1.sqf

Code:
if(myISleep < 1) then {
    myISleep = 1;
    player globalChat "rest";
    _unit = player;
    //_unit removeAction mySleepAction;
    //mySleepAction = -1;
   
    _unit playMove "AidlPpneMstpSnonWnonDnon_SleepA_sleep3";
   
    WaitUntil {(animationState _unit != "AidlPpneMstpSnonWnonDnon_SleepB_sleep1")};
   
    //sleep 5;
    //titleCut [" ","BLACK OUT", 3];
    //5 FadeSound 0;
    //sleep 5;
   
    _unit switchMove "AidlPpneMstpSnonWnonDnon_SleepA_death";
    _timesleep = time;
    _timec = time;
    _done = false;
    _tconst = 0.0625; //0.125 0.0625 0.03125
    While {(inputAction "moveForward"!=1) and (!_done)} do {
        sleep 0.5;
        skipTime _tconst;
       
        //_currenttime =str(floor(daytime));
        _timec = _timec + (3600 * _tconst);
        _sleeptime = _timec - _timesleep;
        if(_sleeptime >= (60*60*6)) then {_done = true;};
       
        _h = floor(_sleeptime / (60*60));
        _m = floor((_sleeptime - (_h * 60*60)) / 60);
       
        hintSilent format["time sleep %1:%2\wake up - W", _h, _m];
    };
    _unit switchMove "AidlPpneMstpSnonWnonDnon_SleepA_sleep3";
    sleep 3;
   
    //titleCut [" ","BLACK IN", 5];
    //15 FadeSound 1;
    //sleep 15;
   
    player globalChat "Rise";
    //mySleepAction = player addAction ["sleep", "sleep1.sqf"];
    hintSilent "";
    myISleep = 0;
};
 

shinkicker

Administrator
Staff member
Just marking this so I can come back to it and help. Need to sleep for now.

You should maybe do some sort of heal process for sleeping.
 

Audio Rejectz

Well-Known Member
Just marking this so I can come back to it and help. Need to sleep for now.

You should maybe do some sort of heal process for sleeping.
That was the plan mate, all though i wanted to possibly look at it protecting you from the elements more so. Im just having problems getting it to work correctly

@Vazabisong - It's not working correctly at present mate
 

shinkicker

Administrator
Staff member
Typing this from my laptop, so none of this is tested as yet.

Copy sleep1.sqf into a folder (I would use dayz_code/actions as that's where most of these sorts of scripts are).

I would then move the script execution from init into /dayz_code/compile/fn_selfActions.sqf

Add the following section to fn_selfActions:

Code:
 if(cursorTarget isKindOf "TentStorage" and _canDo and _ownerID == dayz_characterID) then {
s_player_sleeptent = player addAction [localize "Sleep in tent", "\z\addons\dayz_code\actions\tentsleep.sqf",cursorTarget, 0, false, true, "",""];
};
} else {
player removeAction s_player_sleeptent;
s_player_sleeptent = -1;
};
And the following line:


//Engineering
{dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
dayz_myCursorTarget = objNull;
//Others
player removeAction s_player_forceSave;
s_player_forceSave = -1;
player removeAction s_player_deleteBuild;
s_player_deleteBuild = -1;
player removeAction s_player_butcher;
s_player_butcher = -1;
player removeAction s_player_cook;
s_player_cook = -1;
player removeAction s_player_fireout;
s_player_fireout = -1;
player removeAction s_player_packtent;
s_player_packtent = -1;
player removeAction s_player_fillfuel;
s_player_fillfuel = -1;
player removeAction s_player_studybody;
s_player_studybody = -1;
player removeAction s_player_sleeptent;
s_player_sleeptent = -1;
};
I got a feeling we would need to debug this a little more, but give it a try. Add -ShowScriptErrors to your launch options.

Would you also be interested in putting this into Day 2017? I like this idea, and I could help code in the revive elements / environment protection too.

Nice idea.
 
Top