Jump to content

Recommended Posts

Team,

 

I have moved away from ghost spawner in a new mission I am making and using VVS.

 

I am having an issue in VVS where some of the vehicles spawn in the ground.

 

In the Ghost spawner I used this to solve the problem.

Spoiler

	_veh1 = createVehicle [_vehsel,_spawn, [], 0, "NONE"];
	_veh1 setdir _dir;
	_veh1 setposatl [_spawn select 0, _spawn select 1, 209];
	_veh1 setVectorUP (surfaceNormal [(getPosatl _veh1) select 0,(getPosatl _veh1) select 1]);
	ghst_local_vehicles = ghst_local_vehicles + [_veh1];
	
	[_veh1] spawn DEVAS_AutoPilot;
	[_veh1] spawn DEVAS_Loiter;

 

VVS spawner looks like this.

Spoiler

_vehicle = _className createVehicle _position;
_vehicle allowDamage false;
_vehicle setPos _position; //Make sure it gets set onto the position.
_vehicle setDir _direction; //Set the vehicles direction the same as the marker.

 

 

I know need to add these 2 lines, but not sure how to use the code from the ghost spawn to vvs.

 

Or if there is a simpler solution like spawning the vehicle 1 foot above the ground, etc.

 

Thanks for any help.

 

  • Like 1

Share this post


Link to post
Share on other sites

Hello there Jnr4817 !

 

The spawn position that you are using is a marker in the map ?

 

If yes you can do :

 

_pos = getmarkerpos "marker_1";
_vehicle = _className createVehicle _pos ;
_vehicle setPos _position; //Make sure it gets set onto the position.
_vehicle setDir _direction; //Set the vehicles direction the same as the marker.

 

and remove the first code

 

- i haven't see the whole code but i don't think that you want something more.

 

Share this post


Link to post
Share on other sites
Spoiler

/*
	File: fn_spawnVehicle.sqf
	Author: Bryan "Tonic" Boardwine
	
	Description:
	Spawns the selected vehicle, if a vehicle is already on the spawn point
	then it deletes the vehicle from the spawn point.
*/
disableSerialization;
private["_position","_direction","_className","_displayName","_spCheck","_cfgInfo"];
if(lnbCurSelRow 38101 == -1) exitWith {hint "You did not select a vehicle to spawn!"};

_className = lnbData[38101,[(lnbCurSelRow 38101),0]];
_displayName = lnbData[38101,[(lnbCurSelRow 38101),1]];
_position = getMarkerPos VVS_SP;
_direction = markerDir VVS_SP;

//Make sure the marker exists in a way.
if(isNil "_position") exitWith {hint "The spawn point marker doesn't exist?";};

//Check to make sure the spawn point doesn't have a vehicle on it, if it does then delete it.
_spCheck = nearestObjects[_position,["landVehicle","Air","Ship"],12] select 0;
if(!isNil "_spCheck") then {deleteVehicle _spCheck;};

_cfgInfo = [_className] call VVS_fnc_cfgInfo;

_vehicle = _className createVehicle _position;
_vehicle allowDamage false;
_vehicle setPos _position; //Make sure it gets set onto the position.
_vehicle setDir _direction; //Set the vehicles direction the same as the marker.

[_vehicle] spawn DEVAS_AutoPilot;
[_vehicle] spawn DEVAS_Loiter;

if((_cfgInfo select 4) == "Autonomous") then
{
	createVehicleCrew _vehicle;
};

if(VVS_Checkbox) then
{
	clearWeaponCargoGlobal _vehicle;
	clearMagazineCargoGlobal _vehicle;
	clearItemCargoGlobal _vehicle;
};

_vehicle allowDamage true;
hint format["You have spawned a %1",_displayName];
closeDialog 0;

 

 

 

Here is the full code.

 

Yes it is a service marker named VVS_all_1.

 

Another problem is spawning on the freedom.

 

The ghost spawner code fixes this issue with this code as you can change the exact height of the vehicle spawning to be over the deck of the freedom.

Spoiler

