Page 1 of 1

isThargoidVictim ?

Posted: Fri Oct 16, 2009 8:42 am
by Thargoid
Just been coding up a new AI/js combo for a thargoid AI (partly to stop the dumb-aliens-when cloaked glitch but mainly as I want it to do other things than trunk thargoidAI anyway), and came across something.

In the JS code we already have the boolean isPirateVictim, but could we have something similar for ships that could/should be attacked by Thargoids? As it stands I've had to put together a fairly long chain of filtering checks to get something sensible (that they attack proper victim ships and stations, but not cargo/rocks/other Thargoids/cloaked ships etc). It just struck me that as we have something as convenient as isPirateVictim, might a similar set-up (boolean flag and possibly plist - although the plist is maybe optional given the default is to be attacked rather than to be ignored) be added for alien encounters/attacks too?

Posted: Fri Oct 16, 2009 9:22 am
by Commander McLane
Sounds sensible to me.

Posted: Fri Oct 16, 2009 10:10 am
by Kaks
Hmm, I somehow actually expect the Thargoids to attack cargo too (galCoop contaminated stuff, get rid of it) however rocks, splinters and such don't quite make the grade... Unless we're talking about rock hermits, of course. My preference would be for Thargoids to attack everything unless flagged not to. If only I could think of a sensible name instead of isNotThargoidVictim / isNotThargoidTarget

Posted: Fri Oct 16, 2009 10:17 am
by Thargoid
isThargoidFriend? :lol:

It was more the concept than anything else (and not having to write a huge list of things to include/exclude in the scanning script), brought about by me spawning a test warship under the new AI and it seeming to have an unhealthy obsession with trying to shoot a metal fragment left by the death of one of it's predecessors. The fact that it couldn't actually seem to manage to destroy the thing was a side-niggle too.

For reference, I ended up with:

Code: Select all

function targetShips(entity) {return (entity.isPlayer || entity.isTrader || entity.isPirate || entity.isPolice || entity.isPirateVictim || entity.isBeacon || entity.isStation) && !entity.isThargoid && !entity.isCloaked}; 
As you can see, nice and simple and concise :roll:

Posted: Fri Oct 16, 2009 8:58 pm
by Eric Walch
Thargoid wrote:
For reference, I ended up with:

Code: Select all

function targetShips(entity) {return (entity.isPlayer || entity.isTrader || entity.isPirate || entity.isPolice || entity.isPirateVictim || entity.isBeacon || entity.isStation) && !entity.isThargoid && !entity.isCloaked}; 
As you can see, nice and simple and concise :roll:
You miss escorts and ships added by oxp's that are on no list. Oolites scanForNonThargoid uses:

Code: Select all

if (([thing scanClass] != CLASS_CARGO) && ([thing status] != STATUS_DOCKED) && ![thing isThargoid] && ![thing isCloaked])
{add it as target}
(isCloaked exist currently only in my build)
For some reason it excludes cargo but not rocks. And testing for docked is to prevent it finds a docked player.

Posted: Fri Oct 16, 2009 9:24 pm
by Thargoid
escorts - good catch, can get that with entity.hasRole("escort").

OXP-added ships - that's a more complex one methinks. Any thoughts on how to do that one? Either by adding something in, or redoing things?

I should add they also react to attacks by fighting back, which takes out some of the problems too.

For background reference I'm steering away from scanForNonThargoids both for the known cloaked ship issue (which your fix should, umm, fix), but also as I'm scanning out to 60,000m and with a bit of js/AI interaction actually allowing the Thargoids to properly use their longer scanning. If you want I can share a WIP with you for comment and input (as usual 8) ).

The problem with rocks is rock hermits I guess, and cargo would seem to make them possibly unnaturally pre-occupied with it (at least some of my test ships seemed to be when I didn't exclude it).

Posted: Sat Oct 17, 2009 10:31 am
by Eric Walch
Thargoid wrote:
escorts - good catch, can get that with entity.hasRole("escort").

OXP-added ships - that's a more complex one methinks. Any thoughts on how to do that one? Either by adding something in, or redoing things?
Maybe just scan everything and only exclude certain types. (and not select certain types)
Thargoid wrote:
For background reference I'm steering away from scanForNonThargoids both for the known cloaked ship issue (which your fix should, umm, fix), but also as I'm scanning out to 60,000m and with a bit of js/AI interaction actually allowing the Thargoids to properly use their longer scanning. If you want I can share a WIP with you for comment and input (as usual 8) ).
This 60.000 meter scan range of thargoids is a big bug. Maybe it once worked in earlier oolite versions but at least since 1.65 all scan ranges are limited to 25.600 meter throughout the code.
The JS property "scannerRange" returns the value defined in shipdata. The easiest fix would be to clamp that value to 25.600 and leave the rest as it is.

The more difficult method would be to add a copy of "checkScanner" to the current code that does not use the 25.600 as maximum scan range but the value defined with the ship and than only use that scanner in the "scanForNonThargoid". Than you have really thargoids than scan further.

Also stuff like "performAttack" looses targets when further away than 25.600 meter. Attacking such targets can be achieved by using special AI that just flies in the direction of the target when far away and only starts attacking when within the normal limits.

I even had already written a bit of code that does that. checkScanner not returning "TARGET_FOUND" but also "DISTANT_TARGET_FOUND" Than the targoids do only a flyToDestination when they find a distant target. performAttack only starts then when within scanner range.

Posted: Sat Oct 17, 2009 10:50 am
by Screet
Eric Walch wrote:
The more difficult method would be to add a copy of "checkScanner" to the current code that does not use the 25.600 as maximum scan range but the value defined with the ship and than only use that scanner in the "scanForNonThargoid".
Could be fun to have buyable scanners with different functionality...for example my little code mod which marks non-hostile ships with bounty orange is a great help and I really think such a thing should be available to all, maybe by adding some equipment dependency so that those who don't want it can keep the current behaviour. It's similar with scanners: Some might prefer that the scanner range pretty much also tells them when they can use the torus drive or mil laser while others would prefer to see further into the distance. It also could result in nice NPC pirates which won't lose a track so easily.

Screet

Posted: Sat Oct 17, 2009 11:26 am
by Thargoid
@Eric,

That's essentially what I'm doing. Scan the system once, then filter it to 60km and 25.6km. If there's targets in the near scan then attack them using performAttack.

If there's nothing close by but there are targets in the far range (60km) then performFlyToRangeFromDestination (set at 20km) and then go into performAttack.

The scan everything (isShip) and exclude is probably he simpler way to go here. I was pondering that when out earlier, after I'd posted the above.