- 1
- Posts
- 132
- Days
- Seen Mar 20, 2025
I was working in a scene in pokémon yellow where after defeating a trainer, the screen fades out, she gives an item and then disappears.
I'm not very good with scripts or programming in general, so I tried copying a script from Cerulean City where the same thing happens with a rocket. Everything was working as planned, but when she is defeated her sprite doesn't disappear at all and the same text box keeps looping over and over again. I don't know if I have to change something related to the hide and show objects, as this is a new map and even when I try to make the sprite disappear from another script it still doesn't work.
![[PokeCommunity.com] [Solved] [pokeyellow] Problem with NPC script [PokeCommunity.com] [Solved] [pokeyellow] Problem with NPC script](https://data.pokecommunity.com/attachments/85/85797-58c7ecca6febe69792a4ca1e7ca18cbb.jpg)
the map script:
I'm not very good with scripts or programming in general, so I tried copying a script from Cerulean City where the same thing happens with a rocket. Everything was working as planned, but when she is defeated her sprite doesn't disappear at all and the same text box keeps looping over and over again. I don't know if I have to change something related to the hide and show objects, as this is a new map and even when I try to make the sprite disappear from another script it still doesn't work.
![[PokeCommunity.com] [Solved] [pokeyellow] Problem with NPC script [PokeCommunity.com] [Solved] [pokeyellow] Problem with NPC script](https://data.pokecommunity.com/attachments/85/85797-58c7ecca6febe69792a4ca1e7ca18cbb.jpg)
the map script:
Code:
CeladonForest_Script:
call EnableAutoTextBoxDrawing
ld de, CeladonForest_ScriptPointers
ld a, [wCeladonForestCurScript]
call ExecuteCurMapScriptInTable
ld [wCeladonForestCurScript], a
ret
CeladonForestClearScripts:
xor a
ld [wJoyIgnore], a
ld [wCeladonForestCurScript], a
ret
CeladonForest_ScriptPointers:
def_script_pointers
dw_const CheckFightingMapTrainers, SCRIPT_CELADON_FOREST_DEFAULT
dw_const DisplayEnemyTrainerTextAndStartBattle, SCRIPT_CELADON_FOREST_START_BATTLE
dw_const EndTrainerBattle, SCRIPT_CELADON_FOREST_END_BATTLE
dw_const CeladonForestErikaDefeatedScript, SCRIPT_CELADON_FOREST_ERIKA_DEFEATED
CeladonForestErikaDefeatedScript:
ld a, [wIsInBattle]
cp $ff
jp z, CeladonForestClearScripts
ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN
ld [wJoyIgnore], a
SetEvent EVENT_BEAT_ERIKA_2
ld a, TEXT_CELADON_FOREST_ERIKA
ldh [hTextID], a
call DisplayTextID
xor a ; SCRIPT_CELADON_FOREST_DEFAULT
ld [wJoyIgnore], a
ld [wCeladonForestCurScript], a
ret
CeladonForest_TextPointers:
def_text_pointers
dw_const CeladonForestErikaText, TEXT_CELADON_FOREST_ERIKA
dw_const PickUpItemText, TEXT_CELADON_FOREST_RARE_CANDY
dw_const PickUpItemText, TEXT_CELADON_FOREST_MAX_REVIVE
dw_const PickUpItemText, TEXT_CELADON_FOREST_MAX_ELIXER
dw_const PickUpItemText, TEXT_CELADON_FOREST_ULTRA_BALL
text_end ; unused
CeladonForestErikaText:
text_asm
CheckEvent EVENT_BEAT_ERIKA_2
jr nz, .beatErika
ld hl, .Text
call PrintText
ld hl, wStatusFlags3
set BIT_TALKED_TO_TRAINER, [hl]
set BIT_PRINT_END_BATTLE_TEXT, [hl]
ld hl, .EndBattleText
ld de, .EndBattleText
call SaveEndBattleTextPointers
ldh a, [hTextID]
ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, SCRIPT_CELADON_FOREST_ERIKA_DEFEATED
ld [wCeladonForestCurScript], a
jp TextScriptEnd
.beatErika
ld hl, .TakeThisText
call PrintText
lb bc, LIFT_KEY, 1
call GiveItem
jr c, .Success
ld hl, .Noroom
call PrintText
jr .Done
.Success
ld hl, .ReceivedLiftKeyText
call PrintText
call GBFadeOutToBlack
ld a, HS_CELADON_FOREST_ERIKA
ld [wMissableObjectIndex], a
predef HideObject
call Delay3
call GBFadeInFromBlack
jp .done
.Done
jp TextScriptEnd
.Text:
text_far _CeladonForestErikaText
text_end
.ReceivedLiftKeyText:
text_far _CeladonForestErikaReceivedLiftKeyText
sound_get_item_1
text_far _CeladonForestErikaIGoAwayText
text_waitbutton
text_end
.Noroom:
text_far _CeladonForestErikaNoroom
text_end
.EndBattleText:
text_far _CeladonForestErikaEndBattleText
text_end
.TakeThisText:
text_far _CeladonForestErikaTakeThisText
text_end
.done
jp TextScriptEnd
Last edited: