OpenXcom Forum

Modding => OpenXcom Extended => OXCE Suggestions DONE => Topic started by: Finnik on March 20, 2020, 11:23:50 pm

Title: [DONE][Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Finnik on March 20, 2020, 11:23:50 pm
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
 (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!



Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Meridian on March 20, 2020, 11:28:49 pm
why not use `forbiddenBaseFunc` ?
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: ohartenstein23 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.
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Finnik 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.
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Meridian 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
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Finnik 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

(http://thexcomfiles.xyz/base_func.png)

What am I doing wrong?
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Meridian 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
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Finnik 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...
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Yankes 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.
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Meridian 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.
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Finnik 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 (https://openxcom.org/forum/index.php/topic,8022.0.html)
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Meridian on March 21, 2020, 07:04:26 pm
cant we? =) https://openxcom.org/forum/index.php/topic,8022.0.html (https://openxcom.org/forum/index.php/topic,8022.0.html)

No, we can't.
That functionality is not in OXCE yet.
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: efrenespartano 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

Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Finnik 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
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Meridian 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.
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Finnik on March 21, 2020, 07:31:37 pm
Is my solution bad? It is really tiny and has no such limitations. It is not making for just XCF, one-day modder will come asking to free him from that. Also, modder will be free from functionality stuff that is also used widely for research and manufacture - and in complex mega mods that can do additional mess
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Yankes on March 21, 2020, 07:36:01 pm
Because do not solve core of problem. If you add forbidden and required functionality to your buildings then it will easy break and you will end up in same situation as now.
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Meridian on March 21, 2020, 07:53:36 pm
I paste here a simplest test case I can think of:

1. you can build a small radar from scratch
2. you can build a large radar from scratch
3. you can upgrade a small radar to large radar
4. you cannot build 2 small radars
5. you cannot build 2 large radars
6. you cannot build small and large radar together

I hope this is a complete example and can be used for testing, regardless of chosen implementation.
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Finnik on March 21, 2020, 08:11:40 pm
I paste here a simplest test case I can think of:

1. you can build a small radar from scratch
2. you can build a large radar from scratch
3. you can upgrade a small radar to large radar
4. you cannot build 2 small radars
5. you cannot build 2 large radars
6. you cannot build small and large radar together

I hope this is a complete example and can be used for testing, regardless of chosen implementation.

I think all that doable with current OXCE with `maxAllowedPerBase` and functionalities. I'd like to add:
7. you can upgrade small radar to large radar, but there is no possible way to have them both at the same time.
for that, it split these cases, but they must be all true with the same ruleset
7.1 you can place large radar on small radar (currently possible with `buildOverFacilities`)
7.2 you cant build large radar as a separate building if you already have small radar, thus having 2 of them at the same time (solved with `isUpgrade: true`, so you can replace the facility. if it has `maxAllowedPerBase: 1` case solved)
7.3 you cant build small radar if you already have large radar, thus again having 2 of them at the same time (solved with `cantBeBuiltWith`)
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Meridian on March 21, 2020, 08:20:55 pm
7. you can upgrade small radar to large radar, but there is no possible way to have them both at the same time.

I'm sorry, maybe I'm really stupid, but how is that different from my point 6?
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Finnik on March 21, 2020, 08:31:22 pm
because if you really cant build them together, you cant upgrade one to another, it goes to `_disabledFacilities.push_back(rule)`. I would, actually, keep it separate, for you would not be able to build, say Psi gates on your base if you already have, I don't know, Arcana gates. And I like it goes to the disabled list because it does not pass `cantBeBuiltWith`
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Meridian on March 21, 2020, 08:49:12 pm
because if you really cant build them together, you cant upgrade one to another

I said very explicitly:
3. you can upgrade a small radar to large radar
6. you cannot build small and large radar together

I.e. you can upgrade one to another and you can't build them together.

I really don't know what else to say.

it goes to `_disabledFacilities.push_back(rule)`. I would, actually, keep it separate, for you would not be able to build, say Psi gates on your base if you already have, I don't know, Arcana gates. And I like it goes to the disabled list because it does not pass `cantBeBuiltWith`

I am not saying anything about current or future implementation details, just what the expected result should be.
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Finnik on March 21, 2020, 09:01:26 pm
ok, I'm just saying I think it would be good to have separate ruleset design options to restrict having 2 buildings together (no matter they are upgrades or not) and another option to make upgradable unique building
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Yankes on March 28, 2020, 07:31:53 pm
I'm now finishing my version of implementation.
One design decision was that to enable this functionality you need define `buildOverFacilities`, with this given facility will ignore forbidden functionalities when displayed on available build list. All checks will be done at moment when you try build it on other building.

Game will check if in base after removing old facilities and adding this new, all constrains still holds, aka all buildings have other build that provide its needed fucntion and there is no two buildings that forbids each other functionality.

This mean you can build over building that normally prevent building that new facility.
Title: Re: [Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Meridian on May 17, 2020, 07:32:11 pm
I paste here a simplest test case I can think of:

1. you can build a small radar from scratch
2. you can build a large radar from scratch
3. you can upgrade a small radar to large radar
4. you cannot build 2 small radars
5. you cannot build 2 large radars
6. you cannot build small and large radar together

I hope this is a complete example and can be used for testing, regardless of chosen implementation.

Here is the ruleset for a bit more complicated example (with 3 types of radar).

Code: [Select]
facilities:
  - type: STR_SMALL_RADAR_SYSTEM
    provideBaseFunc: [ RADAR ]
    forbiddenBaseFunc: [ RADAR ]
  - type: STR_LARGE_RADAR_SYSTEM
    provideBaseFunc: [ RADAR ]
    forbiddenBaseFunc: [ RADAR ]
    buildOverFacilities: [ STR_SMALL_RADAR_SYSTEM ]
  - type: STR_HYPER_WAVE_DECODER
    provideBaseFunc: [ RADAR ]
    forbiddenBaseFunc: [ RADAR ]
    buildOverFacilities: [ STR_SMALL_RADAR_SYSTEM, STR_LARGE_RADAR_SYSTEM ]

You can only have 1 radar in the base.
Each radar can be built from scratch.
Or following the upgrade path: Small radar -> Large radar -> Hyper radar.

This is available since OXCE v6.5.
Title: Re: [DONE][Suggestion] cantBeBuiltWith property for xcom base facilities
Post by: Finnik on May 19, 2020, 01:03:41 am
Thank you! It is very welcome by many mods!