Resistances in MM6-MM8

The role-playing games (I-X) that started it all and the various spin-offs (including Dark Messiah).
User avatar
Anubis
War Dancer
War Dancer
Posts: 373
Joined: 08 Sep 2011
Location: Canada

Resistances in MM6-MM8

Unread postby Anubis » 17 Aug 2020, 21:09

Novi asked a good question in the Might & Magic discord earlier today:

If a character had -60 Resistance, how does that work? Would that be similar to a character having 0 resistance?

Tomsod
War Dancer
War Dancer
Posts: 353
Joined: 31 Jul 2020

Re: Resistances in MM6-MM8

Unread postby Tomsod » 17 Aug 2020, 23:47

Good question! Unfortunately I can't open the disassembly right now, but logically it should be. One can't get worse than not having any resistance: there isn't any code to increase elemental damage (only to decrease if you resist), and one certainly can't get a status condition twice. But of course, the game could be buggy, so it's theoretically possible, albeit unlikely, that resistance is treated as unsigned somewhere, in which case negative resistance would equal near-immunity due to overflow.

cthscr
Golem
Golem
Posts: 618
Joined: 12 Jan 2020

Re: Resistances in MM6-MM8

Unread postby cthscr » 18 Aug 2020, 15:14

First, practical advice:

Code: Select all

Party[0].Resistances[0].Base=-60
Party[1].Resistances[0].Bonus=-60
evt.CastSpell(6, 3, 7, Party.X - 100, Party.Y, Party.Z, Party.X, Party.Y, Party.Z)
Now, speaking about MM8. [Base or Bonus] Resistance is two bytes. Base resistance is unsigned so -60 will be 65495 that will be equaled to immunity if your character is Lich (or other class name with id=1). Otherwise you should get 1 damage.
Bonus Resistance is (surprisingly) unsigned too. Should work the same way because CalcDamageToPlayer uses GetResistance.
MMExtension considers Resistance to be signed.

Tomsod
War Dancer
War Dancer
Posts: 353
Joined: 31 Jul 2020

Re: Resistances in MM6-MM8

Unread postby Tomsod » 18 Aug 2020, 16:53

There we go! Although I don't think the player can legitimately get negative base or bonus resistance values. The only times I remember having negative resistances was when using certain artifacts. Have you tried casting fireball on yourself while wielding the Trident of Rulership?

cthscr
Golem
Golem
Posts: 618
Joined: 12 Jan 2020

Re: Resistances in MM6-MM8

Unread postby cthscr » 18 Aug 2020, 18:56

Resistance = Player.Resistance.Base + CalcStatBonusByMagic + GM Leather Bonus + BaseClassResistance (*) + CalcStatBonusByItems
(*) If BaseClassResistance == 65000, Resistance is equal to 65000 regardless of other components.

Code: Select all

...
                 mov     ecx, esi
                 call    sub_48DD6B      ; GetResistance
                 mov     edi, eax
loc_48CDEE:
                 mov     ebx, [ebp+arg_4]
                 mov     ecx, esi
                 mov     [ebp+arg_4], ebx
                 call    sub_48F54A      ; GetClass
                 cmp     eax, 1
                 jnz     short loc_48CE0F
                 cmp     edi, 0FDE8h
                 jl      short loc_48CE0F
                 xor     eax, eax
                 jmp     loc_48CEDF
; ---------------------------------------------------------------------------
loc_48CE0F:
                 test    edi, edi
                 jz      short loc_48CE70
                 mov     ecx, esi
                 call    sub_48C633      ; GetLuck
                 push    eax
                 mov     ecx, esi
                 call    sub_48E18E      ; GetStatisticEffect
                 lea     edi, [eax+edi+1Eh]
                 cmp     edi, 1
                 jge     short loc_48CE2E
                 xor     edi, edi
                 inc     edi
loc_48CE2E:                             ; CODE XREF: sub_48CDA6+83↑j
                 call    sub_4D99F2      ; Rand
                 cdq
                 idiv    edi
                 cmp     edx, 1Eh
                 jl      short loc_48CE70
                 sar     ebx, 1
                 mov     [ebp+arg_4], ebx
...
Since it's 'jz' after 'test edi, edi', small negative resistance can bring you positive effect if you're lucky. -60 though will bring us fail at the first check, so it will be as if resistance is 0.


Return to “Might and Magic”

Who is online

Users browsing this forum: Google [Bot] and 2 guests