Skip to content

Commit

Permalink
Pokemon are not Trainers. Only Items are TMs or HMs.
Browse files Browse the repository at this point in the history
  • Loading branch information
JustRegularLuna committed Oct 23, 2018
1 parent 2ec9e1d commit 48c0b4f
Show file tree
Hide file tree
Showing 24 changed files with 130 additions and 42 deletions.
5 changes: 3 additions & 2 deletions audio.asm
Expand Up @@ -377,9 +377,10 @@ PlayBattleMusic::
ld a, MUSIC_GYM_LEADER_BATTLE
jr .playSong
.notGymLeaderBattle
ld a, [wIsTrainerBattle]
and a
jr z, .wildBattle
ld a, [wCurOpponent]
cp 200
jr c, .wildBattle
cp OPP_SONY3
jr z, .finalBattle
cp OPP_LANCE
Expand Down
2 changes: 2 additions & 0 deletions constants/sprite_constants.asm
Expand Up @@ -101,6 +101,8 @@ const_value = 1
ITEM EQU $80
TRAINER EQU $40

OW_POKEMON EQU $80

BOULDER_MOVEMENT_BYTE_2 EQU $10

; sprite facing directions
Expand Down
18 changes: 9 additions & 9 deletions data/mapObjects/powerplant.asm
Expand Up @@ -9,15 +9,15 @@ PowerPlantObject:
db 0 ; signs

db 14 ; objects
object SPRITE_BALL, 9, 20, STAY, NONE, 1, VOLTORB, 40
object SPRITE_BALL, 32, 18, STAY, NONE, 2, VOLTORB, 40
object SPRITE_BALL, 21, 25, STAY, NONE, 3, VOLTORB, 40
object SPRITE_BALL, 25, 18, STAY, NONE, 4, ELECTRODE, 43
object SPRITE_BALL, 23, 34, STAY, NONE, 5, VOLTORB, 40
object SPRITE_BALL, 26, 28, STAY, NONE, 6, VOLTORB, 40
object SPRITE_BALL, 21, 14, STAY, NONE, 7, ELECTRODE, 43
object SPRITE_BALL, 37, 32, STAY, NONE, 8, VOLTORB, 40
object SPRITE_BIRD, 4, 9, STAY, UP, 9, ZAPDOS, 50
object SPRITE_BALL, 9, 20, STAY, NONE, 1, VOLTORB, 40 | OW_POKEMON
object SPRITE_BALL, 32, 18, STAY, NONE, 2, VOLTORB, 40 | OW_POKEMON
object SPRITE_BALL, 21, 25, STAY, NONE, 3, VOLTORB, 40 | OW_POKEMON
object SPRITE_BALL, 25, 18, STAY, NONE, 4, ELECTRODE, 43 | OW_POKEMON
object SPRITE_BALL, 23, 34, STAY, NONE, 5, VOLTORB, 40 | OW_POKEMON
object SPRITE_BALL, 26, 28, STAY, NONE, 6, VOLTORB, 40 | OW_POKEMON
object SPRITE_BALL, 21, 14, STAY, NONE, 7, ELECTRODE, 43 | OW_POKEMON
object SPRITE_BALL, 37, 32, STAY, NONE, 8, VOLTORB, 40 | OW_POKEMON
object SPRITE_BIRD, 4, 9, STAY, UP, 9, ZAPDOS, 50 | OW_POKEMON
object SPRITE_BALL, 7, 25, STAY, NONE, 10, CARBOS
object SPRITE_BALL, 28, 3, STAY, NONE, 11, HP_UP
object SPRITE_BALL, 34, 3, STAY, NONE, 12, RARE_CANDY
Expand Down
2 changes: 1 addition & 1 deletion data/mapObjects/seafoamislands5.asm
Expand Up @@ -14,7 +14,7 @@ SeafoamIslands5Object:
db 3 ; objects
object SPRITE_BOULDER, 4, 15, STAY, NONE, 1 ; person
object SPRITE_BOULDER, 5, 15, STAY, NONE, 2 ; person
object SPRITE_BIRD, 6, 1, STAY, DOWN, 3, ARTICUNO, 50
object SPRITE_BIRD, 6, 1, STAY, DOWN, 3, ARTICUNO, 50 | OW_POKEMON

