Users browsing this thread: 1 Guest(s)
Steal formula

#2
Posts: 3,971
Threads: 279
Thanks Received: 238
Thanks Given: 58
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
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
  Find
Quote  
[-] The following 1 user says Thank You to madsiur for this post:
  • Tenkarider (06-29-2014)



Messages In This Thread
Steal formula - by Tenkarider - 06-29-2014, 11:47 AM
RE: Steal formula - by madsiur - 06-29-2014, 12:21 PM
RE: Steal formula - by Tenkarider - 06-29-2014, 01:43 PM
RE: Steal formula - by Xenovant - 06-29-2014, 06:29 PM
RE: Steal formula - by Tenkarider - 06-29-2014, 09:17 PM
RE: Steal formula - by wolfokami321 - 11-11-2014, 11:40 AM
RE: Steal formula - by Tenkarider - 11-11-2014, 02:25 PM
RE: Steal formula - by ShinMrKarate - 11-11-2014, 11:21 PM
RE: Steal formula - by Tenkarider - 11-12-2014, 11:23 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite