Hello Kartoffel,

I've had "script crash in ...", at seemingly random points as well, and it was in a pathfinding AI. What I did to narrow down the issue, was to program the AI to run around the level forever/automatically so I could get the crash eventually, since it was random/unpredictable.

What ended up being the culprit was me using a VECTOR incorrectly, Im really sorry I dont remember the exact problem, but it was relating to variable memory in a parallel function relating to getting the AI to shove each other if they got too close to each other, and this vector being used in a way it shouldnt have been. I think at some point it may have created garbage values, used by another function which eventually crashed the game.

The good news is that script crashes almost always is your own fault instead of the engine, which means you can fix it! The bad news is that script crashes are your own fault, so you need to sift through your code to figure out whats going on.

Copy your current games working folder, and in this copied folder, comment out and remove every extraneous code outside of the main and level loading script. Comment out the extra includes, and see if your game crashes while level loading. Script an autoreload loop in your main: every 2 seconds, reload the current level, and you will get your crashes eventually, this will help you narrow down what the problem is. Comment out functions that run on level load, and introduce them back, one by one. Functions that use entities or level content that are not initialized should give you an empty pointer error, not script crashes.

Use the level_ent entity, and check to see if this entity is NULL, to determine whether a function should be running only after the level is loaded.

My hunch is that its definitely memory related, but something seemingly tiny like a misused variable, which would corrupt the memory area when another function tries to access garbage data.

Last edited by jumpman; 02/15/18 15:59.