Jump to content
ribera1945e

[Need help] My missions always crash in the middle.

Recommended Posts

I created the mission using a script in an environment with add-ons in place.
However, when testing in multiplayer, when I place a BRUFOR AI unit group in ZEUS and have them attack the AO, it crashes with access violations in the middle of the mission. This is the same on both dedicated and hosted servers.
I am new to scripting and with the help of a friend I created a mission but could not find the cause of the crash.
I would like to ask everyone to help me debug this mission.

Here is the zip of the mission and the add-on preset html we are using

Thanks.

Share this post


Link to post
Share on other sites

Still need help.
The rpt file did not make sense to me.
Most of the time it crashes after the fight starts.
The timing of the crash is completely random.

Share this post


Link to post
Share on other sites

Would it be too much work if you create a new mission from scratch, but trying to replicate the same steps/objectives in a much smaller scale - best if using the same types of units -, while copying ALL the external files EXCEPT the mission.sqm itself? That at least could help you rule out whether the issue inhabits some of the scripts or the mission objects themselves. 🧐

Share this post


Link to post
Share on other sites

Hello, JCataclisma.
I have split and tested the scripts of the mission.
As a result, I have identified the scripts that contain the cause.
This is the script that gives the AI units randomized equipment by reference to their class name.

 

/*
Script aiLoadout

Description:
- setUnitLoadoutを使用しユニットロードアウト配列に従ってAIの装備を変更する。

Parameter(s):
- unit		: <OBJECT> 装備を変更したいユニット

Example:
- nul = [this] execVM "scripts\aiLoadout.sqf";

Returns:
- Nothing

Author:
- ribera1945e
*/
params [["_unit", objNull, [objNull]]];

if (isNull _unit) exitWith {};
if (!local _unit) exitWith {};

if (side _unit != MC_VAR_EnemySide) exitWith {};

/* 初期化 */

private [
	"_arrayPrimary","_primary","_elementPrimary",
	"_secondary","_elementSecondary",
	"_handgun","_elementHandgun",
	"_arrayUniform","_uniform","_elementUniform",
	"_arrayVest","_vest","_elementVest",
	"_arrayBackpack","_backpack","_elementBackpack",
	"_arrayHeadgear","_headgear",
	"_arrayGoggles","_goggles",
	"_bino","_elementBino",
	"_NV"
];
_arrayPrimary = [];
_primary = [];
_elementPrimary = [];
_secondary = [];
_elementSecondary = [];
_handgun = [];
_elementHandgun = [];
_arrayUniform = [];
_uniform = [];
_elementUniform = [];
_arrayVest = [];
_vest = [];
_elementVest = [];
_arrayBackpack = [];
_backpack = [];
_elementBackpack = [];
_arrayHeadgear = [];
_headgear = [];
_arrayGoggles = [];
_goggles = [];
_bino = [];
_elementBino = [];
_NV = [];
//空の装備を読み込み
private _arrayLoadout = getUnitLoadout (configFile >> "EmptyLoadout");

/* 共通装備登録 */
_arrayHeadgear = [
	"CUP_O_TKI_Khet_Partug_06",
	"CUP_H_TKI_Lungee_Open_06",
	"CUP_H_TK_Lungee",
	"CUP_H_TKI_Lungee_Open_01",
	"CUP_H_TKI_Lungee_Open_02",
	"CUP_H_TKI_Lungee_Open_03",
	"CUP_H_TKI_Lungee_Open_04",
	"CUP_H_TKI_Lungee_Open_05",
	"CUP_H_TKI_Lungee_Open_06",
	"CUP_H_TKI_Lungee_01",
	"CUP_H_TKI_Lungee_02",
	"CUP_H_TKI_Lungee_03",
	"CUP_H_TKI_Lungee_04",
	"CUP_H_TKI_Lungee_05",
	"CUP_H_TKI_Lungee_06",
	"CUP_H_TKI_Pakol_1_01",
	"CUP_H_TKI_Pakol_2_04",
	"CUP_H_TKI_Pakol_2_05",
	"CUP_H_TKI_Pakol_2_06",
	"CUP_H_TKI_Pakol_1_02",
	"CUP_H_TKI_Pakol_1_03",
	"CUP_H_TKI_Pakol_1_04",
	"CUP_H_TKI_Pakol_1_05",
	"CUP_H_TKI_Pakol_1_06",
	"CUP_H_TKI_Pakol_2_01",
	"CUP_H_TKI_Pakol_2_02",
	"CUP_H_TKI_Pakol_2_03",
	"CUP_H_TKI_SkullCap_01",
	"CUP_H_TKI_SkullCap_02",
	"CUP_H_TKI_SkullCap_03",
	"CUP_H_TKI_SkullCap_04",
	"CUP_H_TKI_SkullCap_05",
	"CUP_H_TKI_SkullCap_06"
];
_headgear = selectRandom _arrayHeadgear;

