Author Topic: Enemy Skill Oversight Fixed.  (Read 635 times)

DLPB

  • No life
  • *
  • Posts: 9193
  • Karma: 288
  • For I realized that God's a young man, too.
    • View Profile
Enemy Skill Oversight Fixed.
« on: 2018-02-07 01:14:13 »
I'm not really sure if I need to preserve edi,ebx,esi here.  Didn't check.

Still this nifty replacement I've made for the Enemy Skill mask ensures that, from now on, the enemy skills MISSING from the total are what count, not the ones that are PRESENT.  See, originally, if one of your characters had a full enemy skill set, it would then stop all other enemy skills from learning all abilities. And if one of the materias had, say, Frog Song, then none of the others without it would gain it either.

Code: [Select]
Procedure CreateEnemySkillMask5CFB93; stdcall;
Begin

asm
push ebx
push esi
push edi

xor edi,edi
mov esi,$00FFFFFF

mov ecx,[esp+$10] //Starting address of character materia

@START:
xor ebx,ebx


@LABEL1:

cmp ebx,8
je @Label5

test edi,edi
jne @Label3
  mov eax,[ecx+ebx*4+$40] // Retrieve Materia ID and AP in Weapon slot.
  jmp @Label4
@Label3:
  mov eax,[ecx+ebx*4+$60] // Retrieve Materia ID and AP in Armour slot.
@Label4:

cmp al,$FF //If no materia in slot, then jump to next slot.
je @Label2

xor edx,edx
mov dl,al
imul edx,edx,$14
mov dl,[edx+$DBDF6D] //retrieve formula ID for materia
and dl,$F
cmp dl,7  //materia is Enemy Skill
jne @Label2

shr eax,8
and esi,eax
or esi,$80000000


@LABEL2:
inc ebx

jmp @Label1

  @LABEL5:
  test edi,edi
  jne @End
    inc edi
    jmp @START

@END:

mov eax,esi

pop edi
pop esi
pop ebx
end;

End;


Not rigorously tested yet, but seems to work.

NFITC1

  • No life
  • *
  • Posts: 2830
  • Karma: 71
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Enemy Skill Oversight Fixed.
« Reply #1 on: 2018-02-07 19:37:11 »
What's the purpose of the
Code: [Select]
or esi, $80000000? Other than that it looks fine.

DLPB

  • No life
  • *
  • Posts: 9193
  • Karma: 288
  • For I realized that God's a young man, too.
    • View Profile
Re: Enemy Skill Oversight Fixed.
« Reply #2 on: 2018-02-07 19:49:19 »
For some reason, the enemy skills learned address (9A8DDC for Member 0) requires that byte to be $80.  If it isn't, the address isn't changed.  Perhaps there is a check for it somewhere.  If it's 00, then I assume the game ignores writing to 9A8DDC.  [Edit.  005DB061 is where the check is made.  The originally game sets the byte to 0x80, but any non zero should work. If 00 then Enemy Skill is not equipped, you see.  There is a further check after that, which I am unsure of.]

It also seems to me that the mask check (xor) can be ignored?  All it will do then is ALWAYS update on battle victory when E Skill is in a slot, rather than what it does now- check if any change from e skill at battle start.

I've also disabled the victory E Skill update and put the update in battle exit (so that the E skill change will always be reflected).

« Last Edit: 2018-02-08 02:21:44 by DLPB »

DLPB

  • No life
  • *
  • Posts: 9193
  • Karma: 288
  • For I realized that God's a young man, too.
    • View Profile
Re: Enemy Skill Oversight Fixed.
« Reply #3 on: 2018-02-07 19:55:40 »
I've also added the "if escape, still add kills"  to battle exit.
Code: [Select]
Procedure AddKillsOnEscape; stdcall;
Begin

asm
push ebx

mov dx,[$9AB0C2]
and edx,$C // if escape (04 or 08)
test edx,edx
je @End

xor edx,edx
xor ebx,ebx

@START:

mov eax,ebx
inc ebx

cmp eax,2
ja @End

xor edx,edx
mov dl,[eax+$DC0230] // retrieve ID in slot 0-2
cmp dl,$FF
je @Start

imul eax,eax,$34
mov al,[eax+$9A8DBF]
and eax,$000000FF

imul edx,edx,$84
add edx,$DBFD8C + $24  //Character kills.

xor ecx,ecx
mov cx,word ptr [edx]
add ecx,eax
  cmp ecx,$FFFF
  jna @Label1
    mov ecx,$FFFF
  @Label1:

mov word ptr [edx],cx

jmp @Start

@END:

pop ebx
end;

Ordinary escape is given value of 04.  Seems Smoke Bomb (and possibly other materia/item escapes) are given 08.  I am going to check what value is given when the "no reward screen" field opcode is operating.

Edit.  It uses 0x20...  so normal victory flag when the "no reward" is in use.  I'm going to need to disable the normal victory kill update as well and always force it on exit.
« Last Edit: 2018-02-08 03:06:48 by DLPB »

Kefka

  • Crazy poster
  • *
  • Posts: 143
  • Karma: 8
    • View Profile
Re: Enemy Skill Oversight Fixed.
« Reply #4 on: 2018-02-08 04:53:19 »
This is most interesting. So does that mean it is now possible to keep any learned enemy skills even after running from a battle? This is something I've been wishing for for a long time, thanks a ton! I'll definitely give this a try soon.

DLPB

  • No life
  • *
  • Posts: 9193
  • Karma: 288
  • For I realized that God's a young man, too.
    • View Profile
Re: Enemy Skill Oversight Fixed.
« Reply #5 on: 2018-02-08 05:01:10 »
Yeah, it will fix the issue of them not saving.   8-)
« Last Edit: 2018-02-08 05:18:21 by DLPB »

Kefka

  • Crazy poster
  • *
  • Posts: 143
  • Karma: 8
    • View Profile
Re: Enemy Skill Oversight Fixed.
« Reply #6 on: 2018-02-08 14:30:51 »
Quick question though: Since I'm not a programmer and can't really make much sense of the code you posted, could you tell me what I need to change with a hex editor (I'm assuming this is in the exe?) and where exactly?

DLPB

  • No life
  • *
  • Posts: 9193
  • Karma: 288
  • For I realized that God's a young man, too.
    • View Profile
Re: Enemy Skill Oversight Fixed.
« Reply #7 on: 2018-02-08 18:20:17 »
youll have to wait for reunion r06. it can't be added easily without my dll. it's a mandatory fux there along with many others.