Jump to content
André Krauß

Trying to get Virtual Garage Spawner to work

Recommended Posts

Hey,

 

with the introduction of Tanks DLC i tried to make a Virtual Garage Vehicle spawner that lets me configure addons and camo. This post was very helpful and custom spawning worked great. But i got one remaining problem: Spawned vehicles are invincible. I cannot for the live of me find a way in the wiki as to how to reference to the just spawned vehicle and set allowdamage to true. Any help would be appreciated.

Share this post


Link to post
Share on other sites

Thanks, that helped somewhat.

I got it to atleast make the vehicle damagable with the following script, partially from your link.

 






_pos = player getPos [30,getDir player]; 
_spawner = createVehicle [ "Land_HelipadEmpty_F", _pos, [], 0, "CAN_COLLIDE" ];  

["Open",[ true, _spawner ]] call BIS_fnc_garage;
{_x allowDamage true;} forEach nearestObjects [_pos, [], 5];

 

Here the problem is that, if you change the vehicle you want to spawn in the garage, it doesn't work anymore so i would need to initialize {_x allowDamage true;} forEach nearestObjects [_pos, [], 5]; after the garage is closed.

So i tried it with this eventhandler:
 

[ missionNamespace, "garageClosed", 
{
	{_x allowDamage true;} forEach nearestObjects [_pos, [], 5];
}]; 
call BIS_fnc_addScriptedEventHandler;

 

Which unfortunately produces an error.

 

 

 

 

Share this post


Link to post
Share on other sites
On 5/7/2018 at 11:12 PM, André Krauß said:

call BIS_fnc_addScriptedEventHandler;

 

Hello there André Krauß !

 

Just for the story this should be like :

[this,[
    "<t size=""1.2"" font=""RobotoCondensedBold"" color=""#FF9933"">" + "Open Spawner",
    {
        params ["_target", "_caller", "_actionId", "_arguments"];
		Spawner_pos = [getPos _target, 1, 100, 3, 0, 20, 0] call BIS_fnc_findSafePos;
		BIS_fnc_garage_center = createVehicle ["Land_HelipadEmpty_F", Spawner_pos, [], 0, "CAN_COLLIDE"]; 
		[missionNamespace, "garageClosed",{
			{_x allowDamage true;}forEach nearestObjects [Spawner_pos, [], 5];
		}]call BIS_fnc_addScriptedEventHandler;
		["Open",true] call BIS_fnc_garage;
    },[], 1.5,true,true,"","true",8,false,"",""
]]remoteExec["addAction"];

 

I noticed also someones who have create a spawner from the garage :

 

 

 

Share this post


Link to post
Share on other sites

Not tested that much , but seems to be working :

 

//	in the init
GF_VSpawner = {

	_nearestObjects = BIS_fnc_garage_center nearEntities [["Car","Tank","Ship","Air"], 1];
	{deletevehicle _x}forEach _nearestObjects;
	_Object = selectrandom _nearestObjects;
	_typeOf = typeOf _Object;
	_createVehicle = createVehicle [_typeOf, GF_VSpawner_pos, [], 0, "None"];
};


[missionNamespace, "garageClosed",{
	[]call GF_VSpawner;
}]call BIS_fnc_addScriptedEventHandler;


/*
//	in the init of an object
[this,[
    "<t size=""1.2"" font=""RobotoCondensedBold"" color=""#FF9933"">" + "Open Spawner",
    {
        params ["_target", "_caller", "_actionId", "_arguments"];
		GF_VSpawner_pos = [getPos _target, 1, 100, 3, 0, 20, 0] call BIS_fnc_findSafePos;
		BIS_fnc_garage_center = createVehicle ["Land_HelipadEmpty_F", GF_VSpawner_pos, [], 0, "CAN_COLLIDE"]; 
		["Open",true] call BIS_fnc_garage;
    },[], 1.5,true,true,"","true",8,false,"",""
]]remoteExec["addAction"];

Share this post


Link to post
Share on other sites

Some big improvement :

Spoiler




//________________	Author : GEORGE FLOROS [GR]	___________	20.06.19	_____________ 


/*
________________ GF VSpawner Script - Mod	________________



Please keep the Credits or add them to your Diary

https://community.bistudio.com/wiki/SQF_syntax
Don't try to open this with the simple notepad.
For everything that is with comment  //  in front  or between /*
means that it is disabled , so there is no need to delete the extra lines.

You can open this ex:
with notepad++
https://notepad-plus-plus.org/

and also use the extra pluggins
(this way will be better , it will give also some certain colors to be able to detect ex. problems )
http://www.armaholic.com/page.php?id=8680

or use any other program for editing .

For the Compilation List of my GF Scripts , you can search in:
https://forums.bohemia.net/forums/topic/215850-compilation-list-of-my-gf-scripts/
*/


/*
To use the script add this code to the init field of an object :
	nul = this spawn {waitUntil {!isNil "GF_VSpawner"}; call GF_VSpawner;};
*/


//________________ Settings ________________
//________________ Set true or false  ________________

