Jump to content
Sign in to follow this  
jandrews

Best way to spawn veh after killed or ammo depleted.

Recommended Posts

Hey all. Was wondering the best way or if this has already been listed here. I googled with little luck.

Anyhow, I would like to have a boat and aa vehicle spawn at random locations to cause headaches to players:). Not very sure how to do this. Any ideas . And then have them respawn once killed or ammo depleted. Most likely killed as players will need to destroy them. I figure the vehicles will patrol a large area so giving them unlimited fuel.

Ideas or links to already listed threads. Thanks!

Share this post


Link to post
Share on other sites

Ok, I know, post your code and may be we can help. I understand. This is where i am so far. I am not sure how to:

 

A. RESPAWN this stuff once the vehicle is dead ( I have read using eventkilled) or

 

B. how to delete the vehicle IF it becomes "stuck" somehow for say 10 minutes or so. You know arma driving.

// unit spawns on getPos, unit deletes from several ways (dead or stuck)
// nul = [] execVM "WaterPatrol.sqf";

if (!isServer) exitWith {};

// game logic markers
// random position for patrol

_water = getPos ([water1, water2, water3, water4, water5] call BIS_fnc_selectRandom);

_boatGroup = createGroup east;
    _boat = "I_Boat_Armed_01_minigun_F" createVehicle _water;
    waitUntil{!isNull _boat};
    _boat setVehicleAmmo 1;
    _boat setFuel 1;
    _boat allowCrewInImmobile true;
        "I_C_Soldier_Para_7_F" createUnit [_water,_boatGroup];
        "I_C_Soldier_Para_2_F" createUnit [_water,_boatGroup];
        "I_C_Soldier_Para_3_F" createUnit [_water,_boatGroup];
        ((units _boatGroup) select 0) assignAsDriver _boat;
        ((units _boatGroup) select 0) moveInDriver _boat;
        ((units _boatGroup) select 1) assignAsGunner _boat;
        ((units _boatGroup) select 1) moveInGunner _boat;
        ((units _boatGroup) select 2) assignAsCommander _boat;
        ((units _boatGroup) select 2) moveInCommander _boat;
    [_boatGroup, getPos _water, 3500] call BIS_fnc_taskPatrol;

// wait for dead or stuck

waitUntil { sleep 5; !(alive _boat) or ()};

sleep 10;
deleteGroup _boatGroup;

Lastly, I am always open to suggestions for more efficient code. Am no novice here. :)

Share this post


Link to post
Share on other sites

Ok I found entity killed event handler. However not sure how to use it.

_id = addMissionEventHandler ["entitykilled",{ _this execVM "my.sqf" }];

How do I tie this in to the boat being dead?

Share this post


Link to post
Share on other sites

_boat = addMissionEventHandler ["entitykilled",{ _this execVM "WaterPatrol.sqf" }];

Do I place this in the init.sqf? Anyone know if this is how this works? Am not at PC now. Will try later.

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  

×