Jump to content
Sign in to follow this  
MacRae

Please Help ASAP Guys!!

Recommended Posts

I have recently ported over a target script from arma 2,

and suring yesterdays update somehow it has corrupt the files,

can anyone tell me how to fix this script please, i am on a timeline and i have only 4 hours to get this fixed!

please help guys!

_target_name = "target";



_path = "una_targets\";
_target = _this select 0;
if(count _this > 1) then {_monitor = _this select 1;};
if(count _this > 2) then {_target_name = _this select 2;};

_scoretable = [];


//_target_name = _this select 3


_target setVectorUp [0,0,1];

//-----------------------------------------------
//Initilize target
//-----------------------------------------------

//set target texture
_target setObjectTexture [0,_path + 'circular_target.paa'];


walk_target_pubvar = null;

//get target center position
_offset =[-0.0825,-1.306];

//calibrated score borders
_borders = [0.310,0.280,0.250,0.220,0.180,0.150,0.120,0.090,0.050,0.035, -0.08];
_holelist = [];
_score_table_count_before = 0;
_action_cs = null;
_action_ct = null;
_action_csm = null;
_action_ctm = null;

//how often the the target is checked for new hits (in seconds)
_sweeptime = 0.1;


//-----------------------------------------------
//target loop
//-----------------------------------------------
_xb = 0;
_yb = 0;

While {true} do {

 //if there has been new hits to the target -> update check target actions 
 if(count _scoretable > _score_table_count_before) then {

   _score_table_count_before = count _scoretable;
   _target removeAction _action_cs;
   _action_cs = _target addaction [format["Inspect %1",_target_name], _path + "check_target.sqf",[_scoretable,_target_name]];
   _target removeAction _action_ct;
   _action_ct = _target addaction [format["Clear %1",_target_name], _path + "clear_target.sqf",_target];



   //Enable target actions from a monitor object
   if(!isNull _monitor) then {

       _monitor = _this select 1;
       _monitor removeAction _action_csm;
       _action_csm = _monitor addaction [format["Inspect %1",_target_name], _path + "check_target.sqf",[_scoretable,_target_name]];
       _monitor removeAction _action_ctm;
       _action_ctm = _monitor addaction [format["Clear %1",_target_name], _path + "clear_target.sqf",_target];

   };

 }
 else {
   _score_table_count_before = count _scoretable;
 };

 //if target has been cleared
 if (walk_target_pubvar == _target) then {
         _scoretable = null; //[COMBAT]Geo modification
         _scoretable = [];
         _score_table_count_before = 0; //[COMBAT]Geo modification
         walk_target_pubvar = null;
         publicVariable "walk_target_pubvar";

         _target removeAction _action_cs;
         _target removeAction _action_ct;
         _monitor removeAction _action_csm;
         _monitor removeAction _action_csm;

         //Enable target actions from a monitor object

   if(!isNull _monitor) then {
       _monitor = _this select 1;
       _monitor removeAction _action_cs;
       _action_cs = _target addaction [format["Inspect %1",_target_name], _path + "check_target.sqf",[_scoretable,_target_name]];
       _monitor removeAction _action_ct;
       _action_ct = _target addaction [format["Clear %1",_target_name], _path + "clear_target.sqf",_target];

   };

 };


 //wait sweeptime
 sleep _sweeptime;


 //get recent hits
 _hits = [(getposATL _target select 0),(getposATL _target select 1),(getposATL _target select 2) -  (_offset select 1)] nearObjects ["#craterOnVehicle",1];

   if(count _hits > 0) then {

     _last_hit = _hits select (count _hits - 1);


       _j = 0;
       //iteratet trough all hits since last sweep
       while { !(_last_hit in _holelist) } do {

         _holelist = _holelist + [_last_hit]; 

         //position of last hit (in world coords)
         _xh = getpos _last_hit select 0;
         _yh = getpos _last_hit select 1;
         _zh = getpos _last_hit select 2;

         //position of target (in world coords)
         _xt = getposATL _target select 0;
         _yt = getposATL _target select 1;
         _zt = getposATL _target select 2;

         //position of last hit (in target coords)
         _xb = sqrt((_xh-_xt)*(_xh-_xt) + (_yh-_yt)*(_yh-_yt)) + (_offset select 0);
         _yb = _zh + (_offset select 1);


         if (_xh < _xt) then {
           _xb = -_xb;
         };
         if ((getdir _target) >= 180) then {
            _xb = -_xb;
         };

         //save the hit positions into an array
         _scoretable = _scoretable + [_xb,_yb];

         _j = _j + 1;

         if (count _hits > (_j)) then {
              _last_hit = _hits select (count _hits - (_j + 1));
         };

       };

     };  
};  

