mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 11:44:17 +01:00
add mirror herb
This commit is contained in:
parent
dd99cb6da8
commit
afc4b4cdee
@ -9980,23 +9980,42 @@ BattleScript_PrintPlayerForfeitedLinkBattle::
|
||||
end2
|
||||
|
||||
BattleScript_TotemFlaredToLife::
|
||||
playanimation BS_ATTACKER, B_ANIM_TOTEM_FLARE
|
||||
playanimation BS_ATTACKER, B_ANIM_TOTEM_FLARE, NULL
|
||||
printstring STRINGID_AURAFLAREDTOLIFE
|
||||
waitmessage B_WAIT_TIME_LONG
|
||||
goto BattleScript_ApplyTotemVarBoost
|
||||
call BattleScript_ApplyTotemVarBoost
|
||||
end2
|
||||
|
||||
@ remove the mirror herb, do totem loop
|
||||
BattleScript_MirrorHerbCopyStatChangeEnd2::
|
||||
call BattleScript_MirrorHerbCopyStatChange
|
||||
end2
|
||||
|
||||
BattleScript_MirrorHerbCopyStatChange::
|
||||
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL
|
||||
printstring STRINGID_MIRRORHERBCOPIED
|
||||
waitmessage B_WAIT_TIME_LONG
|
||||
removeitem BS_SCRIPTING
|
||||
call BattleScript_TotemVar_Ret
|
||||
copybyte gBattlerAttacker, sSAVED_BATTLER @ restore the original attacker just to be safe
|
||||
return
|
||||
|
||||
BattleScript_TotemVar::
|
||||
call BattleScript_TotemVar_Ret
|
||||
end2
|
||||
|
||||
BattleScript_TotemVar_Ret::
|
||||
gettotemboost BattleScript_ApplyTotemVarBoost
|
||||
BattleScript_TotemVarEnd:
|
||||
end2
|
||||
return
|
||||
BattleScript_ApplyTotemVarBoost:
|
||||
statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_TotemVarEnd
|
||||
setgraphicalstatchangevalues
|
||||
playanimation BS_SCRIPTING, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
|
||||
BattleScript_TotemVarPrintStatMsg:
|
||||
printfromtable gStatUpStringIds
|
||||
waitmessage B_WAIT_TIME_LONG
|
||||
goto BattleScript_TotemVar @loop until stats bitfield is empty
|
||||
goto BattleScript_TotemVar_Ret @loop until stats bitfield is empty
|
||||
|
||||
|
||||
BattleScript_AnnounceAirLockCloudNine::
|
||||
call BattleScript_AbilityPopUp
|
||||
|
@ -145,6 +145,7 @@ struct ProtectStruct
|
||||
u16 quash:1;
|
||||
u16 shellTrap:1;
|
||||
u16 silkTrapped:1;
|
||||
u16 eatMirrorHerb:1;
|
||||
u32 physicalDmg;
|
||||
u32 specialDmg;
|
||||
u8 physicalBattlerId;
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef GUARD_BATTLE_SCRIPTS_H
|
||||
#define GUARD_BATTLE_SCRIPTS_H
|
||||
|
||||
extern const u8 BattleScript_MirrorHerbCopyStatChange[];
|
||||
extern const u8 BattleScript_MirrorHerbCopyStatChangeEnd2[];
|
||||
extern const u8 BattleScript_NotAffected[];
|
||||
extern const u8 BattleScript_HitFromCritCalc[];
|
||||
extern const u8 BattleScript_MoveEnd[];
|
||||
|
@ -647,8 +647,9 @@
|
||||
#define STRINGID_STEALTHROCKDISAPPEAREDFROMTEAM 645
|
||||
#define STRINGID_COULDNTFULLYPROTECT 646
|
||||
#define STRINGID_STOCKPILEDEFFECTWOREOFF 647
|
||||
#define STRINGID_MIRRORHERBCOPIED 648
|
||||
|
||||
#define BATTLESTRINGS_COUNT 648
|
||||
#define BATTLESTRINGS_COUNT 649
|
||||
|
||||
// This is the string id that gBattleStringsTable starts with.
|
||||
// String ids before this (e.g. STRINGID_INTROMSG) are not in the table,
|
||||
|
@ -782,9 +782,11 @@ static const u8 sText_PrepareShellTrap[] = _("{B_ATK_NAME_WITH_PREFIX} set a she
|
||||
static const u8 sText_ShellTrapDidntWork[] = _("{B_ATK_NAME_WITH_PREFIX}'s shell trap didn't work!");
|
||||
static const u8 sText_CouldntFullyProtect[] = _("{B_DEF_NAME_WITH_PREFIX} couldn't fully protect\nitself and got hurt!");
|
||||
static const u8 sText_StockpiledEffectWoreOff[] = _("{B_ATK_NAME_WITH_PREFIX}'s stockpiled\neffect wore off!");
|
||||
static const u8 sText_MirrorHerbCopied[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s used its {B_LAST_ITEM}\nto mirror its opponent's stat changes!");
|
||||
|
||||
const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
|
||||
{
|
||||
[STRINGID_MIRRORHERBCOPIED - BATTLESTRINGS_TABLE_START] = sText_MirrorHerbCopied,
|
||||
[STRINGID_STOCKPILEDEFFECTWOREOFF - BATTLESTRINGS_TABLE_START] = sText_StockpiledEffectWoreOff,
|
||||
[STRINGID_COULDNTFULLYPROTECT - BATTLESTRINGS_TABLE_START] = sText_CouldntFullyProtect,
|
||||
[STRINGID_ATTACKERGAINEDSTRENGTHFROMTHEFALLEN - BATTLESTRINGS_TABLE_START] = sText_AttackerGainedStrengthFromTheFallen,
|
||||
|
@ -12080,6 +12080,20 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
|
||||
{
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler);
|
||||
gProtectStructs[gActiveBattler].statRaised = TRUE;
|
||||
|
||||
// check mirror herb
|
||||
for (index = 0; index < gBattlersCount; index++)
|
||||
{
|
||||
if (GetBattlerSide(index) == GetBattlerSide(gActiveBattler))
|
||||
continue; // Only triggers on opposing side
|
||||
if (GetBattlerHoldEffect(index, TRUE) == HOLD_EFFECT_MIRROR_HERB
|
||||
&& gBattleMons[index].statStages[statId] < MAX_STAT_STAGE)
|
||||
{
|
||||
gProtectStructs[index].eatMirrorHerb = 1;
|
||||
gTotemBoosts[index].stats |= (1 << (statId - 1)); // -1 to start at atk
|
||||
gTotemBoosts[index].statChanges[statId - 1] = statValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6877,6 +6877,26 @@ static bool32 GetMentalHerbEffect(u8 battlerId)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static u8 TryConsumeMirrorHerb(u8 battlerId, bool32 execute)
|
||||
{
|
||||
u8 effect = 0;
|
||||
|
||||
if (gProtectStructs[battlerId].eatMirrorHerb) {
|
||||
gLastUsedItem = gBattleMons[battlerId].item;
|
||||
gBattleScripting.savedBattler = gBattlerAttacker;
|
||||
gBattleScripting.battler = gBattlerAttacker = battlerId;
|
||||
gProtectStructs[battlerId].eatMirrorHerb = 0;
|
||||
if (execute) {
|
||||
BattleScriptExecute(BattleScript_MirrorHerbCopyStatChangeEnd2);
|
||||
} else {
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_MirrorHerbCopyStatChange;
|
||||
}
|
||||
effect = ITEM_STATS_CHANGE;
|
||||
}
|
||||
return effect;
|
||||
}
|
||||
|
||||
static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
|
||||
{
|
||||
u8 effect = 0;
|
||||
@ -7058,6 +7078,9 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
|
||||
effect = ITEM_EFFECT_OTHER;
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_MIRROR_HERB:
|
||||
effect = TryConsumeMirrorHerb(battlerId, FALSE);
|
||||
break;
|
||||
}
|
||||
|
||||
return effect;
|
||||
@ -7580,6 +7603,9 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
if (!moveTurn)
|
||||
effect = TrySetMicleBerry(battlerId, gLastUsedItem, TRUE);
|
||||
break;
|
||||
case HOLD_EFFECT_MIRROR_HERB:
|
||||
effect = TryConsumeMirrorHerb(battlerId, TRUE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (effect != 0)
|
||||
|
Loading…
Reference in New Issue
Block a user