Jump to content
Sign in to follow this  
Jantemplar

Advanced Vehicle respawn system need help

Recommended Posts

Update:

Alright, i decided to get off my ass, compile some people script and produce this World In Conflict Style.....

So this is what i have

if (!isServer) exitWith {};

// Define variables
_unit = _this select 0;
_delay = if (count _this > 1) then {_this select 1} else {30};
_deserted = if (count _this > 2) then {_this select 2} else {120};
_respawns = if (count _this > 3) then {_this select 3} else {0};
_explode = if (count _this > 4) then {_this select 4} else {false};
_dynamic = if (count _this > 5) then {_this select 5} else {false};
_unitinit = if (count _this > 6) then {_this select 6} else {};
_haveinit = if (count _this > 6) then {true} else {false};

_airtype = "C130J";
_typepilot = "GUE_Soldier_Pilot";
mygroup = creategroup side player;
_hasname = false;
_unitname = vehicleVarName _unit;
if (isNil _unitname) then {_hasname = false;} else {_hasname = true;};
_noend = true;
_run = true;
_rounds = 0;

if (_delay < 0) then {_delay = 0};
if (_deserted < 0) then {_deserted = 0};
if (_respawns <= 0) then {_respawns= 0; _noend = true;};
if (_respawns > 0) then {_noend = false};

_dir = getDir _unit;
_position = getPosASL _unit;
_type = typeOf _unit;
_dead = false;
_nodelay = false;


// Start monitoring the vehicle
while {_run} do 
{    
   sleep (2 + random 10);
     if ((getDammage _unit > 0.8) and ({alive _x} count crew _unit == 0)) then {_dead = true};

   // Check if the vehicle is deserted.
   if (_deserted > 0) then
   {
       if ((getPosASL _unit distance _position > 10) and ({alive _x} count crew _unit == 0) and (getDammage _unit < 0.8)) then 
       {
           _timeout = time + _deserted;
           sleep 0.1;
            waitUntil {_timeout < time or !alive _unit or {alive _x} count crew _unit > 0};
           if ({alive _x} count crew _unit > 0) then {_dead = false}; 
           if ({alive _x} count crew _unit == 0) then {_dead = true; _nodelay =true}; 
           if !(alive _unit) then {_dead = true; _nodelay = false}; 
       };
   };

   // Respawn vehicle
     if (_dead) then 
   {    
       if (_nodelay) then {sleep 0.1; _nodelay = false;} else {sleep _delay;};
       if (_dynamic) then {_position = getPosASL _unit; _dir = getDir _unit;};
       if (_explode) then {_effect = "M_TOW_AT" createVehicle getPosASL _unit; _effect setPosASL getPosASL _unit;};
       sleep 0.1;

       deleteVehicle _unit;
       sleep 2;
       _target = createVehicle  ["testsphere2",[_position select 0,_position select 1,-10], [], 0, "FLY"];
       _target setpos [_position select 0,_position select 1,200];
       _target setDir _dir;
       _vdir = vectorDir _target;
       _target setpos [(_position select 0) + (_vdir select 0) * 26, (_position select 1) + (_vdir select 1) * 26,200];
       _apos = getposasl _target;

       _npos = [(_pos select 0) + (_vdir select 0) * -1500, (_pos select 1) + (_vdir select 1) * -1500, 300];

       _vehicle = createVehicle  [_airtype,_npos, [], 0, "FLY"];
       _vehicle setpos _npos;
       _vehicle setDir _dir;

       _vehicle setvelocity [(_vdir select 0)*50,(_vdir select 1)*50, 5];

       _typepilot createUnit [_npos, mygroup,"pilot=this;"];
       _pilot = pilot;
       _pilot moveindriver _vehicle;
       _pilot reveal _target;
       _pilot doMove _npos;
       _pilot dotarget _target;
       _pilot dowatch _target;
       _pilot FlyInHeight 400;
       _vehicle FlyInHeight 400;

       while {_vehicle distance _target > 40} do 
       {
               sleep 0.5;
               if(_vehicle distance _target < 600) then 
               {
                   _pilot FlyInHeight 400;
                   _pilot doMove _npos;
               };
       };

           _bpos = _vehicle ModelToWorld [0,-12,-5.5];
           _unit = _type createVehicle _bpos;
           _unit setpos _bpos;
           _unit setDir direction _vehicle;
           _chute = "ParachuteMediumWest" createVehicle getpos _bomb;
           _chute setpos (_bomb ModelToWorld [0,0,3]);
           _unit attachTo [_chute,[0,0,0]];
           deletevehicle _target;
           sleep 0.05;

   _plane FlyInHeight 250;


   sleep 1;
   _plane FlyInHeight 450;
   _pilot doMove [(_pos select 0) + (_vdir select 0) * 800, (_pos select 1) + (_vdir select 1) * 800, 500];

   sleep 15;

   deletevehicle _vehicle;
   deletevehicle _pilot;

   if (_haveinit) then 
               {_unit setVehicleInit format ["%1;", _unitinit];
               processInitCommands;};
   if (_hasname) then 
               {_unit setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_unitname];
               processInitCommands;};
   _dead = false;

   // Check respawn amount
   if !(_noend) then {_rounds = _rounds + 1};
   if ((_rounds == _respawns) and !(_noend)) then {_run = false;};
   };
};

