Sign in to follow this  
Followers 0
seibaby

Patch: Master Thief

6 posts in this topic

Hey, looks like it's patch day errday, err... today.

Nowea suggested. BTB approved. I coded. Here you go: Master Thief!

What this does is allow a character's Speed to raise the chance of gaining the rare Steal from a successful attempt.

Formula is (Chance rare item slot will be checked) = Speed / 256.

 

Code:

 

	
;BNW Steal Function
;mod: Speed affects rare steal chance (Speed / 256)
org $C2399E
stealFunction:
LDA $05,S       ;Attacker
TAX
LDA #$01
STA $3401       ;= 1 (Sets message to "Doesn't have anything!")
CPX #$08        ;Check if attacker is monster
BCS enemySteal  ;Branch if monster
REP #$20        ;Set 16-bit accumulator
LDA $3308,Y     ;Target's stolen items
INC A
SEP #$20        ;Set 8-bit Accumulator
BEQ failSteal   ;Fail to steal if no items
INC $3401       ;now = 2 (Sets message to "Couldn't steal!!")
LDA $3B19,X     ;Attacker's Speed
ASL A           ;Double it
BCS .success    ;Automatically steal if Speed >= 128
ADC #$70        ;Add 112
BCS .success    ;Automatically Steal if > 255
STA $EE         ;save StealValue
JSR $4B5A       ;Random: 0 to 255
BRA .skip       ;Branch past unused code
NOP #11
.skip
CMP $EE
BCS failSteal   ;Fail to steal if the random number >= StealValue
.success
PHY
JSR $4B5A       ;Random: 0 to 255
CMP $3B19,X     ;Chance for Rare = Attacker's Speed / 256
BCC .rare       ;branch so Rare steal slot will be checked
INY             ;Check the 2nd [Common] slot
.rare
LDA $3308,Y     ;Target's stolen item
PLY
CMP #$FF        ;If no item
BEQ failSteal   ;Fail to steal
STA $2F35       ;save Item stolen for message purposes in
                ;parameter 1, bottom byte
STA $32F4,X     ;Store in "Acquired item"
LDA $3018,X
TSB $3A8C       ;flag character to have any applicable item in
                ;$32F4,X added to inventory when turn is over.
LDA #$FF
STA $3308,Y     ;Set to no item to steal
STA $3309,Y     ;in both slots
INC $3401       ;now = 3 (Sets message to "Stole #whatever ")
RTS

org $C23A01
failSteal:
org $C23A09
enemySteal:
	

 

Edited by seibaby
4

Share this post


Link to post
Share on other sites

Ooh, I understood that code! My ASM is getting better. Getting some ideas of what to look for in other games.
Interesting that for a X/256 chance, it doesn't need to divide at all; it just compares X to (0 ... 255). Now to learn where my game's RNG is located.

Oh, didn't mean to trail off-topic. This looks really fun!

0

Share this post


Link to post
Share on other sites

Man, I should have named this Pickpocket instead, since it totally doesn't grant a 100% Rare Steal. Is it too late to change it? :kappa:

1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0