Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

Thargoids added as groups crash game.

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

Moderators: another_commander, winston, Getafix

User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Thargoids added as groups crash game.

Post by Commander McLane »

Switeck wrote:
It would seem that pirates will stay on one target only as long as their update pause is, because the moment they get hit by something else they change targets and attack that. And I couldn't find their update pause, so my guess is they would change targets almost instantly? That seems a worse case of ADD than Thargoid warships have!
No. It's all in the documentation. For all info on AI behaviour, please read [wiki]OXP_howto_AI[/wiki]:
setTargetToPrimaryAggressor

This function sets the primary agressor to the primary target. Then in the "performAttack" state, it only has a 25% change of setting the primary agressor to the primary target. The other 75% it will do nothing. This function is designed for used during attack to prevent it will constantly change targets when attacking a group.
primary agressor is set by the system when a ship fires a laser or missile on the other.
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2412
Joined: Mon May 31, 2010 11:11 pm

Re: Thargoids added as groups crash game.

Post by Switeck »

Thargoids have an update delay of 30 seconds.
Pirates have none.
So even if they only have a 25% chance of switching targets PER hit, they should still will seem to have a worse case of ADD. They may even go "OOH! Shiney!"...and wander off to scoop cargo canisters and escape pods.
User avatar
Spartan
Competent
Competent
Posts: 34
Joined: Tue Mar 29, 2011 11:30 pm
Location: Florida

Re: Thargoids added as groups crash game.

Post by Spartan »

SQUIRREL!
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Thargoids added as groups crash game.

Post by Commander McLane »

Switeck wrote:
Thargoids have an update delay of 30 seconds.
Pirates have none.
So even if they only have a 25% chance of switching targets PER hit, they should still will seem to have a worse case of ADD.
No, on the contrary. If you are attacking some object which may or may not fire back, and another ship begins to fire shots at you, it makes increasing sense for you to deal with your attacker first with each hit you take. It's the new attacker who is the imminent danger for you, not the ship you are just finishing off.

This is congruent with the player's behaviour (at least in my case). Usually I concentrate on my enemies one after the other. But if there suddenly comes a Hydra from my side and starts eating away my shields, I would be a fool (a dead fool!) if I wouldn't deal with this new threat immediately and swiftly. And that's exactly what NPCs are doing with their 25% chance of dealing with a new threat. One hit from a third party usually won't distract them. Multiple repeated hits, on the other hand, will get their attention.
Switeck wrote:
They may even go "OOH! Shiney!"...and wander off to scoop cargo canisters and escape pods.
No, why would they do that? The target can be switched to the current primary aggressor, nothing else. Nothing in the AI says that the target can be switched to some random cargo. Cargo usually doesn't fire at pirates. Firing at a ship is the only way to make it switch its target (and only to the one who is firing). Therefore there is no way that an ATTACKED message could be triggered by a cargo pod.
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2412
Joined: Mon May 31, 2010 11:11 pm

Re: Thargoids added as groups crash game.

Post by Switeck »

Commander McLane wrote:
Switeck wrote:
They may even go "OOH! Shiney!"...and wander off to scoop cargo canisters and escape pods.
No, why would they do that? The target can be switched to the current primary aggressor, nothing else. Nothing in the AI says that the target can be switched to some random cargo. Cargo usually doesn't fire at pirates. Firing at a ship is the only way to make it switch its target (and only to the one who is firing). Therefore there is no way that an ATTACKED message could be triggered by a cargo pod.

Code: Select all

        "CARGO_DUMPED" = (checkForFullHold);
        "HOLD_NOT_FULL" = ("rollD: 4");
        "ROLL_1" = ("setStateTo: COLLECT_LOOT");
Right now I don't care if that happens only under extremely rare conditions (of the player or some trader dumping cargo) with a 1-in-4 chance.

But I wish to point out: tone down your comments. Even if you're always right, I shouldn't have to get browbeat every time I make a mistake.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Thargoids added as groups crash game.

