callmesarge 7 Posted October 25, 2014 (edited) Hi Iceman - i am having a bit of trouble with the new LVR. I should also state that I am new to ArmA scripts in general and prone to making schoolboy errors! Whilst testing out the new LVR.Stratis demo, i set the vehicle name in the editor to MHQ1. In fn_vehRespawn.sqf i modified lines 72 and 102 as follows: Line 72 if (_vehName != "MHQ1") then { //// Line 102 if (_vehName != "MHQ1") then { However, when I preview the mission in editor and destroy the vehicle, it goes back to the default unit name. Am I doing something wrong? Any advice would be appreciated. Edited October 25, 2014 by CallMeSarge Edited for typos Share this post Link to post Share on other sites
iceman77 18 Posted October 25, 2014 (edited) Hi. What exactly are you trying to do? Maybe I can post the best way to go about it. Cheers. ---------- Post added at 00:07 ---------- Previous post was at 23:06 ---------- Odds are, whatever you're trying to do, you could create a fn_mhqInit.sqf file and register it in the functions.hpp as per usage instructions. Utilize the optional 3rd parameter by inputting LVR_fnc_mhqInit. Any code in the function file will be executed upon the vehicle. You can simply use _this to reference the vehicle. No need to touch the main respawn file. example fn_mhqWestInit.sqf _this setDamage 0.75; _tent = "CamoNet_BLUFOR_open_F" createVehicle ( position _this ); west mhq init line _nul = [ this, 120, 60, LVR_fnc_mhqWestInit ] spawn LVR_fnc_vehRespawn; Edited October 25, 2014 by Iceman77 Share this post Link to post Share on other sites
callmesarge 7 Posted October 25, 2014 I am trying to maintain vehicle names after respawn, so I can use your teleport function to teleport to them. I have this working now in the last version, thanks to Beerkans advice back on page 6. So would I need to add something about setVehicleVarName to fn_mhqWestInit.sqf? Share this post Link to post Share on other sites
iceman77 18 Posted October 25, 2014 It already sets the vehicle's name. No need to touch a thing in the main respawn file. IE; no need to do if ( _vehname != "MHQ1" ) then { ... it should just be if ( _vehname != "" ) then {... ---------- Post added at 00:31 ---------- Previous post was at 00:27 ---------- Here's how to test it right quick. Open the default demo mission in the editor. Name one hunter car1. Save and preview. Blow car1 up. After it respawns, open the debug console. Put player setPos getPos car1 Notice you teleport to the vehicle because the vehicle has retained it's name. Share this post Link to post Share on other sites
callmesarge 7 Posted October 26, 2014 Tested in my mission and works perfect - thanks Iceman! Share this post Link to post Share on other sites
iceman77 18 Posted October 26, 2014 Sure. Let me know if there's anymore issues. On dedicated server etc Share this post Link to post Share on other sites
thelegendarykhan 15 Posted November 16, 2014 http://img163.imageshack.us/img163/1/k7uh.jpg Example Mission: http://i.imgur.com/xYqfb0d.png fn_vehRespawn.sqf /* ---------------------------------------------------------------------------------------------------- File: fn_vehRespawn.sqf Author: Iceman77 Description: - Monitor a vehicle and "respawn" it if it's destroyed or abandoned - Can be used on vehicles - Set vehicle init upon respawn (optional) - Store and keep the vehicle's variable name automatically Parameter(s): - _this select 0: < OBJECT > - VEHICLE - _this select 1: < NUMBER > - ABANDONED DELAY IN SECONDS - _this select 2: < NUMBER > - DESTROYED DELAY IN SECONDS - _this select 3: < CODE > - FUNCTION THE VEHICLE CALLS UPON RESPAWN (OPTIONAL) Usage (Vehicle init Line): _nul = [ this, 120, 60, LVR_fnc_hunterInit ] spawn LVR_fnc_vehRespawn << have the vehicle call the custom LVR Function upon respawn _nul = [this, 20, 10, {_this setVehicleAmmo 0; _this setDammage 0.5;}] spawn LVR_fnc_vehRespawn; << Run code directly on the vehicle when it respawns _nul = [ this, 120, 60 ] spawn LVR_fnc_vehRespawn; << Default usage ---------------------------------------------------------------------------------------------------- */ // SERVER CODE if ( ! ( isServer ) ) exitWith {}; // SET SCOPE OF LOCAL VARIABLES private ["_veh","_abandonDelay","_destroyedDelay","_vehInit","_vehName","_vehDir","_vehPos","_vehtype","_abandoned","_dead"]; // PASSED ARGUMENTS ( OBJECT, ABANDONED DELAY, DESTROYED DELAY ) _veh = [_this, 0, objNull, [objNull]] call BIS_fnc_param; _abandonDelay = [_this, 1, 60, [0]] call BIS_fnc_param; _destroyedDelay = [_this, 2, 60, [0]] call BIS_fnc_param; _vehInit = [_this, 3, {}, [{}] ] call BIS_fnc_param; // STORE THE VEHICLES NAME, DIRECTION, POSITION AND TYPE _vehName = vehicleVarName _veh; _vehDir = getDir _veh; _vehPos = getPos _veh; _vehtype = typeOf _veh; // START LOOP TO MONITOR THE VEHICLE while { true } Do { sleep 1; // IF THE VEHICLE IS ALIVE AND CAN MOVE AND IS EMPTY THEN THE VEHICLE IS ABANDONED if ( ( alive _veh ) && { ( canMove _veh ) && { { ( alive _x ) } count ( crew _veh ) == 0 } } ) then { _abandoned = true; // COUNTDOWN THE ABANDONED DELAY - STALL SCRIPT HERE for "_i" from 0 to _abandonDelay do { // IF THE VEHICLE ISN'T EMPTY, OR IS DESTROYED, OR IF IT CAN'T MOVE THEN IT'S NOT ABANDONED SO EXIT THE COUNTDOWN EARLY - CONTINUE THE SCRIPT if ( { ( alive _x ) } count (crew _veh) > 0 || { !( alive _veh ) || { !( canMove _veh ) } } ) exitWith { _abandoned = false; }; sleep 1; }; // IF THE VEHICLE IS ABANDONED AND ISN'T CLOSE TO IT'S STARTING POSITION THEN DELETE IT AND CREATE A NEW ONE AT THE STARTING POSITION if ( ( _abandoned ) && { _veh distance _vehPos > 10 } ) then { deleteVehicle _veh; sleep 1; _veh = createVehicle [ _vehtype, _vehPos, [], 0, "CAN_COLLIDE" ]; _veh setPos [ ( _vehPos select 0 ), ( _vehPos select 1 ), 0 ]; _veh setDir _vehDir; _veh call _vehInit; if (_vehName != "") then { missionNamespace setVariable [_vehName, _veh]; publicVariable _vehName; }; }; }; // IF THE VEHICLE IS DESTROYED OR IF IT CAN'T MOVE THEN ITS DEAD if ( !( alive _veh ) || { !( canMove _veh ) } ) then { _dead = true; // COUNTDOWN THE DEAD DELAY - STALL SCRIPT HERE for "_i" from 0 to _destroyedDelay do { // IF THE VEHICLE ISN'T EMPTY, OR IF IT CAN MOVE ( HAS BEEN REPAIRED ) THEN IT'S NOT DEAD SO EXIT THE COUNTDOWN EARLY - CONTINUE THE SCRIPT if ( { ( alive _x ) } count ( crew _veh ) > 0 || { ( canMove _veh ) } ) exitWith { _dead = false; }; sleep 1; }; // IF THE VEHICLE IS DEAD THEN DELETE IT AND CREATE A NEW ONE AT THE STARTING POSITION if ( _dead ) then { deleteVehicle _veh; sleep 1; _veh = createVehicle [ _vehtype, _vehPos, [], 0, "CAN_COLLIDE" ]; _veh setPos [ ( _vehPos select 0 ), (_vehPos select 1 ), 0 ]; _veh setDir _vehDir; _veh call _vehInit; if (_vehName != "") then { missionNamespace setVariable [_vehName, _veh]; publicVariable _vehName; }; }; }; }; Other projects related to LVR: Not So Light Vehicle Respawn ( BY LARROW ) Sounds good. In Larrow's script, the sample mission has the hunter named "h1" and in the init, the line begins with "h=...". So does this mean, I can apply this same init for as many vehicles through just copy paste and just rename every subsequent vehicle as h2, h3, h4....? Coz right now I am using your script and my vehicles spawn over each other and explode at the start of the mission after the delay time. thanks in advance. :) Share this post Link to post Share on other sites
iceman77 18 Posted November 16, 2014 (edited) Hi. Please post a minimum working example mission to download where the vehicles are spawning over each other and exploding. Thanks. ---------- Post added at 03:28 ---------- Previous post was at 03:14 ---------- I'm unable to reproduce vehicles spawning on one another and exploding on hosted or dedicate server. I'm itching for an example to download so I can fix the issue :p Edited November 16, 2014 by Iceman77 Share this post Link to post Share on other sites
thelegendarykhan 15 Posted November 16, 2014 Hi. Please post a minimum working example mission to download where the vehicles are spawning over each other and exploding. Thanks.---------- Post added at 03:28 ---------- Previous post was at 03:14 ---------- I'm unable to reproduce vehicles spawning on one another and exploding on hosted or dedicate server. I'm itching for an example to download so I can fix the issue :p Sure man. http://www.megafileupload.com/en/file/580253/Alive-war-Altis-7z.html Its an Alive MP mission (requires Alive and some more mods). I have highlighted the troubled area by a marker. All the vehicles in the airfield base have the init field done. I have simplified your script by removing LVR folder as I dont use the custom init on vehicles. Also I have seen that apart from vehicles exploding one after the other, if I abandon the vehicle in field with its engine left running, it doesnt disappear after the set time, only a new vehicle spawns in its original position. Fix this also please. Do me one favour man. Please adapt your script for my mission by either fixing through your script or Larrow's. Send me the redone mission. I will basically need this script on vehicles in different bases. One last thing, your script seems to be workable on vanilla vehicles only. What gives? Thanks in advance brah'. :) Share this post Link to post Share on other sites
iceman77 18 Posted November 16, 2014 (edited) Please bare with me here. I mean no disrespect. I didn't use the ALiVE mod while I wrote LVR. LVR works fine with Vanilla from what I can see. LVR works fine when the file and folder structure are unmoletsed. However, if you want to post a minimal working example that reproduces the problem in vanilla, then I'll be happy to fix the issue, regardless of file/folder structure. I'm not sure why LVR doesn't work with addon vehicles. I will look into that. About the vehicle not not being deleted but respawning, I doubt I'll be able to reproduce the issue. DeleteVehicle arguments and effects are global, the script is run on the server, it deletes the vehicle and then creates a new one. So not sure why it magically hops over and ignores the deleteVehicle command for your mission apparently (??). I'll look into it no matter. EDIT: Okay just tested some addon vehicles (certainly not all LOL) and LVR appeared to work fine with both destroyed and abandoned delay, whether the engine was left on or not. Here is an example mission using these 2 addons. In the example is a truck and the hind. And vanilla vehicles too. http://forums.bistudio.com/showthread.php?185594-Arma-2-Mil-Mi-24-Hind-Port&p=2818990&viewfull=1#post2818990 http://www.armaholic.com/page.php?id=26758 Edited November 17, 2014 by Iceman77 Share this post Link to post Share on other sites
thelegendarykhan 15 Posted November 17, 2014 (edited) Brooo I guess i found the problem. I saw a bug report, which I will post later, which mentions same issue with Alive but talks about vanilla vehicle respawn. On Alive profile system, setting it to virtualize all units except for synced may cause this issue. I will try tonight after work, agh 8:30 am here. Thank you mate you always respond to my querries. :) Speaking of mods, I am using 39 at the moment simultaneously. O.o Alhamdolillah, good thing is they dont conflict. Lol Btw I downloaded your digital loadout script last night . Been waiting for something with persistence. Will try tonight. Thanks for the efforts man. Jazak Allah Khairan (Arabic for "Thanks to Allah" said when you wish to thank someone):) Edited November 17, 2014 by TheLegendaryKhan Share this post Link to post Share on other sites
iceman77 18 Posted November 17, 2014 I wish BI would get the respawn module straightened out (unless it's already been fixed :confused:). The only reason I wrote this script is because Tophe quit providing support for his and the BI module had an issue. The newly created vehicle was being created at nearly the same time as the old one was being deleted. If the vehicle was destroyed at it's initial spawn position, it would cause explosions and at best misplacement of the re-spawned vehicle. Thus I wrote this LvR. Note: I'm starting to see why Tophe stopped offering support for simple vehicle respawn though :p Share this post Link to post Share on other sites
thelegendarykhan 15 Posted November 17, 2014 I wish BI would get the respawn module straightened out (unless it's already been fixed :confused:). The only reason I wrote this script is because Tophe quit providing support for his and the BI module had an issue. The newly created vehicle was being created at nearly the same time as the old one was being deleted. If the vehicle was destroyed at it's initial spawn position, it would cause explosions and at best misplacement of the re-spawned vehicle. Thus I wrote this LvR. Note: I'm starting to see why Tophe stopped offering support for simple vehicle respawn though :p Agreed. I tried Tophe's script wayy back. And yeah you're correct BIS modules do have a lot of potential. Sadly they leave the fine tuning work to us lol. That imho is a great way to scrutinize potential employees. :D Tonight I will try turning that feature off in Alive and will get back with my feedback. If it works, maybe it will help you in your update. Share this post Link to post Share on other sites
iceman77 18 Posted November 17, 2014 If it works, maybe it will help you in your update. Which update is that? Share this post Link to post Share on other sites
thelegendarykhan 15 Posted November 17, 2014 Which update is that? I mean your future fix maybe. :) Share this post Link to post Share on other sites
iceman77 18 Posted November 17, 2014 Have to have something to fix first lol. Unfortunately, I don't consider LVR and ALiVE incompatibility as LVR being broken :p. Any other issues that I can reproduce I will try to fix. Note: Why doesn't ALiVE have it's own respawn framework? Or is it supposed to rely on the broken BI respawn module(s)? Share this post Link to post Share on other sites
thelegendarykhan 15 Posted November 17, 2014 Have to have something to fix first lol. Unfortunately, I don't consider LVR and ALiVE incompatibility as LVR being broken :p. Any other issues that I can reproduce I will try to fix.Note: Why doesn't ALiVE have it's own respawn framework? Or is it supposed to rely on the broken BI respawn module(s)? Man it works. Yeah not update, but atleast you can mention in your original post that Alive users need to select "Virtualize synced units only" in the Alive Virtual AI system module to prevent the pile up s*** on vehicles. Lol Btw, how is your latest digital loadout script supposed to work? Sorry but paste the link with instructions for noobs like me. Thanks brah' Share this post Link to post Share on other sites
iceman77 18 Posted November 17, 2014 Okay I'll add a note at the top of the main post. I'll answer your question regarding DLSR in it's own main thread. Share this post Link to post Share on other sites
thelegendarykhan 15 Posted November 21, 2014 Okay I'll add a note at the top of the main post. I'll answer your question regarding DLSR in it's own main thread. Wow thanks man. I saw it. :D Share this post Link to post Share on other sites
iceman77 18 Posted November 21, 2014 Updated Added a Dynamic sector control version of LVR. Pulled from my WIP "conquest" game mode (BCM). See the notes in the OP. Share this post Link to post Share on other sites
fn_Quiksilver 1636 Posted December 31, 2014 (edited) Post the flaws to do with LVR in the LVR thread aswell. I'd appreciate it. That way I can atleast fix what I have. If there is infact flaws with Larrow's vehicle spawn script aswell, feel free to post them there too. Cheers. Its not so much a flaw or error as an inefficiency built into the design. The A3 Vehicle Respawn Module has the same issue. The core of the issue is this: Each vehicle spawns an evaluation thread. 20 vehicles = 20 evaluation threads. 40 = 40. etc. In any scenario using such system with a few respawning vehicles, the system quickly becomes the main non-AI CPU burden for the scenario, given all the concurrent and uncontrolled evaluations taking place. We can spread these out with 'sleep' command, but that is just a band-aid, a work-around to an inefficient design. What I'd like considered is that only one evaluation thread is necessary, to evaluate all the vehicles one at a time. Such a system is in use on my public dev server [ 70.42.74.22:2302 currently running I&A], with noticeable server performance improvement (40+ vehicles :)) over the common systems. Unfortunately it is not available for public use/download. I think there is still a hole in the market (can it be called that?) for such a system. EDIT: Also, PM sent with some more technical details. Edited December 31, 2014 by MDCCLXXVI Share this post Link to post Share on other sites
iceman77 18 Posted January 2, 2015 (edited) Yeah it doesn't matter about how many threads and loops. I think it matters about what's going on inside them. In LVR's case, it's alot of times either just sleeping or creating a new vehicle every now and again, after some pretty soft evaluations. In any case I'll post yours here for everyone to use since it's more efficient. Everyone can use it instead of LVR, because hey I don't even have the time to write code anymore. Not that I could even if I wanted to since I stay drunk. Anyhow... Here's MDCCLXXVI's leet vehicle respawn pseudo code. _arrayOfVehicleData = [ [veh1,vehicledata,etc], [veh2,vehicledata,etc], [veh3,vehicledata,etc] ]; while {TRUE} do { { _index = _arrayOfVehicleData find _x; _vehicleData = _arrayofVehicleData select _index; _vehicle = _vehicleData select 0; _othershit = _vehicleData select whatever if (!alive _vehicle) then { _vehicle = createvehicle [] _vehicleData = [_vehicle,vehicledata,etc]; _arrayOfVehicleData set [_index,_vehicleData]; } else { if (abandoned _vehicle) then { _vehicle setPos [] }; }; } count _arrayOfVehicleData; }; Look ma no sleep!! (you know instead of no hands!) ps; if you wont release a public version of yours why are you on here pm'n me about how to write it? Post a working version and then get back with me. Or not. Frankly I don't give a damn. Just saying. Edited January 2, 2015 by Iceman77 Share this post Link to post Share on other sites
dr death jm 117 Posted January 3, 2015 ICEMAN77 awesome tool, Ive edited killzone_kid autotank and used your vehicle respawn with functions and I got every vehicle that needs a gunner to be auto.. ie: you can drive and shoot in any vehicle.. Share this post Link to post Share on other sites
dr death jm 117 Posted January 5, 2015 well I ported the autotank to my dm mission, but now the autotanks delet and reappear as if the were abandoned ? I left the original hint in the fnc so I see all of the vehicles spawn.. but befor I added the auto tanks to the dm this all worked perfect.. not sure how to fix without getting rid of abandon vehicle all to gether? Share this post Link to post Share on other sites