Remove mom saving/spending coins (#1); add coins gained from a trainer battle to wCurLevelCoins (#30)

This commit is contained in:
xCrystal
2024-03-18 18:17:35 +01:00
parent 659dfb085a
commit 5f0cdcaa85
17 changed files with 10 additions and 954 deletions

View File

@@ -2332,27 +2332,7 @@ WinTrainerBattle:
ld a, [wAmuletCoin]
and a
call nz, .DoubleReward
call .CheckMaxedOutMomCoins
push af
ld a, FALSE
jr nc, .okay
ld a, [wMomSavingCoins]
and MOM_SAVING_COINS_MASK
cp (1 << MOM_SAVING_SOME_COINS_F) | (1 << MOM_SAVING_HALF_COINS_F)
jr nz, .okay
inc a ; TRUE
.okay
ld b, a
ld c, 4
.loop
ld a, b
and a
jr z, .loop2
call .AddCoinsToMom
dec c
dec b
jr .loop
.loop2
ld a, c
@@ -2365,38 +2345,13 @@ WinTrainerBattle:
.done
call .DoubleReward
call .DoubleReward
pop af
jr nc, .KeepItAll
ld a, [wMomSavingCoins]
and MOM_SAVING_COINS_MASK
jr z, .KeepItAll
ld hl, .SentToMomTexts
dec a
ld c, a
ld b, 0
add hl, bc
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
jp StdBattleTextbox
.KeepItAll:
ld hl, GotCoinsForWinningText
jp StdBattleTextbox
.AddCoinsToMom:
push bc
ld hl, wBattleReward + 2
ld de, wMomsCoins + 2
call AddBattleCoinsToAccount
pop bc
ret
.AddCoinsToWallet:
push bc
ld hl, wBattleReward + 2
ld de, wCoins + 2
ld de, wCurLevelCoins + 2
call AddBattleCoinsToAccount
pop bc
ret
@@ -2415,22 +2370,6 @@ WinTrainerBattle:
ld [hl], a
ret
.SentToMomTexts:
; entries correspond to MOM_SAVING_* constants
dw SentSomeToMomText
dw SentHalfToMomText
dw SentAllToMomText
.CheckMaxedOutMomCoins:
ld hl, wMomsCoins + 2
ld a, [hld]
cp LOW(MAX_COINS)
ld a, [hld]
sbc HIGH(MAX_COINS) ; mid
ld a, [hl]
sbc HIGH(MAX_COINS >> 8)
ret
AddBattleCoinsToAccount:
ld c, 3
and a
@@ -2451,17 +2390,17 @@ AddBattleCoinsToAccount:
jr nz, .loop
pop hl
ld a, [hld]
cp LOW(MAX_COINS)
cp LOW(MAX_LEVEL_COINS)
ld a, [hld]
sbc HIGH(MAX_COINS) ; mid
sbc HIGH(MAX_LEVEL_COINS) ; mid
ld a, [hl]
sbc HIGH(MAX_COINS >> 8)
sbc HIGH(MAX_LEVEL_COINS >> 8)
ret c
ld [hl], HIGH(MAX_COINS >> 8)
ld [hl], HIGH(MAX_LEVEL_COINS >> 8)
inc hl
ld [hl], HIGH(MAX_COINS) ; mid
ld [hl], HIGH(MAX_LEVEL_COINS) ; mid
inc hl
ld [hl], LOW(MAX_COINS)
ld [hl], LOW(MAX_LEVEL_COINS)
ret
PlayVictoryMusic:
@@ -8166,7 +8105,7 @@ CheckPayDay:
.okay
ld hl, wPayDayCoins + 2
ld de, wCoins + 2
ld de, wCurLevelCoins + 2
call AddBattleCoinsToAccount
ld hl, BattleText_PlayerPickedUpPayDayCoins
call StdBattleTextbox

View File

@@ -27,7 +27,7 @@ LoadMaxCoins_bc:
cp HIGH(wCurLevelCoins)
ld bc, MaxCurLevelCoins ; CUR_LEVEL_COINS
ret z
ld bc, MaxCoins ; YOUR_COINS or MOMS_COINS
ld bc, MaxCoins ; YOUR_COINS
ret
LoadMaxCoins_hl:

File diff suppressed because it is too large Load Diff

View File

@@ -1,239 +0,0 @@
DEF NUM_MOM_ITEMS_1 EQUS "((MomItems_1.End - MomItems_1) / 8)"
DEF NUM_MOM_ITEMS_2 EQUS "((MomItems_2.End - MomItems_2) / 8)"
const_def 1
const MOM_ITEM
const MOM_DOLL
MomTriesToBuySomething::
ld a, [wMapReentryScriptQueueFlag]
and a
ret nz
call GetMapPhoneService
and a
ret nz
xor a
ld [wWhichMomItemSet], a
call CheckBalance_MomItem2
ret nc
call Mom_GiveItemOrDoll
ret nc
ld b, BANK(.Script)
ld de, .Script
farcall LoadMemScript
scf
ret
.Script:
callasm .ASMFunction
farsjump Script_ReceivePhoneCall
.ASMFunction:
call MomBuysItem_DeductFunds
call Mom_GetScriptPointer
ld a, [wWhichMomItemSet]
and a
jr nz, .ok
ld hl, wWhichMomItem
inc [hl]
.ok
ld a, PHONE_MOM
ld [wCurCaller], a
ld bc, wCallerContact
ld hl, PHONE_CONTACT_TRAINER_CLASS
add hl, bc
ld [hl], TRAINER_NONE
inc hl
ld [hl], PHONE_MOM
ld hl, PHONE_CONTACT_SCRIPT2_BANK
add hl, bc
ld a, BANK(Mom_GetScriptPointer)
ld [hli], a
ld a, e
ld [hli], a
ld a, d
ld [hl], a
ret
CheckBalance_MomItem2:
ld a, [wWhichMomItem]
cp NUM_MOM_ITEMS_2
jr nc, .nope
call GetItemFromMom
ld a, [hli]
ldh [hCoinsTemp], a
ld a, [hli]
ldh [hCoinsTemp + 1], a
ld a, [hli]
ldh [hCoinsTemp + 2], a
ld de, wMomsCoins
ld bc, hCoinsTemp
farcall CompareCoins
jr nc, .have_enough_coins
.nope
jr .check_have_2300
.have_enough_coins
scf
ret
.check_have_2300
ld hl, hCoinsTemp
ld [hl], HIGH(MOM_COINS >> 8)
inc hl
ld [hl], HIGH(MOM_COINS) ; mid
inc hl
ld [hl], LOW(MOM_COINS)
.loop
ld de, wMomItemTriggerBalance
ld bc, wMomsCoins
farcall CompareCoins
jr z, .exact
jr nc, .less_than
call .AddCoins
jr .loop
.less_than
xor a
ret
.exact
call .AddCoins
ld a, NUM_MOM_ITEMS_1
call RandomRange
inc a
ld [wWhichMomItemSet], a
scf
ret
.AddCoins:
ld de, wMomItemTriggerBalance
ld bc, hCoinsTemp
farcall AddCoins
ret
MomBuysItem_DeductFunds:
call GetItemFromMom
ld de, 3 ; cost
add hl, de
ld a, [hli]
ldh [hCoinsTemp], a
ld a, [hli]
ldh [hCoinsTemp + 1], a
ld a, [hli]
ldh [hCoinsTemp + 2], a
ld de, wMomsCoins
ld bc, hCoinsTemp
farcall TakeCoins
ret
Mom_GiveItemOrDoll:
call GetItemFromMom
ld de, 6 ; item type
add hl, de
ld a, [hli]
cp MOM_ITEM
jr z, .not_doll
ld a, [hl]
ld c, a
ld b, 1
farcall DecorationFlagAction_c
scf
ret
.not_doll
ld a, [hl]
ld [wCurItem], a
ld a, 1
ld [wItemQuantityChange], a
ld hl, wNumPCItems
call ReceiveItem
ret
Mom_GetScriptPointer:
call GetItemFromMom
ld de, 6 ; item type
add hl, de
ld a, [hli]
ld de, .ItemScript
cp MOM_ITEM
ret z
ld de, .DollScript
ret
.ItemScript:
writetext MomHiHowAreYouText
writetext MomFoundAnItemText
writetext MomBoughtWithYourCoinsText
writetext MomItsInPCText
end
.DollScript:
writetext MomHiHowAreYouText
writetext MomFoundADollText
writetext MomBoughtWithYourCoinsText
writetext MomItsInYourRoomText
end
GetItemFromMom:
ld a, [wWhichMomItemSet]
and a
jr z, .zero
dec a
ld de, MomItems_1
jr .GetFromList1
.zero
ld a, [wWhichMomItem]
cp NUM_MOM_ITEMS_2
jr c, .ok
xor a
.ok
ld de, MomItems_2
.GetFromList1:
ld l, a
ld h, 0
rept 3 ; multiply hl by 8
add hl, hl
endr
add hl, de
ret
INCLUDE "data/items/mom_phone.asm"
MomHiHowAreYouText:
text_far _MomHiHowAreYouText
text_end
MomFoundAnItemText:
text_far _MomFoundAnItemText
text_end
MomBoughtWithYourCoinsText:
text_far _MomBoughtWithYourCoinsText
text_end
MomItsInPCText:
text_far _MomItsInPCText
text_end
MomFoundADollText:
text_far _MomFoundADollText
text_end
MomItsInYourRoomText:
text_far _MomItsInYourRoomText
text_end
DummyPredef3A_DummyData: ; unreferenced
db 0
DummyPredef3A:
ret
DummyPredef3A_DummyFunction: ; unreferenced
ret

View File

@@ -127,16 +127,6 @@ endc
ld a, LOW(START_COINS)
ld [wCoins + 2], a
xor a
ld [wWhichMomItem], a
ld hl, wMomItemTriggerBalance
ld [hl], HIGH(MOM_COINS >> 8)
inc hl
ld [hl], HIGH(MOM_COINS) ; mid
inc hl
ld [hl], LOW(MOM_COINS)
call InitializeNPCNames
farcall InitDecorations

View File

@@ -1205,7 +1205,6 @@ Script_reloadmapafterbattle:
.notblackedout
bit 0, d
jr z, .was_wild
farcall MomTriesToBuySomething
jr .next
.was_wild
@@ -1223,6 +1222,7 @@ Script_reloadmapafterbattle:
farcall LoadBoardMenuDieNumbersGFX
ld hl, wDisplaySecondarySprites
set SECONDARYSPRITES_SPACES_LEFT_F, [hl]
call ConstructOverworldHUDTilemap ; refresh coins just won
.done
jp Script_reloadmap
@@ -1874,10 +1874,7 @@ GetCoinsAccount:
and a
ld de, wCoins ; YOUR_COINS
ret z
dec a
ld de, wCurLevelCoins ; CUR_LEVEL_COINS
ret z
ld de, wMomsCoins ; MOMS_COINS
ret
LoadCoinsAmountToMem: