2020-10-27 10:22:27 -07:00
|
|
|
StageDataForMysteryGift:
|
2015-12-14 17:06:41 -08:00
|
|
|
ld de, wMysteryGiftStaging
|
2020-10-27 10:22:27 -07:00
|
|
|
ld a, GS_VERSION + 1
|
2015-12-06 19:36:09 -08:00
|
|
|
ld [de], a
|
2020-10-26 12:45:57 -07:00
|
|
|
inc de ; wMysteryGiftStaging+1
|
2015-12-06 19:36:09 -08:00
|
|
|
ld a, BANK(sGameData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, sPlayerData + wPlayerID - wPlayerData
|
2015-12-06 19:36:09 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
ld b, a
|
2020-10-26 12:45:57 -07:00
|
|
|
inc de ; wMysteryGiftStaging+2
|
2015-12-06 19:36:09 -08:00
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
ld c, a
|
2020-10-26 12:45:57 -07:00
|
|
|
inc de ; wMysteryGiftStaging+3
|
2015-12-06 19:36:09 -08:00
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, sPlayerData + wPlayerName - wPlayerData
|
2015-12-06 19:36:09 -08:00
|
|
|
ld bc, NAME_LENGTH
|
|
|
|
call CopyBytes
|
2020-10-26 12:45:57 -07:00
|
|
|
push de ; wMysteryGiftStaging+14
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, sPokemonData + wPokedexCaught - wPokemonData
|
|
|
|
ld b, wEndPokedexCaught - wPokedexCaught
|
2015-12-06 19:36:09 -08:00
|
|
|
call CountSetBits
|
|
|
|
pop de
|
|
|
|
pop bc
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wNumSetBits]
|
2015-12-06 19:36:09 -08:00
|
|
|
ld [de], a
|
2020-10-26 12:45:57 -07:00
|
|
|
inc de ; wMysteryGiftStaging+15
|
2015-12-06 19:36:09 -08:00
|
|
|
call CloseSRAM
|
|
|
|
call Random
|
2018-01-11 09:00:01 -08:00
|
|
|
and 1
|
2015-12-06 19:36:09 -08:00
|
|
|
ld [de], a
|
2020-10-26 12:45:57 -07:00
|
|
|
inc de ; wMysteryGiftStaging+16
|
2015-12-14 17:06:41 -08:00
|
|
|
call .RandomSample
|
2015-12-06 19:36:09 -08:00
|
|
|
ld [de], a
|
2020-10-26 12:45:57 -07:00
|
|
|
inc de ; wMysteryGiftStaging+17
|
2015-12-06 19:36:09 -08:00
|
|
|
ld a, c
|
|
|
|
ld c, b
|
|
|
|
ld b, a
|
2015-12-14 17:06:41 -08:00
|
|
|
call .RandomSample
|
2015-12-06 19:36:09 -08:00
|
|
|
ld [de], a
|
2020-10-26 12:45:57 -07:00
|
|
|
inc de ; wMysteryGiftStaging+18
|
2015-12-06 19:36:09 -08:00
|
|
|
ld a, BANK(sBackupMysteryGiftItem)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-12-06 19:36:09 -08:00
|
|
|
ld a, [sBackupMysteryGiftItem]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2020-10-27 10:22:27 -07:00
|
|
|
ld a, [sNumDailyMysteryGiftPartnerIDs]
|
2015-12-06 19:36:09 -08:00
|
|
|
ld [de], a
|
2020-10-27 10:22:27 -07:00
|
|
|
ld a, wMysteryGiftPlayerDataEnd - wMysteryGiftPlayerData
|
|
|
|
ld [wUnusedMysteryGiftStagedDataLength], a
|
2015-12-06 19:36:09 -08:00
|
|
|
call CloseSRAM
|
2015-12-14 17:06:41 -08:00
|
|
|
ld hl, wMysteryGiftStaging
|
|
|
|
ld de, wMysteryGiftPlayerData
|
|
|
|
ld bc, wMysteryGiftPlayerDataEnd - wMysteryGiftPlayerData
|
2015-12-06 19:36:09 -08:00
|
|
|
jp CopyBytes
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.RandomSample:
|
2015-12-06 19:36:09 -08:00
|
|
|
push de
|
|
|
|
call Random
|
2018-01-11 09:00:01 -08:00
|
|
|
cp 10 percent
|
2015-12-06 19:36:09 -08:00
|
|
|
jr c, .tenpercent
|
|
|
|
call Random
|
2018-01-11 09:00:01 -08:00
|
|
|
and %111
|
2015-12-06 19:36:09 -08:00
|
|
|
ld d, a
|
|
|
|
rl d
|
|
|
|
ld e, $80
|
|
|
|
.loop
|
|
|
|
rlc e
|
|
|
|
dec a
|
|
|
|
jr nz, .loop
|
|
|
|
ld a, e
|
|
|
|
and c
|
|
|
|
jr z, .skip
|
|
|
|
ld a, $1
|
|
|
|
.skip
|
|
|
|
add d
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.tenpercent
|
|
|
|
call Random
|
2020-06-17 07:39:17 -07:00
|
|
|
cp 20 percent - 1
|
2015-12-06 19:36:09 -08:00
|
|
|
jr c, .twopercent
|
|
|
|
call Random
|
2018-01-11 09:00:01 -08:00
|
|
|
and %011
|
2015-12-06 19:36:09 -08:00
|
|
|
ld d, a
|
|
|
|
rl d
|
|
|
|
ld e, $80
|
|
|
|
.loop2
|
|
|
|
rlc e
|
|
|
|
dec a
|
|
|
|
jr nz, .loop2
|
|
|
|
ld a, e
|
|
|
|
and b
|
|
|
|
jr z, .skip2
|
|
|
|
ld a, $1
|
|
|
|
.skip2
|
|
|
|
add d
|
|
|
|
add $10
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.twopercent
|
|
|
|
call Random
|
2018-01-11 09:00:01 -08:00
|
|
|
cp 20 percent - 1
|
2015-12-06 19:36:09 -08:00
|
|
|
jr c, .pointfourpercent
|
|
|
|
ld a, b
|
|
|
|
swap a
|
|
|
|
and $7
|
|
|
|
add $18
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.pointfourpercent
|
|
|
|
ld a, b
|
|
|
|
and $80
|
|
|
|
ld a, $20
|
|
|
|
jr z, .done
|
|
|
|
ld a, $21
|
|
|
|
|
|
|
|
.done
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
2020-10-27 10:22:27 -07:00
|
|
|
MysteryGiftGetItem:
|
2015-12-06 19:36:09 -08:00
|
|
|
ld a, c
|
2018-01-22 10:00:35 -08:00
|
|
|
cp MysteryGiftItems.End - MysteryGiftItems
|
2015-12-14 17:06:41 -08:00
|
|
|
jr nc, MysteryGiftFallbackItem
|
|
|
|
ld hl, MysteryGiftItems
|
2015-12-06 19:36:09 -08:00
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld c, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MysteryGiftGetDecoration:
|
2015-12-06 19:36:09 -08:00
|
|
|
ld a, c
|
2018-01-22 10:00:35 -08:00
|
|
|
cp MysteryGiftDecos.End - MysteryGiftDecos
|
2015-12-14 17:06:41 -08:00
|
|
|
jr nc, MysteryGiftFallbackItem
|
|
|
|
ld hl, MysteryGiftDecos
|
2015-12-06 19:36:09 -08:00
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld c, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MysteryGiftFallbackItem:
|
2015-12-06 19:36:09 -08:00
|
|
|
ld c, DECO_POLKADOT_BED ; GREAT_BALL
|
|
|
|
ret
|
|
|
|
|
2018-01-10 22:54:49 -08:00
|
|
|
INCLUDE "data/items/mystery_gift_items.asm"
|
2015-12-06 19:36:09 -08:00
|
|
|
|
2018-01-10 22:54:49 -08:00
|
|
|
INCLUDE "data/decorations/mystery_gift_decos.asm"
|