Author Topic: FFVII Battle Check discrepancy ?  (Read 6075 times)

antd

  • *
  • Posts: 49
    • View Profile
FFVII Battle Check discrepancy ?
« on: 2013-03-13 21:53:20 »
Quote from: Terrence's Enemy Mechanics Guide
You will encounter a random battle if, during a battle check, Rnd(0..255) is
less than [Danger Counter * Enemy Lure Value / 256]


Note that the Enemy Lure Value is a fraction between 2/16ths to 32/16ths, but is only altered
through the presence of Enemy Lure and Enemy Away Materia on your party.
The default value when no such Materia is equipped is 16/16ths or 100%.

Yet, here is the disasm of the battle check (PSX NTSC U):

Code: [Select]
lui r4,0x8007
lhu r4,0x173c(r4) # load DangerValue
lui r3,0x8006
lbu r3,0x2f19(r3) # load EnemyLureValue (16)
nop
mult r4,r3 # DangerValue * EnemyLureValue (24128)
andi r2,r2,0xff
mflo r3
srl r3,r3,0x0c # (DangerValue * EnemyLureValue) / 4096
sltu r2,r2,r3
beq r2,r0,0xabef0 # if Rnd < [DangerValue * EnemyLureValue / 4096] then battle time
nop

It appears to divide by 2^12 (4096) and not 256.

Does someone care to tell me where I have gone wrong here?

EDIT: I think I see. EnemyLureValue is considered a fraction in Terrence's guide. Therefore the 4096 is divided by 16 to become 256?
« Last Edit: 2013-03-13 23:09:12 by antd »

nfitc1

  • *
  • Posts: 3013
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: FFVII Battle Check discrepancy ?
« Reply #1 on: 2013-03-14 14:39:12 »
It does a bit shift right by 12 to encompass the Encounter Value's fraction and the dividing by 256.

The Encounter Value can range from 2 to 32 based on Enemy Aways/Lures you have equipped. Oddly enough, one master Enemy Away has the full effect, but it takes at least 2 Enemy Lures to reach the cap.
I think the Danger Counter is defined by the field you're in.

If it's any interest to you, this Rnd(0..255) is only pseudo-random. It uses a RNLUT that's in a different place.

Code: [Select]
REPointer += 1
if( REPointer == 0 )
   REVariant += 13
return RELUT( REPointer ) - REVariant

If that number is less than [Danger Counter * ( Encounter Rate ) ] >> 12 then battle ensues. I could give you the RELUT values if you want, but I'm not sure how helpful they'd be.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: FFVII Battle Check discrepancy ?
« Reply #2 on: 2013-03-17 07:01:50 »
What is the chance of encounter if you add 16 enemy away materias?  I take it there is a limit to their effectiveness also?

nfitc1

  • *
  • Posts: 3013
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: FFVII Battle Check discrepancy ?
« Reply #3 on: 2013-03-18 00:16:45 »
What is the chance of encounter if you add 16 enemy away materias?  I take it there is a limit to their effectiveness also?

The encounter rate is capped between 2 (x1/8) and 32 (x2) inclusive. A little odd because one mastered enemy lure provides the full effect while it takes at least two enemy aways to double the encounter rate.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: FFVII Battle Check discrepancy ?
« Reply #4 on: 2013-03-18 13:04:20 »
Do you have the place in ff7 PC that can change that?  I wouldn't mind making Enemy Lure and Enemy Away more effective for my mod eventually.  You will be credited of course.

antd

  • *
  • Posts: 49
    • View Profile
Re: FFVII Battle Check discrepancy ?
« Reply #5 on: 2013-03-18 13:19:09 »
Thanks for that.

nfitc1

  • *
  • Posts: 3013
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: FFVII Battle Check discrepancy ?
« Reply #6 on: 2013-03-18 14:38:42 »
The byte value at 0x5CB250 (0x1CA650) is the lower value. I suppose it can be 0 without problems. The encounter rate will be set to this if the combined values of enemy aways is greater or equal to the enemy lure value plus the traditional encounter rate of 16 ( If E_Lure + 16 < E_Away then encounter rate becomes 2 ).

The byte value at 0x5CB288 (0x1CA688) is the max value. If the encounter rate is greater than the value at 0x5CB27F (0x1CA67F) then it gets set to the value at 0x5CB288.

The encounter rate then becomes Enemy Lure magnitude + 16 - Enemy Away magnitude.

The magnitude of Enemy Lure/Enemy Away is cumulative from all players. If Cloud has a mastered Enemy Away and Barret has a mastered Enemy Lure and they are both in the active party then they will effectively cancel each other out. If Cloud has a level 1 Enemy Away and Barret has a level 1 Enemy Away then you'll get the full effect of the combination of both. It's not based on compound percentage. It's a fixed addition of percentage. (7/16 + 7/16, not 7/16 * 7/16).
« Last Edit: 2013-03-18 15:55:40 by NFITC1 »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: FFVII Battle Check discrepancy ?
« Reply #7 on: 2013-03-18 14:58:12 »
Cheers!   8)