Home   Help Search Login Register  

Author Topic: mando Hitch with vrs_ai vehicle respawn sqf...  (Read 1606 times)

0 Members and 1 Guest are viewing this topic.

Offline Gen.Iceman

  • Members
  • *
mando Hitch with vrs_ai vehicle respawn sqf...
« on: 03 Aug 2008, 13:24:22 »
Hello all, iam having trouble running the vrs sqf script below with mando hitch.Whenever I hitch a vehicle it hitches for a second and then the vehicle returns back to its inital starting spot (as if its respawning)..I have the "destroyed" respawn time and the "idle" respawn time set to 3 minutes...any help is appreciated. :whistle:

Init field of hummvee:
Code: [Select]
v = [this, "", 180, 180] execVM "vrs_AI_crew.sqf"
vrs sqf:
Code: [Select]
/*

VEHICLE RESPAWN SCRIPT WITH CREW RESTRICTIONS

© May 2007 - norrin (norrins_nook@iprimus.com.au)

***********************************************************************************************************************************
Version 1.0

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

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_crew.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",
if on the otherhand you don't want to rename your vehicles just put "" instead

**********************************************************************************************************************************
BEGIN vrs_AI_crew.sqf
*/

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;
  player groupchat format ["%1", VehicleVarName _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;
  player groupchat format ["%1", VehicleVarName _vcl];
        _vcl setdir _dir;
        sleep 1;
        _vcl setvelocity [0,0,0];
        _vcl setpos _pos;
        sleep 1;
        _vcl setvelocity [0,0,0];
  sleep 1;
call {[_vcl] execVM "vcl_lock\lock.sqf"};
};
sleep 2;
};

Regards,
   Iceman

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: mando Hitch with vrs_ai vehicle respawn sqf...
« Reply #1 on: 03 Aug 2008, 13:42:23 »
Probably this is the beginning of the cause:
Code: [Select]
while {_vcl distance _pos < 5 && canMove _vcl} do
  {
  sleep 1;
  };
Your empty vehicles move away of the spawn point when hitched, the script might assume they have been abandoned away of the spawn position, a bit later the script deletes the vehicle and replaces it with a new one.

Also the forEach present in the script are quite odd, none of them has any sense for me.
For example, what is this supposed to do?
Code: [Select]
{damage _x} forEach crew _vcl >= 1

Offline Gen.Iceman

  • Members
  • *
Re: mando Hitch with vrs_ai vehicle respawn sqf...
« Reply #2 on: 03 Aug 2008, 13:48:30 »
that I believe has to do with a crew restriction that can also be ran via another script added...iam not using the crew restriction though...


regards,
  Iceman

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: mando Hitch with vrs_ai vehicle respawn sqf...
« Reply #3 on: 03 Aug 2008, 14:43:03 »
Looks like somebody's tried to use the count command:

if ({damage _x >= 1} count crew _vc1 == count crew _vc1) then ...

Which more commonly would be done by using alive:

if ({alive _x} count crew _vc1 == 0) then {....

 ??? I think?

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Gen.Iceman

  • Members
  • *
Re: mando Hitch with vrs_ai vehicle respawn sqf...
« Reply #4 on: 03 Aug 2008, 14:53:10 »
so this respawn script wont work with mando hitch?

,Ice

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: mando Hitch with vrs_ai vehicle respawn sqf...
« Reply #5 on: 03 Aug 2008, 15:22:52 »
The only relation between hitch and that script is that the hitch script moves the vehicle away of the spawning pos while the vehicle is empty, so the script might conclude that the vehicle is abandoned (empty and away of spawn position), so the script removes it and respawns it. Try to hitch a crewed vehicle and see what happens.

Offline Gen.Iceman

  • Members
  • *
Re: mando Hitch with vrs_ai vehicle respawn sqf...
« Reply #6 on: 04 Aug 2008, 01:56:20 »
It all works fine when someone is in the vehicle...  :dry:

ice

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: mando Hitch with vrs_ai vehicle respawn sqf...
« Reply #7 on: 05 Aug 2008, 00:59:26 »
As expected  :cool2:
The script considers abandoned an empty vehicle which is away of its spawn position, then removes it and replaces it by a new one. You would need to modify that respawn script so that it doesnt check for abandoned vehicles using that criteria.