script-spawned police doesn't get correct scan_class

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

Moderators: another_commander, winston, Getafix

Post Reply
User avatar
Commander McLane
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

script-spawned police doesn't get correct scan_class

Post by Commander McLane »

If a ship with role "police" is spawned by a script (or via the console) it does not get CLASS_POLICE, but CLASS_NEUTRAL, if no scan_class is specified in its shipdata. If it's spawned by the populator, the correct scan_class is assigned, even if there is no entry in shipdata. But script-added police currently need their scan_class explicitly set.

I think that's a bug.

User avatar
Thargoid
Thargoid
Thargoid
Posts: 5510
Joined: Thu Jun 12, 2008 6:55 pm

Re: script-spawned police doesn't get correct scan_class

Post by Thargoid »

As suggested elsewhere, could the auto_AI flag in shipdata.plist also be used to set the scanClass for appropriate roles? For example if auto_AI is true and the role is "police" or "wingman" (and possibly others too) then the scanClass gets auto-set to the appropriate values too.

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: script-spawned police doesn't get correct scan_class

Post by Kaks »

Doesn't sound too undoable...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)

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: script-spawned police doesn't get correct scan_class

Post by Eric Walch »

Kaks wrote:Doesn't sound too undoable...
Its an easy addition to the current code that sets bounty for some script added ships. Looking at the code, the populator does not force a CLASS_POLICE for police on route. Only when no scan_class was set it becomes police scan_class. That means when you define CLASS_MILITARY for a police, it will keep its military class. I don't think that is wanted behaviour as that will lead to adding not wingman but escorts and they will get a military scanclass from their mother. So it will be a military ship with civilian escort-ship that have a military label. :)

stations do it different again. Patrol is forced to CLASS_POLICE, while defence_ships keep their scan_class from shipData. When no class was defined, they keep a CLASS_NOT_SET.

All the code starts with newShipWithRole:, so adding the fix there will also force police on the other locations to CLASS_POLICE unless auto_ai is explicitly set to false. So I leave the code on the other locations as it is at that fix will so a lot of the potential other problems.

----
I also took a look on thargoids. When added in interstellar space they always get a CLASS_THARGOID but in normal space only when no other scan_class was defined for them. Look a bit buggy when they are handled differently. But there is no auto_ai for thargoids because the populator never has altered their AI. I don't want to change that and risking breakage of existing thargoids.

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: script-spawned police doesn't get correct scan_class

Post by Eric Walch »

Thargoid wrote:As suggested elsewhere, could the auto_AI flag in shipdata.plist also be used to set the scanClass for appropriate roles? For example if auto_AI is true and the role is "police" or "wingman" (and possibly others too) then the scanClass gets auto-set to the appropriate values too.
That is the approach I am following. But what looked like a simple 1 line change proofs to be more work. Not directly because of this bug, but checking against other code to make sure I don't introduce new bugs lets me stumble over all kind of other small bugs/inconsistencies.

wingman need no special handling. They are only selected when the mother has police scan_class and they inherit their mothers scan_class. But interceptors need also get a scan_class set. And they need a correct pilot. The populator adds police characters as pilot, but a script will add a random character to an interceptor. So they could have bounties than. :cry:
Populator added interceptors are added in game with a primary role of police. I will change trunk so the same happens for script added ones. That way they automatically receive the correct 'police' pilot. (= clean with 125 ₢. insurance).

I'll make script and populater consistent. With auto_ai = true (default) or without scan_class defined, the police (and interceptors) will always be forced into a police scanclass. With auto_ai = false the defined scan_class will be used. Probably never useful, but who knows what use for it some scripters might invent :P

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: script-spawned police doesn't get correct scan_class

Post by Kaks »

Eric Walch wrote:Probably never useful, but who knows what use for it some scripters might invent :P
/me looks causally at McLane & Thargoid :P
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)

User avatar
CommonSenseOTB
---- E L I T E ----
---- E L I T E ----
Posts: 1397
Joined: Wed May 04, 2011 10:42 am
Location: Saskatchewan, Canada

Re: script-spawned police doesn't get correct scan_class

Post by CommonSenseOTB »

Kaks wrote:
Eric Walch wrote:Probably never useful, but who knows what use for it some scripters might invent :P
/me looks casually at McLane & Thargoid :P
Stolen Viper oxp perhaps? :D
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs

User avatar
Thargoid
Thargoid
Thargoid
Posts: 5510
Joined: Thu Jun 12, 2008 6:55 pm

Re: script-spawned police doesn't get correct scan_class

Post by Thargoid »

/me whistles innocently...

Post Reply