Post by Commander McLane »

First I apologize for coming across too harshly. It wasn't my intention. :) (And I am by far not always right. I've made my fair share of embarrassing blunders.)

I'm trying to be precise in what I'm writing. AI-behaviour is well and strictly defined, after all. And it is well documented (at least in its general lines). I do think that it makes sense, if we talk about the trade, to know the tools of the trade first, especially as those tools are well documented (even though the documentation isn't perfect, and isn't 100% complete sometimes) and easily accessible for everybody here.
Switeck wrote:

Code: Select all

        "CARGO_DUMPED" = (checkForFullHold);
        "HOLD_NOT_FULL" = ("rollD: 4");
        "ROLL_1" = ("setStateTo: COLLECT_LOOT");
Right now I don't care if that happens only under extremely rare conditions (of the player or some trader dumping cargo) with a 1-in-4 chance.
I am not sure when the CARGO_DUMPED message is sent. I haven't used it before. The documentation suggests that this only happens if another NPC uses the dumpCargo or ejectCargo method. (I don't know whether the player hitting 'D' also triggers it; and I don't know whether it is only sent to entities which at the time have the dumper as their primary target, or to all entities in the vicinity.) Generally I think it would be reasonable behaviour for a pirate to try to scoop this cargo. I seem to remember that there was a debate about this in some thread not too long ago, where people made the point that what pirates are ultimately after is cargo, not destroying other ships for the sake of destruction. So, if the prey tries to get away by dumping cargo, the pirate has achieved his goal and would concentrate on the cargo, not the fleeing ship. I think that's the reasoning behind this specific behaviour.

(The COLLECT_LOOT state itself checks for new attacks. Therefore, if a pirate gets hit by laser fire while scooping, he will turn against his attacker with the known 25% probability. In other words: A single shot fired at him will probably not distract him from what he's doing, which is again how I would also react in the same situation. However, continuous fire will make him deal with the attacker first, which is again what I also would do in the same situation. (This is actually an assumption, because I don't know whether the 25%-rule also applies if the current target is not a hostile ship, but some cargo.))

And if the attacked ship doesn't dump cargo, the code is never executed in the first place. (Dumping or ejecting means what the player can do with hitting 'D' while in flight. It does not cover the cargo released after a ship is destroyed. The destruction of a target triggers TARGET_LOST and TARGET_DESTROYED, not CARGO_DUMPED.)

But I thought we were discussing the switching of targets, which is only dealt with in

Code: Select all

        ATTACKED =         (
            setTargetToPrimaryAggressor,
            "setStateTo: ATTACK_SHIP"
        );
        "ESCORT_ATTACKED" =         (
            setTargetToPrimaryAggressor,
            groupAttackTarget
        );
?
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2412
Joined: Mon May 31, 2010 11:11 pm

Re: Thargoids added as groups crash game.

Post by Switeck »

My point was pirates have a much shorter delay between updates, so when taking hits from multiple sources would seem more "A.D.D." than Thargoids which have target fixation for the duration of their 30 second pause in their update.
If the chance of changing targets is only 25% per incoming hit for pirates, the same holds true for Thargoids as well since both use the same commands.

The red herring of dumped cargo distracting the pirate bloodhounds is only to point out there's potentially something that can distract pirates (even if only very momentarily if they're constantly taking hits) that would have no effect on Thargoids.

But since in the Thargoid's case, there is still only 1 visible target change per 30 seconds... and may be contributing to the huge message queue that a Thargoid might have by the time its update is reached. I presume it's the huge message queue that somehow causes the crash.

Pirates under attack would be extremely unlikely to trigger the same conditions that causes the game crash because their delay-between-changes is so short. No appreciable queue would build up.

In regular play, Thargoids are probably less likely to have this crash because normally there's very few enemies attacking a particular Thargoid especially in interstellar space where Thargoids often enjoy advantage of numbers over whatever hapless trader happens to be there. If Galactic Navy units or other player-friendly units are added, more Thargoids typically are added too -- so even still the numbers of units firing on 1 Thargoid may still be somewhat low. In regular systems, if Thargoids are added at all...there is usually only 1 or 2 of them. However there is seldom large trader or pirate groups to concentrate fire on them. They often spit out Thargons to pull at least some attackers off themselves. But because traders, pirates, bounty hunters, AND police are all trying to kill them and maybe using missiles to do that...the 1-2 Thargoids often die fast.

Going forwards, if someone wanted to have a big in-system Thargoids-versus-everyone fight in a system...they probably will see a game crash if the bug I'm seeing is common to all platforms.

Which was why I asked if shortening the update delay on Thargoids would help or have particularly adverse effects.

I might also ask why pirates don't have an update section at all for their "ATTACK_SHIP" section...but I'm guessing it's so they can respond more rapidly to changing events.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Thargoids added as groups crash game.

Post by Commander McLane »

Switeck wrote:
I might also ask why pirates don't have an update section at all for their "ATTACK_SHIP" section...but I'm guessing it's so they can respond more rapidly to changing events.
The presence of an UPDATE section is irrelevant. The UPDATE event is sent to all entities. An UPDATE section only means that together with the commands which are performed internally on receiving the UPDATE message anyway, the commands specified in the UPDATE section will be performed additionally. If there is no UPDATE section, the AI will simply receive the next pending message at the time when the UPDATE is received, and will execute the commands connected to that message, if any.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Thargoids added as groups crash game.

Post by Commander McLane »

Switeck wrote:
My point was pirates have a much shorter delay between updates, so when taking hits from multiple sources would seem more "A.D.D." than Thargoids which have target fixation for the duration of their 30 second pause in their update.
No, as Eric explained, if the target is switched at all, it's switched immediately:
Eric Walch wrote:
Switeck wrote:
Just to sort out if I follow and understand you...
The Thargoid warship's 30 second delay in the update of the attack section means a LOT of ships could have hit it in that time, but it can only change targets once per 30 seconds.
It has to keep track of all that hit it in that interval.
Sort of. Switching of targets happens immediately. Those AIMS_AGGRESSOR_SWITCHED_TARGET messages are only used to do some bookkeeping of bounties as result of a switch and to generate the messages: "[thanks-for-assist]".
This is also what you observe if you're firing on an NPC which is currently fighting with another NPC. Either it turns red immediately, or not at all (speaking of non-Thargoids, of course).

But indeed, the crash is more likely to happen with Thargoids, because the target-switching-messages are kept until the next UPDATE, at which point they are discarded. The overflow (and therefore the crash) happens when 32 messages have been accumulated. So you're correct, the longer the interval until the next UPDATE, the more messages can accumulate.

There is the AI-method dropMessages: which can be used to clear the message-cache. Unfortunately it requires you to specify the message which shall be dropped. This is easy for the standard messages, but of course not possible if the message in question is unique because it contains two ship identifiers. I don't know whether the addition of a more general dropAllMessages would qualify as a feature request or a bug fix.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Re: Thargoids added as groups crash game.

Post by Kaks »

Again, from the better-late-than-never department, this bug should now be squashed in r4621.

Instead of overflowing the stack, any extra message is now discarded, until the stack is back to decent numbers.

In the specific case of thargoids, there should be no discernible change in behaviour, but at least there won't be any game crash! :)

Please do let us know if I missed something obvious.

Cheers,

Kaks.
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2412
Joined: Mon May 31, 2010 11:11 pm

Re: Thargoids added as groups crash game.

Post by Switeck »

I hadn't forgotten about this thread.
But my last few tests didn't seem to trigger the problem...possibly as a result of earlier fixes to Thargoid/Thargon friendly fire issues.

I'll be doing more tests of 1-2 practically invulnerable ships versus 20+ enemies at once in the hopes they could flood the message limit...but doubt I'll find anything conclusive.
Post Reply