Jump to content
pierremgi

AI VEHICLE RESPAWN script, an alternative for BI module

Recommended Posts

I will definitely check out your modules for sure. Question does your module leave a dependency if used in a mission and if you don't want to use it you need to delete items from your mission init?

Share this post


Link to post
Share on other sites

These is no dependency with other mods (CBA or else).

1. If the mod is loaded but no module used, there is nothing in mission.sqm.

2. If you use a module, so, as any modded object, this module is present in mission.sqm. You need to let it or edit again the mission and delete it.  With no more module, you are in the situation 1.

3. For player(s) you need to load the mod. (Same as modded objects/entities)

4. Mod is signed.

Spoiler

The specific module "touch of class" allows you to know the class/model of any objects (houses/vegetation...) on map. You can use it and delete it. It's a kind of tool for writers. On the other hand, this module allows also to change a map object (say shabby house) into another one (say tower control), visible in 3den and persistent for the mission. In this case you need to let the module of course. (see video on steam)

 

  • Thanks 1

Share this post


Link to post
Share on other sites

How can i turn off the notifications? I'm using this with a CAS script for aircraft and don't need to know when they spawn

 

Share this post


Link to post
Share on other sites

delete:

if (!isNull _newVeh) then {

   ['RespawnVehicle',[_displayName,_respawnName,_picture]] remoteExec ['BIS_fnc_showNotification',_side];

 };

Share this post


Link to post
Share on other sites

Hey Pierre, sorry to bother you.
I am currently trying to get your Script to work with different vehicles with different respawn delays for each vehicle.
How would I go about utilizing different delays?
Currently I am trying it this way:


 

Spoiler

 

<whole script of yours above>

respawnhandle1 = [[west_apc,west_tank],"start",300,true,false] spawn MGI_fnc_VehicleRespawn;

respawnhandle2 = [[west_quad1,west_quad2,west_quad3,west_quad4],"start",60,true,false] spawn MGI_fnc_VehicleRespawn;

respawnhandle3 = [[west_qilin_armed,west_qilin],"start",120,true,false] spawn MGI_fnc_VehicleRespawn;

respawnhandle4 = [west_transport,"start",1,true,false] spawn MGI_fnc_VehicleRespawn;


 

But well, it doesn't work out and only uses the last line.
 

Thanks for your script. It really does some awesome stuff and completely replaces the BI Module.


I hope you have an enjoyable day.
Regards, Bradley

Share this post


Link to post
Share on other sites

Yes, this parameter is a global variable. It's normal to overwrite it with the last script. I can't easily implement something different because that means to identify what vehicles should respawn within a delay, and what others within another delay.

What you can do, for yourself, is to  create 3 or 4 versions of this script, for example MGI_fnc_VehicleRespawn1 , MGI_fnc_VehicleRespawn2 ...

in which you customize the variable names like: MGIrespVehDelay1, MGIrespVehDelay2, ...  (everywhere needed). The method worth also for MGIrespOnDisabled variable.

Not tested.

Share this post


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

Yes, this parameter is a global variable. It's normal to overwrite it with the last script. I can't easily implement something different because that means to identify what vehicles should respawn within a delay, and what others within another delay.

What you can do, for yourself, is to  create 3 or 4 versions of this script, for example MGI_fnc_VehicleRespawn1 , MGI_fnc_VehicleRespawn2 ...

in which you customize the variable names like: MGIrespVehDelay1, MGIrespVehDelay2, ...  (everywhere needed). The method worth also for MGIrespOnDisabled variable.

Not tested.

I will try that, thanks for your answer!

Share this post


Link to post
Share on other sites

I want bots to spawn in random place in whole marker called "respawn"


Im calling script with "start",  both for independent and west, any way to randomize it?

Quote

_createBots = [[INDEPENDENT,WEST],["start","start"],5,false,false] spawn MGI_fnc_VehicleRespawn; 

 

TLPQynj.png

Share this post


Link to post
Share on other sites

The easiest way is to respawn on marker (you can choose different ones for sides). Make it invisible on map.

Then run a loop randomizing the position of the marker. Something like, in server:

0 = [] spawn {

  private _initpos = getMarkerPos "myHolyMarker";

  while {true} do {

    "myHolyMarker" setMarkerPosLocal (_initpos vectorAdd [-100 + random 200, -100 + random 200,0]);

    sleep 2

  }

};

Note: I will probably add a random position inside marker with an area... for the MGI module.

Share this post


Link to post
Share on other sites

hey, im trying to get your script version working with my mission. I am unable to get your init field fix working.

I have this in my vehicls init:

this setVariable ["MGIcustomCode",  'this addEventHandler  ["GetOut" , {(_this select 2) setDamage 1;(_this select 0) setDamage 1;} ];' ]; call compile (this getVariable "mgiCustomcode");


and it works the first time around (ie the event handler works) but then on the second spawn it doesnt. have i done something wrong here?

Share this post


Link to post
Share on other sites

No that's not implemented for init field of vehicle. (Because scripters add too much things in init fields and that can be tricky (or even crazy) in MP to re-run some codes on each PCs).

You can easily add EH on spawned vehicles during mission (in init.sqf):

[] spawn {

  while {TRUE} do {

     {

       _x addEventHandler ["getOut", {...}];
       _x setVariable ["yourPass",TRUE];

     } forEach (vehicles select {isNil {_x getVariable "yourPass"}});

     sleep 3;
  };
};

Share this post


Link to post
Share on other sites

Hey Pierre,

-I am making a MP game with only BLUFOR and OPFOR factions. My intention is to only respawn ALL BLUFOR vehicles at their START POSITION if destroyed. 

-I have RHSUSAF and H60J Coast Guard Helicopter MODs loaded

-I also have respawn scripts for saving the loadouts of infantry players in the mission file (onPlayerKilled.sqf and onPlayerRespawn.sqf)

 

-the command line I'm using is:

0 = [[WEST],"start",10,false,true] spawn MGI_fnc_VehicleRespawn;

and the rest of the script is copy and paste

-I got the script to respawn vehicles properly but they seem to always respawn at the death position and occasionally spawn at the start position for choppers

-I dont have any markers and have tried an array of "start" but all of them still respawn the vehicle at death position.

 

-So I looked through your script and I believe the following line of code sets the respawn position as death position if no other markers or start positions are found:

_positions = _positions apply {if (getMarkerpos _x isEqualTo [0,0,0] && _x != "start") then {"death"} else {_x}}; private ["_idx","_positionType"];

-Then, I tried forcing the vehicles to spawn at start by changing {"death"} to {"start"}, but that just ended up not respawning the vehicles completely. I wonder if that means the game couldn't find a start position. 

 

Plz help ;-; 

117

Share this post


Link to post
Share on other sites

Hey Pierre,

 

The script version works great except for one problem when using ace.

 

When a tank blows up and loses its turret, the vehicle respawns in without its turret.

 

Any fix for this?

 

thanks!!

Share this post


Link to post
Share on other sites
58 minutes ago, rowdied said:

Hey Pierre,

 

The script version works great except for one problem when using ace.

 

When a tank blows up and loses its turret, the vehicle respawns in without its turret.

 

Any fix for this?

 

thanks!!

No, unfortunately. I don't care with ACE compatibility. ACE is just too much, interfering with everything. So, if you want to spawn a normal tank, don't ask ACE to split into parts. 🙄

That said, if this is reproducible with a simple great mod, like CUP, RHS, IFA3, UNSUNG,... and no other mod, I'll have a look at it.

Share this post


Link to post
Share on other sites
3 hours ago, J.Larsson said:

 

is there any way to increase the timer on death when a vehicle is downed?

Right now they almost instant delete wreck and respawn


what line is it in the script?

Share this post


Link to post
Share on other sites
19 minutes ago, J.Larsson said:

is there any way to increase the timer on death when a vehicle is downed?

Right now they almost instant delete wreck and respawn


what line is it in the script?

 

It's a 10 sec delay by default. See front page for the script parameters.... or use the module instead.

Share this post


Link to post
Share on other sites

Hey, is there a chance to get a clean script file from the first page?   The thing i can copy is really full of html artifacts and im not able to clean it.

 

Generally i always use the modules version (your modules are one of the more useful things around tbh - enhanced turrets is a must!), but am trying to go light weight.

 

ty for any help, bb

 

