OpenXcom Forum

OpenXcom => Suggestions => Topic started by: tkzv on December 11, 2017, 01:19:37 am

Title: UFO and TFTD in the single sequential campaign
Post by: tkzv on December 11, 2017, 01:19:37 am
Has anybody tried merging the two games in a single mod?

It would go something like this. Just a normal UFO game until you win at Cydonia, but then the game continues. Probably your funding is cut, and you spend several month doing nothing. Maybe all your Avengers are requisitioned. Maybe there's a timeskip a few days or weeks long (to travel to Mars and back).

And then Aquatoids start appearing.

You retain all your technologies, but cannot use most of them underwater. You cannot get more ellerium — whatever is transported from Mars isn't yours.

I know of Dr.Crowley's mod: https://openxcom.org/forum/index.php/topic,5811.0.html , which uses a similar idea, but it is TFTD-only, separate from UFO, starting in 2037.

P.S. The X-COM Files tries a parallel approach with Deep Ones as early as 1997. I asked about serial one.
Title: Re: UFO and TFTD in the single campaign
Post by: Warboy1982 on December 11, 2017, 02:12:14 am
this comes up all the time and the simple answer is "it can't work"
Title: Re: UFO and TFTD in the single campaign
Post by: Hobbes on December 11, 2017, 02:58:27 am
It's the Holy Grail of OpenXCom. Many have tried finding it, but all have failed in this quest.
Title: Re: UFO and TFTD in the single campaign
Post by: tkzv on December 11, 2017, 10:55:06 am
this comes up all the time and the simple answer is "it can't work"
It's the Holy Grail of OpenXCom. Many have tried finding it, but all have failed in this quest.
Any names or links to failed attempts? What made them fail? Other than the amount of work.
Title: Re: UFO and TFTD in the single campaign
Post by: Warboy1982 on December 11, 2017, 12:38:58 pm
simply put: they both follow the same arc, instead of one being the continuation of the other.
Title: Re: UFO and TFTD in the single campaign
Post by: Hobbes on December 11, 2017, 03:55:03 pm
Any names or links to failed attempts? What made them fail? Other than the amount of work.

Just search the forums and you'll find the discussions.
Title: Re: UFO and TFTD in the single campaign
Post by: tkzv on December 11, 2017, 07:44:13 pm
simply put: they both follow the same arc, instead of one being the continuation of the other.
What key featues distinguish the arc? Having to start from scratch? What else?
Title: Re: UFO and TFTD in the single campaign
Post by: The Reaver of Darkness on December 11, 2017, 11:27:07 pm
You'd have to drastically change the gameplay for a while, otherwise it's going to be a long 40 years before you get going again.

In the original storyline, X-Com was put on hold at some point and revived out of a sudden need in 2040. I'd guess that there was a time after the first war in which X-Com became a rapidly expanding international military service which could help explain where Barracuda technology comes from, and why X-Com already had an underwater base before the attacks began. If you wanted to feature that story in a game, it might make more sense to be a political strategy game similar to the Caesar series in which you gradually expand through keeping your people happy and appeasing other people, and you generate wealth through economic success and trade. Maybe you'd have the explicit goal of world peace while your major duties involve keeping positive ties with major nations and using those positive ties to gain access to goods and tools that can help you appease the other nations. You'd perhaps explore applications of alien technology to help people while also trying to prevent other nations from abusing it. Various nations would fight over the remaining elerium and you'd try to keep the peace, but in your economically weak position your best bet is probably to design the technology to enable spaceflight to Mars without using it, so that the Elerium mines can be started before everybody blows each other sky high over an infantile resource grab.
Title: Re: UFO and TFTD in the single campaign
Post by: Warboy1982 on December 12, 2017, 12:07:49 am
https://openxcom.org/forum/index.php/topic,3025.0.html
https://openxcom.org/forum/index.php/topic,1851.0.html
https://openxcom.org/forum/index.php/topic,372.0.html

This must rank up there with the most suggested ideas ever. :)

...and that was in 2012!

By arc, i mean in both games you start with a single base with only meager facilities, a handful of untrained rookies, a minimal science and engineering staff, no access to armour or advanced equipment, and all the funding nations supporting you.
generally speaking by the end of the game, none of these will still hold true.

they are for all intents and purposes, the same game with a different name.

but that's just the structure of the game, the governing rules add a whole other layer of dichotomy, for example:
UFO only allows bases on land, TFTD only allows them at sea.
UFOs shot down over the ocean in UFO disappear, USOs in TFTD disallow engagement over land.
The regions that govern scoring and the country borders are completely different between the two games.
The waypoint areas for UFOs and USOs are in completely different parts of the globe.
and so on...

the structure is too similar and the rules are too different.
Title: Re: UFO and TFTD in the single campaign
Post by: tkzv on December 12, 2017, 03:48:59 am
You'd have to drastically change the gameplay for a while, otherwise it's going to be a long 40 years before you get going again.
I said above. The signal is sent right after the victory and Aquatoids start attacking within weeks.

In the original storyline, X-Com was put on hold at some point and revived out of a sudden need in 2040. I'd guess that there was a time after the first war in which X-Com became a rapidly expanding international military service which could help explain where Barracuda technology comes from, and why X-Com already had an underwater base before the attacks began.
The manual says that X-COM was shoved aside and ended up becoming a salvage company searching for elerium in underwater UFO wrecks.

If you wanted to feature that story in a game, it might make more sense to be a political strategy game similar to the Caesar series in which you gradually expand through keeping your people happy and appeasing other people, and you generate wealth through economic success and trade. Maybe you'd have the explicit goal of world peace while your major duties involve keeping positive ties with major nations and using those positive ties to gain access to goods and tools that can help you appease the other nations. You'd perhaps explore applications of alien technology to help people while also trying to prevent other nations from abusing it. Various nations would fight over the remaining elerium and you'd try to keep the peace, but in your economically weak position your best bet is probably to design the technology to enable spaceflight to Mars without using it, so that the Elerium mines can be started before everybody blows each other sky high over an infantile resource grab.
No time for that — underwater aliens are attacking! There may be funding drop between the victory and first attacks.

Although, now that you mentioned it, I wonder if anybody tried implementing X-COM clone on Caesaria engine. There were rumours of stranger things back in 2000s :)



https://openxcom.org/forum/index.php/topic,3025.0.html
https://openxcom.org/forum/index.php/topic,1851.0.html
https://openxcom.org/forum/index.php/topic,372.0.html
Thanks.


By arc, i mean in both games you start with a single base with only meager facilities, a handful of untrained rookies, a minimal science and engineering staff, no access to armour or advanced equipment, and all the funding nations supporting you.
generally speaking by the end of the game, none of these will still hold true.
Correct, this would be a game with lots of trained people (which may change if funding is cut), many research and production facilities, but weapons and equipment inadequate for underwater missions.

they are for all intents and purposes, the same game with a different name.
Hence the desire to combine them :)

but that's just the structure of the game, the governing rules add a whole other layer of dichotomy,
Then some rules need to change :) The sum game needs to combine them somehow.
for example:
UFO only allows bases on land, TFTD only allows them at sea.
I never really understood why do they need deep underwater bases if their subs can fly. Let them be only on land, for example.
UFOs shot down over the ocean in UFO disappear, USOs in TFTD disallow engagement over land.
Let UFOs downed in water stay there a few days, until they disappear, like any other downed UFO. Another thing that irked me from the start :)
The regions that govern scoring and the country borders are completely different between the two games.
Since the second part follows right after the first, the countries are the same. Let each founding country have a big piece of sea as its territory. Guess, that would affect the 1st half of the game somewhat.
If the spheres of influence over the seas follow current political situation, that would give USA a lot of sea territories, wouldn't it?
The waypoint areas for UFOs and USOs are in completely different parts of the globe.
Is there a limit on numbers of waypoints? Can those sets coexist for different missions?

To sum it up: there is more work than I anticipated, namely reworking the globe. But people wanted this game right from the start. I'm going to find if anybody actually went beyond suggestions...
Title: Re: UFO and TFTD in the single campaign
Post by: The Reaver of Darkness on December 15, 2017, 03:05:13 pm
I said above. The signal is sent right after the victory and Aquatoids start attacking within weeks.
You could make the second war pick up immediately after the end of the first, but you'd have to break canon to do so. At that point, anything goes, you can make the game any way you want, since it's not really tied to canon anymore.
Title: Re: UFO and TFTD in the single campaign
Post by: tkzv on December 19, 2017, 11:32:02 am
You could make the second war pick up immediately after the end of the first, but you'd have to break canon to do so. At that point, anything goes, you can make the game any way you want, since it's not really tied to canon anymore.
The closer to the canon this stays, the better.

It should go something like this. Right from the start there's an option to research recovering UFOs shot down over the sea. This could be something like a helicopter that carries a boat with divers. Or maybe skip the intermediate stages and give X-COM a tilt-rotor seaplane. Seas are partitioned between funders like the land and recovering gives score.

There were discussions in other threads who and what should and should not survive a water crash landing. Long story short: there always should be armed aquanauts. Unlike the land crash sites, they last much longer.

After Cydonia there's a funding drop, but a new type of mission appears. Various countries are declassifying the locations of UFOs they shot down and X-COM is tasked with recovering them. This is where Aquatoids and Gillmen start appearing. Then come USO sightings, attacks on ships and so on.

The perfect game would be where X-COM is underprepared to each new challenge and barely manages to catch up.

P.S. A possible way to drive funding down: a lot of cheap missions that quickly expire and give penalty. The problem would be to keep the score negative, but not too low. And to keep doing this for a fixed number of months after the victory.

P.P.S. Possible missions after the victory: recovering UFOs shot down by various armies of the world and fighting people that want to keep the wreck. Or fighting living terror weapons that survived the crash and thrive in the wild. Cryssalids would die quickly, but if they keep infecting large wild animals at a steady rate, that might last long. Reapers would have no problems surviving. No idea about celatids and silacoids.

P.P.P.S. Interceptors should be able to shoot USOs with rockets in the air and possibly with torpedoes at low depth. Flying subs should carry torpedoes and maybe air-to-air rockets too.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: Solarius Scorch on December 19, 2017, 12:04:16 pm
If you seriously consider doing this, I suggest you start with a list of specific code changes that would be necessary for this. Then look for a coder willing to help - the viability of this depends heavily on how difficult it would be, and how vanilla-friendly.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: tkzv on December 19, 2017, 01:17:50 pm
If you seriously consider doing this, I suggest you start with a list of specific code changes that would be necessary for this. Then look for a coder willing to help - the viability of this depends heavily on how difficult it would be, and how vanilla-friendly.
Not serious yet. But yes, the list of what the engine can and cannot do will be the start.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: Meridian on December 21, 2017, 11:56:13 am
There are many approaches of how to merge the two together:
- from the simplest of just starting TFTD new game automatically after win at cydonia (which is nothing else than saving the user two or three clicks to do it manually)
- to a complete engine rewrite (and potentially completely new artwork)

First the idea needs to be formulated, then reviewed for feasibility, then compromises will inevitably be made... and then a lot of time will be required for both coding and modding.

In my humble opinion a "complete" merge is too much effort for little to no gain.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: darkestaxe on December 21, 2017, 01:34:51 pm
An order to make this idea viable I would look at a transition system, ie 'What should this give you in TFTD?' and 'When do you get it?' In a story sense, UFO stuff cannot actually be directly used in TFTD, and funding status isn't going to directly change over. We'd need transitional items and a way to redeem them at the appropriate time, a way to rehire your old soldiers and formula for what their stats would become, a similar system for converting and redeeming base facilities, and determining the number of starting bases you have.

TFTD was more difficult by design but we'd still need to jump start alien aggression, probably by having extra active alien missions at the start. Aliens should be more busy in the first months to match X-COM starting off with extra resources, for obvious balance reasons.

Title: Re: UFO and TFTD in the single sequential campaign
Post by: tkzv on December 27, 2017, 02:40:36 am
An order to make this idea viable I would look at a transition system,
I wrote a long and detailed answer with a thorough analysis of your suggestions, which took me 5 evenings. Then it was all lost to a browser glitch :(

I'll be short then. What you suggest is a way to transfer games between UFO and TFTD. The only advantage is that they can stay separate. But it would still require much modification of engine to implement redeeming. It also allows to skip the interim period, where X-COM would have nothing to do and new missions will need to be invented.

The most noticeable new idea is the ability to downsize and later to invite the trained operatives back. Adds some depth.

The easiest way to implement redeeming is through money. Either all objects on a certain list (Avenger, Ellerium...) are automatically sold after the victory, or they are no longer allowed in any missions and the player can do nothing but sell them. Selling bases would be a nice addition.

What I suggested is the single unbroken game, where the victory at Cydonia gives several months of quiet and then Aquatoids start appearing much earlier than 2040s. Some balance-breaking objects would be taken away (in line with the game lore), but X-COM still has the chance to retain much of its resources, if the player acts correctly.

'What should this give you in TFTD?' and 'When do you get it?' In a story sense, UFO stuff cannot actually be directly used in TFTD, and funding status isn't going to directly change over.
Yes, it can, if the pause is short enough. Funding will remain several months after the victory — global international organizations tend to be slow, especially if every representative needs to inform his superiors they need to change their budgets again :) After that funding has to be reduced somehow. I suggest a lot of cheap quickly-expiring missions, that would not drive X-COM to disbanding, but will keep the score negative. Or if the engine allows — just reduce the funding by 90% after the victory or 3 months after the victory. Or to 0 at victory and then increase it according to the month's score (but that would look to much like a game glitch) :)

TFTD was more difficult by design but we'd still need to jump start alien aggression, probably by having extra active alien missions at the start. Aliens should be more busy in the first months to match X-COM starting off with extra resources, for obvious balance reasons.
Maybe. I'm thinking about high number of missions and their high variability. Don't forget that X-COM would have to rearm itself for the new environment and that would require a lot of money.

Funding:
All countries are the same, but their control zones from the start include pieces of oceans. The funding was reduced after the victory, but something remains.

Bases and Base Facilities:
I see no justification for floating bases. Hyperwave decoders should still work fine. (Unless the official lore says why they can't. Does it?) If not, radars would still detect USOs above water, and a single sonar wouldn't see far underwater — they'd need a network of buoys, the control centre of which may just as well be far inland. Still, there should be a range limit for the network and some inconveniently located bases would have to be relocated. This is where selling facilities or bases would be handy.

Scientists, Engineers, Skyrangers, Intercepters, etc are all rentals.
You get them by paying a monthly wage/price in advance, and you get nothing for letting them go. That simple. The only question is how to add subs to the list. Right after Cydonia would be ugly. Triggered by a mission against Aquatoids or Gillmen?

Craft and HWPs:
Same as anything else in the stores. Some stuff is requisitioned by the Council after the victory, the rest remains. Let's also follow the official lore that alien alloys and ellerium slowly dissolve in seawater. There'd be limitations on what can go to underwater missions, but the rest will be usable.

Redeemable Cores:
Useful idea, but not here. But it gave me another idea. If all ellerium was requisitioned for expeditions to Mars, but X-COM is tasked with recovering old UFO wrecks, there may be a loophole that it can extract ellerium from any found weapons. It contradicts the short stories, though.


Soldiers: Prior soldiers would be rehire-able
Good idea. Downsize the bases, then rehire the veterans next year. Some may refuse to return. I doubt the engine can do that, can it?

E-115 would be redeemable at a 4 to 1 ratio once zyrbite research is complete.
If the interplanetary search for ellerium yields something quickly enough, ellerium would become purchasable. Guess, it has to be expensive for balance reasons.

There are many approaches of how to merge the two together:
- from the simplest of just starting TFTD new game automatically after win at cydonia (which is nothing else than saving the user two or three clicks to do it manually)
- to a complete engine rewrite (and potentially completely new artwork)

First the idea needs to be formulated, then reviewed for feasibility, then compromises will inevitably be made... and then a lot of time will be required for both coding and modding.

In my humble opinion a "complete" merge is too much effort for little to no gain.

Personally, I didn't like the starting premise of TFTD. So, let's not give X-COM a chance to stagnate.

What I'm talking about is a standard UFO playthrough with additions:
I see several variants requiring from no to significant modifications of the engine. I tried to compile the list of questions about the engine capabilities:
Here are the variants of the scenario:
Title: Re: UFO and TFTD in the single sequential campaign
Post by: Etaoin on August 27, 2018, 12:18:56 am
Apologies for the necropost, but I'm new here and didn't feel what I had to say warranted a new thread...

Firstly, a big thanks to everyone involved in making OpenXcom - I've been a fan of these games since they came out and consider them unmatched to this day in terms of strategy, atmosphere and difficulty. It's truly awesome to still be able to enjoy them today, cleanly rewritten and free of bugs - under Linux - and with lots of little enhancements. Nice work guys!

But I primarily registered here to reply to this thread, because as I've immersed myself yet again in the complex and challenging task of saving the earth from its benthic bane (yes, I'm on the nightlies - quite literally too), I cannot get it out of my head how insanely great it would be if both games could be combined into a new, third game, which included both land and sea X-Com bases and alien colonies, and all the different terrains, aliens and mission types provided. Personally, I couldn't care less about keeping the original timeline - in fact it would probably make more sense if it was positioned as a continuation of the storyline, or even a (partial) rewrite(!)*. Ruleset/AI would be TFTD. Weapons, craft and equipment included only where appropriate, and modified when appropriate. Troops dedicated to land or sea, but land/sea capability of weapons and craft adjusted (e.g. the Barracuda should be able to engage over land as well). Technology trees merged as far as possible (and sensible)**. Perhaps an entirely new endgame tree. Anything that doesn't fit, doesn't work, or creates too much complication: dropped*.

It's been said in this thread that this is the "holy grail" of OpenXcom, and that it is a topic often discussed in these forums, yet my search attempts only turned up this one remotely relevant discussion in the past year. If we all want it so bad, what efforts are going into making it happen? If none, what are the show-stoppers?

Etaoin

*) It's not gospel you know.
**) This sounds to me as the single most difficult task here?

P.S. Radical thought: no more throwing of things under water!
Title: Re: UFO and TFTD in the single sequential campaign
Post by: tkzv on October 02, 2018, 03:02:33 am
Apologies for the necropost,
Not a problem here, it seems :)

how insanely great it would be if both games could be combined into a new, third game, which included both land and sea X-Com bases and alien colonies, and all the different terrains, aliens and mission types provided.
Thanks for your kind words.

Anyway, after postponing this again and again, I decided to start. But I've got questions to specialists.

First step would be recovering of crashed UFOs from the sea in 1999. (Assuming all aliens drowned.) This requires:

1. A globe where sea is a separate terrain.

2. A terrain that kills all sectoids (for example).

Part 1 is tedious, but straightforward. Decode UFO/GEODATA/WORLD.DAT and  TFTD/GEODATA/WORLD.DAT, identify overlapping polygons, correct them, add polygons from TFTD/GEODATA/WORLD.DAT to UFO/GEODATA/WORLD.DAT. Maybe use the globe from Terrain Pack ( https://openxcom.mod.io/terrain-pack ) instead of UFO/GEODATA/WORLD.DAT. The Python script is ready, but doesn't work yet :)

I still don't understand some things about terrains:
1. Is there a limit to the number of terrains? Can I simply continue numbering TFTD terrains after 21 (for Terrain Pack)?
2. How are crashed UFO maps are generated? At what point do exploding engines kill part of the crew? How do I kill all UFO crew for underwater terrains?
Title: Re: UFO and TFTD in the single sequential campaign
Post by: Solarius Scorch on October 02, 2018, 11:35:44 am
I think it's also a balance issue: shoot down a UFO over the ocean, recover all tech and corpses at no risk.
There are no practical limits to number of terrains. I have dozens in XCF.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: tkzv on October 02, 2018, 05:48:29 pm
There are no practical limits to number of terrains. I have dozens in XCF.
In the globe_XCOMFILES.rul you have several terrains for each non-negative ID except 12. How are they picked? Randomly according to weight?
What is the purpose of negative IDs? Only for mission maps?

I think it's also a balance issue: shoot down a UFO over the ocean, recover all tech and corpses at no risk.
I want to partially destroy the equipment and eventually add sea monsters. The question is: how to kill aliens and destroy their ship?

(Note to self: https://openxcom.org/forum/index.php/topic,6201.0.html )
Title: Re: UFO and TFTD in the single sequential campaign
Post by: Solarius Scorch on October 02, 2018, 07:57:47 pm
In the globe_XCOMFILES.rul you have several terrains for each non-negative ID except 12. How are they picked? Randomly according to weight?

Yes, exactly.

What is the purpose of negative IDs? Only for mission maps?

It doesn't matter if the number is negative or positive, it's simply a convention of discerning between globe texture terrains and deployment-specific terrains. This is in accordance with vanilla, where terror missions are -1.

I want to partially destroy the equipment and eventually add sea monsters. The question is: how to kill aliens and destroy their ship?

Umm... With blaster bombs? :D
But seriously, I don't understand your question. Is this about ship crashes? If yes, then it's hardcoded, sorry.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: tkzv on October 02, 2018, 11:08:32 pm
But seriously, I don't understand your question. Is this about ship crashes? If yes, then it's hardcoded, sorry.
Yes, when the ship crashes, all aliens die and the water slowly destroys everything of value. There should be several stages leaving less and less. Is it possible to replace a crashed UFO mission with another crashed UFO mission else when it expires? Thus leaving less and less with each iteration.

And speaking of replacing. Is it possible to replace aliens? In underwater missions in XCF there are tables of what armour replaces what. Perhaps, more importantly, in TFTD some aliens replace some other aliens between a crashed terror ship and a terror mission. Is it possible to replace aliens like that in a mod?

Or what happens with dogs in underwater missions in XCF?


Meanwhile, WORLD.DAT from UFO and TFTD proved mostly incompatible — there's a total of 6 common vertices in those maps:
(0, 0) — 4 in UFO, 8 in TFTD.
(0, 2806) — 4 in each
(0, 2871) — 4 in each
(0, 56) — 4 in each
(0, 82) — 8 in each
(5, 0) — 8 in UFO, 4 in TFTD
I'll try to merge them anyway...
Title: Re: UFO and TFTD in the single sequential campaign
Post by: Solarius Scorch on October 03, 2018, 01:42:14 am
Sorry, armour transformations only work on X-Com units, not aliens.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: tkzv on October 03, 2018, 03:01:28 am
Sorry, armour transformations only work on X-Com units, not aliens.
What about drowning dogs? Same problem?

Anyway, I figured a quick and dirty way to add oceans. Just adding the required "rectangles" at the start of WORLD.DAT, their descriptions to globe.textures and textures to extraSprites proved enough. The rest of the world is drawn over this new terrain. 160x160 rectangles seem large enough to generate few facets (18x9=162), but small enough to avoid visible separation of land from the sea.
Tested with Terrain Pack. Added the terrain as #25, because 0-24 already have textures in TEXTURES.PNG.
1. Add 32x96 bar of tetures to the right side of Terrain Pack/Resources/Geoscape/TEXTURES.PNG
2. Change TEXTURE.DAT description in Terrain Pack/Ruleset/Terrain_Pack_Sprites.rul accordingly (under extraSprites):
Code: [Select]
  - type: TEXTURE.DAT
    width: 832
    height: 96
    subX: 32
    subY: 32
    files:
      0: Resources/Geoscape/TEXTURES.PNG
3. Add to globe.textures section of Terrain Pack/Ruleset/Terrain_Pack_Geoscape.rul:
Code: [Select]
    - id: 25
      terrain:
        - name: OCEAN
          weight: 10
4. Run the following Python script to add 18x9 "rectangles", 160x160 each:
Code: [Select]
#!/usr/bin/python3
from numpy import reshape, set_printoptions, array, frombuffer, int16, concatenate

fi = '../.local/share/openxcom/mods/Terrain Pack/Resources/Geoscape/IMPROVEDGLOBE.DAT.old'
fo = '../.local/share/openxcom/mods/Terrain Pack/Resources/Geoscape/IMPROVEDGLOBE.DAT'
set_printoptions( threshold=1000000 )

bAri = open(fi,'rb').read()
ari = reshape( frombuffer( bAri, dtype=int16 ), (-1, 10) )
add = []
step = 160
for lat in range(-720, 720, step):
    for lon in range(0, 2880, step):
        add += [[lon       % 2880, lat,
                (lon+step) % 2880, lat,
                (lon+step) % 2880, lat+step,
                 lon       % 2880, lat+step, 25, 0 ]]
add = array( add, int16 )
ari = concatenate( (add, ari) )
f = open( fo, 'wb' ).write( ari.tobytes() )

So, any large body of water now allows landing of alien craft. Except that it should crash the game at this point. :)

Next step: either figuring a way to kill aliens in water, or making up rules to recover drowned craft with aliens still alive.

I wonder what can scripts do about this? I've got an event — start of a Battlescape mission on a specific terrain. I've got a value — time elapsed after the crash. I need to alter the Battlescape map accordingly.


Update: Merged the globes and lists of terrain. Attached the mod as "merged_terrains.7z".

Here are the scripts:
Merging globes:
Code: [Select]
from numpy import reshape, set_printoptions, array, int16, concatenate, fromfile

f1 = '../.local/share/openxcom/UFO/GEODATA/WORLD.DAT'
f2 = '../.local/share/openxcom/TFTD/GEODATA/WORLD.DAT'
fo = 'newworld.dat'
set_printoptions( threshold=1000000 )

ar1 = fromfile( f1, dtype=int16 )
ar2 = fromfile( f2, dtype=int16 )
ar1 = reshape( ar1, (-1, 10) )
ar2 = reshape( ar2, (-1, 10) )
for e in ar2:
    e[8] += 13
aro = concatenate( (ar2, ar1) )
open( fo, 'wb' ).write( aro.tobytes() )

Merging textures, TFTD textures are converted to UFO palette.
Code: [Select]
from numpy import reshape, set_printoptions, array, frombuffer, int16, concatenate, fromfile, uint8, zeros, dot, argmin
from PIL import Image

def yccs( a1 ):
    return dot( array( ((0.299,    0.587,    0.114   ),
                        (0.168736, 0.331264, 0.5     ),
                        (0.5,      0.418688, 0.081312)) ), a1 )


f1 = '../.local/share/openxcom/UFO/GEOGRAPH/TEXTURE.DAT'
f2 = '../.local/share/openxcom/TFTD/GEOGRAPH/TEXTURE.DAT'
p1 = '../.local/share/openxcom/UFO/GEODATA/PALETTES.DAT'
p2 = '../.local/share/openxcom/TFTD/GEODATA/PALETTES.DAT'
fo = 'merged.png'
set_printoptions( threshold=1000000 )

ar1 =  fromfile( f1, dtype=uint8 )
pal1 = fromfile( p1, dtype=uint8 )
pal1 *= 4
pic1 = Image.frombuffer( 'P', (32, 13*32*3), ar1, 'raw', 'P', 0, 1 )
pic1.putpalette(pal1[0:768])

ar2 =  fromfile( f2, dtype=uint8 )
pal2 = fromfile( p2, dtype=uint8 )
pal2 *= 4
pic2 = Image.frombuffer( 'P', (32, 13*32*3), ar2, 'raw', 'P', 0, 1 )
pic2.putpalette(pal2[0:768])

cmpM = zeros( (256, 256), float )
palj1, palj2 = zeros( (256,3), float ), zeros( (256,3), float )
for c in range(0, 256):
    offs = c*3
    palj1[c] = yccs( pic1.getpalette()[offs:offs+3] )
    palj2[c] = yccs( pic2.getpalette()[offs:offs+3] )
for c1 in range(0, 256): # 768, 3):
    for c2 in range(0, 256): # 768, 3):
        cmpM[c2, c1] = sum( abs( palj2[c2] - palj1[c1] ) )
newPal  = zeros( 768, uint8 )
for c2 in range(0, 256):
    c1 = argmin( cmpM[c2] )
    newPal[c2*3:c2*3+3] = pic1.getpalette()[c1*3:c1*3+3]
pic2.putpalette(newPal)
picp = pic2.convert( mode = 'RGB' ).quantize( colors=256, palette=pic1 )

picc = Image.new( 'P', (32*13*2, 32*3) )
picc.putpalette(pal1[0:768])
for frame in range(13):
    for z in range(3):
        block = pic1.crop( (0, frame*32+z*32*13, 32, frame*32+32+z*32*13) )
        picc.paste( block, ( frame*32, z*32 ) )
        block = picp.crop( (0, frame*32+z*32*13, 32, frame*32+32+z*32*13) )
        picc.paste( block, ( 32*13+frame*32, z*32 ) )
picc.show()
picc.save( fo )

The seas look good in the daylight: see merged1.png
Not so good at night: see merged2.png, merged3.png, merged4.png

Can anybody explain how does day-night lighting work? Why do light blue colours become yellow in the shadow?
Title: Re: UFO and TFTD in the single sequential campaign
Post by: Yankes on October 08, 2018, 05:02:40 pm
Palette, original UFO used 32 values for ocean and your graphic probably not.
https://www.ufopaedia.org/index.php/File:1_GeoScapePal.Png
This is hardcoded:
https://github.com/Yankes/OpenXcom/blob/OpenXcomExtended/src/Geoscape/Globe.cpp#L203
Title: Re: UFO and TFTD in the single sequential campaign
Post by: tkzv on October 08, 2018, 11:32:56 pm
Palette, original UFO used 32 values for ocean and your graphic probably not.
https://www.ufopaedia.org/index.php/File:1_GeoScapePal.Png
This is hardcoded:
https://github.com/Yankes/OpenXcom/blob/OpenXcomExtended/src/Geoscape/Globe.cpp#L203
Thanks for the link to the source.

As far as I can tell, the problematic textures are shaded the same way as the land textures. Land textures seem to use colours in groups of 16. That allows simple shifting to darker shades. But the new ocean textures use mainly blue colours 80-89 and 245-251, which are shifted to 90-95 and 252-255, which are yellow. Is it possible to change this palette with a YAML file?

The code has the following constants:
Globe::OCEAN_COLOR = Palette::blockOffset(12);
Globe::COUNTRY_LABEL_COLOR = 239;
Globe::LINE_COLOR = 162;
Globe::CITY_LABEL_COLOR = 138;
Globe::BASE_LABEL_COLOR = 133;

Is Globe::OCEAN_COLOR = 12*16 = 152? Is it possible to redefine the palette for 152-183 range and use it for textures? Will it still be shaded by ocean rather than land rule? (Even if yes, it would be OK.)
Title: Re: UFO and TFTD in the single sequential campaign
Post by: The Reaver of Darkness on October 09, 2018, 08:54:10 pm
I am very interested to see how this turns out because I want to use the results for adding land to TFTD.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: Yankes on October 09, 2018, 09:21:25 pm
Thanks for the link to the source.

As far as I can tell, the problematic textures are shaded the same way as the land textures. Land textures seem to use colours in groups of 16. That allows simple shifting to darker shades. But the new ocean textures use mainly blue colours 80-89 and 245-251, which are shifted to 90-95 and 252-255, which are yellow. Is it possible to change this palette with a YAML file?

The code has the following constants:
Globe::OCEAN_COLOR = Palette::blockOffset(12);
Globe::COUNTRY_LABEL_COLOR = 239;
Globe::LINE_COLOR = 162;
Globe::CITY_LABEL_COLOR = 138;
Globe::BASE_LABEL_COLOR = 133;

Is Globe::OCEAN_COLOR = 12*16 = 152? Is it possible to redefine the palette for 152-183 range and use it for textures? Will it still be shaded by ocean rather than land rule? (Even if yes, it would be OK.)
Ok, I see when Warboy or SupSuper add support for TFTD they add loading of this value:
https://github.com/SupSuper/OpenXcom/blob/13049d617fe762b91893faaf7c14ddefa49e2f1d/src/Mod/RuleGlobe.cpp#L138
This mean if you change `oceanPalette` in `globe` then you can alter what color is used.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: tkzv on October 10, 2018, 02:09:39 am
Ok, I see when Warboy or SupSuper add support for TFTD they add loading of this value:
https://github.com/SupSuper/OpenXcom/blob/13049d617fe762b91893faaf7c14ddefa49e2f1d/src/Mod/RuleGlobe.cpp#L138
This mean if you change `oceanPalette` in `globe` then you can alter what color is used.
Thanks. I see that it also allows changing "countryColor", "cityColor", "baseColor" and "lineColor". How is it written in the YAML file?
Code: [Select]
globe
  data: path/to/new/WORLD.DAT
  polygons: [...]
  polylines: [...]
  textures:
    - id: 21
    - delete: 10
  countryColor: 10
  cityColor: 15
  baseColor: 25
  lineColor: 120
  oceanPalette: 180

But I was asking how to change the whole Geoscape palette.
Here is something to replace the whole GEODATA/PALETTES.DAT: https://github.com/SupSuper/OpenXcom/blob/0854dec7da01a14503f750aecaf6c624df33859a/src/Mod/Mod.cpp#L2508
Here is something to read palettes from *.rul files:
https://github.com/SupSuper/OpenXcom/blob/0854dec7da01a14503f750aecaf6c624df33859a/src/Mod/Mod.cpp#L591
https://github.com/SupSuper/OpenXcom/blob/0854dec7da01a14503f750aecaf6c624df33859a/src/Mod/Mod.cpp#L602
But what is the syntax? I can't quite figure it from the C++ code.

I am very interested to see how this turns out because I want to use the results for adding land to TFTD.
I can try it when I have time. This weekend, probably. Just swap "UFO" and "TFTD" in the paths for the 2nd script.

I still don't understand how exactly the shade is drawn. Does the engine check each pixel of the globe if it's in "ocean palette" and change its colour accordingly?


P.S. Interesting side effect. In TFTD the combined globe allows placing bases on the dry land. Considering that TFTD prohibited bases over some parts of oceans, and that UFO shouldn't build in oceans at all, it should be possible to limit that somehow. I'll need to investigate further.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: Yankes on October 10, 2018, 10:47:55 pm
Thanks. I see that it also allows changing "countryColor", "cityColor", "baseColor" and "lineColor". How is it written in the YAML file?


best look at TFTD ruleset that did that, overall as I said before: "`oceanPalette` in `globe`"
This mean
Code: [Select]
globe
  oceanPalette: 160

But I was asking how to change the whole Geoscape palette.
Here is something to replace the whole GEODATA/PALETTES.DAT: https://github.com/SupSuper/OpenXcom/blob/0854dec7da01a14503f750aecaf6c624df33859a/src/Mod/Mod.cpp#L2508
Here is something to read palettes from *.rul files:
https://github.com/SupSuper/OpenXcom/blob/0854dec7da01a14503f750aecaf6c624df33859a/src/Mod/Mod.cpp#L591
https://github.com/SupSuper/OpenXcom/blob/0854dec7da01a14503f750aecaf6c624df33859a/src/Mod/Mod.cpp#L602
But what is the syntax? I can't quite figure it from the C++ code.
 I can try it when I have time. This weekend, probably. Just swap "UFO" and "TFTD" in the paths for the 2nd script.
I do not mess with palettes swapig I do not recall where is exacly and how loaded. This function you link aren't directly responsible for loading palettes, only for internal use to copy palettes to other surfaces.


I still don't understand how exactly the shade is drawn. Does the engine check each pixel of the globe if it's in "ocean palette" and change its colour accordingly?

Exactly, this color can be on texture and it will be changed too. This is unused in UFO where sea ice texture have colors from ocean.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: The Reaver of Darkness on October 10, 2018, 11:27:04 pm
But I was asking how to change the whole Geoscape palette.
You don't want to change the palette. You want to change all of the incorrect ocean indexes to match the correct position on the palette. If you change the palette, you might fix the ocean but you'll break the images in other parts of the game which use the same colors.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: tkzv on October 11, 2018, 02:02:27 pm
You don't want to change the palette. You want to change all of the incorrect ocean indexes to match the correct position on the palette. If you change the palette, you might fix the ocean but you'll break the images in other parts of the game which use the same colors.
Moving ocean colour definitions isn't very useful if palettes don't change. Of course, changing palettes, will require changing textures accordingly, and the work amount may avalanche. I wanted to avoid that, but I already started with the 2nd script.

Geoscape palette is only used for viewing the globe. As long as I don't touch interface colours, change textures and remember to change city/border/etc colours, everything will stay fine.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: Meridian on October 11, 2018, 02:40:22 pm
Geoscape palette is only used for viewing the globe.

Geoscape palette is also used for anything related to geoscape:
- dogfights
- geoscape GUIs and popups
- some Ufopedia articles
- and even some non-geoscape GUIs, for example Debriefing GUI, etc.

I would not recommend any non-cosmetic changes to geoscape palette... but if you want, you can change it completely in OXCE using custom palettes: https://openxcom.org/forum/index.php/topic,4187.msg88361.html#msg88361

Example:

Code: [Select]
customPalettes:
  - type: PAL_GEOSCAPE_NEW
    target: PAL_GEOSCAPE
    file: Resources/Palettes/test.pal       # JASC-PAL format, all 256 colors are mandatory
Title: Re: UFO and TFTD in the single sequential campaign
Post by: tkzv on October 12, 2018, 01:06:47 am
Geoscape palette is also used for anything related to geoscape:
- dogfights
- geoscape GUIs and popups
- some Ufopedia articles
- and even some non-geoscape GUIs, for example Debriefing GUI, etc.

I would not recommend any non-cosmetic changes to geoscape palette... but if you want, you can change it completely in OXCE using custom palettes: https://openxcom.org/forum/index.php/topic,4187.msg88361.html#msg88361

Example:

Code: [Select]
customPalettes:
  - type: PAL_GEOSCAPE_NEW
    target: PAL_GEOSCAPE
    file: Resources/Palettes/test.pal       # JASC-PAL format, all 256 colors are mandatory
Thanks! I was asking about just that.

The R-G-B colour components in PALETTE.DAT are in the range 0-63 and are multiplied by 4 for displaying. Do I understand correctly that palettes in the "palette" tag or JACS-PAL file should be in the range 0-255 and are not multiplied?

If I specify the palette for PAL_GEOSCAPE, will it be used for Ufopedia and debriefing? Or did you separate them?
Title: Re: UFO and TFTD in the single sequential campaign
Post by: Meridian on October 12, 2018, 09:11:07 am
Yes 0-255 and are not multiplied.
It will be used on all places as before.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: SupSuper on January 10, 2019, 01:33:02 am
You can fit TFTD textures into the UFO palette by reusing the (now useless) flat ocean with some TFTD blues and remapping the new textures accordingly:

(https://i.imgur.com/DdtdMbh.png)

Now you get day-night shading, just with an unfortunate side-effect of the "holes" looking even more obvious (since the old "flat shading" is leaking through):

(https://i.imgur.com/03ZNFrh.png)

Only feasible solution would be hiding all the holes or disabling "flat shading" entirely.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: luke83 on January 10, 2019, 03:44:56 am
Hey, thats my pallet ;) i almost have my globe working (except for that same issue you had with the grey overlay in the daylight, night time displays corretly)  :P
Title: Re: UFO and TFTD in the single sequential campaign
Post by: The Reaver of Darkness on January 10, 2019, 10:35:56 am
The holes are caused by some shore regions using color #5. If you remap the shore regions to use color #12 instead, you would solve the issue. If you map them to closest match, it shouldn't have any terrain scars in the water--I think.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: luke83 on January 10, 2019, 11:46:06 am
Just tracking the last few errors in my globe now, just need that bug fix :)
Title: Re: UFO and TFTD in the single sequential campaign
Post by: The Reaver of Darkness on January 10, 2019, 01:08:19 pm
just need that bug fix :)
You need to have the ocean textures from TFTD, like SupSuper has going. Then you just have to match them all up with the UFO textures so there's no holes, like he said.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: luke83 on January 10, 2019, 01:11:04 pm
The textures are used, they are  hidden under that Grey , looks like the blue is ignored but the numbers i placed on the snipped below still show through.

It looks like the game engine ignores any colour you place in that section of the Pallet as if i change those textures to something without Blue, it works correctly, i assume that is the bug SupSuper found.

As for holes, i dont think my map has any left on it ( i fixed them all) but my globe is no good for the majority of OXC, you will need to use Supsupers version for a Vanilla Earth.

Title: Re: UFO and TFTD in the single sequential campaign
Post by: SupSuper on January 11, 2019, 11:26:31 am
The holes are caused by some shore regions using color #5. If you remap the shore regions to use color #12 instead, you would solve the issue. If you map them to closest match, it shouldn't have any terrain scars in the water--I think.
It's a limitation of the globe shader. It doesn't actually check if it's shading a polygon, it just uses the color to decide if it's land (use 16-color shading) or ocean (use 32-color shading). So if polygons use ocean colors, bad stuff happens.
I tried moving the ocean color to an unused zone but that messed up the "flat" coloring. So I've just added an option to disable the 32-color shading via "oceanShading", will have to wait for OXCE to merge.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: Yankes on January 11, 2019, 10:06:58 pm
Easier solution would be change `Uint8 Globe::OCEAN_COLOR` to `Uint16 Globe::OCEAN_COLOR`, with this you could use values greater than`256` to disable it completely.

Btw using only color of pixel is feature not limitation. I deliberately did that to make ice blend with rest of sea.
Title: Re: UFO and TFTD in the single sequential campaign
Post by: richardhead on February 14, 2019, 01:17:18 am
I studied programming briefly in the early 90s. So my knowledge is limited to CoBOL, RPG, pascal and basic. I'd like to try the extended version, but it's sounds a little to complicated for my old ass to implement. Anyhow, it seams a good place to start, creatively, would be to design a totally brand new game with all the changes you'd like to see, then work backwards from there.  Some simple logic flaws always bugged me, like, if you are chasing an alien sub and it touches down, you can't attack it? What is it about being on the sea-bed that makes it immune to sonic oscillators? When aliens attack an underwater base, why dot just breach an exterior wall and watch the puny humans all drown? The "aquatic" aliens are obviously "amphibious" aliens because I don't see them wearing water-filled SCBAs when they are on land. I think I will do this and start a new thread about it. XCOM3 : Total Earth Defense. Maybe some actual modders who know what their doing can glean some ideas from it.