Jump to content
Sign in to follow this  
Impavido

Perplexing problem with vehcile respawn

Recommended Posts

I am using the script by Karrillion and norrin.  The script works beautifully, but for an unbeknownst reason, it does not work on one of my missions (at least in editor preview anyway).  I get no error messages whatsoever and the vehcile does not respawn.  It's as if the script doesnt exist in that one specific map.

I have reviewed my variable names twice and can find no conflicts.

I put this command in the vehicle init line:

Quote[/b] ]s=this execVM "vcl_respawn.sqs"

This is the script that should have been executed:

Quote[/b] ]// *****************************************************

//** Operation Flashpoint Script File

//*****************************************************

//BEGIN vrs_AI.sqf

//Original script by KaRRiLLioN modified by norrin for AI units 7th Feb 2007

//IMPORTANT: ADD A GAMELOGIC NAMED Server

//to the mission to prevent multispawn

private ["_vcl","_respawndelay","_vclemptydelay","_dir",&a

mp;q

uot;_pos","_type","_unit","_run","_wait",&amp

;quo

t;_delay"];

if (!local Server) exitWith {};

_vcl = _this;

//specify the respawn wait times for empty vehicles and destroyed vehicles in the following 2 lines

_vclemptydelay = 180;

_respawndelay = 60;

_dir = Getdir _vcl;

_pos = Getpos _vcl;

_type = typeOf _vcl;

_unit = driver _vcl;

_run = TRUE;

sleep 5;

for [{}, {_run}, {_run}] do

{

while {_vcl distance _pos < 5 && canMove _vcl} do

{

sleep 1;

};

while {canMove _vcl && count crew _vcl > 0 && ({damage _x}forEach crew _vcl)!= 1} do  

{

_wait = Time + _vclemptydelay;

sleep 1;

};

while {canMove _vcl && count crew _vcl < 1 && Time < _wait} do

{

sleep 1;

};

while {canMove _vcl && {damage _x} forEach crew _vcl >= 1 && Time < _wait} do

{

sleep 1;

};

_delay = Time + _respawndelay;

while {!canMove _vcl && Time < _delay} do

{

sleep 1;

};

if (count crew _vcl < 1) then

{

deleteVehicle _vcl;

      _vcl = _type createVehicle _pos;

_vcl setdir _dir;

      sleep 1;

      _vcl setvelocity [0,0,0];

      _vcl setpos _pos;

      sleep 1;

      _vcl setvelocity [0,0,0];

sleep 2;

 };

if ({damage _x} forEach crew _vcl >= 1)then

{

deleteVehicle _vcl;

      _vcl = _type createVehicle _pos;

_vcl setdir _dir;

      sleep 1;

      _vcl setvelocity [0,0,0];

      _vcl setpos _pos;

     sleep 1;

      _vcl setvelocity [0,0,0];

sleep 1;

 };

sleep 2;

};

Share this post


Link to post
Share on other sites

lo,

well make sure u have a gamelogic named "Server" in ur mission

OR change the line

if (!local Server) exitWith {};

to

if (!isServer) exitWith {};

u could also add a

hint format["Unit: %1",_vcl];

after the line

_vcl = _this;

to check for which unit the script is running.

gl

Share this post


Link to post
Share on other sites

If you like PM me a link to your mission and I'll take a look at it,

norrin

Share this post


Link to post
Share on other sites
If you like PM me a link to your mission and I'll take a look at it,

norrin

Thanks norrin.  I will take you up on the offer if the suggestions here don't work.

I'm attempting to debug my mission by deleting things in groups to narrow the culprit down.

Actually, I have multiple versions of the script (slightly changed filenames) implemented with different delay timers.  Could multiple scripts with different timers cause this?

Share this post


Link to post
Share on other sites
Thanks norrin.  I will take you up on the offer if the suggestions here don't work.

I'm attempting to debug my mission by deleting things in groups to narrow the culprit down.

Actually, I have multiple versions of the script (slightly changed filenames) implemented with different delay timers.  Could multiple scripts with different timers cause this?

No it shouldn't, but there is a later version of the script that allows you to specify the times for each vehicle individually in the init line of the vehicle.

Here it is <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//BEGIN vrs_AI_general.sqf

//Script by norrin March 2007

//Based upon KaRRiLLioN's original vrs.sqf script modified for use with playable and non-playable AI units

//Contact me at norrins_nook@iprimus.com.au

//IMPORTANT: ADD A GAMELOGIC NAMED Server

//to the mission to prevent multispawn

//to run this script place the following code in the init line of the vehicle:

// v = [this, "vehicle name", x, y] execVM "vrs_AI_general.sqf"

//where x and y are the times you wish to set for the vehicle empty respawn delay and vehicle destroyed respawn delay

//Note: the vehicle name must be in quotation marks eg. if vehicle name Hmm1 it must appear in the init line as "Hmm1"

private ["_vcl","_respawndelay","_vclemptydelay","_dir","_pos","_type","_unit","_run","_wait","_delay"];

if (!local Server) exitWith {};

_vcl = _this select 0;

_name_vcl = _this select 1;

_vclemptydelay = _this select 2;

_respawndelay = _this select 3;

_dir = Getdir _vcl;

_pos = Getpos _vcl;

_type = typeOf _vcl;

_run = TRUE;

sleep 5;

for [{}, {_run}, {_run}] do

{

  while {_vcl distance _pos < 5 && canMove _vcl} do

    {

       sleep 1;

    };

  while {canMove _vcl && count crew _vcl > 0 && ({damage _x}forEach crew _vcl)!= 1} do  

    {

      _wait = Time + _vclemptydelay;

      sleep 1;

  };

  while {canMove _vcl && count crew _vcl < 1 && Time < _wait} do

  {

      sleep 1;

  };

  while {canMove _vcl && {damage _x} forEach crew _vcl >= 1 && Time < _wait} do

  {

      sleep 1;

  };

  _delay = Time + _respawndelay;

  while {!canMove _vcl && Time < _delay} do

    {

      sleep 1;

    };

  if (count crew _vcl < 1) then

    {

        deleteVehicle _vcl;

          _vcl = _type createVehicle _pos;

        _vcl setVehicleVarName _name_vcl;

          _vcl setdir _dir;

          sleep 1;

          _vcl setvelocity [0,0,0];

          _vcl setpos _pos;

          sleep 1;

          _vcl setvelocity [0,0,0];

        sleep 2;

     };

  if ({damage _x} forEach crew _vcl >= 1)then

    {

        deleteVehicle _vcl;

          _vcl = _type createVehicle _pos;

         _vcl setVehicleVarName _name_vcl;

          _vcl setdir _dir;

          sleep 1;

          _vcl setvelocity [0,0,0];

          _vcl setpos _pos;

          sleep 1;

          _vcl setvelocity [0,0,0];

        sleep 1;

     };

  sleep 2;

};

This might help you simplify things.   To get it to work just put: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">v = [this, "vehicle name", x, y] execVM "vrs_AI_general.sqf" in the vehicles init line, where x and y are the times you wish to set for the vehicle empty respawn delay and vehicle destroyed respawn delay.  If you don't want to name your vehicles just put a "" instead of the vehicle name.

Share this post


Link to post
Share on other sites

BINGO!

Found the problem.  I was using a simple timer-countdown script that created and used a global variable called "time".  Your respawn script used a variable of the same name, so it changed the respawn time of each vehicle to the time-limit set by my timer.

It's always something silly like that.   tounge2.gif

Thanks for the help and the new version of the script Norrin.

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  

×