aliens

Author Topic: [DONE][Suggestion] Possibility to choose UFO size displayed in dogfights  (Read 1170 times)

Offline Cooper

  • Colonel
  • ****
  • Posts: 176
  • Chryssalids are awesome
    • View Profile
So when you give a size to a UFO, for example "size: STR_VERY_SMALL", this affects how big the UFO looks in dogfight. However, if you choose something else than the standard UFO sizes, for example STR_SMALL_X_2, it automatically displays the same size as very large UFOs in dogfight. Would be awesome if there was an option to change this, like:
Code: [Select]
ufos:
  - type: STR_TWO_SMALL_ABDUCTORS
    size: STR_SMALL_X_2
    dogfightDisplaySize: 3

Also: Would be extra awesome to display a size even larger than the one of very large ufos  8)
Code: [Select]
ufos:
  - type: STR_WARSHIP
    size: STR_HUGE
    dogfightDisplaySize: 6

Edit: Typo
« Last Edit: December 11, 2024, 09:43:42 pm by Cooper »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9393
    • View Profile
Re: [Suggestion] Possibility to choose UFO size displayed in dogfights
« Reply #1 on: December 25, 2024, 02:50:33 pm »
Why not just use:

Code: [Select]
ufos:
  - type: STR_TWO_SMALL_ABDUCTORS
    size: STR_MEDIUM_UC

?

Offline Cooper

  • Colonel
  • ****
  • Posts: 176
  • Chryssalids are awesome
    • View Profile
Re: [Suggestion] Possibility to choose UFO size displayed in dogfights
« Reply #2 on: December 28, 2024, 05:42:41 pm »
Why not just use:

Code: [Select]
ufos:
  - type: STR_TWO_SMALL_ABDUCTORS
    size: STR_MEDIUM_UC

?


The idea is to give more options than just the standard sizes, for example to make it seem like there is two UFOs together. As far as the game engine knows its still one, but in battlescape you can have for example two UFOs in the same mission. Of course then the best in dogfight would be to draw two separate UFOs, but I don't know how difficult that is? So I thought if its at least not showing one very large UFO that would help. Hope that makes sense!

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9393
    • View Profile
Re: [DONE][Suggestion] Possibility to choose UFO size displayed in dogfights
« Reply #3 on: February 10, 2025, 12:48:05 pm »
1. Decoupled UFO radius from UFO size

https://github.com/MeridianOXC/OpenXcom/commit/67edd9690c0172ff69c89abc15b620084a268c38

This is currently not used, because UFOs cannot shoot missiles, they always shoot beams.

But if they could in the future, you will be able to set the offset based on ufo radius.

Related calculation/usage: https://github.com/OpenXcom/OpenXcom/blob/master/src/Geoscape/DogfightState.cpp#L1242

Sample ruleset:

Code: [Select]
ufos:
  - type: STR_LARGE_SCOUT
    radius: 10   # default -1 = vanilla by size

If not specified, default is based on vanilla sizes.

Code: [Select]
int RuleUfo::getRadius() const
{
if (_radius > -1)
return _radius;

if (_size == "STR_VERY_SMALL")
return 2;
else if (_size == "STR_SMALL")
return 3;
else if (_size == "STR_MEDIUM_UC")
return 4;
else if (_size == "STR_LARGE")
return 5;
else if (_size == "STR_VERY_LARGE")
return 6;

return 0;
}

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9393
    • View Profile
Re: [DONE][Suggestion] Possibility to choose UFO size displayed in dogfights
« Reply #4 on: February 10, 2025, 12:49:23 pm »
2. Decoupled UFO visibility from UFO size

https://github.com/MeridianOXC/OpenXcom/commit/20052235c4dd41ee8c7c96ade0727cbae2121044

UFO visibility depends on its size and on its altitude.
The size part was decoupled.


Related calculation/usage:
https://github.com/OpenXcom/OpenXcom/blob/master/src/Savegame/Craft.cpp#L754
https://github.com/OpenXcom/OpenXcom/blob/master/src/Savegame/Base.cpp#L477

Sample ruleset:

Code: [Select]
ufos:
  - type: STR_LARGE_SCOUT
    visibility: 90   # default 0 = vanilla by size

If not specified, default is based on vanilla sizes.

Code: [Select]
int RuleUfo::getDefaultVisibility() const
{
if (_visibility != 0)
return _visibility;

// vanilla = 15*(3-ufosize);
if (_size == "STR_VERY_SMALL")
return -30;
else if (_size == "STR_SMALL")
return -15;
else if (_size == "STR_MEDIUM_UC")
return 0;
else if (_size == "STR_LARGE")
return 15;
else if (_size == "STR_VERY_LARGE")
return 30;

return 0;
}

Second part:

Code: [Select]
int Ufo::getVisibility() const
{
int size = _rules->getDefaultVisibility();

int visibility = 0;
if (_altitude == "STR_GROUND")
visibility = -30;
else if (_altitude == "STR_VERY_LOW")
visibility = size - 20;
else if (_altitude == "STR_LOW_UC")
visibility = size - 10;
else if (_altitude == "STR_HIGH_UC")
visibility = size;
else if (_altitude == "STR_VERY_HIGH")
visibility = size - 10;

return visibility;
}

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9393
    • View Profile
Re: [DONE][Suggestion] Possibility to choose UFO size displayed in dogfights
« Reply #5 on: February 10, 2025, 12:51:22 pm »
3. Decoupled UFO blob size from UFO size

https://github.com/MeridianOXC/OpenXcom/commit/561ecc7b4537967e0a02ce2e167b84a03d70e7a1

UFO size is now used for textual display ONLY.
For graphical display and for calculations, ufo blobSize is used instead.

For visual blob display in dogfight UI, the blobSize can be between 0 and 7.
Values 5, 6 and 7 are new.

For non-visual calculation, the blobSize/ufoSize can be between 0 and 4, as before.
blobSizes 5, 6 and 7 are automatically treated as blobSize 4 for non-visual calculations.

Sample ruleset:

Code: [Select]
ufos:
  - type: STR_LARGE_SCOUT
    blobSize: 7   # default -1 = vanilla by size

If not specified, default is based on vanilla sizes.

Code: [Select]
int RuleUfo::getBlobSize() const
{
if (_blobSize > -1 && _blobSize < 8)
return _blobSize;

if (_size == "STR_VERY_SMALL")
return 0;
else if (_size == "STR_SMALL")
return 1;
else if (_size == "STR_MEDIUM_UC")
return 2;
else if (_size == "STR_LARGE")
return 3;
else if (_size == "STR_VERY_LARGE")
return 4;

return 4;
}

Related calculation/usage in dogfight:

Code: [Select]
_ufoBlobSize = _ufo->getRules()->getBlobSize();
_ufoSize = std::min(_ufoBlobSize, 4); // yes, maximum supported is 4, not a typo
« Last Edit: February 10, 2025, 12:53:37 pm by Meridian »

Offline Cooper

  • Colonel
  • ****
  • Posts: 176
  • Chryssalids are awesome
    • View Profile
Re: [DONE][Suggestion] Possibility to choose UFO size displayed in dogfights
« Reply #6 on: February 10, 2025, 03:22:01 pm »
This is so cool, thanks! Looking forward to see the blobSize: 7 in action!