Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
JoSchaap opened this issue Jun 1, 2013 · 14 comments
Assignees
Labels

Comments

@JoSchaap
Copy link
Owner

JoSchaap commented Jun 1, 2013

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

@ghost ghost assigned JoSchaap Jun 1, 2013
@JoSchaap
Copy link
Owner Author

JoSchaap commented Jun 4, 2013

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

@JoSchaap
Copy link
Owner Author

might just put a fence arround it.. /ghettofix

@JoSchaap
Copy link
Owner Author

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

@JoSchaap
Copy link
Owner Author

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

@JoSchaap JoSchaap reopened this Jun 18, 2013
@AgentRev
Copy link

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
Copy link
Owner Author

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
Copy link

I don't really understand what you mean by "that's not our job"... All the BIS_fnc_* 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
Copy link
Owner Author

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
Copy link

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 BIS_fnc_* functions aren't documented on the community wiki, only about 10 of them are on there, while hundreds of them exist.

@JoSchaap
Copy link
Owner Author

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.
a558b52
867542f

@JoSchaap
Copy link
Owner Author

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 JoSchaap reopened this Jun 19, 2013
@JoSchaap
Copy link
Owner Author

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
Copy link

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
Copy link
Owner Author

great thanks! :)

fixed now :)

b02e326
ba1494a

AgentRev added a commit to AgentRev/Arma3-404Wasteland-Stratis-TPG that referenced this issue Jul 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants