Jump to content
Sign in to follow this  
anthonyfromtheuk

Spawn vehicle with working way point to player

Recommended Posts

I am trying to make a spawned ifrit move towards the player preferably to attempt to kill him. below is what i am trying to use but the ifrit is just not moving, spawns in fine but no movement.

_ifrit1 = [(getmarkerPos "ifrit"), 316, "O_MRAP_02_hmg_F", east] call BIS_fnc_spawnVehicle;
_ifrit1 move (getPosATL player);

can anybody help?

Share this post


Link to post
Share on other sites

Try this:

_ifrit1 = [(getmarkerPos "ifrit"), 316, "O_MRAP_02_hmg_F", east] call BIS_fnc_spawnVehicle;
_group_ifrit1 = _ifrit1 select 2;
_wp = _group_ifrit1 addWaypoint [getPosATL player, 0];
_wp setWaypointBehaviour "COMBAT";
_wp setWaypointCombatMode "RED";
_wp setWaypointCompletionRadius 0;
_wp setWaypointFormation "WEDGE";
_wp setWaypointSpeed "FULL";
_wp setwaypointType "MOVE";

(The return: _ifrit1 is an array containing the vehicle, the crew and the group).

Share this post


Link to post
Share on other sites

When you spawned the ifrit, the format from BIS_fnc_spawnVehicle gives you a return (which you called _ifrit1)

This is actually an array, in this format:

_ifrit1 select 0; // is the vehicle
_ifrit1 select 1; // is the crew
_ifrit1 select 2; // is the group

And when you assign a waypoint, you need to reference the group.

In your initial example, you were also using a low level command (which I think only works with FSM's).

If you need units to move somewhere, try using doMove or commandMove.

If you get stuck with commands, look them up on this page:

http://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3

and check the syntax to see what needs to be input as arguements (and what gets returned).

Hope that helps you :)

Share this post


Link to post
Share on other sites

Thanks for the explanation that made me understand enough to use a script I was using to spawn infantry that actively hunt the player, now I can get vehicles to do that too! If anybody is interested This is what I am using to spawn an ifrit that hunts me down.

//place a marker named ifrit. 
//Save this code as ifrit.sqf to your mission folder
//Call it with a trigger with this in the ON ACT: nul = execVM "ifrit.sqf"; hint "ifrit inbound"; 
(!isServer) exitwith {};
private ["_side", "_leader"];
_side = createCenter EAST;
_ifrit1 = [(getmarkerPos "ifrit"), 316, "O_MRAP_02_hmg_F", east] call BIS_fnc_spawnVehicle;

_group_ifrit1 = _ifrit1 select 2;
_leader = leader _group_ifrit1;
_leader move (getPosATL player);
_group_ifrit1 setCombatMode "RED";
_group_ifrit1setBehaviour "Aware";

0 = _group_ifrit1 spawn {
   while {true} do {
       sleep 5;
       if ((player distance (leader _this)) > 3000) exitWith {
           {
               deleteVehicle _x;
           } forEach (units _this);
       };
   };
};
while {true} do {
   sleep 5;

   if (({ alive _x} count (units _Squad3)) == 0) exitWith {
       {
           deleteVehicle _x;
       } forEach (units _group_ifrit1);
       deleteGroup _group_ifrit1;
   };

   _leader = leader _group_ifrit1;
   if ((unitReady _leader) && {(alive _leader)}) then {
       sleep 10;
       if (({ alive _x} count (units _group_ifrit1)) != 0) then {
           _leader = leader _group_ifrit1;
           _leader move (getPosATL player);
           _group_ifrit1 setCombatMode "RED";
           _group_ifrit1 setBehaviour "Aware";
       };
   };
};
//Credit to Cobra4v320 and Zenophon for helping me with the original script for infantry.
//Credit to Das Attorney for helping me understand how to use this with vehicles. Anthonyfromtheuk.

The ifrit can be a bit retarded on its way to the player but it always ends up at the player eventually :D

Edited by Anthonyfromtheuk

Share this post


Link to post
Share on other sites

Perhaps you may be able to help me again I am trying to spawn a boat with a squad incargo that will unload at a waypoint and then move to player. This is what I am trying

_boat = [(getmarkerPos "boatmark"), 316, "B_Boat_Transport_01_F", west] call BIS_fnc_spawnVehicle;
_boatv = _boat select 0;
_group_boat = _boat select 2;
_group_boat allowfleeing 0;
_wp = _group_boat addWaypoint [getmarkerpos "unload", 0];
_wp setWaypointBehaviour "AWARE";
_wp setWaypointCombatMode "RED";
_wp setWaypointCompletionRadius 0;
_wp setWaypointFormation "FILE";
_wp setWaypointSpeed "NORMAL";
_wp setwaypointType "unload";

