aliens

Author Topic: [DONE] Custom hit/melee animation frame count  (Read 6988 times)

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
[DONE] Custom hit/melee animation frame count
« on: December 26, 2020, 03:17:53 pm »
EDIT: new ruleset described below: https://openxcom.org/forum/index.php/topic,8944.msg135061.html#msg135061

According to the documentation, melee weapons should use meleeAnimation stored in HIT.PCK, instead of hitAnimation stored in SMOKE.PCK.
1. - does it mean that the stun rod anim has been moved to HIT.PCK? Because AFAIK the stun hit anim is inside SMOKE.PCK; the default HIT.PCK should only hold the default melee hit (https://www.ufopaedia.org/index.php/HIT.PCK).
2. -  is the maximum number of frames supported for HIT.PCK animations = 4? The anim below is 8 frames, but it seems not fully rendered ingame.
2.1 - the stun rod animation has 9 frames, so IF it has been moved to HIT.PCK, does it mean that not all the frames are rendered?
3. - what about the max frames for animations in SMOKE.PCK? The default smoke animation is 12 frames, so all my custom animations use 12 frames.. but I'm suspecting that the limit is actually 10...
 
« Last Edit: February 12, 2023, 10:50:51 am by Meridian »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9144
    • View Profile
Re: [OXCE] HIT.PCK/SMOKE.PCK and meleeAnimation/hitAnimation
« Reply #1 on: December 26, 2020, 03:43:19 pm »
As far as I know both hitAnimation and meleeAnimation work the same in OXC and OXCE

1. it hasn't been moved, it was always there... there is no special stun hit anim, there is only one default melee hit anim in UFO

2. yes, it's 4
const int Explosion::HIT_FRAMES = 4;
const int Explosion::EXPLODE_FRAMES = 8;
const int Explosion::BULLET_FRAMES = 10;

2.1 where is the 9 frame stun animation? I don't see anything like that

3. the smoke animation is 4 frames, you see 12 sprites only because there are 3 different types (thin, normal and dense smoke)... 3x4=12
limit for bullet impact animations (also in SMOKE.PCK) is 10 frames
limit for explosions (X1.PCK) is 8 frames
« Last Edit: January 03, 2021, 10:19:00 am by Meridian »

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
Re: [OXCE] HIT.PCK/SMOKE.PCK and meleeAnimation/hitAnimation
« Reply #2 on: December 26, 2020, 03:52:03 pm »
As far as I know both hitAnimation and meleeAnimation work the same in OXC and OXCE

1. it hasn't been moved, it was always there... there is no special stun hit anim, there is only one default melee hit anim in UFO

2. yes, it's 4
const int Explosion::HIT_FRAMES = 4;
const int Explosion::EXPLODE_FRAMES = 8;
const int Explosion::BULLET_FRAMES = 10;

2.1 where is the 9 frame stun animation? I don't see anything like that
see attached img, aren't the highlighted frames the ones for the stun rod hit?
EDIT: no i'm an idiot, that's the AP round hit animation... my image had that green frame that mislead me...

limit for bullet impact animations (also in SMOKE.PCK) is 10 frames
AAHHHHHH*booomm*
oh well
« Last Edit: December 26, 2020, 04:02:03 pm by robin »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9144
    • View Profile
Re: [OXCE] HIT.PCK/SMOKE.PCK and meleeAnimation/hitAnimation
« Reply #3 on: December 26, 2020, 04:24:00 pm »
it's probably not too difficult to make the number of frames item-specific, if there's a need for it, I can have a look...

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
Re: [OXCE] HIT.PCK/SMOKE.PCK and meleeAnimation/hitAnimation
« Reply #4 on: December 26, 2020, 05:03:03 pm »
It's ok don't worry, I'll tweak my animations to fit the limits.

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
Re: [OXCE] HIT.PCK/SMOKE.PCK and meleeAnimation/hitAnimation
« Reply #5 on: December 26, 2020, 11:46:32 pm »
MOAR questions. The following is how I defined SMOKE.PCK inside extraSprites.rul.

Code: [Select]
  - type: SMOKE.PCK
    height: 40
    width: 384
    subX: 32
    subY: 40
    files:
      8: Resources/apoc/SMOKE/smoke_cloud.gif  # override vanilla animation, 12 frames
      106: Resources/apoc/SMOKE/hit_spawn_brainsucker.png
      116: Resources/apoc/SMOKE/robomedikit_xcom_spawn.png
      126: Resources/apoc/SMOKE/hit_goo_white.png
      136: Resources/apoc/SMOKE/hit_entropy.png

width=384 means it holds 12 frames. This is necessary because "smoke_cloud.gif" animation is made of 12 frames (or 4*3).
But of course all the other animations must be 10 frames, so the effective width for them is 320.

XComFiles is like this:
Code: [Select]
  - type: SMOKE.PCK
    height: 80
    width: 160
With these sizes, the total frame count of the image is 10. But if the mod were to override the smoke animation, like mine does, needing a total of 12 frames, the size would be insufficient. So I can't use that.

In conclusion, should I:
a) use 40*384 sized image files, with blank frames at the end (but then the subimage count should be 12 or 10 like it is now?)
b) size the images to the effective count of frames (so basically 40*320) despite defining "width: 384"
?
« Last Edit: December 27, 2020, 12:02:16 am by robin »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9144
    • View Profile
Re: [OXCE] HIT.PCK/SMOKE.PCK and meleeAnimation/hitAnimation
« Reply #6 on: December 27, 2020, 12:02:57 am »
I think you can just define it twice, with different sizes, like vanilla terror weapons:

