Skip to content

Commit

Permalink
rebase updates
Browse files Browse the repository at this point in the history
  • Loading branch information
SethBarberee committed Sep 19, 2024
1 parent 273419f commit b68f22e
Show file tree
Hide file tree
Showing 27 changed files with 92 additions and 91 deletions.
9 changes: 3 additions & 6 deletions include/code_8069D4C.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@ struct unkStruct_8069D4C
s16 id;
Position pos;
s16 HP;
u8 atk;
u8 spAtk;
u8 def;
u8 spDef;
/* 0x0 */ u8 att[2]; // Atk, SpAtk
/* 0x2 */ u8 def[2]; // Def, SpDef
u16 level;
u32 exp;
FixedPoint belly;
FixedPoint maxBelly;
Item heldItem;
Move moves[MAX_MON_MOVES];
u32 unk40; // strugglemoveFlags?
Moves moves;
HiddenPower hiddenPower;
};

Expand Down
6 changes: 3 additions & 3 deletions include/moves.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bool8 sub_8093318(s32, Move *moves);
bool8 sub_809333C(s32, Move *moves);
s32 sub_80935B8(Move *moves, s32 index);
void sub_8094060(Move *srcMoves, Move *destMoves);
void sub_8094184(struct unkStruct_8094924 *, struct unkStruct_8094184 *);
void sub_80941FC(struct unkStruct_8094924 *, struct unkStruct_8094184 *);
void sub_8094184(struct unkStruct_8094924 *, struct Moves *);
void sub_80941FC(struct unkStruct_8094924 *, struct Moves *);

#endif // GUARD_MOVES_H
#endif // GUARD_MOVES_H
9 changes: 7 additions & 2 deletions include/structs/dungeon_entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ typedef struct Unk_Entity_x184
/* 0x19e - 0x1a */ u8 unk1A;
} Unk_Entity_x184 ;

typedef struct Moves
{
/* 0x118 */ Move moves[MAX_MON_MOVES];
/* 0x138 */ u8 struggleMoveFlags;
} Moves;

// size: 0x208
typedef struct EntityInfo
{
Expand Down Expand Up @@ -272,8 +278,7 @@ typedef struct EntityInfo
// When non-zero, an AI Pokémon will move in a random direction every turn when it is a room.
// There is a chance of this flag being set when a wild Pokémon spawns. The chance depends on the dungeon's randomMovementChance.
/* 0x114 */ u32 moveRandomly;
/* 0x118 */ Move moves[MAX_MON_MOVES];
/* 0x138 */ u8 struggleMoveFlags;
/* 0x118 */ Moves moves;
/* 0x13C */ FixedPoint belly;
/* 0x140 */ FixedPoint maxBelly;
/* 0x144 */ bool8 aiNextToTarget; // True if an AI Pokémon is following another Pokémon and is already adjacent to them.
Expand Down
6 changes: 3 additions & 3 deletions include/structs/str_pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ typedef struct PokemonStruct2
u16 unk12; // pokeHP
/* 0x14 */ Offense offense; // offense (other offset)
/* 0x18 */ u32 currExp;
/* 0x1C */ unkStruct_8094184 moves;
/* 0x1C */ Moves moves;
/* 0x40 */ Item itemSlot; // heldItem
u32 belly; // some struct
u32 maxBelly; // some struct (same type as 44)
FixedPoint belly; // some struct
FixedPoint maxBelly; // some struct (same type as 44)
/* 0x4C */ u32 IQSkills; // unk20
/* 0x50 */ u8 tacticIndex;
/* 0x54 */ HiddenPower hiddenPower;
Expand Down
2 changes: 1 addition & 1 deletion src/code_8048480.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ void GinsengItemAction(Entity *pokemon, Entity * target)
if (DungeonRandInt(100) < gUnknown_80F4F46)
moveBoost = 3;
if (entityInfo->isTeamLeader) {
for(moveIndex = 0, movePtr1 = &entityInfo->moves[0], movePtr2 = movePtr1; moveIndex < MAX_MON_MOVES; movePtr1++, movePtr2++, moveIndex++)
for(moveIndex = 0, movePtr1 = &entityInfo->moves.moves[0], movePtr2 = movePtr1; moveIndex < MAX_MON_MOVES; movePtr1++, movePtr2++, moveIndex++)
{
if((movePtr1->moveFlags & MOVE_FLAG_EXISTS) && (movePtr1->moveFlags & MOVE_FLAG_SET))
{
Expand Down
4 changes: 2 additions & 2 deletions src/code_8069D4C.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "global.h"
#include "pokemon_mid.h"
#include "dungeon_util.h"
#include "structs/struct_8069D4C.h"
#include "code_8069D4C.h"

u32 sub_8069D18(Position *pos,Entity *entity)
{
Expand Down Expand Up @@ -38,7 +38,7 @@ void sub_8069D4C(struct unkStruct_8069D4C *r0, Entity *target)
r0->def[0] = info->def;
r0->def[1] = info->spDef;
r0->heldItem = info->heldItem;
memcpy(r0->moves.moves, info->moves, sizeof(r0->moves));
memcpy(r0->moves.moves, info->moves.moves, sizeof(r0->moves));
r0->belly = info->belly;
r0->maxBelly = info->maxBelly;
r0->hiddenPower = info->hiddenPower;
Expand Down
2 changes: 1 addition & 1 deletion src/code_806FDF4.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "global.h"
#include "structs/str_pokemon.h"
#include "structs/struct_8069D4C.h"
#include "code_8069D4C.h"
#include "code_80118A4.h"
#include "code_803E668.h"
#include "code_8045A00.h"
Expand Down
8 changes: 4 additions & 4 deletions src/code_8077274_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ void RestorePPTarget(Entity * pokemon,Entity * target, s32 param_3)

for(index = 0; index < MAX_MON_MOVES; index++)
{
movePtr = &entityInfo->moves[index];
movePtr = &entityInfo->moves.moves[index];
movePtr1 = movePtr;
if ((movePtr->moveFlags & MOVE_FLAG_EXISTS)) {
PP = movePtr->PP;
Expand Down Expand Up @@ -689,7 +689,7 @@ void SetChargeStatusTarget(Entity *pokemon, Entity *target, u8 newStatus, Move *

for(index = 0; index < MAX_MON_MOVES; index++)
{
movePtr = &entityInfo->moves[index];
movePtr = &entityInfo->moves.moves[index];
if(movePtr == move)
{
entityInfo->charging.chargingStatusMoveIndex = index;
Expand Down Expand Up @@ -1118,7 +1118,7 @@ void sub_8079F20(Entity * pokemon, Entity * target, u8 param_3, u8 param_4)

for(index = 0; index < MAX_MON_MOVES; index++)
{
move = &entityInfo->moves[index];
move = &entityInfo->moves.moves[index];
if ((move->moveFlags & MOVE_FLAG_EXISTS) && (move->moveFlags2 & MOVE_FLAG_EXISTS)) {
bVar8 = TRUE;
moveUnsealed = TRUE;
Expand Down Expand Up @@ -1155,7 +1155,7 @@ void sub_807A0CC(Entity * pokemon, Entity * target)

for(index = 0; index < MAX_MON_MOVES; index++)
{
move = &entityInfo->moves[index];
move = &entityInfo->moves.moves[index];
if ((move->moveFlags & MOVE_FLAG_EXISTS)) {
move->moveFlags2 &= ~(MOVE_FLAG_EXISTS);
}
Expand Down
4 changes: 2 additions & 2 deletions src/code_807CD9C.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void sub_807CD9C(Entity *pokemon, Entity *target, u32 direction)
if (sp_0x28 != NULL) {
InitPokemonMove(&move,0x163);
if (!sub_80571F0(sp_0x28,&move)) {
sub_807A96C(pokemon,sp_0x28);
TrySendImmobilizeSleepEndMsg(pokemon,sp_0x28);
sub_806F370(pokemon,sp_0x28,gUnknown_80F4F90,0,0,0,0x21a,0,0,0);
}
}
Expand Down Expand Up @@ -248,7 +248,7 @@ void sub_807D148(Entity *pokemon, Entity *target, u32 param_3, Position *pos)
}

sub_80522F4(pokemon,target,*gUnknown_80FC584); // $m0 warped!
sub_807A96C(target,target);
TrySendImmobilizeSleepEndMsg(target,target);
sub_80421AC(pokemon,target);
if (sub_8045888(target)) {
direction = (info->action).direction;
Expand Down
26 changes: 13 additions & 13 deletions src/dungeon_ai_attack.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,18 @@ void DecideAttack(Entity *pokemon)
{
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (pokemonInfo->moves[i].moveFlags & MOVE_FLAG_EXISTS &&
MoveMatchesChargingStatus(pokemon, &pokemonInfo->moves[i]) &&
if (pokemonInfo->moves.moves[i].moveFlags & MOVE_FLAG_EXISTS &&
MoveMatchesChargingStatus(pokemon, &pokemonInfo->moves.moves[i]) &&
pokemonInfo->charging.chargingStatusMoveIndex == i)
{
s32 chosenMoveIndex;
SetMonsterActionFields(&pokemonInfo->action, ACTION_USE_MOVE_AI);
chosenMoveIndex = i;
if (i > 0 && pokemonInfo->moves[i].moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)
if (i > 0 && pokemonInfo->moves.moves[i].moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)
{
while (--chosenMoveIndex > 0)
{
if (!(pokemonInfo->moves[chosenMoveIndex].moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))
if (!(pokemonInfo->moves.moves[chosenMoveIndex].moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))
{
break;
}
Expand All @@ -122,10 +122,10 @@ void DecideAttack(Entity *pokemon)
numUsableMoves = 0;
for (i = 0; i < MAX_MON_MOVES; i++)
{
Move *move = &pokemonInfo->moves[i];
if (pokemonInfo->moves[i].moveFlags & MOVE_FLAG_EXISTS)
Move *move = &pokemonInfo->moves.moves[i];
if (pokemonInfo->moves.moves[i].moveFlags & MOVE_FLAG_EXISTS)
{
if (pokemonInfo->moves[i].moveFlags & MOVE_FLAG_ENABLED_FOR_AI)
if (pokemonInfo->moves.moves[i].moveFlags & MOVE_FLAG_ENABLED_FOR_AI)
{
numUsableMoves++;
}
Expand Down Expand Up @@ -161,7 +161,7 @@ void DecideAttack(Entity *pokemon)
// This requires a separate check from the 0-PP check used for unlinked moves.
for (i = 0; i < MAX_MON_MOVES; i++)
{
Move *move = &pokemonInfo->moves[i];
Move *move = &pokemonInfo->moves.moves[i];
if (!(move->moveFlags & MOVE_FLAG_EXISTS))
{
break;
Expand Down Expand Up @@ -202,7 +202,7 @@ void DecideAttack(Entity *pokemon)
{
Move *move;
aiPossibleMove[i].canBeUsed = FALSE;
move = &pokemonInfo->moves[i];
move = &pokemonInfo->moves.moves[i];
if (move->moveFlags & MOVE_FLAG_EXISTS &&
willNotUnlinkMove[i] &&
CanAIUseMove(pokemon, i, hasPPChecker) &&
Expand Down Expand Up @@ -319,17 +319,17 @@ void DecideAttack(Entity *pokemon)
}
else
{
AIConsiderMove(&aiPossibleMove[i], pokemon, &pokemonInfo->moves[i]);
AIConsiderMove(&aiPossibleMove[i], pokemon, &pokemonInfo->moves.moves[i]);
if (aiPossibleMove[i].canBeUsed)
{
s32 chosenMoveIndex;
SetMonsterActionFields(&pokemonInfo->action, ACTION_USE_MOVE_AI);
chosenMoveIndex = i;
if (i > 0 && pokemonInfo->moves[i].moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)
if (i > 0 && pokemonInfo->moves.moves[i].moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)
{
while (--chosenMoveIndex > 0)
{
if (!(pokemonInfo->moves[chosenMoveIndex].moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))
if (!(pokemonInfo->moves.moves[chosenMoveIndex].moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))
{
break;
}
Expand Down Expand Up @@ -1012,7 +1012,7 @@ void HandleUseOrbAction(Entity *pokemon)
if (!entityInfo->isTeamLeader) {
sp28.canBeUsed = r8;
sp28.weight = 10;
AIConsiderMove(&sp28, pokemon, entityInfo->moves);
AIConsiderMove(&sp28, pokemon, entityInfo->moves.moves);

if (sp28.canBeUsed) {
entityInfo->action.direction = sp28.direction & 7;
Expand Down
4 changes: 2 additions & 2 deletions src/dungeon_ai_item_weight.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ u32 GetAIUseItemProbability(Entity *targetPokemon, Item *item, u32 itemTargetFla
break;
case ITEM_MAX_ELIXIR:
itemWeight = 0;
move = pokemonInfo->moves;
move = pokemonInfo->moves.moves;
move2 = move;
for (i = 0; i < MAX_MON_MOVES; move++, move2++, i++)
{
Expand Down Expand Up @@ -427,7 +427,7 @@ u32 GetAIUseItemProbability(Entity *targetPokemon, Item *item, u32 itemTargetFla
itemWeight = 30;
break;
case ITEM_ROLLCALL_ORB:
move = pokemonInfo->moves; // Fixes a regswap.
move = pokemonInfo->moves.moves; // Fixes a regswap.
if (targetOther)
{
itemWeight = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/dungeon_ai_leader.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ bool8 sub_8072CF4(Entity *entity)

for(index = 0; index < MAX_MON_MOVES; index++)
{
move = &info->moves[index];
move = &info->moves.moves[index];
if ((move->moveFlags & MOVE_FLAG_EXISTS)) {
move->moveFlags2 &= ~(MOVE_FLAG2_UNK4);
}
Expand Down Expand Up @@ -334,8 +334,8 @@ bool8 sub_8072CF4(Entity *entity)

for(index = 0; index < MAX_MON_MOVES; index++)
{
move = &info->moves[index];
if ((info->moves[index].moveFlags & MOVE_FLAG_EXISTS) && (move->moveFlags & MOVE_FLAG_LAST_USED)) {
move = &info->moves.moves[index];
if ((info->moves.moves[index].moveFlags & MOVE_FLAG_EXISTS) && (move->moveFlags & MOVE_FLAG_LAST_USED)) {
move->PP = 0;
bVar4 = TRUE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/dungeon_pokemon_attributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ bool8 sub_80717A4(Entity *pokemon, u16 moveID)

Move *pokeMove2; // some reason uses another pointer to same struct

for(index = 0, pokeMove = entityInfo->moves, pokeMove2 = pokeMove; index < MAX_MON_MOVES; pokeMove++, pokeMove2++, index++)
for(index = 0, pokeMove = entityInfo->moves.moves, pokeMove2 = pokeMove; index < MAX_MON_MOVES; pokeMove++, pokeMove2++, index++)
{
if (((pokeMove->moveFlags & MOVE_FLAG_EXISTS)) && (entityInfo->isTeamLeader || ((pokeMove->moveFlags & MOVE_FLAG_ENABLED_FOR_AI))))
if((sub_805744C(pokemon, pokeMove2, TRUE) != 0) && (pokeMove->PP != 0))
Expand Down
6 changes: 3 additions & 3 deletions src/friend_rescue.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ void sub_8032828(void)
case 0x32:
if (sub_8030894() == 0) {
ResetUnusedInputStruct();
sub_800641C(NULL, TRUE, TRUE);
xxx_call_save_unk_text_struct_800641C(NULL, TRUE, TRUE);
sub_80306A8(WONDER_MAIL_TYPE_SOS, 0, NULL, 6);
}
break;
Expand Down Expand Up @@ -921,7 +921,7 @@ void sub_8032828(void)
case 0x1D:
if (sub_8030894() == 0) {
ResetUnusedInputStruct();
sub_800641C(NULL, TRUE, TRUE);
xxx_call_save_unk_text_struct_800641C(NULL, TRUE, TRUE);
sub_80306A8(WONDER_MAIL_TYPE_AOK, 0, NULL, 6);
}
break;
Expand Down Expand Up @@ -1028,7 +1028,7 @@ void sub_8032828(void)
if (sub_8030894() != 0)
break;
ResetUnusedInputStruct();
sub_800641C(NULL, TRUE, TRUE);
xxx_call_save_unk_text_struct_800641C(NULL, TRUE, TRUE);
sub_80306A8(WONDER_MAIL_TYPE_SOS, 0, NULL, 6);
break;
case 0x15:
Expand Down
16 changes: 8 additions & 8 deletions src/move_actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ void sub_8057588(Entity * pokemon, u8 param_2)
entityInfo = pokemon->info;
for(index = 0; index < MAX_MON_MOVES; index++)
{
move = &entityInfo->moves[index];
move = &entityInfo->moves.moves[index];
if ((move->moveFlags & MOVE_FLAG_EXISTS)) {
PPtoRemove = 1;
if ((move->moveFlags2 & MOVE_FLAG_LAST_USED)) {
Expand Down Expand Up @@ -556,7 +556,7 @@ bool8 TormentMoveAction(Entity *pokemon, Entity *target, Move *move, s32 param_4

for(iVar4 = 0; iVar4 < MAX_MON_MOVES; iVar4++)
{
movePtr = &entityInfo->moves[iVar4];
movePtr = &entityInfo->moves.moves[iVar4];
if ((movePtr->moveFlags & MOVE_FLAG_EXISTS) != 0) {
if ((movePtr->moveFlags & MOVE_FLAG_DISABLED) == 0) {
if ((movePtr->moveFlags & MOVE_FLAG_LAST_USED) != 0) {
Expand All @@ -573,18 +573,18 @@ bool8 TormentMoveAction(Entity *pokemon, Entity *target, Move *move, s32 param_4
}
};

if ((entityInfo->struggleMoveFlags & MOVE_FLAG_DISABLED) == 0) {
if ((entityInfo->struggleMoveFlags & MOVE_FLAG_LAST_USED) != 0) {
if ((entityInfo->moves.struggleMoveFlags & MOVE_FLAG_DISABLED) == 0) {
if ((entityInfo->moves.struggleMoveFlags & MOVE_FLAG_LAST_USED) != 0) {
InitPokemonMove(&struggleMove, MOVE_STRUGGLE);
entityInfo->struggleMoveFlags |= MOVE_FLAG_DISABLED;
entityInfo->moves.struggleMoveFlags |= MOVE_FLAG_DISABLED;
isTormented = TRUE;
sub_80928C0(gFormatItems,&struggleMove,0);
// $i0 was tormented
sub_80522F4(pokemon,target,*gUnknown_80FCFBC);
}
}
else if ((entityInfo->struggleMoveFlags & MOVE_FLAG_LAST_USED) == 0) {
entityInfo->struggleMoveFlags &= ~(MOVE_FLAG_DISABLED);
else if ((entityInfo->moves.struggleMoveFlags & MOVE_FLAG_LAST_USED) == 0) {
entityInfo->moves.struggleMoveFlags &= ~(MOVE_FLAG_DISABLED);
}
if (isTormented)
{
Expand Down Expand Up @@ -2321,7 +2321,7 @@ bool8 ConversionMoveAction(Entity * pokemon,Entity * target,Move * move,u32 para
{
for(index = 0; index < MAX_MON_MOVES; index++)
{
movePtr = &info->moves[index];
movePtr = &info->moves.moves[index];
if (((movePtr->moveFlags & MOVE_FLAG_EXISTS)) && (GetMoveTypeForMonster(target,movePtr) != TYPE_NONE)) {
moveStack[counter] = movePtr;
counter++;
Expand Down
Loading

0 comments on commit b68f22e

Please sign in to comment.