Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2016-02-27 05:26:12

Fotomac
Member
Registered: 2015-10-25
Post 156/297

Trainer name problem

I feel like I'm missing something here:

PrintBeginningBattleText: ; 58d99 (16:4d99)
    ld a, [wIsInBattle]
    dec a
    jr nz, .trainerBattle
    ld a, [wCurMap]
    cp POKEMONTOWER_3
    jr c, .notPokemonTower
    cp LAVENDER_HOUSE_1
    jr c, .pokemonTower
.notPokemonTower
    ld a, [wEnemyMonSpecies2]
    call PlayCry
    ld hl, WildMonAppearedText
    ld a, [wMoveMissed]
    and a
    jr z, .notFishing
    ld hl, HookedMonAttackedText
.notFishing
    jr .wildBattle
.trainerBattle
    call .playSFX
    ld c, 20
    call DelayFrames
    ld hl, SpecialTrainerIDs
    ld a, [wTrainerClass]
    ld de, 1
    call IsInArray
    jr c, .specialTrainer
    ld hl, TrainerWantsToFightText
.specialTrainer
    ld hl, TrainerWantsToFightText2
.wildBattle
    push hl
    callab DrawAllPokeballs
    pop hl
    call PrintText
    jr .done
.pokemonTower
    ld b, SILPH_SCOPE
    call IsItemInBag
    ld a, [wEnemyMonSpecies2]
    ld [wcf91], a
    cp MAROWAK
    jr z, .isMarowak
    ld a, b
    and a
    jr z, .noSilphScope
    callab LoadEnemyMonData
    jr .notPokemonTower
.noSilphScope
    ld hl, EnemyAppearedText
    call PrintText
    ld hl, GhostCantBeIDdText
    call PrintText
    jr .done
.isMarowak
    ld a, b
    and a
    jr z, .noSilphScope
    ld hl, EnemyAppearedText
    call PrintText
    ld hl, UnveiledGhostText
    call PrintText
    callab LoadEnemyMonData
    callab MarowakAnim
    ld hl, WildMonAppearedText
    call PrintText

How do you get it to say "The BUG CATCHER RICK wants to fight!" as opposed to "The BUG CATCHER wants to fight!", looking at this code? (And I'm pretty sure the SpecialTrainerIDs list doesn't include the BUG CATCHER trainer class.)

Offline

#2 2016-02-27 05:50:45

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,250/3,503

Re: Trainer name problem

I'm on my phone so it would be a pain to look up the link, but you might've just missed something when porting my code for individual trainer names.

Offline

#3 2016-02-27 09:12:50

Fotomac
Member
Registered: 2015-10-25
Post 157/297

Re: Trainer name problem

It's not the trainer names I'm having trouble with, it's the toggling between regular and special trainers. The code happens to be from "engine/battle/common_text.asm".

Offline

#4 2016-02-27 16:26:58

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,251/3,503

Re: Trainer name problem

I'll take a look and see what I can find. I know I mentioned on PokeCommunity to you that you have two identical lists with the same label name which wasn't letting me compile. If you changed the label name for the list in common_text.asm but forgot to change where you load it, then it would technically be loading it with an invalid pointer (the pointer to the other list which would just be gibberish in this bank) so it might be reading unrelated data as a list, and that gibberish happened to include the ID for Bug Catchers. That's just speculation at this point since I haven't gone in and checked but it seems like a simple enough mistake to make and a simple enough mistake to fix. I'll let you know more later.

Offline

#5 2016-02-29 21:57:45

Fotomac
Member
Registered: 2015-10-25
Post 160/297

Re: Trainer name problem

OK, next we've got the pointers for TrainerWantsToFightText and TrainerWantsToFightText2:

TrainerWantsToFightText: ; 58e4a (16:4e4a)
    TX_FAR _TrainerWantsToFightText
    db "@"

TrainerWantsToFightText2:
    TX_FAR _TrainerWantsToFightText2
    db "@"

which correspond to these:

_TrainerWantsToFightText:: ; 89c5e (22:5c5e)
    text "The @"
    TX_RAM wTrainerName
    db $0
    line "@"
    TX_RAM wCurTrainerName
    text " wants"
    cont "to fight!"
    prompt

_TrainerWantsToFightText2:: ; 89c5e (22:5c5e)
    text "The @"
    TX_RAM wTrainerName
    db $0
    line "wants to fight!"
    prompt

