Jump to content
Sign in to follow this  
lockjaw-65-

create vehicle with name

Recommended Posts

Been working on this for a long time now on and off. Im at the stage where I have lots of objectives and at each one I have a lot of things that spawn as we have mentioned. Once the objective is complete and I dont need them what is the best way to delete them. I have tried garbage removel and a couple of other scritps but none of them remove the items? has anybody got any suggestions?

1 way of doing it, run my DMZ Delete script in your mission (will clean the mission for you aswell, fully customizable btw) and use the DMZ_include option on each of the spawned objects.

or another way, create a global array:

objectiveObjects = [];  // global array that can be acessed from anywhere.
// now add all objects spawned into the array.
_obj = createVehicle ["some_object", some_position, [], 0, "NONE"];
objectiveObjects = objectiveObjects + [_obj];  // add the object to the array.

reason for using a global array is that you can use it from triggers etc later on, for example on task complete or no opfor present etc...

{deleteVehicle _x} foreach objectiveObjects;  // all objects deleting from array.

Or you can create a local array in the spawning script and just wait or transfer the array to a objective complete part and then delete it at will.

Share this post


Link to post
Share on other sites

@Giallusto. Your method works fine for the vehicles and objects. Im using your script that you posted earlier in this thread which spawns the crew for the named vehicles. deleteVehicle objectName; deletes the vehicles etc ok but the crew is still there, how would I delete the crew??

@Demonized, thanks for your help. Your script was one of the ones I tried before but could not get it to work. Im not sure if its because I have DACS 3 running at the same time..

Share this post


Link to post
Share on other sites

I'm away from my PC, but try something like:

{deleteVehicle _x;} foreach crew vehicleName;
deleteVehicle vehicleName;

Share this post


Link to post
Share on other sites

The above will work but if you want to delete several units in one go this will do that

{{deleteVehicle _x} foreach crew _x+[_x]} foreach [objectName,objectName,objectName] 

Share this post


Link to post
Share on other sites

Ok thanks...

this is whats in the call trigger for the first objective.

[tas1] call DAC_Activate;

_spawn = [getmarkerpos "air1", "2S6M_Tunguska", "aa1",180] execVM "mission1a.sqf";  

_spawn = [getmarkerpos "air2", "2S6M_Tunguska", "aa2",180] execVM "mission1b.sqf";  

_spawn = [getmarkerpos "def1", "RU_WarfareBMGNest_PK", "def1a",280] execVM "mission1aa.sqf"; 

_spawn = [getmarkerpos "def2", "RU_WarfareBMGNest_PK", "def1b",290] execVM "mission1ab.sqf";  

_spawn = [getmarkerpos "def3", "SPG9_Gue", "def1c",280] execVM "mission1ac.sqf";  

_spawn = [getmarkerpos "def4", "Land_Fort_Watchtower", "def1d",315] execVM "mission1ad.sqf"; 

_spawn = [getmarkerpos "def5", "SPG9_Gue", "def1e",335] execVM "mission1ae.sqf"; 

_spawn = [getmarkerpos "def6", "RU_WarfareBMGNest_PK", "def1f",75] execVM "mission1af.sqf";  

_spawn = [getmarkerpos "def7", "SPG9_Gue", "def1g",75] execVM "mission1ag.sqf";  

Each one of these has the script:

_spawn_zone = _this select 0;
_veh_type = _this select 1;
_name = _this select 2;
_dir = _this select 3;// new

_group = createGroup east;
_veh = createVehicle [_veh_type, _spawn_zone, [], 0, "NONE"];
_gunner = _veh emptyPositions "gunner";
_commander = _veh emptyPositions "commander";
_cargo = (_veh emptyPositions "cargo") - 1;
"MVD_Soldier" createUnit [_spawn_zone, _group, "this moveinDriver _veh;this assignAsDriver _veh;"];
if (_gunner > 0) then {"MVD_Soldier" createUnit [_spawn_zone, _group, "this moveinGunner _veh;this assignAsGunner _veh;"];};
if (_commander > 0) then {"MVD_Soldier" createUnit [_spawn_zone, _group, "this moveinCommander _veh;this assignAsCommander _veh;"];};
for "_i" from 0 to _cargo do
{
"MVD_Soldier" createUnit [_spawn_zone, _group, "this moveinCargo _veh;this assignAsCargo _veh;"];
};

_veh setdir _dir;// new
_veh SetVehicleVarName _aa1;
call compile format["%1 = _veh", _name];  

Once all the units are dead i have another trigger with this:

["tas1"] call DAC_fDeleteZone; {{deleteVehicle _x} foreach crew _x+[_x]} foreach [def1a,def1b,def1c,def1d,def1e,def1f,def1g,aa1,aa2]

This deletes the objects but not the units. I think with the tungstas the crew gets deleted but I will have to check that again

Edited by LockJaw-65-

Share this post


Link to post
Share on other sites

Get it!

I didn't see that you spawn a static.

You have to modify the code, just few lines:

_spawn_zone = _this select 0;
_veh_type = _this select 1;
_name = _this select 2;
_dir = _this select 3;// new

