Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed zMovePower field in gBattleMoves in favor of a function. #2794

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/battle_z_move.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ const u8 *GetZMoveName(u16 move);
void SetZEffect(void);
bool32 IsZMoveUsable(u8 battlerId, u16 moveIndex);
void GetUsableZMoves(u8 battlerId, u16 *moves);
u16 GetZMovePower(u16 move);

#endif // GUARD_BATTLE_Z_MOVE_H
#endif // GUARD_BATTLE_Z_MOVE_H
1 change: 0 additions & 1 deletion include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ struct BattleMove
u32 flags;
u8 split;
u8 argument;
u8 zMovePower;
u8 zMoveEffect;
};

Expand Down
3 changes: 2 additions & 1 deletion src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "battle_controllers.h"
#include "battle_interface.h"
#include "battle_setup.h"
#include "battle_z_move.h"
#include "party_menu.h"
#include "pokemon.h"
#include "international_string_util.h"
Expand Down Expand Up @@ -8532,7 +8533,7 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef)
u32 weight, hpFraction, speed;

if (gBattleStruct->zmove.active)
return gBattleMoves[gBattleStruct->zmove.baseMoves[battlerAtk]].zMovePower;
return GetZMovePower(gBattleStruct->zmove.baseMoves[battlerAtk]);

switch (gBattleMoves[move].effect)
{
Expand Down
44 changes: 43 additions & 1 deletion src/battle_z_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ bool32 MoveSelectionDisplayZMove(u16 zmove)
static void ZMoveSelectionDisplayPower(u16 move, u16 zMove)
{
u8 *txtPtr;
u16 power = gBattleMoves[move].zMovePower;
u16 power = GetZMovePower(move);

if (zMove >= MOVE_CATASTROPIKA)
power = gBattleMoves[zMove].power;
Expand Down Expand Up @@ -698,3 +698,45 @@ static bool32 AreStatsMaxed(u8 battlerId, u8 n)
return TRUE;
}

u16 GetZMovePower(u16 move)
{
if (gBattleMoves[move].split == SPLIT_STATUS)
return 0;
if (gBattleMoves[move].effect == EFFECT_OHKO)
return 180;

switch (move)
{
case MOVE_MEGA_DRAIN: return 120;
case MOVE_CORE_ENFORCER: return 140;
case MOVE_WEATHER_BALL: return 160;
case MOVE_HEX: return 160;
case MOVE_FLYING_PRESS: return 170;
case MOVE_GEAR_GRIND: return 180;
case MOVE_V_CREATE: return 220;
default:
{
if (gBattleMoves[move].power >= 140)
return 200;
else if (gBattleMoves[move].power >= 130)
return 195;
else if (gBattleMoves[move].power >= 120)
return 190;
else if (gBattleMoves[move].power >= 110)
return 185;
else if (gBattleMoves[move].power >= 100)
return 180;
else if (gBattleMoves[move].power >= 90)
return 175;
else if (gBattleMoves[move].power >= 80)
return 160;
else if (gBattleMoves[move].power >= 70)
return 140;
else if (gBattleMoves[move].power >= 60)
return 120;
else
return 100;
}
}
}

Loading