Jump to content
ChaIie

AI with alive limit and respawn after death

Recommended Posts

Hello everyone,

Im really new to scripting. I've been looking for days how to create this script

The script i want works like this: 2 AI vehicles spawn at a marker. those AI targeting me. when those 2 AI died, 2 new will respawn at marker.

 

The only thing i've done so far is this:


while {true} do {

_Spawntarget = Soldier1;   <--Me
_veh = createVehicle ["RHS_T50_vvs_blueonblue", getMarkerPos "marker_plane2", [], 0, "NONE"];
createVehicleCrew _veh;

sleep 10;
};
 

How do i make the script so only 2 will spawn and respawn after those 2 died?

 

Also how can i implement those 3 commands to it?

 

setBehaviour "COMBAT";
setSpeedMode "FULL";
setCombatMode "RED";

 

Im really sorry if the script i poor and probably wrong. I really have no idea how this works 😞 i just want to have fun

Thanks for any help

 

Share this post


Link to post
Share on other sites

Hi and welcome to the BI forums!

Here's an example using for command.

Cheers.

while {true} do {
	private _units = [];
	for "_i" from 0 to 1 do {
		private _veh = createVehicle ["RHS_T50_vvs_blueonblue", getMarkerPos "marker_plane2", [], 0, "NONE"];
		private _group = createVehicleCrew _veh;
		_group setBehaviour "COMBAT";
		_group setSpeedMode "FULL";
		_group setCombatMode "RED";
		_units append (units _group);
		sleep 10;
	};
	waitUntil {_units select {alive _x} isEqualTo []};
	sleep 10;
};
Edited by RCA3
added sleep between each createVehicle

Share this post


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

Hi and welcome to the BI forums!

Here's an example using for command.

Cheers.

 

Thank you very much for the example!

I've added an extra line so it looks like this

_Spawntarget = Soldier1;


while {true} do {


    private _units = [];
    for "_i" from 0 to 1 do {
        private _veh = createVehicle ["RHS_T50_vvs_blueonblue", getMarkerPos "marker_plane2", [], 50, "NONE"];
        private _group = createVehicleCrew _veh;
        _group setBehaviour "COMBAT";
        _group setSpeedMode "FULL";
        _group setCombatMode "RED";
        _units append (units _group); 
        _waypoint =_group addWaypoint [position _Spawntarget, 0];
        
    };
    waitUntil {_units select {alive _x} isEqualTo []};
    sleep 5;
};

So the AI has a waypoint towards me.

The only Issue i face is that the group of jets spawn on complete random positions. sometimes they even collide and explode or jump into the sky. What i hopefully understand correctly from another script is that "call BIS_fnc_findSafePos" should prevent this issue. (if yes, where do i have to add it?)

Also, is there a good way to controll the group size? sometimes 3,  sometimes 4 vehicles spawn. is there something i can do so only 2 spawn?

Thanks for any help o7

Share this post


Link to post
Share on other sites

I should've added a sleep between each createVehicle to help prevent collision... After your _waypoint line would help.

 

You can also try and create them mid-air:

private _veh = createVehicle ["RHS_T50_vvs_blueonblue", getMarkerPos "marker_plane2", [], 50, "FLY"];

 

Or use indeed BIS_fnc_findSafePos

private _pos = [getMarkerPos "marker_plane2", 0, 100, 5, 0, 10, 0] call BIS_fnc_findSafePos;

and then createVehicle on that pos:

private _veh = createVehicle ["RHS_T50_vvs_blueonblue", _pos, [], 50, "FLY"];

Share this post


Link to post
Share on other sites

You should enlarge your position area (150 instead of 50 in createVehicle).

For jets, use "Fly" instead of "none" (except if you want to spawn on an airfield). You can stagger in altitude also (getMarkerPos "marker_plane2" vectorAdd [0,0,200 + random 200])

If you don't spawn the wanted number of vehicles (nbr), that probably means  you are spawning nbr * x players in multiplayers, so not on server only. Spawn on server only.

 

The fact you add a waypoint on player's position, will not guarantee the jet will attack you. That depends on many things like the jet awareness of your presence. For the Wipeout Arma vanilla, it's rather fair, but for any modded WW2 aircraft, as far as I tested them, it's dead. You need to reveal the target.

 

If you don't want to dig deeper in all problems, and use a cool spawn group(s), I strongly suggest you:

 

Sorry for self-promoting but you're at the core of the subject. And I guess your while {true} loop is not your final intention. So, give this module a trial with the condition(s) you really want: player(s) in area(s), at day or at night, if enemy count is less than...

  • Thanks 1

Share this post


Link to post
Share on other sites
16 hours ago, pierremgi said:

 

If you don't want to dig deeper in all problems, and use a cool spawn group(s), I strongly suggest you:

 

 

@pierremgi OH.. i played a bit with it and it seems like this is the perfect thing i was looking for!

I placed some vehicles in editor with AI crew. I gave them a Waypoint (Destroy) on me (via Editor)

I synced those vehicles to a Respawn vehicles Module from your Mod.

And this works exactly how i wanted the whole time! thank you very much sir o7

 

@RCA3 Also thank you for help. but i think scripting is still a bit too complicated for me

 

  • Like 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

×