Users browsing this thread: 1 Guest(s)
Steal formula
It is well documented and fun to play with:
Code:
C2/399E: A3 05 LDA $05,S (Attacker)
C2/39A0: AA TAX
C2/39A1: A9 01 LDA #$01
C2/39A3: 8D 01 34 STA $3401 (=1) (Sets message to "Doesn't have anything!")
C2/39A6: E0 08 CPX #$08 (Check if attacker is monster)
C2/39A8: B0 5F BCS $3A09 (Branch if monster)
C2/39AA: C2 20 REP #$20 (Set 16-bit accumulator)
C2/39AC: B9 08 33 LDA $3308,Y (Target's stolen items)
C2/39AF: 1A INC
C2/39B0: E2 21 SEP #$21 (Set 8-bit Accumulator AND Carry Flag)
C2/39B2: F0 4D BEQ $3A01 (Fail to steal if no items)
C2/39B4: EE 01 34 INC $3401 (now = 2) (Sets message to "Couldn't steal!!")
C2/39B7: BD 18 3B LDA $3B18,X (Attacker's Level)
C2/39BA: 69 32 ADC #$32 (adding 51, since Carry Flag was set)
C2/39BC: B0 1A BCS $39D8 (Automatically steal if level >= 205)
C2/39BE: F9 18 3B SBC $3B18,Y (Subtract Target's Level, along with an extra 1 because
Carry Flag is unset at this point. Don't worry; this
cancels out with the extra 1 from C2/39BA.)
(StealValue = [attacker level + 51] - [target lvl + 1]
= Attacker level + 50 - Target level )
C2/39C1: 90 3E BCC $3A01 (Fail to steal if StealValue < 0)
C2/39C3: 30 13 BMI $39D8 (Automatically steal if StealValue >= 128)
C2/39C5: 85 EE STA $EE (save StealValue)
C2/39C7: BD 45 3C LDA $3C45,X
C2/39CA: 4A LSR
C2/39CB: 90 02 BCC $39CF (If no sneak ring)
C2/39CD: 06 EE ASL $EE (Double value)
C2/39CF: A9 64 LDA #$64
C2/39D1: 20 65 4B JSR $4B65 (Random: 0 to 99)
C2/39D4: C5 EE CMP $EE
C2/39D6: B0 29 BCS $3A01 (Fail to steal if the random number >= StealValue)
C2/39D8: 5A PHY
C2/39D9: 20 5A 4B JSR $4B5A (Random: 0 to 255)
C2/39DC: C9 20 CMP #$20
C2/39DE: 90 01 BCC $39E1 (branch 1/8 of the time, so Rare steal slot
will be checked)
C2/39E0: C8 INY (Check the 2nd [Common] slot 7/8 of the time)
C2/39E1: B9 08 33 LDA $3308,Y (Target's stolen item)
C2/39E4: 7A PLY
C2/39E5: C9 FF CMP #$FF (If no item)
C2/39E7: F0 18 BEQ $3A01 (Fail to steal)
C2/39E9: 8D 35 2F STA $2F35 (Item stolen, for message purposes)
C2/39EC: 9D F4 32 STA $32F4,X (Store in "Acquired item")
C2/39EF: BD 18 30 LDA $3018,X
C2/39F2: 0C 8C 3A TSB $3A8C (flag character to have any applicable item in
$32F4,X added to inventory when turn is over.)
C2/39F5: A9 FF LDA #$FF
C2/39F7: 99 08 33 STA $3308,Y (Set to no item to steal)
C2/39FA: 99 09 33 STA $3309,Y (in both slots)
C2/39FD: EE 01 34 INC $3401 (now = 3) (Sets message to "Stole #whatever ")
C2/3A00: 60 RTS
« Next Oldest | Next Newest »
|
||||
Users browsing this thread: 1 Guest(s)