mirror of
https://github.com/pret/pmd-red.git
synced 2024-11-26 22:40:33 +00:00
new file - dungeon_move.c and clean-up
This commit is contained in:
parent
a2bc2f66ec
commit
b0f1f8a878
@ -235,8 +235,7 @@ SECTIONS {
|
||||
src/code_804AFAC.o(.text);
|
||||
asm/code_804FD30.o(.text);
|
||||
src/dungeon_message.o(.text);
|
||||
src/charge_move.o(.text);
|
||||
src/move_util.o(.text);
|
||||
src/dungeon_move.o(.text);
|
||||
src/move_actions.o(.text);
|
||||
src/status_actions.o(.text);
|
||||
src/move_checks.o(.text);
|
||||
@ -557,7 +556,7 @@ SECTIONS {
|
||||
src/dungeon_pokemon_attributes.o(.rodata);
|
||||
src/called_move_data.o(.rodata);
|
||||
data/data_80F59C8.o(.rodata);
|
||||
src/charge_move.o(.rodata);
|
||||
src/dungeon_move.o(.rodata);
|
||||
data/data_8106A4C.o(.rodata);
|
||||
src/code_806CD90.o(.rodata);
|
||||
src/type_effectiveness.o(.data);
|
||||
|
@ -1,123 +0,0 @@
|
||||
#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->charging.chargingStatus == gMultiTurnChargeMoves[i].chargingStatus)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
bool8 IsChargingAnyTwoTurnMove(Entity *pokemon, bool8 checkCharge)
|
||||
{
|
||||
if (!EntityExists(pokemon))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityInfo *pokemonInfo = pokemon->info;
|
||||
int i = 0;
|
||||
u8 *chargingStatusPointer = &pokemonInfo->charging.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->charging.chargingStatus;
|
||||
if (chargingStatus == currentStatus)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
// BUG: This condition is never reached because the for loop terminates by returning FALSE at the end of the gMultiTurnChargingStatuses array.
|
||||
if (checkCharge && *chargingStatusPointer2 == chargeStatus)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
3300
src/dungeon_move.c
Normal file
3300
src/dungeon_move.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -219,65 +219,6 @@ extern void DealDamageToEntity(Entity *, s32, u32, u32);
|
||||
extern s16 gUnknown_80F4DB4;
|
||||
extern u32 gUnknown_8106A4C;
|
||||
|
||||
// TODO: WTF are these loops? https://decomp.me/scratch/svYTQ
|
||||
void sub_80574C4(s32 *a0, s32 a1)
|
||||
{
|
||||
s32 r2;
|
||||
s32 r3;
|
||||
s32 temp;
|
||||
s32 buffer[0x41];
|
||||
|
||||
r3 = 0;
|
||||
r2 = 0;
|
||||
if (a0[0] != 0) {
|
||||
if (a0[0] == a1)
|
||||
goto continue1;
|
||||
itsmol1:
|
||||
buffer[r3] = a0[r2];
|
||||
r3++;
|
||||
continue1:
|
||||
r2++;
|
||||
if (r2 >= 0x41)
|
||||
goto break1;
|
||||
if (a0[r2] == 0)
|
||||
goto break1;
|
||||
if (a0[r2] == a1)
|
||||
goto continue1;
|
||||
if (r3 < 0x40)
|
||||
goto itsmol1;
|
||||
}
|
||||
break1:
|
||||
|
||||
r2 = 0;
|
||||
temp = a0[r2];
|
||||
goto for2;
|
||||
itsmol2:
|
||||
buffer[r3] = a0[r2];
|
||||
r3++;
|
||||
continue2:
|
||||
r2++;
|
||||
if (r2 > 0x40)
|
||||
goto break2;
|
||||
temp = a0[r2];
|
||||
for2:
|
||||
if (temp == 0)
|
||||
goto break2;
|
||||
if (temp != a1)
|
||||
goto continue2;
|
||||
if (r3 < 0x40)
|
||||
goto itsmol2;
|
||||
break2:
|
||||
|
||||
while (r3 < 0x41) {
|
||||
buffer[r3] = 0;
|
||||
r3++;
|
||||
}
|
||||
|
||||
for (r2 = 0; r2 < 0x41; r2++) {
|
||||
a0[r2] = buffer[r2];
|
||||
}
|
||||
}
|
||||
|
||||
bool8 sub_805755C(Entity* pokemon, u16 moveID)
|
||||
{
|
||||
if ((moveID == MOVE_SOLARBEAM) && (GetApparentWeather(pokemon) == WEATHER_SUNNY)) {
|
||||
|
218
src/move_util.c
218
src/move_util.c
@ -1,218 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "move_util.h"
|
||||
|
||||
#include "constants/ability.h"
|
||||
#include "constants/move_id.h"
|
||||
#include "constants/status.h"
|
||||
#include "moves.h"
|
||||
#include "dungeon_util.h"
|
||||
#include "dungeon_pokemon_attributes.h"
|
||||
#include "dungeon_random.h"
|
||||
#include "structs/str_dungeon.h"
|
||||
#include "called_move_data.h"
|
||||
|
||||
|
||||
extern bool8 sub_8044B28(void);
|
||||
extern void sub_80429C8(Entity *r0);
|
||||
|
||||
bool8 sub_805755C(Entity* pokemon,u16 param_2);
|
||||
|
||||
u32 sub_8057144(Entity * pokemon)
|
||||
{
|
||||
Move *moveStack[80];
|
||||
int i, j, nMoves;
|
||||
|
||||
nMoves = 0;
|
||||
for (i = 0; i < DUNGEON_MAX_POKEMON; i++)
|
||||
{
|
||||
Entity *dungeonMon = gDungeon->allPokemon[i];
|
||||
if (EntityExists(dungeonMon)) {
|
||||
Move *moves = dungeonMon->info->moves.moves;
|
||||
for (j = 0; j < MAX_MON_MOVES; j++)
|
||||
{
|
||||
if (moves[j].moveFlags & MOVE_FLAG_EXISTS
|
||||
&& !sub_805755C(pokemon, moves[j].id)
|
||||
&& moves[j].id != MOVE_SKETCH
|
||||
&& nMoves < 80) {
|
||||
moveStack[nMoves++] = &moves[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nMoves == 0) {
|
||||
return MOVE_REGULAR_ATTACK;
|
||||
}
|
||||
else {
|
||||
return moveStack[DungeonRandInt(nMoves)]->id;
|
||||
}
|
||||
}
|
||||
|
||||
bool8 sub_80571F0(Entity * pokemon, Move *move)
|
||||
{
|
||||
u16 moveID;
|
||||
s32 tileset;
|
||||
EntityInfo *entityInfo;
|
||||
|
||||
entityInfo = pokemon->info;
|
||||
|
||||
if (entityInfo->unkFF == 1) {
|
||||
moveID = move->id;
|
||||
if ((moveID == MOVE_SKY_UPPERCUT) || (moveID == MOVE_TWISTER) || (moveID == MOVE_GUST) || (moveID == MOVE_THUNDER))
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
else if (entityInfo->unkFF == 2) {
|
||||
if (entityInfo->charging.chargingStatus == STATUS_DIVING) {
|
||||
if (move->id == MOVE_WHIRLPOOL || move->id == MOVE_SURF) return FALSE;
|
||||
}
|
||||
else if (entityInfo->charging.chargingStatus == STATUS_DIGGING) {
|
||||
moveID = move->id;
|
||||
if (moveID == MOVE_EARTHQUAKE || moveID == MOVE_MAGNITUDE) return FALSE;
|
||||
if (moveID == MOVE_NATURE_POWER) {
|
||||
tileset = gDungeon->tileset;
|
||||
if (tileset < 0) {
|
||||
tileset = 0;
|
||||
}
|
||||
if (0x4a < tileset) {
|
||||
tileset = 0x4a;
|
||||
}
|
||||
if (gNaturePowerCalledMoves[tileset].moveID == MOVE_EARTHQUAKE) return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 sub_805727C(Entity * pokemon, Entity * target, s32 chance)
|
||||
{
|
||||
bool8 uVar2;
|
||||
if (sub_8044B28())
|
||||
return FALSE;
|
||||
if (!EntityExists(pokemon) || !EntityExists(target))
|
||||
return FALSE;
|
||||
if (target->info->unk158 == 0 || target->info->HP == 0)
|
||||
return FALSE;
|
||||
|
||||
if (chance != 0) {
|
||||
if (HasAbility(pokemon, ABILITY_SERENE_GRACE)) {
|
||||
uVar2 = DungeonRandOutcome_2(chance * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
uVar2 = DungeonRandOutcome_2(chance);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uVar2 = TRUE;
|
||||
}
|
||||
|
||||
if (uVar2 && (pokemon != target) && HasAbility(target, ABILITY_SHIELD_DUST))
|
||||
{
|
||||
sub_80429C8(target);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return uVar2;
|
||||
}
|
||||
|
||||
bool8 sub_8057308(Entity *pokemon, s32 chance)
|
||||
{
|
||||
if(!EntityExists(pokemon))
|
||||
return FALSE;
|
||||
if(chance == 0)
|
||||
return TRUE;
|
||||
if(HasAbility(pokemon, ABILITY_SERENE_GRACE))
|
||||
return DungeonRandOutcome_2(chance * 2);
|
||||
else
|
||||
return DungeonRandOutcome_2(chance);
|
||||
}
|
||||
|
||||
bool8 CanAIUseMove(Entity *pokemon, s32 moveIndex, bool8 hasPPChecker)
|
||||
{
|
||||
s32 i;
|
||||
EntityInfo *pokemonInfo = GetEntInfo(pokemon);
|
||||
Move *move = &pokemonInfo->moves.moves[moveIndex];
|
||||
if (!MoveFlagExists(move))
|
||||
return FALSE;
|
||||
if (MoveFlagLinkChain(move) || MoveFlagDisabled(move) || MoveFlagSealed(move))
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < MAX_MON_MOVES; i++) {
|
||||
if (CanMonsterUseMove(pokemon, move, hasPPChecker))
|
||||
return TRUE;
|
||||
move++;
|
||||
if (move >= &pokemonInfo->moves.moves[MAX_MON_MOVES])
|
||||
break;
|
||||
if (!(move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 CanMonsterUseMove(Entity *pokemon, Move *move, bool8 hasPPChecker)
|
||||
{
|
||||
EntityInfo *pokemonInfo = pokemon->info;
|
||||
if (move->id == MOVE_REGULAR_ATTACK)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
if (move->moveFlags & MOVE_FLAG_DISABLED || move->moveFlags2 & MOVE_FLAG_SEALED)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (hasPPChecker)
|
||||
{
|
||||
if (move->PP == 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (pokemonInfo->volatileStatus.volatileStatus == STATUS_TAUNTED && !MoveIgnoresTaunted(move))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (pokemonInfo->volatileStatus.volatileStatus == STATUS_ENCORE)
|
||||
{
|
||||
if (move->id == MOVE_STRUGGLE)
|
||||
{
|
||||
if (!(pokemonInfo->moves.struggleMoveFlags & MOVE_FLAG_LAST_USED))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else if (!(move->moveFlags & MOVE_FLAG_LAST_USED))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 sub_805744C(Entity * pokemon, Move *move, bool8 param_3)
|
||||
{
|
||||
EntityInfo *entityInfo;
|
||||
|
||||
entityInfo = pokemon->info;
|
||||
if (move->id != MOVE_REGULAR_ATTACK) {
|
||||
if (((move->moveFlags & MOVE_FLAG_DISABLED)) || ((move->moveFlags2 & MOVE_FLAG_EXISTS))) {
|
||||
return FALSE;
|
||||
}
|
||||
if (param_3 != 0) {
|
||||
if ((entityInfo->volatileStatus.volatileStatus == STATUS_TAUNTED) && (!MoveIgnoresTaunted(move))) return FALSE;
|
||||
if (entityInfo->volatileStatus.volatileStatus == STATUS_ENCORE) {
|
||||
if (move->id == MOVE_STRUGGLE) {
|
||||
if((entityInfo->moves.struggleMoveFlags & MOVE_FLAG_LAST_USED) == 0) return FALSE;
|
||||
}
|
||||
else {
|
||||
if((move->moveFlags & MOVE_FLAG_LAST_USED) == 0) return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
@ -392,47 +392,8 @@ gUnknown_202F1E0: /* 202F1E0 (sub_80511F0) */
|
||||
gUnknown_202F1E1: /* 202F1E1 (sub_80511F0 - sub_8051438) */
|
||||
.space 0x7
|
||||
|
||||
gUnknown_202F1E8: /* 202F1E8 (sub_80521D0 - sub_80523A8) */
|
||||
.space 0x8
|
||||
|
||||
gUnknown_202F1F0: /* 202F1F0 (sub_8052FB8) */
|
||||
.space 0x8
|
||||
|
||||
gUnknown_202F1F8: /* 202F1F8 (sub_80532B4 - sub_8053540) */
|
||||
.space 0x4
|
||||
gUnknown_202F1FC: /* 202F1FC (sub_80532B4 - sub_8053540) */
|
||||
.space 0x4
|
||||
|
||||
gUnknown_202F200: /* 202F200 (sub_805363C) */
|
||||
.space 0x8
|
||||
|
||||
gUnknown_202F208: /* 202F208 (sub_8053704 - sub_8067904) */
|
||||
.space 0x4
|
||||
gUnknown_202F20C: /* 202F20C (sub_8053704 - sub_8055FA0) */
|
||||
.space 0x4
|
||||
gUnknown_202F210: /* 202F210 (sub_8055FA0 - sub_805A210) */
|
||||
.space 0x4
|
||||
gUnknown_202F214: /* 202F214 (sub_8055FA0 - sub_8059988) */
|
||||
.space 0x4
|
||||
gUnknown_202F218: /* 202F218 (sub_8055FA0 - sub_8059988) */
|
||||
.space 0x1
|
||||
gUnknown_202F219: /* 202F219 (sub_8055FA0 - sub_80588B8) */
|
||||
.space 0x1
|
||||
gUnknown_202F21A: /* 202F21A (sub_8055FA0 - sub_8058A18) */
|
||||
.space 0x2
|
||||
gUnknown_202F21C: /* 202F21C (sub_8055FA0 - sub_805768C) */
|
||||
.space 0x4
|
||||
gUnknown_202F220: /* 202F220 (sub_8055FA0 - sub_805768C) */
|
||||
.space 0x1
|
||||
gUnknown_202F221: /* 202F221 (sub_8055A00 - sub_8072CF4) */
|
||||
.space 0x1
|
||||
gUnknown_202F222: /* 202F222 (sub_8053704 - sub_8072CF4) */
|
||||
.space 0x2
|
||||
gUnknown_202F224: /* 202F224 (sub_8040DA0 - sub_805B264) */
|
||||
.space 0x4
|
||||
gMetronomeCalledArrayId: /* 202F228 (sub_8055FA0 - sub_805B618) */
|
||||
.space 0x4
|
||||
|
||||
.include "src/dungeon_message.o"
|
||||
.include "src/dungeon_move.o"
|
||||
.include "src/code_805D8C8_1.o"
|
||||
|
||||
gUnknown_202F268: /* 202F268 (sub_8062500) */
|
||||
|
Loading…
Reference in New Issue
Block a user