OpenXcom Forum
Modding => OpenXcom Extended => OXCE Suggestions DONE => Topic started 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:
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!
-
why not use `forbiddenBaseFunc` ?
-
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.
-
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:
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.
-
- Airlock should provide funcA
- Small radar should require funcA and provide funcB
- Big radar should require funcB and forbid funcA
-
Yes, I tried that...
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?
-
hmm, I guess the feature is not compatible with upgrades, probably checking too much or not enough...
I'll check later
-
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...
-
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.
-
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.
-
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)
-
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.
-
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
-
No, we can't.
That functionality is not in OXCE yet.
Ok, but we could, for example, with that
-
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.
-
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
-
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.
-
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 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`)
-
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?
-
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`
-
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.
-
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
-
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.
-
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).
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.
-
Thank you! It is very welcome by many mods!