You are not logged in.
Pages: 1
Hey guys, maybe you can help me. I've been pulling my hair out over here trying to figure out why on earth I can't get this to work.
I'm trying to add berries, and so far they have been working-- except for the status healing ones.
In the .checkItemType section, I added
cp a,PECHA_BERRY
jp nc,.cureStatusAilment
Which should be working, since the ones above Pecha Berry are status healing items and it appears to be jumping like it is supposed to.
When you get to .cureStatusAilment, there is:
.cureStatusAilment
ld bc,4
add hl,bc ; hl now points to status
ld a,[wcf91]
ld bc,$f008
cp a,ANTIDOTE
jr z,.checkMonStatus
etc. Where it loads bc with a message to show if it is successful and a condition to check for.
So I just jumped in the middle and added checks in the right places. So after the jump for Antidote, I added a check for Pecha Berry followed by another jump, then let it go on loading bc with the value for Burn Heal and went from there.
Well, for some reason, Antidote works but Pecha Berry makes the game freeze up, and if I manage to get it to stop freezing, I see that it has corrupted just about everything to do with the Pokémon I used it on.
My next thought was to do what the game does with some of the other instances of Duplicate effects. I tried making it so it subtracts the right amount from "a" so that the berries would match the other healing items. Exact same thing. Real items work fine, berries crash.
I tried looking at the routine that prints the message saying they were healed of whatever condition. Can't find anything there that would be making it crash, it's just checking the message ID that was loaded into bc earlier, which is still the right value.
I'm getting extremely frustrated here because I've been checking everything I can think of, and I can't understand why it won't work. Oran Berries and Sitrus Berries are healing HP like they are supposed to, and Leppa Berry is healing PP like it's supposed to, but I can't figure out why Pecha Berry and the other status berries choose to crash instead.
I'm sure it's going to be something super simple and I'll feel like an idiot when someone points it out, but for now I'm out of ideas.
EDIT: When it "freezes up" I guess it isn't technically frozen. It isn't giving an invalid opcode or anything. If I hold down speed-up and wait a long time, it will claime the Pokémon recovered a glitched amount of HP and everything will be corrupted.
EDIT2: Ugg, I take that back. On closer inspection, Oran Berry is healing HP without crashing, but it's healing more HP than I told it to. WTF Gamefreak. Why make your code so stupid.
Last edited by Luna (2015-03-15 03:41:13)
I am not very active on this forum. I only pop in from time to time.
Offline
I am not sure why this would cause your problem, but you do not need to touch the .checkItemType section. As the "; fall through if it's one of the status-specifc healing items" comment says, it falls through for items that heal a specific status.
If I'm not mistaken, you only need to add two lines to ItemUseMedicine to get this to work.
cp a,PECHA_BERRY
jr z,.checkMonStatus
.cureStatusAilment
ld bc,4
add hl,bc ; hl now points to status
ld a,[wcf91]
ld bc,$f008
cp a,ANTIDOTE
jr z,.checkMonStatus
cp a,PECHA_BERRY
jr z,.checkMonStatus
ld bc,$f110
cp a,BURN_HEAL
jr z,.checkMonStatus
I hope this helps.
Last edited by YamaArashi (2015-03-15 03:48:51)
Offline
I am not sure why this would cause your problem, but you do not need to touch the .checkItemType section. As the "; fall through if it's one of the status-specifc healing items" comment says, it falls through for items that heal a specific status.
If I'm not mistaken, you only need to add two lines to ItemUseMedicine to get this to work.
.cureStatusAilment ld bc,4 add hl,bc ; hl now points to status ld a,[wcf91] ld bc,$f008 cp a,ANTIDOTE jr z,.checkMonStatus [b]cp a,PECHA_BERRY jr z,.checkMonStatus[/b] ld bc,$f110 cp a,BURN_HEAL jr z,.checkMonStatus
I hope this helps.
Yeah, no. It falls through because they are lower item IDs that haven't been checked for. There are other checks above it that would cause it to jump to the wrong place if I left that alone, because the Berry IDs are higher than the ones it is checking for.
The line that says:
cp a, REVIVE
jr nc, .healHP
would cause them to jump to healing HP. So above that, I put a check to get it to jump to the status ailments before it had a chance to check for Revives and jump to the wrong place.
Thanks for trying to help though.
I am not very active on this forum. I only pop in from time to time.
Offline
In the .checkItemType section, I added
cp a,PECHA_BERRY
jp nc,.cureStatusAilment
Can you show the whole block?
Last edited by comet (2015-03-15 04:03:01)
Offline
Yeah, no. It falls through because they are lower item IDs that haven't been checked for. There are other checks above it that would cause it to jump to the wrong place if I left that alone, because the Berry IDs are higher than the ones it is checking for.
The line that says:
cp a, REVIVE
jr nc, .healHPwould cause them to jump to healing HP. So above that, I put a check to get it to jump to the status ailments before it had a chance to check for Revives and jump to the wrong place.
Thanks for trying to help though.
True. I didn't think about the fact that you would be adding the ID outside the range of the usual status items. It seems to me that if you added those lines from your first post, the lines I posted would work. Is that what you did?
Last edited by YamaArashi (2015-03-15 04:08:33)
Offline
Here is the entire code for ItemUseMedicine
That way you can see all the changes I made to it, since Oran Berry was healing more than 10HP for some reason as well.
ItemUseMedicine: ; dabb (3:5abb)
ld a,[wPartyCount]
and a
jp z,.emptyParty
ld a,[wWhichPokemon]
push af
ld a,[wcf91]
push af
ld a,$01
ld [wd07d],a ; item use party menu
ld a,$ff
ld [wUpdateSpritesEnabled],a
ld a,[wd152]
and a ; using Softboiled?
jr z,.notUsingSoftboiled
; if using softboiled
call GoBackToPartyMenu
jr .getPartyMonDataAddress
.emptyParty
ld hl,.emptyPartyText
xor a
ld [wcd6a],a ; item use failed
jp PrintText
.emptyPartyText
text "You don't have"
line "any #MON!"
prompt
.notUsingSoftboiled
call DisplayPartyMenu
.getPartyMonDataAddress
jp c,.canceledItemUse
ld hl,wPartyMons
ld bc,wPartyMon2 - wPartyMon1
ld a,[wWhichPokemon]
call AddNTimes
ld a,[wWhichPokemon]
ld [wcf06],a
ld d,a
ld a,[wcf91]
ld e,a
ld [wd0b5],a
pop af
ld [wcf91],a
pop af
ld [wWhichPokemon],a
ld a,[wd152]
and a ; using Softboiled?
jr z,.checkItemType
; if using softboiled
ld a,[wWhichPokemon]
cp d ; is the pokemon trying to use softboiled on itself?
jr z,ItemUseMedicine ; if so, force another choice
.checkItemType
ld a,[wcf91]
cp a,SWEG_BERRY
jp z,.useVitamin
cp a,PECHA_BERRY
jp nc,.cureStatusAilment
cp a,ORAN_BERRY
jp nc,.healHP
cp a,REVIVE
jp nc,.healHP ; if it's a Revive or Max Revive
cp a,FULL_HEAL
jp z,.cureStatusAilment ; if it's a Full Heal
cp a,HP_UP
jp nc,.useVitamin ; if it's a vitamin or Rare Candy
cp a,FULL_RESTORE
jp nc,.healHP ; if it's a Full Restore or one of the potions
; fall through if it's one of the status-specifc healing items
.cureStatusAilment
ld bc,4
add hl,bc ; hl now points to status
ld a,[wcf91]
ld bc,$f008
cp a,ANTIDOTE
jr z,.checkMonStatus
cp a,PECHA_BERRY
jr z,.checkMonStatus
ld bc,$f110
cp a,BURN_HEAL
jr z,.checkMonStatus
cp a,RAWST_BERRY
jr z,.checkMonStatus
ld bc,$f220
cp a,ICE_HEAL
jr z,.checkMonStatus
cp a,ASPEAR_BERRY
jr z,.checkMonStatus
ld bc,$f307
cp a,AWAKENING
jr z,.checkMonStatus
cp a,CHESTO_BERRY
jr z,.checkMonStatus
ld bc,$f440
cp a,PARLYZ_HEAL
jr z,.checkMonStatus
cp a,CHERI_BERRY
jr z,.checkMonStatus
ld bc,$f6ff ; Full Heal or Lum Berry
.checkMonStatus
ld a,[hl] ; pokemon's status
and c ; does the pokemon have a status ailment the item can cure?
jp z,.healingItemNoEffect
; if the pokemon has a status the item can heal
xor a
ld [hl],a ; remove the status ailment in the party data
ld a,b
ld [wd07d],a ; the message to display for the item used
ld a,[wPlayerMonNumber]
cp d ; is pokemon the item was used on active in battle?
jp nz,.doneHealing
; if it is active in battle
xor a
ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data
push hl
ld hl,W_PLAYERBATTSTATUS3
res BadlyPoisoned,[hl] ; heal Toxic status
pop hl
ld bc,30
add hl,bc ; hl now points to party stats
ld de,wBattleMonMaxHP
ld bc,10
call CopyData ; copy party stats to in-battle stat data
predef DoubleOrHalveSelectedStats
jp .doneHealing
.healHP
inc hl ; hl = address of current HP
ld a,[hli]
ld b,a
ld [wHPBarOldHP+1],a
ld a,[hl]
ld c,a
ld [wHPBarOldHP],a ; current HP stored at wHPBarOldHP (2 bytes, big-endian)
or b
jr nz,.notFainted
.fainted
ld a,[wcf91]
cp a,REVIVE
jr z,.updateInBattleFaintedData
cp a,MAX_REVIVE
jr z,.updateInBattleFaintedData
jp .healingItemNoEffect
.updateInBattleFaintedData
ld a,[W_ISINBATTLE]
and a
jr z,.compareCurrentHPToMaxHP
push hl
push de
push bc
ld a,[wcf06]
ld c,a
ld hl,wPartyFoughtCurrentEnemyFlags
ld b,$02
predef FlagActionPredef
ld a,c
and a
jr z,.next
ld a,[wcf06]
ld c,a
ld hl,wPartyGainExpFlags
ld b,$01
predef FlagActionPredef
.next
pop bc
pop de
pop hl
jr .compareCurrentHPToMaxHP
.notFainted
ld a,[wcf91]
cp a,REVIVE
jp z,.healingItemNoEffect
cp a,MAX_REVIVE
jp z,.healingItemNoEffect
.compareCurrentHPToMaxHP
push hl
push bc
ld bc,32
add hl,bc ; hl now points to max HP
pop bc
ld a,[hli]
cp b
jr nz,.skipComparingLSB ; no need to compare the LSB's if the MSB's don't match
ld a,[hl]
cp c
.skipComparingLSB
pop hl
jr nz,.notFullHP
.fullHP ; if the pokemon's current HP equals its max HP
ld a,[wcf91]
cp a,FULL_RESTORE
jp nz,.healingItemNoEffect
inc hl
inc hl
ld a,[hld] ; status ailment
and a ; does the pokemon have a status ailment?
jp z,.healingItemNoEffect
ld a,FULL_HEAL
ld [wcf91],a
dec hl
dec hl
dec hl
jp .cureStatusAilment
.notFullHP ; if the pokemon's current HP doesn't equal its max HP
xor a
ld [wd083],a
ld [wc02a],a
push hl
push de
ld bc,32
add hl,bc ; hl now points to max HP
ld a,[hli]
ld [wHPBarMaxHP+1],a
ld a,[hl]
ld [wHPBarMaxHP],a ; max HP stored at wHPBarMaxHP (2 bytes, big-endian)
ld a,[wd152]
and a ; using Softboiled?
jp z,.notUsingSoftboiled2
; if using softboiled
ld hl,wHPBarMaxHP
ld a,[hli]
push af
ld a,[hli]
push af
ld a,[hli]
push af
ld a,[hl]
push af
ld hl,wPartyMon1MaxHP
ld a,[wWhichPokemon]
ld bc,wPartyMon2 - wPartyMon1
call AddNTimes
ld a,[hli]
ld [wHPBarMaxHP + 1],a
ld [H_DIVIDEND],a
ld a,[hl]
ld [wHPBarMaxHP],a
ld [H_DIVIDEND + 1],a
ld a,5
ld [H_DIVISOR],a
ld b,2 ; number of bytes
call Divide ; get 1/5 of max HP of pokemon that used Softboiled
ld bc,wPartyMon1HP - wPartyMon1MaxHP
add hl,bc ; hl now points to LSB of current HP of pokemon that used Softboiled
; subtract 1/5 of max HP from current HP of pokemon that used Softboiled
ld a,[H_QUOTIENT + 3]
push af
ld b,a
ld a,[hl]
ld [wHPBarOldHP],a
sub b
ld [hld],a
ld [wHPBarNewHP],a
ld a,[H_QUOTIENT + 2]
ld b,a
ld a,[hl]
ld [wHPBarOldHP+1],a
sbc b
ld [hl],a
ld [wHPBarNewHP+1],a
hlCoord 4, 1
ld a,[wWhichPokemon]
ld bc,2 * 20
call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled
ld a,(SFX_02_3d - SFX_Headers_02) / 3
call PlaySoundWaitForCurrent ; play sound
ld a,[hFlags_0xFFF6]
set 0,a
ld [hFlags_0xFFF6],a
ld a,$02
ld [wHPBarType],a
predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled
ld a,[hFlags_0xFFF6]
res 0,a
ld [hFlags_0xFFF6],a
pop af
ld b,a ; store heal amount (1/5 of max HP)
ld hl,wHPBarOldHP + 1
pop af
ld [hld],a
pop af
ld [hld],a
pop af
ld [hld],a
pop af
ld [hl],a
jr .addHealAmount
.notUsingSoftboiled2
ld a,[wcf91]
cp a,SODA_POP
ld b,60 ; Soda Pop heal amount
jr z,.addHealAmount
ld b,80 ; Lemonade heal amount
jr nc,.addHealAmount
cp a,FRESH_WATER
ld b,50 ; Fresh Water heal amount
jr z,.addHealAmount
cp a,SITRUS_BERRY
ld b,30
jr z,.addHealAmount
cp a,ORAN_BERRY
ld b,10
jr z,.addHealAmount
cp a,SUPER_POTION
ld b,200 ; Hyper Potion heal amount
jr c,.addHealAmount
ld b,50 ; Super Potion heal amount
jr z,.addHealAmount
ld b,20 ; Potion heal amount
.addHealAmount
pop de
pop hl
ld a,[hl]
add b
ld [hld],a
ld [wHPBarNewHP],a
ld a,[hl]
ld [wHPBarNewHP+1],a
jr nc,.noCarry
inc [hl]
ld a,[hl]
ld [wHPBarNewHP + 1],a
.noCarry
push de
inc hl
ld d,h
ld e,l ; de now points to current HP
ld hl,33
add hl,de ; hl now points to max HP
ld a,[wcf91]
cp a,REVIVE
jr z,.setCurrentHPToHalfMaxHP
ld a,[hld]
ld b,a
ld a,[de]
sub b
dec de
ld b,[hl]
ld a,[de]
sbc b
jr nc,.setCurrentHPToMaxHp ; if current HP exceeds max HP after healing
ld a,[wcf91]
cp a,HYPER_POTION
jr c,.setCurrentHPToMaxHp ; if using a Full Restore or Max Potion
cp a,MAX_REVIVE
jr z,.setCurrentHPToMaxHp ; if using a Max Revive
jr .updateInBattleData
.setCurrentHPToHalfMaxHP
dec hl
dec de
ld a,[hli]
srl a
ld [de],a
ld [wHPBarNewHP+1],a
ld a,[hl]
rr a
inc de
ld [de],a
ld [wHPBarNewHP],a
dec de
jr .doneHealingPartyHP
.setCurrentHPToMaxHp
ld a,[hli]
ld [de],a
ld [wHPBarNewHP+1],a
inc de
ld a,[hl]
ld [de],a
ld [wHPBarNewHP],a
dec de
.doneHealingPartyHP ; done updating the pokemon's current HP in the party data structure
ld a,[wcf91]
cp a,FULL_RESTORE
jr nz,.updateInBattleData
ld bc,-31
add hl,bc
xor a
ld [hl],a ; remove the status ailment in the party data
.updateInBattleData
ld h,d
ld l,e
pop de
ld a,[wPlayerMonNumber]
cp d ; is pokemon the item was used on active in battle?
jr nz,.calculateHPBarCoords
; copy party HP to in-battle HP
ld a,[hli]
ld [wBattleMonHP],a
ld a,[hld]
ld [wBattleMonHP + 1],a
ld a,[wcf91]
cp a,FULL_RESTORE
jr nz,.calculateHPBarCoords
xor a
ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data
.calculateHPBarCoords
ld hl,wOAMBuffer + $90
ld bc,2 * 20
inc d
.calculateHPBarCoordsLoop
add hl,bc
dec d
jr nz,.calculateHPBarCoordsLoop
jr .doneHealing
.healingItemNoEffect
call ItemUseNoEffect
jp .done
.doneHealing
ld a,[wd152]
and a ; using Softboiled?
jr nz,.skipRemovingItem ; no item to remove if using Softboiled
push hl
call RemoveUsedItem
pop hl
.skipRemovingItem
ld a,[wcf91]
cp a,FULL_RESTORE
jr c,.playStatusAilmentCuringSound
cp a,FULL_HEAL
jr z,.playStatusAilmentCuringSound
ld a,(SFX_02_3d - SFX_Headers_02) / 3 ; HP healing sound
call PlaySoundWaitForCurrent ; play sound
ld a,[hFlags_0xFFF6]
set 0,a
ld [hFlags_0xFFF6],a
ld a,$02
ld [wHPBarType],a
predef UpdateHPBar2 ; animate the HP bar lengthening
ld a,[hFlags_0xFFF6]
res 0,a
ld [hFlags_0xFFF6],a
ld a,$f7 ; revived message
ld [wd07d],a
ld a,[wcf91]
cp a,REVIVE
jr z,.showHealingItemMessage
cp a,MAX_REVIVE
jr z,.showHealingItemMessage
ld a,$f5 ; standard HP healed message
ld [wd07d],a
jr .showHealingItemMessage
.playStatusAilmentCuringSound
ld a,(SFX_02_3e - SFX_Headers_02) / 3 ; status ailment curing sound
call PlaySoundWaitForCurrent
.showHealingItemMessage
xor a
ld [H_AUTOBGTRANSFERENABLED],a
call ClearScreen
dec a
ld [wUpdateSpritesEnabled],a
call RedrawPartyMenu ; redraws the party menu and displays the message
ld a,1
ld [H_AUTOBGTRANSFERENABLED],a
ld c,50
call DelayFrames
call WaitForTextScrollButtonPress
jr .done
.canceledItemUse
xor a
ld [wcd6a],a ; item use failed
pop af
pop af
.done
ld a,[wd152]
and a ; using Softboiled?
ret nz ; if so, return
call GBPalWhiteOut
call z,GoPAL_SET_CF1C
ld a,[W_ISINBATTLE]
and a
ret nz
jp ReloadMapData
.useVitamin
push hl
ld a,[hl]
ld [wd0b5],a
ld [wd11e],a
ld bc,33
add hl,bc ; hl now points to level
ld a,[hl] ; a = level
ld [W_CURENEMYLVL],a ; store level
call GetMonHeader
push de
ld a,d
ld hl,wPartyMonNicks
call GetPartyMonName
pop de
pop hl
ld a,[wcf91]
cp a,RARE_CANDY
jp z,.useRareCandy
cp a,SWEG_BERRY
jp z,.useRareCandy
push hl
sub a,HP_UP
add a
ld bc,17
add hl,bc
add l
ld l,a
jr nc,.noCarry2
inc h
.noCarry2
ld a,10
ld b,a
ld a,[hl] ; a = MSB of stat experience of the appropriate stat
cp a,100 ; is there already at least 25600 (256 * 100) stat experience?
jr nc,.vitaminNoEffect ; if so, vitamins can't add any more
add b ; add 2560 (256 * 10) stat experience
jr nc,.noCarry3 ; a carry should be impossible here, so this will always jump
ld a,255
.noCarry3
ld [hl],a
pop hl
call .recalculateStats
ld hl,VitaminText
ld a,[wcf91]
sub a,HP_UP - 1
ld c,a
.statNameLoop ; loop to get the address of the name of the stat the vitamin increases
dec c
jr z,.gotStatName
.statNameInnerLoop
ld a,[hli]
ld b,a
ld a,$50
cp b
jr nz,.statNameInnerLoop
jr .statNameLoop
.gotStatName
ld de,wcf4b
ld bc,10
call CopyData ; copy the stat's name to wcf4b
ld a,(SFX_02_3e - SFX_Headers_02) / 3
call PlaySound ; play sound
ld hl,VitaminStatRoseText
call PrintText
jp RemoveUsedItem
.vitaminNoEffect
pop hl
ld hl,VitaminNoEffectText
call PrintText
jp GBPalWhiteOut
.recalculateStats
ld bc,34
add hl,bc
ld d,h
ld e,l ; de now points to stats
ld bc,-18
add hl,bc ; hl now points to byte 3 of experience
ld b,1
jp CalcStats ; recalculate stats
.useRareCandy
push hl
ld bc,33
add hl,bc ; hl now points to level
ld a,[hl] ; a = level
cp a, MAX_LEVEL
jr z,.vitaminNoEffect ; can't raise level above 100
inc a
ld [hl],a ; store incremented level
ld [W_CURENEMYLVL],a
push hl
push de
ld d,a
callab CalcExperience ; calculate experience for next level and store it at $ff96
pop de
pop hl
ld bc,-19
add hl,bc ; hl now points to experience
; update experience to minimum for new level
ld a,[$ff96]
ld [hli],a
ld a,[$ff97]
ld [hli],a
ld a,[$ff98]
ld [hl],a
pop hl
ld a,[wWhichPokemon]
push af
ld a,[wcf91]
push af
push de
push hl
ld bc,34
add hl,bc ; hl now points to MSB of max HP
ld a,[hli]
ld b,a
ld c,[hl]
pop hl
push bc
push hl
call .recalculateStats
pop hl
ld bc,35 ; hl now points to LSB of max HP
add hl,bc
pop bc
ld a,[hld]
sub c
ld c,a
ld a,[hl]
sbc b
ld b,a ; bc = the amount of max HP gained from leveling up
; add the amount gained to the current HP
ld de,-32
add hl,de ; hl now points to MSB of current HP
ld a,[hl]
add c
ld [hld],a
ld a,[hl]
adc b
ld [hl],a
ld a,$f8 ; level up message
ld [wd07d],a
call RedrawPartyMenu
pop de
ld a,d
ld [wWhichPokemon],a
ld a,e
ld [wd11e],a
xor a
ld [wcc49],a ; load from player's party
call LoadMonData
ld d,$01
callab PrintStatsBox ; display new stats text box
call WaitForTextScrollButtonPress ; wait for button press
xor a
ld [wcc49],a
predef LearnMoveFromLevelUp ; learn level up move, if any
xor a
ld [wccd4],a
callab TryEvolvingMon ; evolve pokemon, if appropriate
ld a,$01
ld [wUpdateSpritesEnabled],a
pop af
ld [wcf91],a
pop af
ld [wWhichPokemon],a
jp RemoveUsedItem
VitaminStatRoseText: ; df24 (3:5f24)
TX_FAR _VitaminStatRoseText
db "@"
VitaminNoEffectText: ; df29 (3:5f29)
TX_FAR _VitaminNoEffectText
db "@"
VitaminText: ; df2e (3:5f2e)
db "HEALTH@"
db "ATTACK@"
db "DEFENSE@"
db "SPEED@"
db "SPECIAL@"
EDIT: And just in case it matters, my item constants:
MASTER_BALL EQU $01
ULTRA_BALL EQU $02
GREAT_BALL EQU $03
POKE_BALL EQU $04
TOWN_MAP EQU $05
BICYCLE EQU $06
SURFBOARD EQU $07 ; buggy?
SAFARI_BALL EQU $08
POKEDEX EQU $09
MOON_STONE EQU $0A
ANTIDOTE EQU $0B
BURN_HEAL EQU $0C
ICE_HEAL EQU $0D
AWAKENING EQU $0E
PARLYZ_HEAL EQU $0F
FULL_RESTORE EQU $10
MAX_POTION EQU $11
HYPER_POTION EQU $12
SUPER_POTION EQU $13
POTION EQU $14
; Used for Safari Zone, Duplicate names
SAFARI_BAIT EQU $15
SAFARI_ROCK EQU $16
; Only used to show the badges in Cerulean House
BOULDERBADGE EQU $15
CASCADEBADGE EQU $16
THUNDERBADGE EQU $17
RAINBOWBADGE EQU $18
SOULBADGE EQU $19
MARSHBADGE EQU $1A
VOLCANOBADGE EQU $1B
EARTHBADGE EQU $1C
ESCAPE_ROPE EQU $1D
REPEL EQU $1E
OLD_AMBER EQU $1F
FIRE_STONE EQU $20
THUNDER_STONE EQU $21
WATER_STONE EQU $22
HP_UP EQU $23
PROTEIN EQU $24
IRON EQU $25
CARBOS EQU $26
CALCIUM EQU $27
RARE_CANDY EQU $28
DOME_FOSSIL EQU $29
HELIX_FOSSIL EQU $2A
SECRET_KEY EQU $2B
SUN_STONE EQU $2C
BIKE_VOUCHER EQU $2D
X_ACCURACY EQU $2E
LEAF_STONE EQU $2F
CARD_KEY EQU $30
NUGGET EQU $31
THIEF_BALL EQU $32
POKE_DOLL EQU $33
FULL_HEAL EQU $34
REVIVE EQU $35
MAX_REVIVE EQU $36
GUARD_SPEC_ EQU $37
SUPER_REPEL EQU $38
MAX_REPEL EQU $39
DIRE_HIT EQU $3A
COIN EQU $3B ; unused?
FRESH_WATER EQU $3C
SODA_POP EQU $3D
LEMONADE EQU $3E
S_S__TICKET EQU $3F
GOLD_TEETH EQU $40
X_ATTACK EQU $41
X_DEFEND EQU $42
X_SPEED EQU $43
X_SPECIAL EQU $44
COIN_CASE EQU $45
OAKS_PARCEL EQU $46
ITEMFINDER EQU $47
SILPH_SCOPE EQU $48
POKE_FLUTE EQU $49
LIFT_KEY EQU $4A
EXP__ALL EQU $4B
OLD_ROD EQU $4C
GOOD_ROD EQU $4D
SUPER_ROD EQU $4E
PP_UP EQU $4F
ETHER EQU $50
MAX_ETHER EQU $51
ELIXER EQU $52
MAX_ELIXER EQU $53
; Only used for elevator menus
ITEM_B2F EQU $54
ITEM_B1F EQU $55
ITEM_1F EQU $56
ITEM_2F EQU $57
ITEM_3F EQU $58
ITEM_4F EQU $59
ITEM_5F EQU $5A
ITEM_6F EQU $5B
ITEM_7F EQU $5C
ITEM_8F EQU $5D
ITEM_9F EQU $5E
ITEM_10F EQU $5F
ITEM_11F EQU $60
ITEM_B4F EQU $61
; Berries start here
ORAN_BERRY EQU $62
SITRUS_BERRY EQU $63
LEPPA_BERRY EQU $64
PECHA_BERRY EQU $65
RAWST_BERRY EQU $66
ASPEAR_BERRY EQU $67
CHESTO_BERRY EQU $68
CHERI_BERRY EQU $69
LUM_BERRY EQU $6A
SWEG_BERRY EQU $6B
; Don't call actual item scripts
HM_01 EQU $C4
HM_02 EQU $C5
HM_03 EQU $C6
HM_04 EQU $C7
HM_05 EQU $C8
TM_01 EQU $C9
TM_02 EQU $CA
TM_03 EQU $CB
TM_04 EQU $CC
TM_05 EQU $CD
TM_06 EQU $CE
TM_07 EQU $CF
TM_08 EQU $D0
TM_09 EQU $D1
TM_10 EQU $D2
TM_11 EQU $D3
TM_12 EQU $D4
TM_13 EQU $D5
TM_14 EQU $D6
TM_15 EQU $D7
TM_16 EQU $D8
TM_17 EQU $D9
TM_18 EQU $DA
TM_19 EQU $DB
TM_20 EQU $DC
TM_21 EQU $DD
TM_22 EQU $DE
TM_23 EQU $DF
TM_24 EQU $E0
TM_25 EQU $E1
TM_26 EQU $E2
TM_27 EQU $E3
TM_28 EQU $E4
TM_29 EQU $E5
TM_30 EQU $E6
TM_31 EQU $E7
TM_32 EQU $E8
TM_33 EQU $E9
TM_34 EQU $EA
TM_35 EQU $EB
TM_36 EQU $EC
TM_37 EQU $ED
TM_38 EQU $EE
TM_39 EQU $EF
TM_40 EQU $F0
TM_41 EQU $F1
TM_42 EQU $F2
TM_43 EQU $F3
TM_44 EQU $F4
TM_45 EQU $F5
TM_46 EQU $F6
TM_47 EQU $F7
TM_48 EQU $F8
TM_49 EQU $F9
TM_50 EQU $FA
MART_LIST EQU $FE
Last edited by Luna (2015-03-15 04:11:59)
I am not very active on this forum. I only pop in from time to time.
Offline
What happens if you try this?
Change this:
.skipRemovingItem
ld a,[wcf91]
cp a,FULL_RESTORE
jr c,.playStatusAilmentCuringSound
cp a,FULL_HEAL
jr z,.playStatusAilmentCuringSound
To this:
.skipRemovingItem
ld a,[wcf91]
cp a,PECHA_BERRY
jr nc,.playStatusAilmentCuringSound
cp a,FULL_RESTORE
jr c,.playStatusAilmentCuringSound
cp a,FULL_HEAL
jr z,.playStatusAilmentCuringSound
This assumes that every medicine item ID greater than or equal to PECHA_BERRY is a status-healing item.
Offline
While we're here, it's worth noting that UseItem_ will only work on items with id < 0x80:
ld hl, ItemUsePtrTable
dec a
add a
ld c, a
ld b, 0
add hl, bc
vs
ld hl, ItemUsePtrTable
dec a
ld c, a
ld b, 0
add hl, bc
add hl, bc
Offline
Adding in the check for Pecha Berry made it stop crashing! Woo!
However, I still have the issue of Oran Berry restoring an unknown amount of HP instead of 10 like it is supposed to. :S
Also, that's good to know on the item thing, but my IDs are all still below $80 so that shouldn't really apply?
I am not very active on this forum. I only pop in from time to time.
Offline
I think it is because the game thinks your berry is lemonade.
You could change this:
.notUsingSoftboiled2
ld a,[wcf91]
cp a,SODA_POP
ld b,60 ; Soda Pop heal amount
jr z,.addHealAmount
ld b,80 ; Lemonade heal amount
jr nc,.addHealAmount
To this:
.notUsingSoftboiled2
ld a,[wcf91]
cp a,SODA_POP
ld b,60 ; Soda Pop heal amount
jr z,.addHealAmount
cp a,LEMONADE
ld b,80 ; Lemonade heal amount
jr z,.addHealAmount
Or you could put your check above the soda pop check. Either way should work.
Last edited by YamaArashi (2015-03-15 04:42:41)
Offline
Wow, that looks right. I just got carried away and missed the jr nc in with all the jr z commands. That fixed it!
Thanks so much guys.
I am not very active on this forum. I only pop in from time to time.
Offline
No problem. It's easy to get lost in long functions written in languages without high-level control constructs, like assembly.
Offline
Definitely true.
By the way, anyone who may be curious, here is the final commit after getting those worked out:
I am not very active on this forum. I only pop in from time to time.
Offline
Mateo, were you using BGB's debugger when trying to fix the problem? It seems like this problem could have been spotted faster by stepping through the code and seeing Lemonade's value being loaded. I'm not trying to be mean or anything. I just want to make sure you're taking advantage of the debugger!
My hacks: Pokémon Maize, Pokémon Red: Battle Factory
Offline
Mateo, were you using BGB's debugger when trying to fix the problem? It seems like this problem could have been spotted faster by stepping through the code and seeing Lemonade's value being loaded. I'm not trying to be mean or anything. I just want to make sure you're taking advantage of the debugger!
No, I wasn't.
I am not very active on this forum. I only pop in from time to time.
Offline
Pages: 1