Code: [Select]
  - type: BIGOBS.PCK
    width: 64
    height: 96
    subX: 32
    subY: 48
    files:
      58: Resources/Weapons/Terror.png
  - type: BIGOBS.PCK
    width: 32
    height: 48
    files:
      57: Resources/Weapons/Zombie.png

I'll check tomorrow and update the post if necessary.

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
Re: [OXCE] HIT.PCK/SMOKE.PCK and meleeAnimation/hitAnimation
« Reply #7 on: December 27, 2020, 12:07:28 am »
Thanks! I'll try defining it twice.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9144
    • View Profile
Re: [OXCE] HIT.PCK/SMOKE.PCK and meleeAnimation/hitAnimation
« Reply #8 on: December 27, 2020, 11:53:35 am »
Thanks! I'll try defining it twice.

I checked it and defining it twice is fully supported and recommended way to do this.

It's ok don't worry, I'll tweak my animations to fit the limits.

In other news, custom animation frame count is now also supported (OXCE v6.8.4 or higher).
Example:

Code: [Select]
items:
  - type: STR_LASER_RIFLE
    hitAnimation: 36
    hitAnimFrames: 20   # plays laser anim + plasma anim
  - type: STR_STUN_ROD
    meleeAnimation: 4
    meleeAnimFrames: 32  # don't forget to define additional frames in HIT.PCK

Attached a video of Liu Kang doing an 8 hit combo on a Floater.
« Last Edit: January 09, 2021, 03:27:41 pm by Meridian »

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
Re: [OXCE] HIT.PCK/SMOKE.PCK and meleeAnimation/hitAnimation
« Reply #9 on: December 27, 2020, 12:27:52 pm »
I checked it and defining it twice is fully supported and recommended way to do this.

In other news, custom animation frame count is now also supported (OXCE v6.8.4 or higher).
Example:

Code: [Select]
items:
  - type: STR_LASER_RIFLE
    hitAnimation: 36
    hitAnimFrames: 20   # plays laser anim + plasma anim
  - type: STR_STUN_ROD
    meleeAnimation: 4
    meleeAnimFrames: 32  # don't forget to define additional frames in HIT.PCK

Attached a video of Liu Kang doing an 8 hit combo on a Floater.
Great! The combo looked quite spectacular, I want to turn the agents into Power Rangers now.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: [OXCE] HIT.PCK/SMOKE.PCK and meleeAnimation/hitAnimation
« Reply #10 on: December 27, 2020, 01:20:07 pm »
3. the smoke animation is 4 frames, you see 12 sprites only because there are 3 different animations (thin, normal and dense smoke)... 3x4=12
In-game testing suggests there are 2 animations: one with 4 frames of thin smoke and 2 of medium smoke, and one with 2 of medium smoke and 4 of thick smoke. But I might be interpreting something wrong.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9144
    • View Profile
Re: [OXCE] HIT.PCK/SMOKE.PCK and meleeAnimation/hitAnimation
« Reply #11 on: December 27, 2020, 02:46:56 pm »
Dude, I really don't have the mental strength to fight you each time I say something.

The smoke animation has 4 frames, end of the story.

I don't know what kind of testing you did, but testing and reverse-engineering has been done by a million people before you and they all agree.
Documentation is here: https://www.ufopaedia.org/index.php/SMOKREF.DAT
Source code is here: https://github.com/OpenXcom/OpenXcom/blob/master/src/Battlescape/Map.cpp#L884

PS: thick smoke (and second half of the normal smoke) is not even achievable in the game without save editing, I really wonder where you saw that...

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: [OXCE] HIT.PCK/SMOKE.PCK and meleeAnimation/hitAnimation
« Reply #12 on: December 28, 2020, 02:20:17 pm »
That animation is excellent Robin!

You can really feel the teeth slamming together just by looking at it.

I want to turn the agents into Power Rangers now.

If X-Com is going to field a Power Rangers squad they will need suitable interdimensional beasties to fight.
(I hope you don't mind me adapting your melee strike into a lovecraftian monstrosity)



drawingRoutine: 12 (Hallucinoid)



drawingRoutine: 22 (Inverted Cyberdisc with propulsion animation on top)
<The central eye is from Dioxine's X-Piratez, it looks in the direction the unit is facing.>


In other news, custom animation frame count is now also supported (OXCE v6.8.4 or higher).
Wonderful news! Thank you for adding this feature.

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
Re: [OXCE] HIT.PCK/SMOKE.PCK and meleeAnimation/hitAnimation
« Reply #13 on: December 29, 2020, 12:14:17 am »
hahahaha that monstrosity is nightmare fuel!

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: [OXCE] HIT.PCK/SMOKE.PCK and meleeAnimation/hitAnimation
« Reply #14 on: January 03, 2021, 03:16:05 am »
I don't know what kind of testing you did, but testing and reverse-engineering has been done by a million people before you and they all agree.
Documentation is here: https://www.ufopaedia.org/index.php/SMOKREF.DAT

I did deeper testing and discovered that we were both wrong. The documentation appears to be right, and it tells a story different from what you or I said.

What you said (and I'm paraphrasing based on how I interpreted it): There are three different sets of animation, the top four frames (thin smoke), the middle four frames(medium smoke), and the bottom four frames(thick smoke).
What I said: There are two sets of animation, the first six frames, and the last six frames.
What the documentation says: It selects an initial frame based on the smoke's remaining lifespan and animates through that frame and the next three frames.

What actually happens: There are three possible smoke animations, frames 1-4, frames 2-5, and frames 3-6. The remaining 6 sprite indexes aren't ever used.

https://youtu.be/nbtl7_C6Ags

In this video, I have made a smoke cloud using the smoke spritesheet below. You can see (easier at 0.25x speed) that each animation uses a set of four sprites taken from the first six on the sheet. I tried this several more times and got the same results every time.