GF_VSpawner_Systemchat_info				= true;		
GF_VSpawner_Hintsilent_info				= true;
GF_VSpawner_diag_log_info				= true;
GF_VSpawner_Max_distance				= 100;



if(GF_VSpawner_Systemchat_info)then{
	systemchat "GF VSpawner Script initializing";			
};	

if(GF_VSpawner_diag_log_info)then{
	diag_log "//________________ GF VSpawner Script initializing ________________";
};




GF_VSpawner_Closed = {

	_nearestObjects = BIS_fnc_garage_center nearEntities [["Car","Tank","Ship","Air"], 1];
	if(!isNil "_nearestObjects")then{
		_Object = selectrandom _nearestObjects;
		_veh = typeOf _Object;
		_textures = getObjectTextures _Object;
		_animationNames = animationNames _Object;
		{deletevehicle _x}forEach _nearestObjects;
		_position = GF_VSpawner_pos findEmptyPosition [10,GF_VSpawner_Max_distance,_veh];
		_createVehicle = createVehicle [_veh, _position, [], 0, "None"];
	
		if(count _textures > 0)then{
			_count = 0;
			{
				_createVehicle setObjectTextureglobal[_count,_x];
				_count = _count + 1;
			}forEach _textures;
		};
		
		if(count _animationNames > 0)then{
			_animationPhase = [];
			for '_i' from 0 to count _animationNames -1 do{
				_animationPhase pushBack[_animationNames select _i,_Object animationPhase(_animationNames select _i)];
				{_createVehicle animate _x}forEach _animationPhase;
			};
		};
	};
};


[missionNamespace, "garageClosed",{
	[]call GF_VSpawner_Closed;
}]call BIS_fnc_addScriptedEventHandler;


GF_VSpawner	= {

	[_this,[
		"<t size=""1.2"" font=""RobotoCondensedBold"" color=""#FF9933"">" + "Open Spawner",
		{ 
			params ["_target", "_caller", "_actionId", "_arguments"];
	  GF_VSpawner_pos = [getPos _target, 1, GF_VSpawner_Max_distance, 3, 0, 20, 0] call BIS_fnc_findSafePos;
	  BIS_fnc_garage_center = createVehicle ["Land_HelipadEmpty_F", GF_VSpawner_pos, [], 0, "CAN_COLLIDE"];
	  ["Open",true] call BIS_fnc_garage;
		},[], 1.5,true,true,"","true",8,false,"",""
	]]remoteExec["addAction"];
};


if(GF_VSpawner_Systemchat_info)then{
	systemchat "GF VSpawner Script initialized";			
};	

if(GF_VSpawner_diag_log_info)then{
	diag_log "//________________ GF VSpawner Script initialized ________________";
};

+ test mission :

+GF_VSpawner_Script.Stratis.zip

Expires in: 29 days 20:55:08   |   Size: 7.5 KB   | 21.06.19

 

16 minutes ago, GEORGE FLOROS GR said:

Working with mods + extras :

 

this is from @CUP mod :

84rIHUH.png0xGKJ8I.pngU8IrBXv.png

Share this post


Link to post
Share on other sites

Do I set an object that spawns the vehicle or is it just an addaction?

 

Does it work on the USS Freedom?

  • Like 1

Share this post


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

Do I

 

Hello there Jnr4817 !

 

You need to add this in an object ( or a man ) and it's not tested in USS Freedom , though even if it doesn't , it can be fixed.

Would you like to give it a try ?!

Share this post


Link to post
Share on other sites

Ok,

 

Tested with CUP and MELB and RHS.

 

The multiple aircraft options that CUP has for example, the UH-60M has several different variations. These are not spawned with any weapons if you use the garage and hide and unhide certain things, like the ESSS-4x weapons pylons.

 

The spot, the spawner pics is random. It would not work on the USS Freedom, always defaulted to the ground on land somewhere.

 

Some vehicles, like the CH-53 Stallion would spawn with wheels below ground.

 

Here is the fn_spawnVehicle functions VVS uses to spawn stuff on ground and USS Freedom at the spot you choose, usually marker. I have modified a little to add certain scripts to the spawning vehicle and make it spawn on the freedom with the help of several others, troubleshooting.

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 = 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;};

//Creating vehicle

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

_vehicle allowDamage false;

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

//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;
[_vehicle, ["Embark AI Crew", "SA\scripts\SSAIG12.sqf", [_vehicle, true, true, true, true, west, nil, 1800], 0, true, true, "", "true", -1, false, "", ""]] remoteExec ["addAction",0, true];


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;

 

 

  • Like 1

Share this post


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

Here is the fn_spawnVehicle functions VVS uses to spawn stuff on ground and USS Freedom at the spot you choose, usually marker.

 

Thanks i'll check it !

If i remember i had helped you modifying this script or it was someone else ?

Share this post


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

The spot, the spawner pics is random. It would not work on the USS Freedom, always defaulted to the ground on land somewhere.

 

I forgot to answer ,

this is because i have fix this to find an empty spawn position , not a certain one, though as said this can change.

Share this post


Link to post
Share on other sites

You did help me, I went back and looked at the credits.sqf and I listed you.

 

Thanks

  • 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

×