Author Topic: [DONE][Suggestion] Ability to disable Pedia articles (by modders)  (Read 1362 times)

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9057
    • View Profile
Thanks for the response, Meridian. I have cleaned the list, here is the revised version:

3. RESEARCH: FALSE FOR UFOPAEDIA ARTICLES
Priority: low
Justification: Lack of this option causes confusion with some Piratez players and there's no other way of clearing it up easily (without sacrificing some gameplay).
Clarifications: It's an inversion of "requires". With this, the article only displays when you do not have a given research. It would have to be compatible with requires. For example:
* You find a Plasma Pistol. You can immediately research it regardless of any research prerequisites. It will display an article saying "we think it's an alien weapon, blah blah"
* Later you collect enough knowledge to examine the item in full, which gives you full info, and the old article disappears.
So essentially there are two different articles, which never appear at the same time.
One problem I'm not sure how to approach is writing such rulesets for items. Continuing the plasma pistol example, the "early" research/article could not be STR_PLASMA_PISTOL, because it would conflict with the later article, which would also need to be STR_PLASMA_PISTOL, else the article wouldn't work properly. But it can't be some other string, because then the needItem command wouldn't work. I don't have a good solution at the moment.

The inversion of "requires" is doable, but I don't think it's the best approach.
Also, it might have performance implications in huge mods (for reasons).

I'd rather do something similar to "disables:" in research ruleset (https://openxcom.org/forum/index.php/topic,5482.msg86298.html#msg86298), but you'll specify the names of ufopedia articles to disable (permanently).
Would that cover the requirement?

About the problem with "needitem"... it is now possible to specify a different "neededItem", so it should not be a problem anymore: https://openxcom.org/forum/index.php/topic,8653.msg160505.html#msg160505

However, the problem I see is the middle-clicking on a pistol for example... I can't see a way how the game would determine whether it should open an article called STR_PLASMA_PISTOL or some other article with unpredictable name, e.g. STR_PLASMA_PISTOL_EARLY.
Any ideas here? If not, is the "disables" feature still useful with this (big) caveat?

Offline Juku121

  • Commander
  • *****
  • Posts: 1796
  • We're all mad here.
    • View Profile
Re: [Suggestion] Ability to disable Pedia articles (by modders)
« Reply #1 on: January 15, 2024, 11:52:30 am »
I can't see a way how the game would determine whether it should open an article called STR_PLASMA_PISTOL or some other article with unpredictable name, e.g. STR_PLASMA_PISTOL_EARLY.

Any ideas here?
Not Solarius, but
  • For the given example, that wouldn't be a big deal if middle-clicking wouldn't display the "We think it's an alien pistol, yup" article while still displaying the useful article with stats and stuff.
  • From an implementation POV, what would be the issue with looking at 'neededitem' entries and displaying the latest article with a 'neededItem' that matches the item?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9057
    • View Profile
Re: [Suggestion] Ability to disable Pedia articles (by modders)
« Reply #2 on: January 15, 2024, 11:59:28 am »
From an implementation POV, what would be the issue with looking at 'neededitem' entries and displaying the latest article with a 'neededItem' that matches the item?

`neededItem`is a property of a research topic, not of a ufopedia article

(or in other words, this information is not available at all for ufopedia purposes... ufopedia articles and research topics are two separate and unrelated things)

Offline Juku121

  • Commander
  • *****
  • Posts: 1796
  • We're all mad here.
    • View Profile
Re: [Suggestion] Ability to disable Pedia articles (by modders)
« Reply #3 on: January 15, 2024, 12:31:04 pm »
I wouldn't say they are unrelated... there's a rather strong connection between the two. :)

But since the correspondence can be quite complex, yeah...

I guess using first 'lookup' and then single/double-entry 'requires' fields (with allowance for ammo) is too messy and not guaranteed to work, either.

Well, one could again offload this on the modder and introduce a 'pediaPriority' field that replaces the article corresponding to the item-name research topic with a list of topics to show, picking the highest researched one. But IDK if that'd be particularly convenient to use for actual modding work, and the payoff (at least for the Plasma Pistol example) is kinda meager.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11704
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Suggestion] Ability to disable Pedia articles (by modders)
« Reply #4 on: January 15, 2024, 02:25:39 pm »
If everything here works as I assume it does, then we're good. I am fine with the current state of things.

If not, I'll rethink the topic.

Thank you!

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9057
    • View Profile
Re: [DONE][Suggestion] Ability to disable Pedia articles (by modders)
« Reply #5 on: January 20, 2024, 03:55:57 pm »
The inversion of "requires" is doable, but I don't think it's the best approach.
Also, it might have performance implications in huge mods (for reasons).

At the end, I decided to still go for "inversion of requires" (attribute `disabledBy`) as the performance won't be much worse (than it already is).

It also has a significant advantage, that nothing is saved in the save file, so old saves can be used without any problems or migration or fiddling.

> 2. I assume the article STR_PLASMA_PISTOL_PRE can't be type 4, as type 4 is for articles with the same ID as an item (I don't care much about this either)

regarding point 2.
it's not possible now, but it is a very easy change
we can even reuse one of the existing attributes for type 3 (HWP) called `weapon` to override the item used for display

Added `weapon` attribute for ufopedia type 4 and 14.


Sample ruleset for researching plasma pistol twice:

Code: [Select]
research:
  - name: STR_PLASMA_PISTOL_PRE
    cost: 20
    points: 10
    needItem: true
    neededItem: STR_PLASMA_PISTOL    # needs the same item

  - name: STR_PLASMA_PISTOL
    cost: 30
    points: 20
    needItem: true
    dependencies: [STR_SECTOID_SOLDIER, STR_PLASMA_PISTOL_PRE]   # more dependencies

Code: [Select]
ufopaedia:
  - id: STR_PLASMA_PISTOL_PRE
    weapon: STR_PLASMA_PISTOL        # display accuracy, TUs, image, etc. of the plasma pistol
    type_id: 4
    section: STR_ALIEN_ARTIFACTS
    requires:
      - STR_PLASMA_PISTOL_PRE        # show on initial research
    disabledBy:
      - STR_PLASMA_PISTOL            # hide on further research
    text: STR_PLASMA_PISTOL_UFOPEDIA_PRE     # different fluff text

Code: [Select]
extraStrings:
  - type: en-US
    strings:
      STR_PLASMA_PISTOL_PRE: "Green Death Gun"
      STR_PLASMA_PISTOL_UFOPEDIA_PRE: "We don't know much about this stuff yet. It shoots green stuff."

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9057
    • View Profile
Re: [DONE][Suggestion] Ability to disable Pedia articles (by modders)
« Reply #6 on: January 20, 2024, 03:57:47 pm »
Demonstration video attached.