Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2017-03-19 13:46:31

Wild
Member
Registered: 2016-12-30
Post 10/16

[pokered] Adding trainers to new maps

Hi Everyone,

Little recurring problem I am having here with adding new trainers into the overworld. The problem is similar to the one described and solved in this topic here : https://hax.iimarckus.org/topic/5656/

However, I am trying to add new trainers to Route 2, a map that didn't already have trainers on it originally. Even though my object data and script is seemingly fine, a virtual carbon copy of Route 3, the trainers do not behave correctly.

They will see you, the battle will initiate and work fine, however when you beat the trainer, the flag is not set saying that you have. This results in an endless battle loop that you can't excape from. I have added new event constants for these new trainers, is there something else that I'm missing?

There's also another strange glitch happening on this map, where an NPC gives you a Freshwater. The event plays out fine, but at the end, his sprite and those of all the others on the map glitch. Something's seriously wrong somewhere, but I can't work it out.

Any help, pointers or advice would be greatly appreciated if anyone has experienced this same problem. Cheers!

Offline

#2 2017-03-19 13:54:58

Fotomac
Member
Registered: 2015-10-25
Post 291/332

Re: [pokered] Adding trainers to new maps

I think you might be looking for the event constants. That's a good place to start.

Offline

#3 2017-03-19 14:38:54

Wild
Member
Registered: 2016-12-30
Post 11/16

Re: [pokered] Adding trainers to new maps

Thanks Fotomac, however I have added new event constants for every trainer. Unless there is somewhere else other than event_constants.asm that would need editing as well?

Offline

#4 2017-03-19 23:47:41

Fotomac
Member
Registered: 2015-10-25
Post 292/332

Re: [pokered] Adding trainers to new maps

You would need to edit the corresponding script to add the events, if I remember correctly. It worked for me when I added a Lass into Pewter Gym as a reference to Pokémon Origins, but just in case I'd like to suggest setting each trainer's line of sight to 0, so talking to the trainer becomes mandatory to trigger a battle.

Offline

#5 2017-03-20 10:51:41

Wild
Member
Registered: 2016-12-30
Post 12/16

Re: [pokered] Adding trainers to new maps

OK, so I figured out what was causing the sprite glitching in the game. Turns out that Route 2's sprite set is split into two, and all battles and events that were set below the boundary between the two different sprite sets for the map were behaving incorrectly. A simple change of the map's assigned sprite set to not have the split solved the problem straight away.

With regard to trainer flags not being set, it was a typo of one number on my part that caused the problem. Woops! :O Thanks for giving your ideas Fotomac!

Offline

#6 2017-03-21 00:05:35

Fotomac
Member
Registered: 2015-10-25
Post 293/332

Re: [pokered] Adding trainers to new maps

Always glad to help.

Offline

#7 2020-02-27 20:54:33

zalor
Member
Registered: 2020-01-31
Post 4/10

Re: [pokered] Adding trainers to new maps

Sorry to Necro this thread but I'm having the exact same issue as OP had. I'm also trying to add a trainer to Route 2 and not just does the defeat flag not work, but the trainer's view range won't work either (have to talk to the trainer). This is all my relevant code:

scripts\Route2.asm:

Route2_Script:
call EnableAutoTextBoxDrawing
ld hl, Route2TrainerHeader0
ld de, Route2_ScriptPointers
;ld a, [wRoute2CurScript]
;call ExecuteCurMapScriptInTable
;ld [wRoute2CurScript], a
ret

Route2_ScriptPointers:
dw CheckFightingMapTrainers
dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle

Route2_TextPointers:
dw PickUpItemText
dw PickUpItemText
dw Route2Text3
dw Route2Text4

Route2TrainerHeader0:
dbEventFlagBit EVENT_BEAT_ROUTE_2_TRAINER_0
db ($3 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROUTE_2_TRAINER_0
dw Route2BattleText3 ; TextBeforeBattle
dw Route2AfterBattleText3 ; TextAfterBattle
dw Route2EndBattleText3 ; TextEndBattle
dw Route2EndBattleText3 ; TextEndBattle

Route2Text3:
TX_ASM
ld hl, Route2TrainerHeader0
call TalkToTrainer
jp TextScriptEnd

Route2BattleText3:
TX_FAR _Route2BattleText3
db "@"

Route2EndBattleText3:
TX_FAR _Route2EndBattleText3
db "@"

Route2AfterBattleText3:
TX_FAR _Route2AfterBattleText3
db "@"

Apparently there is no such thing as [wRoute2CurScript] which is why I commented that part out. I used the events of route 3 as my base.


data\mapObjects\Route2.asm:

Route2_Object:
db $f ; border block

db 0 ; warps

db 1 ; signs
sign 15, 11, 4 ; Route2Text4

db 3 ; objects
object SPRITE_BALL, 4, 13, STAY, NONE, 1, MASTER_BALL ;MOON_STONE
object SPRITE_BALL, 15, 15, STAY, NONE, 2, HP_UP
object SPRITE_LASS, 11, 11, STAY, NONE, 3, OPP_LASS, 1 ; person

; warp-to

; unused


constants/event_constants.asm:

const EVENT_BEAT_ROUTE_2_TRAINER_0 ;EVENT_3CA    ; 3CA, (D7C0, bit 2)

I created this event flag, and added it in a random area of what looked to be empty space (D7C0, bit 2).

Last edited by zalor (2020-02-27 20:55:11)

Offline

#8 2020-03-17 03:09:28

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,153/1,188

Re: [pokered] Adding trainers to new maps

Good question!

As you point out, some maps have no w*CurMapScript value. These maps also never have trainers. In order for a map to have trainers, it needs to have a script ID in memory.

If you create "wRoute2CurScript" in wram.asm and un-comment those lines you mentioned, I believe you should be able to get a lot further.

You can create "wRoute2CurScript" anywhere under/near "wGameProgressFlags" where you see an unused address. For example, you can use the unused address after "wPalletTownCurScript".

Offline

Board footer

Powered by FluxBB