Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2018-01-07 19:11:21

Shararamosh
Member
Registered: 2016-08-25
Post 15/24

Adding new trainer or trainer class in Pokemon Red/Blue.

Hello, it's been a while since I've visited Skeetendo. But I've some ideas for my rom-hack, and one of them includes new trainer or trainer class. But as many of you know, I'm a complete noob in Z80-Assembler. So, I'll be very glad if someone can tell me how to add a new trainer class.

Offline

#2 2018-01-09 00:59:06

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,054/1,119

Re: Adding new trainer or trainer class in Pokemon Red/Blue.

Give them a constant in constants/trainer_constants.asm

Give them some sprite objects in data/mapObjects/

Give them some party data in data/trainer_parties.asm

Give them a name string in engine/battle/save_trainer_name.asm and text/trainer_names.asm

Give them an AI in engine/battle/trainer_ai.asm

Give them a pointer to a battle pic and a base money reward in engine/battle/trainer_pic_money_pointers.asm

Include their battle pic in main.asm in bank $13

That's everything I can think of at the moment.

If there isn't enough room in bank $13 for a new pic, move all of the trainer pics to a new bank

You shouldn't have to write any z80 code to add trainer classes. Just add to existing data structures.

Offline

#3 2018-01-09 11:41:58

Shararamosh
Member
Registered: 2016-08-25
Post 17/24

Re: Adding new trainer or trainer class in Pokemon Red/Blue.

Danny-E 33 wrote:

Give them a constant in constants/trainer_constants.asm

Give them some sprite objects in data/mapObjects/

Give them some party data in data/trainer_parties.asm

Give them a name string in engine/battle/save_trainer_name.asm and text/trainer_names.asm

Give them an AI in engine/battle/trainer_ai.asm

Give them a pointer to a battle pic and a base money reward in engine/battle/trainer_pic_money_pointers.asm

Include their battle pic in main.asm in bank $13

That's everything I can think of at the moment.

If there isn't enough room in bank $13 for a new pic, move all of the trainer pics to a new bank

You shouldn't have to write any z80 code to add trainer classes. Just add to existing data structures.

I've got a problem. I'm trying to move all trainer pics to another bank, but Cygwin shows error: rgbasm -D _RED -h -o main_red.o main.asm
D:\Program Files\Cygwin\usr\local\bin\rgbasm.exe: Section 'bank2D' is too big (old size 16383 + 2 > 16384)
make: *** [Makefile:37: main_red.o] Ошибка 1

Offline

#4 2018-01-10 20:41:27

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,055/1,119

Re: Adding new trainer or trainer class in Pokemon Red/Blue.

Are you using a mod as a base?
Did you try moving the trainer pics to bank $2D?

If this is the case, I think you are using a mod that already uses bank $2D.
You need to move all of the trainer pics to a currently empty bank.

Offline

#5 2018-01-14 22:23:56

Shararamosh
Member
Registered: 2016-08-25
Post 18/24

Re: Adding new trainer or trainer class in Pokemon Red/Blue.

Danny-E 33 wrote:

Are you using a mod as a base?
Did you try moving the trainer pics to bank $2D?

If this is the case, I think you are using a mod that already uses bank $2D.
You need to move all of the trainer pics to a currently empty bank.

I am using a version where I've added a bunch of text. I will try to do it on the original Pokered.

Offline

#6 2018-01-14 22:30:28

Shararamosh
Member
Registered: 2016-08-25
Post 19/24

Re: Adding new trainer or trainer class in Pokemon Red/Blue.

Danny-E 33 wrote:

Are you using a mod as a base?
Did you try moving the trainer pics to bank $2D?

If this is the case, I think you are using a mod that already uses bank $2D.
You need to move all of the trainer pics to a currently empty bank.

That's strange. I'm trying to make the original roms and it shows error 1: $ make
rgbasm -D _RED -h -o audio_red.o audio.asm
rgbasm -D _RED -h -o main_red.o main.asm
rgbasm -D _RED -h -o text_red.o text.asm
rgbasm -D _RED -h -o wram_red.o wram.asm
rgblink -n pokered.sym -l pokered.link -o pokered.gbc audio_red.o main_red.o text_red.o wram_red.o
usage: rgblink [-t] [-m mapfile] [-n symfile] [-o outfile] [-p pad_value]
               [-s symbol] file [...]
D:\Program Files\Cygwin\usr\local\bin\rgblink.exe: invalid option -- l
make: *** [Makefile:47: pokered.gbc] Ошибка 1

Offline

#7 2018-01-14 23:23:42

Ammako
Member
Registered: 2016-03-06
Post 142/158

Re: Adding new trainer or trainer class in Pokemon Red/Blue.

pokered uses rgbds 0.3.3 now. Maybe you were working on an older version of pokered before which used 0.2.5 and that's why you're getting this error trying to compile fresh pokered.

Offline

#8 2018-01-19 00:08:59

Shararamosh
Member
Registered: 2016-08-25
Post 20/24

Re: Adding new trainer or trainer class in Pokemon Red/Blue.

Danny-E 33 wrote:

Are you using a mod as a base?
Did you try moving the trainer pics to bank $2D?

If this is the case, I think you are using a mod that already uses bank $2D.
You need to move all of the trainer pics to a currently empty bank.

I've downloaded a new clean Pokered and tried to move all trainer pics to bank $2D by changing SECTION "bank13",ROMX,BANK[$13] in text.asm to SECTION "bank2d",ROMX,BANK[$2D], but Cygwin still shows an error message:
rgbasm -D _RED -h -o main_red.o main.asm
ERROR: main.asm(1313) -> engine/predefs.asm(106) -> add_predef(2):
        Section 'bank2d' is too big (max size = 0x4000 bytes).
make: *** [Makefile:37: main_red.o] Ошибка 5

Offline

#9 2018-01-28 19:50:55

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,058/1,119

Re: Adding new trainer or trainer class in Pokemon Red/Blue.

I didn't mean simply change "SECTION "bank13",ROMX,BANK[$13]" to "SECTION "bank2d",ROMX,BANK[$2D]"
(also I'm assuming you meant to say main.asm not text.asm right?)

The reason all that data won't fit in bank $13 is that there is a lot more in bank $13 than just the trainer sprites.
There is some map data and some engine code at the bottom of bank $13.

If you just change the bank number, then it still won't fit in that new bank.

What I mean is create an additional SECTION. Leave the map data and engine code in bank $13 and put all the trainer pics in bank $2D.

Offline

#10 2018-01-29 22:34:18

Shararamosh
Member
Registered: 2016-08-25
Post 22/24

Re: Adding new trainer or trainer class in Pokemon Red/Blue.

Danny-E 33 wrote:

I didn't mean simply change "SECTION "bank13",ROMX,BANK[$13]" to "SECTION "bank2d",ROMX,BANK[$2D]"
(also I'm assuming you meant to say main.asm not text.asm right?)

The reason all that data won't fit in bank $13 is that there is a lot more in bank $13 than just the trainer sprites.
There is some map data and some engine code at the bottom of bank $13.

If you just change the bank number, then it still won't fit in that new bank.

What I mean is create an additional SECTION. Leave the map data and engine code in bank $13 and put all the trainer pics in bank $2D.

In addition to what you said to edit I edited scripts\school.asm to look like this:

SchoolScript:
    call EnableAutoTextBoxDrawing
    ld hl, SchoolTrainerHeader0
    ld de, SchoolScriptPointers
    ld a, [wSchoolCurScript]
    call ExecuteCurMapScriptInTable
    ld [wSchoolCurScript], a
    ret

SchoolTextPointers:
    dw SchoolText1
    dw SchoolText2

SchoolScriptPointers:
    dw CheckFightingMapTrainers
    dw DisplayEnemyTrainerTextAndStartBattle
    dw EndTrainerBattle

SchoolTrainerHeader0:
    dbEventFlagBit EVENT_BEAT_SCHOOL_TRAINER_0
    db ($0 << 4) ; trainer's view range
    dwEventFlagAddress EVENT_BEAT_SCHOOL_TRAINER_0
    dw SchoolBattleText2 ; TextBeforeBattle
    dw SchoolAfterBattleText2 ; TextAfterBattle
    dw SchoolEndBattleText2 ; TextEndBattle
    dw SchoolEndBattleText2 ; TextEndBattle

SchoolText1:
    TX_FAR _SchoolText1
    db "@"

SchoolText2:
    TX_ASM
    ld hl, SchoolTrainerHeader0
    call TalkToTrainer
    jp TextScriptEnd

SchoolBattleText2:
    TX_FAR _SchoolBattleText2
    db "@"

SchoolEndBattleText2:
    TX_FAR _SchoolEndBattleText2
    db "@"

SchoolAfterBattleText2:
    TX_FAR _SchoolAfterBattleText2
    db "@"

Then I've added this to wram.asm:

wSchoolCurScript:: 
    ds 1

But after this the game shows battle text, starts youngster music and doesn't trigger the battle. And after that text I can re-enter the building, and the same will happen.

Last edited by Shararamosh (2018-01-30 14:19:06)

Offline

#11 2018-01-29 23:23:22

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,064/1,119

Re: Adding new trainer or trainer class in Pokemon Red/Blue.

I don't see any problems with your script.

Except try adding "db $ff" after the end the trainer header. I'm not positive that will make a difference though.

Also please put your code in a [­code] [­/code] block.

Offline

#12 2018-01-30 16:08:30

Shararamosh
Member
Registered: 2016-08-25
Post 23/24

Re: Adding new trainer or trainer class in Pokemon Red/Blue.

Danny-E 33 wrote:

I don't see any problems with your script.

Except try adding "db $ff" after the end the trainer header. I'm not positive that will make a difference though.

Also please put your code in a [­code] [­/code] block.

Sorry, it was mistake. I accidentally chose the wrong object on the map, and this occured. I've fixed it, and now I can battle her. But there's one problem: when I re-enter the building (it is school in Viridian City) I can battle with her again. Here's part of my data\mapObjects\school.asm:

object SPRITE_LASS, $4, $1, STAY, DOWN, $2, OPP_SAYORI, $1

And here's part of scripts\school.asm:

SchoolTrainerHeader0:
    dbEventFlagBit EVENT_BEAT_SCHOOL_TRAINER_0, 1
    db ($0 << 4) ; trainer's view range
    dwEventFlagAddress EVENT_BEAT_SCHOOL_TRAINER_0, 1
    dw SchoolBattleText2 ; TextBeforeBattle
    dw SchoolAfterBattleText2 ; TextAfterBattle
    dw SchoolEndBattleText2 ; TextEndBattle
    dw SchoolEndBattleText2 ; TextEndBattle

    db $ff

My question is what does "1" after EVENT_BEAT_SCHOOL_TRAINER_0 mean and what does $2 and $1 between OPP_SAYORI mean? I think the problem is in this 2 parts of scripts.

Offline

#13 2018-02-06 03:51:48

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,065/1,119

Re: Adding new trainer or trainer class in Pokemon Red/Blue.

You can take a look at the definition of the dwEventFlagAddress macro in macros/event_macros.asm and the definition of the object macro in macros/data_macros.asm to find out what each argument means

Offline

Board footer

Powered by FluxBB