P.S I take NO credit for this script it was created by Walker.

Please help guys i know i can count on you!

~MacRae~

Share this post


Link to post
Share on other sites

it would help to get the error code you have in the report file. can you supply? (I mean just few lines before and few lines after the error, with every different kind of error you have)

actually, what the patch seem to do is only displaying the error concerning undefined variables, but the scripts run as usual.

like if you get this error one time when you connect and never after that, you can easily go with it and not panic. everyone is in the same boat right now.

otherwise, if it is nagging to a point... well, let see your report.

edit1: fast like this I see your _monitor variable not initialized if the parameter is not supplied. can you put an else {_monitor=something}; ?

Edited by holo89

Share this post


Link to post
Share on other sites

Change line 26 to this:

walk_target_pubvar = objNull;

It's used later to compare to an object so you need to use objNull instead of just null.

Share this post


Link to post
Share on other sites

also maybe change your multiple

if (!isNull _monitor)

by

if (!isNil "_monitor") ...

maybe someone else can confirm? Kylania?

Share this post


Link to post
Share on other sites

Kylania that dose not work fro some reason, im just getting loads of Undefined variable errors, can you tell me how to define all the variables?

Share this post


Link to post
Share on other sites

I ran his code as is and got the Object, expected something else error. Changed line 26 and the error went away. :) I've had to put quotes around isNil things before though, but no errors currently. Also no idea if that'll actually work as intended since the objects it's expecting aren't in ArmA3 I don't think.

---------- Post added at 04:04 PM ---------- Previous post was at 04:02 PM ----------

Kylania that dose not work fro some reason, im just getting loads of Undefined variable errors, can you tell me how to define all the variables?

Define them. :) The code you have there doesn't have any so those errors are from other scripts you're using. Many larger scripts like VAS, UPS and whatever else are giving errors so you might look for newer versions of them.

Share this post


Link to post
Share on other sites

what did you change line 26 to?

and i dont know how to define them, can you please tell me how?

Share this post


Link to post
Share on other sites

I showed you above that I changed it to. Just added "obj" to change "null" into "objnull".

To define them is easy, to figure out what they are and what they are supposed to be defined as is more difficult.

Share this post


Link to post
Share on other sites

oh okay, and i know wich variables they are can i just get the code on how to define them...?

Share this post


Link to post
Share on other sites

@kylania

is null a valid variable by default?

if not, and null is not defined anywhere, it could be one of his problem, not?

Share this post


Link to post
Share on other sites

dose anyone know how to define the varables?

Share this post


Link to post
Share on other sites

As far as I can tell it's working for now.

//=====================================================================
//script by Walker
//www.united-nations-army.eu
//=====================================================================
// This script initilizes a new target, collects the positions of the hits.
// The saved positions are passed to check_target.sqf
// Init line: nul = [this] execVM "una_targets\init_target.sqf";
//=====================================================================

_target_name = "target";
_monitor = objnull;


_path = "una_targets\";
_target = _this select 0;
if(count _this > 1) then {_monitor = _this select 1;};
if(count _this > 2) then {_target_name = _this select 2;};

_scoretable = [];


//_target_name = _this select 3


_target setVectorUp [0,0,1];

//-----------------------------------------------
//Initilize target
//-----------------------------------------------

//set target texture
_target setObjectTexture [0,_path + 'circular_target.paa'];


WALK_TARGET_PUBVAR = objnull;

//get target center position
_offset =[0.00,-1.306];

