Author Topic: [DONE][Suggestion] isUsed property for base facility  (Read 3414 times)

Offline Finnik

  • Colonel
  • ****
  • Posts: 492
  • Finnik#0257
    • View Profile
[DONE][Suggestion] isUsed property for base facility
« on: March 21, 2020, 06:27:11 pm »
Regardless of how the problem with facility uniqueness constraint can be solved (https://openxcom.org/forum/index.php/topic,8017.0.html), we in The X-Com Files need another property for our facilities.
See, we want straightway to upgrade one building (say, HQ, or Bio Lab) to its advanced version without permitting the player to be able to build any other copies of that building - in other words, the player should have either normal HQ, or advanced one at a time, without any other options. We also have more such buildings. Currently, if player desire, even with a uniqueness constraint, that I mentioned above, the player can build normal HQ, and then advanced next to it, thus, having both of them at a time.

To solve this problem I would like to suggest this small addition to the code. Proposed syntax:

Code: [Select]
  - type: STR_CYBER_HQ
    maxAllowedPerBase: 1
    isUpgrade: true #default false
    buildOverFacilities:
      - STR_HQ

Here is a solution I can imagine at the moment:

https://github.com/MeridianOXC/OpenXcom/compare/oxce-plus...FinnikXCF:virtualCraft


Additionally, I think, we can check onLoad if `isUpgrade: true` was set, but there are no `buildOverFacilities:` defined. If so, stop loading with error for modder:

Code: [Select]
[21-03-2020_19-25-52] [INFO] Loading rulesets...
[21-03-2020_19-25-58] [ERROR] Error processing 'STR_LARGE_RADAR_SYSTEM' in facilities: Facility has property isUpgrade set TRUE, but buildOverFacilities property was not defined!

I would really appreciate feedback and comments!
« Last Edit: May 17, 2020, 07:34:25 pm by Meridian »

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11454
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Suggestion] isUsed property for base facility
« Reply #1 on: March 21, 2020, 06:34:32 pm »
Judging from the clip, this is exactly what I want in my life.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8616
    • View Profile
Re: [Suggestion] isUsed property for base facility
« Reply #2 on: March 21, 2020, 06:41:40 pm »
what is so bad about being able to build upgraded facility straight away?

why force player to build one and then the other?

(assuming you already have the uniqueness mentioned in another thread)

Judging from the clip, this is exactly what I want in my life.

so after this you never need anything else?

Offline Finnik

  • Colonel
  • ****
  • Posts: 492
  • Finnik#0257
    • View Profile
Re: [Suggestion] isUsed property for base facility
« Reply #3 on: March 21, 2020, 06:51:55 pm »
because without it, as I said, you can build upgrade building not on top of the upgradable, but on another tile. thus, I can build advanced HQ next to normal and have 2 at a same time at the same base. And this is what we want to prevent.
At the same time, if uniqueness constraint will not allow us to build an upgrade next to the original, I can't see how can we allow to make upgrades...

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11454
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Suggestion] isUsed property for base facility
« Reply #4 on: March 21, 2020, 06:53:56 pm »
[ninja'd by Finnik]

what is so bad about being able to build upgraded facility straight away?

why force player to build one and then the other?

(assuming you already have the uniqueness mentioned in another thread)

so after this you never need anything else?

You're right, preventing building the facility from scratch is not the main goal, more of a way to deal with logic problems.

THe point is that in XCF:
- you can have only one building of a certain type per base
- there are several stages of this building
- with clever planning, you can build several buildings of the same type (but exactly the same building) - this is the problem

Yes, I tried fixing it with existing options, but nothing worked well enough. This solution with upgrades simply cuts the problem away and would be very helpful. (Assuming I understand it correctly.)

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8616
    • View Profile
Re: [Suggestion] isUsed property for base facility
« Reply #5 on: March 21, 2020, 06:56:19 pm »
because without it, as I said, you can build upgrade building not on top of the upgradable, but on another tile. thus, I can build advanced HQ next to normal and have 2 at a same time at the same base. And this is what we want to prevent.

This is what the uniqueness feature is supposed to solve, no?
That you cannot build adv HQ next to normal HQ...

Offline Finnik

  • Colonel
  • ****
  • Posts: 492
  • Finnik#0257
    • View Profile
Re: [Suggestion] isUsed property for base facility
« Reply #6 on: March 21, 2020, 06:57:25 pm »
yes, but then I still can build advanced one next to normal and still break things

Offline Yankes

  • Commander
  • *****
  • Posts: 3207
    • View Profile
Re: [Suggestion] isUsed property for base facility
« Reply #7 on: March 21, 2020, 06:59:04 pm »
From my perspective both your threads are effective same functionality (I think we should merge them) and in reality work around of some limitations with BaseFuncitnality logic. As I mentioned in other there we should fix core of problem not work around it. Simply you can build building over one that forbid your building that you want to build.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8616
    • View Profile
Re: [Suggestion] isUsed property for base facility
« Reply #8 on: March 21, 2020, 07:00:41 pm »
yes, but then I still can build advanced one next to normal and still break things

Code: [Select]
facilities:
  - type: STR_LARGE_RADAR_SYSTEM
    cantBeBuiltWith:
      - STR_SMALL_RADAR_SYSTEM
  - type: STR_SMALL_RADAR_SYSTEM
    cantBeBuiltWith:
      - STR_LARGE_RADAR_SYSTEM

if you do this, doesn't it mean you can only ever have one of the two?

Offline Finnik

  • Colonel
  • ****
  • Posts: 492
  • Finnik#0257
    • View Profile
Re: [Suggestion] isUsed property for base facility
« Reply #9 on: March 21, 2020, 07:16:44 pm »
Of course no, it just prevents me from building the second building, no matter who comes first. For unique upgradable buildings, we need both, as far I can see.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8616
    • View Profile
Re: [Suggestion] isUsed property for base facility
« Reply #10 on: March 21, 2020, 07:35:39 pm »
Of course no, it just prevents me from building the second building, no matter who comes first. For unique upgradable buildings, we need both, as far I can see.

I read the PR now, and I think I understand what you mean.

It's because the PR checks the condition when creating a list (i.e. earlier)... not when placing a facility (i.e. later).
That can be improved.

I'll talk to Yankes and we'll try to come up with proposal(s).

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8616
    • View Profile
Re: [Suggestion] isUsed property for base facility
« Reply #11 on: May 17, 2020, 07:33:09 pm »