’Cause all games were better on the GBC

You are not logged in.

#1 2020-12-15 22:12:54

New member
Registered: 2020-12-15
Post 1/1

Adding betting to match

I am working on a hack that adds a house in pallet town that is like a 'fight club' for trainers to battle their pokemon.

The idea is to allow for recurring battles for grinding up your mons levels and the ability to make some money earlier in the game.

At the moment I am stuck trying to place the bet itself with the character I added to the map. I modeled what I have so far based on the vending_machine.asm script. I've added MIN_BET, MID_BET, and MAX_BET items to all of the following files:

I've also copied the vending_prices.asm file and made my own betting_prices.asm file. And I've added to the hram.asm file lines for betting items and prices like the vending lines that are there now. Also there were a few tweaks to get all of my stuff hooked together, but I forget which files those were. (I don't think they are relevant to my problem). Everything runs and I know I'm getting to my code and seems like it should be working to me, but when I go to click on one of the bet items that costs more than my character currently has it doesn't trigger the not enough money text, it carries on as though he has enough money.

Here is the betting_engine.asm file I've created, it's almost identical to the vending_machine.asm file but with my changes. (I'll be changing more eventually, like the fact that it's putting a bet item in your bag etc.)

Can anyone help me out?

    ld hl, BettingText1
    call PrintText
    ld a, MONEY_BOX
    ld [wTextBoxID], a
    call DisplayTextBoxID
    xor a
    ld [wCurrentMenuItem], a
    ld [wLastMenuItem], a
    ld a, A_BUTTON | B_BUTTON
    ld [wMenuWatchedKeys], a
    ld a, 3
    ld [wMaxMenuItem], a
    ld a, 5
    ld [wTopMenuItemY], a
    ld a, 1
    ld [wTopMenuItemX], a
    ld hl, wd730
    set 6, [hl]
    hlcoord 0, 3
    ld b, 8
    ld c, 12
    call TextBoxBorder
    call UpdateSprites
    hlcoord 2, 5
    ld de, BetText
    call PlaceString
    hlcoord 9, 6
    ld de, BetPriceText
    call PlaceString
    ld hl, wd730
    res 6, [hl]
    call HandleMenuInput
    bit 1, a ; pressed B?
    jr nz, .tooScared
    ld a, [wCurrentMenuItem]
    cp 3 ; chose Cancel?
    jr z, .tooScared
    xor a    
     ldh [hMoney], a
     ldh [hMoney + 2], a
     ld a, $2
     ldh [hMoney + 1], a
     call HasEnoughMoney
     jr nc, .enoughMoney
     ld hl, BettingText4
     jp PrintText
     call LoadBetItem
     ldh a, [hBettingItem]
     ld b, a
     ld c, 1
    call GiveItem
    jr nc, .BagFull
    ld b, 60 ; number of times to play the "brrrrr" sound
    ld c, 2
    call DelayFrames
    push bc
    call PlaySound
    pop bc
    dec b
    jr nz, .playDeliverySound
    ld hl, BettingText5
    call PrintText
    ld hl, hBettingPrice + 2
    ld de, wPlayerMoney + 2
    ld c, $3
    predef SubBCDPredef
    ld a, MONEY_BOX
    ld [wTextBoxID], a
    jp DisplayTextBoxID
     ld hl, BettingText6
     jp PrintText
     ld hl, BettingText7
     jp PrintText

    text_far _BettingText1

    db   "MIN BET"
    next "MID BET"
    next "MAX BET"
    next "CANCEL@"

    db   "¥2000"
    next "¥4000"
    next "¥6000"
    next "@"

    text_far _BettingText4

     text_far _BettingText5

     text_far _BettingText6

    text_far _BettingText7

     ld hl, BettingPrices
     ld a, [wCurrentMenuItem]
     add a
     add a
     ld d, 0
     ld e, a
     add hl, de
     ld a, [hli]
     ldh [hBettingItem], a
     ld a, [hli]
     ldh [hBettingPrice], a
     ld a, [hli]
     ldh [hBettingPrice + 1], a
     ld a, [hl]
     ldh [hBettingPrice + 2], a

INCLUDE "data/items/betting_prices.asm"


#2 2020-12-28 11:29:36

Registered: 2016-09-14
Post 16/20

Re: Adding betting to match

This part of your code:

xor a    
ldh [hMoney], a
ldh [hMoney + 2], a
ld a, $2
ldh [hMoney + 1], a
call HasEnoughMoney

checks whether the player has at least ¥200. If you want to check against another amount (like the price of an item) you should load that amount into hMoney, as a binary-coded decimal. I'm not very familiar with pokered, but it seems that DisplayChooseQuantityMenu does something similar in the part of that function called .addLoop.

Last edited by lakeofdance (2020-12-28 15:06:39)


Board footer

Powered by FluxBB