OpenXcom Forum

Modding => OpenXcom Extended => Topic started by: greenscarf on September 10, 2019, 04:40:49 pm

Title: How underwater bullet trajectory works?
Post by: greenscarf on September 10, 2019, 04:40:49 pm
In TFTD, projectiles that are fired underwater leaves traces of bubble, or bullet trajectory (couldn't figure out the exact name to call it). I am wondering which part of the ruleset causes it. Also, I'd like to know if the 'trajectory' can be implemented on surface shooting/ xcom 1. I think it would be a great missile smoke trails.
Title: Re: How underwater bullet trajectory works?
Post by: wcho035 on September 10, 2019, 05:19:56 pm
vaporColor    The color offset (0-15) to use for the vapor trail.    -1
vaporDensity    The vapor cloud density (number of particles) for the vapor trail.    0
vaporProbability    The vapor cloud probability (0-100%) for the vapor trail.
Title: Re: How underwater bullet trajectory works?
Post by: greenscarf on September 10, 2019, 06:57:27 pm
Thanks for your information. Also, would there be a way to implement the vapor into xcom 1?
Title: Re: How underwater bullet trajectory works?
Post by: The Martian on September 10, 2019, 07:50:09 pm
would there be a way to implement the vapor into xcom 1?
I've been wondering about that as well.
Title: Re: How underwater bullet trajectory works?
Post by: wcho035 on September 11, 2019, 09:09:20 pm
I have been experimenting with this at the moment, the game keep crashing.

Okay, here is my research so far, after a few consultation.

The bubble trail will work and replace bulletsprite only at depth greater than zero, so in your terrain rul, you need to have depth greater than zero.

From the TFTD var file you need to copy over the transparencyLUTs to the xcom var file.

I have attempted to implement this on my Sonic weapons, with

vaporColor    
vaporDensity    
vaporProbability

Unfortunately, there is where the crash starts.  Still awaiting consultation from the others. I will post more.. later when I have more replies.
Title: Re: How underwater bullet trajectory works?
Post by: wcho035 on September 12, 2019, 08:57:44 am
I have been told that’s its sound issues that’s the cause of the crash, yet my code for my sonic weapon works perfectly on the land. All the firing and hit sounds.

Question is, does the weapon uses a different firing sound underwater? If that is the case, is it in the Var. ruls from TFTD which handles all the sounds? Oh well, I will experiment this tonight.
Title: Re: How underwater bullet trajectory works?
Post by: Meridian on September 12, 2019, 09:54:45 am
Just look at the log file, if it says something about missing sounds, then it is missing sounds.

Most likely however it is missing transparencyLUTs, which are not moddable yet.
Title: Re: How underwater bullet trajectory works?
Post by: Warboy1982 on September 12, 2019, 01:45:18 pm
transparencyLUTs are moddable, the problem is he's setting the depth value greater than zero but doesn't have a battle2.cat to pull the audio from (that's my take on it anyway)
Title: Re: How underwater bullet trajectory works?
Post by: wcho035 on September 12, 2019, 03:45:27 pm
Okay, here are the error logs.

[12-09-2019_22-43-29]   [FATAL]   A fatal error has occurred: Segmentation fault.
[12-09-2019_22-43-29]   [FATAL]   0x588e80 OpenXcom::CrossPlatform::stackTrace(void*)
[12-09-2019_22-43-29]   [FATAL]   0x589cf0 OpenXcom::CrossPlatform::crashDump(void*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
[12-09-2019_22-43-29]   [FATAL]   0x41e830 signalLogger(int)
[12-09-2019_22-43-29]   [FATAL]   0x91aa70 OpenXcom::UfopaediaStartState::think()
[12-09-2019_22-43-29]   [FATAL]   0x7ffa42230ef0 _C_specific_handler
[12-09-2019_22-43-29]   [FATAL]   0x7ffa42244b50 _chkstk
[12-09-2019_22-43-29]   [FATAL]   0x7ffa421bbcc0 RtlWalkFrameChain
[12-09-2019_22-43-29]   [FATAL]   0x7ffa42243b70 KiUserExceptionDispatcher
[12-09-2019_22-43-29]   [FATAL]   0x538680 OpenXcom::Map::drawTerrain(OpenXcom::Surface*)
[12-09-2019_22-43-29]   [FATAL]   0x658d30 OpenXcom::Surface::blit(SDL_Surface*)
[12-09-2019_22-43-29]   [FATAL]   0x657100 OpenXcom::State::blit()
[12-09-2019_22-43-29]   [FATAL]   0x5a1770 OpenXcom::Game::run()
[12-09-2019_22-43-29]   [FATAL]   0x41e990 SDL_main
[12-09-2019_22-43-29]   [FATAL]   0x91c5a0 console_main
[12-09-2019_22-43-29]   [FATAL]   0x91c6c0 WinMain
[12-09-2019_22-43-29]   [FATAL]   ??
[12-09-2019_22-43-29]   [FATAL]   ??
[12-09-2019_22-43-29]   [FATAL]   0x7ffa411b1fd0 BaseThreadInitThunk
[12-09-2019_22-43-29]   [FATAL]   0x7ffa4220ef90 RtlUserThreadStart
[12-09-2019_22-43-37]   [FATAL]   OpenXcom has crashed: Segmentation fault.
Title: Re: How underwater bullet trajectory works?
Post by: wcho035 on September 12, 2019, 03:58:15 pm
For the sake of testing. I have copy the Sample.cat from TFTD sound folder to UFO Sound folder of and renamed it as Sample4.cat

Here are my var.rul
startingTime:
  second: 0
  minute: 0
  hour: 12
  weekday: 6
  day: 1
  month: 1
  year: 1999
costEngineer: 25000
costScientist: 30000
timePersonnel: 72
initialFunding: 6000
disableUnderwaterSounds: true
alienFuel: [STR_ELERIUM_115, 50]
fontName: Font.dat
#soundDefs:
#  - type: BATTLE2.CAT
#    file: SAMPLE4.CAT
#    soundRanges:
#      - [0, 47]
#      - [99, 117]
#    sounds: [48]
#constants: #done
#  - doorSound: 47
#  - slidingDoorSound: 46
#  - slidingDoorClose: -1
#  - smallExplosion: 30
#  - largeExplosion: 29
#  - itemDrop: 44
#  - itemThrow: 42
#  - itemReload: 45
#  - walkOffset: 0
#  - flyingSound: 66
#  - buttonPress: 0
#  - windowPopup: [1, 1, 1]
#  - ufoFire: 5
#  - ufoHit: 4
#  - ufoExplode: 3
#  - ufoCrash: 2
#  - interceptorHit: 2
#  - interceptorExplode: 2
#  - explosionOffset: 8
#  - smokeOffset: 56
#  - underwaterSmokeOffset: 8
#  - basescapeCursor: 42
#  - graphsCursor: 144
#  - goodDebriefingMusic: GMDEBGOO
#  - badDebriefingMusic: GMDEBPOR
transparencyLUTs: #done
  - colors:
     - [  8,  8, 12, 2 ] # "white"
     - [ 16,  8,  0, 2 ] # orange
     - [  0, 12, 12, 2 ] # cyan
     - [  4, 16,  4, 2 ] # green

For my item.rul I have

  - type: STR_BLASTA_CANNON
    size: 0.3
    costBuy: 1
    costSell: 171600
    weight: 8
    bigSprite: 570
    floorSprite: 570
    handSprite: 381
    bulletSprite: 8
    hitAnimation: 150
    fireSound: 111
    hitSound: 112
    power: 130
    damageType: 0
    accuracySnap: 80
    accuracyAimed: 120
    tuAimed: 70
    tuSnap: 50
    clipSize: -1
    battleType: 1
    twoHanded: true
    invWidth: 2
    invHeight: 3
    recoveryPoints: 5
    armor: 50
    vaporColor: 3
    vaporDensity: 30
    vaporProbability: 100

extraSounds:
  - type: BATTLE.CAT
    files:
      111: Resources/Sounds/Fire.wav
      112: Resources/Sounds/sonichit.wav
  - type: BATTLE2.CAT
    files:
      111: Resources/Sounds/Fire.wav
      112: Resources/Sounds/sonichit.wav

It still crash. So, I must be missing something.
The game crash exactly when the bubble was about to be drawn. I can hear the hit sound, but not the fireSound in the underwater map.
Title: Re: How underwater bullet trajectory works?
Post by: Meridian on September 12, 2019, 04:04:15 pm
transparencyLUTs are moddable, the problem is he's setting the depth value greater than zero but doesn't have a battle2.cat to pull the audio from (that's my take on it anyway)

As discussed:
1. they are supposed to be moddable, but there's a bug which makes them not moddable... fixed today
2. currently only master mods can mod them... discussion in progress

Also:
3. currently only TFTD-based mods support them... because the LUTs are created only from the LBM palette files... so UFO-based hybrid mods won't have LUTs calculated even if defined
4. (OXCE only) even if point 3 is implemented, there can still be only one LUT per depth... i.e. can't have multiple LUTs for OXCE custom palettes

In other words... it's not working for UFO-based mods... it can be implemented (see screenshot), but it won't support all OXCE palette features.

@wcho035: is this a serious feature you're missing, or are you just playing around and don't really need it?
Title: Re: How underwater bullet trajectory works?
Post by: wcho035 on September 12, 2019, 04:21:29 pm
Hi Meridian, this is a feature I love to (or must) have with my underwater weapons. Even Luke could not get it to work, if there is a way to get it working. I am sure he and not to mention to me, I would be very grateful.

"2. currently only master mods can mod them... discussion in progress"

"(OXCE only) even if point 3 is implemented, there can still be only one LUT per depth... i.e. can't have multiple LUTs for OXCE custom palettes"

Not 100% what they means, but I am happy to find away to make it happen. I am not picky, just one vaporcolor is good enough for me.

If possible, I would like to keep disableUnderwaterSounds: true and let the vapor trail sound work in the depth. AKA no need for Battlecat2, because if I disableUnderwaterSounds: false, this will bring up other headaches.. 
Title: Re: How underwater bullet trajectory works?
Post by: Meridian on September 12, 2019, 06:30:52 pm
Hi Meridian, this is a feature I love to (or must) have with my underwater weapons. Even Luke could not get it to work, if there is a way to get it working. I am sure he and not to mention to me, I would be very grateful.

Test mod attached as zip.

Test build: https://lxnt.wtf/oxem/builds//Extended/Extended-5.6.3-ecaa78032-2019-09-12-win64.7z
Title: Re: How underwater bullet trajectory works?
Post by: wcho035 on September 12, 2019, 07:33:13 pm
Hi Meridian, I want to thank you very much for the new code, but this time, it did not work as plan. I have included the error logs. I have coded my ruls to the exact sample you send me. I tested only on underwater maps. The surface maps are okay but no vapor trails are drawn. The crash is the same, just when the vapor trail was about to be shown, it crashed,

[13-09-2019_02-30-37]   [FATAL]   A fatal error has occurred: Segmentation fault.
[13-09-2019_02-30-37]   [FATAL]   0x589080 OpenXcom::CrossPlatform::stackTrace(void*)
[13-09-2019_02-30-37]   [FATAL]   0x589ef0 OpenXcom::CrossPlatform::crashDump(void*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
[13-09-2019_02-30-37]   [FATAL]   0x41e830 signalLogger(int)
[13-09-2019_02-30-37]   [FATAL]   0x925b90 OpenXcom::UfopaediaStartState::think()
[13-09-2019_02-30-37]   [FATAL]   0x7ffa42230ef0 _C_specific_handler
[13-09-2019_02-30-37]   [FATAL]   0x7ffa42244b50 _chkstk
[13-09-2019_02-30-37]   [FATAL]   0x7ffa421bbcc0 RtlWalkFrameChain
[13-09-2019_02-30-37]   [FATAL]   0x7ffa42243b70 KiUserExceptionDispatcher
[13-09-2019_02-30-37]   [FATAL]   0x538880 OpenXcom::Map::drawTerrain(OpenXcom::Surface*)
[13-09-2019_02-30-37]   [FATAL]   0x658f10 OpenXcom::Surface::blit(SDL_Surface*)
[13-09-2019_02-30-37]   [FATAL]   0x6572e0 OpenXcom::State::blit()
[13-09-2019_02-30-37]   [FATAL]   0x59fd10 OpenXcom::Game::run()
[13-09-2019_02-30-37]   [FATAL]   0x41e990 SDL_main
[13-09-2019_02-30-37]   [FATAL]   0x9276c0 console_main
[13-09-2019_02-30-37]   [FATAL]   0x9277e0 WinMain
[13-09-2019_02-30-37]   [FATAL]   ??
[13-09-2019_02-30-37]   [FATAL]   ??
[13-09-2019_02-30-37]   [FATAL]   0x7ffa411b1fd0 BaseThreadInitThunk
[13-09-2019_02-30-37]   [FATAL]   0x7ffa4220ef90 RtlUserThreadStart
[13-09-2019_02-30-41]   [FATAL]   OpenXcom has crashed: Segmentation fault.
Log file: C:/games/XCOM UFO/test build/user/openxcom.log
Title: Re: How underwater bullet trajectory works?
Post by: Meridian on September 12, 2019, 07:52:31 pm
Did you try my mod?
Title: Re: How underwater bullet trajectory works?
Post by: wcho035 on September 12, 2019, 08:20:33 pm
I have tried your mod. It work on the surface for the Plasma rifle and pistol but not the Heavy Plasma. I can see the particle or vapor trail for both! Your mod hasn't got any underwater maps. So I also tried them on mine. Problem still persist unfortunately. It is a great effort and eye popping amazement! Seeing them working on UFO1.
Title: Re: How underwater bullet trajectory works?
Post by: Meridian on September 12, 2019, 08:25:43 pm
I have tried your mod. It work on the surface for the Plasma rifle and pistol but not the Heavy Plasma. I can see the particle or vapor trail for both! Your mod hasn't got any underwater maps. So I also tried them on mine. Problem still persist unfortunately. It is a great effort and eye popping amazement! Seeing them working on UFO1.

It doesn't work on surface... surface doesn't have any vapor, ever.

It works only under water.
My mod has underwater maps... two of them... medium scout and large scout.
I have modded only plasma pistol and rifle, not heavy plasma... haven't you seen that in the ruleset?

It's a very simple mod... is it really so hard to read?

PS: I guess your mistake is in metadata.yml... please check it again
Title: Re: How underwater bullet trajectory works?
Post by: wcho035 on September 12, 2019, 08:42:56 pm
Sorry, it is 3am here, late the day, made a few mistakes. I will check it out again.
Title: Re: How underwater bullet trajectory works?
Post by: wcho035 on September 12, 2019, 09:00:39 pm
Wow.. it really worked! THANK YOU MERIDIAN! It is the metadata that is messing up in my mod. Also I was not using an Aliendeployment in my mod. Problem Solved!

You are a total legend Meridian! Absolute total legend! I bet Luke would say the same to you!

Sorry about the mistake! Kind of late in the night..
Title: Re: How underwater bullet trajectory works?
Post by: Meridian on September 12, 2019, 09:18:41 pm
Sorry about the mistake! Kind of late in the night..

No worries... and go to bed already ;-)
Title: Re: How underwater bullet trajectory works?
Post by: luke83 on November 25, 2019, 07:20:41 am
Finally added this today, thankyou Meridiam. :P
Title: Re: How underwater bullet trajectory works?
Post by: Meridian on May 14, 2020, 08:14:53 pm
Since OXCE v6.5, having surface weapon vapor trail is possible also for non-hybrid mods, i.e. just normal xcom1-based mods.

Steps are also much easier than for hybrid mods.

Sample mod attached.
Title: Re: How underwater bullet trajectory works?
Post by: efrenespartano on May 23, 2020, 07:36:38 pm
Wonderful! I expected to have this feature a long time ago.

Question: I notice the vaporColors are limited to four colors: white, cyan, orange and green. Could be possible the add more colors (like red or purple)?

Also: how does
Code: [Select]
colors works?

Code: [Select]
transparencyLUTs:
  - colors:
      - [  8,  8, 12, 2 ] # "white"

Those numbers are indexes on the Battlescape palette?
Title: Re: How underwater bullet trajectory works?
Post by: Meridian on May 23, 2020, 07:48:59 pm
Question: I notice the vaporColors are limited to four colors: white, cyan, orange and green. I tried your test mod and I found that the cyan, the white and the green were basically the same. Could be possible the add more colors (like red or purple)?

They are not the same, but they can sometimes appear the same based on what is in the background.

For example green and cyan on green background will look almost the same.
But the same cyan and green on light grey background will look different.
Try it.

OpenXcom palette is very limited and simulating transparency just isn't possible in all background/foreground color combinations.


Also: how does
Code: [Select]
colors works?

Code: [Select]
transparencyLUTs:
  - colors:
      - [  8,  8, 12, 2 ] # "white"

Those numbers are indexes on the Battlescape palette?

I don't know how it works... I was trying to read it for a long time, but it's too cryptic without someone telling you what it is.

As far as I can tell, the numbers correspond to [(R)ed, (G)reen, (B)lue, Step], where R G B are not real RGB (0-255), also not xcom RGB (0-63) and also not OpenXcom colors/indices.
I also don't know what values they can have, probably between 0 and 15, but that's just a wild guess. "Step", no idea.

Probably the only guy who can answer this is Warboy.
If you find out, do let us know!
Title: Re: How underwater bullet trajectory works?
Post by: Yankes on May 23, 2020, 07:58:23 pm
If I recall correctly this is "desired" color you want have, after that game iterate for each palette and try find best matches for desired color.
Logic is somthing like:
Get some color for palette, mix in your desired color in RGB, now for this new color in RGB find best match in same palette.
This will give transition from original color to final one in same palette and it represent transparent vapor cloud.
Title: Re: How underwater bullet trajectory works?
Post by: efrenespartano on May 24, 2020, 09:33:11 am
They are not the same, but they can sometimes appear the same based on what is in the background.

For example green and cyan on green background will look almost the same.
But the same cyan and green on light grey background will look different.
Try it.

OpenXcom palette is very limited and simulating transparency just isn't possible in all background/foreground color combinations.

Hahaha I noticed it after I tried on the Polar terrain. My bad, that's why I deleted that specific part of my question hahaha.  ;D
The change is more noticeable if the
Code: [Select]
vaporDensitySurface is set above 20.

Quote
I don't know how it works... I was trying to read it for a long time, but it's too cryptic without someone telling you what it is.

As far as I can tell, the numbers correspond to [(R)ed, (G)reen, (B)lue, Step], where R G B are not real RGB (0-255), also not xcom RGB (0-63) and also not OpenXcom colors/indices.
I also don't know what values they can have, probably between 0 and 15, but that's just a wild guess. "Step", no idea.

Probably the only guy who can answer this is Warboy.
If you find out, do let us know!

If I recall correctly this is "desired" color you want have, after that game iterate for each palette and try find best matches for desired color.
Logic is somthing like:
Get some color for palette, mix in your desired color in RGB, now for this new color in RGB find best match in same palette.
This will give transition from original color to final one in same palette and it represent transparent vapor cloud.


Oh, dang. I think I could do some random tries to see if I could get a new color, then. Thanks for the quick reply, folks.  :D
Title: Re: How underwater bullet trajectory works?
Post by: Ethereal on April 15, 2021, 03:26:58 pm
Vapor works only underwater.
Fake underwater... as the name says... is not underwater.

For surface (including fake underwater) missions, you can use surface vapor.

Poporobuy. "Vapor...Surface" does not work with setting depth on the terrain. And without the set depth, "drawBubbles", underwater animation of explosions, missions and  race "_UNDERWATER" do not work.

In my modification, the rocket launchers have "vaporColorSurface:" and "vaporDensitySurface:", but this only works on land. And if we set the usual "vaporColor: vaporDensity:" we get -

Code: [Select]
[15-04-2021_15-25-20] [FATAL] A fatal error has occurred: Segmentation fault.
[15-04-2021_15-25-20] [FATAL] 0x5b6d50 OpenXcom::CrossPlatform::stackTrace(void*)
[15-04-2021_15-25-20] [FATAL] 0x5b7bc0 OpenXcom::CrossPlatform::crashDump(void*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
[15-04-2021_15-25-20] [FATAL] 0x41c7f0 signalLogger(int)
[15-04-2021_15-25-20] [FATAL] 0x9ba390 OpenXcom::UfopaediaStartState::think()
[15-04-2021_15-25-20] [FATAL] 0x774e72fc _C_specific_handler
[15-04-2021_15-25-20] [FATAL] 0x774fbee0 _chkstk
[15-04-2021_15-25-20] [FATAL] 0x774cff00 RtlInitializeResource
[15-04-2021_15-25-20] [FATAL] 0x774fb5f0 KiUserExceptionDispatcher
[15-04-2021_15-25-20] [FATAL] 0x55f0f0 OpenXcom::Map::drawTerrain(OpenXcom::Surface*)
[15-04-2021_15-25-20] [FATAL] 0x68ed50 OpenXcom::Surface::blit(SDL_Surface*)
[15-04-2021_15-25-20] [FATAL] 0x68d290 OpenXcom::State::blit()
[15-04-2021_15-25-20] [FATAL] 0x5cef20 OpenXcom::Game::run()
[15-04-2021_15-25-20] [FATAL] 0x41c950 SDL_main
[15-04-2021_15-25-20] [FATAL] 0x9bbec0 console_main
[15-04-2021_15-25-20] [FATAL] 0x9bbfe0 WinMain
[15-04-2021_15-25-20] [FATAL] ??
[15-04-2021_15-25-20] [FATAL] ??
[15-04-2021_15-25-20] [FATAL] 0x77385550 BaseThreadInitThunk
[15-04-2021_15-25-20] [FATAL] 0x774e3840 RtlUserThreadStart
[15-04-2021_15-25-23] [FATAL] OpenXcom has crashed: Segmentation fault.
Title: Re: How underwater bullet trajectory works?
Post by: Meridian on April 15, 2021, 04:53:50 pm
If you're using depth on fake underwater terrain it counts as normal underwater again, and normal vapor should work too.

Upload a save where it doesn't work pls.
Title: Re: How underwater bullet trajectory works?
Post by: Ethereal on April 15, 2021, 05:20:38 pm
Saves is not necessary. You can simply test it in "Battle" mode. In this mode, everything works the same as in a regular game. I checked. Very convenient, by the way.

Although, here's the save, if that's more convenient for you.
Title: Re: How underwater bullet trajectory works?
Post by: Meridian on April 15, 2021, 06:42:12 pm
You are missing PAL_BATTLESCAPE_3 (for sea depth = 3).

Just add this to your custom palettes and it will work.

Code: [Select]
  - type: PAL_BATTLESCAPE_3L83
    target: PAL_BATTLESCAPE_3
    file: Resources/PALS/battlescape_seadepth2.jasc

And of course also this for STR_HWP_ROCKETS

Code: [Select]
    vaporColor: 9
    vaporDensity: 40
Title: Re: How underwater bullet trajectory works?
Post by: Ethereal on April 15, 2021, 07:28:43 pm
You are missing PAL_BATTLESCAPE_3 (for sea depth = 3).

Just add this to your custom palettes and it will work.

And of course also this for STR_HWP_ROCKETS

Thank you very much. I would never have guessed. Everything works fine.