mirror of
https://github.com/pret/pmd-red.git
synced 2026-10-04 08:21:01 -04:00
123 lines
3.0 KiB
C
123 lines
3.0 KiB
C
#include "global.h"
|
|
#include "charge_move.h"
|
|
|
|
#include "constants/move_id.h"
|
|
#include "constants/status.h"
|
|
#include "dungeon_random.h"
|
|
#include "dungeon_util.h"
|
|
#include "moves.h"
|
|
|
|
struct MultiTurnChargeMove
|
|
{
|
|
u16 moveID;
|
|
u8 chargingStatus;
|
|
};
|
|
|
|
const struct MultiTurnChargeMove gMultiTurnChargeMoves[10] = {
|
|
{MOVE_SOLARBEAM, STATUS_SOLARBEAM},
|
|
{MOVE_SKY_ATTACK, STATUS_SKY_ATTACK},
|
|
{MOVE_RAZOR_WIND, STATUS_RAZOR_WIND},
|
|
{MOVE_FOCUS_PUNCH, STATUS_FOCUS_PUNCH},
|
|
{MOVE_SKULL_BASH, STATUS_SKULL_BASH},
|
|
{MOVE_FLY, STATUS_FLYING},
|
|
{MOVE_BOUNCE, STATUS_BOUNCING},
|
|
{MOVE_DIVE, STATUS_DIVING},
|
|
{MOVE_DIG, STATUS_DIGGING},
|
|
{MOVE_NOTHING, STATUS_NONE}
|
|
};
|
|
|
|
const u32 gMultiTurnChargingStatuses[10] = {
|
|
STATUS_SOLARBEAM,
|
|
STATUS_SKY_ATTACK,
|
|
STATUS_RAZOR_WIND,
|
|
STATUS_FOCUS_PUNCH,
|
|
STATUS_SKULL_BASH,
|
|
STATUS_FLYING,
|
|
STATUS_BOUNCING,
|
|
STATUS_DIVING,
|
|
STATUS_DIGGING,
|
|
STATUS_NONE
|
|
};
|
|
|
|
u32 sub_8057070(Move *move)
|
|
{
|
|
u32 numberOfChainedHits;
|
|
numberOfChainedHits = GetMoveNumberOfChainedHits(move);
|
|
if(numberOfChainedHits == 0)
|
|
return DungeonRandRange(2, 6);
|
|
else
|
|
return numberOfChainedHits;
|
|
}
|
|
|
|
bool8 MoveCausesPaused(Move *move)
|
|
{
|
|
if(move->id == MOVE_FRENZY_PLANT) return TRUE;
|
|
if(move->id == MOVE_HYDRO_CANNON) return TRUE;
|
|
if(move->id == MOVE_HYPER_BEAM) return TRUE;
|
|
if(move->id == MOVE_BLAST_BURN) return TRUE;
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
bool8 MoveMatchesChargingStatus(Entity *pokemon, Move *move)
|
|
{
|
|
if (!EntityExists(pokemon))
|
|
{
|
|
return FALSE;
|
|
}
|
|
else
|
|
{
|
|
EntityInfo *pokemonInfo = pokemon->info;
|
|
s32 i;
|
|
for (i = 0; i < 100; i++)
|
|
{
|
|
if (gMultiTurnChargeMoves[i].moveID == MOVE_NOTHING)
|
|
{
|
|
return FALSE;
|
|
}
|
|
if (move->id == gMultiTurnChargeMoves[i].moveID &&
|
|
pokemonInfo->chargingStatus == gMultiTurnChargeMoves[i].chargingStatus)
|
|
{
|
|
return TRUE;
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
bool8 IsCharging(Entity *pokemon, bool8 checkCharge)
|
|
{
|
|
if (!EntityExists(pokemon))
|
|
{
|
|
return FALSE;
|
|
}
|
|
else
|
|
{
|
|
EntityInfo *pokemonInfo = pokemon->info;
|
|
int i = 0;
|
|
u8 *chargingStatusPointer = &pokemonInfo->chargingStatus;
|
|
u8 *chargingStatusPointer2;
|
|
u8 chargeStatus = STATUS_CHARGING;
|
|
for (; i < 100; i++)
|
|
{
|
|
u8 currentStatus = gMultiTurnChargingStatuses[i];
|
|
u8 chargingStatus;
|
|
if (currentStatus == STATUS_NONE)
|
|
{
|
|
return FALSE;
|
|
}
|
|
chargingStatus = *chargingStatusPointer;
|
|
chargingStatusPointer2 = &pokemonInfo->chargingStatus;
|
|
if (chargingStatus == currentStatus)
|
|
{
|
|
return TRUE;
|
|
}
|
|
}
|
|
if (checkCharge && *chargingStatusPointer2 == chargeStatus)
|
|
{
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
}
|