_group = createGroup east;
_veh = createVehicle [_veh_type, _spawn_zone, [], 0, "NONE"];
_driver = _veh emptyPositions "driver";
_gunner = _veh emptyPositions "gunner";
_commander = _veh emptyPositions "commander";
_cargo = (_veh emptyPositions "cargo") - 1;
if (_driver > 0) then {"MVD_Soldier" createUnit [_spawn_zone, _group, "this moveinDriver _veh;this assignAsDriver _veh;"];};
if (_gunner > 0) then {"MVD_Soldier" createUnit [_spawn_zone, _group, "this moveinGunner _veh;this assignAsGunner _veh;"];};
if (_commander > 0) then {"MVD_Soldier" createUnit [_spawn_zone, _group, "this moveinCommander _veh;this assignAsCommander _veh;"];};
for "_i" from 0 to _cargo do
{
"MVD_Soldier" createUnit [_spawn_zone, _group, "this moveinCargo _veh;this assignAsCargo _veh;"];
};
_veh setdir _dir;// new
_veh SetVehicleVarName _name;
call compile format["%1 = _veh", _name];

Try now and let me know! ;)

Edited by Giallustio

Share this post


Link to post
Share on other sites

Also it seems this line isn't needed

_veh SetVehicleVarName _aa1;

_aa1 is never set to anything but the script works anyway.

If you do need SetVehicleVarName it would be

_veh SetVehicleVarName _name;

The difference is that without it will return something like O-1-1:b3 and setting the name would return the given name aa1 ect.

Also your still using multiple scripts just use one example :-

_spawn = [getmarkerpos "air1", "2S6M_Tunguska", "aa1",180] execVM "mission1a.sqf";

_spawn = [getmarkerpos "air2", "2S6M_Tunguska", "aa2",180] execVM "mission1a.sqf";

ect

You don't need a separate script to create each vehicle

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Thanks your a great help. wish I knew about the seperate scripts before, I have done over 50 objectives like that lol.

I will test these later thanks.

So can I use that script for all now?

Share this post


Link to post
Share on other sites

Just tested and same thing the objects get deleted but the crew still there even on the tungstas?

Share this post


Link to post
Share on other sites

I tested it in the editor.

Here my init.sqf:

_spawn = [getmarkerpos "air1", "2S6M_Tunguska", "aa1",180] execVM "mission1a.sqf";
_spawn = [getmarkerpos "def1", "RU_WarfareBMGNest_PK", "def1a",280] execVM "mission1aa.sqf";

And in the trigger:

{deletevehicle _x;} foreach crew aa1;
{deletevehicle _x;} foreach crew def1a;
deletevehicle aa1;
deletevehicle def1a;

Did you update my code?

Share this post


Link to post
Share on other sites

Just tested again. I made sure all code was correct I copy and paste it. Ok the tungsta and crew get deleted, the mg nest gets deleted but the mg man remains dead on floor.

Share this post


Link to post
Share on other sites

That would be because if the gun gets damaged the gunner gets out and is no longer part of that unit so when the vehicle gets deleted it won't delete the old crew.

Share this post


Link to post
Share on other sites

Of course! would garbage collector module remove them?

Im not sure that it works very well anyway.

Edited by LockJaw-65-

Share this post


Link to post
Share on other sites

Use this:

BTC_delete_corps =
{
//_delete = [1,60,15] spawn BTC_delete_corps;
_repetelly = _this select 0;
_time      = _this select 1;
_max_corps = _this select 2;
if ((count alldead) > _max_corps) then 
{
	{if (_x isKindOf "Man") then {hideBody _x; sleep 1.5;deletevehicle _x};} foreach alldead;
};
if (_repetelly == 1) then {sleep _time;_delete = [_repetelly,_time,_max_corps] spawn BTC_delete_corps;};
};

Share this post


Link to post
Share on other sites

Well...There're a lot of way to use this...

Copy this into your init.sqf and after the code add this line:

_delete = [1,60,15] spawn BTC_delete_corps;

You can modify the numbers in the []:

First -> set 0 if you want to execute the code just one time;

Second -> it's the delay;

Third -> Max dead corps allowed;

If your mission it's MP run the script on the server:

if (isServer) then {_delete = [1,60,15] spawn BTC_delete_corps;};

Share this post


Link to post
Share on other sites

Just finished the main part of the campaign im doing, apart from a few bug fixes everything seems to work fine now. Many thanks for your help with this @ Giallustio &

F2K Sel. Something that I have noticed however is the behaviour of the spawned units. An example: im part of a tank squad attacking a town, lots of activity going on I spot a static mg drive right up to it, get out and shoot the operator. All this time He did not move BTW he was facing the other way but I have also noticed other units and they just seem really dumb. Is there a way to set the behaviour of the spawned units??

Share this post


Link to post
Share on other sites

You need to place a unit of that side on the map, it can have a probability of zero but it needs one or they will be dumb.

It's either a bug or feature of createcenter.

Share this post


Link to post
Share on other sites

I dont think that is the problem as I have 43 AI pre-placed on the map to stop triggers activating etc.

Share this post


Link to post
Share on other sites

I find MG's are quite dumb at the best of times, usually people make a scan script to make them turn around at random.

Share this post


Link to post
Share on other sites

static weapons are terrible because of the grouping problem they cause - if you group a static weapon to an active group, he will always be ordered to fall back - if you have enough statics linked to groups, this will destroy your fps because all leaders are ordering the statics to return to formation. So when you create statics that are their own groups, they are very dumb and completely oblivious to enemy, because they dont share information with any other members (they are the only member in group, unless you add a spotter of some sort of them)

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
Sign in to follow this  

×