https://drive.google.com/file/d/1uTrUOsoFmSDj6OEUV4SbCEUFPw1N5SRE/view?usp=sharing
Here's a new beta patch. All I've verified right now is that it doesn't crash immediately, so heads up. The goal of this patch is to shuffle around how resistances are calculated with attacks with multiple elements. Basically what it does is look at each element and do a rolling sum:
1) If it's absorbed, the attack is absorbed and the rest skipped.
2) If it's nulled, add 3 to the resist count.
3) If it's resisted, add 2 to the resist count.
4) If it's one they're weak against, subtract 2 from the resist count.
Then, if 2 or more elements were used in the attack, the resist count is cut in half, rounded down. Then:
1) If the count is negative, take double damage.
2) If the count is 3 or greater, take no damage.
3) If the count is 1 or 2, take half damage.
For some concrete examples:
Fire+wind attack (Merton):
Null fire, neutral wind : resist
Null fire, weak wind : resist
Absorb fire: absorb
Resist fire resist wind: resist
Resist fire neutral wind: resist
Null fire resist wind: resist
Code:
;xkas 0.06
hirom
;header
!freespace = $C0FD40 ;patch to this offset
org $C20B9D
JML newfunc2
returnfromnewfunc2:
NOP
NOP
;hook
org $C20BD3
LDA $11A1
BEQ done
LDA $3BCC,Y ;(Absorbed elements)
BIT $11A1
BEQ nullstart ;(branch if none are used in attack)
LDA $F2
EOR #$01
STA $F2 ;(toggle healing flag)
BRA done
nullstart:
PHX ; 17 bytes so far
LDX #$00
LDA $3BCD,Y ;(Nullified elements)
AND $11A1
null:
BEQ resiststart ;(branch if none are used in attack or left to check)
LSR
BCC null ;(move to next ele if this one isn't nulled)
INX
INX
INX
BRA null ;(counted this nulled element, 34 bytes so far)
resiststart:
LDA $3BE1,Y ;(Resisted elements)
AND $11A1
resist:
BEQ weakstart ;(branch if none are used in attack or left to check)
LSR
BCC resist ;(move to next ele if this one isn't resisted)
INX
INX
BRA resist ;(counted this resisted element, 48 bytes)
weakstart:
LDA $3BE0,Y ;(Weak elements)
AND $11A1
weak:
BEQ damage ;(branch if none are used in attack or left to check)
LSR
LSR
BCC weak ;(move to next ele if this one isn't weak)
DEX
BRA weak ;(counted this weak element, 62 bytes)
damage:
JSL newfunc
PLX
done:
LDA $11A9 ; (get attack special effect, 69 (nice) bytes)
CMP #$04
BNE skip ; (Branch if not Atma Weapon)
JSR $0E39 ; (Atma Weapon damage modification)
skip:
JSR $0C2D
PLP
RTS
org !freespace
newfunc:
PHY ; (stack is y)
LDY #$00
LDA $11A1
elecount:
BEQ continue ;(no eles left, 8 bytes)
LSR
BCC elecount ;(this ele isn't used)
INY ; (12 bytes so far)
BRA elecount
continue:
TXA
BPL proper ; if it's negative, we're takin double
ASL $F0
ROL $F1
BRA done2
proper:
TYA ; at this point, A is the element count, X is the resistance total. We are gonna do some bullshit
CMP #$02 ; compare to 2, carry is set if element count >= 2
BCC elehandled
TXA ; A and X are resistance totals now
LSR
TAX ; finished manipulating
elehandled:
TXA ; :^) 21 bytes
CMP #$03 ; if >= 2, we're blocking
BCC resistcheck
STZ $F0
STZ $F1 ; 35
resistcheck:
CMP #$02 ; if == 1, we resist
BNE done2
LSR $F1
ROR $F0
done2:
PLY
RTL
newfunc2:
LDA $3EE4,Y
ASL
BMI petrified
JML returnfromnewfunc2
petrified:
STZ $F0
STZ $F1
JML done