//calibrated score borders
_borders = [0.460,0.410,0.365,0.320,0.270,0.225,0.175,0.130,0.080,0.035, 0];
_holelist = [];
_score_table_count_before = 0;
_action_cs = nil;
_action_ct = nil;
_action_csm = nil;
_action_ctm = nil;

//how often the the target is checked for new hits (in seconds)
_sweeptime = 0.1;


//-----------------------------------------------
//target loop
//-----------------------------------------------
_xb = 0;
_yb = 0;

While {true} do {

 //if there has been new hits to the target -> update check target actions 
 if(count _scoretable > _score_table_count_before) then {

   _score_table_count_before = count _scoretable;
   _target removeAction _action_cs;
   _action_cs = _target addaction [format["Inspect %1",_target_name], _path + "check_target.sqf",[_scoretable,_target_name]];
   _target removeAction _action_ct;
   _action_ct = _target addaction [format["Clear %1",_target_name], _path + "clear_target.sqf",_target];



   //Enable target actions from a monitor object
   if(!isNull _monitor) then {

       _monitor = _this select 1;
       _monitor removeAction _action_csm;
       _action_csm = _monitor addaction [format["Inspect %1",_target_name], _path + "check_target.sqf",[_scoretable,_target_name]];
       _monitor removeAction _action_ctm;
       _action_ctm = _monitor addaction [format["Clear %1",_target_name], _path + "clear_target.sqf",_target];

   };

 }
 else {
   _score_table_count_before = count _scoretable;
 };

 //if target has been cleared
 if (WALK_TARGET_PUBVAR == _target) then {
         _scoretable = nil; //[COMBAT]Geo modification
         _scoretable = [];
         _score_table_count_before = 0; //[COMBAT]Geo modification
         WALK_TARGET_PUBVAR = objnull;
         publicVariable "WALK_TARGET_PUBVAR";

         _target removeAction _action_cs;
         _target removeAction _action_ct;
         _monitor removeAction _action_csm;
         _monitor removeAction _action_csm;

         //Enable target actions from a monitor object

   if(!isNull _monitor) then {
       _monitor = _this select 1;
       _monitor removeAction _action_cs;
       _action_cs = _target addaction [format["Inspect %1",_target_name], _path + "check_target.sqf",[_scoretable,_target_name]];
       _monitor removeAction _action_ct;
       _action_ct = _target addaction [format["Clear %1",_target_name], _path + "clear_target.sqf",_target];

   };

 };


 //wait sweeptime
 sleep _sweeptime;


 //get recent hits
 _hits = [(getposATL _target select 0),(getposATL _target select 1),(getposATL _target select 2) -  (_offset select 1)] nearObjects ["#craterOnVehicle",1];

   if(count _hits > 0) then {

     _last_hit = _hits select (count _hits - 1);


       _j = 0;
       //iteratet trough all hits since last sweep
       while { !(_last_hit in _holelist) } do {

         _holelist = _holelist + [_last_hit]; 

         //position of last hit (in world coords)
         _xh = getpos _last_hit select 0;
         _yh = getpos _last_hit select 1;
         _zh = getpos _last_hit select 2;

         //position of target (in world coords)
         _xt = getposATL _target select 0;
         _yt = getposATL _target select 1;
         _zt = getposATL _target select 2;

         //position of last hit (in target coords)
         _xb = sqrt((_xh-_xt)*(_xh-_xt) + (_yh-_yt)*(_yh-_yt)) + (_offset select 0);
         _yb = _zh + (_offset select 1);


         if (_xh < _xt) then {
           _xb = -_xb;
         };
         if ((getdir _target) >= 180) then {
            _xb = -_xb;
         };

         //save the hit positions into an array
         _scoretable = _scoretable + [_xb,_yb];

         _j = _j + 1;

         if (count _hits > (_j)) then {
              _last_hit = _hits select (count _hits - (_j + 1));
         };

       };

     };  
};  

I never tried the original so I can't say it's as it should be.

Share this post


Link to post
Share on other sites

Thankyou F2k I apriciate it! That worked!

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  

×