From caee1c278c9ee7f11b6cecf4db0e7ec747bc7535 Mon Sep 17 00:00:00 2001 From: Llinos Evans <36418502+PlagueVonKarma@users.noreply.github.com> Date: Tue, 27 Aug 2024 00:54:58 +0100 Subject: [PATCH] Add move effect for Coin Hurl Thanks to Shellnuts for helping out. Coin Hurl is now a max-150 base power move that scales with the user's wealth. --- constants/move_effect_constants.asm | 1 + data/battle/ai/useful_moves.asm | 1 + data/battle/effect_command_pointers.asm | 1 + data/moves/effects.asm | 20 +++++++++ data/moves/effects_pointers.asm | 1 + data/moves/moves.asm | 2 +- data/pokemon/evos_attacks_kanto.asm | 2 +- engine/battle/effect_commands.asm | 2 + engine/battle/move_effects/coin_hurl.asm | 56 ++++++++++++++++++++++++ macros/scripts/battle_commands.asm | 1 + 10 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 engine/battle/move_effects/coin_hurl.asm diff --git a/constants/move_effect_constants.asm b/constants/move_effect_constants.asm index 0477a6b..a4dfd2a 100644 --- a/constants/move_effect_constants.asm +++ b/constants/move_effect_constants.asm @@ -157,4 +157,5 @@ const EFFECT_BEAT_UP const EFFECT_FLY const EFFECT_DEFENSE_CURL + const EFFECT_COIN_HURL DEF NUM_MOVE_EFFECTS EQU const_value diff --git a/data/battle/ai/useful_moves.asm b/data/battle/ai/useful_moves.asm index d43024a..0251496 100644 --- a/data/battle/ai/useful_moves.asm +++ b/data/battle/ai/useful_moves.asm @@ -20,4 +20,5 @@ UsefulMoves: dw FIRE_BLAST dw SOFTBOILED dw SUPER_FANG + dw COIN_HURL dw -1 ; end diff --git a/data/battle/effect_command_pointers.asm b/data/battle/effect_command_pointers.asm index 7239e81..53ea3fd 100644 --- a/data/battle/effect_command_pointers.asm +++ b/data/battle/effect_command_pointers.asm @@ -180,4 +180,5 @@ BattleCommandPointers: dw BattleCommand_SuperEffectiveLoopText dw BattleCommand_StartLoop dw BattleCommand_Curl + dw BattleCommand_CoinHurlPower assert_table_length NUM_EFFECT_COMMANDS diff --git a/data/moves/effects.asm b/data/moves/effects.asm index 02305d8..57a3b59 100644 --- a/data/moves/effects.asm +++ b/data/moves/effects.asm @@ -2077,3 +2077,23 @@ DefenseCurl: statupmessage statupfailtext endmove + +CoinHurl: ; Identical to Return, except it calculates damage differently, and does not trigger King's Rock, as contact isn't being made. + checkobedience + usedmovetext + doturn + critical + damagestats + coinhurlpower + damagecalc + stab + damagevariation + checkhit + moveanim + failuretext + applydamage + criticaltext + supereffectivetext + checkfaint + buildopponentrage + endmove diff --git a/data/moves/effects_pointers.asm b/data/moves/effects_pointers.asm index c834926..7661887 100644 --- a/data/moves/effects_pointers.asm +++ b/data/moves/effects_pointers.asm @@ -158,4 +158,5 @@ MoveEffectsPointers: dw BeatUp dw Fly dw DefenseCurl + dw CoinHurl assert_table_length NUM_MOVE_EFFECTS diff --git a/data/moves/moves.asm b/data/moves/moves.asm index a777cb2..9d26639 100644 --- a/data/moves/moves.asm +++ b/data/moves/moves.asm @@ -276,7 +276,7 @@ Moves1: move EFFECT_FREEZE_HIT, 100, ICE, 95, 5, 30 ;MYSTIC_ICE move EFFECT_FLY, 85, WATER, 85, 5, 0 ; BOUNCE - went back and forth on type (making it modern or keeping it spaceworldy), chose spaceworld to diversify the "fly" move category move EFFECT_ACCURACY_UP, 85, GRASS, 0, 20, 0 ; BRIGHT_MOSS - move EFFECT_RETURN, 1, NORMAL, 100, 20, 0 ; COIN_HURL - effect not implemented + move EFFECT_COIN_HURL, 1, NORMAL, 100, 20, 0 ; COIN_HURL move EFFECT_NORMAL_HIT, 85, GROUND, 100, 10, 0 ; UPROOT move EFFECT_MIRROR_COAT, 1, PSYCHIC_TYPE, 100, 10, 0 ; SYNCHRONIZE - effect not implemented move EFFECT_ATTACK_UP_HIT, 70, STEEL, 90, 10, 10 ; STRONG_ARM diff --git a/data/pokemon/evos_attacks_kanto.asm b/data/pokemon/evos_attacks_kanto.asm index 052521d..85c4c62 100644 --- a/data/pokemon/evos_attacks_kanto.asm +++ b/data/pokemon/evos_attacks_kanto.asm @@ -1205,7 +1205,7 @@ PersianEvosAttacks: dbw 43, SLASH dbw 50, DOUBLE_TEAM ; KEP dbw 56, BODY_SLAM ; RBY TM - ; dbw 61, COIN_HURL + dbw 61, COIN_HURL db 0 ; no more level-up moves PerrserkerEvosAttacks: diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index 4dd095a..9d228ec 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -6450,6 +6450,8 @@ INCLUDE "engine/battle/move_effects/attract.asm" INCLUDE "engine/battle/move_effects/return.asm" +INCLUDE "engine/battle/move_effects/coin_hurl.asm" + INCLUDE "engine/battle/move_effects/present.asm" INCLUDE "engine/battle/move_effects/frustration.asm" diff --git a/engine/battle/move_effects/coin_hurl.asm b/engine/battle/move_effects/coin_hurl.asm new file mode 100644 index 0000000..a7dc5db --- /dev/null +++ b/engine/battle/move_effects/coin_hurl.asm @@ -0,0 +1,56 @@ +; Checks the user's money and divides by 100. +; Caps at base 150 power, from 15,000 yen, which is 00000000-00111010-10011000 in binary (the player's money box). This is achieved through skipping the calculation at a certain point. +; Against an enemy Pokemon, they'll always have base 90 Power. + +; Given the way this works, Coin Hurl will rise in power *very* quickly, but, likewise, also reward good fiscal responsibility from the player. At 3,000 yen, it's almost useless. At 10,000 yen, you have max power Return. + +; This move is only learned by Persian and Belledam. Persian has 75 Attack and is basically useless without the move; this gives it an RBY Slash-like counterpart to bring it back to its roots. Belledam, on the other hand, doesn't get STAB, so it's just a (very good) Double-Edge alternative. I really like this! + +; To change scaling, simply change which bytes are checked for the cap, and work from there. Alternatively, change the division process, and so on. Lots of ways, ours is very simple. + +; Have fun using Coin Hurl! - PvK + +BattleCommand_CoinHurlPower: + push bc + ld hl, wMoney + + ld a, [wLinkMode] + and a + jr nz, .linked ; To test max power in the Debug Room, set to z. + + ldh a, [hBattleTurn] + and a + jr z, .ok + jr .enemyMon ; If you're fighting an enemy Pokemon, then skip the calculation and force base 90 Power. We've already checked the link mode, so this only works in PvP. +.ok + + ; Cap at base 150 power + ; There's no multi-byte compare instruction by default so we're doing it in a really funny way + ; s/o Shellnuts for helping! + ld a, [wMoney] ; check high byte + cp %00000001 + jr c, .linked ; if there's a 1 in here at all, just skip the calculation entirely, because you're over 15,000. + ld a, [wMoney+1] ; check middle byte + cp %00111010 + jr c, .linked ; Fuck off again if you're at the initial total. + ld a, [wMoney+2] ; low byte, you can get here sometimes + cp %10011000 + jr c, .linked + xor a + + ld a, 100 ; Take current money and divide it by 100. + ldh [hDivisor], a + ld b, 4 + call Divide + ldh a, [hQuotient + 3] + ld d, a + jr .end +.enemyMon ; Against an enemy Pokemon, base 75 power. + ld d, 90 + jr .end +.linked ; In a Link Battle, it's always base 150 power. We also skip here if the player's money is over 15,000 yen. + ld d, 150 + ; fallthrough +.end + pop bc + ret \ No newline at end of file diff --git a/macros/scripts/battle_commands.asm b/macros/scripts/battle_commands.asm index 180ff85..e023b72 100644 --- a/macros/scripts/battle_commands.asm +++ b/macros/scripts/battle_commands.asm @@ -180,6 +180,7 @@ ENDM command supereffectivelooptext ; ad command startloop ; ae command curl ; af + command coinhurlpower DEF NUM_EFFECT_COMMANDS EQU const_value - 1 const_def -1, -1