JoSchaap / GoT_Wasteland_V2.Stratis

WARNING! This repo is no longer updated, find the updated version on the A3Wasteland git! -
http://www.a3wasteland.com
11 stars 20 forks source link

2 respawned vehicles and 2 respawned boats keep respawning in the centre of the map #4

Closed JoSchaap closed 11 years ago

JoSchaap commented 11 years ago

4-7 respawned vehicles and 2-4 respawned boats keep respawning in the centre of the map

JoSchaap commented 11 years ago

seems to be related to FindSafePos bugging out. but is not gamebreaking. it just looks wierd to see that pile of vehicles :)

JoSchaap commented 11 years ago

might just put a fence arround it.. /ghettofix

JoSchaap commented 11 years ago

fixed in next release. some vehicles will still spawn there but no longer respawn at the 'limbo' location

JoSchaap commented 11 years ago

thought it was fixed but it seems that vehicles are still placed in limbo (mountain between airfield/city) if the setpos command fails after spawn/respawn.

When hosted locally the issie is resolved though..

I think ill just box out that area with some walls, since its only a few vehicles

AgentRev commented 11 years ago

I know why BIS_fnc_findSafePos does that. I looked at the code in the functions help, and what it actually does is try 1000 different random positions within the specified radius, and if it doesn't find a satisfying location, it will just place the vehicle at the "map center" from the game config, which for Stratis is defined as in front of the airbase gunstore.

I took the original code and modified it to fix this. It's in "server\functions\findSafePos.sqf" in my master. I raised the number of attempts to 10 000, and if no fitting position is found, it will try to find one by using "findEmptyPosition" on the base position.

The 8th parameter of the function is the vehicle type, it is passed to "findEmptyPosition" so it can find a location that fits the size of the vehicle. If it can't find a good position again, it will use the base position itself. If the base position isn't valid for some reason, only THEN will it spawn it in front of the gunstore.

Hopefully it should fix most issues with that function. For some reason, BIS originally coded it to search in a square pattern sized to the specified radius, but I changed it to a circle pattern, as it would be expected.

JoSchaap commented 11 years ago

if its caused by the BIS functions id rather just box it out, i did notice you copied and changed the findsafeposs funtion. but.. really thats not our job, i draw a line at the anticheat stuff since thats just needed..

i've got the old 3d editor to work, maybe ill just build a nice town on that hill :)

AgentRev commented 11 years ago

I don't really understand what you mean by "that's not our job"... All the BISfnc* scripts are simply helper functions that some BIS developers took the time to write so that people wouldn't have to re-invent the wheel.

There's a reason why you can see and copy the source code in the editor, it's so that you can improve them if you need to. Those functions aren't part of the game core itself.

Anyway, with BIS_fnc_findSafePos, the 8th 9th parameter is to specify "fallback" positions if the function fails to find one. It is in the format "[[groundX, groundY, groundZ], [waterX, waterY, waterZ]]". The water position is only needed if you want it to spawn in water, and that the 5th parameter is set to 1 or 2. But, the position(s) have to be in an array. So in your vehicle spawning script, if you include the 8th 9th parameter as "[_markerPos]", it will spawn at the center of the marker if it can't find a valid random position.

For vehicleCreation.sqf :

_pos = [_markerPos, 0, 30, ( if (_type == 1) then { 2 } else { 5 } ), 0, 60 * (pi / 180), 0, [], [_markerPos]] call BIS_fnc_findSafePos;

For boatCreation.sqf :

_pos = [_markerPos, 0, 15, 5, 2, 60 * (pi / 180), 0, [], [[], _markerPos]] call BIS_fnc_findSafePos;

Besides, using the 8th 9th parameter or my custom script are much more convenient than building a town around the "limbo".

JoSchaap commented 11 years ago

I thought of it as being a flaw in a BIS entitled function, and I never even noticed the fallback option in the wiki, thanks for pointing that one out to me. :)

Maybe i just enjoy improvising too much ;) (thats how i started working on this in the first place) :)

BTW: is there a reason youre going for 0 (minimal distance) rather then Random 25 ? :)

AgentRev commented 11 years ago

Because as I said, the function tries 1000 attempts at different random positions inside the radius. When I first wrote random 25, I thought the function was starting from the center of the base position and moved out progressively to find a free spot.

Many BISfnc* functions aren't documented on the community wiki, only about 10 of them are on there, while hundreds of them exist.

JoSchaap commented 11 years ago

thanks for all the info! Guess ill have to spend some more time digging through the helpdocumentation in the editor ass-well :)

I've incorporated it with the fallback principle you posted earlyer. a558b5298bd0518f1771fced70e126169c8ba535 867542f7a6278885923f756f74227384bf150e04

JoSchaap commented 11 years ago

okay this results into errors in a BIS function.


Error in expression <"_maxX", "_minY", "_maxY"]; _minX = _tl select 0; _maxX = _br select 0; _minY = > Error position: <select 0; _maxX = _br select 0; _minY = > Error select: Type Number, expected Array,Config entry File A3\functions_f\misc\fn_isPosBlacklisted.sqf, line 37

Error in expression <_tl = _current select 0; _br = _current select 1;

private ["_minX", "maxX", "> Error position: <select 1;

private ["_minX", "maxX", "> Error Zero divisor File A3\functions_f\misc\fn_isPosBlacklisted.sqf, line 34

Error in expression <"_maxX", "_minY", "_maxY"]; _minX = _tl select 0; _maxX = _br select 0; _minY = > Error position: <select 0; _maxX = _br select 0; _minY = > Error select: Type Number, expected Array,Config entry File A3\functions_f\misc\fn_isPosBlacklisted.sqf, line 37


ill look into this after work so i can actually test the code :)

JoSchaap commented 11 years ago

oh, lol i was blacklisting the positions :)


Parameter(s): _this select 0: center position (Array) Note: passing [](empty Array), the world's safePositionAnchor entry will be used. _this select 1: minimum distance from the center position (Number) _this select 2: maximum distance from the center position (Number) Note: passing -1, the world's safePositionRadius entry will be used. _this select 3: minimum distance from the nearest object (Number) _this select 4: water mode (Number) 0: cannot be in water 1: can either be in water or not 2: must be in water _this select 5: maximum terrain gradient (average altitude difference in meters - Number) _this select 6: shore mode (Number): 0: does not have to be at a shore 1: must be at a shore _this select 7: (optional) blacklist (Array of Arrays): (_this select 7) select X: Top-left and bottom-right coordinates of blacklisted area (Array) _this select 8: (optional) default positions (Array of Arrays): (_this select 8) select 0: default position on land (Array) (_this select 8) select 1: default position on water (Array)


:)

sooo i gues it would become

For vehicleCreation.sqf :

_pos = [_markerPos, 1, 35, ( if (_type == 1) then { 2 } else { 5 } ), 0, 60 * (pi / 180), 0, [], [_markerPos]] call BIS_fnc_findSafePos;

For boatCreation.sqf :

_pos = [_markerPos, 1, 15, 5, 2, 60 * (pi / 180), 0, [], [[], _markerPos]] call BIS_fnc_findSafePos;

or should i add an empty array in the empty array? because it wants arrays in an array)

AgentRev commented 11 years ago

Oh, right. I saw "_this select 8" but I completely forgot that it started at 0. So, it's the 9th parameter. Corrected my comment with the examples. An empty array alone should do, because the blacklist checking function iterates through it in the following manner :

for "_i" from 0 to (count _list - 1) do { ...

And "from 0 to -1" cancels the for loop.

JoSchaap commented 11 years ago

great thanks! :)

fixed now :)

b02e3266e09c2f5a833e50e2c2f0a732c6b34b1e ba1494a4c48c378624cc956e0e6643c6e8944a84