pokecrystal-board/engine/events/special.asm

236 lines
3.9 KiB
NASM
Raw Normal View History

2018-01-11 22:40:20 -08:00
MANIA_OT_ID EQU 00518
2018-01-02 08:13:57 -08:00
Special_GiveShuckle: ; 7305
2016-03-27 09:47:28 -07:00
; Adding to the party.
xor a
2018-01-23 14:39:09 -08:00
ld [wMonType], a
2016-03-27 09:47:28 -07:00
; Level 15 Shuckle.
ld a, SHUCKLE
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-03-27 09:47:28 -07:00
ld a, 15
2018-01-23 14:39:09 -08:00
ld [wCurPartyLevel], a
2016-03-27 09:47:28 -07:00
predef TryAddMonToParty
2016-03-27 09:47:28 -07:00
jr nc, .NotGiven
; Caught data.
ld b, 0
2017-12-24 09:47:30 -08:00
farcall SetGiftPartyMonCaughtData
2016-03-27 09:47:28 -07:00
; Holding a Berry.
ld bc, PARTYMON_STRUCT_LENGTH
2018-01-23 14:39:09 -08:00
ld a, [wPartyCount]
2016-03-27 09:47:28 -07:00
dec a
push af
push bc
2018-01-23 14:39:09 -08:00
ld hl, wPartyMon1Item
2016-03-27 09:47:28 -07:00
call AddNTimes
ld [hl], BERRY
pop bc
pop af
; OT ID.
2018-01-23 14:39:09 -08:00
ld hl, wPartyMon1ID
2016-03-27 09:47:28 -07:00
call AddNTimes
2018-01-11 22:40:20 -08:00
ld a, HIGH(MANIA_OT_ID)
2016-03-27 09:47:28 -07:00
ld [hli], a
2018-01-11 22:40:20 -08:00
ld [hl], LOW(MANIA_OT_ID)
2016-03-27 09:47:28 -07:00
; Nickname.
2018-01-23 14:39:09 -08:00
ld a, [wPartyCount]
2016-03-27 09:47:28 -07:00
dec a
2018-01-23 14:39:09 -08:00
ld hl, wPartyMonNicknames
2016-03-27 09:47:28 -07:00
call SkipNames
ld de, SpecialShuckleNick
call CopyName2
; OT.
2018-01-23 14:39:09 -08:00
ld a, [wPartyCount]
2016-03-27 09:47:28 -07:00
dec a
2018-01-23 14:39:09 -08:00
ld hl, wPartyMonOT
2016-03-27 09:47:28 -07:00
call SkipNames
ld de, SpecialShuckleOT
call CopyName2
; Engine flag for this event.
ld hl, wDailyFlags
2018-01-11 22:40:20 -08:00
set 5, [hl] ; ENGINE_SHUCKLE_GIVEN
2016-03-27 09:47:28 -07:00
ld a, 1
2018-01-23 14:39:09 -08:00
ld [wScriptVar], a
2016-03-27 09:47:28 -07:00
ret
.NotGiven:
2016-03-27 09:47:28 -07:00
xor a
2018-01-23 14:39:09 -08:00
ld [wScriptVar], a
2016-03-27 09:47:28 -07:00
ret
SpecialShuckleOT:
db "MANIA@"
SpecialShuckleNick:
db "SHUCKIE@"
2018-01-02 08:13:57 -08:00
Special_ReturnShuckle: ; 737e
2017-12-24 09:47:30 -08:00
farcall SelectMonFromParty
2016-03-27 09:47:28 -07:00
jr c, .refused
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
2016-03-27 09:47:28 -07:00
cp SHUCKLE
jr nz, .DontReturn
2018-01-23 14:39:09 -08:00
ld a, [wCurPartyMon]
ld hl, wPartyMon1ID
2016-03-27 09:47:28 -07:00
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
; OT ID
ld a, [hli]
2018-01-11 22:40:20 -08:00
cp HIGH(MANIA_OT_ID)
2016-03-27 09:47:28 -07:00
jr nz, .DontReturn
ld a, [hl]
2018-01-11 22:40:20 -08:00
cp LOW(MANIA_OT_ID)
2016-03-27 09:47:28 -07:00
jr nz, .DontReturn
; OT
2018-01-23 14:39:09 -08:00
ld a, [wCurPartyMon]
ld hl, wPartyMonOT
2016-03-27 09:47:28 -07:00
call SkipNames
ld de, SpecialShuckleOT
.CheckOT:
2016-03-27 09:47:28 -07:00
ld a, [de]
cp [hl]
jr nz, .DontReturn
cp "@"
jr z, .done
inc de
inc hl
jr .CheckOT
.done
2017-12-24 09:47:30 -08:00
farcall CheckCurPartyMonFainted
2016-03-27 09:47:28 -07:00
jr c, .fainted
2018-01-23 14:39:09 -08:00
ld a, [wCurPartyMon]
ld hl, wPartyMon1Happiness
2016-03-27 09:47:28 -07:00
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld a, [hl]
cp 150
2018-01-11 22:40:20 -08:00
ld a, SHUCKIE_HAPPY
2016-03-27 09:47:28 -07:00
jr nc, .HappyToStayWithYou
xor a ; take from pc
ld [wPokemonWithdrawDepositParameter], a
2017-12-24 09:47:30 -08:00
callfar RemoveMonFromPartyOrBox
2018-01-11 22:40:20 -08:00
ld a, SHUCKIE_RETURNED
.HappyToStayWithYou:
2018-01-23 14:39:09 -08:00
ld [wScriptVar], a
2016-03-27 09:47:28 -07:00
ret
.refused
2018-01-11 22:40:20 -08:00
ld a, SHUCKIE_REFUSED
2018-01-23 14:39:09 -08:00
ld [wScriptVar], a
2016-03-27 09:47:28 -07:00
ret
.DontReturn:
2018-01-11 22:40:20 -08:00
xor a ; SHUCKIE_WRONG_MON
2018-01-23 14:39:09 -08:00
ld [wScriptVar], a
2016-03-27 09:47:28 -07:00
ret
.fainted
2018-01-11 22:40:20 -08:00
ld a, SHUCKIE_FAINTED
2018-01-23 14:39:09 -08:00
ld [wScriptVar], a
2016-03-27 09:47:28 -07:00
ret
Special_BillsGrandfather: ; 73f7
2017-12-24 09:47:30 -08:00
farcall SelectMonFromParty
2016-03-27 09:47:28 -07:00
jr c, .cancel
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
ld [wScriptVar], a
2016-03-27 09:47:28 -07:00
ld [wNamedObjectIndexBuffer], a
call GetPokemonName
jp CopyPokemonName_Buffer1_Buffer3
.cancel
xor a
2018-01-23 14:39:09 -08:00
ld [wScriptVar], a
2016-03-27 09:47:28 -07:00
ret
Special_YoungerHaircutBrother: ; 7413
ld hl, Data_YoungerHaircutBrother
jr MassageOrHaircut
Special_OlderHaircutBrother: ; 7418
ld hl, Data_OlderHaircutBrother
jr MassageOrHaircut
Special_DaisyMassage: ; 741d
ld hl, Data_DaisyMassage
MassageOrHaircut: ; 7420
push hl
2017-12-24 09:47:30 -08:00
farcall SelectMonFromParty
2016-03-27 09:47:28 -07:00
pop hl
jr c, .nope
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
2016-03-27 09:47:28 -07:00
cp EGG
jr z, .egg
push hl
call GetCurNick
call CopyPokemonName_Buffer1_Buffer3
pop hl
call Random
; Bug: Subtracting $ff from $ff fails to set c.
; This can result in overflow into the next data array.
; In the case of getting a massage from Daisy, we bleed
; into CopyPokemonName_Buffer1_Buffer3, which passes
; $d0 to ChangeHappiness and returns $73 to the script.
; The end result is that there is a 0.4% chance your
; Pokemon's happiness will not change at all.
.loop
sub [hl]
jr c, .ok
inc hl
inc hl
inc hl
2016-03-27 09:47:28 -07:00
jr .loop
.ok
inc hl
ld a, [hli]
2018-01-23 14:39:09 -08:00
ld [wScriptVar], a
2016-03-27 09:47:28 -07:00
ld c, [hl]
call ChangeHappiness
ret
.nope
xor a
2018-01-23 14:39:09 -08:00
ld [wScriptVar], a
2016-03-27 09:47:28 -07:00
ret
.egg
ld a, 1
2018-01-23 14:39:09 -08:00
ld [wScriptVar], a
2016-03-27 09:47:28 -07:00
ret
Data_YoungerHaircutBrother: ; 7459
db $4c, 2, HAPPINESS_YOUNGCUT1 ; 30% chance
db $80, 3, HAPPINESS_YOUNGCUT2 ; 20% chance
db $ff, 4, HAPPINESS_YOUNGCUT3 ; 50% chance
Data_OlderHaircutBrother: ; 7462
db $9a, 2, HAPPINESS_OLDERCUT1 ; 60% chance
db $4c, 3, HAPPINESS_OLDERCUT2 ; 10% chance
db $ff, 4, HAPPINESS_OLDERCUT3 ; 30% chance
Data_DaisyMassage: ; 746b
db $ff, 2, HAPPINESS_MASSAGE ; 99.6% chance
CopyPokemonName_Buffer1_Buffer3: ; 746e
2018-01-23 14:39:09 -08:00
ld hl, wStringBuffer1
ld de, wStringBuffer3
2018-01-20 09:25:55 -08:00
ld bc, MON_NAME_LENGTH
2016-03-27 09:47:28 -07:00
jp CopyBytes
2018-01-02 06:05:14 -08:00
DummyPredef1: ; 747a
ret