From 1bc5644edcbb763e60a32612033ed382c7904878 Mon Sep 17 00:00:00 2001 From: Llinos Evans <36418502+PlagueVonKarma@users.noreply.github.com> Date: Tue, 30 Jul 2024 20:53:14 +0100 Subject: [PATCH] Bug Catching Contest gives a funny Gligar If you win the Bug Catching Contest, the man will give you an Earthquake Gligar. The code that gives it a special move is a bit fucked up because I tried to add a Farfetch'd function, but I can't be bothered to finish the functionality because I'm stupid (it is actually quite easy I'm just lazy) --- constants/event_flags.asm | 2 +- data/events/special_pointers.asm | 1 + engine/events/specials.asm | 131 +++++++++++++++++++++++++++++++ engine/events/std_scripts.asm | 25 +++--- engine/games/memory_game.asm | 2 +- maps/DebugRoom.asm | 16 ++++ maps/Route36NationalParkGate.asm | 13 +-- 7 files changed, 172 insertions(+), 18 deletions(-) diff --git a/constants/event_flags.asm b/constants/event_flags.asm index d34ff87..3ee9147 100644 --- a/constants/event_flags.asm +++ b/constants/event_flags.asm @@ -487,7 +487,7 @@ const EVENT_KARENS_ROOM_EXIT_OPEN const EVENT_LANCES_ROOM_ENTRANCE_CLOSED const EVENT_LANCES_ROOM_EXIT_OPEN - const EVENT_CONTEST_OFFICER_HAS_SUN_STONE + const EVENT_CONTEST_OFFICER_HAS_GLIGAR const EVENT_CONTEST_OFFICER_HAS_EVERSTONE const EVENT_CONTEST_OFFICER_HAS_GOLD_BERRY const EVENT_CONTEST_OFFICER_HAS_BERRY diff --git a/data/events/special_pointers.asm b/data/events/special_pointers.asm index 6954b10..1824f66 100644 --- a/data/events/special_pointers.asm +++ b/data/events/special_pointers.asm @@ -191,3 +191,4 @@ SpecialsPointers:: add_special NameMom add_special ShoveSafariBallsDownKrissThroat add_special GiveKrisSneakers + add_special DebugGiveMonSpecialMove diff --git a/engine/events/specials.asm b/engine/events/specials.asm index 7e66fb1..19bd21f 100644 --- a/engine/events/specials.asm +++ b/engine/events/specials.asm @@ -15,6 +15,137 @@ Special:: INCLUDE "data/events/special_pointers.asm" +DebugGiveMonSpecialMove: +; TODO: Make this good :3 +; I could implement Rangi's special givepoke but i am too stupid +; also this code is bugged and never works for farfetch'd partly because i am a dumb stupid idiot +; it works for gligar tho so it's good FOR NOW +; ScriptVar 1 - Gligar +; ScriptVar 2 - Farfetch'd + ld bc, wPartyCount + ld a, [bc] + ld hl, MON_SPECIES + call .GetNthPartyMon + ld a, [bc] + ld c, a + push hl + + ;call .GetNthPartyMon + ld hl, GLIGAR + call GetPokemonIDFromIndex + + pop hl + ld b, a + ld de, PARTYMON_STRUCT_LENGTH +.CheckForNthPokemon: +; start at the end of the party and search backwards for the last Pokemon in the party. + ld a, [hl] + cp b + jr z, .GiveMoveset + ld a, l + sub e + ld l, a + ld a, h + sbc d + ld h, a + dec c + jr nz, .CheckForNthPokemon + ret + +.GiveMoveset: + push hl + + ;call .GetNthPartyMon + ld hl, GLIGAR + call GetPokemonIDFromIndex +; cp FARFETCH_D +; jr z, .skip + ld a, 1 + ld [wScriptVar], a +;.skip + + ld a, [wScriptVar] + ld hl, .Movesets + ld bc, .Moveset1 - .Moveset0 + call AddNTimes + + ; get address of mon's first move + pop de + inc de + inc de + +.GiveMoves: + ld a, [hli] + or [hl] ; is the move 00? + ret z ; if so, we're done here + + push hl + push de + ld a, [hld] + ld l, [hl] + ld h, a + call GetMoveIDFromIndex + ld [de], a ; give the Pokémon the new move + + ; get the PP of the new move + ld l, a + ld a, MOVE_PP + call GetMoveAttribute + + ; get the address of the move's PP and update the PP + ld hl, MON_PP - MON_MOVES + add hl, de + ld [hl], a + + pop de + pop hl + inc de + inc hl + jr .GiveMoves + +.Movesets: +.Moveset0: +; Gligar + dw BATON_PASS + dw SWORDS_DANCE + dw AGILITY + dw SLASH + dw 0 +.Moveset1: +; Farfetch'd + dw EARTHQUAKE + dw POISON_STING + dw COUNTER + dw WING_ATTACK + dw 0 + +.GetNthPartyMon: +; inputs: +; hl must be set to 0 before calling this function. +; a must be set to the number of Pokémon in the party. + +; outputs: +; returns the address of the last Pokémon in the party in hl. +; sets carry if a is 0. + + ld de, wPartyMon1 + add hl, de + and a + jr z, .EmptyParty + dec a + ret z + ld de, PARTYMON_STRUCT_LENGTH +.loop + add hl, de + dec a + jr nz, .loop + ret + +.EmptyParty: + scf + ret + ret + UnusedDummySpecial: ret diff --git a/engine/events/std_scripts.asm b/engine/events/std_scripts.asm index c4908cc..ff97309 100644 --- a/engine/events/std_scripts.asm +++ b/engine/events/std_scripts.asm @@ -355,7 +355,7 @@ BugContestResultsWarpScript: BugContestResultsScript: clearflag ENGINE_BUG_CONTEST_TIMER clearevent EVENT_WARPED_FROM_ROUTE_35_NATIONAL_PARK_GATE - clearevent EVENT_CONTEST_OFFICER_HAS_SUN_STONE + clearevent EVENT_CONTEST_OFFICER_HAS_GLIGAR clearevent EVENT_CONTEST_OFFICER_HAS_EVERSTONE clearevent EVENT_CONTEST_OFFICER_HAS_GOLD_BERRY clearevent EVENT_CONTEST_OFFICER_HAS_BERRY @@ -425,18 +425,21 @@ BugContestResults_CleanUp: BugContestResults_FirstPlace: setevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1 + farwritetext ContestResults_PlayerWonAPrizeText + waitbutton + readvar VAR_PARTYCOUNT + ifequal PARTY_LENGTH, .BugContestResults_NoRoomForGligar + + givepoke GLIGAR, 5 + special DebugGiveMonSpecialMove ; give it the Stadium 2 moveset + + sjump BugContestResults_ReturnAfterWinnersPrize + +BugContestResults_SecondPlace: getitemname STRING_BUFFER_4, BLK_AUGURITE farwritetext ContestResults_PlayerWonAPrizeText waitbutton verbosegiveitem BLK_AUGURITE - iffalse BugContestResults_NoRoomForSunStone - sjump BugContestResults_ReturnAfterWinnersPrize - -BugContestResults_SecondPlace: - getitemname STRING_BUFFER_4, EVERSTONE - farwritetext ContestResults_PlayerWonAPrizeText - waitbutton - verbosegiveitem EVERSTONE iffalse BugContestResults_NoRoomForEverstone sjump BugContestResults_ReturnAfterWinnersPrize @@ -448,10 +451,10 @@ BugContestResults_ThirdPlace: iffalse BugContestResults_NoRoomForGoldBerry sjump BugContestResults_ReturnAfterWinnersPrize -BugContestResults_NoRoomForSunStone: +BugContestResults_NoRoomForGligar: farwritetext BugContestPrizeNoRoomText promptbutton - setevent EVENT_CONTEST_OFFICER_HAS_SUN_STONE + setevent EVENT_CONTEST_OFFICER_HAS_GLIGAR sjump BugContestResults_ReturnAfterWinnersPrize BugContestResults_NoRoomForEverstone: diff --git a/engine/games/memory_game.asm b/engine/games/memory_game.asm index a06bbb8..521fce7 100644 --- a/engine/games/memory_game.asm +++ b/engine/games/memory_game.asm @@ -357,7 +357,7 @@ MemoryGame_CheckMatch: done .DarnText: - text "Darn<...>" + text "Darn!" done MemoryGame_InitBoard: diff --git a/maps/DebugRoom.asm b/maps/DebugRoom.asm index 7202316..ed2e5ae 100644 --- a/maps/DebugRoom.asm +++ b/maps/DebugRoom.asm @@ -372,6 +372,21 @@ MemoryGameScript: closetext end +DebugGligarScript: + opentext + writetext DebugGligarText + + givepoke GLIGAR, 5 + special DebugGiveMonSpecialMove + + waitbutton + closetext + end + +DebugGligarText: + text "Hi" + done + DebugRoom_MapEvents: db 0, 0 ; filler @@ -405,3 +420,4 @@ DebugRoom_MapEvents: object_event 18, 13, SPRITE_SAFARI_ZONE_WORKER, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, TrainerTestScript, -1 object_event 20, 13, SPRITE_FISHER, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, DebugDollShopScript, -1 object_event 25, 15, SPRITE_WILL, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, MemoryGameScript, -1 + object_event 27, 16, SPRITE_KAREN, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, DebugGligarScript, -1 diff --git a/maps/Route36NationalParkGate.asm b/maps/Route36NationalParkGate.asm index 87ace21..a727f39 100644 --- a/maps/Route36NationalParkGate.asm +++ b/maps/Route36NationalParkGate.asm @@ -231,7 +231,7 @@ Route36OfficerScriptContest: end Route36Officer_ContestHasConcluded: - checkevent EVENT_CONTEST_OFFICER_HAS_SUN_STONE + checkevent EVENT_CONTEST_OFFICER_HAS_GLIGAR iftrue .Sunstone checkevent EVENT_CONTEST_OFFICER_HAS_EVERSTONE iftrue .Everstone @@ -247,16 +247,19 @@ Route36Officer_ContestHasConcluded: .Sunstone: writetext Route36NationalParkGateOfficer1HeresThePrizeText promptbutton - verbosegiveitem BLK_AUGURITE - iffalse .BagFull - clearevent EVENT_CONTEST_OFFICER_HAS_SUN_STONE + readvar VAR_PARTYCOUNT + ifequal PARTY_LENGTH, .BagFull + + givepoke GLIGAR, 5 + special DebugGiveMonSpecialMove ; give it the Stadium 2 moveset + clearevent EVENT_CONTEST_OFFICER_HAS_GLIGAR closetext end .Everstone: writetext Route36NationalParkGateOfficer1HeresThePrizeText promptbutton - verbosegiveitem EVERSTONE + verbosegiveitem BLK_AUGURITE iffalse .BagFull clearevent EVENT_CONTEST_OFFICER_HAS_EVERSTONE closetext