Author Topic: CC Enemyedit: Max HP Possible?  (Read 7720 times)

Maximus

  • Iokan (+1)
  • *
  • Posts: 6
    • View Profile
CC Enemyedit: Max HP Possible?
« on: April 12, 2020, 03:41:27 pm »
** I changed title name because a new discovery
I Discovered that on New Game + monsters Stats get double, Hp is evident, not sure about other stats...any way to confirm this more in deep?
So...
I am working on a mod with all CC Enemies stats increased x2.00 (HP, ATk, Def, Mag, MDef)
However, just tested on the final boss DT (Lavos) and its Hp resulted to be around 160 ~ 170! (I set it on 20000).

There is a kind of limitation, i haven't even exceed the 65535 stated limit on the app tool.

Would like to know if anyone have experience on this?  :roll:
« Last Edit: April 12, 2020, 11:15:47 pm by Maximus »

glennxserge

  • Earthbound (+15)
  • *
  • Posts: 40
  • Sacred lickaroo.... Not!
    • View Profile
    • Chrono Cross FateTerminal
Re: CC Enemyedit: Max HP Possible?
« Reply #1 on: July 26, 2020, 08:24:24 pm »
I think the base HP value also scales with game progress... somehow, and I'm guessing the game doesn't have an overflow check so you can get odd behavior.  My current hunch is this is star based.  For instance, when fighting beach bums at star level 0, they have just under half the HP their stat block indicates, but near end game (in the 40 odd star level), they are pretty close to the right amount.  I haven't tested this at the 99 star limit since I don't have a save state that far, but it's something I intend to do.

Also keep in mind, this means it's also possible to have HP issues on the low end-> if you set a beginning enemy to 1 HP for instance, it gets halved and rounded down to 0.  You get enemies that are instantly dead but don't go through the dying animation.

Grobycftw

  • Architect of Kajar
  • Porrean (+50)
  • *
  • Posts: 89
  • Chilling in the Bend of Time
    • View Profile
Re: CC Enemyedit: Max HP Possible?
« Reply #2 on: November 09, 2020, 05:05:30 am »
If I remember well, the way enemy HP's are set, depends on the number of character you have in your party when fighting , go and try fighting the Beach Bum on a new game with Serge only, then try with Serge and Poshul, and then with 3 char, you should see a difference, also when doing a new game plus it does x2 to all HP I believe

glennxserge

  • Earthbound (+15)
  • *
  • Posts: 40
  • Sacred lickaroo.... Not!
    • View Profile
    • Chrono Cross FateTerminal
Re: CC Enemyedit: Max HP Possible?
« Reply #3 on: November 23, 2020, 02:16:29 pm »
Oh, that's really interesting, Grobycftw.  I hadn't thought to check HP based on party size.  The tests I did I think were with just Serge (seeing half HP at the beginning of the game), I wonder if it scales cleanly at 25% reduction per missing character:
1 char: 50%
2 char: 75%
3 char: 100%

Gonna go test this now.

EDIT: Checked this over my lunch break.  Here's what I found testing Beach Bums at Cape Howl. 
  • With one character, they had 16 HP (50%)
  • With two characters, they had 33 HP (100%+1HP, which is maybe probably just the bonus 5% given to male enemies when rounded down)
  • With three characters, they also have 33 HP.

So I think the scaling is only present when there are less than 2 characters on your team.  I'll have to test this later, when you become solo Lynx to see if this widely the case for the game, or just how they handle difficulty at the very beginning.
« Last Edit: November 23, 2020, 05:49:32 pm by glennxserge »

Grobycftw

  • Architect of Kajar
  • Porrean (+50)
  • *
  • Posts: 89
  • Chilling in the Bend of Time
    • View Profile
Re: CC Enemyedit: Max HP Possible?
« Reply #4 on: November 24, 2020, 04:40:02 am »
Nice finding glennxserge , that sure will be useful to know when scaling the difficulty for a hack!
Let us know what you find with Lynx!

glennxserge

  • Earthbound (+15)
  • *
  • Posts: 40
  • Sacred lickaroo.... Not!
    • View Profile
    • Chrono Cross FateTerminal
Re: CC Enemyedit: Max HP Possible?
« Reply #5 on: November 24, 2020, 08:15:51 pm »
So I tested a little bit more.  The next time in the game you have a solo character is as Lynx in the Temporal Vortex, but you recruit Sprigg before any battles, so that was a bust. 

The only other scenario I could think of is in Lucca's orphanage since your party gradually decreases as you work your way through the house.  This is what I found there:
Lava-boys (and girls) - these have a random sex, so they'll get +/- 5% HP depending on Male or Female.  My calculations account for the bonus in order to better match the stat block on disc.
  • 1 char - 780 HP (Male 819, Female 741)
  • 2 char - 780 HP (Male 819, Female 741)
  • 3 char - 780 HP (Male 819, Female 741)
That's the regular value on disc for that encounter, so I don't think scaling is used after you recruit your first character, regardless how many are actually in your current party, and it seems like it has nothing to do with star level.  At zero stars if you recruit Poshul, enemy HP will be normal. 

There is another factor though, that you noticed Grobycftw, NG+ enemies will have 2x HP.  It looks like this is a separate scaling factor that is applied alongside the early game difficulty scaling.  I tested this in a NG+ game and enemies had the normal HP, until I recruited a character, and then they had 2x. 

Here's my hunch about the way it's calculated, order of operations :
Code: [Select]
HP is multiplied by 2 if it is a NG+
HP is then divided by 2 if it's early game
5% is then +/- from HP depending on Male/Female
The order of operations does seem to matter here, since a shift down or divide with integers could clear the low bit before shifting back up (in the case of NG+ and early game).  However it doesn't seem to matter since no enemies in the beginning have stat blocks with odd values.  The 5% definitely happens after the scaling though, as it is testable (male Beach Bums have 67 HP, not 66 in NG+).

I'm tempted to try and dump emu states before and after recruiting Poshul to see if I can find where that value gets set, but feeling a bit lazy at the moment.

Can anyone think of any other points in the game where there is a solo character with enemy encounters?  I'm willing to test a bit more.
« Last Edit: November 24, 2020, 09:12:37 pm by glennxserge »

glennxserge

  • Earthbound (+15)
  • *
  • Posts: 40
  • Sacred lickaroo.... Not!
    • View Profile
    • Chrono Cross FateTerminal
Re: CC Enemyedit: Max HP Possible?
« Reply #6 on: November 27, 2020, 05:57:10 pm »
Ah, sorry Maximus, it seems like I've gotten sidetracked to the point of your original question.  Which was why Max HP seems to overflow before the 16bit upper limit.  First thing to look at is if HP is actually used as a signed integer.  I would've thought that the game logic would just check for underflow (HP after damage greater than initial HP), and set to zero, but it's also possible that they would use a signed data type and just check for a less than zero value, since there are cases where damage actually does heal (plate armor stolen from dragons).

WARNING: Wall of text incoming
Experiment:
  • Set an enemy HP right at the 32,767 max
  • Modify an attack element to make enemy HP visible
  • Heal enemy and check HP
(I'll list my disc modifications based on a 2352 sector size, and using disc 1 only)

So I set the Beach Bum HP to 32,767.  since these are always male, the value is actually 31,207 * 1.05.  The disc address and values used:
  • 0x13B8EDEE: 0xE7
  • 0x13B8EDEF: 0x79

Next I modified Aquabeam so that it does zero damage but shows enemy HP:
  • 0x13BA00FC: 0x00 (zero damage)
  • 0x13BA00FE: 0x64 (stat effect 100% chance of hitting)
  • 0x13BA010E: 0x40 (HP vis stat)

And last, I changed Tablet, so that it targets enemies:
  • 0x13BA1538: 0x80

Then I started a battle, and cast Aquabeam on a full HP Beach Bum.  When I targeted him next, he had 32,767/32,767 HP.  So far so good.

Next I used a Tablet on him, which did... something odd.  He sagged like he was close to death.  And when I checked his HP it was far outside the 16bit boundary: 934,557/32,767 (and colored red like low HP).  A single 1 stamina attack then killed it  :shock:
So it seems like the game doesn't display negative HP values properly, but it sure acted like one.  This makes me think that HP, while not explicitly signed, is contingent on some game logic that treats it as such, but isn't well enforced.

I also double checked that an enemy with a reasonable HP value, when healed, doesn't go above it's max HP.  It seems like this overflow is only possible during the heal calculation if the result is lower than the max HP because of the sign change.

The last thing to note, giving an enemy a default HP value of 32768, made it's max HP overflow too, which creates some odd interactions.  This seems like a bug in the game logic.  It might be possible to fix the damage formula to allow for full 16bit values, but that'll take someone with more experience than me.  In the meantime, probably best to only use HP values under 32,767. Or, if you are planning on having a mod that can be played in NG+, 16,383.
« Last Edit: November 27, 2020, 06:06:15 pm by glennxserge »

ZeaLitY

  • Entity
  • End of Timer (+10000)
  • *
  • Posts: 10797
  • Spring Breeze Dancin'
    • View Profile
    • My Compendium Staff Profile

F-man

  • Earthbound (+15)
  • *
  • Posts: 17
    • View Profile
Re: CC Enemyedit: Max HP Possible?
« Reply #8 on: January 08, 2023, 07:37:41 pm »
Oh, that's really interesting, Grobycftw.  I hadn't thought to check HP based on party size.  The tests I did I think were with just Serge (seeing half HP at the beginning of the game), I wonder if it scales cleanly at 25% reduction per missing character:
1 char: 50%
2 char: 75%
3 char: 100%

Gonna go test this now.

EDIT: Checked this over my lunch break.  Here's what I found testing Beach Bums at Cape Howl. 
  • With one character, they had 16 HP (50%)
  • With two characters, they had 33 HP (100%+1HP, which is maybe probably just the bonus 5% given to male enemies when rounded down)
  • With three characters, they also have 33 HP.

So I think the scaling is only present when there are less than 2 characters on your team.  I'll have to test this later, when you become solo Lynx to see if this widely the case for the game, or just how they handle difficulty at the very beginning.

Just to make sure in case you haven't realized yet: Some early game battlescripts (the beach and cliff areas near Arni) have a global init code that weakens enemies if there is only one PC in the battle. Other battlescripts don't have this code so that's why this hp drop happens only in this situation.