this.shipDied event not triggering in 1.75.3

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

this.shipDied event not triggering in 1.75.3

Post by Frame »

I'm trying to remove some frameCallBacks with the this.shipDied handler, for a missile ship script.

Code: Select all

this.shipDied = function(whom, why)
{
	log("missile died because of "+whom+" by "+why)
	removeFrameCallback(this.paused);
	removeFrameCallback(this.detonate);
}
the log message never comes up in the debug console or the log file, even with or without the removeFrameCallBacks, so i must conclude that the trigger is never fired for some reason.

I saw in an earlier post that Thargoid was "complaining" about the same problem here

https://bb.oolite.space/viewtopic.ph ... t=shipDied

if you scroll down to his last post, not the last he complains about that removing the callback is not removed when the ship dies.. and this is on February 20.

can anyone confirm this ?

cheers Frame...
Last edited by Frame on Fri Aug 26, 2011 8:12 pm, edited 1 time in total.
Bounty Scanner
Number 935
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: this.shipDied event not triggering in 1.75.3

Post by Eric Walch »

Frame wrote:
I'm trying to remove some frameCallBacks with the this.shipDied handler, for a missile ship script.
For cleaning up timers and callBacks, you can better use the this.entityDestroyed() handler. Introduced in 1.75.1

e.g. shipDied does not trigger when the player jumps out and the ship/missile is still flying around. this.entityDestroyed() is placed in the routine that always triggers when an entity is removed from memory.

That does not fix the bug in question though.

The problem is that normally the shipDied handler fires, and than the ship is exploded. The AI command becomeExplosion directly starts the explosion and bypasses the handler that way. I think that the easiest way to fix this is -without rewriting everything- to let the AI command becomeExplosion call a special internal function that also triggers the shipDied. And probably with itself as argument.
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Re: this.shipDied event not triggering in 1.75.3

Post by Frame »

ahh thanks for clearing that up.

the missiles got a very limited lifespan, so i'll just trigger it via a timer...
Bounty Scanner
Number 935
User avatar
CommonSenseOTB
---- E L I T E ----
---- E L I T E ----
Posts: 1397
Joined: Wed May 04, 2011 10:42 am
Location: Saskatchewan, Canada

Re: this.shipDied event not triggering in 1.75.3

Post by CommonSenseOTB »

So Eric, are you saying that I should use this.entityDestroyed() instead of this.shipDied() in any script that has frameCallbacks and Timers(all my oxp's)? As far as I know everything works super using this.shipDied(). I'm not sure I understand what exactly the problem is. :?

Is this a problem only with becomeExplosion?
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: this.shipDied event not triggering in 1.75.3

Post by Thargoid »

Hmm, I hadn't even noticed that entityDestroyed() existed! Obviously snuck in without me noticing...

OTB - from the wiki it's an NPC event, so may not work for the player ship (I haven't tested it to see) so it may be of limited use to you (presuming you're referring to HUD support-script usage). Will certainly need to experiment with it and the callBack butterflies at some point soon though.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: this.shipDied event not triggering in 1.75.3

Post by Eric Walch »

I just committed r4604. The AI commands 'becomeExplosion' and "becomeEnergyBlast' now also trigger the shipDied() handler. I was thinking about using 'self" as the who parameter, but because the JS method explode() gives null and energyDamage, the same now happens with the AI command.
I think it went wrong around oolite 1.71. In the past, 'becomeExplosion' did trigged the death events.
CommonSenseOTB wrote:
So Eric, are you saying that I should use this.entityDestroyed() instead of this.shipDied() in any script that has frameCallbacks and Timers(all my oxp's)? As far as I know everything works super using this.shipDied(). I'm not sure I understand what exactly the problem is. :?
shipDied() is not always triggering. e.g. not when a ship docks or when a ship leaves the system trough a wormhole. Also when the player leaves the system, all remaining ships are removed silently without triggering a shipDied event.

I only know that in the past there were a lot of crashes because of timers that were still firing but the code they called was already removed. I think that the crashes are now fixed because the timers now notice that the underlying script has been removed, but for the benefit of real cleanup code the this.entityDestroyed()was added. This always fires, no matter how the entity was removed.
User avatar
CommonSenseOTB
---- E L I T E ----
---- E L I T E ----
Posts: 1397
Joined: Wed May 04, 2011 10:42 am
Location: Saskatchewan, Canada

Re: this.shipDied event not triggering in 1.75.3

Post by CommonSenseOTB »

Eric, I was just reading an old missiles related viewtopic and it got me thinking.

Could this

https://bb.oolite.space/viewtopic.php?f= ... le#p135189

and this

https://bb.oolite.space/viewtopic.php?f= ... 7&start=15

Edit:and just found this

https://bb.oolite.space/viewtopic.php?f= ... le#p106866

be related to the crashing timers because this.shipDied() wasn't firing? The field missile and the mini missile and the trident are all Thargoid's and like myself he never heard of this.entityDestroyed() till now so it isn't in these missile's scripts. Could this be the reason for the long running problem of CTD's sometimes happening when a missile is fired off? They seem to be connected to me and was wondering what you thought.
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: this.shipDied event not triggering in 1.75.3

Post by Eric Walch »

CommonSenseOTB wrote:
be related to the crashing timers because this.shipDied() wasn't firing? The field missile and the mini missile and the trident are all Thargoid's and like myself he never heard of this.entityDestroyed() till now so it isn't in these missile's scripts. Could this be the reason for the long running problem of CTD's sometimes happening when a missile is fired off? They seem to be connected to me and was wondering what you thought.
No, i don't think the this.shipDied() not firing has anything to do with the reported crashes. Not firing happens when the missile detonates itself and that is at the end of the missile lifetime and not as reported on launch. But I agree that most reports are very incomplete and only blame a missile, but don't state if it happened on missile launch or missile explosion. The report of zsozso is very clearly and for him it happened on launch of plain hardheads. So no oxp missiles. This suggest it is not something special in the missile script itself that triggers the problem. Hence I thought is might be the target script (If not the default script).
It could be something from the launching ship, but no report states from which ships the missile is fired or if some special huds are used. So I assume this also was pretty standard. Leaving the bug of CTD on missile launch still open. Earliest reports were from 1.75.1
Post Reply