aliens

Author Topic: [SUGGESTION]Custom Hangar/Craft types  (Read 10865 times)

Offline krautbernd

  • Commander
  • *****
  • Posts: 1108
    • View Profile
[SUGGESTION]Custom Hangar/Craft types
« on: November 10, 2022, 07:02:59 pm »
Seeing how different hangar&craft sizes probably aren't going to happen, I'd like to suggest custom hangar types instead, so things like dedicated sub pens or vehicles grages can be implemented which do not share hangars with aircarfts. This would also enable modders to implement 1x1 hangars for ground-based craft and reserve 2x2 hangars for aircraft or larger carfts. No messing around with different craft or hangar sizes or fitting multiple craft into one hangar slot.

Something like

Code: [Select]
crafts:
  - type: STR_VAN
    requires:
      - STR_LOGISTICS
    sprite: 829
    fuelMax: 9999
    damageMax: 25
    speedMax: 75
    hangarType: garage

Code: [Select]
facilities:
  - type: STR_HANGAR
    spriteShape: 9
    spriteFacility: 9
    size: 2
    buildCost: 200000
    buildTime: 25
    monthlyCost: 25000
    hangarType: garage
    crafts: 1

If a craft has no defined hangar type default to vanilla behaviour and ignore hangarType entry on facilities. If a craft definition includes a hangar type check for free hangar of that type. If free hangar of that type exist assign craft to first free hangar of that type. If no free hangars of that type exist throw "no free hangars" error.

That way vanilla craft treat all facilities with craft slots the same, while proper implementation requires all craft to have an assigned hangarType.

Would it be possible to implement something along these lines?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9078
    • View Profile
Re: [SUGGESTION]Custom Hangar/Craft types
« Reply #1 on: November 10, 2022, 07:58:54 pm »
The custom hangar types are the current request, there's nothing new in your post: https://openxcom.org/forum/index.php/topic,5895.msg96471.html#msg96471
The feature is still planned, but it is very difficult to implement (in a backwards-compatible way).

Also, I'm not sure what exactly do you mean by hangar sizes... but whatever it is, the custom hangar types are more difficult to implement than custom hangar sizes... so if you wanted to propose an easier solution, I'll have to disappoint you there.

Offline krautbernd

  • Commander
  • *****
  • Posts: 1108
    • View Profile
Re: [SUGGESTION]Custom Hangar/Craft types
« Reply #2 on: November 10, 2022, 11:14:01 pm »
The "current request" still includes multiple craft types (i.e. sizes) per hangar, which as I understand it causes major issues with sorting/assigning multiple different crafts to a hangar.

My suggestion is to drop and simplify this. No "default" craft types, no multiple different "craft types" per hangar. Just one craft type per hangar (or one hangar type per craft, however this is implemented).

Require all crafts to have an assigned hangar type (if a mod implements the feature) or no crafts have an assigned hangarType (i.e. vanilla). Alternatively assign crafts with no hangar type first, ignoring hangarType restrictions. That way any mod not implenting the feature as well as vanilla should default to vanilla behaviour.

Maybe I am missing something here in regards to backwards-compatibility.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9078
    • View Profile
Re: [SUGGESTION]Custom Hangar/Craft types
« Reply #3 on: November 10, 2022, 11:52:09 pm »
It might help, I'm not sure, I'll have to look at it again.

However, I will still likely go for the full solution.
I feel some modders will not accept just one type, and "force" me to implement multiple types later anyway... and it's better for me to do it that way from the start. Splitting it into two phases will again likely make it more complicated around backwards-compatibility (I'd have to be backwards-compatible not only with vanilla but also with phase 1 solution).

As for solving the "sorting/assigning mini-game", I already have a solution for that... it will be purely manual, the player will be forced to do it :)
Real-world mini-games are going to be much less complicated than a generic algorithm I'd have to do for worst cases.
And the manual mini-game GUI is necessary anyway for when the player wants to move craft within available hangars to allow buying/manufacturing more craft.

Offline mutantlord

  • Colonel
  • ****
  • Posts: 136
    • View Profile
Re: [SUGGESTION]Custom Hangar/Craft types
« Reply #4 on: February 07, 2023, 11:47:39 am »
Any update on this feature?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9078
    • View Profile
Re: [SUGGESTION]Custom Hangar/Craft types
« Reply #5 on: February 07, 2023, 11:56:50 am »
planned for oxce 8.0

Offline mutantlord

  • Colonel
  • ****
  • Posts: 136
    • View Profile
Re: [SUGGESTION]Custom Hangar/Craft types
« Reply #6 on: February 07, 2023, 02:49:58 pm »
thank you for the reply, looking forward to it!

Offline Flaubert

  • Sergeant
  • **
  • Posts: 39
    • View Profile
Re: [SUGGESTION]Custom Hangar/Craft types
« Reply #7 on: February 22, 2023, 10:28:07 pm »
It might help, I'm not sure, I'll have to look at it again.

However, I will still likely go for the full solution.
I feel some modders will not accept just one type, and "force" me to implement multiple types later anyway... and it's better for me to do it that way from the start. Splitting it into two phases will again likely make it more complicated around backwards-compatibility (I'd have to be backwards-compatible not only with vanilla but also with phase 1 solution).