; warp-to
warp_to 20, 17, SEAFOAM_ISLANDS_5_WIDTH ; SEAFOAM_ISLANDS_4
Expand Down
2 changes: 1 addition & 1 deletion data/mapObjects/unknowndungeon3.asm
Expand Up @@ -7,7 +7,7 @@ UnknownDungeon3Object:
db 0 ; signs

db 3 ; objects
object SPRITE_SLOWBRO, 27, 13, STAY, DOWN, 1, MEWTWO, 70
object SPRITE_SLOWBRO, 27, 13, STAY, DOWN, 1, MEWTWO, 70 | OW_POKEMON
object SPRITE_BALL, 16, 9, STAY, NONE, 2, ULTRA_BALL
object SPRITE_BALL, 18, 1, STAY, NONE, 3, MAX_REVIVE

Expand Down
2 changes: 1 addition & 1 deletion data/mapObjects/victoryroad2.asm
Expand Up @@ -18,7 +18,7 @@ VictoryRoad2Object:
object SPRITE_BLACK_HAIR_BOY_1, 19, 8, STAY, DOWN, 3, OPP_TAMER, 5
object SPRITE_BLACK_HAIR_BOY_2, 4, 2, STAY, DOWN, 4, OPP_POKEMANIAC, 6
object SPRITE_BLACK_HAIR_BOY_2, 26, 3, STAY, LEFT, 5, OPP_JUGGLER, 5
object SPRITE_BIRD, 11, 5, STAY, UP, 6, MOLTRES, 50
object SPRITE_BIRD, 11, 5, STAY, UP, 6, MOLTRES, 50 | OW_POKEMON
object SPRITE_BALL, 27, 5, STAY, NONE, 7, TM_17
object SPRITE_BALL, 18, 9, STAY, NONE, 8, FULL_HEAL
object SPRITE_BALL, 9, 11, STAY, NONE, 9, TM_05
Expand Down
6 changes: 3 additions & 3 deletions engine/battle/battle_transitions.asm
Expand Up @@ -81,9 +81,9 @@ BattleTransitions:
dw BattleTransition_Split ; %111

GetBattleTransitionID_WildOrTrainer:
ld a, [wCurOpponent]
cp 200
jr nc, .trainer
ld a, [wIsTrainerBattle]
and a
jr nz, .trainer
res 0, c
ret
.trainer
Expand Down
12 changes: 11 additions & 1 deletion engine/battle/core.asm
Expand Up @@ -1037,6 +1037,12 @@ TrainerBattleVictory:
; win money
ld hl, MoneyForWinningText
call PrintText

xor a
ld [wIsTrainerBattle], a
ld a, 1
ld [wWasTrainerBattle], a

ld de, wPlayerMoney + 2
ld hl, wAmountMoneyWon + 2
ld c, $3
Expand Down Expand Up @@ -1224,6 +1230,8 @@ ChooseNextMon:
; called when player is out of usable mons.
; prints appropriate lose message, sets carry flag if player blacked out (special case for initial rival fight)
HandlePlayerBlackOut:
xor a
ld [wIsTrainerBattle], a
ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr z, .notSony1Battle
Expand Down Expand Up @@ -6939,9 +6947,11 @@ InitBattleCommon:
push af
res 1, [hl]
callab InitBattleVariables
ld a, [wIsTrainerBattle]
and a
jp z, InitWildBattle
ld a, [wEnemyMonSpecies2]
sub 200
jp c, InitWildBattle
ld [wTrainerClass], a
call GetTrainerInformation
callab ReadTrainer
Expand Down
1 change: 1 addition & 0 deletions engine/battle/wild_encounters.asm
Expand Up @@ -120,6 +120,7 @@ TryDoWildEncounter:
ld [wcf91], a
ld [wEnemyMonSpecies2], a
xor a
ld [wIsTrainerBattle], a
ret

WildMonEncounterSlotChances:
Expand Down
3 changes: 3 additions & 0 deletions engine/overworld/movement.asm
Expand Up @@ -118,6 +118,9 @@ UpdateNPCSprite:
ld hl, wMapSpriteData
add l
ld l, a
jr nc, .nc
inc h
.nc
ld a, [hl] ; read movement byte 2
ld [wCurSpriteMovement2], a
ld h, $c1
Expand Down
2 changes: 1 addition & 1 deletion engine/pokedex_rating.asm
Expand Up @@ -86,7 +86,7 @@ DexRatingsTable:
dw PokedexRatingText_44242
db 150
dw PokedexRatingText_44247
db 152
db NUM_POKEMON + 1 ; 152 originally, prevent reading past the end of the list looking for an entry
dw PokedexRatingText_4424c

