Author Topic: [DONE][Suggestion] cantBeBuiltWith property for xcom base facilities  (Read 6293 times)

Offline Finnik

  • Colonel
  • ****
  • Posts: 490
  • Finnik#0257
    • View Profile
Edit by Meridian: final solution here: https://openxcom.org/forum/index.php/topic,8017.msg125175.html#msg125175

Hello guys, im really interested what are you think about my tiny new feature for Open Xcom Extended in form of cantBeBuiltWith property for xcom base facilities.

Here is a sample ruleset code:
Code: [Select]
facilities:
  - type: STR_LARGE_RADAR_SYSTEM
    spriteShape: 1
    spriteFacility: 22
    buildCost: 800000
    buildTime: 25
    monthlyCost: 15000
    radarRange: 2577
    radarChance: 20
    mapName: XBASE_05
    cantBeBuiltWith:
      - STR_SMALL_RADAR_SYSTEM

What it actually does – its allows a modder to restrict certain facility to be built if the specified facility was already been built on that base. This will be especially useful for creating upgrades for unique facilities, that already using both buildOverFacilities and maxAllowedPerBase properties.
For example, in The Xcom Files we have the xcom HQ facility and its improved version. Thus, we would like to forbid the player to build a normal version of the headquarters if there is already an improved version, but we should allow building an improvement over the normal version of the headquarters.
There are not many changes:

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

I can make a pull request if it's ok. If not, please, let me know, I will correct it.

Any feedback from modders is also very welcome!



« Last Edit: May 17, 2020, 07:35:40 pm by Meridian »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8597
    • View Profile
Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
« Reply #1 on: March 20, 2020, 11:28:49 pm »
why not use `forbiddenBaseFunc` ?

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
« Reply #2 on: March 21, 2020, 12:22:02 am »
This is already done in Piratez and I think XCF too using the providesBaseFunc and forbiddenBaseFunc parameters to limit certain facilities to one per base.

Offline Finnik

  • Colonel
  • ****
  • Posts: 490
  • Finnik#0257
    • View Profile
Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
« Reply #3 on: March 21, 2020, 04:04:37 pm »
The first motivation here was to provide properties for upgrading unique facilities. Like HQ should be one per base and have an upgrade into Cyber HQ (i want to make the same for intel and bio labs here to make advanced versions of them). So we have rules like this:

Code: [Select]
facilities:
  - type: STR_HQ
    spriteShape: 1
    spriteFacility: 317
    provideBaseFunc: [BIOLAB, INTLAB]
    buildCost: 3000000
    buildTime: 40
    monthlyCost: 20000
    canBeBuiltOver: true
    maxAllowedPerBase: 1
    storage: 25
    labs: 5
    rightClickActionType: 3
    radarRange: 10800
    radarChance: 2
    mapName: XBASS_22
    listOrder: 6830
  - type: STR_CYBER_HQ
    requires:
      - STR_CYBER_HQ
    spriteShape: 1
    spriteFacility: 874
    provideBaseFunc: [BIOLAB, INTLAB, AI]
    maxAllowedPerBase: 1
    buildCost: 4000000
    buildTime: 50
    monthlyCost: 40000
    buildOverFacilities:
      - STR_HQ
    storage: 25
    labs: 10
    manaRecoveryPerDay: 2
    rightClickActionType: 3
    radarRange: 10800
    radarChance: 3
    mapName: XBASS_33
    listOrder: 6832

I tried to use `forbiddenBaseFunc` in different ways, but I can't make it work.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8597
    • View Profile
Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
« Reply #4 on: March 21, 2020, 04:15:06 pm »
- Airlock should provide funcA
- Small radar should require funcA and provide funcB
- Big radar should require funcB and forbid funcA

Offline Finnik

  • Colonel
  • ****
  • Posts: 490
  • Finnik#0257
    • View Profile
Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
« Reply #5 on: March 21, 2020, 05:57:57 pm »
Yes, I tried that...

Code: [Select]
facilities:
  - type: STR_ACCESS_LIFT
    spriteShape: 2
    spriteFacility: 17
    lift: true
    provideBaseFunc: [funcA]
    buildCost: 300000
    buildTime: 1
    monthlyCost: 4000
    mapName: XBASE_00
  - type: STR_SMALL_RADAR_SYSTEM
    spriteShape: 2
    spriteFacility: 21
    requiresBaseFunc: [funcA]
    provideBaseFunc: [funcB]
    buildCost: 500000
    buildTime: 12
    monthlyCost: 10000
    radarRange: 1695
    radarChance: 10
    mapName: XBASE_04
  - type: STR_LARGE_RADAR_SYSTEM
    spriteShape: 1
    spriteFacility: 22
    requiresBaseFunc: [funcB]
    forbiddenBaseFunc: [funcA]
    buildCost: 800000
    buildTime: 25
    monthlyCost: 15000
    radarRange: 2577
    radarChance: 20
    mapName: XBASE_05



What am I doing wrong?
« Last Edit: March 21, 2020, 06:16:09 pm by Meridian »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8597
    • View Profile
Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
« Reply #6 on: March 21, 2020, 06:20:22 pm »
hmm, I guess the feature is not compatible with upgrades, probably checking too much or not enough...

I'll check later
« Last Edit: March 21, 2020, 06:24:17 pm by Meridian »

Offline Finnik

  • Colonel
  • ****
  • Posts: 490
  • Finnik#0257
    • View Profile
Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
« Reply #7 on: March 21, 2020, 06:32:23 pm »
Upgrades do not count, I did this rules on pure vanilla (the screenshot was done exactly on that rules I posted), that my radars are not upgrades, but just separate buildings...

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
« Reply #8 on: March 21, 2020, 06:49:20 pm »
If I understand correctly, you want:

FacilityA
FacilityB
FacilityC

Only one of this 3 can exists in base, and you can upgrade them (FacilityA to FacilityB and FacilityB to FacilityC).

Looking on code this is impossible right now because required and forbidden are check on populating build list.

Right now to have only one facility from list you need define same functionality for both provided and forbidden list.
But then you can't upgrade because this building is not available on list.


One way I see to fix it, is allow conditional build if `buildOverFacilities` exists in base and have same "unique" functionalities that building we want build.
Then if you tray build it on other place that this old building you will get error, but if you "over" build you will allowed.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8597
    • View Profile
Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
« Reply #9 on: March 21, 2020, 06:54:05 pm »
Upgrades do not count, I did this rules on pure vanilla (the screenshot was done exactly on that rules I posted), that my radars are not upgrades, but just separate buildings...

That's what I meant too.
All upgrades are currently normal facilities, you can't have a facility which is only an upgrade.

Offline Finnik

  • Colonel
  • ****
  • Posts: 490
  • Finnik#0257
    • View Profile
Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
« Reply #10 on: March 21, 2020, 06:58:11 pm »
That's what I meant too.
All upgrades are currently normal facilities, you can't have a facility which is only an upgrade.

cant we? =) https://openxcom.org/forum/index.php/topic,8022.0.html

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8597
    • View Profile
Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
« Reply #11 on: March 21, 2020, 07:04:26 pm »

Offline efrenespartano

  • Commander
  • *****
  • Posts: 748
  • I know a lot about the law and other lawyerings.
    • View Profile
Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
« Reply #12 on: March 21, 2020, 07:06:00 pm »
I really like this feature. I can see many uses for the mods of the IDT.

I hope its in the next OXCE, looking forward to see it, Finnik!

Enviado desde mi LG-M400 mediante Tapatalk


Offline Finnik

  • Colonel
  • ****
  • Posts: 490
  • Finnik#0257
    • View Profile
Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
« Reply #13 on: March 21, 2020, 07:11:23 pm »
No, we can't.
That functionality is not in OXCE yet.

Ok, but we could, for example, with that

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8597
    • View Profile
Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
« Reply #14 on: March 21, 2020, 07:22:57 pm »
If I understand correctly, you want:

FacilityA
FacilityB
FacilityC

Only one of this 3 can exists in base, and you can upgrade them (FacilityA to FacilityB and FacilityB to FacilityC).

Looking on code this is impossible right now because required and forbidden are check on populating build list.

Right now to have only one facility from list you need define same functionality for both provided and forbidden list.
But then you can't upgrade because this building is not available on list.


One way I see to fix it, is allow conditional build if `buildOverFacilities` exists in base and have same "unique" functionalities that building we want build.
Then if you try build it on other place than this old building you will get error, but if you "over" build you will allowed.

Yes, after reading Solarius's explanation (https://openxcom.org/forum/index.php/topic,8022.msg124856.html#msg124856) I think we can achieve it without any new attributes, the way you describe.

Just one small technical correction maybe, the upgrades don't need to have the "same" unique functionalities... they can have "same or more", for example:

FacilityA - funcX
FacilityB - funcX, funcY
FacilityC - funcX, funcY, funcZ

is allowed, but:

FacilityA - funcX, funcY, funcZ
FacilityB - funcX, funcY
FacilityC - funcX

is not allowed.