height of spawn

height of spawn

« posted: Dec 17, 2014, 10:44 AM »
Hi all,

I'm trying to build a city on big artificial island on stratis map. For this, I used piers so my ground level is around 2.5m up the sea level . I created a marker to set this island as a city. We can respawn on this place but it appears that we're in the sea, under the piers :/ Is it possible to modify the height of spawn to correct this ? Many thanks for advance  :) 
  • Offline micovery
  • Moderator
  • Hardened
  • ******
  • Posts: 159

Re: height of spawn

« Reply #1 posted: Dec 17, 2014, 12:18 PM »
You mean like this video :-) :


The Z axis for markers is always 0 ... are you trying to integrate this with the wasteland spawn dialog?

I did something similar ... but ended up putting invisible objects (spheres) to act as sort-of spawn beacons.

Here is the code that spawns a player at a random location within 10 meters of the invisible sphere.

Code: [Select]

//generate a random distance, and direction
private["_rad","_dir"];
_rad = random(10);
_dir = random(360);


//convert from polar coordinates to X,Y
private["_xr","_yr"];
_xr = _rad * cos(_dir);
_yr = _rad * sin(_dir);

player attachTo [invisible_sphere,[_xr,_yr,0]];
detach player;

Make sure the sphere is above the surface of the piers.

Re: height of spawn

« Reply #2 posted: Dec 17, 2014, 01:56 PM »
Hi, thks a lot for your fast answer :-)

I knew this video =^-^= Here, you've a link to see the island, this project is not yet finished, lot of work   ;)

https://www.dropbox.com/s/jzunsws3ahm5gog/2014-12-17_00002.jpg?dl=0
  • Offline LouD
  • Silent but deadly ;)
  • Moderator
  • Veteran
  • ******
  • Posts: 1415

Re: height of spawn

« Reply #3 posted: Dec 17, 2014, 02:19 PM »
Oh my, that is one massive! island haha. Looks cool though :)
Do you load it from the mission.sqm or did you load it from an external sqf script?
It's not creating any lag?

Re: height of spawn

« Reply #4 posted: Dec 17, 2014, 02:28 PM »
I load it from the mission.sqm file. I didn't noticed any lag. I'll send you again my pbo so you have an up to date version and can see it  ;)
  • Offline JoSchaap
  • Developer
  • Mercenary
  • ******
  • Posts: 481
  • Had a life.. Got a modem.. (~1996)

Re: height of spawn

« Reply #5 posted: Dec 17, 2014, 03:34 PM »
and driving over it goes well in MP too? :)

Re: height of spawn

« Reply #6 posted: Dec 17, 2014, 05:50 PM »
Hi :) for the moment, it's implemented on our MP server even if the site is still under construction to test it. I would like to create a big PVP area ;) Feel free to take a look on FLAG server, on 85.131.231.191:2302 :-) If you have any suggestions, I'm interested ;)
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2495

Re: height of spawn

« Reply #7 posted: Dec 18, 2014, 05:55 AM »
Code: [Select]
//generate a random distance, and direction
private["_rad","_dir"];
_rad = random(10);
_dir = random(360);


//convert from polar coordinates to X,Y
private["_xr","_yr"];
_xr = _rad * cos(_dir);
_yr = _rad * sin(_dir);

player attachTo [invisible_sphere,[_xr,_yr,0]];
detach player;

Using raw math commands is a great way to complicate code.

Code: [Select]
player attachTo [invisible_sphere, [[random 10, 0, 0], random 360] call BIS_fnc_rotateVector2D];
detach player;
  • Offline micovery
  • Moderator
  • Hardened
  • ******
  • Posts: 159

Re: height of spawn

« Reply #8 posted: Dec 18, 2014, 06:10 AM »
Using raw math commands is a great way to complicate code.

Code: [Select]
player attachTo [invisible_sphere, [[random 10, 0, 0], random 360] call BIS_fnc_rotateVector2D];
detach player;

Nice, thanks for simplifying it.

Re: height of spawn

« Reply #9 posted: Dec 18, 2014, 11:09 AM »
Thanks a lot for the infos, Rev  :) but which file should I modify ?
  • Offline micovery
  • Moderator
  • Hardened
  • ******
  • Posts: 159

Re: height of spawn

« Reply #10 posted: Dec 18, 2014, 01:14 PM »
but which file should I modify ?

Depends on what you want to do. Do you want players to have a chance of spawning in your city when they click on "Random" in the spawn dialog? If that's the case you'd need to edit the "spawnRandom.sqf".

Something like this (I have not tested it ... you need to tinker with it):

Code: [Select]
private ["_preload", "_randomLoc", "_pos", "_rad", "_townName", "_playerPos"];
_preload = [_this, 1, false, [false]] call BIS_fnc_param;

_randomLoc = ((call cityList) + [invisible_sphere]) call BIS_fnc_selectRandom;