_arrayUniform = [
	"CUP_O_TKI_Khet_Jeans_04",
	"CUP_O_TKI_Khet_Jeans_02",
	"CUP_O_TKI_Khet_Jeans_01",
	"CUP_O_TKI_Khet_Jeans_03",
	"CUP_O_TKI_Khet_Partug_04",
	"CUP_O_TKI_Khet_Partug_02",
	"CUP_O_TKI_Khet_Partug_01",
	"CUP_O_TKI_Khet_Partug_07",
	"CUP_O_TKI_Khet_Partug_08",
	"CUP_O_TKI_Khet_Partug_05",
	"CUP_O_TKI_Khet_Partug_06"
];
_uniform = selectRandom _arrayUniform;

_arrayVest = [
	"CUP_V_OI_TKI_Jacket2_04",
	"CUP_V_OI_TKI_Jacket4_04",
	"CUP_V_OI_TKI_Jacket4_05",
	"CUP_V_OI_TKI_Jacket4_02",
	"CUP_V_OI_TKI_Jacket4_06",
	"CUP_V_OI_TKI_Jacket4_03",
	"CUP_V_OI_TKI_Jacket4_01",
	"CUP_V_OI_TKI_Jacket3_04",
	"CUP_V_OI_TKI_Jacket3_02",
	"CUP_V_OI_TKI_Jacket3_03",
	"CUP_V_OI_TKI_Jacket3_05",
	"CUP_V_OI_TKI_Jacket3_06",
	"CUP_V_OI_TKI_Jacket3_01",
	"CUP_V_OI_TKI_Jacket6_04",
	"CUP_V_OI_TKI_Jacket6_05",
	"CUP_V_OI_TKI_Jacket6_02",
	"CUP_V_OI_TKI_Jacket6_06",
	"CUP_V_OI_TKI_Jacket6_03",
	"CUP_V_OI_TKI_Jacket6_01",
	"CUP_V_OI_TKI_Jacket2_04",
	"CUP_V_OI_TKI_Jacket2_06",
	"CUP_V_OI_TKI_Jacket2_03",
	"CUP_V_OI_TKI_Jacket2_02",
	"CUP_V_OI_TKI_Jacket2_05",
	"CUP_V_OI_TKI_Jacket2_01"
];
_vest = selectRandom _arrayVest;

_arrayBackpack = [
	"CUP_B_AlicePack_Bedroll",
	"CUP_B_AlicePack_Khaki",
	"CUP_B_AlicePack_OD",
	"CUP_B_Bergen_BAF",
	"CUP_B_CivPack_WDL",
	"CUP_B_ACRPara_dpm",
	"CUP_B_ACRPara_m95",
	"CUP_B_HikingPack_Civ",
	"CUP_B_RUS_Backpack",
	"CUP_B_TacticalPack_CCE",
	"CUP_B_TacticalPack_TTS"
];
_backpack = selectRandom _arrayBackpack;

_arrayGoggles = [
	"G_Bandanna_blk",
	"G_Bandanna_khk",
	"G_Bandanna_oli",
	"G_Bandanna_shades",
	"G_Bandanna_sport",
	"G_Bandanna_tan",
	"TRYK_Beard_BK",
	"TRYK_Beard_BK2",
	"TRYK_Beard_BK3",
	"TRYK_Beard_BK4",
	"TRYK_SBeard_BK6",
	"CUP_Beard_Black"
];
_goggles = selectRandom _arrayGoggles;

/* Identity */
private ["_arrayFace","_face","_arraySpeeker","_speeker","_pitch"];
	_arrayFace = [
	"PersianHead_A3_01",
	"PersianHead_A3_02",
	"PersianHead_A3_03"
	];
_face = selectRandom _arrayFace;

	_arraySpeeker = [
	"cup_d_male01_tk",
	"cup_d_male02_tk",
	"cup_d_male03_tk",
	"cup_d_male04_tk",
	"cup_d_male05_tk"
	];
_speeker = selectRandom _arraySpeeker;

_pitch = random[0.8,1,1.2];

