summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dungeon_ai.c16
-rw-r--r--src/dungeon_ai_attack.c332
-rw-r--r--src/dungeon_ai_attack_1.c76
-rw-r--r--src/dungeon_ai_item_weight.c4
-rw-r--r--src/dungeon_ai_items.c2
-rw-r--r--src/dungeon_ai_movement.c2
-rw-r--r--src/dungeon_pokemon_attributes.c6
-rw-r--r--src/dungeon_pokemon_attributes_1.c4
-rw-r--r--src/items.c1
-rw-r--r--src/moves.c14
-rw-r--r--src/moves_1.c8
-rw-r--r--src/status_checks.c4
12 files changed, 396 insertions, 73 deletions
diff --git a/src/dungeon_ai.c b/src/dungeon_ai.c
index 5776bfa..263ef16 100644
--- a/src/dungeon_ai.c
+++ b/src/dungeon_ai.c
@@ -7,13 +7,13 @@
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_util.h"
-extern void CheckRunAwayVisualFlag(struct DungeonEntity *, u8 r1);
+extern void CheckRunAwayVisualFlag(struct DungeonEntity *, bool8 showRunAwayEffect);
bool8 ShouldAvoidFirstHit(struct DungeonEntity *pokemon, bool8 forceAvoid)
{
- if(!HasTactic(pokemon, TACTIC_AVOID_THE_FIRST_HIT))
+ if (!HasTactic(pokemon, TACTIC_AVOID_THE_FIRST_HIT))
return FALSE;
- if(!forceAvoid)
+ if (!forceAvoid)
return FALSE;
return TRUE;
}
@@ -43,8 +43,8 @@ bool8 ShouldAvoidEnemies(struct DungeonEntity *pokemon)
return TRUE;
}
}
- if (HasTactic(pokemon, TACTIC_GET_AWAY)
- || (HasTactic(pokemon, TACTIC_AVOID_TROUBLE) && pokemonData->HP <= pokemonData->maxHP / 2))
+ if (HasTactic(pokemon, TACTIC_GET_AWAY) ||
+ (HasTactic(pokemon, TACTIC_AVOID_TROUBLE) && pokemonData->HP <= pokemonData->maxHP / 2))
{
return TRUE;
}
@@ -52,11 +52,11 @@ bool8 ShouldAvoidEnemies(struct DungeonEntity *pokemon)
}
}
-bool8 ShouldAvoidEnemies_2(struct DungeonEntity *pokemon, u8 r1)
+bool8 ShouldAvoidEnemiesAndShowEffect(struct DungeonEntity *pokemon, bool8 showRunAwayEffect)
{
- if(ShouldAvoidEnemies(pokemon))
+ if (ShouldAvoidEnemies(pokemon))
{
- CheckRunAwayVisualFlag(pokemon, r1);
+ CheckRunAwayVisualFlag(pokemon, showRunAwayEffect);
return TRUE;
}
return FALSE;
diff --git a/src/dungeon_ai_attack.c b/src/dungeon_ai_attack.c
index 5794038..e695422 100644
--- a/src/dungeon_ai_attack.c
+++ b/src/dungeon_ai_attack.c
@@ -1,76 +1,322 @@
#include "global.h"
#include "dungeon_ai_attack.h"
+#include "constants/direction.h"
+#include "constants/dungeon_action.h"
#include "constants/iq_skill.h"
-#include "dungeon_global_data.h"
-#include "dungeon_map_access.h"
+#include "constants/move_id.h"
+#include "constants/status.h"
+#include "constants/tactic.h"
+#include "constants/type.h"
+#include "dungeon_action.h"
+#include "dungeon_ai.h"
+#include "dungeon_capabilities_1.h"
+#include "dungeon_pokemon_attributes.h"
#include "dungeon_pokemon_attributes_1.h"
-#include "dungeon_util.h"
+#include "dungeon_random.h"
+#include "dungeon_random_1.h"
+#include "moves.h"
+#include "status_checks.h"
-bool8 IsTargetStraightAhead(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, s32 facingDir, s32 maxRange)
+#define REGULAR_ATTACK_INDEX 4
+
+const s16 gRegularAttackWeights[] = {100, 20, 30, 40, 50};
+
+struct MoveTargetResults
+{
+ bool8 moveUsable;
+ u8 targetDir;
+ s32 moveWeight;
+};
+
+extern bool8 IsChargeMove(struct DungeonEntity*, struct PokemonMove*);
+extern void TargetTileInFront(struct DungeonEntity*);
+extern s32 FindMoveTarget(struct MoveTargetResults*, struct DungeonEntity*, struct PokemonMove*);
+extern bool8 IsMoveUsable(struct DungeonEntity*, s32, bool8);
+extern bool8 TargetRegularAttack(struct DungeonEntity*, u32*, bool8);
+
+void DecideAttack(struct DungeonEntity *pokemon)
{
- s32 posDiffX = pokemon->posWorld.x - targetPokemon->posWorld.x;
- s32 effectiveMaxRange;
- if (posDiffX < 0)
+ struct DungeonEntityData *pokemonData = pokemon->entityData;
+ s32 i;
+ s32 chargeStatus = CHARGING_STATUS_CHARGE;
+ struct MoveTargetResults moveTargetResults[MAX_MON_MOVES + 1];
+ bool8 willNotUnlinkMove[MAX_MON_MOVES];
+ s32 randomWeight;
+ bool8 hasPPChecker;
+ s32 numUsableMoves;
+ s32 total;
+ s32 weightCounter;
+ bool8 hasWeakTypePicker;
+ s32 regularAttackTargetDir;
+ bool8 canTargetRegularAttack;
+ s32 maxWeight;
+ if (CannotAttack(pokemon, FALSE) ||
+ ShouldAvoidEnemiesAndShowEffect(pokemon, TRUE) ||
+ HasTactic(pokemon, TACTIC_KEEP_YOUR_DISTANCE) ||
+ (pokemonData->volatileStatus == VOLATILE_STATUS_CONFUSED && RollPercentChance(gConfusedAttackChance)))
{
- posDiffX = -posDiffX;
+ return;
}
- effectiveMaxRange = pokemon->posWorld.y - targetPokemon->posWorld.y;
- if (effectiveMaxRange < 0)
+ if (pokemonData->chargingStatus != CHARGING_STATUS_NONE)
{
- effectiveMaxRange = -effectiveMaxRange;
+ for (i = 0; i < MAX_MON_MOVES; i++)
+ {
+ if (pokemonData->moves[i].moveFlags & MOVE_FLAG_EXISTS &&
+ IsChargeMove(pokemon, &pokemonData->moves[i]) &&
+ pokemonData->chargingStatusMoveIndex == i)
+ {
+ s32 chosenMoveIndex;
+ SetAction(&pokemonData->action, DUNGEON_ACTION_USE_MOVE_AI);
+ chosenMoveIndex = i;
+ if (i > 0 && pokemonData->moves[i].moveFlags & MOVE_FLAG_LINKED)
+ {
+ while (--chosenMoveIndex > 0)
+ {
+ if (!(pokemonData->moves[chosenMoveIndex].moveFlags & MOVE_FLAG_LINKED))
+ {
+ break;
+ }
+ }
+ }
+ pokemonData->action.actionUseIndex = chosenMoveIndex;
+ TargetTileInFront(pokemon);
+ return;
+ }
+ }
}
- if (effectiveMaxRange < posDiffX)
+ total = 0;
+ numUsableMoves = 0;
+ for (i = 0; i < MAX_MON_MOVES; i++)
{
- effectiveMaxRange = posDiffX;
+ struct PokemonMove *move = &pokemonData->moves[i];
+ if (pokemonData->moves[i].moveFlags & MOVE_FLAG_EXISTS)
+ {
+ if (pokemonData->moves[i].moveFlags & MOVE_FLAG_ENABLED)
+ {
+ numUsableMoves++;
+ }
+ total += move->PP;
+ }
+ }
+ if (total == 0)
+ {
+ struct PokemonMove struggle;
+ InitPokemonMove(&struggle, MOVE_STRUGGLE);
+ FindMoveTarget(&moveTargetResults[0], pokemon, &struggle);
+ if (moveTargetResults[0].moveUsable)
+ {
+ SetAction(&pokemonData->action, DUNGEON_ACTION_STRUGGLE);
+ pokemonData->action.facingDir = moveTargetResults[0].targetDir & DIRECTION_MASK;
+ TargetTileInFront(pokemon);
+ }
+ return;
}
- if (effectiveMaxRange > maxRange)
+ hasWeakTypePicker = HasIQSkill(pokemon, IQ_SKILL_WEAK_TYPE_PICKER);
+ hasPPChecker = HasIQSkill(pokemon, IQ_SKILL_PP_CHECKER) != FALSE;
+ total = 0;
+ for (i = 0; i < MAX_MON_MOVES; i++)
{
- effectiveMaxRange = maxRange;
+ willNotUnlinkMove[i] = TRUE;
}
- if (!HasIQSkill(pokemon, IQ_SKILL_COURSE_CHECKER))
+ if (hasPPChecker)
{
- // BUG: effectiveMaxRange is already capped at maxRange, so this condition always evaluates to TRUE.
- // The AI also has range checks elsewhere, so this doesn't become an issue in most cases.
- // If the AI has the Long Toss or Pierce statuses and Course Checker is disabled,
- // this incorrect check causes the AI to throw items at targets further than 10 tiles away.
- if (effectiveMaxRange <= maxRange)
+ s32 minPP = 99;
+ s32 linkedMoveStartIndex = 0;
+ // Linked moves unlink if any move in the chain runs out of PP.
+ // With PP Checker, the AI avoids this by not using linked moves if any move in the chain has 1 PP left.
+ // This requires a separate check from the 0-PP check used for unlinked moves.
+ for (i = 0; i < MAX_MON_MOVES; i++)
{
- return TRUE;
+ struct PokemonMove *move = &pokemonData->moves[i];
+ if (!(move->moveFlags & MOVE_FLAG_EXISTS))
+ {
+ break;
+ }
+ if (i != 0 && !(move->moveFlags & MOVE_FLAG_LINKED))
+ {
+ if (linkedMoveStartIndex + 1 < i && minPP <= 1 && linkedMoveStartIndex + 1 <= i)
+ {
+ s32 j;
+ for (j = linkedMoveStartIndex; j < i; j++)
+ {
+ willNotUnlinkMove[j] = FALSE;
+ }
+ }
+ minPP = move->PP;
+ linkedMoveStartIndex = i;
+ }
+ else
+ {
+ s32 newMinPP = move->PP;
+ if (newMinPP > minPP)
+ {
+ newMinPP = minPP;
+ }
+ minPP = newMinPP;
+ }
+ }
+ if (linkedMoveStartIndex + 1 < i && minPP <= 1 && linkedMoveStartIndex + 1 <= i)
+ {
+ s32 j;
+ for (j = linkedMoveStartIndex; j < i; j++)
+ {
+ willNotUnlinkMove[j] = FALSE;
+ }
}
}
- else
+ for (i = 0; i < MAX_MON_MOVES; i++)
+ {
+ struct PokemonMove *move;
+ moveTargetResults[i].moveUsable = FALSE;
+ move = &pokemonData->moves[i];
+ if (move->moveFlags & MOVE_FLAG_EXISTS &&
+ willNotUnlinkMove[i] &&
+ IsMoveUsable(pokemon, i, hasPPChecker) &&
+ move->moveFlags & MOVE_FLAG_ENABLED)
+ {
+ moveTargetResults[i].moveUsable = TRUE;
+ if (pokemonData->chargingStatus == chargeStatus)
+ {
+ if (move->moveID == MOVE_CHARGE)
+ {
+ moveTargetResults[i].moveWeight = 0;
+ continue;
+ }
+ else if (GetMoveTypeForPokemon(pokemon, move) == TYPE_ELECTRIC)
+ {
+ moveTargetResults[i].moveWeight = GetMoveWeight(move);
+ }
+ else
+ {
+ moveTargetResults[i].moveWeight = 1;
+ }
+ }
+ else if (hasWeakTypePicker)
+ {
+ struct MoveTargetResults *results = &moveTargetResults[i];
+ results->moveWeight = FindMoveTarget(results, pokemon, move);
+ }
+ else
+ {
+ moveTargetResults[i].moveWeight = GetMoveWeight(move);
+ }
+ total += moveTargetResults[i].moveWeight;
+ }
+ }
+ moveTargetResults[REGULAR_ATTACK_INDEX].moveWeight = 0;
+ if (!HasIQSkill(pokemon, IQ_SKILL_EXCLUSIVE_MOVE_USER) && pokemonData->chargingStatus != chargeStatus)
+ {
+ moveTargetResults[REGULAR_ATTACK_INDEX].moveUsable = TRUE;
+ if (pokemonData->chargingStatus == chargeStatus)
+ {
+ // Never reached? Charge already skips the regular attack in the outer block.
+ moveTargetResults[REGULAR_ATTACK_INDEX].moveWeight = 1;
+ }
+ else if (hasWeakTypePicker)
+ {
+ moveTargetResults[REGULAR_ATTACK_INDEX].moveWeight = 2;
+ }
+ else
+ {
+ moveTargetResults[REGULAR_ATTACK_INDEX].moveWeight = gRegularAttackWeights[numUsableMoves];
+ }
+ total += moveTargetResults[REGULAR_ATTACK_INDEX].moveWeight;
+ }
+ if (hasWeakTypePicker)
{
- s32 currentPosX = pokemon->posWorld.x;
- s32 currentPosY = pokemon->posWorld.y;
- s32 adjacentTileOffsetX = gAdjacentTileOffsets[facingDir].x;
- s32 adjacentTileOffsetY = gAdjacentTileOffsets[facingDir].y;
s32 i;
- for (i = 0; i <= effectiveMaxRange; i++)
+ maxWeight = 0;
+ total = 0;
+ for (i = 0; i < MAX_MON_MOVES + 1; i++)
{
- struct MapTile *mapTile;
- currentPosX += adjacentTileOffsetX;
- currentPosY += adjacentTileOffsetY;
- if (currentPosX <= 0 || currentPosY <= 0 ||
- currentPosX >= DUNGEON_MAX_SIZE_X - 1 || currentPosY >= DUNGEON_MAX_SIZE_Y - 1)
+ if (!moveTargetResults[i].moveUsable)
{
- break;
+ moveTargetResults[i].moveWeight = 0;
}
- while (0); // Extra label needed to swap branch locations in ASM.
- mapTile = GetMapTileAtPosition(currentPosX, currentPosY);
- if (!(mapTile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)))
+ else if (maxWeight < moveTargetResults[i].moveWeight)
{
- break;
+ maxWeight = moveTargetResults[i].moveWeight;
}
- if (mapTile->pokemon == targetPokemon)
+ }
+ for (i = 0; i < MAX_MON_MOVES + 1; i++)
+ {
+ if (moveTargetResults[i].moveUsable)
{
- return TRUE;
+ if (maxWeight != moveTargetResults[i].moveWeight)
+ {
+ moveTargetResults[i].moveWeight = 0;
+ }
+ total += moveTargetResults[i].moveWeight;
}
- if (mapTile->pokemon != NULL)
+ }
+ }
+ if (total == 0)
+ {
+ return;
+ }
+ randomWeight = DungeonRandomCapped(total);
+ weightCounter = 0;
+ if (!HasIQSkill(pokemon, IQ_SKILL_EXCLUSIVE_MOVE_USER))
+ {
+ canTargetRegularAttack = TargetRegularAttack(pokemon, &regularAttackTargetDir, TRUE);
+ }
+ else
+ {
+ canTargetRegularAttack = FALSE;
+ regularAttackTargetDir = DIRECTION_SOUTH;
+ }
+ for (i = 0; i <= REGULAR_ATTACK_INDEX; i++)
+ {
+ if (moveTargetResults[i].moveUsable && moveTargetResults[i].moveWeight != 0)
+ {
+ weightCounter += moveTargetResults[i].moveWeight;
+ if (weightCounter >= randomWeight)
{
- break;
+ if (i == REGULAR_ATTACK_INDEX)
+ {
+ if (canTargetRegularAttack)
+ {
+ SetAction(&pokemonData->action, DUNGEON_ACTION_REGULAR_ATTACK);
+ pokemonData->action.facingDir = regularAttackTargetDir & DIRECTION_MASK;
+ TargetTileInFront(pokemon);
+ }
+ }
+ else
+ {
+ FindMoveTarget(&moveTargetResults[i], pokemon, &pokemonData->moves[i]);
+ if (moveTargetResults[i].moveUsable)
+ {
+ s32 chosenMoveIndex;
+ SetAction(&pokemonData->action, DUNGEON_ACTION_USE_MOVE_AI);
+ chosenMoveIndex = i;
+ if (i > 0 && pokemonData->moves[i].moveFlags & MOVE_FLAG_LINKED)
+ {
+ while (--chosenMoveIndex > 0)
+ {
+ if (!(pokemonData->moves[chosenMoveIndex].moveFlags & MOVE_FLAG_LINKED))
+ {
+ break;
+ }
+ }
+ }
+ pokemonData->action.facingDir = moveTargetResults[i].targetDir & DIRECTION_MASK;
+ pokemonData->action.actionUseIndex = chosenMoveIndex;
+ TargetTileInFront(pokemon);
+ }
+ else
+ {
+ break;
+ }
+ }
+ return;
}
}
}
- return FALSE;
+ if (canTargetRegularAttack)
+ {
+ SetAction(&pokemonData->action, DUNGEON_ACTION_REGULAR_ATTACK);
+ pokemonData->action.facingDir = regularAttackTargetDir & DIRECTION_MASK;
+ TargetTileInFront(pokemon);
+ }
}
diff --git a/src/dungeon_ai_attack_1.c b/src/dungeon_ai_attack_1.c
new file mode 100644
index 0000000..e846b4b
--- /dev/null
+++ b/src/dungeon_ai_attack_1.c
@@ -0,0 +1,76 @@
+#include "global.h"
+#include "dungeon_ai_attack_1.h"
+
+#include "constants/iq_skill.h"
+#include "dungeon_global_data.h"
+#include "dungeon_map_access.h"
+#include "dungeon_pokemon_attributes_1.h"
+#include "dungeon_util.h"
+
+bool8 IsTargetStraightAhead(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, s32 facingDir, s32 maxRange)
+{
+ s32 posDiffX = pokemon->posWorld.x - targetPokemon->posWorld.x;
+ s32 effectiveMaxRange;
+ if (posDiffX < 0)
+ {
+ posDiffX = -posDiffX;
+ }
+ effectiveMaxRange = pokemon->posWorld.y - targetPokemon->posWorld.y;
+ if (effectiveMaxRange < 0)
+ {
+ effectiveMaxRange = -effectiveMaxRange;
+ }
+ if (effectiveMaxRange < posDiffX)
+ {
+ effectiveMaxRange = posDiffX;
+ }
+ if (effectiveMaxRange > maxRange)
+ {
+ effectiveMaxRange = maxRange;
+ }
+ if (!HasIQSkill(pokemon, IQ_SKILL_COURSE_CHECKER))
+ {
+ // BUG: effectiveMaxRange is already capped at maxRange, so this condition always evaluates to TRUE.
+ // The AI also has range checks elsewhere, so this doesn't become an issue in most cases.
+ // If the AI has the Long Toss or Pierce statuses and Course Checker is disabled,
+ // this incorrect check causes the AI to throw items at targets further than 10 tiles away.
+ if (effectiveMaxRange <= maxRange)
+ {
+ return TRUE;
+ }
+ }
+ else
+ {
+ s32 currentPosX = pokemon->posWorld.x;
+ s32 currentPosY = pokemon->posWorld.y;
+ s32 adjacentTileOffsetX = gAdjacentTileOffsets[facingDir].x;
+ s32 adjacentTileOffsetY = gAdjacentTileOffsets[facingDir].y;
+ s32 i;
+ for (i = 0; i <= effectiveMaxRange; i++)
+ {
+ struct MapTile *mapTile;
+ currentPosX += adjacentTileOffsetX;
+ currentPosY += adjacentTileOffsetY;
+ if (currentPosX <= 0 || currentPosY <= 0 ||
+ currentPosX >= DUNGEON_MAX_SIZE_X - 1 || currentPosY >= DUNGEON_MAX_SIZE_Y - 1)
+ {
+ break;
+ }
+ while (0); // Extra label needed to swap branch locations in ASM.
+ mapTile = GetMapTileAtPosition(currentPosX, currentPosY);
+ if (!(mapTile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)))
+ {
+ break;
+ }
+ if (mapTile->pokemon == targetPokemon)
+ {
+ return TRUE;
+ }
+ if (mapTile->pokemon != NULL)
+ {
+ break;
+ }
+ }
+ }
+ return FALSE;
+}
diff --git a/src/dungeon_ai_item_weight.c b/src/dungeon_ai_item_weight.c
index 6c9669b..829bc2d 100644
--- a/src/dungeon_ai_item_weight.c
+++ b/src/dungeon_ai_item_weight.c
@@ -85,11 +85,11 @@ u32 EvaluateItem(struct DungeonEntity *targetPokemon, struct ItemSlot *item, u32
{
if (move->moveFlags & MOVE_FLAG_EXISTS)
{
- if (move->pp == 0)
+ if (move->PP == 0)
{
itemWeight += 30;
}
- if (move->pp != GetMoveMaxPP(move2))
+ if (move->PP != GetMoveMaxPP(move2))
{
itemWeight += 6;
}
diff --git a/src/dungeon_ai_items.c b/src/dungeon_ai_items.c
index d515ebb..2b1bb71 100644
--- a/src/dungeon_ai_items.c
+++ b/src/dungeon_ai_items.c
@@ -7,7 +7,7 @@
#include "constants/targeting.h"
#include "dungeon_action.h"
#include "dungeon_ai_1.h"
-#include "dungeon_ai_attack.h"
+#include "dungeon_ai_attack_1.h"
#include "dungeon_ai_item_weight.h"
#include "dungeon_ai_items.h"
#include "dungeon_capabilities.h"
diff --git a/src/dungeon_ai_movement.c b/src/dungeon_ai_movement.c
index bc109eb..88ed8cb 100644
--- a/src/dungeon_ai_movement.c
+++ b/src/dungeon_ai_movement.c
@@ -8,6 +8,7 @@
#include "constants/targeting.h"
#include "code_80521D0.h"
#include "dungeon_action.h"
+#include "dungeon_ai_attack.h"
#include "dungeon_ai_items.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_global_data.h"
@@ -27,7 +28,6 @@ extern char *gPtrItsaMonsterHouseMessage;
extern void SendImmobilizeEndMessage(struct DungeonEntity*, struct DungeonEntity*);
extern void SetMessageArgument(char[], struct DungeonEntity*, u32);
extern void ResetAction(u16*);
-extern void DecideAttack(struct DungeonEntity*);
extern void MoveIfPossible(struct DungeonEntity*, bool8);
extern u8 sub_8044B28(void);
extern void sub_807AB38(struct DungeonEntity *, u32);
diff --git a/src/dungeon_pokemon_attributes.c b/src/dungeon_pokemon_attributes.c
index c70d4ff..9f01c2b 100644
--- a/src/dungeon_pokemon_attributes.c
+++ b/src/dungeon_pokemon_attributes.c
@@ -51,7 +51,7 @@ bool8 sub_80717A4(struct DungeonEntity *param_1, u16 moveID)
{
struct DungeonEntityData * entityData;
s32 iVar3;
-
+
entityData = param_1->entityData;
if ((entityData->sleepStatus != SLEEP_STATUS_SLEEP) && (entityData->sleepStatus != SLEEP_STATUS_NAPPING) && (entityData->sleepStatus != SLEEP_STATUS_NIGHTMARE)) {
return FALSE;
@@ -66,10 +66,10 @@ bool8 sub_80717A4(struct DungeonEntity *param_1, u16 moveID)
for(iVar3 = 0, pokeMove = entityData->moves, pokeMove2 = pokeMove; iVar3 < MAX_MON_MOVES; pokeMove++, pokeMove2++, iVar3++)
{
if (((pokeMove->moveFlags & MOVE_FLAG_EXISTS) != 0) && (entityData->isLeader || ((pokeMove->moveFlags & MOVE_FLAG_ENABLED) != 0)))
- if((sub_805744C(param_1, pokeMove2, 1) != '\0') && (pokeMove->pp != 0))
+ if((sub_805744C(param_1, pokeMove2, 1) != '\0') && (pokeMove->PP != 0))
if(pokeMove->moveID == moveID)
return TRUE;
- }
+ }
return FALSE;
}
}
diff --git a/src/dungeon_pokemon_attributes_1.c b/src/dungeon_pokemon_attributes_1.c
index 93d8d4a..c7d3a13 100644
--- a/src/dungeon_pokemon_attributes_1.c
+++ b/src/dungeon_pokemon_attributes_1.c
@@ -113,9 +113,9 @@ bool8 CanSeeTeammate(struct DungeonEntity * pokemon)
}
}
-u8 GetMoveType_2(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove)
+u8 GetMoveTypeForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove)
{
- if(pokeMove->moveID == MOVE_HIDDEN_POWER)
+ if (pokeMove->moveID == MOVE_HIDDEN_POWER)
return pokemon->entityData->hiddenPowerType;
else
return GetMoveType(pokeMove);
diff --git a/src/items.c b/src/items.c
index a19b71b..999fd7d 100644
--- a/src/items.c
+++ b/src/items.c
@@ -39,7 +39,6 @@ extern void ExpandPlaceholdersBuffer(u8 *, const u8 *, ...);
extern s32 sub_8090FEC(s32 a1, u8* a2, u8 a3);
extern void sub_80073B8(u32);
extern u32 sub_8097DF0(char *, struct subStruct_203B240 **);
-extern void InitPokemonMove(void*, u16); // first arg is some struct
extern void sub_80078A4(u32, u32, u32, u32, u32);
extern u32 GetMoveType(void*);
extern u8* GetUnformattedTypeString(s16);
diff --git a/src/moves.c b/src/moves.c
index f2e334c..54927d8 100644
--- a/src/moves.c
+++ b/src/moves.c
@@ -99,7 +99,7 @@ void sub_80928C0(u8 *buffer, struct PokemonMove *move, struct unkStruct_80928C0
ExpandPlaceholdersBuffer
(buffer,gUnknown_81098EC,uVar2,move->moveFlags & MOVE_FLAG_SET ? gUnknown_8109908 : gUnknown_810990C,
gMovesData[move->moveID].namePointer,localBuffer,param_3->unk4,
- move->pp,maxPP);
+ move->PP,maxPP);
break;
case 2:
@@ -107,7 +107,7 @@ void sub_80928C0(u8 *buffer, struct PokemonMove *move, struct unkStruct_80928C0
ExpandPlaceholdersBuffer
(buffer,gUnknown_8109910,uVar2,move->moveFlags & MOVE_FLAG_SET ? gUnknown_8109908 : gUnknown_810990C,
gMovesData[move->moveID].namePointer,localBuffer,param_3->unk4,
- move->pp,maxPP);
+ move->PP,maxPP);
break;
case 3:
@@ -115,7 +115,7 @@ void sub_80928C0(u8 *buffer, struct PokemonMove *move, struct unkStruct_80928C0
ExpandPlaceholdersBuffer
(buffer,gUnknown_81098EC,uVar2,move->moveFlags & MOVE_FLAG_ENABLED ? gUnknown_8109928 : gUnknown_810990C,
gMovesData[move->moveID].namePointer,localBuffer,param_3->unk4,
- move->pp,maxPP);
+ move->PP,maxPP);
break;
case 4:
@@ -123,7 +123,7 @@ void sub_80928C0(u8 *buffer, struct PokemonMove *move, struct unkStruct_80928C0
ExpandPlaceholdersBuffer
(buffer,gUnknown_8109910,uVar2, move->moveFlags & MOVE_FLAG_ENABLED ? gUnknown_8109928 : gUnknown_810990C,
gMovesData[move->moveID].namePointer,localBuffer,param_3->unk4,
- move->pp,maxPP);
+ move->PP,maxPP);
break;
}
}
@@ -133,7 +133,7 @@ void InitPokemonMove(struct PokemonMove *move, u16 moveID)
move->moveFlags = MOVE_FLAG_ENABLED | MOVE_FLAG_EXISTS;
move->sealed = FALSE;
move->moveID = moveID;
- move->pp = GetMoveMaxPP(move);
+ move->PP = GetMoveMaxPP(move);
move->powerBoost = 0;
}
@@ -146,7 +146,7 @@ void sub_8092AA8(struct PokemonMove *move, u16 moveID)
move->moveFlags = MOVE_FLAG_ENABLED | MOVE_FLAG_EXISTS;
move->sealed = FALSE;
move->moveID = moveID;
- move->pp = GetMoveMaxPP(move);
+ move->PP = GetMoveMaxPP(move);
move->powerBoost = 0;
}
}
@@ -155,7 +155,7 @@ void InitZeroedPPPokemonMove(struct PokemonMove *move, u16 moveID)
{
move->moveFlags = MOVE_FLAG_ENABLED | MOVE_FLAG_EXISTS;
move->moveID = moveID;
- move->pp = 0;
+ move->PP = 0;
}
s16 GetMoveTargetingFlags(struct PokemonMove *move, u32 r1)
diff --git a/src/moves_1.c b/src/moves_1.c
index db84d41..5a7bf6b 100644
--- a/src/moves_1.c
+++ b/src/moves_1.c
@@ -7,14 +7,14 @@ void SavePokemonMove(struct unkStruct_8094924 *r0, struct PokemonMove *move)
{
SaveIntegerBits(r0, &move->moveFlags, 4);
SaveIntegerBits(r0, &move->moveID, 9);
- SaveIntegerBits(r0, &move->pp, 7);
+ SaveIntegerBits(r0, &move->PP, 7);
}
void RestorePokemonMove(struct unkStruct_8094924 *r0, struct PokemonMove *move)
{
RestoreIntegerBits(r0, &move->moveFlags, 4);
RestoreIntegerBits(r0, &move->moveID, 9);
- RestoreIntegerBits(r0, &move->pp, 7);
+ RestoreIntegerBits(r0, &move->PP, 7);
}
void SavePokemonMoves(struct unkStruct_8094924 *r0, struct PokemonMove *moveSet)
@@ -40,7 +40,7 @@ void sub_8094148(struct unkStruct_8094924 *r0, struct PokemonMove *move)
SaveIntegerBits(r0, &move->moveFlags, 4);
SaveIntegerBits(r0, &move->sealed, 1);
SaveIntegerBits(r0, &move->moveID, 9);
- SaveIntegerBits(r0, &move->pp, 7);
+ SaveIntegerBits(r0, &move->PP, 7);
SaveIntegerBits(r0, &move->powerBoost, 7);
}
@@ -61,7 +61,7 @@ void sub_80941B0(struct unkStruct_8094924 *r0, struct PokemonMove *move)
RestoreIntegerBits(r0, &move->moveFlags, 4);
RestoreIntegerBits(r0, &move->sealed, 1);
RestoreIntegerBits(r0, &move->moveID, 9);
- RestoreIntegerBits(r0, &move->pp, 7);
+ RestoreIntegerBits(r0, &move->PP, 7);
RestoreIntegerBits(r0, &move->powerBoost, 7);
}
diff --git a/src/status_checks.c b/src/status_checks.c
index b371934..12889b5 100644
--- a/src/status_checks.c
+++ b/src/status_checks.c
@@ -6,9 +6,12 @@
#include "constants/status.h"
#include "code_80521D0.h"
#include "dungeon_action.h"
+#include "dungeon_ai_attack.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_random.h"
+const s16 gConfusedAttackChance = 70;
+
extern char *gPtrFrozenMessage;
extern char *gPtrWrappedAroundMessage;
extern char *gPtrWrappedByMessage;
@@ -18,7 +21,6 @@ extern char *gPtrInfatuatedMessage;
extern char gAvailablePokemonNames[];
extern void SetMessageArgument(char[], struct DungeonEntity*, u32);
-extern void DecideAttack(struct DungeonEntity*);
bool8 HasStatusAffectingActions(struct DungeonEntity *pokemon)
{