Skip to content

Commit

Permalink
Phys / Spec Split Implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
OrchiidDev committed Sep 4, 2024
1 parent 332fbb8 commit fa70249
Show file tree
Hide file tree
Showing 14 changed files with 358 additions and 279 deletions.
7 changes: 5 additions & 2 deletions constants/type_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
; - TypeBoostItems (see data/types/type_boost_items.asm)
const_def

DEF PHYSICAL EQU const_value
const NORMAL
const FIGHTING
const FLYING
Expand All @@ -23,7 +22,6 @@ DEF UNUSED_TYPES EQU const_value
const CURSE_TYPE
DEF UNUSED_TYPES_END EQU const_value

DEF SPECIAL EQU const_value
const FIRE
const WATER
const GRASS
Expand All @@ -34,6 +32,11 @@ DEF SPECIAL EQU const_value
const DARK
DEF TYPES_END EQU const_value

DEF TYPE_MASK EQU %00111111
DEF PHYSICAL EQU %01000000
DEF SPECIAL EQU %10000000
DEF STATUS EQU %11000000

DEF NUM_TYPES EQU TYPES_END + UNUSED_TYPES - UNUSED_TYPES_END - 1 ; discount BIRD

DEF POKEDEX_TYPE_STRING_LENGTH EQU 9
514 changes: 257 additions & 257 deletions data/moves/moves.asm

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions data/types/category_names.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CategoryNames:
dw .Physical
dw .Special
dw .Status

.Physical: db "PHYSICAL@"
.Special: db "SPECIAL@"
.Status: db "STATUS@"
37 changes: 26 additions & 11 deletions engine/battle/ai/scoring.asm
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ AI_Types:
push de
push bc
ld a, [wEnemyMoveStruct + MOVE_TYPE]
and TYPE_MASK
ld d, a
ld hl, wEnemyMonMoves
ld b, NUM_MOVES + 1
Expand All @@ -207,6 +208,7 @@ AI_Types:

call AIGetEnemyMove
ld a, [wEnemyMoveStruct + MOVE_TYPE]
and TYPE_MASK
cp d
jr z, .checkmove2
ld a, [wEnemyMoveStruct + MOVE_POWER]
Expand Down Expand Up @@ -1115,17 +1117,34 @@ AI_Smart_SpDefenseUp2:
jr nc, .discourage

; 80% chance to greatly encourage this move if
; enemy's Special Defense level is lower than +2, and the player is of a special type.
; enemy's Special Defense level is lower than +2,
; and the player's Pokémon is Special-oriented.
cp BASE_STAT_LEVEL + 2
ret nc

ld a, [wBattleMonType1]
cp SPECIAL
jr nc, .encourage
ld a, [wBattleMonType2]
cp SPECIAL
push hl
; Get the pointer for the player's Pokémon's base Attack
ld a, [wBattleMonSpecies]
ld hl, BaseData + BASE_ATK
ld bc, BASE_DATA_SIZE
call AddNTimes
; Get the Pokémon's base Attack
ld a, BANK(BaseData)
call GetFarByte
ld d, a
; Get the pointer for the player's Pokémon's base Special Attack
ld bc, BASE_SAT - BASE_ATK
add hl, bc
; Get the Pokémon's base Special Attack
ld a, BANK(BaseData)
call GetFarByte
pop hl
; If its base Attack is greater than its base Special Attack,
; don't encourage this move.
cp d
ret c


.encourage
call AI_80_20
ret c
Expand Down Expand Up @@ -1409,6 +1428,7 @@ AI_Smart_Encore:

push hl
ld a, [wEnemyMoveStruct + MOVE_TYPE]
and TYPE_MASK
ld hl, wEnemyMonType1
predef CheckTypeMatchup

Expand Down Expand Up @@ -1842,11 +1862,6 @@ AI_Smart_Curse:
ld a, [wBattleMonType1]
cp GHOST
jr z, .greatly_encourage
cp SPECIAL
ret nc
ld a, [wBattleMonType2]
cp SPECIAL
ret nc
call AI_80_20
ret c
dec [hl]
Expand Down
12 changes: 7 additions & 5 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5689,14 +5689,18 @@ MoveInfoBox:
ld [wStringBuffer1], a
call .PrintPP

farcall UpdateMoveData
ld a, [wPlayerMoveStruct + MOVE_ANIM]
ld b, a
farcall GetMoveCategoryName
hlcoord 1, 9
ld de, .Type
ld de, wStringBuffer1
call PlaceString

hlcoord 7, 11
ld h, b
ld l, c
ld [hl], "/"

callfar UpdateMoveData
ld a, [wPlayerMoveStruct + MOVE_ANIM]
ld b, a
hlcoord 2, 10
Expand All @@ -5707,8 +5711,6 @@ MoveInfoBox:

.Disabled:
db "Disabled!@"
.Type:
db "TYPE/@"

.PrintPP:
hlcoord 5, 11
Expand Down
5 changes: 5 additions & 0 deletions engine/battle/effect_commands.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,7 @@ BattleCommand_Stab:
.go
ld a, BATTLE_VARS_MOVE_TYPE
call GetBattleVarAddr
and TYPE_MASK
ld [wCurType], a

push hl
Expand Down Expand Up @@ -1290,6 +1291,7 @@ BattleCommand_Stab:
.SkipStab:
ld a, BATTLE_VARS_MOVE_TYPE
call GetBattleVar
and TYPE_MASK
ld b, a
ld hl, TypeMatchups

Expand Down Expand Up @@ -1409,6 +1411,7 @@ CheckTypeMatchup:
push bc
ld a, BATTLE_VARS_MOVE_TYPE
call GetBattleVar
and TYPE_MASK
ld d, a
ld b, [hl]
inc hl
Expand Down Expand Up @@ -3003,6 +3006,7 @@ BattleCommand_DamageCalc:
ld b, a
ld a, BATTLE_VARS_MOVE_TYPE
call GetBattleVar
and TYPE_MASK
cp b
jr nz, .DoneItem

Expand Down Expand Up @@ -5922,6 +5926,7 @@ CheckMoveTypeMatchesTarget:

ld a, BATTLE_VARS_MOVE_TYPE
call GetBattleVar
and TYPE_MASK
cp NORMAL
jr z, .normal

Expand Down
1 change: 1 addition & 0 deletions engine/battle/hidden_power.asm
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ HiddenPowerDamage:
ld a, BATTLE_VARS_MOVE_TYPE
call GetBattleVarAddr
pop af
or SPECIAL
ld [hl], a

; Get the rest of the damage formula variables
Expand Down
1 change: 1 addition & 0 deletions engine/battle/move_effects/conversion.asm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ BattleCommand_Conversion:
dec a
ld hl, Moves + MOVE_TYPE
call GetMoveAttr
and TYPE_MASK
ld [de], a
inc de
pop bc
Expand Down
2 changes: 2 additions & 0 deletions engine/battle/move_effects/conversion2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ BattleCommand_Conversion2:
dec a
ld hl, Moves + MOVE_TYPE
call GetMoveAttr
and TYPE_MASK
ld d, a
pop hl
cp CURSE_TYPE
Expand All @@ -38,6 +39,7 @@ BattleCommand_Conversion2:
push hl
ld a, BATTLE_VARS_MOVE_TYPE
call GetBattleVarAddr
and TYPE_MASK
push af
push hl
ld a, d
Expand Down
1 change: 1 addition & 0 deletions engine/battle/move_effects/thunder.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BattleCommand_ThunderAccuracy:
ld a, BATTLE_VARS_MOVE_TYPE
call GetBattleVarAddr
and TYPE_MASK
inc hl
ld a, [wBattleWeather]
cp WEATHER_RAIN
Expand Down
31 changes: 31 additions & 0 deletions engine/pokemon/categories.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
GetMoveCategoryName:
; Copy the category name of move b to wStringBuffer1.

ld a, b
dec a
ld bc, MOVE_LENGTH
ld hl, Moves + MOVE_TYPE
call AddNTimes
ld a, BANK(Moves)
call GetFarByte

; Mask out the type
and ~TYPE_MASK
; Shift the category bits into the range 0-2
rlc a
rlc a
dec a

ld hl, CategoryNames
ld e, a
ld d, 0
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
ld de, wStringBuffer1
ld bc, MOVE_NAME_LENGTH
jp CopyBytes

INCLUDE "data/types/category_names.asm"
16 changes: 12 additions & 4 deletions engine/pokemon/mon_menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ MoveScreenLoop:
.moving_move
ld a, " "
hlcoord 1, 11
ld bc, 5
ld bc, 8
call ByteFill
hlcoord 1, 12
lb bc, 5, SCREEN_WIDTH - 2
Expand Down Expand Up @@ -1193,7 +1193,15 @@ PlaceMoveData:
call PlaceString
ld a, [wCurSpecies]
ld b, a
hlcoord 2, 12
farcall GetMoveCategoryName
hlcoord 1, 11
ld de, wStringBuffer1
call PlaceString
ld a, [wCurSpecies]
ld b, a
hlcoord 1, 12
ld [hl], "/"
inc hl
predef PrintMoveType
ld a, [wCurSpecies]
dec a
Expand Down Expand Up @@ -1223,9 +1231,9 @@ PlaceMoveData:
ret

String_MoveType_Top:
db "┌─────┐@"
db "┌────────┐@"
String_MoveType_Bottom:
db "│TYPE/└@"
db "│ └@"
String_MoveAtk:
db "ATK/@"
String_MoveNoPower:
Expand Down
1 change: 1 addition & 0 deletions engine/pokemon/types.asm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ PrintMoveType:
ld a, BANK(Moves)
call FarCopyBytes
ld a, [wStringBuffer1 + MOVE_TYPE]
and TYPE_MASK
pop hl

ld b, a
Expand Down
1 change: 1 addition & 0 deletions main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ INCLUDE "engine/events/basement_key.asm"
INCLUDE "engine/events/sacred_ash.asm"
INCLUDE "engine/pokemon/tempmon.asm"
INCLUDE "engine/pokemon/types.asm"
INCLUDE "engine/pokemon/categories.asm"
INCLUDE "engine/battle/getgen1trainerclassname.asm"
INCLUDE "engine/pokemon/mon_stats.asm"
INCLUDE "engine/link/init_list.asm"
Expand Down

0 comments on commit fa70249

Please sign in to comment.