_veh1 setposatl [_spawn select 0, _spawn select 1, 209];
_veh1 setVectorUP (surfaceNormal [(getPosatl _veh1) select 0,(getPosatl _veh1) select 1]);

 

 

 

Thanks again for any help.

 

I am also going to integrate your GF_Mission and GF_AutoPopulation.

 

Reed

  • Thanks 1

Share this post


Link to post
Share on other sites
10 minutes ago, Jnr4817 said:

Another problem is spawning on the freedom.

 

you can create in the editor , on the freedom a UserTexture1m_F and name this somthing "Spawn_pos_1"

and then go to the script and :

_pos = getPosATL Spawn_pos_1;

so you can set the spawn position wherever you want from the editor.

 

Just , i really haven't understand , you are using this and it's fine dor the ship but not ok for the land ?

Share this post


Link to post
Share on other sites

Currently the VVS work on land with all BIS assets and most CUP. The issue is some vehicles spawn in the ground. I need to fix this so all assets spawn correctly.

 

Next, VVS doesn't spawn anything on the freedom, it spawns on the ocean floor, at the marker location. I also need to fix this.

 

I want to be able to use the same spawn function from VVS.

 

It sounds like I need to change from a marker to something else and use posatl?

 

Reed

 

Share this post


Link to post
Share on other sites

THis is a solution from the VVS thread, but I need to work on land too.

Spoiler

/*
	File: fn_spawnVehicle.sqf
	Author: Bryan "Tonic" Boardwine
	
	Description:
	Spawns the selected vehicle, if a vehicle is already on the spawn point
	then it deletes the vehicle from the spawn point.

   Edit: Strider 10 Sep 2017
   Updated to work with the USS Freedom aircraft carrier.
*/
disableSerialization;
private["_position","_direction","_className","_displayName","_spCheck","_cfgInfo"];
if(lnbCurSelRow 38101 == -1) exitWith {hint "You did not select a vehicle to spawn!"};

_className = lnbData[38101,[(lnbCurSelRow 38101),0]];
_displayName = lnbData[38101,[(lnbCurSelRow 38101),1]];
_position = getMarkerPos VVS_SP;

// Check if we are over water (and assume we are on the USS Freedom.
if ( surfaceIsWater _position ) then {
   _position = _position vectorAdd [0,0,24];
};

_direction = markerDir VVS_SP;

//Make sure the marker exists in a way.
if(isNil "_position") exitWith {hint "The spawn point marker doesn't exist?";};

//Check to make sure the spawn point doesn't have a vehicle on it, if it does then delete it.
_spCheck = nearestObjects[_position,["landVehicle","Air","Ship"],12] select 0;
if(!isNil "_spCheck") then {deleteVehicle _spCheck;};

_cfgInfo = [_className] call VVS_fnc_cfgInfo;

/*
 * Spawn the requested vehicle.
 */

// Spawn vehicle somewhere where we can manipulate it.
_vehicle = createVehicle [_className, [0,0,10], [], 0, "CAN_COLLIDE"];

// Stop it being damaged.
_vehicle allowDamage false;

// Set the vehicle direction.
_vehicle setDir _direction;

// Put the vehicle where we  want it.
_vehicle setVehiclePosition [_position , [], 0, "CAN_COLLIDE"];


if((_cfgInfo select 4) == "Autonomous") then
{
	createVehicleCrew _vehicle;
};

if(VVS_Checkbox) then
{
	clearWeaponCargoGlobal _vehicle;
	clearMagazineCargoGlobal _vehicle;
	clearItemCargoGlobal _vehicle;
};

_vehicle allowDamage true;
hint format["You have spawned a %1",_displayName];
closeDialog 0;
The new bits of code are: 
Checking if the respawn position is over water and them modifying the _postion variable. 
// Check if we are over water (and assume we are on the USS Freedom).
if ( surfaceIsWater _position ) then {
   _position = _position vectorAdd [0,0,24];
};
Respawn the vehicle safely.  This uses a template I like for safe vehicle respawn and the simple way seemed to cause problems with some vehicle spawning and other disappearing. 
/*
 * Spawn the requested vehicle.
 */

