From d027bb0d7a809be5765637dd0c8df24e67ad6cff Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 10 May 2019 11:03:33 +0200 Subject: [PATCH] Life Flame toxic orbs --- data/battle_scripts_1.s | 25 ++++++++++--- include/battle.h | 1 + include/battle_scripts.h | 3 ++ include/battle_util.h | 1 + include/constants/battle_script_commands.h | 5 ++- src/battle_script_commands.c | 19 ++++++++++ src/battle_util.c | 43 +++++++++++++++++++++- 7 files changed, 89 insertions(+), 8 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 38a3f500cb..808d2733c0 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2432,8 +2432,7 @@ BattleScript_EffectToxic:: jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected jumpifflowerveil BattleScript_FlowerVeilProtects jumpifsubstituteblocks BattleScript_ButItFailed - jumpifstatus BS_TARGET, STATUS1_POISON, BattleScript_AlreadyPoisoned - jumpifstatus BS_TARGET, STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned + jumpifstatus BS_TARGET, STATUS1_POISON | STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed jumpiftype BS_TARGET, TYPE_POISON, BattleScript_NotAffected jumpiftype BS_TARGET, TYPE_STEEL, BattleScript_NotAffected @@ -6020,6 +6019,18 @@ BattleScript_BufferEndTurn:: printstring STRINGID_BUFFERENDS waitmessage 0x40 end2 + +BattleScript_ToxicOrb:: + setbyte cMULTISTRING_CHOOSER, 0 + copybyte gEffectBattler, gBattlerAttacker + call BattleScript_MoveEffectToxic + end2 + +BattleScript_FlameOrb:: + setbyte cMULTISTRING_CHOOSER, 0 + copybyte gEffectBattler, gBattlerAttacker + call BattleScript_MoveEffectBurn + end2 BattleScript_MoveEffectPoison:: statusanimation BS_EFFECT_BATTLER @@ -6860,15 +6871,19 @@ BattleScript_AirBaloonMsgPop:: removeitem BS_TARGET return -BattleScript_ItemHurtEnd2:: - playanimation BS_ATTACKER, B_ANIM_MON_HIT, NULL - waitanimation +BattleScript_ItemHurtRet:: orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER printstring STRINGID_HURTBYITEM waitmessage 0x40 tryfaintmon BS_ATTACKER, FALSE, NULL + return + +BattleScript_ItemHurtEnd2:: + playanimation BS_ATTACKER, B_ANIM_MON_HIT, NULL + waitanimation + call BattleScript_ItemHurtRet end2 BattleScript_ItemHealHP_Ret:: diff --git a/include/battle.h b/include/battle.h index 701297c597..16822bb1a9 100644 --- a/include/battle.h +++ b/include/battle.h @@ -169,6 +169,7 @@ struct SpecialStatus u8 berryReduced:1; u8 gemBoost:1; u8 gemParam; + u8 damagedMons:4; // Mons that have been damaged directly by using a move, includes substitute. s32 dmg; s32 physicalDmg; s32 specialDmg; diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 7628b35bb4..b5b57f855c 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -318,5 +318,8 @@ extern const u8 BattleScript_RockyHelmetActivates[]; extern const u8 BattleScript_ItemHurtEnd2[]; extern const u8 BattleScript_AirBaloonMsgIn[]; extern const u8 BattleScript_AirBaloonMsgPop[]; +extern const u8 BattleScript_ItemHurtRet[]; +extern const u8 BattleScript_ToxicOrb[]; +extern const u8 BattleScript_FlameOrb[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/battle_util.h b/include/battle_util.h index 6031bf874f..130a533433 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -26,6 +26,7 @@ #define ITEMEFFECT_MOVE_END 0x3 #define ITEMEFFECT_KINGSROCK_SHELLBELL 0x4 #define ITEMEFFECT_TARGET 0x5 +#define ITEMEFFECT_ORBS 0x6 #define WEATHER_HAS_EFFECT ((!IsAbilityOnField(ABILITY_CLOUD_NINE) && !IsAbilityOnField(ABILITY_AIR_LOCK))) diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 775f8b337b..d13a84fc19 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -182,8 +182,9 @@ #define ATK49_UPDATE_LAST_MOVES 16 #define ATK49_MIRROR_MOVE 17 #define ATK49_NEXT_TARGET 18 -#define ATK49_CLEAR_BITS 19 -#define ATK49_COUNT 20 +#define ATK49_LIFE_ORB 19 +#define ATK49_CLEAR_BITS 20 +#define ATK49_COUNT 21 #define BIT_HP 0x1 #define BIT_ATK 0x2 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 8c6ebf27a5..ae2cb028f9 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1517,6 +1517,9 @@ static void atk07_adjustdamage(void) END: gBattlescriptCurrInstr++; + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleMoveDamage >= 1) + gSpecialStatuses[gBattlerAttacker].damagedMons |= gBitTable[gBattlerTarget]; + // Check gems and damage reducing berries. if (gSpecialStatuses[gBattlerTarget].berryReduced && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) @@ -4577,6 +4580,21 @@ static void atk49_moveend(void) } gBattleScripting.atk49_state++; break; + case ATK49_LIFE_ORB: + if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_LIFE_ORB + && !(GetBattlerAbility(gBattlerAttacker) == ABILITY_SHEER_FORCE && gBattleMoves[gCurrentMove].flags & FLAG_SHEER_FORCE_BOOST) + && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD + && gSpecialStatuses[gBattlerAttacker].damagedMons) + { + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 10; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + effect = TRUE; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_ItemHurtRet; + } + gBattleScripting.atk49_state++; + break; case ATK49_CLEAR_BITS: // Clear bits active while using a move for all targets and all hits. if (gSpecialStatuses[gBattlerAttacker].instructedChosenTarget) *(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].instructedChosenTarget & 0x3; @@ -4584,6 +4602,7 @@ static void atk49_moveend(void) gBattleStruct->ateBoost[gBattlerAttacker] = 0; gStatuses3[gBattlerAttacker] &= ~(STATUS3_ME_FIRST); gSpecialStatuses[gBattlerAttacker].gemBoost = 0; + gSpecialStatuses[gBattlerAttacker].damagedMons = 0; gSpecialStatuses[gBattlerTarget].berryReduced = 0; gBattleScripting.atk49_state++; break; diff --git a/src/battle_util.c b/src/battle_util.c index aab30c15e8..c5c04eb752 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1361,6 +1361,7 @@ enum ENDTURN_TAUNT, ENDTURN_YAWN, ENDTURN_ITEMS2, + ENDTURN_ORBS, ENDTURN_ROOST, ENDTURN_ELECTRIFY, ENDTURN_POWDER, @@ -1430,6 +1431,11 @@ u8 DoBattlerEndTurnEffects(void) effect++; gBattleStruct->turnEffectsTracker++; break; + case ENDTURN_ORBS: + if (ItemBattleEffects(ITEMEFFECT_ORBS, gActiveBattler, FALSE)) + effect++; + gBattleStruct->turnEffectsTracker++; + break; case ENDTURN_LEECH_SEED: // leech seed if ((gStatuses3[gActiveBattler] & STATUS3_LEECHSEED) && gBattleMons[gStatuses3[gActiveBattler] & STATUS3_LEECHSEED_BATTLER].hp != 0 @@ -4173,6 +4179,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) } break; } + if (effect) { gBattleScripting.battler = battlerId; @@ -4395,7 +4402,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) && IsMoveMakingContact(gCurrentMove, gBattlerAttacker) && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) { - gBattleMoveDamage = gBattleMons[gBattlerAttacker].hp / 6; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 6; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; effect = ITEM_HP_CHANGE; @@ -4462,6 +4469,40 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) } } break; + case ITEMEFFECT_ORBS: + switch (battlerHoldEffect) + { + case HOLD_EFFECT_TOXIC_ORB: + if (!gBattleMons[battlerId].status1 + && !IS_BATTLER_OF_TYPE(battlerId, TYPE_POISON) && !IS_BATTLER_OF_TYPE(battlerId, TYPE_STEEL) + && GetBattlerAbility(battlerId) != ABILITY_IMMUNITY) + { + effect = ITEM_STATUS_CHANGE; + gBattleMons[battlerId].status1 = STATUS1_TOXIC_POISON; + BattleScriptExecute(BattleScript_ToxicOrb); + RecordItemEffectBattle(battlerId, battlerHoldEffect); + } + break; + case HOLD_EFFECT_FLAME_ORB: + if (!gBattleMons[battlerId].status1 + && !IS_BATTLER_OF_TYPE(battlerId, TYPE_FIRE) + && GetBattlerAbility(battlerId) != ABILITY_WATER_VEIL) + { + effect = ITEM_STATUS_CHANGE; + gBattleMons[battlerId].status1 = STATUS1_BURN; + BattleScriptExecute(BattleScript_FlameOrb); + RecordItemEffectBattle(battlerId, battlerHoldEffect); + } + break; + } + + if (effect == ITEM_STATUS_CHANGE) + { + gActiveBattler = battlerId; + BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[battlerId].status1); + MarkBattlerForControllerExec(gActiveBattler); + } + break; } // Berry was successfully used on a Pokemon.