diff options
author | ElectroDeoxys <ElectroDeoxys@gmail.com> | 2020-05-10 14:19:36 +0100 |
---|---|---|
committer | ElectroDeoxys <ElectroDeoxys@gmail.com> | 2020-12-16 00:13:21 +0000 |
commit | fa1339c32f77f28c8cf27abf931aad5efe2268c9 (patch) | |
tree | 7dd1c949e2ca0bef9ad34cba45e988a25ab07e5d /src | |
parent | 5ee1d3908bcf4cbd8ae05c0dbd420fb8cc6aca2f (diff) |
Zubat, Golbat and Venonat Leech Life effects
Diffstat (limited to 'src')
-rw-r--r-- | src/data/effect_commands.asm | 6 | ||||
-rw-r--r-- | src/engine/bank05.asm | 14 | ||||
-rw-r--r-- | src/engine/bank08.asm | 42 | ||||
-rw-r--r-- | src/engine/effect_functions.asm | 85 | ||||
-rw-r--r-- | src/engine/home.asm | 10 | ||||
-rw-r--r-- | src/wram.asm | 1 |
6 files changed, 121 insertions, 37 deletions
diff --git a/src/data/effect_commands.asm b/src/data/effect_commands.asm index c201b91..88938fa 100644 --- a/src/data/effect_commands.asm +++ b/src/data/effect_commands.asm @@ -95,7 +95,7 @@ KakunaPoisonPowderEffectCommands: db $00 GolbatLeechLifeEffectCommands: - dbw EFFECTCMDTYPE_AFTER_DAMAGE, $47bc + dbw EFFECTCMDTYPE_AFTER_DAMAGE, GolbatLeechLifeEffect db $00 VenonatStunSporeEffectCommands: @@ -103,7 +103,7 @@ VenonatStunSporeEffectCommands: db $00 VenonatLeechLifeEffectCommands: - dbw EFFECTCMDTYPE_AFTER_DAMAGE, $47c6 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, VenonatLeechLifeEffect db $00 ScytherSwordsDanceEffectCommands: @@ -115,7 +115,7 @@ ZubatSupersonicEffectCommands: db $00 ZubatLeechLifeEffectCommands: - dbw EFFECTCMDTYPE_AFTER_DAMAGE, $47e3 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, ZubatLeechLifeEffect db $00 BeedrillTwineedleEffectCommands: diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 6af2582..01af541 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -3122,7 +3122,7 @@ AIDecideEvolution: ; 15f4c (5:5f4c) .check_damage ld a, [wTempAI] ld e, a - call GetCardDamage + call GetCardDamageAndMaxHP or a jr z, .check_mysterious_fossil srl a @@ -3294,7 +3294,7 @@ Func_16120: ; 16120 (5:6120) dec b ld e, b push bc - call GetCardDamage + call GetCardDamageAndMaxHP pop bc add c ld c, a @@ -3324,7 +3324,7 @@ Func_16120: ; 16120 (5:6120) ; check if there's a Muk in any duelist's Play Area .is_active ld e, 0 - call GetCardDamage + call GetCardDamageAndMaxHP cp 50 jr c, .lower_score ld e, PLAY_AREA_ARENA @@ -5308,7 +5308,7 @@ GetAIScoreOfAttack: ; 16a86 (5:6a86) cp 31 jr nc, .high_recoil_generic_checks ld e, PLAY_AREA_ARENA - call GetCardDamage + call GetCardDamageAndMaxHP sla a cp c jr c, .high_recoil_generic_checks @@ -5544,7 +5544,7 @@ GetAIScoreOfAttack: ; 16a86 (5:6a86) .tally_heal_score push af ld e, PLAY_AREA_ARENA - call GetCardDamage + call GetCardDamageAndMaxHP call CalculateByteTensDigit pop bc cp b ; wLoadedMoveEffectParam @@ -6191,7 +6191,7 @@ LookForCardThatIsKnockedOutOnDevolution: ; 17080 (5:7080) ld [wTempAI], a ld e, c push bc - call GetCardDamage + call GetCardDamageAndMaxHP pop bc ld e, a ld a, [wTempAI] @@ -7229,7 +7229,7 @@ Func_174f2: ; 174f2 (5:74f2) Func_17583: ; 17583 (5:7583) push hl push de - call GetCardDamage + call GetCardDamageAndMaxHP call CalculateByteTensDigit ld b, a push bc diff --git a/src/engine/bank08.asm b/src/engine/bank08.asm index 272f7c7..d133fd1 100644 --- a/src/engine/bank08.asm +++ b/src/engine/bank08.asm @@ -202,7 +202,7 @@ AIPlay_Potion: ; 201b5 (8:41b5) ld a, [wAITrainerCardParameter] ldh [hTemp_ffa0], a ld e, a - call GetCardDamage + call GetCardDamageAndMaxHP cp 20 jr c, .play_card ld a, 20 @@ -232,7 +232,7 @@ AIDecide_Potion1: ; 201d1 (8:41d1) call GetTurnDuelistVariable ld h, a ld e, PLAY_AREA_ARENA - call GetCardDamage + call GetCardDamageAndMaxHP cp 20 + 1 ; if damage <= 20 jr c, .calculate_hp ld a, 20 ; amount of Potion HP healing @@ -270,7 +270,7 @@ AIDecide_Potion2: ; 20204 (8:4204) call GetTurnDuelistVariable ld h, a ld e, PLAY_AREA_ARENA - call GetCardDamage + call GetCardDamageAndMaxHP cp 20 + 1 ; if damage <= 20 jr c, .calculate_hp ld a, 20 @@ -309,7 +309,7 @@ AIDecide_Potion2: ; 20204 (8:4204) ret z call .check_boost_if_taken_damage jr c, .has_boost_damage - call GetCardDamage + call GetCardDamageAndMaxHP cp 20 ; if damage >= 20 jr nc, .found .has_boost_damage @@ -392,7 +392,7 @@ AIPlay_SuperPotion: ; 202a8 (8:42a8) ldh [hTemp_ffa0], a ld a, [wAITrainerCardParameter] ld e, a - call GetCardDamage + call GetCardDamageAndMaxHP cp 40 jr c, .play_card ld a, 40 @@ -426,7 +426,7 @@ AIDecide_SuperPotion1: ; 202cc (8:42cc) call GetTurnDuelistVariable ld h, a ld e, PLAY_AREA_ARENA - call GetCardDamage + call GetCardDamageAndMaxHP cp 40 + 1 ; if damage < 40 jr c, .calculate_hp ld a, 40 @@ -470,7 +470,7 @@ AIDecide_SuperPotion2: ; 2030f (8:430f) call GetTurnDuelistVariable ld h, a ld e, PLAY_AREA_ARENA - call GetCardDamage + call GetCardDamageAndMaxHP cp 40 + 1 ; if damage < 40 jr c, .calculate_hp ld a, 40 @@ -516,7 +516,7 @@ AIDecide_SuperPotion2: ; 2030f (8:430f) jr c, .next call .check_energy_cost jr c, .next - call GetCardDamage + call GetCardDamageAndMaxHP cp 40 ; if damage >= 40 jr nc, .found .next @@ -2274,7 +2274,7 @@ AIDecide_PokemonBreeder: ; 20b1b (8:4b1b) dec b ld e, b push bc - call GetCardDamage + call GetCardDamageAndMaxHP pop bc call ConvertHPToCounters add c @@ -2296,7 +2296,7 @@ AIDecide_PokemonBreeder: ; 20b1b (8:4b1b) ; compare number of this card's damage counters ; with 5, if less than that, set carry ld e, PLAY_AREA_ARENA - call GetCardDamage + call GetCardDamageAndMaxHP cp 5 jr c, .set_carry @@ -3182,7 +3182,7 @@ AIDecide_PokemonCenter: ; 210eb (8:50eb) ; get this Pokemon's current damage counters ; and add it to the total. - call GetCardDamage + call GetCardDamageAndMaxHP call ConvertHPToCounters ld b, a ld a, [wce08] @@ -3950,7 +3950,7 @@ AIDecide_MrFuji: ; 214a7 (8:54a7) ld b, a ; skip if zero damage counters - call GetCardDamage + call GetCardDamageAndMaxHP call ConvertHPToCounters or a jr z, .next @@ -4061,7 +4061,7 @@ AIDecide_ScoopUp: ; 21506 (8:5506) ; skip if card has no damage counters. ld e, PLAY_AREA_ARENA - call GetCardDamage + call GetCardDamageAndMaxHP or a jr z, .no_carry @@ -6653,7 +6653,7 @@ HandleAIHeal: ; 22402 (8:6402) ; check if Arena card has any damage counters, ; if not, check Bench instead. ld e, PLAY_AREA_ARENA - call GetCardDamage + call GetCardDamageAndMaxHP or a jr z, .check_bench @@ -6666,7 +6666,7 @@ HandleAIHeal: ; 22402 (8:6402) call GetTurnDuelistVariable ld h, a ld e, PLAY_AREA_ARENA - call GetCardDamage + call GetCardDamageAndMaxHP ; this seems useless since it was already ; checked that Arena card has damage, ; so card damage is at least 10. @@ -6704,7 +6704,7 @@ HandleAIHeal: ; 22402 (8:6402) cp d jr z, .done push bc - call GetCardDamage + call GetCardDamageAndMaxHP pop bc cp b jr c, .next_bench @@ -6902,7 +6902,7 @@ HandleAIStrangeBehavior: ; 2255d (8:655d) ldh [hTemp_ffa0], a ld e, PLAY_AREA_ARENA - call GetCardDamage + call GetCardDamageAndMaxHP or a ret z ; return if Arena card has no damage counters @@ -6977,7 +6977,7 @@ HandleAICurse: ; 225b5 (8:65b5) call SwapTurn .loop_play_area_1 push bc - call GetCardDamage + call GetCardDamageAndMaxHP pop bc or a jr z, .next_1 @@ -7033,7 +7033,7 @@ HandleAICurse: ; 225b5 (8:65b5) cp b jr z, .next_2 ; skip same Pokemon card push bc - call GetCardDamage + call GetCardDamageAndMaxHP pop bc jr nz, .use_curse ; has damage counters, choose this card .next_2 @@ -7116,7 +7116,7 @@ HandleAICowardice: ; 2262d (8:662d) ld a, c ldh [hTemp_ffa0], a ld e, a - call GetCardDamage + call GetCardDamageAndMaxHP .asm_22678 or a ret z ; return if has no damage counters @@ -7183,7 +7183,7 @@ HandleAIDamageSwap: ; 226a3 (8:66a3) .ok ld e, PLAY_AREA_ARENA - call GetCardDamage + call GetCardDamageAndMaxHP or a ret z ; return if no damage diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index edfc773..d254f5c 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -332,7 +332,61 @@ HandleSwitchDefendingPokemonEffect: ; 2c1ec (b:41ec) ret ; 0x2c221 - INCROM $2c221, $2c2a4 +; applies HP recovery on Pokemon after HP drain attack +; and handles its animation. +; input: +; d = damage effectiveness +; e = damage dealt +ApplyAndAnimateHPDrain: ; 2c221 (b:4221) + push de + ld hl, wccbd + ld [hl], e + inc hl + ld [hl], d + +; get Arena card's damage + ld e, PLAY_AREA_ARENA + call GetCardDamageAndMaxHP + pop de + or a + ret z ; return if no damage + +; load correct animation + push de + ld a, $79 + ld [wLoadedMoveAnimation], a + ld bc, $01 ; arrow + bank1call PlayMoveAnimation + +; compare HP to be restores with max HP +; if HP to be restored would cause HP to +; be larger than max HP, cap it accordingly + ld e, PLAY_AREA_ARENA + call GetCardDamageAndMaxHP + ld b, $00 + pop de + ld a, DUELVARS_ARENA_CARD_HP + call GetTurnDuelistVariable + add e + ld e, a + ld a, 0 + adc d + ld d, a + ; de = damage dealt + current HP + ; bc = max HP of card + call CompareDEtoBC + jr c, .skip_cap + ; cap de to value in bc + ld e, c + ld d, b + +.skip_cap + ld [hl], e ; apply new HP to arena card + bank1call WaitMoveAnimation + ret +; 0x2c25b + + INCROM $2c25b, $2c2a4 ; makes a list in wDuelTempList with the deck indices ; of all the energy cards found in opponent's Discard Pile. @@ -637,7 +691,23 @@ KakunaPoisonPowder_AIEffect: ; 2c7b4 (b:47b4) jp Func_2c0d4 ; 0x2c7bc - INCROM $2c7bc, $2c7d0 +GolbatLeechLifeEffect: ; 2c7bc (b:47bc) + ld hl, wDealtDamage + ld e, [hl] + inc hl ; wDamageEffectiveness + ld d, [hl] + call ApplyAndAnimateHPDrain + ret +; 0x2c7c6 + +VenonatLeechLifeEffect: ; 2c7c6 (b:47c6) + ld hl, wDealtDamage + ld e, [hl] + inc hl ; wDamageEffectiveness + ld d, [hl] + call ApplyAndAnimateHPDrain + ret +; 0x2c7d0 ; During your next turn, double damage SwordsDanceEffect: ; 2c7d0 (b:47d0) @@ -655,7 +725,16 @@ ZubatSupersonicEffect: ; 2c7dc (b:47dc) ret ; 0x2c7e3 - INCROM $2c7e3, $2c7ed +ZubatLeechLifeEffect: ; 2c7e3 (b:47e3) + ld hl, wDealtDamage + ld e, [hl] + inc hl + ld d, [hl] + call ApplyAndAnimateHPDrain + ret +; 0x2c7ed + + INCROM $2c7ed, $2c7ed Twineedle_AIEffect: ; 2c7ed (b:47ed) ld a, 30 diff --git a/src/engine/home.asm b/src/engine/home.asm index ff887fd..98b10ac 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -5172,9 +5172,13 @@ MoveCardToDiscardPileIfInArena: ; 1c13 (0:1c13) jr c, .next_card ret -; calculate damage of card at CARD_LOCATION_* in e -; return the result in a -GetCardDamage: ; 1c35 (0:1c35) +; calculate damage an max HP of card at PLAY_AREA_* in e. +; input: +; e = PLAY_AREA_* of card; +; output: +; a = damage; +; c = max HP. +GetCardDamageAndMaxHP: ; 1c35 (0:1c35) push hl push de ld a, DUELVARS_ARENA_CARD diff --git a/src/wram.asm b/src/wram.asm index bb1f346..1d678b6 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -931,6 +931,7 @@ wAIMinDamage:: ; ccbb wAIMaxDamage:: ; ccbc ds $1 +wccbd:: ; ccbd ds $2 ; damage dealt by an attack to a target |