// Spawn vehicle somewhere where we can manipulate it.
_vehicle = createVehicle [_className, [0,0,10], [], 0, "CAN_COLLIDE"];

// Stop it being damaged.
_vehicle allowDamage false;

// Set the vehicle direction.
_vehicle setDir _direction;

// Put the vehicle where we  want it.
_vehicle setVehiclePosition [_position , [], 0, "CAN_COLLIDE"];
Hope this might help you.  S 

 

 

Share this post


Link to post
Share on other sites
4 minutes ago, Jnr4817 said:

THis is a solution from the VVS thread, but I need to work on land too.

 

This is supposed to work both in land and water as i see.

Just remove the CAN_COLLIDE to None

5 minutes ago, Jnr4817 said:

// Put the vehicle where we want it. _vehicle setVehiclePosition [_position , [], 0, "None"];

 

Share this post


Link to post
Share on other sites
1 hour ago, GEORGE FLOROS GR said:

 

This is supposed to work both in land and water as i see.

Just remove the CAN_COLLIDE to None

 

Did not work on freedom.

Share this post


Link to post
Share on other sites

nothing happened using UserTexture1m_F and 

_pos = getPosATL Spawn_pos_1;

I went back to using a marker it worked.

 

I may have jacked it up though, I am not a very good scripter. No errors though.

Share this post


Link to post
Share on other sites
2 hours ago, Jnr4817 said:

_position = getMarkerPos VVS_SP;

 

since you are using the code from above then you should use "_position" instead of _pos.

For the CAN_COLLIDE and the None , the can collide will always work faster but since we are talking about a vehicle and not for a building for example , you don't want the vehicle position collide with anything , this is why none is better

https://community.bistudio.com/wiki/createVehicle

 

Share this post


Link to post
Share on other sites

 

Ok, I can get land vehicles to spawn on the freedom with this code, but no Air vehicles will spawn on the freedom.

Air vehicles will spawn on land however, so weird.

Spoiler

/*
	File: fn_spawnVehicle.sqf
	Author: Bryan "Tonic" Boardwine
	
	Description:
	Spawns the selected vehicle, if a vehicle is already on the spawn point
	then it deletes the vehicle from the spawn point.
*/
disableSerialization;
private["_position","_direction","_className","_displayName","_spCheck","_cfgInfo"];
if(lnbCurSelRow 38101 == -1) exitWith {hint "You did not select a vehicle to spawn!"};

_className = lnbData[38101,[(lnbCurSelRow 38101),0]];
_displayName = lnbData[38101,[(lnbCurSelRow 38101),1]];
_position = getMarkerPos VVS_SP;

// Check if we are over water (and assume we are on the USS Freedom.
if ( surfaceIsWater _position ) then {
   _position = _position vectorAdd [0,0,24];
};

_direction = markerDir VVS_SP;

//Make sure the marker exists in a way.
if(isNil "_position") exitWith {hint "The spawn point marker doesn't exist?";};

//Check to make sure the spawn point doesn't have a vehicle on it, if it does then delete it.
_spCheck = nearestObjects[_position,["landVehicle","Air","Ship"],12] select 0;
if(!isNil "_spCheck") then {deleteVehicle _spCheck;};

_cfgInfo = [_className] call VVS_fnc_cfgInfo;

/*
 * Spawn the requested vehicle.
 */

 // Spawn vehicle somewhere where we can manipulate it.
_vehicle = createVehicle [_className, [0,0,10], [], 0, "None"];
//_vehicle = _className createVehicle _position;

// Stop it being damaged.
_vehicle allowDamage false;

//Set the vehicles direction the same as the marker.
_vehicle setDir _direction;

//Make sure it gets set onto the position.
//_vehicle setPosATL _position;
_vehicle setVehiclePosition [_position , [], 0, "None"];
//_vehicle setposatl [_this select 0, _this select 1, 200];


[_vehicle] spawn DEVAS_AutoPilot;
[_vehicle] spawn DEVAS_Loiter;

