diff options
Diffstat (limited to 'engine/events')
-rwxr-xr-x | engine/events/basement_key.asm | 32 | ||||
-rwxr-xr-x | engine/events/card_key.asm | 37 | ||||
-rwxr-xr-x | engine/events/fishing_gfx.asm | 24 | ||||
-rwxr-xr-x | engine/events/poisonstep.asm | 154 | ||||
-rwxr-xr-x | engine/events/sacred_ash.asm | 68 | ||||
-rwxr-xr-x | engine/events/squirtbottle.asm | 45 | ||||
-rwxr-xr-x | engine/events/sweet_scent.asm | 65 |
7 files changed, 425 insertions, 0 deletions
diff --git a/engine/events/basement_key.asm b/engine/events/basement_key.asm new file mode 100755 index 00000000..ab8c39ce --- /dev/null +++ b/engine/events/basement_key.asm @@ -0,0 +1,32 @@ +_BasementKey: +; Are we even in the right map to use this? + ld a, [wMapGroup] + cp GROUP_GOLDENROD_UNDERGROUND + jr nz, .nope + + ld a, [wMapNumber] + cp MAP_GOLDENROD_UNDERGROUND + jr nz, .nope +; Are we on the tile in front of the door? + call GetFacingTileCoord + ld a, d + cp 22 + jr nz, .nope + ld a, e + cp 10 + jr nz, .nope +; Let's use the Basement Key + ld hl, .BasementKeyScript + call QueueScript + ld a, TRUE + ld [wItemEffectSucceeded], a + ret + +.nope + ld a, FALSE + ld [wItemEffectSucceeded], a + ret + +.BasementKeyScript: + closetext + farsjump BasementDoorScript diff --git a/engine/events/card_key.asm b/engine/events/card_key.asm new file mode 100755 index 00000000..c15b1def --- /dev/null +++ b/engine/events/card_key.asm @@ -0,0 +1,37 @@ +_CardKey: +; Are we even in the right map to use this? + ld a, [wMapGroup] + cp GROUP_RADIO_TOWER_3F + jr nz, .nope + + ld a, [wMapNumber] + cp MAP_RADIO_TOWER_3F + jr nz, .nope +; Are we facing the slot? + ld a, [wPlayerDirection] + and %1100 + cp OW_UP + jr nz, .nope + + call GetFacingTileCoord + ld a, d + cp 18 + jr nz, .nope + ld a, e + cp 6 + jr nz, .nope +; Let's use the Card Key. + ld hl, .CardKeyScript + call QueueScript + ld a, TRUE + ld [wItemEffectSucceeded], a + ret + +.nope + ld a, FALSE + ld [wItemEffectSucceeded], a + ret + +.CardKeyScript: + closetext + farsjump CardKeySlotScript diff --git a/engine/events/fishing_gfx.asm b/engine/events/fishing_gfx.asm new file mode 100755 index 00000000..c4a0b9fa --- /dev/null +++ b/engine/events/fishing_gfx.asm @@ -0,0 +1,24 @@ +LoadFishingGFX: + ld de, FishingGFX + ld hl, vTiles0 tile $02 + lb bc, BANK(FishingGFX), 2 + call Get2bpp + + ld de, FishingGFX tile $02 + ld hl, vTiles0 tile $06 + lb bc, BANK(FishingGFX), 2 + call Get2bpp + + ld de, FishingGFX tile $04 + ld hl, vTiles0 tile $0a + lb bc, BANK(FishingGFX), 2 + call Get2bpp + + ld de, FishingGFX tile $06 + ld hl, vTiles0 tile $fc + lb bc, BANK(FishingGFX), 2 + call Get2bpp + ret + +FishingGFX: +INCBIN "gfx/overworld/chris_fish.2bpp" diff --git a/engine/events/poisonstep.asm b/engine/events/poisonstep.asm new file mode 100755 index 00000000..98a6e25a --- /dev/null +++ b/engine/events/poisonstep.asm @@ -0,0 +1,154 @@ +DoPoisonStep:: + ld a, [wPartyCount] + and a + jr z, .no_faint + + xor a + ld c, wPoisonStepDataEnd - wPoisonStepData + ld hl, wPoisonStepData +.loop_clearPoisonStepData + ld [hli], a + dec c + jr nz, .loop_clearPoisonStepData + + xor a + ld [wCurPartyMon], a +.loop_check_poison + call .DamageMonIfPoisoned + jr nc, .not_poisoned +; the output flag is stored in c, copy it to [wPoisonStepPartyFlags + [wCurPartyMon]] +; and set the corresponding flag in wPoisonStepFlagSum + ld a, [wCurPartyMon] + ld e, a + ld d, 0 + ld hl, wPoisonStepPartyFlags + add hl, de + ld [hl], c + ld a, [wPoisonStepFlagSum] + or c + ld [wPoisonStepFlagSum], a + +.not_poisoned + ld a, [wPartyCount] + ld hl, wCurPartyMon + inc [hl] + cp [hl] + jr nz, .loop_check_poison + + ld a, [wPoisonStepFlagSum] + and %10 + jr nz, .someone_has_fainted + ld a, [wPoisonStepFlagSum] + and %01 + jr z, .no_faint + call .PlayPoisonSFX + xor a + ret + +.someone_has_fainted + ld a, BANK(.Script_MonFaintedToPoison) + ld hl, .Script_MonFaintedToPoison + call CallScript + scf + ret + +.no_faint + xor a + ret + +.DamageMonIfPoisoned: +; check if mon is poisoned, return if not + ld a, MON_STATUS + call GetPartyParamLocation + ld a, [hl] + and 1 << PSN + ret z + +; check if mon is already fainted, return if so + ld a, MON_HP + call GetPartyParamLocation + ld a, [hli] + ld b, a + ld c, [hl] + or c + ret z + +; do 1 HP damage + dec bc + ld [hl], c + dec hl + ld [hl], b + +; check if mon has fainted as a result of poison damage + ld a, b + or c + jr nz, .not_fainted + +; the mon has fainted, reset its status, set carry, and return %10 + ld a, MON_STATUS + call GetPartyParamLocation + ld [hl], 0 + ld c, %10 + scf + ret + +.not_fainted +; set carry and return %01 + ld c, %01 + scf + ret + +.PlayPoisonSFX: + ld de, SFX_POISON + call PlaySFX + ld b, $2 + predef LoadPoisonBGPals + call DelayFrame + ret + +.Script_MonFaintedToPoison: + callasm .PlayPoisonSFX + opentext + callasm .CheckWhitedOut + iffalse .whiteout + closetext + end + +.whiteout + farsjump Script_OverworldWhiteout + +.CheckWhitedOut: + xor a + ld [wCurPartyMon], a + ld de, wPoisonStepPartyFlags +.party_loop + push de + ld a, [de] + and %10 + jr z, .mon_not_fainted + ld c, HAPPINESS_POISONFAINT + farcall ChangeHappiness + farcall GetPartyNick + ld hl, .PoisonFaintText + call PrintText + +.mon_not_fainted + pop de + inc de + ld hl, wCurPartyMon + inc [hl] + ld a, [wPartyCount] + cp [hl] + jr nz, .party_loop + predef CheckPlayerPartyForFitMon + ld a, d + ld [wScriptVar], a + ret + +.PoisonFaintText: + text_far _PoisonFaintText + text_end + +.PoisonWhiteoutText: + text_far _PoisonWhiteoutText + text_end diff --git a/engine/events/sacred_ash.asm b/engine/events/sacred_ash.asm new file mode 100755 index 00000000..d105b2fb --- /dev/null +++ b/engine/events/sacred_ash.asm @@ -0,0 +1,68 @@ +_SacredAsh: + ld a, $0 + ld [wItemEffectSucceeded], a + call CheckAnyFaintedMon + ret nc + + ld hl, SacredAshScript + call QueueScript + ld a, $1 + ld [wItemEffectSucceeded], a + ret + +CheckAnyFaintedMon: + ld de, PARTYMON_STRUCT_LENGTH + ld bc, wPartySpecies + ld hl, wPartyMon1HP + ld a, [wPartyCount] + and a + ret z + +.loop + push af + push hl + ld a, [bc] + inc bc + cp EGG + jr z, .next + + ld a, [hli] + or [hl] + jr z, .done + +.next + pop hl + add hl, de + pop af + dec a + jr nz, .loop + xor a + ret + +.done + pop hl + pop af + scf + ret + +SacredAshScript: + special HealParty + reloadmappart + playsound SFX_WARP_TO + special FadeOutPalettes + special FadeInPalettes + special FadeOutPalettes + special FadeInPalettes + special FadeOutPalettes + special FadeInPalettes + waitsfx + writetext .UseSacredAshText + playsound SFX_CAUGHT_MON + waitsfx + waitbutton + closetext + end + +.UseSacredAshText: + text_far _UseSacredAshText + text_end diff --git a/engine/events/squirtbottle.asm b/engine/events/squirtbottle.asm new file mode 100755 index 00000000..411b5c2e --- /dev/null +++ b/engine/events/squirtbottle.asm @@ -0,0 +1,45 @@ +_Squirtbottle: + ld hl, .SquirtbottleScript + call QueueScript + ld a, $1 + ld [wItemEffectSucceeded], a + ret + +.SquirtbottleScript: + reloadmappart + special UpdateTimePals + callasm .CheckCanUseSquirtbottle + iffalse .SquirtbottleNothingScript + farsjump WateredWeirdTreeScript + +.SquirtbottleNothingScript: + jumptext .SquirtbottleNothingText + +.SquirtbottleNothingText: + text_far _SquirtbottleNothingText + text_end + +.CheckCanUseSquirtbottle: + ld a, [wMapGroup] + cp GROUP_ROUTE_36 + jr nz, .nope + + ld a, [wMapNumber] + cp MAP_ROUTE_36 + jr nz, .nope + + farcall GetFacingObject + jr c, .nope + + ld a, d + cp SPRITEMOVEDATA_SUDOWOODO + jr nz, .nope + + ld a, 1 + ld [wScriptVar], a + ret + +.nope + xor a + ld [wScriptVar], a + ret diff --git a/engine/events/sweet_scent.asm b/engine/events/sweet_scent.asm new file mode 100755 index 00000000..9b99a256 --- /dev/null +++ b/engine/events/sweet_scent.asm @@ -0,0 +1,65 @@ +SweetScentFromMenu: + ld hl, .SweetScent + call QueueScript + ld a, $1 + ld [wFieldMoveSucceeded], a + ret + +.SweetScent: + reloadmappart + special UpdateTimePals + callasm GetPartyNick + writetext UseSweetScentText + waitbutton + callasm SweetScentEncounter + iffalse SweetScentNothing + checkflag ENGINE_BUG_CONTEST_TIMER + iftrue .BugCatchingContest + randomwildmon + startbattle + reloadmapafterbattle + end + +.BugCatchingContest: + farsjump BugCatchingContestBattleScript + +SweetScentNothing: + writetext SweetScentNothingText + waitbutton + closetext + end + +SweetScentEncounter: + farcall CanUseSweetScent + jr nc, .no_battle + ld hl, wStatusFlags2 + bit STATUSFLAGS2_BUG_CONTEST_TIMER_F, [hl] + jr nz, .not_in_bug_contest + farcall GetMapEncounterRate + ld a, b + and a + jr z, .no_battle + farcall ChooseWildEncounter + jr nz, .no_battle + jr .start_battle + +.not_in_bug_contest + farcall ChooseWildEncounter_BugContest + +.start_battle + ld a, $1 + ld [wScriptVar], a + ret + +.no_battle + xor a + ld [wScriptVar], a + ret + +UseSweetScentText: + text_far _UseSweetScentText + text_end + +SweetScentNothingText: + text_far _SweetScentNothingText + text_end |