Skip to content
Permalink
Browse files

Trainers are not Pokemon

  • Loading branch information...
TheFakeMateo committed Oct 23, 2015
1 parent 59afaf2 commit 5b2068ad14d051ca983fde68456539ce705c826b
@@ -377,9 +377,10 @@ PlayBattleMusic:: ; 0x90c6
ld a, MUSIC_GYM_LEADER_BATTLE
jr .playSong
.notGymLeaderBattle
ld a, [wIsTrainerBattle]
and a
jr z, .wildBattle
ld a, [W_CUROPPONENT]
cp TRAINER_START
jr c, .wildBattle
cp SONY3 + TRAINER_START
jr z, .finalBattle
cp LANCE + TRAINER_START
@@ -107,6 +107,8 @@ const_value = 1
ITEM EQU $80
TRAINER EQU $40

OW_POKEMON EQU $80

BOULDER_MOVEMENT_BYTE_2 EQU $10

; sprite facing directions
@@ -8,7 +8,7 @@ FarawayIslandInsideObject:
db $0 ; signs

db $1 ; people
db SPRITE_SLOWBRO, $c + 4, $c + 4, $ff, $d0, TRAINER | $1, MEW, 30
db SPRITE_SLOWBRO, $c + 4, $c + 4, $ff, $d0, TRAINER | $1, MEW, 30 | OW_POKEMON

; warp-to
EVENT_DISP FARAWAY_ISLAND_INSIDE_WIDTH, $13, $c ; FARAWAY_ISLAND_OUTSIDE
@@ -9,15 +9,15 @@ PowerPlantObject: ; 0x1e3bf (size=135)
db $0 ; signs

db $e ; people
db SPRITE_BALL, $14 + 4, $9 + 4, $ff, $ff, TRAINER | $1, VOLTORB, 40
db SPRITE_BALL, $12 + 4, $20 + 4, $ff, $ff, TRAINER | $2, VOLTORB, 40
db SPRITE_BALL, $19 + 4, $15 + 4, $ff, $ff, TRAINER | $3, VOLTORB, 40
db SPRITE_BALL, $12 + 4, $19 + 4, $ff, $ff, TRAINER | $4, ELECTRODE, 43
db SPRITE_BALL, $22 + 4, $17 + 4, $ff, $ff, TRAINER | $5, VOLTORB, 40
db SPRITE_BALL, $1c + 4, $1a + 4, $ff, $ff, TRAINER | $6, VOLTORB, 40
db SPRITE_BALL, $e + 4, $15 + 4, $ff, $ff, TRAINER | $7, ELECTRODE, 43
db SPRITE_BALL, $20 + 4, $25 + 4, $ff, $ff, TRAINER | $8, VOLTORB, 40
db SPRITE_BIRD, $9 + 4, $4 + 4, $ff, $d1, TRAINER | $9, ZAPDOS, 50
db SPRITE_BALL, $14 + 4, $9 + 4, $ff, $ff, TRAINER | $1, VOLTORB, 40 | OW_POKEMON
db SPRITE_BALL, $12 + 4, $20 + 4, $ff, $ff, TRAINER | $2, VOLTORB, 40 | OW_POKEMON
db SPRITE_BALL, $19 + 4, $15 + 4, $ff, $ff, TRAINER | $3, VOLTORB, 40 | OW_POKEMON
db SPRITE_BALL, $12 + 4, $19 + 4, $ff, $ff, TRAINER | $4, ELECTRODE, 43 | OW_POKEMON
db SPRITE_BALL, $22 + 4, $17 + 4, $ff, $ff, TRAINER | $5, VOLTORB, 40 | OW_POKEMON
db SPRITE_BALL, $1c + 4, $1a + 4, $ff, $ff, TRAINER | $6, VOLTORB, 40 | OW_POKEMON
db SPRITE_BALL, $e + 4, $15 + 4, $ff, $ff, TRAINER | $7, ELECTRODE, 43 | OW_POKEMON
db SPRITE_BALL, $20 + 4, $25 + 4, $ff, $ff, TRAINER | $8, VOLTORB, 40 | OW_POKEMON
db SPRITE_BIRD, $9 + 4, $4 + 4, $ff, $d1, TRAINER | $9, ZAPDOS, 50 | OW_POKEMON
db SPRITE_BALL, $19 + 4, $7 + 4, $ff, $ff, ITEM | $a, CARBOS
db SPRITE_BALL, $3 + 4, $1c + 4, $ff, $ff, ITEM | $b, HP_UP
db SPRITE_BALL, $3 + 4, $22 + 4, $ff, $ff, ITEM | $c, RARE_CANDY
@@ -14,7 +14,7 @@ SeafoamIslands5Object: ; 0x468bc (size=62)
db $3 ; people
db SPRITE_BOULDER, $f + 4, $4 + 4, $ff, $ff, $1 ; person
db SPRITE_BOULDER, $f + 4, $5 + 4, $ff, $ff, $2 ; person
db SPRITE_BIRD, $1 + 4, $6 + 4, $ff, $d0, TRAINER | $3, ARTICUNO, 50
db SPRITE_BIRD, $1 + 4, $6 + 4, $ff, $d0, TRAINER | $3, ARTICUNO, 50 | OW_POKEMON

