aboutsummaryrefslogtreecommitdiffstats
path: root/engine/battle/read_trainer_party.asm
diff options
context:
space:
mode:
authorluckytyphlosion <alan.rj.huang@gmail.com>2015-12-06 16:08:20 -0500
committerluckytyphlosion <alan.rj.huang@gmail.com>2015-12-06 16:08:20 -0500
commit6ddc025942a03802acf6a2731d7b46f2672ae74f (patch)
tree97cf0f4bca92254f5e6d32bd78505bca9f6cda94 /engine/battle/read_trainer_party.asm
parentBankD misc functions (diff)
downloadpokeyellow-6ddc025942a03802acf6a2731d7b46f2672ae74f.tar.gz
pokeyellow-6ddc025942a03802acf6a2731d7b46f2672ae74f.tar.xz
pokeyellow-6ddc025942a03802acf6a2731d7b46f2672ae74f.zip
engine/battle/trainer_ai.asm
Diffstat (limited to 'engine/battle/read_trainer_party.asm')
-rwxr-xr-xengine/battle/read_trainer_party.asm113
1 files changed, 46 insertions, 67 deletions
diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm
index 9f94981e..a4843417 100755
--- a/engine/battle/read_trainer_party.asm
+++ b/engine/battle/read_trainer_party.asm
@@ -1,4 +1,4 @@
-ReadTrainer: ; 39c53 (e:5c53)
+ReadTrainer: ; 39bb6 (e:5bb6)
; don't change any moves in a link battle
ld a,[wLinkState]
@@ -15,9 +15,9 @@ ReadTrainer: ; 39c53 (e:5c53)
ld [hl],a
; get the pointer to trainer data for this class
- ld a,[wCurOpponent]
- sub $C9 ; convert value from pokemon to trainer
- add a,a
+ ld a,[wTrainerClass] ; get trainer class
+ dec a
+ add a
ld hl,TrainerDataPointers
ld c,a
ld b,0
@@ -25,7 +25,7 @@ ReadTrainer: ; 39c53 (e:5c53)
ld a,[hli]
ld h,[hl]
ld l,a
- ld a,[W_TRAINERNO]
+ ld a,[wTrainerNo]
ld b,a
; At this point b contains the trainer number,
; and hl points to the trainer class.
@@ -53,7 +53,7 @@ ReadTrainer: ; 39c53 (e:5c53)
.LoopTrainerData
ld a,[hli]
and a ; have we reached the end of the trainer data?
- jr z,.FinishUp
+ jp z, .AddAdditionalMoveData
ld [wcf91],a ; write species somewhere (XXX why?)
ld a,ENEMY_PARTY_DATA
ld [wMonDataLocation],a
@@ -68,7 +68,7 @@ ReadTrainer: ; 39c53 (e:5c53)
; - if [wLoneAttackNo] != 0, one pokemon on the team has a special move
ld a,[hli]
and a ; have we reached the end of the trainer data?
- jr z,.AddLoneMove
+ jr z,.AddAdditionalMoveData
ld [wCurEnemyLVL],a
ld a,[hli]
ld [wcf91],a
@@ -78,69 +78,48 @@ ReadTrainer: ; 39c53 (e:5c53)
call AddPartyMon
pop hl
jr .SpecialTrainer
-.AddLoneMove
-; does the trainer have a single monster with a different move
- ld a,[wLoneAttackNo] ; Brock is 01, Misty is 02, Erika is 04, etc
+.AddAdditionalMoveData
+; does the trainer have additional move data?
+ ld a, [wTrainerClass]
+ ld b, a
+ ld a, [wTrainerNo]
+ ld c, a
+ ld hl, SpecialTrainerMoves
+.loopAdditionalMoveData
+ ld a, [hli]
+ cp $ff
+ jr z, .FinishUp
+ cp b
+ jr nz, .asm_39c46
+ ld a, [hli]
+ cp c
+ jr nz, .asm_39c46
+ ld d, h
+ ld e, l
+.writeAdditionalMoveDataLoop
+ ld a, [de]
+ inc de
and a
- jr z,.AddTeamMove
+ jp z, .FinishUp
dec a
- add a,a
- ld c,a
- ld b,0
- ld hl,LoneMoves
- add hl,bc
- ld a,[hli]
- ld d,[hl]
- ld hl,wEnemyMon1Moves + 2
- ld bc,wEnemyMon2 - wEnemyMon1
+ ld hl, wEnemyMon1Moves
+ ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
- ld [hl],d
- jr .FinishUp
-.AddTeamMove
-; check if our trainer's team has special moves
-
-; get trainer class number
- ld a,[wCurOpponent]
- sub 200
- ld b,a
- ld hl,TeamMoves
-
-; iterate through entries in TeamMoves, checking each for our trainer class
-.IterateTeamMoves
- ld a,[hli]
- cp b
- jr z,.GiveTeamMoves ; is there a match?
- inc hl ; if not, go to the next entry
- inc a
- jr nz,.IterateTeamMoves
-
-; no matches found. is this trainer champion rival?
- ld a,b
- cp SONY3
- jr z,.ChampionRival
- jr .FinishUp ; nope
-.GiveTeamMoves
- ld a,[hl]
- ld [wEnemyMon5Moves + 2],a
- jr .FinishUp
-.ChampionRival ; give moves to his team
-
-; pidgeot
- ld a,SKY_ATTACK
- ld [wEnemyMon1Moves + 2],a
-
-; starter
- ld a,[W_RIVALSTARTER]
- cp STARTER3
- ld b,MEGA_DRAIN
- jr z,.GiveStarterMove
- cp STARTER1
- ld b,FIRE_BLAST
- jr z,.GiveStarterMove
- ld b,BLIZZARD ; must be squirtle
-.GiveStarterMove
- ld a,b
- ld [wEnemyMon6Moves + 2],a
+ ld a, [de]
+ inc de
+ dec a
+ ld c, a
+ ld b, 0
+ add hl,bc
+ ld a, [de]
+ inc de
+ ld [hl], a
+ jr .writeAdditionalMoveDataLoop
+.asm_39c46
+ ld a, [hli]
+ and a
+ jr nz, .asm_39c46
+ jr .loopAdditionalMoveData
.FinishUp
; clear wAmountMoneyWon addresses
xor a