pokecrystal-board/engine/events/special.asm

226 lines
3.5 KiB
NASM
Raw Normal View History

2018-01-11 22:40:20 -08:00
MANIA_OT_ID EQU 00518
GiveShuckle: ; 7305
2016-03-27 09:47:28 -07:00
; Adding to the party.
xor a
ld [MonType], a
; Level 15 Shuckle.
ld a, SHUCKLE
ld [CurPartySpecies], a
ld a, 15
ld [CurPartyLevel], a
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
ld a, [PartyCount]
dec a
push af
push bc
ld hl, PartyMon1Item
call AddNTimes
ld [hl], BERRY
pop bc
pop af
; OT ID.
ld hl, PartyMon1ID
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.
ld a, [PartyCount]
dec a
ld hl, PartyMonNicknames
call SkipNames
ld de, SpecialShuckleNick
call CopyName2
; OT.
ld a, [PartyCount]
dec a
ld hl, PartyMonOT
call SkipNames
ld de, SpecialShuckleOT
call CopyName2
; Engine flag for this event.
ld hl, wDailyFlags
set DAILYFLAGS_GOT_SHUCKIE_TODAY_F, [hl]
2016-03-27 09:47:28 -07:00
ld a, 1
ld [ScriptVar], a
ret
.NotGiven:
2016-03-27 09:47:28 -07:00
xor a
ld [ScriptVar], a
ret
SpecialShuckleOT:
db "MANIA@"
SpecialShuckleNick:
db "SHUCKIE@"
ReturnShuckle: ; 737e
2017-12-24 09:47:30 -08:00
farcall SelectMonFromParty
2016-03-27 09:47:28 -07:00
jr c, .refused
ld a, [CurPartySpecies]
cp SHUCKLE
jr nz, .DontReturn
ld a, [CurPartyMon]
ld hl, PartyMon1ID
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
ld a, [CurPartyMon]
ld hl, PartyMonOT
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
ld a, [CurPartyMon]
ld hl, PartyMon1Happiness
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:
2016-03-27 09:47:28 -07:00
ld [ScriptVar], a
ret
.refused
2018-01-11 22:40:20 -08:00
ld a, SHUCKIE_REFUSED
2016-03-27 09:47:28 -07:00
ld [ScriptVar], a
ret
.DontReturn:
2018-01-11 22:40:20 -08:00
xor a ; SHUCKIE_WRONG_MON
2016-03-27 09:47:28 -07:00
ld [ScriptVar], a
ret
.fainted
2018-01-11 22:40:20 -08:00
ld a, SHUCKIE_FAINTED
2016-03-27 09:47:28 -07:00
ld [ScriptVar], a
ret
BillsGrandfather: ; 73f7
2017-12-24 09:47:30 -08:00
farcall SelectMonFromParty
2016-03-27 09:47:28 -07:00
jr c, .cancel
ld a, [CurPartySpecies]
ld [ScriptVar], a
ld [wNamedObjectIndexBuffer], a
call GetPokemonName
jp CopyPokemonName_Buffer1_Buffer3
.cancel
xor a
ld [ScriptVar], a
ret
YoungerHaircutBrother: ; 7413
2018-01-25 19:19:24 -08:00
ld hl, HappinessData_YoungerHaircutBrother
2018-01-22 21:11:23 -08:00
jr HaircutOrGrooming
2016-03-27 09:47:28 -07:00
OlderHaircutBrother: ; 7418
2018-01-25 19:19:24 -08:00
ld hl, HappinessData_OlderHaircutBrother
2018-01-22 21:11:23 -08:00
jr HaircutOrGrooming
2016-03-27 09:47:28 -07:00
DaisysGrooming: ; 741d
2018-01-25 19:19:24 -08:00
ld hl, HappinessData_DaisysGrooming
2018-01-22 21:11:23 -08:00
; fallthrough
2016-03-27 09:47:28 -07:00
2018-01-22 21:11:23 -08:00
HaircutOrGrooming: ; 7420
2016-03-27 09:47:28 -07:00
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
ld a, [CurPartySpecies]
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.
2018-01-22 21:11:23 -08:00
; In the case of getting a grooming from Daisy, we bleed
2016-03-27 09:47:28 -07:00
; 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]
ld [ScriptVar], a
ld c, [hl]
call ChangeHappiness
ret
.nope
xor a
ld [ScriptVar], a
ret
.egg
ld a, 1
ld [ScriptVar], a
ret
2018-01-25 19:19:24 -08:00
INCLUDE "data/events/happiness_chances.asm"
2016-03-27 09:47:28 -07:00
CopyPokemonName_Buffer1_Buffer3: ; 746e
ld hl, StringBuffer1
ld de, StringBuffer3
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