And, of course, I had to duplicate everything into separate SpecialTrainerIDs lists due to that idiot Cygwin yelling at me for three files pointing to the same list (and, of course, they have to for consistency's sake, since the files "common_text.asm", "core.asm", and "trainer_ai.asm" all have text pointers affected by this list):

SpecialTrainerIDs:
    db SONY1
    db GIOVANNI
    db ROCKET
    db BRUNO
    db BROCK
    db MISTY
    db LT__SURGE
    db ERIKA
    db KOGA
    db BLAINE
    db SABRINA
    db SONY2
    db SONY3
    db LORELEI
    db AGATHA
    db LANCE
    db "@"

SpecialTrainerIDs2:
    db SONY1
    db GIOVANNI
    db ROCKET
    db BRUNO
    db BROCK
    db MISTY
    db LT__SURGE
    db ERIKA
    db KOGA
    db BLAINE
    db SABRINA
    db SONY2
    db SONY3
    db LORELEI
    db AGATHA
    db LANCE
    db "@"

SpecialTrainerIDs3:
    db SONY1
    db GIOVANNI
    db ROCKET
    db BRUNO
    db BROCK
    db MISTY
    db LT__SURGE
    db ERIKA
    db KOGA
    db BLAINE
    db SABRINA
    db SONY2
    db SONY3
    db LORELEI
    db AGATHA
    db LANCE
    db "@"

Offline

#6 2016-03-01 00:09:52

comet
Member
Registered: 2012-04-09
Post 628/679

Re: Trainer name problem

Fotomac wrote:

And, of course, I had to duplicate everything into separate SpecialTrainerIDs lists due to that idiot Cygwin yelling at me for three files pointing to the same list (and, of course, they have to for consistency's sake, since the files "common_text.asm", "core.asm", and "trainer_ai.asm" all have text pointers affected by this list):

:: exports a label so it can be used anywhere.

Last edited by comet (2016-03-01 00:25:55)

Offline

#7 2016-03-01 00:35:12

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,256/3,503

Re: Trainer name problem

Just being able to reference it from anywhere won't necessarily mean your routine can find the data you actually want it to though. If the list is in bank 22 and you're trying to reference it in bank 16 you're still going to run into problems unless you specify which bank it is in (which you haven't been doing, and just writing code assuming the list is in the same bank as the code that is calling it).

Last edited by Mateo (2016-03-01 00:35:49)

Offline

#8 2016-03-01 03:03:33

Fotomac
Member
Registered: 2015-10-25
Post 161/297

Re: Trainer name problem

Well, how do you suggest I rewrite the relevant parts of the code?

Offline

#9 2016-03-01 03:12:58

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,257/3,503

Re: Trainer name problem

If you have room at the end of bank 0, it might be simpler to take all of the redundant instances you have and replace them with:

call IsTrainerSpecial
jr c, .whateverYouHaveNow


Then in bank 0, at the end, just add:

IsTrainerSpecial::
    ld hl, SpecialTrainerIDs
    ld a, [wTrainerClass]
    ld de, 1
    jp IsInArray

SpecialTrainerIDs:
    db SONY1
    db GIOVANNI
    db ROCKET
    db BRUNO
    db BROCK
    db MISTY
    db LT__SURGE
    db ERIKA
    db KOGA
    db BLAINE
    db SABRINA
    db SONY2
    db SONY3
    db LORELEI
    db AGATHA
    db LANCE
    db $FF


Also, IsInArray expects an array to be terminated with db $FF, not db "@" like you have it currently. As such, you're making it read past the end of the array until it hits $FF somewhere unrelated to get to the end of the list, which is probably why it thinks BugCatcher is a special trainer. "@" corresponds to $50 not $FF, and IsInArray is written to treat $FF (sometimes written as -1 in here, which is confusing to you I'm sure) as the end-of-array marker. "@" is the end-of-text marker, which is different.

Offline

#10 2016-03-01 17:36:08

Fotomac
Member
Registered: 2015-10-25
Post 162/297

Re: Trainer name problem

Just three questions:

1. Which lines of code, specifically, should I change to call IsTrainerSpecial?
2. Where is bank 0?
3. If the game erroneously assumes BugCatcher to be a special trainer, then why does the line intended to be "The BUG CATCHER RICK sent WEEDLE out!" display correctly instead of omitting the trainer's name?

Last edited by Fotomac (2016-03-01 17:36:33)

Offline

#11 2016-03-01 17:58:11

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,258/3,503

Re: Trainer name problem

1: Obviously, the lines of code that are identical to what I pasted into the new IsTrainerSpecial routine.
2: home.asm
3: You have duplicate checks on duplicate lists in multiple banks, none of which are terminated correctly. Therefore it is very likely that there are different values after the end of the list that are being read depending on which copy of the list you are checking.

Offline

#12 2016-03-01 18:16:03

Fotomac
Member
Registered: 2015-10-25
Post 163/297

Re: Trainer name problem

Regarding number three, the variables in "engine/battle/core.asm" are reading from SpecialTrainerIDs2.

ETA: I still don't understand exactly where to put call IsTrainerSpecial; I was hoping you'd be able to tell me going from the segment of code from "engine/battle/common_text.asm" I posted here.

Last edited by Fotomac (2016-03-01 18:22:49)

Offline

#13 2016-03-01 19:23:42

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,259/3,503

Re: Trainer name problem

Considering I literally just copy/pasted part of your code to make that routine (except I changed a call to a jp) it should not be difficult for you to see what to replace with a call to that new function. So anywhere you originally put a duplicate of that code, put a call instead.

Offline

#14 2016-03-01 19:40:26

Fotomac
Member
Registered: 2015-10-25
Post 164/297

Re: Trainer name problem

I'm assuming this is the part of my code you copy/pasted?

.trainerBattle
    call .playSFX
    ld c, 20
    call DelayFrames
    ld hl, SpecialTrainerIDs
    ld a, [wTrainerClass]
    ld de, 1
    call IsInArray
    jr c, .specialTrainer
    ld hl, TrainerWantsToFightText
.specialTrainer
    ld hl, TrainerWantsToFightText2

So I would replace "ld hl, SpecialTrainerIDs" with the "call IsTrainerSpecial" lines. Or was it the SpecialTrainerIDs list itself?

Offline

#15 2016-03-01 21:32:47

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,260/3,503

Re: Trainer name problem

Considering the routine you are calling is:

    ld hl, SpecialTrainerIDs
    ld a, [wTrainerClass]
    ld de, 1
    jp IsInArray



Clearly, you would replace:

    ld hl, SpecialTrainerIDs
    ld a, [wTrainerClass]
    ld de, 1
    call IsInArray

With a call to the new command, since the lines are identical. Then anywhere else you need to check if a trainer is special, you would do the same. That way you don't have a bunch of redundant checks and don't need 3 copies of that same table (just the one table, in home.asm, right after the routine.) And again, remember to end the list with either db -1 or db $FF but NOT db "@" because that is totally different.

Offline

#16 2016-03-01 21:38:08

Fotomac
Member
Registered: 2015-10-25
Post 166/297

Re: Trainer name problem

Ah, that clears things up for me now! Thanks!

Last edited by Fotomac (2016-03-01 21:39:03)

Offline

#17 2016-03-24 19:17:05

Fotomac
Member
Registered: 2015-10-25
Post 180/297

Re: Trainer name problem

New stumper! How do you clear up space in bank 0? Because Cygwin yelled at me for following your instructions.

Offline

#18 2016-03-24 19:19:48

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,279/3,503

Re: Trainer name problem

Carefully. Most of the stuff in Bank 0 is there because it has to be. Some stuff can be easily moved out, others with a little work, others are best staying there.

I noticed that you copied over "GoodCopyVideoData" in a previous commit, while seemingly never actually using it. So if that is the case, it could be removed to free up space.
You can also take Mart Inventories, split them into separate files, and include them with the other scripts for that Mart instead of having them all in bank 0 for no good reason like they are by default.

Offline

#19 2016-03-25 00:45:47

Fotomac
Member
Registered: 2015-10-25
Post 181/297

Re: Trainer name problem

What do you use GoodCopyVideoData for? And the whole Mart Inventories thing sounds like a fabulous idear. One question, though: does doing it allow you to customize a city's Poké Mart inventory depending on certain conditions in the game (e.g. adding Potions to Viridian Mart after certain conditions are met, and giving that Potion-loving guy the new dialogue to match)?

Offline

#20 2016-03-25 03:29:29

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,280/3,503

Re: Trainer name problem

It's part of the stuff I copied from Danny's Gen 2 Graphics Patch, that's why it's in Red++.

As for marts based on things, I haven't actually tried that but there is probably a way. You'd just have to experiment and see.

Offline

#21 2016-04-04 05:08:33

Fotomac
Member
Registered: 2015-10-25
Post 192/297

Re: Trainer name problem

I think I've sussed out the problem. Apparently, the Trainer Battle section of "common_text.asm" doesn't include a PrintText call. What I am having a hard time figuring out is, would adding a PrintText call after each TrainerWantsToFightText pointer be of any help?

Offline

#22 2016-04-22 04:08:39

Fotomac
Member
Registered: 2015-10-25
Post 202/297

Re: Trainer name problem

Case closed. Apparently, all I forgot was a pointer to the section after the Special Trainer section of that code.

Offline

Board footer

Powered by FluxBB