/* Gear selection */
private "_type";
switch(typeOf _unit) do{
	
	case "CUP_I_TK_GUE_Soldier_AT":	// RPG7 man
	{
		_arrayPrimary = [
			"CUP_arifle_AKMS_Early",
			"CUP_arifle_AKMS",
			"CUP_arifle_AKS"
		];
		_primary = selectRandom _arrayPrimary;
		_elementPrimary = [_primary,
			"",
			"",
			"",
			["CUP_30Rnd_TE1_Green_Tracer_762x39_AK47_M",30],
			[],
			""
		];
		
		_elementVest = [_vest,[
			["CUP_30Rnd_TE1_Green_Tracer_762x39_AK47_M",6,30],
			["rhs_mag_f1",1,1]
		]];
		
		_secondary = "launch_RPG7_F";
		_elementSecondary = [_secondary,
			"",
			"",
			"",
			["RPG7_F",1],
			[],
			""
		];
		
		_elementBackpack = ["rhs_rpg_empty",[
			["RPG7_F",2,1]
		]];
	};
	
	case "CUP_I_TK_GUE_Soldier_GL":	// Grenadier
	{
		_arrayPrimary = [
			"CUP_arifle_AK47_GL_Early",
			"CUP_arifle_AKM_GL_Early",
			"CUP_arifle_AKM_GL",
			"CUP_arifle_AKMS_GL_Early",
			"CUP_arifle_AKMS_GL",
			"CUP_arifle_AK47_GL"
		];
		_primary = selectRandom _arrayPrimary;
		_elementPrimary = [_primary,
			"",
			"",
			"",
			["CUP_30Rnd_TE1_Green_Tracer_762x39_AK47_M",30],
			["rhs_VOG25",1],
			""
		];
		_elementVest = [_vest,[
			["CUP_30Rnd_TE1_Green_Tracer_762x39_AK47_M",6,30],
			["CUP_1Rnd_HE_GP25_M",1,1],
			["rhs_mag_f1",1,1]
		]];
		_elementBackpack = [_backpack,[
			["CUP_30Rnd_TE1_Green_Tracer_762x39_AK47_M",6,30],
			["CUP_1Rnd_HE_GP25_M",1,1]
		]];
	};
	
	case "CUP_I_TK_GUE_Soldier_AR":	// Auto rifleman RPK74
	{
		_primary = "CUP_arifle_RPK74_45";
		_elementPrimary = [_primary,
			"",
			"",
			"",
			["rhs_45Rnd_545X39_AK_Green",45],
			[],
			""
		];
		_elementVest = [_vest,[
			["rhs_45Rnd_545X39_AK_Green",5,45],
			["rhs_mag_f1",1,1]
		]];
		_elementBackpack = [_backpack,[
			["rhs_45Rnd_545X39_AK_Green",5,40]
		]];
	};
	
	case "CUP_I_TK_GUE_Soldier_MG":	// Machinegunner
	{
		_primary = "CUP_lmg_PKM";
		_elementPrimary = [_primary,
			"",
			"",
			"",
			["CUP_100Rnd_TE4_LRT4_762x54_PK_Tracer_Green_M",100],
			[],
			""
		];
		_elementVest = [_vest,[
			["CUP_100Rnd_TE4_LRT4_762x54_PK_Tracer_Green_M",2,100],
			["rhs_mag_f1",1,1]
		]];
		_elementBackpack = [_backpack,[
			["CUP_100Rnd_TE4_LRT4_762x54_PK_Tracer_Green_M",3,100]
		]];
	};
	
	case "CUP_I_TK_GUE_Guerilla_Enfield":	// Marksman
	{
		_primary = "CUP_srifle_SVD";
		_elementPrimary = [_primary,
			"",
			"",
			"CUP_optic_PSO_1",
			["CUP_10Rnd_762x54_SVD_M",10],
			[],
			""
		];
		_elementVest = [_vest,[
			["CUP_10Rnd_762x54_SVD_M",6,10],
			["rhs_mag_f1",1,1]
		]];
		_elementBackpack = [_backpack,[
			["CUP_10Rnd_762x54_SVD_M",6,10]
		]];
	};
	
	case "CUP_I_TK_GUE_Sniper":	// Sniper
	{
		_primary = "CUP_srifle_ksvk";
		_elementPrimary = [_primary,
			"",
			"",
			"CUP_optic_PSO_3",
			["CUP_5Rnd_127x108_KSVK_M",5],
			[],
			""
		];
		_elementVest = [_vest,[
			["CUP_5Rnd_127x108_KSVK_M",4,5],
			["rhs_mag_f1",1,1]
		]];
		_elementBackpack = [_backpack,[
			["CUP_5Rnd_127x108_KSVK_M",4,5]
		]];
	};
	
	case "CUP_I_TK_GUE_Soldier_TL":	// Team Leader
	{
		_arrayVest = [
			"V_TacVest_blk",
			"V_TacVest_brn",
			"V_TacVest_camo",
			"V_TacVest_khk",
			"V_TacVest_oli",
			"V_I_G_resistanceLeader_F"
		];
		_vest = selectRandom _arrayVest;
		
		_primary = "CUP_arifle_M4A3_black";
		_elementPrimary = [_primary,
			"",
			"CUP_acc_ANPEQ_15_Top_Flashlight_Black_L",
			"CUP_optic_ACOG_TA31_KF",
			["CUP_30Rnd_556x45_Stanag_Tracer_Red",30],
			[],
			""
		];
		_elementVest = [_vest,[
			["CUP_30Rnd_556x45_Stanag_Tracer_Red",6,30],
			["rhs_mag_f1",1,1]
		]];
		_elementBackpack = [_backpack,[
			["CUP_30Rnd_556x45_Stanag_Tracer_Red",6,30]
		]];
	};
	
	case "CUP_I_TK_GUE_Commander":	// Warlord
	{
		_uniform = "CUP_O_TKI_Khet_Partug_01";
		_elementPrimary = ["CUP_arifle_AKS74U",
			"",
			"",
			"",
			["CUP_30Rnd_TE1_Green_Tracer_545x39_AK_M",30],
			[],
			""
		];
		_vest = "CUP_V_OI_TKI_Jacket5_04";
		_elementVest = [_vest,[
			["CUP_30Rnd_TE1_Green_Tracer_545x39_AK_M",6,30],
			["rhs_mag_f1",1,1]
		]];
		_backpack = "";
		_face = "Mavros";
		_speeker = "male03gre";
		_headgear = "CUP_H_TKI_Lungee_Open_04";
		_goggles = "CUP_Beard_Black";
	};
	
	case "C_man_1":	// Civilian
	{
		_vest = "";
		_backpack = "";
	};
	
		default
	{
		_type = selectRandom ["typeAR","typeAK"];
		switch(_type) do{
			case "typeAR":
			{
				_arrayPrimary = [
					"CUP_arifle_M16A2",
					"CUP_arifle_Colt727",
					"CUP_arifle_M4A1"
				];
				_primary = selectRandom _arrayPrimary;
				_elementPrimary = [_primary,
					"",
					"",
					"",
					["CUP_30Rnd_556x45_Stanag_Tracer_Red",30],
					[],
					""
				];
				
				_elementVest = [_vest,[
					["CUP_30Rnd_556x45_Stanag_Tracer_Red",6,30],
					["rhs_mag_f1",1,1]
				]];
				_elementBackpack = [_backpack,[
					["CUP_30Rnd_556x45_Stanag_Tracer_Red",6,30]
				]];
			};
			case "typeAK":
			{
				_arrayPrimary = [
					"CUP_arifle_AK74",
					"CUP_arifle_AKS74",
					"CUP_arifle_AK74_Early",
					"CUP_arifle_AKS74_Early"
				];
				_primary = selectRandom _arrayPrimary;
				_elementPrimary = [_primary,
					"",
					"",
					"",
					["CUP_30Rnd_TE1_Green_Tracer_545x39_AK_M",30],
					[],
					""
				];
				
				_elementVest = [_vest,[
					["CUP_30Rnd_TE1_Green_Tracer_545x39_AK_M",6,30],
					["rhs_mag_f1",1,1]
				]];
				_elementBackpack = [_backpack,[
					["CUP_30Rnd_TE1_Green_Tracer_545x39_AK_M",6,30]
				]];
			};
		};
	};
};