As for solving the "sorting/assigning mini-game", I already have a solution for that... it will be purely manual, the player will be forced to do it :)
Real-world mini-games are going to be much less complicated than a generic algorithm I'd have to do for worst cases.
And the manual mini-game GUI is necessary anyway for when the player wants to move craft within available hangars to allow buying/manufacturing more craft.

Hello,
   are you considering a lot of different types of crafts? Or just big/small? If it's the later, I've developed a  variation of your code in which every craft has an "assigned" variable, so it's  possible to know if that kind is already allocated in the next facilities to draw. Sadly, it's necessary to check for all the crafts when drawing every hangar facility -and its crafts-, until you find the more apropriate, but as vector-of-crafts it's not expected to be large, I think it works well.
Facilities for small-crafts-only are allocated at the front of the facilities vector when created,  so "smallcrafts" are assigned first at small slots, and then, when all small slots are busy, all types of crafts are allocated at big slots.

In craft rules you must use a key for big/small craft (no key=big); in facilities rules (hangar type), you should use another key for "allow_only_small_crafts/allow_any_craft" (no key = any craft).

I also added to hangars rules, when they can contain more than 1 craft, a list of positions for the crafts sprites in the hangar tile (offsets with respect to the center of the tile). This way you can allocate more than 1 craft in a Hangar, and see the crafts in the BaseEscape.

I've made some tests, and draw routine works well, though there are a lot of changes to do -and mainly, to test- yet, regarding rules of acquisitions/manufcaturing/transfers and so on. At now purchase-of-crafts seems to work well too, observing rules of which-crafts-can-be-purchased depending of free (big/small) slots; manufacture of crafts seems to work also; I've not touched transfers yet, but I think it could be done using similar structures than in purchase/manufacture.

I must work also on what happens when an hangar is destroyed, as if there is more than 1 craft, current rules of craft destruction (based on the sprite at the hangar tile) must be reworked.

I'm sure that changes you are doing towards this feature will be better, but I don't know if I could be any help towards the introduction of this feature. If so, please let me know.

Finally, thanks a lot for your work with this engine. Xcom was one of mi favourite games when I was a child, and it was a big-pleasant surprise when I found this great port. Not only to play again, with better and polished mechanics, but also for the opportunity to learn about how it works.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9078
    • View Profile
Re: [SUGGESTION]Custom Hangar/Craft types
« Reply #8 on: February 23, 2023, 09:27:32 am »
are you considering a lot of different types of crafts? Or just big/small?

Many different types, not just big/small.

I'm sure that changes you are doing towards this feature will be better, but I don't know if I could be any help towards the introduction of this feature. If so, please let me know.

Not sure, probably not (with the coding).
I still have my old attempt and Yankes' old attempt available, I don't really need more code for inspiration.
The complexity is in the save backwards-compatibility (both old saves in new version and new saves in old version), and in a multitude of functional corner-cases.

I could use help with thorough testing though (from someone who can also read the code), maybe I can publish a beta version in a separate branch when ready and ask for help there.

Finally, thanks a lot for your work with this engine. Xcom was one of mi favourite games when I was a child, and it was a big-pleasant surprise when I found this great port. Not only to play again, with better and polished mechanics, but also for the opportunity to learn about how it works.

Thanks.

Most of your gratitude should however be pointed at SupSuper (for starting and for finishing this project) and at Warboy (for all the "how it works" stuff).
Many others helped too of course, but without these two gentlemen, it would not happen.

Offline TBeholder

  • Sergeant
  • **
  • Posts: 41
    • View Profile
Re: [SUGGESTION]Custom Hangar/Craft types
« Reply #9 on: February 27, 2023, 06:14:51 am »
but it is very difficult to implement (in a backwards-compatible way).
Why would it cause any more backwards-compatibility problems that requiresBaseFunc?
Hangar would have functionality property (much like provideBaseFunc, but affecting only this facility) set (or maybe even tag?). Craft has property that requires a hangar with certain functionality, which defaults to empty string. If a given craft has this requirement set, the required functionality is matched when available hangars are checked, so they are ineligible unless it’s present, much like they were full. Otherwise, all hangars remain good for this craft.
Then any mod not using this feature would be unaffected.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9078
    • View Profile
Re: [SUGGESTION]Custom Hangar/Craft types
« Reply #10 on: February 27, 2023, 08:38:32 am »
For example because right now the crafts don't belong to any hangars, just to a base. After this change, they will have to belong to particular hangars.

Online Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3348
    • View Profile
Re: [SUGGESTION]Custom Hangar/Craft types
« Reply #11 on: February 27, 2023, 12:03:01 pm »
And this is problem as you can't easy assignee craft to specific hangar manually, adding logic to allow this probably whole new UI and revamp all logic that touch crafts (build, transfer, sell, buy, facility destruction). This could end up with crating all this logic from scratch.

At least in my try code automatically tried assign crafts to hangars and only there were no space/valid combination (3 big and 2 small hangars will not fit 4 big crafts)
game report missing space for given craft.

