Wow, lots of replies, thanks guys.
In the meantime I have tried to update all of my scripts using some c++ code to automatically modify them. My goal was to make every ent_remove call that there is in the script log into a file in case it deletes the entity that my in this function points to.
That doesn't work though, for some reason I suddenly get messages saying entities have "Invalid MDL format". Which is absolutely weird, but it might have something to do with the fact that this logging loads and closes the file way too many times.

Ch40zzC0d3r, I don't think a wait will do the trick. But I can try.
I can also try out EvilSOB's ideas, but I have to leave soon and it will take some time before I can get to it.
JustSid, your idea does sound the most reasonable to me as well. The problem ist that I can rule this out (unless I'm making a mistake here somewhere, so please correct me if I'm wrong!)
Just after posting above, I added two logging functions, before the sys_marker("se0") and before the sys_marker("se5"). In both cases, I log a random value as an "ID", that stays the same throughout the function, to make sure both logging functions use the same ID (so I can find which two log-entries belong to the same instance of the function). Then I log the value of the my pointer.

I get the following log (this is only a small part of it):

.. .. .. .. .. .. !(debug) shieldEffectEnt: 620.665039
.. .. .. .. .. .. !(debug) my:: 48265.832031
.. .. .. .. .. .. !(debug) shieldEffectEnt: 2292.555664
.. .. .. .. .. .. !(debug) my:: 48231.097656
.. .. .. .. .. .. !(debug) shieldEffectEnt: 8088.179688
.. .. .. .. .. .. !(debug) my:: 48280.527344
.. .. .. .. .. .. !(debug) shieldEffectEnt: 5034.590820
.. .. .. .. .. .. !(debug) my:: 48132.238281
.. .. .. .. .. .. !(debug) shieldEffectEnt: 620.665039
.. .. .. .. .. .. !(debug) my:: 48265.832031
As you can see, shieldEffectEnt 620 has the same value when called at the beginning of the function and when called at the end. This means the my pointer does not change. But what you also see is that there's log entries in between the two. That means that I got to the wait somehow, because otherwise the other functions would not have been able to run between the first 620 log entry and the second one.
Here's the code:
Code:
void shieldEffectEnt()
{
	var randID = random(9999);
	logNewValue("shieldEffectEnt", randID, debugLog, OFF);
	logNewValue("my:", my, debugLog, OFF);
	sys_marker("se0");
	set(my,PASSABLE);
	vec_set(my.pan,vector(you.lastHitPan, you.lastHitTilt,0));
	my.flags2 |= UNTOUCHABLE;
	my_playsound(my,shieldHitOGG, volumeMain*volumeFX*500*soundBrightFlash);
	sys_marker("se1");
	my.parent = you;
	sc_ent_shieldImpact(my, getShieldEffectColor(you.shieldEffectType), 15, 1);

	var timePassed = 0;
	while(my != NULL && you != NULL && timePassed < 8)
	{
		sys_marker("se3");
		timePassed += time_frame;
		vec_set(my.x, you.x);
		sys_marker("se4");
		wait(1);
	}
	sys_marker("se2");
	logNewValue("shieldEffectEnt", randID, debugLog, OFF);
	logNewValue("my:", my, debugLog, OFF);
	sys_marker("se5");
	if(my) ent_remove(my);	//will also stop sc_ent_shieldImpact
	sys_marker("se6");
}



The only way that shieldEffectEnt is called is this way:
ent_create(sc_shieldMDL,my.x,shieldEffectEnt);
That means it will never be called with a broken my pointer, unless ent_create fails, in which case shieldEffectEnt should not be called at all.

Edit:
I have tried with a wait(1); before the ent_remove. It changes nothing, same crash in "se5".
These are the last lines of the log before the crash:
Code:
.. .. .. .. .. .. !(debug) shieldEffectEnt: 2816.185547
.. .. .. .. .. .. !(debug) my:: 48288.542969
rkt time: 4648.295898
.. .. .. .. .. .. !(debug) shieldEffectEnt: 2521.109375
.. .. .. .. .. .. !(debug) my:: 48313.925781
.. .. .. .. .. .. !(debug) shieldEffectEnt: 4278.441406
.. .. .. .. .. .. !(debug) my:: 48235.105469
rkt time: 4649.435547
.. .. .. .. .. .. !(debug) shieldEffectEnt: 7803.479492
.. .. .. .. .. .. !(debug) my:: 48406.105469
rkt time: 4650.536133
rkt time: 4651.131836
rkt time: 4652.229492
rkt time: 4652.229492
.. .. .. .. .. .. !(debug) shieldEffectEnt: 5514.889648
.. .. .. .. .. .. !(debug) my:: 48591.800781
rkt time: 4652.820313
.. .. .. .. .. .. !(debug) shieldEffectEnt: 2756.376953
.. .. .. .. .. .. !(debug) my:: 48450.191406
.. .. .. .. .. .. !(debug) shieldEffectEnt: 5325.700195
.. .. .. .. .. .. !(debug) my:: 48590.464844
.. .. .. .. .. .. !(debug) shieldEffectEnt: 9378.639648
.. .. .. .. .. .. !(debug) my:: 48233.769531
.. .. .. .. .. .. !(debug) shieldEffectEnt: 3958.649414
.. .. .. .. .. .. !(debug) my:: 48291.214844
.. .. .. .. .. .. !(debug) shieldEffectEnt: 2816.185547
.. .. .. .. .. .. !(debug) my:: 48288.542969



Last edited by Germanunkol; 02/24/12 16:55.

~"I never let school interfere with my education"~
-Mark Twain