/* Uniform element set */
_elementUniform = [_uniform,[
	["ACE_fieldDressing",5],
	["ACE_elasticBandage",5],
	["ACE_packingBandage",5],
	["ACE_tourniquet",1],
	["ACE_splint",1]
]];


/* Construct haracter */
_arrayLoadout = [
	_elementPrimary,
	_elementSecondary,
	_elementHandgun,
	_elementUniform,
	_elementVest,
	_elementBackpack,
	_headgear,
	_goggles,
	_elementBino,
	[
		"ItemMap",		// Map type
		"ItemGPS",		// GPS type
		"ItemRadio",	// Radio type
		"ItemCompass",	// Compass type
		"ItemWatch",	// Watch type
		_NV				// NV type
	]
];

_unit setUnitLoadout _arrayLoadout;
[_unit, _face, _speeker, _pitch] call BIS_fnc_setIdentity;

nil

If a unit to which this script is applied dies, it will crash with a certain probability.
Is there something wrong with this script?
Cheer.

Share this post


Link to post
Share on other sites
15 hours ago, ribera1945e said:

If a unit to which this script is applied dies, it will crash with a certain probability.
Is there something wrong with this script?

 

On their own scripts rarely cause "access violations", they run in the script engine which should catch errors without crashing the game.

Of course this could be a weird edge case but your script has no loops and ends as soon as all code has executed, likely long before the unit dies.

 