One problem is that in theory it could be 36 hangars and unlimited number of crafts, and this in naive implementation could take eons to decide what is best fit
(as there 3.7199333e+41 possible combination of putting 36 crafts in 36 hangars). We can cut corners to reduce this insane number like allowing only 16 or 32 crafts (for 16! we have less than day to naive check every combination),
ignoring similar combinations (like in case default game you have 3 crafts and 6 possible combinations but you can use first one as all are equivalent).
And many other, and there is chance to reduce this time to less than second in even more extreme case.

Offline Flaubert

  • Sergeant
  • **
  • Posts: 39
    • View Profile
Re: [SUGGESTION]Custom Hangar/Craft types
« Reply #12 on: March 01, 2023, 08:52:43 pm »
Hello. I (think I) finished my attempt of OXCE modification to allow hangars with small and big crafts (but only "small" or "big", not a mix). I've tested (but not exhaustive testing) all but hangar destruction. All crafts are shown at baseescape, and you can select them with mouse right button.

You can see it working at this video, in the discord channel:
https://discordapp.com/channels/292085473890009088/330653502693179394/1080189519426490560

Code is in my public repository at github:  https://github.com/NHerreroReder/OpenXcomPruebas/tree/MultipleHangar
Feel free to use or modify it; I have no intention to make a fork, as OXC, OXCE authors have planned to add a similar feature in the future (which probably will be better/more complete). I just though it could be a funny way to learn more about the game engine.

I tested this feature with XcomFiles MOD (v2.8 and 2.9) and a  modified XFCHangar_Expansion_Pack SUBMOD. In order to use the new features:

- Hangars with small slots must have the "smallCraftsOnly: true" tag in their rule definition.
- Hangars with more than one craft must have a list of "craftSlots:" with their positions [x,y,z] in their rule definition:
     ...
    crafts: 2
   craftSlots:
     - [11, -11, 0]
     - [-11, 11, 0]

where x, y are distance respect the center of the hangar sprite; z is not used

- Crafts to be allocated in such slots must have a "isSmallCraft: true" tag in their rule definition

Of course you can avoid using those tags if your craft is not considered small and/or your hangar facility doesn't differentiate big and small crafts. This way I think backward compatibility will not be a problem.

I attached to this message a modified version of  XFCHangar_Expansion_Pack SUBMOD which include two new types of hangars (2x2 for 2 small slots and 3x3 for 4 big slots). It modifies also craft rules to include required tags at some of the Xcom Files vehicles (Van, Cars, Hummer,...)






Offline DoxaLogos (JG)

  • Colonel
  • ****
  • Posts: 358
  • Squaddie cautiously peering through the breach
    • View Profile
Re: [SUGGESTION]Custom Hangar/Craft types
« Reply #13 on: March 01, 2023, 10:41:34 pm »
If this gets fully implemented, it would be such a great add especially for some of these mega mods.  I feel like I'm wasting a ton of base space to have one small vehicle in a massive hangar.

Online Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3348
    • View Profile
Re: [SUGGESTION]Custom Hangar/Craft types
« Reply #14 on: March 01, 2023, 11:25:48 pm »
Hello. I (think I) finished my attempt of OXCE modification to allow hangars with small and big crafts (but only "small" or "big", not a mix). I've tested (but not exhaustive testing) all but hangar destruction. All crafts are shown at baseescape, and you can select them with mouse right button.

You can see it working at this video, in the discord channel:
https://discordapp.com/channels/292085473890009088/330653502693179394/1080189519426490560

Code is in my public repository at github:  https://github.com/NHerreroReder/OpenXcomPruebas/tree/MultipleHangar
Feel free to use or modify it; I have no intention to make a fork, as OXC, OXCE authors have planned to add a similar feature in the future (which probably will be better/more complete). I just though it could be a funny way to learn more about the game engine.

I tested this feature with XcomFiles MOD (v2.8 and 2.9) and a  modified XFCHangar_Expansion_Pack SUBMOD. In order to use the new features:

- Hangars with small slots must have the "smallCraftsOnly: true" tag in their rule definition.
- Hangars with more than one craft must have a list of "craftSlots:" with their positions [x,y,z] in their rule definition:
     ...
    crafts: 2
   craftSlots:
     - [11, -11, 0]
     - [-11, 11, 0]

where x, y are distance respect the center of the hangar sprite; z is not used

- Crafts to be allocated in such slots must have a "isSmallCraft: true" tag in their rule definition

Of course you can avoid using those tags if your craft is not considered small and/or your hangar facility doesn't differentiate big and small crafts. This way I think backward compatibility will not be a problem.

I attached to this message a modified version of  XFCHangar_Expansion_Pack SUBMOD which include two new types of hangars (2x2 for 2 small slots and 3x3 for 4 big slots). It modifies also craft rules to include required tags at some of the Xcom Files vehicles (Van, Cars, Hummer,...)
Ok, but its very limited, effective only two types of craft available, if I recall correctly Meridian target fro multiple hangar types, not only two.
Xcom Files could for example use submarine subpen or dedicate rocket launch bay.