whole upper portion of the script looks like this after copying :icon_confused:

 

Screenshot-2023-12-05-133701.png

 

 

Share this post


Link to post
Share on other sites
21 hours ago, Rok Stuhne said:

Hey, is there a chance to get a clean script file from the first page?   The thing i can copy is really full of html artifacts and im not able to clean it.

whole upper portion of the script looks like this after copying :icon_confused:

 

Hello, Not sure to understand what you're speaking about. I can't see any problem with your screenshot as far as the code is compiling strings.

Share this post


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

 

Hello, Not sure to understand what you're speaking about. I can't see any problem with your screenshot as far as the code is compiling strings.

 

 

yes but the bottom of the page looks written in several colors, like it should be and that usually means there's some invisible symbols, it breaks the color coding of the page, letting you know there's something wrong. 

 

idk, ill try in the game, see what happens, i didn't have time yet tbh, thats why i didnt respond so long lol. will report back!

 

 

#edit: now that i think of it, if that portion of the page is doing just one thing, it maybe makes sense it's mostly all in red, idk 

 

Share this post


Link to post
Share on other sites
On 12/6/2023 at 9:21 PM, Rok Stuhne said:

idk, ill try in the game, see what happens, i didn't have time yet tbh, thats why i didnt respond so long lol. will report back!

 

#edit: now that i think of it, if that portion of the page is doing just one thing, it maybe makes sense it's mostly all in red, idk 

 

 

You should start by that! I just tested once again this old script, by copying/pasting in a trigger and it works. There is no added value compared to the module, but on the contrary, the module have more options for useless features.

Your problem is on your side. As I said, a long string is whole colored... as usual in your editor. If you have some extra characters, I can't say why, depending on what you did with the script. I definitely tested the script in front page, and I didn't find a problem.

Share this post


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

 

You should start by that! I just tested once again this old script, by copying/pasting in a trigger and it works. There is no added value compared to the module, but on the contrary, the module have more options for useless features.

Your problem is on your side. As I said, a long string is whole colored... as usual in your editor. If you have some extra characters, I can't say why, depending on what you did with the script. I definitely tested the script in front page, and I didn't find a problem.

 

 

gonna play with it over the weekend. super busy rn. still didnt test and admittedly i might have jumped the gun with "reporting errors", just based on color coding of the code in the code preview window of the forums.

 

ty for the response 

Share this post


Link to post
Share on other sites

hey @pierremgi    what would be the syntax for all empty vehicles respawning at start location?

 

0 = [ [ ],"start",10,true,true] spawn MGI_fnc_VehicleRespawn;    ???

 

can't get this one to work, and it's really the one i need. Yes, i know, for such a minute purpose the BI module is great, but i'd really like loadouts on planes. 

 

ty for any insight

 

 

 

 

Share this post


Link to post
Share on other sites
2 hours ago, Rok Stuhne said:

hey @pierremgi    what would be the syntax for all empty vehicles respawning at start location?

 

0 = [ [ ],"start",10,true,true] spawn MGI_fnc_VehicleRespawn;    ???

 

can't get this one to work, and it's really the one i need. Yes, i know, for such a minute purpose the BI module is great, but i'd really like loadouts on planes.

 

 

With MGI Respawn Vehicles module (recommended, for some features like respawning on board USS Freedom, respawning UAV/UGV... and more. Doesn't impact on resource):

 

- just tick the option empty vehicles can respawn (and untick sided options if not needed). Empty vehicles are "empty at start or when spawned", not emptied by units disembarking.

- or link some empty vehicles to the module if all empty respawn is not necessary.

- check also other options (appearance, pylons, added actions...)

 

With this script front page :

[ [ ],["start"],10,true,true] spawn MGI_fnc_VehicleRespawn; //works for me.

or even:

[[],"start",10] spawn MGI_fnc_VehicleRespawn;  // works also with default parameters (destroyed empty vehicles but not disabled ones (false by default))

Note: if you start as pilot then leave the plane, this plane is not "empty at start", so, in this case, add the name of the plane in first array.

 

The array of vehicles/sides   can be also a little code like:    vehicles select {_x isKindOf "plane"}...  or what you need, independently of other parameters.

 

 

 

  • 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

×