shipAttackedOther incorrectly documented and fairly odd

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

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2453
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

shipAttackedOther incorrectly documented and fairly odd

Post by Wildeblood »

According to http://wiki.alioth.net/index.php/Oolite ... ackedOther
The shipAttackedOther handler is called when this ship hits another with a laser shot. other is the identity of the ship being hit (added in test version 1.74.2).
this.shipAttackedOther = function(other)
{
// Your code here
}
No mention of missiles, just lasers. On the basis of that information I created the Type XS Ultra-Power Laser:

Code: Select all

/* Ultra-Power Laser guarantees destruction of any target with one hit. */

this.shipAttackedOther = function(victim)
   {
   if (player.ship.equipmentStatus("EQ_DEATH_RAY") === "EQUIPMENT_OK")
      {
      victim.explode();
      }
   }
But now when I fire missiles at ships they (the target ships) just explode immediately. I suppose this is intended, but if so the wiki needs updating. But... when I fired a missile at a Coriolis, it didn't explode. But when the missile reached it, it did.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: shipAttackedOther incorrectly documented and fairly odd

Post by JensAyton »

shipAttackedOther is called immediately after shipBeingAttacked is called on the target and the ATTACKED AI message is sent. This currently happens in the following cases:
  • When a ship takes energy damage.
  • When a ship is attacked by a member of its own group, and a decision is made to throw out the perpetrator, both events are sent as though the group’s leader attacked the defector. This is inherited from the behaviour of the ATTACKED AI message.
  • When the AI responds to an incoming missile by calling fightOrFleeMissile.
This last one is a bit odd, but it’s sort of entrenched; it was added in January 2008. It explains the Coriolis situation: it doesn’t react to missiles, but does take energy damage from them.

Edit: Supplementary note: energy damage occurs in the following cases:
  • From laser or plasma fire.
  • From the explode() and remove() script methods, and the legacy blowUpStation command.
  • From dealEnergyDamageWithinDesiredRange AI command and dealEnergyDamage() JS method – this includes missiles.
  • From quirium explosions (Q-mines or secondary explosions).
  • From energy bombs.
Essentially, energy damage is any damage other than scrape and heat damage.
Post Reply