Now after extensive testing i know it does not work.... It works right up to the Effect point but then the c130 never appears, flys over my head drops the vehicle that died and flies away. Anyone got an idea why. Ive also tried running the game with the -showscripterrors on the end and it only shows erorrs in my briefing and not in this script.

BTW this script is a mix of Tajin c130 dropspawn script and Simple Vehicle Respawn Script by Tophe with edits to them and compiling of them by me.

But if anyone sees whats wrong, please post.

Thanks

Jan Templar

Edited by Jantemplar

Share this post


Link to post
Share on other sites

script it out. set a scripted waypoint. look up the actions list for the game. tell the c130 to do the action via script. then spawn your item out of the plane via script. I would look at the commands biki. that's a good starting place if the nerds don't look at your post.

Share this post


Link to post
Share on other sites

Well, almost anything is possible. But I find the following a bit conflicting and hard to provide help with:

"Advanced Vehicle respawn system" and "waypoints (i can do that at least)" and "no clue on some of the scripting required."

Now, hopefully I'm not gonna turn up like a jerk here, but: Basically what you're asking is for others to make you a fairly complex script. I'm observing you have 33 posts since joining in feb. It is easy to conclude (maybe even wrongly so), that the efforts of learning this scripting business has not been great.

The commands on the biki is a great tool to learn scripting if you already have some scripts that use the commands. I wouldn't reccommend the biki command list as a tool to learn scripting. I suggest trying to learn the trade and post examples of the problems you're experiencing instead of asking others to make it for you.

Mr. Murrays editing bible is a great place to start, but can be confusing due to mix of .sqf and .sqs script formats. I haven't checked it lately though, so I could be wrong. Also simply downloading existing Arma missions and script templates from the Ofpec site is a nice way to get you going. Stay away from the too advanced stuff though in the beginning as it will only lead to frustrations.

Sorry if I didn't provide the help you asked. Hopefully I pushed you in the right direction :)

Share this post


Link to post
Share on other sites

OK, you sort of did, It says feb 08 but i was a member since 05 (Different name), now at sole i am a modeler and scripting does not come easy to me.

Now i asked for

Now if anyone had anything they can point me in the right direction would be awsome.

And yes Murrays editing bible is awesome, and i have read it, and yes i have done most of what you have said, now what i was looking for was a simple method for me to create what i want to do, as so use actions. What i was looking for was direction on where to go from here :). But anyway constructive criticism is welcome and i dont blame you for pointing that stuff out. anyway im still trying to get my head around ARMA 2's new commands and stuff so that why i posted.

Share this post


Link to post
Share on other sites

Jantemplar, I don't think you need my cargoscript for what you're trying to do here.

