Jump to content
Sign in to follow this  
romeoquiznos

Passing on vehicle attributes to respawned vehicle

Recommended Posts

Greetings,

I am attempting to get an enemy AI vehicle to respawn once it is destroyed in a MP mission and follow the previous waypoints it had on patrol. I have tried the copyWaypoints in various combinations but not sure if some of the commands can be executed from the vehicle init or the respawn modules expression line. Have not been able to find any good code examples of "copyWaypoints as it is. The bigger question is; Can I use the Arma 3 mission editor and pass all of the attributes (trigger syncing, waypoints, unlimitted fuel, etc. with another module or some scripting in the veh init or respawn module init or repawn module expression line. I did notice when the mouse is over the expression field of the vehicle respawn module a tooltip pops up and part of it says "(passing...[<oldVehicle>,<newVehicle>])? What does this mean. Thanks.:confused:

Share this post


Link to post
Share on other sites

It means that variables representing destroyed and created vehicle can be used in your expression or script.

Concerning your troubles with copying waypoints, try to add this to module's "Expression" field:

(group (_this select 1)) copyWaypoints (group (_this select 0));

Share this post


Link to post
Share on other sites

First off, thank you for the response. I tried the code you suggested but it does not seem to be working. I noticed the () around the entire expression. Is this how you pass script from the old vehicle to the new vehicle in the module expression line because I noticed those parenthesis in the tooltip as well. Thanks again.

Share this post


Link to post
Share on other sites

No, the parenthesis are just making code easier to read for human, but they are not necessary. To access variables that represents old and new vehicle you can use this code

newVehicle = _this select 0;
oldVehicle = _this select 1;

Of course you don't need to use addition variables old/newVehicle, the "_this select 0" itself works fine:

clearweaponcargoGlobal (_this select 0);
// That command in "Expression" field clears all default weapons from newly spawned vehicle

Concerning that script isn't working: I'm afraid it's my fault, I was confused by copyWaypoint syntax and swapped old and new vehicle, so the code that I've posted tried to copy waypoints form new vehicle to the old one.

I think that code will work fine (well, it should :D):

//groupTo copyWaypoints groupFrom 
//_this select 0 - new vehicle
//_this select 1 - destroyed vehicle
(group (_this select 0)) copyWaypoints (group (_this select 1));

---------- Post added at 19:27 ---------- Previous post was at 19:16 ----------

a tooltip pops up and part of it says "(passing...[<oldVehicle>,<newVehicle>])?
A small note, it's actually [<newVehicle>, <oldVehicle>]. :D <newVehicle> can be accessed with _this select 0 and the <oldVehicle> can be accessed with _this select 1;

Share this post


Link to post
Share on other sites

Again, Thanks for the response. I am putting your latest code in the editor's "vehicle respawn module" expression field and still no luck. Maybe I am missing something here or possibly copyWaypoints is no longer working with the latest stable build. Am I supposed to replace the word "group" for an actual groupname or is "group" returning the groupname string? This is a real head-scratcher for me. Because from everything I have researched in the wiki and forums it seems like the code you posted should work.

Share this post


Link to post
Share on other sites

You might be able to save yourself a bunch of scripting with a simple respawn script. Murklor updated his murk spawn script for Arma 3. IMO it actually works better than it did in Arma 2.

http://forums.bistudio.com/showthread.php?167588-Editor-based-AI-spawn-by-trigger

Simply put, place the units on the map along with the waypoints and sync them up to a trigger. When the mission starts the bad guys go on the clipboard only to appear when the trigger is hit. The bad guys will follow the waypoints. He has four options that will trigger the next wave of bad guys, one of which is being destroyed.

You'll need to look at his sample mission to see how it works and make sure to double check the execvm's.....he copied and pasted some old lines from the previous version of the script and you need a close eye to make sure they point to the current sqs file.

This is one of the easiest and most lightweight scripts I've used.

Share this post


Link to post
Share on other sites
Again, Thanks for the response. I am putting your latest code in the editor's "vehicle respawn module" expression field and still no luck. Maybe I am missing something here or possibly copyWaypoints is no longer working with the latest stable build. Am I supposed to replace the word "group" for an actual groupname or is "group" returning the groupname string? This is a real head-scratcher for me. Because from everything I have researched in the wiki and forums it seems like the code you posted should work.
I went to editor and finally found the problem. I'm sorry, I should have do it before I posted my previous message because the problem is quite obvious: when Vehicle Respawn Module respawns a vehicle it don't respawn its crew (only vehicle itself) and copyWaypoints command just have no group to assign waypoints to (vehicles don't have their own group, they just copy group of the driver when he gets in and loses that group when he gets out) and also there is nobody to follow them. To fix that problem all you need to do is create a driver to newly respawned vehicle, like this:

createVehicleCrew (_this select 0); (group (_this select 0)) copyWaypoints (group (_this select 1));

As you can see, that code creates driver first (at that moment vehicle receives its group) and then waypoints are copied. Just tested in editor, everything works fine for me.

Oh, and yes, "group" is a command that returns group of some unit, (_this select 0) in this case. You don't need to replace it with some variable. :)

Also, createVehicleCrew creates not only driver, but the entire crew that is necessary to vehicle to operate, so while for MRAP it's only a driver, for tank it would be driver, gunner and commander. It don't create units in cargo space though.

Hope that helps. :)

Edited by Semiconductor

Share this post


Link to post
Share on other sites

Thanks for taking the time to finish this off. I really appreciate it. I have yet to implement it into the mission as I got side tracked with other missions and learning new things about scripting along the way. I finally got back to this one as of this post. Will let you know how it turns out. Cheers.

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  

×