PokedexRatingText_44201:
Expand Down
47 changes: 40 additions & 7 deletions home.asm
Expand Up @@ -1487,6 +1487,8 @@ DisplayListMenuIDLoop::
ld [wd0b5], a
ld a, BANK(ItemNames)
ld [wPredefBank], a
ld a, ITEM_NAME
ld [wNameListType], a
call GetName
jr .storeChosenEntry
.pokemonList
Expand Down Expand Up @@ -2364,16 +2366,20 @@ EndTrainerBattle::
res 0, [hl] ; player is no longer engaged by any trainer
ld a, [wIsInBattle]
cp $ff
jp z, ResetButtonPressedAndMapScript
jr z, EndTrainerBattleWhiteout
ld a, $2
call ReadTrainerHeaderInfo
ld a, [wTrainerHeaderFlagBit]
ld c, a
ld b, FLAG_SET
call TrainerFlagAction ; flag trainer as fought
ld a, [wEnemyMonOrTrainerClass]
cp 200
jr nc, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite)
ld a, [wWasTrainerBattle]
and a
jr nz, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite)
ld a, [wCurMap]
cp POKEMONTOWER_7
jr z, .skipRemoveSprite ; the tower 7f scripts call EndTrainerBattle manually after
; wIsTrainerBattle has been unset
ld hl, wMissableObjectList
ld de, $2
ld a, [wSpriteIndex]
Expand All @@ -2383,11 +2389,19 @@ EndTrainerBattle::
ld [wMissableObjectIndex], a ; load corresponding missable object index and remove it
predef HideObject
.skipRemoveSprite
xor a
ld [wWasTrainerBattle], a
ld hl, wd730
bit 4, [hl]
res 4, [hl]
ret nz

EndTrainerBattleWhiteout:
xor a
ld [wIsTrainerBattle], a
ld [wWasTrainerBattle], a
; fallthrough to original routine

ResetButtonPressedAndMapScript::
xor a
ld [wJoyIgnore], a
Expand All @@ -2406,12 +2420,14 @@ InitBattleEnemyParameters::
ld a, [wEngagedTrainerClass]
ld [wCurOpponent], a
ld [wEnemyMonOrTrainerClass], a
cp 200
ld a, [wIsTrainerBattle]
and a
jr z, .noTrainer
ld a, [wEngagedTrainerSet]
jr c, .noTrainer
ld [wTrainerNo], a
ret
.noTrainer
ld a, [wEngagedTrainerSet]
ld [wCurEnemyLVL], a
ret

Expand Down Expand Up @@ -2507,7 +2523,17 @@ EngageMapTrainer::
ld a, [hli] ; load trainer class
ld [wEngagedTrainerClass], a
ld a, [hl] ; load trainer mon set
bit 7, a
jr nz, .pokemon
ld [wEngagedTrainerSet], a
ld a, 1
ld [wIsTrainerBattle], a
jp PlayTrainerMusic
.pokemon
and $7F
ld [wEngagedTrainerSet], a
xor a
ld [wIsTrainerBattle], a
jp PlayTrainerMusic

PrintEndBattleText::
Expand Down Expand Up @@ -3213,14 +3239,21 @@ GetName::
; [wPredefBank] = bank of list
;
; returns pointer to name in de
ld a, [wNameListType]
cp ITEM_NAME
ld a, [wd0b5]
ld [wd11e], a
jr nz, .noItem

; TM names are separate from item names.
; BUG: This applies to all names instead of just items.
; Only call this code if we are looking up an Item name
; This originally applied to all name lists, not just items
; This caused issues such as new moves having the wrong name
; This also caused name issues upon evolution with Pokemon in the TM/HM ID range
cp HM_01
jp nc, GetMachineName

.noItem
ld a, [H_LOADEDROMBANK]
push af
push hl
Expand Down
15 changes: 15 additions & 0 deletions home/copy.asm
Expand Up @@ -22,3 +22,18 @@ CopyData::
or b
jr nz, CopyData
ret

FarCopyData2::
; Identical to FarCopyData, but uses hROMBankTemp
; as temp space instead of wBuffer.
ld [hROMBankTemp], a
ld a, [H_LOADEDROMBANK]
push af
ld a, [hROMBankTemp]
ld [H_LOADEDROMBANK], a
ld [MBC1RomBank], a
call CopyData
pop af
ld [H_LOADEDROMBANK], a
ld [MBC1RomBank], a
ret
15 changes: 0 additions & 15 deletions home/copy2.asm
@@ -1,18 +1,3 @@
FarCopyData2::
; Identical to FarCopyData, but uses hROMBankTemp
; as temp space instead of wBuffer.
ld [hROMBankTemp], a
ld a, [H_LOADEDROMBANK]
push af
ld a, [hROMBankTemp]
ld [H_LOADEDROMBANK], a
ld [MBC1RomBank], a
call CopyData
pop af
ld [H_LOADEDROMBANK], a
ld [MBC1RomBank], a
ret

FarCopyData3::
; Copy bc bytes from a:de to hl.
ld [hROMBankTemp], a
Expand Down
4 changes: 4 additions & 0 deletions scripts/ceruleancity.asm
Expand Up @@ -152,6 +152,8 @@ CeruleanCityScript1:
ld a, $9
.done
ld [wTrainerNo], a
ld a, 1
ld [wIsTrainerBattle], a

xor a
ld [hJoyHeld], a
Expand All @@ -164,6 +166,8 @@ CeruleanCityScript2:
ld a, [wIsInBattle]
cp $ff
jp z, CeruleanCityScript_1948c
xor a
ld [wIsTrainerBattle], a
call CeruleanCityScript_1955d
ld a, $f0
ld [wJoyIgnore], a
Expand Down
4 changes: 4 additions & 0 deletions scripts/gary.asm
Expand Up @@ -82,6 +82,8 @@ GaryScript2:
ld a, $3
.saveTrainerId
ld [wTrainerNo], a
ld a, 1
ld [wIsTrainerBattle], a

xor a
ld [hJoyHeld], a
Expand All @@ -93,6 +95,8 @@ GaryScript3:
ld a, [wIsInBattle]
cp $ff
jp z, ResetGaryScript
xor a
ld [wIsTrainerBattle], a
call UpdateSprites
SetEvent EVENT_BEAT_CHAMPION_RIVAL
ld a, $f0
Expand Down
4 changes: 4 additions & 0 deletions scripts/oakslab.asm
Expand Up @@ -381,6 +381,8 @@ OaksLabScript11:
ret nz

; define which team rival uses, and fight it
ld a, 1
ld [wIsTrainerBattle], a
ld a, OPP_SONY1
ld [wCurOpponent], a
ld a, [wRivalStarter]
Expand Down Expand Up @@ -415,6 +417,8 @@ OaksLabScript11:
ret

OaksLabScript12:
xor a
ld [wIsTrainerBattle], a
ld a, $f0
ld [wJoyIgnore], a
ld a, PLAYER_DIR_UP
Expand Down
4 changes: 4 additions & 0 deletions scripts/pokemontower2.asm
Expand Up @@ -62,6 +62,8 @@ PokemonTower2Script1:
ld a, [wIsInBattle]
cp $ff
jp z, PokemonTower2Script_604fe
xor a
ld [wIsTrainerBattle], a
ld a, $f0
ld [wJoyIgnore], a
SetEvent EVENT_BEAT_POKEMON_TOWER_RIVAL
Expand Down Expand Up @@ -160,6 +162,8 @@ PokemonTower2Text1:
ld a, $6
.done
ld [wTrainerNo], a
ld a, 1
ld [wIsTrainerBattle], a

ld a, $1
ld [wPokemonTower2CurScript], a
Expand Down
2 changes: 2 additions & 0 deletions scripts/route12.asm
Expand Up @@ -33,6 +33,8 @@ Route12Script0:
ld [wCurOpponent], a
ld a, 30
ld [wCurEnemyLVL], a
xor a
ld [wIsTrainerBattle], a
ld a, HS_ROUTE_12_SNORLAX
ld [wMissableObjectIndex], a
predef HideObject
Expand Down
2 changes: 2 additions & 0 deletions scripts/route16.asm
Expand Up @@ -33,6 +33,8 @@ Route16Script0:
ld [wCurOpponent], a
ld a, 30
ld [wCurEnemyLVL], a
xor a
ld [wIsTrainerBattle], a
ld a, HS_ROUTE_16_SNORLAX
ld [wMissableObjectIndex], a
predef HideObject
Expand Down

0 comments on commit 48c0b4f

Please sign in to comment.