Weird doubling bonus

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

Moderators: winston, another_commander, Getafix

Post Reply
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Weird doubling bonus

Post by UK_Eliter »

Dear all

I've got oolite-trunk-1.75.4.4607-dev.win32 and armoury.oxp 1.08. And I can report than when I launch a combat drone, I get two! And when I launch thargon fighters, I get ten!
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6633
Joined: Wed Feb 28, 2007 7:54 am

Re: Weird doubling bonus

Post by another_commander »

Does the same happen with v1.75.3?
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Weird doubling bonus

Post by Thargoid »

Confirmed the combat drone - in 1.75.4.4607 you get two per launch.

On 1.75.3 you get only one.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6633
Joined: Wed Feb 28, 2007 7:54 am

Re: Weird doubling bonus

Post by another_commander »

OK, it seems that the this.shipDied handler in drones_Launcher.js is firing twice. I guess we can go through the changelogs since 1.75.3 (should not be that many) and try to pinpoint the exact revision where this started happening.
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: Weird doubling bonus

Post by Eric Walch »

It is not a bug in Ooltite but an oxp that tries to fix a bug himself. It is the drone launcher AI

Code: Select all

UPDATE	= (becomeExplosion, "sendScriptMessage: shipDied");
When the mine now explodes itself it sends a "shipDied". But on top of that, the AI also sends a script message for "shipDied".

Missiles not receiving a shipDied event was fixed after 1.75.3
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Weird doubling bonus

Post by Thargoid »

OK - I'll make a second version of the OXP available later fixing it for use with trunk (there may be other AIs that have that in them too, for the same reason).
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: Weird doubling bonus

Post by Eric Walch »

I must say that some of my missiles also did send a shipDied by scriptMessage to compensate for the bug, but I always made sure the handler deleted itself on use, to avoid double triggering in case it would start working as it should.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Weird doubling bonus

Post by Thargoid »

Hmm, indeed a more elegant solution. I'll update later to implement that into the OXP (and any others that have that bugfix built-in).
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: Weird doubling bonus

Post by UK_Eliter »

Dear all

Hey, you are (as they say) all over this one! Thanks. But I am confused by the technicalities, which may matter because I wonder whether I should adjust my own missile OXP ('nexus' oxp, which involves submunitions). Do I need to add some 'shipdied' code (or something), please?

Thanks.
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: Weird doubling bonus

Post by Eric Walch »

UK_Eliter wrote:
Do I need to add some 'shipdied' code (or something), please?
When you want to fix it yourself you must find the shipscript and look for the part

Code: Select all

this.shipDied = function ()
{
    .....
    code
    ....
}
and change it into

Code: Select all

this.shipDied = function ()
{
    .....
    code
    ....
   delete this.shipDied;
}
You can add the line at the end or the beginning, it does not matter. This will ensure that when this function is called twice, it will be gone on the second call. So, this ensures that the code can only run once.

However, when your missile script has no shipDied() event in the first place you don't need to worry at all. Problem was that missiles used the death_actions until 1.71. After that this was broken since 1.72 and apparently nobody cared to repair it in oolite (#). Or it was forgotten because there was no official bug report about it on Berlios. In trunk it now works again, but oxps that bypassed this bug might suffer problems now, that are easy to fix in a way that makes them compatible with all oolite versions.

#) That includes me as I thought it is easy to deal with by script. Only after there was a new report about this bug I did fix it to make it consistent with normal ships.
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: Weird doubling bonus

Post by UK_Eliter »

Eric: marvellous explanation. Thanks. As they say in Germany: all ist klar.
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: Weird doubling bonus

Post by Eric Walch »

UK_Eliter wrote:
Eric: marvellous explanation. Thanks.
Thanks. I just remembered that shipDied() could trigger before the bugfix when the missile was destroyed by collision, was shot down by laser or was shot down by a second missile. That did happen sometime, so a script already had to be prepared for a shipDied() event that could sometimes trigger.
UK_Eliter wrote:
As they say in Germany: all ist klar.
I am just amazed how many german speaking members we have. My sister and her boyfriend moved this spring from Ireland to the south of Germany. He did not speak german and was surprised how few of the locals could understand english. In Holland almost everybody understands english enough to speak with.
But this board gives a wrong impression of the real live situation, as every german member here speaks english. :lol:
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Weird doubling bonus

Post by Thargoid »

OK, version 1.09 of Armoury uploaded with the scripting fixed in 3 places (probe missile also suffers from the same issue in 1.76).
Post Reply