if((_cfgInfo select 4) == "Autonomous") then
{
	createVehicleCrew _vehicle;
};

if(VVS_Checkbox) then
{
	clearWeaponCargoGlobal _vehicle;
	clearMagazineCargoGlobal _vehicle;
	clearItemCargoGlobal _vehicle;
};

_vehicle allowDamage true;
hint format["You have spawned a %1",_displayName];
closeDialog 0;

 

 

Share this post


Link to post
Share on other sites

I recently added my own VVS script/dialog onto my server here is the section of code which Spawns the vehicle in any empty location 50 meters around the player. You will need to edit the code a little bit but from the snippet, you can see how I found the empty position. You also probably could just use an if true ExitWith statement on the count_emptyPosdir == 0 and not use an else statement to make it easier.

 

_VehicleSelected = lbCurSel 1;
    _classVeh = lbData[1, _VehicleSelected];
    _emptyPos = position player findEmptyPosition [5,50, _classVeh]; //Spawn A Vehicle 5-50M around player
    //_emptyPosDir = ( [ _emptyPos, 1, getDir player ] call BIS_fnc_relPos );
    if (count _emptyPosDir == 0) then {hint "Vehicle Cant be Spawned Here"; }
    else
    {
        _veh = createVehicle [_classVeh, _emptyPos, [], 0, ""];

        player moveInAny _veh;
        _veh setVehicleAmmo 0;
        _veh setVehicleAmmoDef 0;
        clearWeaponCargoGlobal _veh;
        clearMagazineCargoGlobal _veh;
        clearItemCargoGlobal _veh;
        clearBackpackCargoGlobal _veh;

        //if (Old_Vehicle_Spawned isEqualTo "") exitWith {closeDialog 18002;};
        //deleteVehicle Old_Vehicle_Spawned;
        //Old_Vehicle_Spawned = _veh;

    };

 

 

Also like to add that i am a begginer to programming in SQF so i may have done things wrong or in a long winded way if so any feedback is appreciated.

Share this post


Link to post
Share on other sites

Solved with this code.

Spoiler

/*
	File: fn_spawnVehicle.sqf
	Author: Bryan "Tonic" Boardwine
	
	Description:
	Spawns the selected vehicle, if a vehicle is already on the spawn point
	then it deletes the vehicle from the spawn point.
*/
disableSerialization;
private["_position","_direction","_className","_displayName","_spCheck","_cfgInfo"];
if(lnbCurSelRow 38101 == -1) exitWith {hint "You did not select a vehicle to spawn!"};

_className = lnbData[38101,[(lnbCurSelRow 38101),0]];
_displayName = lnbData[38101,[(lnbCurSelRow 38101),1]];
_position = getMarkerPos VVS_SP;

// Check if we are over water (and assume we are on the USS Freedom.
if ( surfaceIsWater _position ) then {
   _position = _position vectorAdd [0,0,24];
};

_direction = markerDir VVS_SP;

//Make sure the marker exists in a way.
if(isNil "_position") exitWith {hint "The spawn point marker doesn't exist?";};

//Check to make sure the spawn point doesn't have a vehicle on it, if it does then delete it.
_spCheck = nearestObjects[_position,["landVehicle","Air","Ship"],12] select 0;
if(!isNil "_spCheck") then {deleteVehicle _spCheck;};

_cfgInfo = [_className] call VVS_fnc_cfgInfo;

/*
 * Spawn the requested vehicle.
 */

 // Spawn vehicle somewhere where we can manipulate it.
//_vehicle = createVehicle [_className, [0,0,10], [], 0, "None"];
_vehicle = createVehicle [_className,_position, [], 0, "NONE"];
//_vehicle = _className createVehicle _position;

//Set the vehicles direction the same as the marker.
_vehicle setDir _direction;

// Stop it being damaged.
_vehicle allowDamage false;

//Make sure it gets set onto the position.
//_vehicle setPosATL _position;
//_vehicle setVehiclePosition [_position , [], 0, "None"];
_vehicle setposatl [_position select 0, _position select 1, 66];