If this is only used for respawn, it's not necessary to have the vehicle carried around in the c130 with my script. Noone will ever see if the vehicle actually was in the c130, before it got dropped, right ?

The script to be used here would be something simillar to an airstrike-script. Spawn a c130, let it fly over the dropzone, spawn a vehicle on a parachute, let the plane fly on, delete the plane. Thats it.

---------- Post added at 01:15 PM ---------- Previous post was at 01:09 PM ----------

Ok damn it. Try this:

http://tajin.evilhosting.de/arma/dropspawn.sqf

nul = [this,"HMMWV",90] execVM "dropspawn.sqf";

first value is the droptarget, an invisible H or whatever.

second value is the type of vehicle to be spawned

third value is the angle where the plane should come from -180°

Its not tested or anything, I've only just altered my airsupport-script on the fly, to drop vehicles instead of blasting the whole place into pieces.

It may need some adjustments, but those are up to you. Editing existing scripts is always a good way to learn anyway. :)

Let me know if it works.

Share this post


Link to post
Share on other sites

Thanks for that , m8,

If this is only used for respawn, it's not necessary to have the vehicle carried around in the c130 with my script. Noone will ever see if the vehicle actually was in the c130, before it got dropped, right ?

The script to be used here would be something simillar to an airstrike-script. Spawn a c130, let it fly over the dropzone, spawn a vehicle on a parachute, let the plane fly on, delete the plane. Thats it.

That would have been enough cause i could have done that, but i would never have though of it.

Anyway, ill check out you script and modify it, and add to it where i need to. :)

---------- Post added at 08:37 AM ---------- Previous post was at 08:07 AM ----------

I cant get it to work, but im going throught the script and puting thins in and taking things out anyway.

What is this

 _target = createVehicle  ["RoadCone",[_pos select 0,_pos select 1,-10], [], 0, "FLY"];
_target setpos [_pos select 0,_pos select 1,0];
_target setDir _dir;

I understand its setting the target, but what it the point of creating a roadcone??

---------- Post added at 09:09 AM ---------- Previous post was at 08:37 AM ----------

Never mind, i found Kronzky Dropit script for arma, and use that as a reference, got it working great. anyway thanks for your guys help.

Share this post


Link to post
Share on other sites

Alright, i decided to get off my ass, compile some people script and produce this World In Conflict Style.....

So this is what i have

if (!isServer) exitWith {};

// Define variables
_unit = _this select 0;
_delay = if (count _this > 1) then {_this select 1} else {30};
_deserted = if (count _this > 2) then {_this select 2} else {120};
_respawns = if (count _this > 3) then {_this select 3} else {0};
_explode = if (count _this > 4) then {_this select 4} else {false};
_dynamic = if (count _this > 5) then {_this select 5} else {false};
_unitinit = if (count _this > 6) then {_this select 6} else {};
_haveinit = if (count _this > 6) then {true} else {false};

_airtype = "C130J";
_typepilot = "GUE_Soldier_Pilot";
mygroup = creategroup side player;
_hasname = false;
_unitname = vehicleVarName _unit;
if (isNil _unitname) then {_hasname = false;} else {_hasname = true;};
_noend = true;
_run = true;
_rounds = 0;

if (_delay < 0) then {_delay = 0};
if (_deserted < 0) then {_deserted = 0};
if (_respawns <= 0) then {_respawns= 0; _noend = true;};
if (_respawns > 0) then {_noend = false};

_dir = getDir _unit;
_position = getPosASL _unit;
_type = typeOf _unit;
_dead = false;
_nodelay = false;