if (typeName _randomLoc == typeName objNull)  then {

  if (_preload) then { waitUntil {sleep 0.1; preloadCamera (getPos _randomLoc)} };
 
  player attachTo [_randomLoc, [[random 10, 0, 0], random 360] call BIS_fnc_rotateVector2D];
  detach player;

  _townName = "Your Awesome Town Name";
}
else {
  _pos = getMarkerPos (_randomLoc select 0);
  _rad = _randomLoc select 1;
  _townName = _randomLoc select 2;
  _playerPos = [_pos,5,_rad,1,0,0,0] call findSafePos;

  if (_preload) then { waitUntil {sleep 0.1; preloadCamera _playerPos} };

  player setPos _playerPos;
};

waitUntil {!isNil "bis_fnc_init" && {bis_fnc_init}};

respawnDialogActive = false;
closeDialog 0;

_townName spawn {
  _townName = _this;
  sleep 1;

  _hour = date select 3;
  _mins = date select 4;
  ["Wasteland", _townName, format ["%1:%3%2", _hour, _mins, if (_mins < 10) then {"0"} else {""}]] spawn BIS_fnc_infoText;
};

Re: height of spawn

« Reply #11 posted: Dec 18, 2014, 01:53 PM »
Exactly, thks a lot :) i'll try that and for vehicles spawning randomly and missions spawning randomly in cities, I presume that I  need to do other modifications, just to be sure :)

Re: height of spawn

« Reply #12 posted: Dec 28, 2014, 06:04 PM »
Hi all, my island is growing but still not succeed to make spawn on it :/

https://www.dropbox.com/s/fohjkl3gm9r55v6/2014-12-28_00001.jpg?dl=0

As recommended by Micovery, i modified the file spawnRandom.sqf :

Code: [Select]
// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
// @file Version: 1.1
// @file Name: spawnRandom.sqf
// @file Author: [404] Deadbeat, [404] Costlyy, [GoT] JoSchaap, AgentRev

waituntil {!isnil "bis_fnc_init"};


private ["_preload", "_randomLoc", "_pos", "_rad", "_townName", "_playerPos"];
_preload = [_this, 1, false, [false]] call BIS_fnc_param;

_randomLoc = ((call cityList) + [invisible_sphere]) call BIS_fnc_selectRandom;

if (typeName _randomLoc == typeName objNull)  then {

  if (_preload) then { waitUntil {sleep 0.1; preloadCamera (getPos _randomLoc)} };
 
  player attachTo [_randomLoc, [[random 10, 0, 0], random 360] call BIS_fnc_rotateVector2D];
  detach player;

  _townName = "West FLAG Airport";
  _townName = "East FLAG Airport";
  _townName = "FLAG Harbour";
  _townName = "FLAG City";
  _townName = "Tsoukalia Bay Fortified Island";
  _townName = "Agia Bay Fortified Island";
  _townName = "Kamino Bay Fortified Island";
}
else {
  _pos = getMarkerPos (_randomLoc select 0);
  _rad = _randomLoc select 1;
  _townName = _randomLoc select 2;
  _playerPos = [_pos,5,_rad,1,0,0,0] call findSafePos;

  if (_preload) then { waitUntil {sleep 0.1; preloadCamera _playerPos} };

  player setPos _playerPos;
};

waitUntil {!isNil "bis_fnc_init" && {bis_fnc_init}};

respawnDialogActive = false;
closeDialog 0;

_townName spawn {
  _townName = _this;
  sleep 1;

  _hour = date select 3;
  _mins = date select 4;
  ["Wasteland", _townName, format ["%1:%3%2", _hour, _mins, if (_mins < 10) then {"0"} else {""}]] spawn BIS_fnc_infoText;
};

and for the invisible spheres, i created 8 vehicles in my mission.sqm file as below :

Code: [Select]
class Item4465
{
position[]={2386.666748,0,6284.638184};
name="invisible_sphere";
offsetY=3.5;
id=4622;
side="EMPTY";
vehicle="Sign_Sphere100cm_F";
skill=0.60000002;
init="this hideObjectGlobal true;";
};

Does anybody have an idea about what I did wrong ? Thanks for advance for your help or advices :)
  • Offline micovery
  • Moderator
  • Hardened
  • ******
  • Posts: 159

Re: height of spawn

« Reply #13 posted: Dec 28, 2014, 07:46 PM »
You have  new/extra spawn locations ... but you only added one to the list of cities passed to "BIS_fnc_selectRandom".

Here you go: https://gist.github.com/micovery/66463acd19388bc86e81

In order to easily test if it was working I made it spawn only in your custom cities like this:

Code: [Select]
  _randomLoc = _extraCities  call BIS_fnc_selectRandom;

However, for the actual mission you have to include all cities like this:

Code: [Select]
  _randomLoc = ((call cityList) + _extraCities)  call BIS_fnc_selectRandom;


Finally, your mission.sqm, the thing you have for "name", should be "text" instead.
The sample mission.sqm entries that I have in the gist link are placed 30 meters above the sea-level:

Code: [Select]
  init="this setPosASL [((getPos this) select 0), ((getPos this) select 1), 30]";

You should vary this height for each sphere, depending on how high (above sea level) the spawn location is for each of your artificial islands. 

As far as the X, and Y coordinates ... you can edit those in the Arma 3 editor itself by moving them around on the map.

Re: height of spawn

« Reply #14 posted: Dec 29, 2014, 12:01 PM »
It works like a charm :) thanks a lot, micovery :)