//Make sure it gets sets upright.
_vehicle setVectorUP (surfaceNormal [(getPosatl _vehicle) select 0,(getPosatl _vehicle) select 1]);

[_vehicle] spawn DEVAS_AutoPilot;
[_vehicle] spawn DEVAS_Loiter;

if((_cfgInfo select 4) == "Autonomous") then
{
	createVehicleCrew _vehicle;
};

if(VVS_Checkbox) then
{
	clearWeaponCargoGlobal _vehicle;
	clearMagazineCargoGlobal _vehicle;
	clearItemCargoGlobal _vehicle;
};

_vehicle allowDamage true;
hint format["You have spawned a %1",_displayName];
closeDialog 0;

 

 

Share this post


Link to post
Share on other sites

I've got working on land again and spawning on freedom.

However the vehicle spawns several meters above the freedom deck

Thanks for any help.

Here is the most current code.

Spoiler

/*
	File: fn_spawnVehicle.sqf
	Author: Bryan "Tonic" Boardwine
	
	Description:
	Spawns the selected vehicle, if a vehicle is already on the spawn point
	then it deletes the vehicle from the spawn point.
*/
disableSerialization;
private["_position","_direction","_className","_displayName","_spCheck","_cfgInfo"];
if(lnbCurSelRow 38101 == -1) exitWith {hint "You did not select a vehicle to spawn!"};

_className = lnbData[38101,[(lnbCurSelRow 38101),0]];
_displayName = lnbData[38101,[(lnbCurSelRow 38101),1]];
_position = getMarkerPos VVS_SP;
_direction = markerDir VVS_SP;

//Make sure the marker exists in a way.
if(isNil "_position") exitWith {hint "The spawn point marker doesn't exist?";};

_cfgInfo = [_className] call VVS_fnc_cfgInfo;

//Check to make sure the spawn point doesn't have a vehicle on it, if it does then delete it.
_spCheck = nearestObjects[_position,["landVehicle","Air","Ship"],12] select 0;
if(!isNil "_spCheck") then {deleteVehicle _spCheck;};

//_vehicle = _className createVehicle _position;
_vehicle = createVehicle [_className,_position, [], 0, "NONE"];

_vehicle allowDamage false;

//Make sure it gets set onto the position.
//_vehicle setPos _position;
_vehicle setposatl [_position select 0, _position select 1, 0.5];

// Check if we are over water (and assume we are on the USS Freedom).
if ( surfaceIsWater _position ) then {
   _position = _position vectorAdd [0,0,25];
};

//Set the vehicles direction the same as the marker.
_vehicle setDir _direction;

//Make sure it gets sets upright.
//_vehicle setVectorUP (surfaceNormal [(getPosatl _vehicle) select 0,(getPosatl _vehicle) select 1]);

[_vehicle] spawn DEVAS_AutoPilot;
[_vehicle] spawn DEVAS_Loiter;

if((_cfgInfo select 4) == "Autonomous") then
{
	createVehicleCrew _vehicle;
};

if(VVS_Checkbox) then
{
	clearWeaponCargoGlobal _vehicle;
	clearMagazineCargoGlobal _vehicle;
	clearItemCargoGlobal _vehicle;
};

_vehicle allowDamage true;
hint format["You have spawned a %1",_displayName];
closeDialog 0;

 

 

Share this post


Link to post
Share on other sites
4 hours ago, Jnr4817 said:

I've got working on land again and spawning on freedom.

However the vehicle spawns several meters above the freedom deck

 

It will work better , if you do as i first told you about setting your position , with founding space to create this , in order to get the certain position.

 

9 hours ago, GEORGE FLOROS GR said:

you can create in the editor , on the freedom a UserTexture1m_F and name this somthing "Spawn_pos_1"

and then go to the script and :

 

if ( surfaceIsWater _position ) then {
   _position = getPosATL Spawn_pos_1;
};

 

Share this post


Link to post
Share on other sites
7 hours ago, GEORGE FLOROS GR said:

 

It will work better , if you do as i first told you about setting your position , with founding space to create this , in order to get the certain position.

 

 


