What's happening exactly: The docking ship has the station as target in its docking process. When attacked it sets target to the attacker and goes in an interceptAI. But sometimes the found target was for some reason nil and target is not changed and stays the station.
I see several routes to solve this but don't really know what is the best way.
I think it goes mainly wrong with groups. When a ship is attacked that is part of a group, the core code checks if it has escorts of if it has role pirate. In both cases all group members get an ATTACK message. This is independent of the AI. And this are the two situations were I noticed the problems till now. Working on pirate cove I now regularly noticed pirates attacking their station. When forcing an exitAI on them they fell back into a dockingAI what clearly showed they initiated their attack when busy with the docking procedure. Part of them is already docking while others are still fighting and receiving hits. I think this automated attack message is even send when both ships don't see each other. For 1.73 this will be better as the ships will get an other role on launch and the automated ATTACK message to group members is not send anymore.
Yesterday I saw this behaviour for the first time with an escorted ship. I was playing cataclism and was escorting the ambassador back to the main station. At the end I noticed he was in a dockingAI and both of its escorts were just hanging still in a ENTER_WORMHOLE state of the escortAI. Very strange as the mother just does a "dockEscorts" and nothing fancy like "wormholeEscorts"? Anyhow, one moment the embassador ship was still dockings and the next moment it was in an interceptAI, attacking the main station. Of course he didn't survive it as the police killed him for that.
An other situation were thing can go wrong now when ships target a friendly object and scan for hostiles. When found the get a "TARGET_FOUND" message. But the target can get destroyed before the next update were the setTargetToFoundTarget is used. Rare but it can happen. I had similar friendly fire incidents in the past with a hostile target just at scanner range. In that case my AI must have received also a TARGET_LOST that I didn't handle right.
-----
Several suggestions:
A) Remove the automated ATTACK messages. Do we really need this code or is it from a period before we had a groupAttack command and this code was just left in after the groupAttack was introduced?
B) currently it is:
Code: Select all
- (void) setTargetToFoundTarget
{
if ([UNIVERSE entityForUniversalID:found_target])
[self addTarget:[UNIVERSE entityForUniversalID:found_target]];
}
With setTargetToPrimaryAggressor my mind is not so clear. When used while attacking it should not send a target lost message.
Code: Select all
- (void) setTargetToPrimaryAggressor
{
if (![UNIVERSE entityForUniversalID:primaryAggressor])
return;
// further code deleted.