2016-03-27 16:47:28 +00:00
|
|
|
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]
|
2017-12-11 18:47:58 +00:00
|
|
|
cp HAPPINESS_THRESHOLD_1
|
2016-03-27 16:47:28 +00:00
|
|
|
ld e, 0
|
|
|
|
jr c, .ok
|
|
|
|
inc e
|
2017-12-11 18:47:58 +00:00
|
|
|
cp HAPPINESS_THRESHOLD_2
|
2016-03-27 16:47:28 +00:00
|
|
|
jr c, .ok
|
|
|
|
inc e
|
|
|
|
|
|
|
|
.ok
|
|
|
|
dec c
|
|
|
|
ld b, 0
|
2017-12-12 03:44:25 +00:00
|
|
|
ld hl, HappinessChanges
|
2016-03-27 16:47:28 +00:00
|
|
|
add hl, bc
|
2016-05-10 16:31:49 +00:00
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
2016-03-27 16:47:28 +00:00
|
|
|
ld d, 0
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2017-12-11 18:47:58 +00:00
|
|
|
cp $64 ; $80?
|
2016-03-27 16:47:28 +00:00
|
|
|
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
|
|
|
|
|
2017-12-12 03:44:25 +00:00
|
|
|
|
2017-12-11 18:47:58 +00:00
|
|
|
INCLUDE "data/happiness_changes.asm"
|
2016-03-27 16:47:28 +00:00
|
|
|
|
2017-12-12 03:44:25 +00:00
|
|
|
|
2016-03-27 16:47:28 +00:00
|
|
|
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
|
|
|
|
|
2017-12-10 18:37:15 +00:00
|
|
|
DayCareStep:: ; 7282
|
2016-03-27 16:47:28 +00:00
|
|
|
|
2017-12-10 18:37:15 +00:00
|
|
|
ld a, [wDayCareMan]
|
2016-03-27 16:47:28 +00:00
|
|
|
bit 0, a
|
2017-12-10 18:37:15 +00:00
|
|
|
jr z, .day_care_lady
|
2016-03-27 16:47:28 +00:00
|
|
|
|
|
|
|
ld a, [wBreedMon1Level] ; level
|
2017-12-11 18:47:58 +00:00
|
|
|
cp MAX_LEVEL
|
2017-12-10 18:37:15 +00:00
|
|
|
jr nc, .day_care_lady
|
2016-03-27 16:47:28 +00:00
|
|
|
ld hl, wBreedMon1Exp + 2 ; exp
|
|
|
|
inc [hl]
|
2017-12-10 18:37:15 +00:00
|
|
|
jr nz, .day_care_lady
|
2016-03-27 16:47:28 +00:00
|
|
|
dec hl
|
|
|
|
inc [hl]
|
2017-12-10 18:37:15 +00:00
|
|
|
jr nz, .day_care_lady
|
2016-03-27 16:47:28 +00:00
|
|
|
dec hl
|
|
|
|
inc [hl]
|
|
|
|
ld a, [hl]
|
|
|
|
cp 5242880 / $10000
|
2017-12-10 18:37:15 +00:00
|
|
|
jr c, .day_care_lady
|
2016-03-27 16:47:28 +00:00
|
|
|
ld a, 5242880 / $10000
|
|
|
|
ld [hl], a
|
|
|
|
|
2017-12-10 18:37:15 +00:00
|
|
|
.day_care_lady
|
|
|
|
ld a, [wDayCareLady]
|
2016-03-27 16:47:28 +00:00
|
|
|
bit 0, a
|
|
|
|
jr z, .check_egg
|
|
|
|
|
|
|
|
ld a, [wBreedMon2Level] ; level
|
2017-12-11 18:47:58 +00:00
|
|
|
cp MAX_LEVEL
|
2016-03-27 16:47:28 +00:00
|
|
|
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
|
2017-12-10 18:37:15 +00:00
|
|
|
ld hl, wDayCareMan
|
2016-03-27 16:47:28 +00:00
|
|
|
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
|
2017-12-10 18:37:15 +00:00
|
|
|
ld hl, wDayCareMan
|
2016-03-27 16:47:28 +00:00
|
|
|
res 5, [hl]
|
|
|
|
set 6, [hl]
|
|
|
|
ret
|