Are you sure the problem occurs only with this script enabled?

 

If No: Keep testing more things in isolation, shut down systems in broad strokes and refine the search each time you test, it's a lot of work but a sure way forward.

 

If Yes: Since the problem happens sometimes it is more likely to be one of the items or identities that are the root cause. It may be a bug in one of the mods you are using...

The only code where you have any randomness involved seems to be the in the selection of identity.


To find out which unit, items and identity are causing the problem you can try add event handlers for hits and kills to print out which are involved. This is of course assuming the death is actually the trigger.

After adding them try forcing the crash and then check the log file, unless the crash happens the same frame the unit dies the last entry in .rpt before the crash message should contain your culprit, just check the timestamps to make sure.

Put something like this at the end of your script to get the debug printouts, just remember to remove them before release 🙂

 

Spoiler

// ...

/* Construct haracter */
_arrayLoadout = [
	_elementPrimary,
	_elementSecondary,
	_elementHandgun,
	_elementUniform,
	_elementVest,
	_elementBackpack,
	_headgear,
	_goggles,
	_elementBino,
	[
		"ItemMap",		// Map type
		"ItemGPS",		// GPS type
		"ItemRadio",	// Radio type
		"ItemCompass",	// Compass type
		"ItemWatch",	// Watch type
		_NV				// NV type
	]
];

_unit setUnitLoadout _arrayLoadout;

private _identity = [_unit, _face, _speeker, _pitch]; // Note: Moved the identity parameters to a variable
_identity call BIS_fnc_setIdentity;

// Add logging on death to identify access violations
_unit setVariable [ "DEBUG_loadout:", _arrayLoadout ];
_unit setVariable [ "DEBUG_identity:", _identity ];

_fnc_printDebugMsg = {
	params ["_unit"];
	diag_log format [ "DEBUG Type: %1", typeOf _unit];
	diag_log format [ "DEBUG Identity: %1", _unit getVariable "DEBUG_identity" ];
	diag_log format [ "DEBUG Loadout: %1", _unit getVariable "DEBUG_loadout" ];
};

_unit addEventHandler ["Dammaged", _fnc_printDebugMsg ];
_unit addEventHandler ["Killed", _fnc_printDebugMsg ];
// End of logging

nil

 

 

As a side note:

You also seem to have some rogue Unicode Characters (U+FEFF) on line 195 and 197. 

Could be an artefact of the forum formatting and probably not relevant but worth cleaning out anyway if you have them on your end.

 

RogueUnicodeCharacters.png?rlkey=v532hly

  • Like 1

Share this post


Link to post
Share on other sites

Hi mrcurry.
I have tried many times and it crashes randomly only when the unit that the script described in my previous post is executed dies.
I was able to confirm this in a test scenario where I extracted only this script.

I have tested it by adding to the script you added the code to so that it is also debugged output at the end of the script.

The test is to use Zeus to get the CUP's Takistan locals infantry out from under the list and shoot to kill.
I ran the test 3 times and in each case it crashed when I killed a random unit before finishing the entire list.
I checked the _arrayLoadout of the units that crashed on kill and found a common denominator. To my surprise, the _headgear stored the uniform class name.

19 hours ago, ribera1945e said:

"CUP_O_TKI_Khet_Partug_06",


We checked the arsenal of scripted units with the script limited to only this much headgear, and found that they had uniforms in their headgear and would crash if we killed a unit with such incorrect equipment. If the wrong one of the 33 class names on the headgear list was drawn, a "mine unit" would be created.
 

I don't know if I was tired or drunk when I wrote this list of scripts, but there is a saying in Japanese: "It is darkest under the lamp. It is probably because of my belief that the list I wrote is correct that I did not notice such a careless mistake.

And so the crashing mission that had tormented me for two years was back to normal.

Thank you both. Cheers to all the wonderful forum members.

 

  • Like 2

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

×