Skip to content

Commit

Permalink
Added HAPPINESS properties to trainers
Browse files Browse the repository at this point in the history
  • Loading branch information
SoupPotato committed Nov 5, 2024
1 parent 1d474c8 commit c00c3d8
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 18 deletions.
11 changes: 7 additions & 4 deletions constants/trainer_data_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ DEF CONTEXT_USE EQU 1 << CONTEXT_USE_F

; TrainerTypes bits (see engine/battle/read_trainer_party.asm)
const_def
const TRAINERTYPE_MOVES_F ; 0
const TRAINERTYPE_ITEM_F ; 1
const TRAINERTYPE_VARIABLE_F ; 3
const TRAINERTYPE_DVS_F ; 4
const TRAINERTYPE_MOVES_F ; 0
const TRAINERTYPE_ITEM_F ; 1
const TRAINERTYPE_VARIABLE_F ; 3
const TRAINERTYPE_DVS_F ; 4
const TRAINERTYPE_HAPPINESS_F ; 5

; Trainer party types (see data/trainers/parties.asm)
DEF TRAINERTYPE_NORMAL EQU 0
Expand All @@ -53,6 +54,8 @@ DEF TRAINERTYPE_ITEM EQU 1 << TRAINERTYPE_ITEM_F
DEF TRAINERTYPE_ITEM_MOVES EQU TRAINERTYPE_MOVES | TRAINERTYPE_ITEM
DEF TRAINERTYPE_VARIABLE EQU 1 << TRAINERTYPE_VARIABLE_F
DEF TRAINERTYPE_DVS EQU 1 << TRAINERTYPE_DVS_F
DEF TRAINERTYPE_HAPPINESS EQU 1 << TRAINERTYPE_HAPPINESS_F

DEF PERFECT_DV EQU $11 ; treated as $FF in enemy party data
DEF MAX_HAPPINESS EQU $42 ; treated as $FF in enemy party data

29 changes: 15 additions & 14 deletions data/trainers/parties.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
; * in all cases: db level, species
; * with TRAINERTYPE_NICKNAME: db "NICKNAME@"
; * with TRAINERTYPE_DVS: db atk|def dv, spd|spc dv
; * with TRAINERTYPE_HAPPINESS db happiness
; * with TRAINERTYPE_STAT_EXP: dw hp, atk, def, spd, spc
; * with TRAINERTYPE_ITEM: db item
; * with TRAINERTYPE_MOVES: db move 1, move 2, move 3, move 4
Expand Down Expand Up @@ -41,13 +42,13 @@ FalknerGroup:
db $fe ; delimiter
;Challenge Mode
db TRAINERTYPE_DVS | TRAINERTYPE_ITEM | TRAINERTYPE_MOVES
db 68, NOCTOWL, $fe, $ff, QUICK_CLAW, HIDDEN_POWER, NO_MOVE, NO_MOVE, NO_MOVE
db 70, TOGETIC, $ff, $ff, BRIGHTPOWDER, SWEET_KISS, TRI_ATTACK, SUBSTITUTE, BATON_PASS
db 72, FEAROW, $ff, $ff, FOCUS_BAND, DRILL_PECK, HYPER_BEAM, MUD_SLAP, SWAGGER
db 72, XATU, $ff, $ff, LUM_BERRY, GIGA_DRAIN, PSYCHIC_M, MUD_SLAP, THUNDER_WAVE
db 74, DODRIO, $ff, $ff, SCOPE_LENS, TRI_ATTACK, DRILL_PECK, JUMP_KICK, SWORDS_DANCE
db 76, PIDGEOT, $ff, $ff, SITRUS_BERRY, DOUBLE_EDGE, MUD_SLAP, SKY_ATTACK, STEEL_WING
db TRAINERTYPE_DVS | TRAINERTYPE_HAPPINESS | TRAINERTYPE_ITEM | TRAINERTYPE_MOVES
db 68, NOCTOWL, $ff, $ff, MAX_HAPPINESS, QUICK_CLAW, NIGHTMARE, HYPNOSIS, SHADOW_BALL, WING_ATTACK
db 70, TOGETIC, $ff, $ff, MAX_HAPPINESS, BRIGHTPOWDER, SWEET_KISS, TRI_ATTACK, SUBSTITUTE, BATON_PASS
db 72, FEAROW, $ff, $ff, MAX_HAPPINESS, FOCUS_BAND, DRILL_PECK, HYPER_BEAM, MUD_SLAP, SWAGGER
db 72, XATU, $ff, $ff, MAX_HAPPINESS, LUM_BERRY, GIGA_DRAIN, PSYCHIC_M, MUD_SLAP, THUNDER_WAVE
db 74, DODRIO, $ff, $ff, MAX_HAPPINESS, SCOPE_LENS, TRI_ATTACK, DRILL_PECK, JUMP_KICK, SWORDS_DANCE
db 76, PIDGEOT, $ff, $ff, MAX_HAPPINESS, SITRUS_BERRY, DOUBLE_TEAM, SWAGGER, SKY_ATTACK, RETURN ; MAX_HAPPINESS = 102 BP RETURN
db -1 ; end


Expand Down Expand Up @@ -7556,13 +7557,13 @@ ExecutiveMGroup:
db $fe ; delimiter
;Challenge Mode
db TRAINERTYPE_MOVES
db 40, KOFFING, SPITE, SLUDGE, SMOKESCREEN, SELFDESTRUCT
db 40, KOFFING, PAIN_SPLIT, SLUDGE, CURSE, SELFDESTRUCT
db 40, KOFFING, FEINT_ATTACK, DESTINY_BOND, SCREECH, SELFDESTRUCT
db 42, WEEZING, SLUDGE_BOMB, FLAMETHROWER, PSYBEAM, EXPLOSION
db 40, KOFFING, SLUDGE_BOMB, HAZE, PSYWAVE, SELFDESTRUCT
db 40, KOFFING, FRUSTRATION, SLUDGE_BOMB, SMOKESCREEN, SELFDESTRUCT
db TRAINERTYPE_HAPPINESS | TRAINERTYPE_MOVES
db 40, KOFFING, $1e, SPITE, SLUDGE, SMOKESCREEN, SELFDESTRUCT
db 40, KOFFING, $1e, PAIN_SPLIT, SLUDGE, CURSE, SELFDESTRUCT
db 40, KOFFING, $1e, FEINT_ATTACK, DESTINY_BOND, SCREECH, SELFDESTRUCT
db 42, WEEZING, $1e, SLUDGE_BOMB, FLAMETHROWER, PSYBEAM, EXPLOSION
db 40, KOFFING, $1e, SLUDGE_BOMB, HAZE, PSYWAVE, SELFDESTRUCT
db 40, KOFFING, $1e, FRUSTRATION, SLUDGE_BOMB, SMOKESCREEN, SELFDESTRUCT ; $1e = 30 HAPPINESS = 90 BP FRUSTRATION
db -1 ; end

; EXECUTIVEM (4)
Expand Down
9 changes: 9 additions & 0 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6562,7 +6562,16 @@ LoadEnemyMon:

.Happiness:
; Set happiness
ld a, [wBattleMode]
dec a
ld a, BASE_HAPPINESS
jr z, .load_happiness

ld a, [wCurPartyMon]
ld hl, wOTPartyMon1Happiness
call GetPartyLocation
ld a, [hl]
.load_happiness
ld [wEnemyMonHappiness], a
; Set level
ld a, [wCurPartyLevel]
Expand Down
21 changes: 21 additions & 0 deletions engine/battle/read_trainer_party.asm
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,28 @@ ReadTrainerPartyPieces:
.spd_spc_dv_nonzero
ld [de], a
.no_dvs
; happiness?
ld a, [wOtherTrainerType]
bit TRAINERTYPE_HAPPINESS_F, a
jr z, .no_happiness

push hl
ld a, [wOTPartyCount]
dec a
ld hl, wOTPartyMon1Happiness
call GetPartyLocation
ld d, h
ld e, l
pop hl

call GetNextTrainerDataByte
cp MAX_HAPPINESS
jr nz, .happiness_ok
ld a, $ff
.happiness_ok
ld [de], a
.no_happiness
; item?
ld a, [wOtherTrainerType]
bit TRAINERTYPE_ITEM_F, a
Expand Down
5 changes: 5 additions & 0 deletions engine/overworld/wildmons.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,11 @@ RandomPhoneMon:
inc c
inc c
.no_dvs
; TRAINERTYPE_HAPPINESS uses 1 more byte
bit TRAINERTYPE_HAPPINESS_F, b
jr z, .no_happiness
inc c
.no_happiness
; TRAINERTYPE_ITEM uses 1 more byte
bit TRAINERTYPE_ITEM_F, b
jr z, .no_item
Expand Down

0 comments on commit c00c3d8

Please sign in to comment.