Author Topic: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...  (Read 2124 times)

Offline WarStalkeR

  • Sergeant
  • **
  • Posts: 18
  • Repensum Est Canicula
    • View Profile
Hello Meridian, I spoke with Yankes in Matrix Chat and he told me that you intend to implement Multi-Craft Hangars. I want to know if you intended to implement Multi-Craft Hangars in a way, similar to what I implemented here: https://github.com/WarStalkeR/OpenXcomExMore/compare/810aba6..8e4cb43?diff=unified

Sadly, this compare is quite messy as it encompasses multiple code changes, including Multi-Craft Hangars, Craft Sizes, Custom/Moddable Craft Classifications, Bigger Craft Sprites and even soldiers+vehicles as modifiable craft stats (that already in pull into main and QA'd by Yankes).

I'm mostly active on Matrix and all glaring mistakes that were pointed out by Yankes - are fixed, except few: missing proper Struct for hangar slots instead of Position and missing proper Struct for bigOffset. Because I make it all for submod for XPZ, it uses OXCE 7.9.8 as base version. Latest compiled EXE is also uploaded there (in Submods chatroom).

Meridian, you don't need to do any QA, just tell me if this is same or similar way you intended to implement? And I will work from there.

And this is how it looks for modders right now (more description is on GitHub):
Code: [Select]
facilities:
  - type: NEW_FANCY_HANGAR
  crafts: 2 #Original code isn't going anywhere for sake of max backwards compatibility.
  craftsHidden: false #Flag to render or not render housed crafts in base view. Mostly for damaged/sealed hangars.
  craftOptions: #Horizontal offset - X, Vertical offset - Y, Craft size limit Z (0 is no size limit and default).
  - [2, -4, 37] #This slot can fit size 37 craft or smaller.
  - [8, 2, -25] #This slot can fit size 24 craft or smaller and is always hidden, regardless of the 'craftsHidden'
The - [2, -4, 37] will be replaced with - {x: 2, y: -4, size: 37, hidden: false} per Yankes advice. I originally intended to go with - [2, -4, 37, false] but Yankes said its better to make it more verbose and obvious, which I agree with.
Code: [Select]
crafts:
  - type: NEW_FANCY_CRAFT
  craftSize: 12 #Can't be placed into size 11 hangar slots. If 0, can be placed into any hangar slot (0 is default).
The craftSize variable has no bounds beside being an int (i.e. from -2^31 to 2^31). Modders can define for themselves what craft size ranges belongs to what craft classes.
Code: [Select]
craftWeapons:
  - type: NEW_FANCY_WEAPON
  stats:
    craftSize: 6 #Increases craft's size by 6, if equipped. Can't be equipped if no suitable hangar slots available.
craftSize is stat as so modders can create various types that take more or less space on craft.
Code: [Select]
craftClasses:
 100: STR_CRAFT_CLASS_03 #All crafts of size 100 or above will be assigned STR_CRAFT_CLASS_03 string.
 20: STR_CRAFT_CLASS_02 #All crafts of size 20 to 99 will be assigned STR_CRAFT_CLASS_02 string.
 1: STR_CRAFT_CLASS_01 #All crafts of size 1 to 19 will be assigned STR_CRAFT_CLASS_01 string.
 0: STR_CRAFT_CLASS_NA #All crafts of size 0 or below will be assigned STR_CRAFT_CLASS_NA string.
 craftsCanChangeClass: false #Allows to enforce craft size changes to be within boundaries declared in the craftClasses.
This is global option and can be added just to any rule file. craftsCanChangeClass will allow modders to ensure that player can't install quad 30mm autocannon that increases craftSize by 20 (just because it is in light weapons group) on small helicopter.
Code: [Select]
crafts:
 - type: BIG_SPRITE_CRAFT
 bigOffsetX: -11 #Because sprite width got increased by 22, i.e. from 32 to 54.
 bigOffsetY: -16 #Because sprite height got increased by 32, i.e. from 40 to 72.
Allows to keep crafts with bigger sprites centered in hangars at same point as original 32x40 sprites. Any change to the sprite size should be even: i.e. you can't use 35x45 pixels sprite. Any change to sprite size should get reflected as negative half in bigOffsetX and bigOffsetY. Rather lazy implementation, but I will replace it with custom Struct as well.

Offline Flaubert

  • Sergeant
  • **
  • Posts: 37
    • View Profile
    • Email
Re: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...
« Reply #1 on: September 26, 2023, 09:01:19 am »
Hello Meridian, I spoke with Yankes in Matrix Chat and he told me that you intend to implement Multi-Craft Hangars. I want to know if you intended to implement Multi-Craft Hangars in a way, similar to what I implemented here: https://github.com/WarStalkeR/OpenXcomExMore/compare/810aba6..8e4cb43?diff=unified

Sadly, this compare is quite messy as it encompasses multiple code changes, including Multi-Craft Hangars, Craft Sizes, Custom/Moddable Craft Classifications, Bigger Craft Sprites and even soldiers+vehicles as modifiable craft stats (that already in pull into main and QA'd by Yankes).

I'm mostly active on Matrix and all glaring mistakes that were pointed out by Yankes - are fixed, except few: missing proper Struct for hangar slots instead of Position and missing proper Struct for bigOffset. Because I make it all for submod for XPZ, it uses OXCE 7.9.8 as base version. Latest compiled EXE is also uploaded there (in Submods chatroom).

Meridian, you don't need to do any QA, just tell me if this is same or similar way you intended to implement? And I will work from there.

And this is how it looks for modders right now (more description is on GitHub):
Code: [Select]
facilities:
  - type: NEW_FANCY_HANGAR
  crafts: 2 #Original code isn't going anywhere for sake of max backwards compatibility.
  craftsHidden: false #Flag to render or not render housed crafts in base view. Mostly for damaged/sealed hangars.
  craftOptions: #Horizontal offset - X, Vertical offset - Y, Craft size limit Z (0 is no size limit and default).
  - [2, -4, 37] #This slot can fit size 37 craft or smaller.
  - [8, 2, -25] #This slot can fit size 24 craft or smaller and is always hidden, regardless of the 'craftsHidden'
The - [2, -4, 37] will be replaced with - {x: 2, y: -4, size: 37, hidden: false} per Yankes advice. I originally intended to go with - [2, -4, 37, false] but Yankes said its better to make it more verbose and obvious, which I agree with.
Code: [Select]
crafts:
  - type: NEW_FANCY_CRAFT
  craftSize: 12 #Can't be placed into size 11 hangar slots. If 0, can be placed into any hangar slot (0 is default).
The craftSize variable has no bounds beside being an int (i.e. from -2^31 to 2^31). Modders can define for themselves what craft size ranges belongs to what craft classes.
Code: [Select]
craftWeapons:
  - type: NEW_FANCY_WEAPON
  stats:
    craftSize: 6 #Increases craft's size by 6, if equipped. Can't be equipped if no suitable hangar slots available.
craftSize is stat as so modders can create various types that take more or less space on craft.
Code: [Select]
craftClasses:
 100: STR_CRAFT_CLASS_03 #All crafts of size 100 or above will be assigned STR_CRAFT_CLASS_03 string.
 20: STR_CRAFT_CLASS_02 #All crafts of size 20 to 99 will be assigned STR_CRAFT_CLASS_02 string.
 1: STR_CRAFT_CLASS_01 #All crafts of size 1 to 19 will be assigned STR_CRAFT_CLASS_01 string.
 0: STR_CRAFT_CLASS_NA #All crafts of size 0 or below will be assigned STR_CRAFT_CLASS_NA string.
 craftsCanChangeClass: false #Allows to enforce craft size changes to be within boundaries declared in the craftClasses.
This is global option and can be added just to any rule file. craftsCanChangeClass will allow modders to ensure that player can't install quad 30mm autocannon that increases craftSize by 20 (just because it is in light weapons group) on small helicopter.
Code: [Select]
crafts:
 - type: BIG_SPRITE_CRAFT
 bigOffsetX: -11 #Because sprite width got increased by 22, i.e. from 32 to 54.
 bigOffsetY: -16 #Because sprite height got increased by 32, i.e. from 40 to 72.
Allows to keep crafts with bigger sprites centered in hangars at same point as original 32x40 sprites. Any change to the sprite size should be even: i.e. you can't use 35x45 pixels sprite. Any change to sprite size should get reflected as negative half in bigOffsetX and bigOffsetY. Rather lazy implementation, but I will replace it with custom Struct as well.
Your solution is very similar to mine:
https://r.tapatalk.com/shareLink/topic?url=https%3A%2F%2Fopenxcom%2Eorg%2Fforum%2Findex%2Ephp%3Ftopic%3D10870%2E0&share_tid=10870&share_fid=91863&share_type=t&link_source=app

But in mine, crafts can only be allocated in an specific hangar class. I thought about doing size-basis-allocation, but someone told me that couldn't be enough as you can have small air-craft and small ships and each one could have its own place.
I tried with a bit-wise allocation to allow many hangars allocation for a craft, but It was very difficult to achieve due to algorithmical complexity.

Also, I don't understand the hidden flag, as I thought damaged hangars couldn't store anything; perhaps I'm mistaken.

You should add something to allow current mods compatibility -without changes-. In my version, as I identify hangars/crafts by a number, I used a special-default value (-1) for not-defined hangars, so It was compatible with existing mods.

Furthermore, last version of OXCE+ I worked with, had some logic faults in program that didn't allow many crafts in an hangar. In that version, when a hangar is destroyed, only one craft -the one shown at basescape- is destroyed. So, if you want to show more than one craft at an hangar, that Code must be changed -with I did already in my version-

Hope your version will be accepted. Good luck.



Enviado desde mi V2244 mediante Tapatalk


Offline WarStalkeR

  • Sergeant
  • **
  • Posts: 18
  • Repensum Est Canicula
    • View Profile
Re: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...
« Reply #2 on: September 27, 2023, 02:10:30 pm »
But in mine, crafts can only be allocated in an specific hangar class. I thought about doing size-basis-allocation, but someone told me that couldn't be enough as you can have small air-craft and small ships and each one could have its own place.
I will just add 'minSize', since I will be making my own struct anyway and I intended to add it in the first place.

I tried with a bit-wise allocation to allow many hangars allocation for a craft, but It was very difficult to achieve due to algorithmical complexity.
It isn't simple, but you can use as reference how 'Base.cpp' handles '_crafts' - and if you will handle '_craftSlots' in similar manner, everything becomes way less complicated.

Also, I don't understand the hidden flag, as I thought damaged hangars couldn't store anything; perhaps I'm mistaken.
Example: hangar with blast doors. After bombardment doors closed, hangar damaged, but not heavily. I don't want to draw crafts on top of blast doors, nor do I want to move them to another slot.

You should add something to allow current mods compatibility -without changes-. In my version, as I identify hangars/crafts by a number, I used a special-default value (-1) for not-defined hangars, so It was compatible with existing mods.
I only need to ensure backwards compatibility with OXCE, so in case if original OXCE executable is getting used, so mod will load without any issues.

Furthermore, last version of OXCE+ I worked with, had some logic faults in program that didn't allow many crafts in an hangar. In that version, when a hangar is destroyed, only one craft -the one shown at basescape- is destroyed.
Seems like I forgot to test and validate that part. Thanks for pointing it out.
« Last Edit: September 27, 2023, 02:13:50 pm by WarStalkeR »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8272
    • View Profile
Re: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...
« Reply #3 on: September 27, 2023, 03:05:12 pm »
Hi WarStalkeR,

I intend to keep facilities.crafts, same as you.
Your facilities.craftsHidden is a nice idea, I will add it to my notes.
Your facilities.craftOptions I plan to do as well, maybe in a different way, but same result.

craft.craftSize, I don't plan doing:
- I plan a solution based on matching hangar/craft types, similar approach as Flaubert
- I don't think a numeric size should be the core parameter, I'd rather see descriptive types (e.g. small/medium/large, land/underwater, earth/space, etc.); I think it's better for players and modders

craftWeapons.craftSize, I don't plan doing either:
- honestly any weapon should be much smaller than a craft and not change its size
(- or from the other perspective... craft size is the size of the craft with the biggest possible guns already installed)

craftClasses, I don't plan on doing as global parameters, but as hangar and craft types directly.

--

I also will make sure the solution is backwards compatible with current mods, with previous versions of OXCE and with previous and future versions of OXC. Any old saves from OXC/OXCE should load and recover in the new version of OXCE, and any new OXCE saves should load and recover in the old versions of OXC/OXCE.

--

Functionally, I plan to change existing OXC (vanilla) behavior only where absolutely necessary for data consistency... for example as Flaubert mentioned when hangars are destroyed.

--

I'm not sure if your size-based solution will be compatible (or necessary) after the planned OXCE changes are done.
I guess we'll see only after it's done.
« Last Edit: September 27, 2023, 03:25:02 pm by Meridian »

Offline WarStalkeR

  • Sergeant
  • **
  • Posts: 18
  • Repensum Est Canicula
    • View Profile
Re: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...
« Reply #4 on: September 27, 2023, 04:15:29 pm »
craft.craftSize, I don't plan doing:
- I plan a solution based on matching hangar/craft types, similar approach as Flaubert
- I don't think a numeric size should be the core parameter, I'd rather see descriptive types (e.g. small/medium/large, land/underwater, earth/space, etc.); I think it's better for players and modders

craftWeapons.craftSize, I don't plan doing either:
- honestly any weapon should be much smaller than a craft and not change its size
(- or from the other perspective... craft size is the size of the craft with the biggest possible guns already installed)

craftClasses, I don't plan on doing as global parameters, but as hangar and craft types directly.
My approach to the Craft Size stems from this example:
Escort-class, Craft Size range: 20 ~ 29.
Small-class, Craft Size range: 30 ~ 49.
"Piranha" belongs to Escort-class, while "Shark" belongs to Small-class.
Both of them have same weapon slots: 2x Light Weapons.
Research, "Minigun Development", unlocks set of new Light Weapons:
* 14mm Minigun - increases craft's size by 4.
* 14mm Dual Minigun w/ Extended Ammo Rack - increases craft size by 8.
* 14mm Minigun w/ Advanced Cooling - increases craft size by 7.
* 14mm Minigun w/ Reduced Ammo Cap - increases craft size by 3.
Piranha won't be able to mount two biggest Minigun variants, because it ain't big itself.
Shark will be able to mount two biggest Minigun variants, because it has enough space to spare for it.

Another example will be module/system that increase craft's soldier/vehicle (the part that transforms soldiers/vehicles to dynamic stat is already in pull and QA'd by Yankes). It should be rather massive, to ensure that only one can be mounted into same system slots that allows to mount various other systems and to make player chose between better soldier capacity or better craft weapons.

Craft Size is something akin to inventory slots, albeit numerical only.
« Last Edit: September 27, 2023, 05:14:35 pm by WarStalkeR »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8272
    • View Profile
Re: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...
« Reply #5 on: September 27, 2023, 05:35:10 pm »
I understand.
I just don't think it's a good feature.

Both usability-wise and lore-wise.

In my opinion, a jet without a minigun and a jet with a minigun makes no difference.
Hangar space/volume that can house a jet without a minigun must be able to house a jet with a minigun, easily.
First because a minigun is way smaller than any jet, and second because any hangar slot must have a generous "buffer" (crafts in a hangar are not tetris pieces literally touching each other, there's always a LOT of extra space around a craft for maneuvering, refueling, repairs, rearming, installation of weapons, takeoff and landing, etc.).
Volume-wise, I don't think a craft takes more than 10% of the volume of its assigned slot, probably even less. With a minigun installed, it takes up 10.1% of the available volume.

As for "extra modules" increasing craft crew capacity... I have already said that I don't have any objections and that the PR can be merged into OXCE.
But I also hope that modders have common sense and won't allow adding a "weapon" to a single-manned jet that will increase its capacity by another 10 people or something.
I would (maybe naively) assume that adding a little extra capacity to a small craft leaves it still small, medium stays medium and large stays large.

PS: I definitely don't want hangars to work like soldier inventory... that is way too complicated and unnecessary.

PS2: if you're on Matrix, maybe ask Dioxine (and other modders) what do they think about the concept... if they want to go to this level of granularity... or if they would prefer "simpler" categorization (by type instead of by numbers). So far, all the requests I have heard over the years from various people were just fine with the types.

Offline WarStalkeR

  • Sergeant
  • **
  • Posts: 18
  • Repensum Est Canicula
    • View Profile
Re: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...
« Reply #6 on: September 27, 2023, 07:23:45 pm »
In my opinion, a jet without a minigun and a jet with a minigun makes no difference.
Hangar space/volume that can house a jet without a minigun must be able to house a jet with a minigun, easily.
First because a minigun is way smaller than any jet, and second because any hangar slot must have a generous "buffer"
When I started implementing craft slots at first I went similar to the way you intended. Craft gets size/id/type as single number and then in slots I write what sizes/ids/types it can house. But then I though maybe it will be good idea to submod different variations of existing weapons/modules/system in XPZ and allow players to balance it out on their own: do the player wants craft weapon with more ammo, but gets to equip weaker module/system? Or do the player wants strap onto craft additional rocket engines in exchange for meager weapons with reduced stats. And this is how it ended up with craft size becoming new stat for crafts.

(crafts in a hangar are not tetris pieces literally touching each other, there's always a LOT of extra space around a craft for maneuvering, refueling, repairs, rearming, installation of weapons, takeoff and landing, etc.).
Well, while making submod for XPZ I already drawn various hangars... And I already partially made 3x3 hangars.

* Old Civilian Hangar - can safekeep and maintain single Assault-class craft. Also known as default hangar.
* Reinforced Hangar - can safekeep and maintain single Massive-class craft.
* Composite Hangar - can safekeep and maintain one Large-class and one Medium-class craft.
* Interception Hangar - can safekeep and maintain three Small-class crafts.
* Relic X-COM Hangar - can safekeep and maintain one Massive-class and two Escort-class crafts. Has blast doors.
* Camping Site - can house single Infantry-class "craft" (expeditions & etc).
* Vehicle Garage - can house any single Vehicle-class "craft" (truck, convoy, cadillac & etc).
* Small Helipad - can house any single Escort-class craft (small helicopter, Piranha & etc).
* Mass Driver - can house four Rail Pods (they will get new sprite for it as well).

PS: I definitely don't want hangars to work like soldier inventory... that is way too complicated and unnecessary.
Well, Craft Size is numerical only to avoid all this hassle (despite my love for X-COM Apocalypse-style craft inventory, implementation of which into OXCE is just beyond my ability). It is more like mix of inventory and max weight capacity. Anyway, any code you find yourself in my fork, you're free to take and modify as you deem necessary.

PS2: if you're on Matrix, maybe ask Dioxine (and other modders) what do they think about the concept... if they want to go to this level of granularity... or if they would prefer "simpler" categorization (by type instead of by numbers). So far, all the requests I have heard over the years from various people were just fine with the types.
Certainly. I will ask Dioxine and other modders what they are thinking in that regard. Frankly, I hope the code I've wrote already will be of help to you and reduce some of your OXCE workload and allow you to implement stuff you want instead.

Offline Dioxine

  • Commander
  • *****
  • Posts: 5403
  • punk not dead
    • View Profile
    • Nocturnal Productions
    • Email
Re: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...
« Reply #7 on: September 27, 2023, 07:54:47 pm »
I consider this system far overcomplicated for my actual needs (for which a system mirroring eg. prison types would be more than enough; I actually plan to have only 2 types of craft, 'small' and 'normal', to make craft like V8 more useful by making it take 1/4th space). However I won't judge or try to guess what other people need.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11303
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
    • Email
Re: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...
« Reply #8 on: September 27, 2023, 08:05:11 pm »
Coincidentally, my opinion is exactly the same. I don't even understand 90% of these features, all I want for my mod are two types of hangars, big and small. Right now I honestly don't know what else I could ever want and why.
But then again, I don't like the air game in X-Com much, so I'm not the best person to ask.

Offline Flaubert

  • Sergeant
  • **
  • Posts: 37
    • View Profile
    • Email
Re: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...
« Reply #9 on: September 28, 2023, 06:19:04 pm »
Coincidentally, my opinion is exactly the same. I don't even understand 90% of these features, all I want for my mod are two types of hangars, big and small. Right now I honestly don't know what else I could ever want and why.
But then again, I don't like the air game in X-Com much, so I'm not the best person to ask.
Honestly, most people only really wanted a 1x1garage for cars, so first version I had was just "Small&Big hangars/crafts" - where cars (1x1) could be stored also at crafts hangars (2x2) but not the opposite-

Then someone noted that you could need different hangars for underwater and aerial crafts and so on, so a new version was done where each craft had a hangar-ID and could only be allocated at that hangar/garage or whatever. This gives more flexibility, as different crafts can go to the same hangar type, but on the other side they can go to only ONE hangar type, which is the main drawback.

Probably Meridian wants to get ahead of other future modders, whose requirements could be more demanding.

« Last Edit: September 28, 2023, 06:25:36 pm by Flaubert »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8272
    • View Profile
Re: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...
« Reply #10 on: September 28, 2023, 06:30:45 pm »
I want multiple craft types into multiple hangar types (or more precisely into multiple hangar slot types).
So all the cases you mentioned, plus more.

That should cover all the use cases I have heard so far from the modders... until WarStalkeR came with a more demanding requirement.

I don't dare guess or judge peoples' needs, but I can't make everybody happy.
I will implement the solution acceptable by the majority, and if WarStalkeR will still need a more complicated solution, we can discuss if it could be done in OXCE (afterwards) or if a new fork is required.

Offline Alex_D

  • Colonel
  • ****
  • Posts: 475
    • View Profile
Re: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...
« Reply #11 on: September 29, 2023, 03:07:44 am »
For what is worth, here is my two cents on my understanding of the hangar problem.

The idea was to approach it like in real life, like storing stuff in a warehouse (or even a large US supercarrier), this is using available square footage area.

A global variable is defined which is the square area per craft size. Example for an array with five class sizes: [100,5,2,10,500], where craft size 1 is 100 area (default), size 2 is 5 area, size 3 is 2 area, and so on. Default array would be [100] in this example.

Each applicable facility will have a number than indicate a total footage area (say 100 default) that can be used to store vehicles, and an array of 1 or 0 indicating if a certain craft size will be allowed to "park" in the facility or not (e.g. [1,0,0,1,0] ). Alternative this array can be used to limit the number of crafts per size class, overruling area limitations (e.g. [1,0,0,3,0]).

Each craft will be assigned a size based on the array position (eg. size=1).

Then then game, once every in a while (once a day, or hour, or when there is a need for a check), will allocate the crafts sorting them across all facilities per base.

Of course this approaches doesn't solve graphics or user specific assignments.

Offline WarStalkeR

  • Sergeant
  • **
  • Posts: 18
  • Repensum Est Canicula
    • View Profile
Re: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...
« Reply #12 on: September 29, 2023, 06:55:19 am »
I will implement the solution acceptable by the majority, and if WarStalkeR will still need a more complicated solution, we can discuss if it could be done in OXCE (afterwards) or if a new fork is required.
I mean, I already implemented it in my fork. With all the validation to ensure that no action allows to exploit/bypass it. Such as when player purchases/produces/transfers craft, the game validates that base has suitable craft slots, and so that crafts won't occupy bigger slot than they actually need, and some validations for some other craft slot related changes such as when facility gets removed/destroyed/built, and so on.

I've tried to to encapsulate my new code to functions as much as possible (and I think I succeeded for the most part), so just in case anybody can implement their own vision of the multi-craft hangars without worrying too much, if X/Y/Z places were validated properly.

Anyway, Meridian, you don't need to worry about my requests, you can go on with what majority decided. Once XPZ will switch to the new version, I will just sync and rebase my code to these changes (of version XPZ will be using). The C++ code of OXCE (that I've seen so far) is very clean and easy to understand, so there will be no issues with code rebases for me.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8272
    • View Profile
Re: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...
« Reply #13 on: September 30, 2023, 08:53:31 pm »
What I like about your solution is that it has a very low complexity, basically just n.log(n)
You can easily find the best solution for craft placement, and quickly.
That's the advantage of having just one "dimension", i.e. size, and even a numeric one.

However, I (or better said modders) need more than just size, there's demand for orthogonal dimensions (like land/underwater/space, etc.) making craft types inherently incomparable/un-sortable.
This will leave me with a brute-force solution only, resulting in unacceptable complexity of n-factorial.
The workaround I have in mind for that, is basically dumb down the algorithm to quadratic (or even linear) approximation and let the player resolve any failures (situations when the algorithm cannot find a solution) manually.

Your "encapsulation" looks nice, I will give it a try when doing my solution.
I cannot say upfront if it will work for me or not, but I can at least try.

Offline WarStalkeR

  • Sergeant
  • **
  • Posts: 18
  • Repensum Est Canicula
    • View Profile
Re: Multi-Craft Hangars, Craft Sizes, Custom Craft Classifications & More...
« Reply #14 on: September 30, 2023, 09:39:25 pm »
However, I (or better said modders) need more than just size, there's demand for orthogonal dimensions (like land/underwater/space, etc.) making craft types inherently incomparable/un-sortable.
I have very good news regarding this part.

I just finished implementing (and testing) min/max size option for hangar slots: https://github.com/WarStalkeR/OpenXcomExMore/commit/07a9cd7bcaa81f3773b8cdcc74c3c3b9bba2e54c

Basically, right now modder can decide that craft sizes from 200 to 399 are reserved for subs only, 400 to 599 to spaceships only & etc. And modding-wise it looks like this:
Code: [Select]
facilities:
  - type: NEW_FANCY_HANGAR
  crafts: 3 #Original code isn't going anywhere for sake of max backwards compatibility.
  craftsHidden: false #Flag to render or not render housed crafts in base view. Mostly for damaged/sealed hangars.
  craftOptions: #Horizontal offset - x, Vertical offset - y, Craft minimum size - min, Craft maximum size - max, Hide craft - true/false.
    - [2, -4, 20, 49, false] #This slot can fit any craft of size between 20 (inclusive) and 49 (inclusive), and craft isn't hidden.
    - [8, 2, 1, 19, true] #This slot can fit any craft of size between 1 and 19, and always hides craft, regardless of the 'craftsHidden' setting.
    - [2, -4, 0, 0, false] #This slot can fit any craft of any size, because 0, 0 is option to ignore craft sizes and classic hangars default.

Using granular feature I've shown in first post modder can classify it like this:
Code: [Select]
craftClasses:
 400: STR_STOP #To limit spaceship class to craft size range between 200 and 399.
 200: STR_CRAFT_CLASS_SPACE #All crafts of size 200 to 399 will be reserved for spaceships.
 1: STR_CRAFT_CLASS_SUBS #All crafts of size 1 to 199 will be reserved for subs.
 0: STR_NOPE #No using 0, since craft size 0 means craft can be shoved into any craft slot.

Or if modder decided to go more complicated way:
Code: [Select]
craftClasses:
 4000: STR_STOP #To limit large spaceship class to max craft size of 3999.
 1000: STR_SPACESHIP_LARGE #Craft sizes from 1000 to 3999 - large spaceships.
 500: STR_SPACESHIP_MED #Craft sizes from 500 to 999 - medium spaceships.
 200: STR_SPACESHIP_SMALL #Craft sizes from 200 to 499 - small spaceships.
 100: STR_SUBS_LARGE #Craft sizes from 100 to 199 will be reserved for large subs.
 40: STR_SUBS_MED #Craft sizes from 40 to 99 will be reserved for medium subs.
 1: STR_SUBS_SMALL #Craft sizes from 1 to 39 will be reserved for small subs.
 0: STR_NOPE #No using 0, since craft size 0 means craft can be shoved into any craft slot.

And then just use these self-defined bounds in custom spaceship dock:
Code: [Select]
facilities:
  - type: DEFINITELY_A_SPACEPORT
  crafts: 2
  craftOptions:
    - [10, -10, 1000, 3999, false] #Can house large spaceship.
    - [10, -10, 200, 999, false] #Can house small or medium spaceship.

Class also will be shown in Ufopaedia, as in example below: