Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#4092 closed defect (fixed)

[PATCH] Restricted classes should allow whitelisting

Reported by: elexis Owned by: fatherbushido
Priority: Should Have Milestone: Alpha 21
Component: UI & Simulation Keywords: simple, patch
Cc: knight.erraunt@… Patch:

Description

The RestrictedClasses property of the Attack component allows to blacklist certain entity types from being attacked by the unit.

For example women are allowed to attack other women and siege, but not buildings or fighters.

However right now one can only specify a blacklist, not a whitelist. The fishing ship ought to be able to only attack SeaCreature. Since we can only specify a blacklist and not a whitelist, we have to add every possible entity to that list that isn't a SeaCreature. Notice the attack cursor when selecting a fishing ship and hovering any land animal.

Instead one should be able to specify a whitelist or blacklist.

Related code: RestrictedClasses in Attack.js and simulation/templates/

refs r11710 r11873

Attachments (4)

fishing_ship_template_patch.diff (578 bytes ) - added by erraunt 8 years ago.
uninteresting obvious part of the patch.
Attack_MatchesClassList.diff (370 bytes ) - added by erraunt 8 years ago.
Not sure why the diff tool prints strange indentation though.
4092_ai_compatibility.patch (2.3 KB ) - added by elexis 8 years ago.
Added AI compatibility, as noticed by fatherbushido. Those are all the occurances of RestrictedClasses. Couldn't find any template besides the fishing ship which has an Attack component but no attacking abilities (besides killing whale).
4092_ai_compatibility_v1.1.patch (2.2 KB ) - added by elexis 8 years ago.
nuked one loc too much

Download all attachments as: .zip

Change History (11)

comment:1 by elexis, 8 years ago

In 18509:

Prevent fishing ships from trying to attack entities besides fauna, refs #4092.

comment:2 by mimo, 8 years ago

I don't think r18509 is the right approach. It would be much better that the tests on RestrictedClasses use the MatchesClassList function from globalscripts instead of the indexOf, and then it would be enough to have "!"SeaCreature

Last edited 8 years ago by mimo (previous) (diff)

in reply to:  2 comment:3 by elexis, 8 years ago

Priority: Nice to HaveShould Have

Thanks for the hint, that's indeed better than the proposal of the ticket description, as it would also mean that we don't have to differentiate between a blacklist and a whitelist in the template and also allows for logical OR/AND.

by erraunt, 8 years ago

uninteresting obvious part of the patch.

comment:4 by erraunt, 8 years ago

Cc: knight.erraunt@… added
Keywords: rfc patch added
Summary: Restricted classes should allow whitelisting[PATCH] Restricted classes should allow whitelisting

Changed in the way suggested by mimo, looks rather simple, hopefully it is correct. Tested in-game, and looks like it is working.

Last edited 8 years ago by erraunt (previous) (diff)

by erraunt, 8 years ago

Not sure why the diff tool prints strange indentation though.

comment:5 by erraunt, 8 years ago

Milestone: BacklogAlpha 21

by elexis, 8 years ago

Attachment: 4092_ai_compatibility.patch added

Added AI compatibility, as noticed by fatherbushido. Those are all the occurances of RestrictedClasses. Couldn't find any template besides the fishing ship which has an Attack component but no attacking abilities (besides killing whale).

by elexis, 8 years ago

nuked one loc too much

comment:6 by fatherbushido, 8 years ago

Owner: set to fatherbushido
Resolution: fixed
Status: newclosed

In 18741:

Uses MatchesClassList for restricted classes tests in order to allow more flexibility as whitelisting. Uses it for fishing boat template and fixes a cursor inconsistency. Patch by erraunt and elexis. Fixes #4092

comment:7 by elexis, 7 years ago

Keywords: rfc removed
Note: See TracTickets for help on using tickets.