_side = west;
_boatgroup = [getMarkerPos "boatgroup", _side, ["B_Soldier_GL_F", "B_soldier_AT_F", "B_Soldier_SL_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup;
_leader = leader _boatgroup;
_leader move (getPosATL player);
_boatgroup setCombatMode "RED";
_boatgroup setBehaviour "Aware";
_boatgroup moveInCargo _boatv;

the squad and boat spawn. boat moves to unload point but I cannot seem to get the squad in the boat, I have tried multiple variations on this including trying to use a trigger to get them in the boat and just cannot figure it out, I understand how to get units to move in cargo when I have placed them in the editor but this spawning business is confusing to me. When I have spawned _boat what name does that have? is the name "_boat" or "boat"

-----UPDATE---- This is driving me insane tried so many things now I can get just the leader on the boat but that brought up another problem how to get him to join my group. Just to be sure I can do that I have just spawned one unit on the ground and want him to move to me and join, he moves to me with this code but doesn't join group???? I can make him join the group as soon as he is spawned but then he is so far away, I don't want him to join until he is within 200m. SO much trial and ERROR!

if (!isServer) exitwith {};
private ["_side", "_reinforce", "_leader"];
_side = west;
_reinforce = [getMarkerPos "reinforce", _side, ["B_soldier_AR_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup;

_leader = leader _reinforce;
_leader move (getPosATL player);
_reinforce setCombatMode "RED";
_reinforce setBehaviour "Aware";
if ((player distance (_reinforce)) < 200) then
           [_reinforce] joinSilent player;

Edited by Anthonyfromtheuk

Share this post


Link to post
Share on other sites

@Anthonyfromtheuk

Curious, what does the 316 mean in your code?

Been looking into this myself. Trying to setup so OPFOR will start to hunt you

down when Triggered, but they only went to the cords you were standing at

when code ran and not update to your newest current location.

Does yours make the enemy continue to track/follow you? Also wanted a version

to use CIVs as well (terrorists) to hunt you down with suicide vest. I have the

vest part but same issue, won't continue to track. Will have to try yours out.

Share this post


Link to post
Share on other sites

Yeah this stuff above is for a vehicle to do that, but its from an infantry based script I got with help from people on this forum. Strangely this forum only goes so far back when I look at what posts I have made so I cannot link you to the thread but heres the script. Spawns few infantry who then actively hunt the player. It also deletes them if they are more than 3000m away and supposedly when they are dead but it just seems to clear away the last member of the group you kill.

if (!isServer) exitwith {}; 
private ["_side", "_Squad1", "_leader"];
_side = createCenter EAST;  
_Squad1 = [getMarkerPos "spawn", _side, ["o_soldier_TL_F", "O_soldier_AA_F", "o_soldier_AA_F", "o_soldier_AA_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup; 

_leader = leader _Squad1; 
_leader move (getPosATL player); 
_Squad1 setCombatMode "RED"; 
_Squad1 setBehaviour "Aware"; 

0 = _Squad1 spawn { 
   while {true} do { 
       sleep 5; 
       if ((player distance (leader _this)) > 3000) exitWith { 
           { 
               deleteVehicle _x; 
           } forEach (units _this); 
       }; 
   }; 
}; 

while {true} do { 
   sleep 5; 

   if (({ alive _x} count (units _Squad1)) == 0) exitWith { 
       { 
           deleteVehicle _x; 
       } forEach (units _squad1); 
       deleteGroup _Squad1; 
   }; 

   _leader = leader _Squad1; 
   if ((unitReady _leader) && {(alive _leader)}) then { 
       sleep 10; 
       if (({ alive _x} count (units _Squad1)) != 0) then { 
           _leader = leader _Squad1; 
           _leader move (getPosATL player); 
           _Squad1 setCombatMode "RED"; 
           _Squad1 setBehaviour "Aware"; 
       }; 
   }; 
};

I had the same problem that they would only move to the position of where I was when they spawned to beginning with, but Cobra4v320 and Zenophon on this forum got it working for me. You will need a marker placed on the map named spawn.

_leader = leader _Squad1;

if ((unitReady _leader) && {(alive _leader)}) then {

sleep 10;

if (({ alive _x} count (units _Squad1)) != 0)

that makes the difference it checks if they are alive and if they are it waits 10 then checks again and resets them on their way to the player

---------- Post added at 14:52 ---------- Previous post was at 14:28 ----------

Also wanted a version

to use CIVs as well (terrorists) to hunt you down with suicide vest.

If you get a working version of that please link me it, Id like that to. I think all you would need is that script above and a trigger to blow them up when within a certain distance of the player and perhaps turn of some of the AI so they don't run away when bullets start flying. Edited by Anthonyfromtheuk
I think the 316 is direction.

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  

×