You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-09-08 08:13:02 -07:00
Split up banks 1-3 of main.asm
This commit is contained in:
238
event/happiness_egg.asm
Executable file
238
event/happiness_egg.asm
Executable file
@@ -0,0 +1,238 @@
|
||||
GetFirstPokemonHappiness: ; 718d
|
||||
ld hl, PartyMon1Happiness
|
||||
ld bc, PARTYMON_STRUCT_LENGTH
|
||||
ld de, PartySpecies
|
||||
.loop
|
||||
ld a, [de]
|
||||
cp EGG
|
||||
jr nz, .done
|
||||
inc de
|
||||
add hl, bc
|
||||
jr .loop
|
||||
|
||||
.done
|
||||
ld [wd265], a
|
||||
ld a, [hl]
|
||||
ld [ScriptVar], a
|
||||
call GetPokemonName
|
||||
jp CopyPokemonName_Buffer1_Buffer3
|
||||
|
||||
CheckFirstMonIsEgg: ; 71ac
|
||||
ld a, [PartySpecies]
|
||||
ld [wd265], a
|
||||
cp EGG
|
||||
ld a, $1
|
||||
jr z, .egg
|
||||
xor a
|
||||
|
||||
.egg
|
||||
ld [ScriptVar], a
|
||||
call GetPokemonName
|
||||
jp CopyPokemonName_Buffer1_Buffer3
|
||||
|
||||
ChangeHappiness: ; 71c2
|
||||
; Perform happiness action c on CurPartyMon
|
||||
|
||||
ld a, [CurPartyMon]
|
||||
inc a
|
||||
ld e, a
|
||||
ld d, 0
|
||||
ld hl, PartySpecies - 1
|
||||
add hl, de
|
||||
ld a, [hl]
|
||||
cp EGG
|
||||
ret z
|
||||
|
||||
push bc
|
||||
ld hl, PartyMon1Happiness
|
||||
ld bc, PARTYMON_STRUCT_LENGTH
|
||||
ld a, [CurPartyMon]
|
||||
call AddNTimes
|
||||
pop bc
|
||||
|
||||
ld d, h
|
||||
ld e, l
|
||||
|
||||
push de
|
||||
ld a, [de]
|
||||
cp 100
|
||||
ld e, 0
|
||||
jr c, .ok
|
||||
inc e
|
||||
cp 200
|
||||
jr c, .ok
|
||||
inc e
|
||||
|
||||
.ok
|
||||
dec c
|
||||
ld b, 0
|
||||
ld hl, .Actions
|
||||
rept 3
|
||||
add hl, bc
|
||||
endr
|
||||
ld d, 0
|
||||
add hl, de
|
||||
ld a, [hl]
|
||||
cp 100
|
||||
pop de
|
||||
|
||||
ld a, [de]
|
||||
jr nc, .negative
|
||||
add [hl]
|
||||
jr nc, .done
|
||||
ld a, -1
|
||||
jr .done
|
||||
|
||||
.negative
|
||||
add [hl]
|
||||
jr c, .done
|
||||
xor a
|
||||
|
||||
.done
|
||||
ld [de], a
|
||||
ld a, [wBattleMode]
|
||||
and a
|
||||
ret z
|
||||
ld a, [CurPartyMon]
|
||||
ld b, a
|
||||
ld a, [wPartyMenuCursor]
|
||||
cp b
|
||||
ret nz
|
||||
ld a, [de]
|
||||
ld [BattleMonHappiness], a
|
||||
ret
|
||||
|
||||
.Actions
|
||||
db +5, +3, +2 ; Gained a level
|
||||
db +5, +3, +2 ; Vitamin
|
||||
db +1, +1, +0 ; X Item
|
||||
db +3, +2, +1 ; Battled a Gym Leader
|
||||
db +1, +1, +0 ; Learned a move
|
||||
db -1, -1, -1 ; Lost to an enemy
|
||||
db -5, -5, -10 ; Fainted due to poison
|
||||
db -5, -5, -10 ; Lost to a much stronger enemy
|
||||
db +1, +1, +1 ; Haircut (Y1)
|
||||
db +3, +3, +1 ; Haircut (Y2)
|
||||
db +5, +5, +2 ; Haircut (Y3)
|
||||
db +1, +1, +1 ; Haircut (O1)
|
||||
db +3, +3, +1 ; Haircut (O2)
|
||||
db +10, +10, +4 ; Haircut (O3)
|
||||
db -5, -5, -10 ; Used Heal Powder or Energypowder (bitter)
|
||||
db -10, -10, -15 ; Used Energy Root (bitter)
|
||||
db -15, -15, -20 ; Used Revival Herb (bitter)
|
||||
db +3, +3, +1 ; Grooming
|
||||
db +10, +6, +4 ; Gained a level in the place where it was caught
|
||||
|
||||
StepHappiness:: ; 725a
|
||||
; Raise the party's happiness by 1 point every other step cycle.
|
||||
|
||||
ld hl, wHappinessStepCount
|
||||
ld a, [hl]
|
||||
inc a
|
||||
and 1
|
||||
ld [hl], a
|
||||
ret nz
|
||||
|
||||
ld de, PartyCount
|
||||
ld a, [de]
|
||||
and a
|
||||
ret z
|
||||
|
||||
ld c, a
|
||||
ld hl, PartyMon1Happiness
|
||||
.loop
|
||||
inc de
|
||||
ld a, [de]
|
||||
cp EGG
|
||||
jr z, .next
|
||||
inc [hl]
|
||||
jr nz, .next
|
||||
ld [hl], $ff
|
||||
|
||||
.next
|
||||
push de
|
||||
ld de, PARTYMON_STRUCT_LENGTH
|
||||
add hl, de
|
||||
pop de
|
||||
dec c
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
||||
DaycareStep:: ; 7282
|
||||
|
||||
ld a, [wDaycareMan]
|
||||
bit 0, a
|
||||
jr z, .daycare_lady
|
||||
|
||||
ld a, [wBreedMon1Level] ; level
|
||||
cp 100
|
||||
jr nc, .daycare_lady
|
||||
ld hl, wBreedMon1Exp + 2 ; exp
|
||||
inc [hl]
|
||||
jr nz, .daycare_lady
|
||||
dec hl
|
||||
inc [hl]
|
||||
jr nz, .daycare_lady
|
||||
dec hl
|
||||
inc [hl]
|
||||
ld a, [hl]
|
||||
cp 5242880 / $10000
|
||||
jr c, .daycare_lady
|
||||
ld a, 5242880 / $10000
|
||||
ld [hl], a
|
||||
|
||||
.daycare_lady
|
||||
ld a, [wDaycareLady]
|
||||
bit 0, a
|
||||
jr z, .check_egg
|
||||
|
||||
ld a, [wBreedMon2Level] ; level
|
||||
cp 100
|
||||
jr nc, .check_egg
|
||||
ld hl, wBreedMon2Exp + 2 ; exp
|
||||
inc [hl]
|
||||
jr nz, .check_egg
|
||||
dec hl
|
||||
inc [hl]
|
||||
jr nz, .check_egg
|
||||
dec hl
|
||||
inc [hl]
|
||||
ld a, [hl]
|
||||
cp 5242880 / $10000
|
||||
jr c, .check_egg
|
||||
ld a, 5242880 / $10000
|
||||
ld [hl], a
|
||||
|
||||
.check_egg
|
||||
ld hl, wDaycareMan
|
||||
bit 5, [hl] ; egg
|
||||
ret z
|
||||
ld hl, wStepsToEgg
|
||||
dec [hl]
|
||||
ret nz
|
||||
|
||||
call Random
|
||||
ld [hl], a
|
||||
callab CheckBreedmonCompatibility
|
||||
ld a, [wd265]
|
||||
cp 230
|
||||
ld b, -1 + 32 percent
|
||||
jr nc, .okay
|
||||
ld a, [wd265]
|
||||
cp 170
|
||||
ld b, 16 percent
|
||||
jr nc, .okay
|
||||
ld a, [wd265]
|
||||
cp 110
|
||||
ld b, 12 percent
|
||||
jr nc, .okay
|
||||
ld b, 4 percent
|
||||
|
||||
.okay
|
||||
call Random
|
||||
cp b
|
||||
ret nc
|
||||
ld hl, wDaycareMan
|
||||
res 5, [hl]
|
||||
set 6, [hl]
|
||||
ret
|
||||
1890
event/overworld.asm
Executable file
1890
event/overworld.asm
Executable file
File diff suppressed because it is too large
Load Diff
231
event/special.asm
Executable file
231
event/special.asm
Executable file
@@ -0,0 +1,231 @@
|
||||
SpecialGiveShuckle: ; 7305
|
||||
|
||||
; 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
|
||||
jr nc, .NotGiven
|
||||
|
||||
; Caught data.
|
||||
ld b, 0
|
||||
callba SetGiftPartyMonCaughtData
|
||||
|
||||
; 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
|
||||
ld a, $2
|
||||
ld [hli], a
|
||||
ld [hl], $6
|
||||
|
||||
; 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, DailyFlags
|
||||
set 5, [hl]
|
||||
; setflag ENGINE_SHUCKLE_GIVEN
|
||||
ld a, 1
|
||||
ld [ScriptVar], a
|
||||
ret
|
||||
|
||||
.NotGiven
|
||||
xor a
|
||||
ld [ScriptVar], a
|
||||
ret
|
||||
|
||||
SpecialShuckleOT:
|
||||
db "MANIA@"
|
||||
SpecialShuckleNick:
|
||||
db "SHUCKIE@"
|
||||
|
||||
SpecialReturnShuckle: ; 737e
|
||||
callba SelectMonFromParty
|
||||
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]
|
||||
cp 00518 / $100
|
||||
jr nz, .DontReturn
|
||||
ld a, [hl]
|
||||
cp 00518 % $100
|
||||
jr nz, .DontReturn
|
||||
|
||||
; OT
|
||||
ld a, [CurPartyMon]
|
||||
ld hl, PartyMonOT
|
||||
call SkipNames
|
||||
ld de, SpecialShuckleOT
|
||||
.CheckOT
|
||||
ld a, [de]
|
||||
cp [hl]
|
||||
jr nz, .DontReturn
|
||||
cp "@"
|
||||
jr z, .done
|
||||
inc de
|
||||
inc hl
|
||||
jr .CheckOT
|
||||
|
||||
.done
|
||||
callba CheckCurPartyMonFainted
|
||||
jr c, .fainted
|
||||
ld a, [CurPartyMon]
|
||||
ld hl, PartyMon1Happiness
|
||||
ld bc, PARTYMON_STRUCT_LENGTH
|
||||
call AddNTimes
|
||||
ld a, [hl]
|
||||
cp 150
|
||||
ld a, $3
|
||||
jr nc, .HappyToStayWithYou
|
||||
xor a ; take from pc
|
||||
ld [wPokemonWithdrawDepositParameter], a
|
||||
callab RemoveMonFromPartyOrBox
|
||||
ld a, $2
|
||||
.HappyToStayWithYou
|
||||
ld [ScriptVar], a
|
||||
ret
|
||||
|
||||
.refused
|
||||
ld a, $1
|
||||
ld [ScriptVar], a
|
||||
ret
|
||||
|
||||
.DontReturn
|
||||
xor a
|
||||
ld [ScriptVar], a
|
||||
ret
|
||||
|
||||
.fainted
|
||||
ld a, $4
|
||||
ld [ScriptVar], a
|
||||
ret
|
||||
|
||||
Special_BillsGrandfather: ; 73f7
|
||||
callba SelectMonFromParty
|
||||
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
|
||||
|
||||
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
|
||||
callba SelectMonFromParty
|
||||
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.
|
||||
; 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
|
||||
rept 3
|
||||
inc hl
|
||||
endr
|
||||
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
|
||||
|
||||
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
|
||||
ld hl, StringBuffer1
|
||||
ld de, StringBuffer3
|
||||
ld bc, PKMN_NAME_LENGTH
|
||||
jp CopyBytes
|
||||
Reference in New Issue
Block a user