2018-06-24 07:09:41 -07:00
|
|
|
GetFirstPokemonHappiness:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Happiness
|
2016-03-27 09:47:28 -07:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wPartySpecies
|
2016-03-27 09:47:28 -07:00
|
|
|
.loop
|
|
|
|
ld a, [de]
|
|
|
|
cp EGG
|
|
|
|
jr nz, .done
|
|
|
|
inc de
|
|
|
|
add hl, bc
|
|
|
|
jr .loop
|
|
|
|
|
|
|
|
.done
|
2020-12-23 13:29:30 -08:00
|
|
|
ld [wNamedObjectIndex], a
|
2016-03-27 09:47:28 -07:00
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wScriptVar], a
|
2016-03-27 09:47:28 -07:00
|
|
|
call GetPokemonName
|
|
|
|
jp CopyPokemonName_Buffer1_Buffer3
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckFirstMonIsEgg:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartySpecies]
|
2020-12-23 13:29:30 -08:00
|
|
|
ld [wNamedObjectIndex], a
|
2016-03-27 09:47:28 -07:00
|
|
|
cp EGG
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, TRUE
|
2016-03-27 09:47:28 -07:00
|
|
|
jr z, .egg
|
|
|
|
xor a
|
|
|
|
|
|
|
|
.egg
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wScriptVar], a
|
2016-03-27 09:47:28 -07:00
|
|
|
call GetPokemonName
|
|
|
|
jp CopyPokemonName_Buffer1_Buffer3
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ChangeHappiness:
|
2018-01-23 14:39:09 -08:00
|
|
|
; Perform happiness action c on wCurPartyMon
|
2016-03-27 09:47:28 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2016-03-27 09:47:28 -07:00
|
|
|
inc a
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartySpecies - 1
|
2016-03-27 09:47:28 -07:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
cp EGG
|
|
|
|
ret z
|
|
|
|
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Happiness
|
2016-03-27 09:47:28 -07:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2016-03-27 09:47:28 -07:00
|
|
|
call AddNTimes
|
|
|
|
pop bc
|
|
|
|
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
|
|
|
|
push de
|
|
|
|
ld a, [de]
|
2017-12-11 10:47:58 -08:00
|
|
|
cp HAPPINESS_THRESHOLD_1
|
2016-03-27 09:47:28 -07:00
|
|
|
ld e, 0
|
|
|
|
jr c, .ok
|
|
|
|
inc e
|
2017-12-11 10:47:58 -08:00
|
|
|
cp HAPPINESS_THRESHOLD_2
|
2016-03-27 09:47:28 -07:00
|
|
|
jr c, .ok
|
|
|
|
inc e
|
|
|
|
|
|
|
|
.ok
|
|
|
|
dec c
|
|
|
|
ld b, 0
|
2017-12-11 19:44:25 -08:00
|
|
|
ld hl, HappinessChanges
|
2016-03-27 09:47:28 -07:00
|
|
|
add hl, bc
|
2016-05-10 09:31:49 -07:00
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
2016-03-27 09:47:28 -07:00
|
|
|
ld d, 0
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2017-12-26 19:57:19 -08:00
|
|
|
cp $64 ; why not $80?
|
2016-03-27 09:47:28 -07: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
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2016-03-27 09:47:28 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [wPartyMenuCursor]
|
|
|
|
cp b
|
|
|
|
ret nz
|
|
|
|
ld a, [de]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleMonHappiness], a
|
2016-03-27 09:47:28 -07:00
|
|
|
ret
|
|
|
|
|
2018-01-25 19:19:24 -08:00
|
|
|
INCLUDE "data/events/happiness_changes.asm"
|
2016-03-27 09:47:28 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StepHappiness::
|
2016-03-27 09:47:28 -07:00
|
|
|
; 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
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wPartyCount
|
2016-03-27 09:47:28 -07:00
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ld c, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Happiness
|
2016-03-27 09:47:28 -07:00
|
|
|
.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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DayCareStep::
|
2017-12-26 19:57:19 -08:00
|
|
|
; Raise the experience of Day-Care Pokémon every step cycle.
|
2016-03-27 09:47:28 -07:00
|
|
|
|
2017-12-10 10:37:15 -08:00
|
|
|
ld a, [wDayCareMan]
|
2018-01-22 10:18:23 -08:00
|
|
|
bit DAYCAREMAN_HAS_MON_F, a
|
2017-12-10 10:37:15 -08:00
|
|
|
jr z, .day_care_lady
|
2016-03-27 09:47:28 -07:00
|
|
|
|
|
|
|
ld a, [wBreedMon1Level] ; level
|
2017-12-11 10:47:58 -08:00
|
|
|
cp MAX_LEVEL
|
2017-12-10 10:37:15 -08:00
|
|
|
jr nc, .day_care_lady
|
2016-03-27 09:47:28 -07:00
|
|
|
ld hl, wBreedMon1Exp + 2 ; exp
|
|
|
|
inc [hl]
|
2017-12-10 10:37:15 -08:00
|
|
|
jr nz, .day_care_lady
|
2016-03-27 09:47:28 -07:00
|
|
|
dec hl
|
|
|
|
inc [hl]
|
2017-12-10 10:37:15 -08:00
|
|
|
jr nz, .day_care_lady
|
2016-03-27 09:47:28 -07:00
|
|
|
dec hl
|
|
|
|
inc [hl]
|
|
|
|
ld a, [hl]
|
2017-12-25 13:18:05 -08:00
|
|
|
cp HIGH(MAX_DAY_CARE_EXP >> 8)
|
2017-12-10 10:37:15 -08:00
|
|
|
jr c, .day_care_lady
|
2017-12-25 13:18:05 -08:00
|
|
|
ld a, HIGH(MAX_DAY_CARE_EXP >> 8)
|
2016-03-27 09:47:28 -07:00
|
|
|
ld [hl], a
|
|
|
|
|
2017-12-10 10:37:15 -08:00
|
|
|
.day_care_lady
|
|
|
|
ld a, [wDayCareLady]
|
2018-01-22 10:18:23 -08:00
|
|
|
bit DAYCARELADY_HAS_MON_F, a
|
2016-03-27 09:47:28 -07:00
|
|
|
jr z, .check_egg
|
|
|
|
|
|
|
|
ld a, [wBreedMon2Level] ; level
|
2017-12-11 10:47:58 -08:00
|
|
|
cp MAX_LEVEL
|
2016-03-27 09:47:28 -07: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]
|
2017-12-25 13:18:05 -08:00
|
|
|
cp HIGH(MAX_DAY_CARE_EXP >> 8)
|
2016-03-27 09:47:28 -07:00
|
|
|
jr c, .check_egg
|
2017-12-25 13:18:05 -08:00
|
|
|
ld a, HIGH(MAX_DAY_CARE_EXP >> 8)
|
2016-03-27 09:47:28 -07:00
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
.check_egg
|
2017-12-10 10:37:15 -08:00
|
|
|
ld hl, wDayCareMan
|
2018-01-22 10:18:23 -08:00
|
|
|
bit DAYCAREMAN_MONS_COMPATIBLE_F, [hl]
|
2016-03-27 09:47:28 -07:00
|
|
|
ret z
|
|
|
|
ld hl, wStepsToEgg
|
|
|
|
dec [hl]
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
call Random
|
|
|
|
ld [hl], a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar CheckBreedmonCompatibility
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wBreedingCompatibility]
|
2016-03-27 09:47:28 -07:00
|
|
|
cp 230
|
2020-05-07 08:09:41 -07:00
|
|
|
ld b, 31 percent + 1
|
2016-03-27 09:47:28 -07:00
|
|
|
jr nc, .okay
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wBreedingCompatibility]
|
2016-03-27 09:47:28 -07:00
|
|
|
cp 170
|
|
|
|
ld b, 16 percent
|
|
|
|
jr nc, .okay
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wBreedingCompatibility]
|
2016-03-27 09:47:28 -07:00
|
|
|
cp 110
|
|
|
|
ld b, 12 percent
|
|
|
|
jr nc, .okay
|
|
|
|
ld b, 4 percent
|
|
|
|
|
|
|
|
.okay
|
|
|
|
call Random
|
|
|
|
cp b
|
|
|
|
ret nc
|
2017-12-10 10:37:15 -08:00
|
|
|
ld hl, wDayCareMan
|
2018-01-22 10:18:23 -08:00
|
|
|
res DAYCAREMAN_MONS_COMPATIBLE_F, [hl]
|
|
|
|
set DAYCAREMAN_HAS_EGG_F, [hl]
|
2016-03-27 09:47:28 -07:00
|
|
|
ret
|