Jump to content
Sign in to follow this  
thevisad

Possible bug in INIT handling or I am doing something wrong here?

Recommended Posts

I am working on a base protection script for COOP missions. This will remove all damage from the vehicles/players and prevent any TK from happening while in a safe zone. The player script works properly and any damage by a player is 100% prevented. However, when adding a variation of the script to a vehicle, it will only cleanup some of the damage. When parsing out the information, its dropping the object in 6 to <NULL-object>, but this does not occur every time. It seems to be random and doesn't matter what vehicle is using this. In this I was testing with the AH-9.

//  add this to your vehicle init _index = this addEventHandler ["Fired", {Null = _this execVM "scripts\baseDamageRemovalVehicle.sqf";}]; 
#define SAFEZONES	[["respawn_west", 400],["sf_team",100]] 
#define FIREMESSAGE			"No firing of any kind in base!"

if (isDedicated) exitWith {};
diag_log("VAR 0: " + str(_this select 0));
diag_log("VAR 1: " + str(_this select 1));
diag_log("VAR 2: " + str(_this select 2));
diag_log("VAR 3: " + str(_this select 3));
diag_log("VAR 4: " + str(_this select 4));
diag_log("VAR 5: " + str(_this select 5));
diag_log("VAR 6: " + str(_this select 6));
shotsFired = shotsFired + 1;

if (_this select 2 == "LMG_Minigun_heli" || _this select 2 == "missiles_DAGR" || _this select 2 == "CMFlareLauncher" || _this select 2 == "M134_minigun" || _this select 2 == "missiles_DAR" || _this select 2 == "SmokeLauncher" || _this select 2 == "GMG_40mm" || _this select 2 == "HMG_Mk30" || _this select 2 == "LMG_Minigun") then
{
if ({(_this select 0) distance getMarkerPos (_x select 0) < _x select 1} count SAFEZONES > 0) then
{
deleteVehicle (_this select 6);
titleText [FIREMESSAGE, "PLAIN", 3];
diag_log("shotsFired: " + str(shotsFired));
diag_log("DELETED: " + str(_this select 6));
};
};

"VAR 0: B Alpha 1-2:14 (thevisad)"
"VAR 1: "missiles_DAR""
"VAR 2: "missiles_DAR""
"VAR 3: "Burst""
"VAR 4: "M_AT""
"VAR 5: "24Rnd_missiles""
"VAR 6: <NULL-object>"
"shotsFired: 173"
"DELETED: <NULL-object>"
"VAR 0: B Alpha 1-2:14 (thevisad)"
"VAR 1: "missiles_DAR""
"VAR 2: "missiles_DAR""
"VAR 3: "Burst""
"VAR 4: "M_AT""
"VAR 5: "24Rnd_missiles""
"VAR 6: 164573: 70mmrocket.p3d"
"shotsFired: 174"
"DELETED: 164573: 70mmrocket.p3d"
"VAR 0: B Alpha 1-2:14 (thevisad)"
"VAR 1: "missiles_DAR""
"VAR 2: "missiles_DAR""
"VAR 3: "Burst""
"VAR 4: "M_AT""
"VAR 5: "24Rnd_missiles""
"VAR 6: <NULL-object>"
"shotsFired: 175"
"DELETED: <NULL-object>"
"VAR 0: B Alpha 1-2:14 (thevisad)"
"VAR 1: "missiles_DAR""
"VAR 2: "missiles_DAR""
"VAR 3: "Burst""
"VAR 4: "M_AT""
"VAR 5: "24Rnd_missiles""
"VAR 6: 164575: 70mmrocket.p3d"
"shotsFired: 176"
"DELETED: 164575: 70mmrocket.p3d"
"VAR 0: B Alpha 1-2:14 (thevisad)"
"VAR 1: "missiles_DAR""
"VAR 2: "missiles_DAR""
"VAR 3: "Burst""
"VAR 4: "M_AT""
"VAR 5: "24Rnd_missiles""
"VAR 6: 164578: 70mmrocket.p3d"
"shotsFired: 177"

Share this post


Link to post
Share on other sites

I know this is an obvious question, but have you confirmed that the script does not delete the projectile whenever diag_log prints <NULL-object>? I only as because to me it seems that diag_log is printing <NULL-object> because by the time it gets to actually output it to the log the projectile has already been deleted and appears to be null (even though you use the diag_log command before you actually delete the projectile.

FYI, just a small tip, I recommend using the in command when doing your conditional check to make your code easier to maintain in case you want to add or delete weapons. Example:

_weapons = ["LMG_Minigun_heli", "missiles_DAGR", "CMFlareLauncher", "M134_minigun", "missiles_DAR", "SmokeLauncher", "GMG_40mm", "HMG_Mk30", "LMG_Minigun"];
if (_this select 2) in _weapons then
{
   if ({(_this select 0) distance getMarkerPos (_x select 0) < _x select 1} count SAFEZONES > 0) then
   {
         deleteVehicle (_this select 6);
         titleText [FIREMESSAGE, "PLAIN", 3];
         diag_log("shotsFired: " + str(shotsFired));
         diag_log("DELETED: " + str(_this select 6));
   };
};

Share this post


Link to post
Share on other sites

I wish that were the case, I rearranged the log printouts at this point in the script because I was having other issues and forgot to put it back. Also you notize its deleting some but not others in the log file. If you use this script and attach it to the AH-9 you will see it definitely deletes only part of the shots being fired. This is whether you are shooting the missiles or the mini-gun. I would assume the same to be true of the other vehicles; although. I have not tested.

Thanks for the tip there, I will implement that in the script.

Edited by thevisad

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  

×