if ( surfaceIsWater _position ) then {
   _position = getPosATL Spawn_pos_1;
};

 

I am running multiple instances of the VVS for different spawn areas around the map, they all cant be named Spawn_pos_1.

 

How can I manage this?

Share this post


Link to post
Share on other sites
1 hour ago, Jnr4817 said:

they all cant be named Spawn_pos_1.

 

This position is only for the ship

if ( surfaceIsWater _position ) then {

I haven't understand to be honest which part is the problem , the ship or the land ?

Share this post


Link to post
Share on other sites
1 hour ago, GEORGE FLOROS GR said:

 

This position is only for the ship


if ( surfaceIsWater _position ) then {

I haven't understand to be honest which part is the problem , the ship or the land ?

I have the land working well.

 

The ship is the issue. Let me test.

 

THanks for helping.

Share this post


Link to post
Share on other sites

Ok I tested your solution and no joy on the freedom. The land works well.

 

The vehicles are spawning, just under the ship in the water. Sometimes you can see it flash like its on the ship, then drops below the deck

Spoiler

disableSerialization;
private["_position","_direction","_className","_displayName","_spCheck","_cfgInfo"];
if(lnbCurSelRow 38101 == -1) exitWith {hint "You did not select a vehicle to spawn!"};

_className = lnbData[38101,[(lnbCurSelRow 38101),0]];
_displayName = lnbData[38101,[(lnbCurSelRow 38101),1]];
_position = getMarkerPos VVS_SP;

// Check if we are over water (and assume we are on the USS Freedom).
if ( surfaceIsWater _position ) then {
   _position = getPosATL Freedom_Spawn;
};

_direction = markerDir VVS_SP;

//Make sure the marker exists in a way.
if(isNil "_position") exitWith {hint "The spawn point marker doesn't exist?";};

_cfgInfo = [_className] call VVS_fnc_cfgInfo;

//Check to make sure the spawn point doesn't have a vehicle on it, if it does then delete it.
_spCheck = nearestObjects[_position,["landVehicle","Air","Ship"],12] select 0;
if(!isNil "_spCheck") then {deleteVehicle _spCheck;};

//_vehicle = _className createVehicle _position;
_vehicle = createVehicle [_className,_position, [], 0, "NONE"];

_vehicle allowDamage false;

//Make sure it gets set onto the position.
//_vehicle setPos _position;
_vehicle setposatl [_position select 0, _position select 1, 0.2];

_vehicle setDir _direction; //Set the vehicles direction the same as the marker.

//Make sure it gets sets upright.
//_vehicle setVectorUP (surfaceNormal [(getPosatl _vehicle) select 0,(getPosatl _vehicle) select 1]);

[_vehicle] spawn DEVAS_AutoPilot;
[_vehicle] spawn DEVAS_Loiter;

if((_cfgInfo select 4) == "Autonomous") then
{
	createVehicleCrew _vehicle;
};

if(VVS_Checkbox) then
{
	clearWeaponCargoGlobal _vehicle;
	clearMagazineCargoGlobal _vehicle;
	clearItemCargoGlobal _vehicle;
};

_vehicle allowDamage true;
hint format["You have spawned a %1",_displayName];
closeDialog 0;

 

 

Share this post


Link to post
Share on other sites
35 minutes ago, Jnr4817 said:

//Make sure it gets set onto the position. //_vehicle setPos _position;

_vehicle setposatl [_position select 0, _position select 1, 0.2];

 

change also this and tell me :

_vehicle setposatl [(_position select 0) , (_position select 1) , (_position select 2)];

 

  • Thanks 1

Share this post


Link to post
Share on other sites
Just now, GEORGE FLOROS GR said:

 

change also this and tell me :


_vehicle setposatl [(_position select 0) , (_position select 1) , (_position select 2)];

 

Works great from testing in the editor, Ill test on dedicated after I load your autoPop script.

 

Can you explain why this worked for my knowledge base?

 

Thanks again for the help,

Reed

  • Thanks 1

Share this post


Link to post
Share on other sites

makes since, thank you very much.

  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×