[Discussion] Stashes (modelToWorld)

Soul

Valued Member!
Hello fellow DayZ fanatics!

I'll first get on what i try to accomplish here.
To my personal opinion, stashes spawn to high on the map, i would like to achieve that
only the lid stays above ground level. So i tought i'd take a look in player_createstash.sqf
found in dayz_code.

The following code handles the stash position:
Code:
_location = player modeltoworld [0,2.5,0];
_location set [2,0];
Now i know that in modeltoworld [x,y,z] z handles the height, however when i set z to -1
it still spawns in the stash as it does normaly.
The other thing is _location set[index,value]; now what the hell is index and what does it
doe with _location like what does it affect on _location, anyone got a clue to this?
I tought it would affect index 2 of modeltoworld wich i believe would be the Z indicator
if you have x as index 0, y as index 1 and z as index 2 but that didnt work out well when i tried
changing _location set[2,-1]; the stash would not even appear on screen eventho the script said
the stash whas created succesfully and the cluttercutter whas applied aswell...

so i've kind of tried all what i could but without any positive result.
ps i changed the 2.5 value and that handles the distance it spawns calculated from your player.
 
I have tried modeltoworld as well with little success, not for the same purpose however. I love your idea and I totally agree. To accomplish my goal I used a combination of setposASL and setVectorDirAndUp instead, perhaps that will work for you! This is taken from the init of the object I adjusted.
[getposASL this select 0,getposASL this select 1,-3.75];this setVectorDirAndUp [[1,3,0],[0,0,1]]

Relevant information:
http://community.bistudio.com/wiki/setVectorDirAndUp
http://community.bistudio.com/wiki/setPosASL
 
I'll try that out this evening when i got some more spare time, thanks for the suggestions!
 
So I had a look at player_createstash.sqf and further down in it from where you mentioned _location is defined as being
_location = getPosATL _stash;
so maybe try this
_location = getPosATL _stash select 0, getPosATL _stash select 1, (getPosATL _stash select 2) -1;
 
On second thought you might not be able to change the height of _location during getpos, so maybe like this! Haha, sorry for bombarding your thread I just love the idea and want to help you make it work.

@line63
Code:
sleep 5;
    //place tent (local)
    _stash = createVehicle [_stashtype, _location, [], 0, "CAN_COLLIDE"];
    _stash setdir _dir;
    _stash setpos [ getPosATL _location select 0, getPosATL _location select 1, (getPosATL _location select 2) - 1];
    player reveal _stash;
    _location = getPosATL _stash;


Changed
_stash setpos _location;
to
_stash setpos [ getPosATL _location select 0, getPosATL _location select 1, (getPosATL _location select 2) - 1];
 
Tried it and failed hard xD ended up with it not even writing the stash to the database...

Breakdown

grabing location related to player position
Code:
_location = player modeltoworld [0,2.5,0];

need to find out that this exactly does!
Code:
_location set [2,0];

creating the stash using the location relative to player position [0,2.5,0]
tried your code here and changing _location to _stash combined with your suggestion below.
Code:
_stash = createVehicle [_stashtype, _location, [], 0, "CAN_COLLIDE"];

eh what? setting _stash as _dir and then overwrite that ont he next line?
Code:
_stash setdir _dir;

define _stash as _location, still [0,2.5,0]
tried your privded code here (replacing)
Code:
_stash setpos _location;

published _stash locally to the player so he can see it without it being read form the database.
Code:
player reveal _stash;

redefining _location as position from _stash
Code:
_location = getPosATL _stash;


publishing stash to database
Code:
_stash setVariable ["characterID",dayz_characterID,true];
PVDZ_obj_Publish = [dayz_characterID,_stash,[_dir,_location],_stashtype];
 
publicVariableServer "PVDZ_obj_Publish";

End of breakdown

Code:
_stash setpos [ getPosATL _location select 0, getPosATL _location select 1, (getPosATL _location select 2) - 1];
why use getPosATL? i tought _location is already a position array [0,2.5,0]
so i tried making it
Code:
_stash setpos [ _location select 0,  _location select 1, ( _location select 2) - 1];
Also player around with the -1 value to be more and less without result.
 
You know as far as I can tell

_location set [2,0];

should change the 3rd element in _location, which would be Z. So maybe that did work when you set it at -1 it was just too low, have you tried anything else? Like -.3 for example?
 
pretty much what i figured out but i wasnt to shure. even then why would they even use that set 0 when its already on 0 in modeltoworld ???

it's driving me nuts atm
 
bingo!

initial spawning of the stash z height got affected by changing the set[2,0];
howerer after restarting it got it's original height back...

changed it to set[2,0.15]; for testing and looked nicely for a first value attempt
database shows this [349,[13128.4,5890.51,-0.154]] so idk why it got f***** after
a restart.
 
no after a restart it spawns in like normaly even tho the worldspace location in the database is correct.
there shure must be a file handling the spawning of deployables and vehicles wich reads out worldspace and
handles the createvehicles... any idea where?
 
found this bit in server_monitor.sqf
Code:
if (_damage < 1) then { // create object
#ifdef OBJECTS_FIX_OUTOFMAP
                _worldspace = [_dir, _point] call fa_staywithus;
                _dir =  _worldspace select 0;
                _point =  _worldspace select 1;
#endif
                // for tents: non colliding position
                _entity = createVehicle [_class, _point, [], 0,
                    if (_class=="TentStorage") then {"NONE"} else {"CAN_COLLIDE"}
                ];   
                _entity setVariable ["ObjectUID", _ObjectID, true];
                _entity setVariable ["CharacterID", _CharacterID, true];   
                _entity setVariable ["lastUpdate",time];
                _entity setDamage _damage;
   
                if (_class == "TentStorage") then {
                    _entity addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
                };
                //diag_log ("DW_DEBUG " + _class + " #" + str(_ObjectID) + " pos=" +      (_point call fa_coor2str) + ", damage=" + str(_damage)  );
            }
 
I believe that section is just deleting any storage place outside the map boundaries. :/ I've been looking too but so far have just found that and a few parts that deal with deleting empty tents.
 
i will, just going to give this a test and then a test on the pub server see if it adds unwanted side effects
if found sane i'll release this ;)
 
did you change
_entity = createVehicle [_class, _point, [], 0,
if (_class=="TentStorage") then {"NONE"} else {"CAN_COLLIDE"}

to

_entity = createVehicle [_class, _point, [], 0,
if (_class=="TentStorage") then {"CAN_COLLIDE"} else {"CAN_COLLIDE"}

?
 
1st in createstash file
_location = player modeltoworld [0,2.5,-0.20];
//_location set [2,-0.17]; comented this out and hardcoded in above line
 
then in servermonitor i have this atm in place
red text is added code to the existing code to ensure correct Z value for stashes ;)
// for tents: non colliding position
_xpoint = _point select 0;
_ypoint = _point select 1;
_zpoint = _point select 2;
_point = [_xpoint, _ypoint, if((_class=="stashsmall") or (_class=="stashmedium"))then{-0.20}else{_zpoint}];
_entity = createVehicle [_class, _point, [], 0,
if (_class=="TentStorage") then {"NONE"} else {"CAN_COLLIDE"}
 
however on slopes they are fully under the ground, does work nice on somewhat flat surface
my next step is adding a slope check in nicespot.sqf stashes cause i have it at false atm
 
Back
Top