; warp-to
EVENT_DISP SEAFOAM_ISLANDS_5_WIDTH, $11, $14 ; SEAFOAM_ISLANDS_4
@@ -8,8 +8,8 @@ SouthernIslandInsideObject:
db $0 ; signs

db $2 ; people
db SPRITE_BIRD, $b + 4, $c + 4, $ff, $d0, TRAINER | $1, LATIOS, 60
db SPRITE_BIRD, $b + 4, $e + 4, $ff, $d0, TRAINER | $2, LATIAS, 60
db SPRITE_BIRD, $b + 4, $c + 4, $ff, $d0, TRAINER | $1, LATIOS, 60 | OW_POKEMON
db SPRITE_BIRD, $b + 4, $e + 4, $ff, $d0, TRAINER | $2, LATIAS, 60 | OW_POKEMON

; warp-to
EVENT_DISP SOUTHERN_ISLAND_INSIDE_WIDTH, $15, $c ; SOUTHERN_ISLAND_OUTSIDE
@@ -7,7 +7,7 @@ UnknownDungeon3Object: ; 0x45f36 (size=34)
db $0 ; signs

db $3 ; people
db SPRITE_SLOWBRO, $d + 4, $1b + 4, $ff, $d0, TRAINER | $1, MEWTWO, 70
db SPRITE_SLOWBRO, $d + 4, $1b + 4, $ff, $d0, TRAINER | $1, MEWTWO, 70 | OW_POKEMON
db SPRITE_BALL, $9 + 4, $10 + 4, $ff, $ff, ITEM | $2, ULTRA_BALL
db SPRITE_BALL, $1 + 4, $12 + 4, $ff, $ff, ITEM | $3, MAX_REVIVE

@@ -18,7 +18,7 @@ VictoryRoad2Object: ; 0x51915 (size=154)
db SPRITE_BLACK_HAIR_BOY_1, $8 + 4, $13 + 4, $ff, $d0, TRAINER | $3, TAMER + TRAINER_START, $5
db SPRITE_BLACK_HAIR_BOY_2, $2 + 4, $4 + 4, $ff, $d0, TRAINER | $4, POKEMANIAC + TRAINER_START, $6
db SPRITE_BLACK_HAIR_BOY_2, $3 + 4, $1a + 4, $ff, $d2, TRAINER | $5, JUGGLER + TRAINER_START, $5
db SPRITE_BIRD, $5 + 4, $b + 4, $ff, $d1, TRAINER | $6, MOLTRES, 50
db SPRITE_BIRD, $5 + 4, $b + 4, $ff, $d1, TRAINER | $6, MOLTRES, 50 | OW_POKEMON
db SPRITE_BALL, $5 + 4, $1b + 4, $ff, $ff, ITEM | $7, TM_23
db SPRITE_BALL, $9 + 4, $12 + 4, $ff, $ff, ITEM | $8, FULL_HEAL
db SPRITE_BALL, $b + 4, $9 + 4, $ff, $ff, ITEM | $9, TM_01
@@ -165,9 +165,9 @@ BattleTransitions: ; 709d2 (1c:49d2)
dw BattleTransition_Split ; %111

GetBattleTransitionID_WildOrTrainer: ; 709e2 (1c:49e2)
ld a, [W_CUROPPONENT]
cp TRAINER_START
jr nc, .trainer
ld a, [wIsTrainerBattle]
and a
jr nz, .trainer
res 0, c
ret
.trainer
@@ -171,6 +171,8 @@ TryDoWildEncounter: ; 13870 (4:7870)
ld a, [hl]
ld [wcf91], a
ld [wEnemyMonSpecies2], a
xor a
ld [wIsTrainerBattle], a
ld a, [wRepelRemainingSteps]
and a
jr z, .willEncounter
@@ -1237,6 +1237,8 @@ ChooseNextMon: ; 3c7d8 (f:47d8)
; called when player is out of usable mons.
; prints approriate lose message, sets carry flag if player blacked out (special case for initial rival fight)
HandlePlayerBlackOut: ; 3c837 (f:4837)
xor a
ld [wIsTrainerBattle], a
ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr z, .notSony1Battle
@@ -6938,9 +6940,11 @@ asm_3ef3d: ; 3ef3d (f:6f3d)
push af
res 1, [hl]
callab InitBattleVariables
ld a, [wIsTrainerBattle]
and a
jp z, InitWildBattle
ld a, [wEnemyMonSpecies2]
sub TRAINER_START
jp c, InitWildBattle
ld [W_TRAINERCLASS], a
call GetTrainerInformation
callab ReadTrainer
@@ -740,8 +740,6 @@ UncompressMonSprite:: ; 1627 (0:1627)
.GotBank
jp UncompressSpriteData

ds $19


; de: destination location
LoadMonFrontSprite:: ; 1665 (0:1665)
@@ -2390,16 +2388,20 @@ EndTrainerBattle:: ; 3275 (0:3275)
res 0, [hl] ; player is no longer engaged by any trainer
ld a, [W_ISINBATTLE] ; W_ISINBATTLE
cp $ff
jp z, ResetButtonPressedAndMapScript
jr z, EndTrainerBattleWhiteout
ld a, $2
call ReadTrainerHeaderInfo
ld a, [wTrainerHeaderFlagBit]
ld c, a
ld b, $1
call TrainerFlagAction ; flag trainer as fought
ld a, [W_ENEMYMONORTRAINERCLASS]
cp TRAINER_START
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, [W_CURMAP]
cp POKEMONTOWER_7
jr z, .skipRemoveSprite ; the tower 7f scripts call EndTrainerBattle manually after
; wIsTrainerBattle has been unset
ld hl, W_MISSABLEOBJECTLIST
ld de, $2
ld a, [wSpriteIndex]
@@ -2409,6 +2411,8 @@ EndTrainerBattle:: ; 3275 (0:3275)
ld [wcc4d], 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]
@@ -2423,6 +2427,13 @@ ResetButtonPressedAndMapScript:: ; 32c1 (0:32c1)
ld [W_CURMAPSCRIPT], a ; reset battle status
ret

EndTrainerBattleWhiteout:
xor a
ld [wIsTrainerBattle], a
ld [wWasTrainerBattle], a
jp ResetButtonPressedAndMapScript
; calls TrainerWalkUpToPlayer
TrainerWalkUpToPlayer_Bank0:: ; 32cf (0:32cf)
ld b, BANK(TrainerWalkUpToPlayer)
@@ -2434,12 +2445,14 @@ InitBattleEnemyParameters:: ; 32d7 (0:32d7)
ld a, [wEngagedTrainerClass]
ld [W_CUROPPONENT], a ; wd059
ld [W_ENEMYMONORTRAINERCLASS], a
cp TRAINER_START
ld a, [wIsTrainerBattle]
and a
jr z, .noTrainer
ld a, [wEngagedTrainerSet] ; wcd2e
jr c, .noTrainer
ld [W_TRAINERNO], a ; wd05d
ret
.noTrainer
ld a, [wEngagedTrainerSet]
ld [W_CURENEMYLVL], a ; W_CURENEMYLVL
ret

@@ -2535,7 +2548,17 @@ EngageMapTrainer:: ; 336a (0:336a)
ld a, [hli] ; load trainer class
ld [wEngagedTrainerClass], a
ld a, [hl] ; load trainer mon set
bit 7, a
jr nz, .pokemon
ld [wEnemyMonAttackMod], a
ld a, 1
ld [wIsTrainerBattle], a
jp PlayTrainerMusic
.pokemon
and $7F
ld [wEnemyMonAttackMod], a ; wcd2e
xor a
ld [wIsTrainerBattle], a
jp PlayTrainerMusic

PrintEndBattleText:: ; 3381 (0:3381)
@@ -3131,7 +3154,6 @@ LoadHpBarAndStatusTilePatterns::
ld hl,vChars1 + $400
lb bc,BANK(EXPBarGraphics), (EXPBarGraphicsEnd - EXPBarGraphics) / $10
jp GoodCopyVideoData
ds $8


FillMemory::
@@ -22,3 +22,18 @@ CopyData::
or b
jr nz, CopyData
ret

FarCopyData2::
; Identical to FarCopyData, but uses $ff8b
; as temp space instead of wBuffer.
ld [$ff8b],a
ld a,[H_LOADEDROMBANK]
push af
ld a,[$ff8b]
ld [H_LOADEDROMBANK],a
ld [MBC1RomBank],a
call CopyData
pop af
ld [H_LOADEDROMBANK],a
ld [MBC1RomBank],a
ret
@@ -1,18 +1,3 @@
FarCopyData2::
; Identical to FarCopyData, but uses $ff8b
; as temp space instead of wBuffer.
ld [$ff8b],a
ld a,[H_LOADEDROMBANK]
push af
ld a,[$ff8b]
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 [$ff8b],a
@@ -152,6 +152,8 @@ CeruleanCityScript1: ; 19567 (6:5567)
ld a, $9
.done
ld [W_TRAINERNO], a
ld a, 1
ld [wIsTrainerBattle], a

xor a
ld [hJoyHeld], a
@@ -164,6 +166,8 @@ CeruleanCityScript2: ; 195b1 (6:55b1)
ld a, [W_ISINBATTLE]
cp $ff
jp z, CeruleanCityScript_1948c
xor a
ld [wIsTrainerBattle], a
call CeruleanCityScript_1955d
ld a, $f0
ld [wJoyIgnore], a
@@ -82,6 +82,8 @@ GaryScript2: ; 75f6a (1d:5f6a)
ld a, $3
.done
ld [W_TRAINERNO], a
ld a, 1
ld [wIsTrainerBattle], a

xor a
ld [hJoyHeld], a
@@ -93,6 +95,8 @@ GaryScript3: ; 75fbb (1d:5fbb)
ld a, [W_ISINBATTLE]
cp $ff
jp z, GaryScript_75f29
xor a
ld [wIsTrainerBattle], a
call UpdateSprites ; move sprites
ld hl, wd867
set 1, [hl]
@@ -357,6 +357,8 @@ OaksLabScript11: ; 1cdb9 (7:4db9)
ret nz

; define which team rival uses, and fight it
ld a, 1
ld [wIsTrainerBattle], a
ld a, SONY1 + TRAINER_START
ld [W_CUROPPONENT], a
ld a, [W_RIVALSTARTER]
@@ -391,6 +393,8 @@ OaksLabScript11: ; 1cdb9 (7:4db9)
ret

OaksLabScript12: ; 1ce03 (7:4e03)
xor a
ld [wIsTrainerBattle], a
ld a, $f0
ld [wJoyIgnore], a
ld a, $8
@@ -64,6 +64,8 @@ PokemonTower2Script1: ; 60563 (18:4563)
ld a, [W_ISINBATTLE]
cp $ff
jp z, PokemonTower2Script_604fe
xor a
ld [wIsTrainerBattle], a
ld a, $f0
ld [wJoyIgnore], a
ld hl, wd764
@@ -149,6 +151,8 @@ PokemonTower2Text1: ; 605df (18:45df)
ld a, $6
.done
ld [W_TRAINERNO], a
ld a, 1
ld [wIsTrainerBattle], a

ld a, $1
ld [W_POKEMONTOWER2CURSCRIPT], a
@@ -33,6 +33,8 @@ Route22Script_50ed6: ; 50ed6 (14:4ed6)
.asm_50ee1
ld a, [hl]
ld [W_TRAINERNO], a ; wd05d
ld a, 1
ld [wIsTrainerBattle], a
ret

Route22MoveRivalSprite: ; 50ee6 (14:4ee6)
@@ -147,6 +149,8 @@ Route22Script2: ; 50fb5 (14:4fb5)
ld a, [W_ISINBATTLE]
cp $ff
jp z, Route22Script_50ece
xor a
ld [wIsTrainerBattle], a
ld a, [wSpriteStateData1 + 9]
and a
jr nz, .asm_50fc7 ; 0x50fc1 $4
@@ -288,6 +292,8 @@ Route22Script5: ; 510df (14:50df)
ld a, [W_ISINBATTLE] ; W_ISINBATTLE
cp $ff
jp z, Route22Script_50ece
xor a
ld [wIsTrainerBattle], a
ld a, $2
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
ld a, [wcf0d]
@@ -194,13 +194,17 @@ SilphCo7Script3: ; 51c82 (14:5c82)
ld a, $9
.asm_51cc0
ld [W_TRAINERNO], a ; wd05d
ld a, 1
ld [wIsTrainerBattle], a
ld a, $4
jp SilphCo7Text_51c10

SilphCo7Script4: ; 51cc8 (14:5cc8)
ld a, [W_ISINBATTLE] ; W_ISINBATTLE
cp $ff
jp z, SilphCo7Text_51c0c
xor a
ld [wIsTrainerBattle], a
ld a, $f0
ld [wJoyIgnore], a
ld hl, wd82f

0 comments on commit 5b2068a

Please sign in to comment.
You can’t perform that action at this time.