OpenXcom Forum

Modding => Work In Progress => Topic started by: Orz on March 27, 2016, 04:20:38 pm

Title: TFTD's Alt/Extra Explosions (Underwater Sprites) *Resolved*
Post by: Orz on March 27, 2016, 04:20:38 pm
TFTD requires separate "underwater" strings for sprites and sounds, so my question is: how does one go about implementing this, exactly? Last night I was experimenting with extra/alternate explosion colors to visually differentiate between smoke/dye, HE and stun/freeze. They work on land just fine; however, the game keeps crashing underwater. I'm obviously missing something.

(I tried a much darker smoke/dye, but it just didn't look good. These aren't final, will continue experimenting.)
(https://s24.postimg.org/dcagrmcad/X1_Smoke.png)

(https://s11.postimg.org/7alree2kz/X1_HE.png)

(https://s11.postimg.org/vdbs0qxzn/X1_Stun.png)

I believe I got sounds figured out, like so:

Code: [Select]
extraSounds:
  - type: BATTLE.CAT
    files:
      90: Resources/Sounds/GaussPistol.ogg
  - type: BATTLE2.CAT
    files:
      90: Resources/Sounds/GaussPistolUW.ogg

So I'm assuming something similar applies for sprites? Example:

Code: [Select]
extraSprites:
  - type: X1.PCK
    width: 1024
    height: 128
    subX: 128
    subY: 64
    files:
      80: Resources/Extra_Explosions/X1_Stun.png
      100: Resources/Extra_Explosions/X1_Smoke.png
      120: Resources/Extra_Explosions/X1_HE.png
items:
  - type: STR_DYE_GRENADE
    hitAnimation: 100
  - type: STR_GC_HE_AMMO
    hitAnimation: 120
  - type: STR_HALLUCINOID_STUN_WEAPON
    hitAnimation: 80

As always, help much appreciated :)


PS: Somewhat related also: shotgun-style weapon do not work underwater either (it won't crash the game, but shotgunPellets only work on land. It's nothing urgent as of now, but Warboy may wanna patch that up that later?
Title: Re: TFTD's Underwater Sprites & Sounds?
Post by: ivandogovich on March 27, 2016, 04:36:24 pm
Did you get the correct pallettes for underwater?  There are four if I remember correctly, that correspond to the various depths.
Title: Re: TFTD's Underwater Sprites & Sounds?
Post by: chaosshade on March 27, 2016, 09:19:33 pm
Palettes don't cause crashing, I've fought that battle before.  They just make the game annoying until you fix them, lol.  In TFTD you just use the palette for Depth 0 (surface) and the game corrects for depth.
Title: Re: TFTD's Underwater Sprites & Sounds?
Post by: Xeno Wiper on March 30, 2016, 06:32:32 am

I believe I got sounds figured out, like so:

Code: [Select]
extraSounds:
  - type: BATTLE.CAT
    files:
      90: Resources/Sounds/GaussPistol.ogg
  - type: BATTLE2.CAT
    files:
      90: Resources/Sounds/GaussPistolUW.ogg

So I'm assuming something similar applies for sprites? Example:
[/code]


This works for weapons as it does for aliens. But aliens need a bit more, IMHO.  :-\ 

Palettes don't cause crashing, I've fought that battle before.  They just make the game annoying until you fix them, lol.  In TFTD you just use the palette for Depth 0 (surface) and the game corrects for depth.

FIXED:

and the game screws up your colors in all depths.  :P
Title: Re: TFTD's Underwater Sprites & Sounds?
Post by: Orz on March 30, 2016, 09:53:20 pm
Yes, palettes are not the problem here. They look fine (on land). They just crash the game underwater.

Anyone willing to take a look at this? I'm pretty sure I'm doing something stupid with the ruleset. Attached:
Title: Re: TFTD's Underwater Sprites & Sounds?
Post by: R1dO on March 30, 2016, 10:25:08 pm
According to ufopaedia (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_%28OpenXcom%29#Items) entry on hitAnimation:
Quote
NOTE: Explosive style weapons (Damage type: smoke, incendiary, stun, & High Explosive) use X1.PCK and should always be set to 0.

Your values are quite far of from 0, so that might be the problem here.

Another thing i noted is that the .rul file is in an unexpected place (under Resources, not in archive root or Ruleset). But i don't think that contributes to the error.
Title: Re: TFTD's Underwater Sprites & Sounds?
Post by: Orz on March 30, 2016, 10:33:49 pm
According to ufopaedia (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_%28OpenXcom%29#Items) entry on hitAnimation:
Your values are quite far of from 0, so that might be the problem here.

Another thing i noted is that the .rul file is in an unexpected place (under Resources, not in archive root or Ruleset). But i don't think that contributes to the error.

That was my bad, I put that together really quick (since I wasn't making a separate mod out of it, rather integrated on my TFTD Rework). Just re-uploaded with ruleset in correct folder. Still, though, that couldn't be the issue since I can define custom hitAnimation in UFO/EU as I like and it works fine. And here too, they work, just not underwater. And that's the issue.
Title: Re: TFTD's Alt/Extra Explosions (Underwater Sprites/Sounds Question)
Post by: R1dO on March 31, 2016, 01:40:01 am
I might have found the somewhat hidden logic.
Does attached file work?
Title: Re: TFTD's Alt/Extra Explosions (Underwater Sprites/Sounds Question)
Post by: Orz on March 31, 2016, 03:33:17 am
I might have found the somewhat hidden logic.
Does attached file work?

That did it, thanks! I just had to correct Dye Grenade's hitAnimation: 188 to 108, but your logic got across :) How did you figure it out anyway? Was it because of the double row of sprites? I wouldn't have guessed unless it was pointed out!
Title: Re: TFTD's Alt/Extra Explosions (Underwater Sprites) *Resolved*
Post by: R1dO on March 31, 2016, 11:34:36 am
I had to run it via a debugger.
Luckily it drew the first sprites of the explosion. Those were the above water sprites.
Combine that with an observed hitanimation variable that was below the sprite value, some careful looking at the code (and the ruleset for TFTD) and suddenly an idea forms. Of course it did help that you defined the smoke animation to be 20 points below the HE animation, otherwise i wouldn't have seen an explosion at all ;)

For reference. hitAnimation should always point to the first above water sprite. The game corrects for underwater explosions.
The cool thing about this is that you can use the same sprite sheets for both UFO and TFTD, only the ruleset files need to differ (ok .. theoretical, i haven't tested it).


Now the question remains .. what was your problem with the shotgun, are the paths not drawn, or the impacts?
Title: Re: TFTD's Alt/Extra Explosions (Underwater Sprites) *Resolved*
Post by: Warboy1982 on March 31, 2016, 01:46:17 pm
The cool thing about this is that you can use the same sprite sheets for both UFO and TFTD, only the ruleset files need to differ (ok .. theoretical, i haven't tested it).

theoretically sound
Title: Re: TFTD's Alt/Extra Explosions (Underwater Sprites) *Resolved*
Post by: Orz on March 31, 2016, 06:01:38 pm
For reference. hitAnimation should always point to the first above water sprite. The game corrects for underwater explosions.

Gotcha.

Quote
Now the question remains .. what was your problem with the shotgun, are the paths not drawn, or the impacts?

"shotgunPellets" make it work like a shotgun alright, just not underwater. When we go swimmin' it simply operates like a regular weapon (i.e. one single AP shot, path drawn as normal). It's nothing urgent anyway.
Title: Re: TFTD's Alt/Extra Explosions (Underwater Sprites) *Resolved*
Post by: R1dO on March 31, 2016, 08:53:57 pm
Let me guess:
You defined:
Code: [Select]
vaporColor:
vaporDensity:
on the submersible shotgun?


Update:
 I have to stand corrected on this one. Those variables do NOT clash with underwater drawing of shutgun pellets. In fact it works completely fine by default when using
Code: [Select]
shotgunPellets
Title: Re: TFTD's Alt/Extra Explosions (Underwater Sprites) *Resolved*
Post by: Orz on April 01, 2016, 01:28:25 am
Let me guess:
You defined:
Code: [Select]
vaporColor:
vaporDensity:
on the submersible shotgun?


Update:
 I have to stand corrected on this one. Those variables do NOT clash with underwater drawing of shutgun pellets. In fact it works completely fine by default when using
Code: [Select]
shotgunPellets

Really? I was just testing it on Hyrdojet Cannon (AP ammo, of course), just to get an idea how it'd look like. I didn't play with it again since. And no, I didn't touch vapors. I'll have to look at it again.

Thanks, though!
Title: Re: TFTD's Alt/Extra Explosions (Underwater Sprites) *Resolved*
Post by: R1dO on April 01, 2016, 01:37:37 am
Perhaps the RNG gods played the same trick on you as they did on me.

Creating a super accurate shotgun sniper that can land all pellets in the same area, when all you want is rookie with default eye-hand coordination (e.g. none).