// Start monitoring the vehicle
while {_run} do 
{    
   sleep (2 + random 10);
     if ((getDammage _unit > 0.8) and ({alive _x} count crew _unit == 0)) then {_dead = true};

   // Check if the vehicle is deserted.
   if (_deserted > 0) then
   {
       if ((getPosASL _unit distance _position > 10) and ({alive _x} count crew _unit == 0) and (getDammage _unit < 0.8)) then 
       {
           _timeout = time + _deserted;
           sleep 0.1;
            waitUntil {_timeout < time or !alive _unit or {alive _x} count crew _unit > 0};
           if ({alive _x} count crew _unit > 0) then {_dead = false}; 
           if ({alive _x} count crew _unit == 0) then {_dead = true; _nodelay =true}; 
           if !(alive _unit) then {_dead = true; _nodelay = false}; 
       };
   };

   // Respawn vehicle
     if (_dead) then 
   {    
       if (_nodelay) then {sleep 0.1; _nodelay = false;} else {sleep _delay;};
       if (_dynamic) then {_position = getPosASL _unit; _dir = getDir _unit;};
       if (_explode) then {_effect = "M_TOW_AT" createVehicle getPosASL _unit; _effect setPosASL getPosASL _unit;};
       sleep 0.1;

       deleteVehicle _unit;
       sleep 2;
       _target = createVehicle  ["testsphere2",[_position select 0,_position select 1,-10], [], 0, "FLY"];
       _target setpos [_position select 0,_position select 1,200];
       _target setDir _dir;
       _vdir = vectorDir _target;
       _target setpos [(_position select 0) + (_vdir select 0) * 26, (_position select 1) + (_vdir select 1) * 26,200];
       _apos = getposasl _target;

       _npos = [(_pos select 0) + (_vdir select 0) * -1500, (_pos select 1) + (_vdir select 1) * -1500, 300];

       _vehicle = createVehicle  [_airtype,_npos, [], 0, "FLY"];
       _vehicle setpos _npos;
       _vehicle setDir _dir;

       _vehicle setvelocity [(_vdir select 0)*50,(_vdir select 1)*50, 5];

       _typepilot createUnit [_npos, mygroup,"pilot=this;"];
       _pilot = pilot;
       _pilot moveindriver _vehicle;
       _pilot reveal _target;
       _pilot doMove _npos;
       _pilot dotarget _target;
       _pilot dowatch _target;
       _pilot FlyInHeight 400;
       _vehicle FlyInHeight 400;

       while {_vehicle distance _target > 40} do 
       {
               sleep 0.5;
               if(_vehicle distance _target < 600) then 
               {
                   _pilot FlyInHeight 400;
                   _pilot doMove _npos;
               };
       };

           _bpos = _vehicle ModelToWorld [0,-12,-5.5];
           _unit = _type createVehicle _bpos;
           _unit setpos _bpos;
           _unit setDir direction _vehicle;
           _chute = "ParachuteMediumWest" createVehicle getpos _bomb;
           _chute setpos (_bomb ModelToWorld [0,0,3]);
           _unit attachTo [_chute,[0,0,0]];
           deletevehicle _target;
           sleep 0.05;

   _plane FlyInHeight 250;


   sleep 1;
   _plane FlyInHeight 450;
   _pilot doMove [(_pos select 0) + (_vdir select 0) * 800, (_pos select 1) + (_vdir select 1) * 800, 500];

   sleep 15;

   deletevehicle _vehicle;
   deletevehicle _pilot;

   if (_haveinit) then 
               {_unit setVehicleInit format ["%1;", _unitinit];
               processInitCommands;};
   if (_hasname) then 
               {_unit setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_unitname];
               processInitCommands;};
   _dead = false;

   // Check respawn amount
   if !(_noend) then {_rounds = _rounds + 1};
   if ((_rounds == _respawns) and !(_noend)) then {_run = false;};
   };
};

Now after extensive testing i know it does not work.... It works right up to the Effect point but then the c130 never appears, flys over my head drops the vehicle that died and flies away. Anyone got an idea why. Ive also tried running the game with the -showscripterrors on the end and it only shows erorrs in my briefing and not in this script.

BTW this script is a mix of Tajin c130 dropspawn script and Simple Vehicle Respawn Script by Tophe with edits to them and compiling of them by me.

But if anyone sees whats wrong, please post.

Thanks

Jan Templar

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  

×