Decomped EvaluateItem()

This commit is contained in:
AnonymousRandomPerson
2022-01-04 00:00:31 -06:00
parent a61f7ea2a1
commit c30cf5c6da
12 changed files with 537 additions and 652 deletions

View File

@@ -1310,638 +1310,4 @@ sub_8048F00:
_08048F24: .4byte gPtrMusicBoxPlayedCrumbledMessage
thumb_func_end sub_8048F00
thumb_func_start EvaluateItem
EvaluateItem:
push {r4-r7,lr}
sub sp, 0x4
adds r4, r0, 0
ldr r3, [r4, 0x70]
movs r6, 0
movs r0, 0x1
adds r5, r2, 0
ands r5, r0
lsrs r2, 1
movs r0, 0x1
ands r2, r0
ldrb r0, [r1, 0x2]
subs r0, 0x1
cmp r0, 0xCC
bls _08048F48
b _080494E0
_08048F48:
lsls r0, 2
ldr r1, _08048F54
adds r0, r1
ldr r0, [r0]
mov pc, r0
.align 2, 0
_08048F54: .4byte _08048F58
.align 2, 0
_08048F58:
.4byte _0804928C
.4byte _0804928C
.4byte _0804928C
.4byte _0804928C
.4byte _0804928C
.4byte _0804928C
.4byte _0804928C
.4byte _0804928C
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _08049408
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _08049296
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080492B0
.4byte _080492B0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _08049320
.4byte _080494E0
.4byte _080492B8
.4byte _080492B8
.4byte _0804935E
.4byte _080494E0
.4byte _080493E0
.4byte _0804948E
.4byte _08049394
.4byte _08049344
.4byte _0804946E
.4byte _0804947A
.4byte _08049378
.4byte _080493CE
.4byte _080493AC
.4byte _080493B8
.4byte _08049436
.4byte _080494E0
.4byte _080493F6
.4byte _080494B2
.4byte _0804946A
.4byte _08049462
.4byte _08049454
.4byte _08049498
.4byte _080492DC
.4byte _0804932C
.4byte _08049338
.4byte _0804933C
.4byte _08049340
.4byte _080494C2
.4byte _080494C2
.4byte _080494D6
.4byte _080494C2
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494E0
.4byte _080494DA
_0804928C:
cmp r5, 0
bne _08049292
b _080494E2
_08049292:
movs r6, 0x46
b _080494E2
_08049296:
cmp r5, 0
bne _0804929C
b _080494E0
_0804929C:
movs r1, 0x9E
lsls r1, 1
adds r0, r3, r1
ldr r0, [r0]
bl GetBellyRoundedUp
cmp r0, 0
ble _080492AE
b _0804948A
_080492AE:
b _080494E0
_080492B0:
cmp r5, 0
beq _080492B6
b _0804948A
_080492B6:
b _080494E0
_080492B8:
movs r2, 0xE
ldrsh r1, [r3, r2]
movs r2, 0x10
ldrsh r0, [r3, r2]
cmp r1, r0
blt _080492C6
b _080494E2
_080492C6:
cmp r0, 0
bge _080492CC
adds r0, 0x3
_080492CC:
asrs r0, 2
cmp r1, r0
ble _080492D4
b _080494E2
_080492D4:
cmp r5, 0
bne _080492DA
b _08049420
_080492DA:
b _08049432
_080492DC:
movs r6, 0
movs r0, 0x8C
lsls r0, 1
adds r5, r3, r0
adds r7, r5, 0
movs r2, 0x3
_080492E8:
ldrb r1, [r5]
movs r0, 0x1
ands r0, r1
cmp r0, 0
beq _0804930C
ldrb r0, [r5, 0x4]
cmp r0, 0
bne _080492FA
adds r6, 0x1E
_080492FA:
ldrb r4, [r5, 0x4]
adds r0, r7, 0
str r2, [sp]
bl GetMoveMaxPP
ldr r2, [sp]
cmp r4, r0
beq _0804930C
adds r6, 0x6
_0804930C:
adds r5, 0x8
adds r7, 0x8
subs r2, 0x1
cmp r2, 0
bge _080492E8
cmp r6, 0x62
bgt _0804931C
b _080494E2
_0804931C:
movs r6, 0x63
b _080494E2
_08049320:
adds r0, r4, 0
bl HasNegativeStatus
lsls r0, 24
movs r6, 0
b _080494BC
_0804932C:
ldrb r0, [r3, 0x14]
_0804932E:
movs r6, 0x64
cmp r0, 0xF9
bhi _08049336
b _080494E2
_08049336:
b _080494E0
_08049338:
ldrb r0, [r3, 0x15]
b _0804932E
_0804933C:
ldrb r0, [r3, 0x16]
b _0804932E
_08049340:
ldrb r0, [r3, 0x17]
b _0804932E
_08049344:
cmp r5, 0
beq _0804934A
b _080494E0
_0804934A:
adds r0, r4, 0
bl CanTargetAdjacentPokemon
lsls r0, 24
movs r6, 0x64
cmp r0, 0
bne _0804935A
b _080494E2
_0804935A:
movs r6, 0xA
b _080494E2
_0804935E:
adds r0, r4, 0
bl CanSeeInvisible
lsls r0, 24
cmp r0, 0
beq _0804936C
b _080494A2
_0804936C:
adds r0, r4, 0
bl CanTargetAdjacentPokemon
lsls r0, 24
movs r6, 0x5
b _080494BC
_08049378:
ldr r0, [r4, 0x70]
movs r1, 0x82
lsls r1, 1
adds r0, r1
ldr r0, [r0]
cmp r0, 0x3
ble _08049388
b _080494A2
_08049388:
adds r0, r4, 0
bl CanTargetAdjacentPokemon
lsls r0, 24
movs r6, 0x5
b _080494BC
_08049394:
adds r0, r3, 0
adds r0, 0xE8
ldrb r0, [r0]
cmp r0, 0x2
bne _080493A0
b _080494A2
_080493A0:
adds r0, r4, 0
bl CanTargetAdjacentPokemon
lsls r0, 24
movs r6, 0x5
b _080494BC
_080493AC:
adds r0, r3, 0
adds r0, 0xAC
ldrb r0, [r0]
cmp r0, 0x4
bne _080494A2
b _080494B2
_080493B8:
adds r0, r3, 0
adds r0, 0xBC
ldrb r0, [r0]
cmp r0, 0x2
beq _080494A2
adds r0, r4, 0
bl CanTargetAdjacentPokemon
lsls r0, 24
movs r6, 0xF
b _080494BC
_080493CE:
adds r0, r3, 0
adds r0, 0xAC
ldrb r0, [r0]
subs r0, 0x2
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bhi _080494A2
b _08049420
_080493E0:
adds r0, r3, 0
adds r0, 0xE8
ldrb r0, [r0]
cmp r0, 0x1
beq _080494A2
adds r0, r4, 0
bl CanTargetAdjacentPokemon
lsls r0, 24
movs r6, 0x5
b _080494BC
_080493F6:
cmp r2, 0
bne _0804940C
adds r0, r4, 0
bl CanTargetAdjacentPokemon
lsls r0, 24
movs r6, 0x5
cmp r0, 0
beq _080494E2
_08049408:
movs r6, 0x28
b _080494E2
_0804940C:
movs r2, 0xE
ldrsh r1, [r3, r2]
movs r2, 0x10
ldrsh r0, [r3, r2]
cmp r1, r0
bge _080494E2
cmp r1, 0x13
bgt _080494E2
cmp r5, 0
bne _08049432
_08049420:
adds r0, r4, 0
bl CanTargetAdjacentPokemon
lsls r0, 24
movs r6, 0x32
cmp r0, 0
beq _080494E2
movs r6, 0x64
b _080494E2
_08049432:
movs r6, 0x32
b _080494E2
_08049436:
adds r0, r3, 0
adds r0, 0xA8
ldrb r0, [r0]
cmp r0, 0x1
beq _080494A2
cmp r0, 0x5
beq _080494A2
cmp r0, 0x3
beq _080494A2
adds r0, r4, 0
bl CanTargetAdjacentPokemon
lsls r0, 24
movs r6, 0x5
b _080494BC
_08049454:
adds r0, r3, 0
adds r0, 0xA8
ldrb r0, [r0]
cmp r0, 0x2
beq _080494A2
movs r6, 0x5
b _080494E2
_08049462:
ldrb r0, [r3, 0x9]
movs r6, 0
cmp r0, 0x62
bhi _080494E2
_0804946A:
movs r6, 0x50
b _080494E2
_0804946E:
adds r0, r3, 0
adds r0, 0xAC
ldrb r0, [r0]
cmp r0, 0x1
beq _0804948A
b _080494E0
_0804947A:
movs r1, 0x9E
lsls r1, 1
adds r0, r3, r1
ldr r0, [r0]
bl GetBellyRoundedUp
cmp r0, 0
ble _080494E0
_0804948A:
movs r0, 0x32
b _080494E4
_0804948E:
ldrb r0, [r3, 0x9]
movs r6, 0
cmp r0, 0x1
bls _080494E2
b _0804946A
_08049498:
adds r0, r3, 0
adds r0, 0xB0
ldrb r0, [r0]
cmp r0, 0x6
bne _080494A6
_080494A2:
movs r0, 0
b _080494E4
_080494A6:
adds r0, r4, 0
bl CanTargetAdjacentPokemon
lsls r0, 24
movs r6, 0x5
b _080494BC
_080494B2:
adds r0, r4, 0
bl CanTargetAdjacentPokemon
lsls r0, 24
movs r6, 0x1E
_080494BC:
cmp r0, 0
beq _080494E2
b _0804946A
_080494C2:
movs r2, 0x9E
lsls r2, 1
adds r0, r3, r2
ldr r0, [r0]
bl GetBellyRoundedUp
cmp r0, 0x9
bgt _080494E0
movs r0, 0x64
b _080494E4
_080494D6:
movs r6, 0x1E
b _080494E2
_080494DA:
movs r6, 0x14
cmp r5, 0
beq _080494E2
_080494E0:
movs r6, 0
_080494E2:
adds r0, r6, 0
_080494E4:
add sp, 0x4
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end EvaluateItem
thumb_func_start CanTargetAdjacentPokemon
CanTargetAdjacentPokemon:
push {r4-r6,lr}
adds r5, r0, 0
movs r6, 0
_080494F2:
movs r1, 0x4
ldrsh r0, [r5, r1]
ldr r1, _08049538
lsls r2, r6, 2
adds r2, r1
movs r3, 0
ldrsh r1, [r2, r3]
adds r0, r1
movs r3, 0x6
ldrsh r1, [r5, r3]
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
ldr r4, [r0, 0x10]
cmp r4, 0
beq _0804953C
adds r0, r4, 0
bl GetEntityType
cmp r0, 0
beq _0804953C
adds r0, r5, 0
adds r1, r4, 0
movs r2, 0
movs r3, 0x1
bl CanTarget
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _0804953C
movs r0, 0x1
b _08049544
.align 2, 0
_08049538: .4byte gAdjacentTileOffsets
_0804953C:
adds r6, 0x1
cmp r6, 0x7
ble _080494F2
movs r0, 0
_08049544:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end CanTargetAdjacentPokemon
.align 2, 0

59
asm/code_80494EC.s Normal file
View File

@@ -0,0 +1,59 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start CanTargetAdjacentPokemon
CanTargetAdjacentPokemon:
push {r4-r6,lr}
adds r5, r0, 0
movs r6, 0
_080494F2:
movs r1, 0x4
ldrsh r0, [r5, r1]
ldr r1, _08049538
lsls r2, r6, 2
adds r2, r1
movs r3, 0
ldrsh r1, [r2, r3]
adds r0, r1
movs r3, 0x6
ldrsh r1, [r5, r3]
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
ldr r4, [r0, 0x10]
cmp r4, 0
beq _0804953C
adds r0, r4, 0
bl GetEntityType
cmp r0, 0
beq _0804953C
adds r0, r5, 0
adds r1, r4, 0
movs r2, 0
movs r3, 0x1
bl CanTarget
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _0804953C
movs r0, 0x1
b _08049544
.align 2, 0
_08049538: .4byte gAdjacentTileOffsets
_0804953C:
adds r6, 0x1
cmp r6, 0x7
ble _080494F2
movs r0, 0
_08049544:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end CanTargetAdjacentPokemon
.align 2, 0

View File

@@ -162,18 +162,18 @@
#define ITEM_ID_CALM_MIND 0x80
#define ITEM_ID_ROAR 0x81
#define ITEM_ID_TOXIC 0x82
#define ITEM_ID_HAIL_ORB 0x83
#define ITEM_ID_HAIL 0x83
#define ITEM_ID_BULK_UP 0x84
#define ITEM_ID_BULLET_SEED 0x85
#define ITEM_ID_HIDDEN_POWER 0x86
#define ITEM_ID_SUNNY_ORB 0x87
#define ITEM_ID_SUNNY_DAY 0x87
#define ITEM_ID_TAUNT 0x88
#define ITEM_ID_ICE_BEAM 0x89
#define ITEM_ID_BLIZZARD 0x8A
#define ITEM_ID_HYPER_BEAM 0x8B
#define ITEM_ID_LIGHT_SCREEN 0x8C
#define ITEM_ID_PROTECT 0x8D
#define ITEM_ID_RAINY_ORB 0x8E
#define ITEM_ID_RAIN_DANCE 0x8E
#define ITEM_ID_GIGA_DRAIN 0x8F
#define ITEM_ID_SAFEGUARD 0x90
#define ITEM_ID_FRUSTRATION 0x91
@@ -187,14 +187,14 @@
#define ITEM_ID_PSYCHIC 0x99
#define ITEM_ID_SHADOW_BALL 0x9A
#define ITEM_ID_BRICK_BREAK 0x9B
#define ITEM_ID_EVASION_ORB 0x9C
#define ITEM_ID_DOUBLE_TEAM 0x9C
#define ITEM_ID_REFLECT 0x9D
#define ITEM_ID_SHOCK_WAVE 0x9E
#define ITEM_ID_FLAMETHROWER 0x9F
#define ITEM_ID_SLUDGE_BOMB 0xA0
#define ITEM_ID_SANDY_ORB 0xA1
#define ITEM_ID_SANDSTORM 0xA1
#define ITEM_ID_FIRE_BLAST 0xA2
#define ITEM_ID_ROCKY_ORB 0xA3
#define ITEM_ID_ROCK_TOMB 0xA3
#define ITEM_ID_AERIAL_ACE 0xA4
#define ITEM_ID_TORMENT 0xA5
#define ITEM_ID_FACADE 0xA6
@@ -204,7 +204,7 @@
#define ITEM_ID_THIEF 0xAA
#define ITEM_ID_STEEL_WING 0xAB
#define ITEM_ID_SKILL_SWAP 0xAC
#define ITEM_ID_SNATCH_ORB 0xAD
#define ITEM_ID_SNATCH 0xAD
#define ITEM_ID_OVERHEAT 0xAE
#define ITEM_ID_WIDE_SLASH 0xAF
#define ITEM_ID_EXCAVATE 0xB0

View File

@@ -0,0 +1,9 @@
#ifndef GUARD_DUNGEON_AI_ITEM_WEIGHT_H
#define GUARD_DUNGEON_AI_ITEM_WEIGHT_H
#include "dungeon_entity.h"
// 0x48F28
u32 EvaluateItem(struct DungeonEntity *targetPokemon, struct ItemSlot *item, u32 itemTargetFlags);
#endif

View File

@@ -164,8 +164,7 @@ struct DungeonEntityData
u8 fillFE[0x100 - 0xFE];
/* 0x100 */ u8 targetingDecoy; // If the Pokémon is targeting a decoy, this indicates whether the decoy target is a team or wild Pokémon.
u8 fill101[0x104 - 0x101];
/* 0x104 */ u8 movementSpeed;
u8 fill105[0x108 - 0x105];
/* 0x104 */ s32 movementSpeed;
// The turn counter for movement speed up/down is split into five timers each. Multiple timers are used if the Pokémon is affected by multiple
// speed-up/slow effects at once, like using Agility twice.
/* 0x108 */ u8 speedUpTurnsLeft[5];

8
include/moves.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef GUARD_MOVES_H
#define GUARD_MOVES_H
#include "constants/move.h"
u32 GetMoveMaxPP(struct PokemonMove *move);
#endif

View File

@@ -196,6 +196,8 @@ SECTIONS {
asm/code_8046CE4.o(.text);
src/code_8048480.o(.text);
asm/code_8048480.o(.text);
src/dungeon_ai_item_weight.o(.text);
asm/code_80494EC.o(.text);
src/dungeon_map_access.o(.text);
asm/code_8049590.o(.text);
src/code_80521D0.o(.text);

View File

@@ -0,0 +1,442 @@
#include "global.h"
#include "dungeon_ai_item_weight.h"
#include "constants/status.h"
#include "dungeon_pokemon_attributes_1.h"
#include "moves.h"
extern s32 GetBellyRoundedUp(u32);
extern bool8 CanTargetAdjacentPokemon(struct DungeonEntity*);
extern bool8 HasNegativeStatus(struct DungeonEntity*);
u32 EvaluateItem(struct DungeonEntity *targetPokemon, struct ItemSlot *item, u32 itemTargetFlags)
{
struct DungeonEntityData *pokemonData = targetPokemon->entityData;
s32 itemWeight = 0;
bool8 targetOther = itemTargetFlags & 1;
u16 targetAlly = (itemTargetFlags >> 1) & 1;
s32 i;
struct PokemonMove *move;
struct PokemonMove *move2;
switch (item->itemIndex)
{
case ITEM_ID_STICK:
case ITEM_ID_IRON_THORN:
case ITEM_ID_SILVER_SPIKE:
case ITEM_ID_GOLD_FANG:
case ITEM_ID_CACNEA_SPIKE:
case ITEM_ID_CORSOLA_TWIG:
case ITEM_ID_GRAVELEROCK:
case ITEM_ID_GEO_PEBBLE:
if (targetOther)
{
itemWeight = 70;
}
break;
case ITEM_ID_DIET_RIBBON:
if (targetOther && GetBellyRoundedUp(pokemonData->belly) > 0)
{
return 50;
}
else
{
itemWeight = 0;
}
break;
case ITEM_ID_WHIFF_SPECS:
case ITEM_ID_NO_AIM_SCOPE:
if (targetOther)
{
return 50;
}
else
{
itemWeight = 0;
}
break;
case ITEM_ID_ORAN_BERRY:
case ITEM_ID_SITRUS_BERRY:
if (pokemonData->HP < pokemonData->maxHP && pokemonData->HP <= pokemonData->maxHP / 4)
{
if (!targetOther)
{
if (CanTargetAdjacentPokemon(targetPokemon))
{
itemWeight = 100;
}
else
{
itemWeight = 50;
}
}
else
{
itemWeight = 50;
}
}
break;
case ITEM_ID_MAX_ELIXIR:
itemWeight = 0;
move = pokemonData->moves;
move2 = move;
for (i = 0; i < MAX_MON_MOVES; move++, move2++, i++)
{
if (move->moveFlags & MOVE_FLAG_EXISTS)
{
if (move->pp == 0)
{
itemWeight += 30;
}
if (move->pp != GetMoveMaxPP(move2))
{
itemWeight += 6;
}
}
}
if (itemWeight > 98)
{
itemWeight = 99;
}
break;
case ITEM_ID_HEAL_SEED:
if (HasNegativeStatus(targetPokemon))
{
itemWeight = 80;
}
else
{
itemWeight = 0;
}
break;
case ITEM_ID_PROTEIN:
if (pokemonData->attack > 249)
{
itemWeight = 0;
}
else
{
itemWeight = 100;
}
break;
case ITEM_ID_CALCIUM:
if (pokemonData->specialAttack > 249)
{
itemWeight = 0;
}
else
{
itemWeight = 100;
}
break;
case ITEM_ID_IRON:
if (pokemonData->defense > 249)
{
itemWeight = 0;
}
else
{
itemWeight = 100;
}
break;
case ITEM_ID_ZINC:
if (pokemonData->specialDefense > 249)
{
itemWeight = 0;
}
else
{
itemWeight = 100;
}
break;
case ITEM_ID_LIFE_SEED:
if (!targetOther)
{
if (CanTargetAdjacentPokemon(targetPokemon))
{
itemWeight = 10;
}
else
{
itemWeight = 100;
}
}
else
{
itemWeight = 0;
}
break;
case ITEM_ID_EYEDROP_SEED:
if (!CanSeeInvisible(targetPokemon))
{
if (CanTargetAdjacentPokemon(targetPokemon))
{
itemWeight = 80;
}
else
{
itemWeight = 5;
}
}
else
{
return 0;
}
break;
case ITEM_ID_QUICK_SEED:
if (targetPokemon->entityData->movementSpeed <= 3)
{
if (CanTargetAdjacentPokemon(targetPokemon))
{
itemWeight = 80;
}
else
{
itemWeight = 5;
}
}
else
{
return 0;
}
break;
case ITEM_ID_ALLURE_SEED:
if (pokemonData->eyesightStatus != EYESIGHT_STATUS_CROSS_EYED)
{
if (CanTargetAdjacentPokemon(targetPokemon))
{
itemWeight = 80;
}
else
{
itemWeight = 5;
}
}
else
{
return 0;
}
break;
case ITEM_ID_CHERI_BERRY:
if (pokemonData->nonVolatileStatus != NON_VOLATILE_STATUS_PARALYZED)
{
return 0;
}
else if (CanTargetAdjacentPokemon(targetPokemon))
{
itemWeight = 80;
}
else
{
itemWeight = 30;
}
break;
case ITEM_ID_TOTTER_SEED:
if (pokemonData->volatileStatus != VOLATILE_STATUS_CONFUSED)
{
if (CanTargetAdjacentPokemon(targetPokemon))
{
itemWeight = 80;
}
else
{
itemWeight = 15;
}
}
else
{
return 0;
}
break;
case ITEM_ID_PECHA_BERRY:
if (pokemonData->nonVolatileStatus != NON_VOLATILE_STATUS_POISONED &&
pokemonData->nonVolatileStatus != NON_VOLATILE_STATUS_BADLY_POISONED)
{
return 0;
}
else if (CanTargetAdjacentPokemon(targetPokemon))
{
itemWeight = 100;
}
else
{
itemWeight = 50;
}
break;
case ITEM_ID_BLINKER_SEED:
if (pokemonData->eyesightStatus != EYESIGHT_STATUS_BLINKER)
{
if (CanTargetAdjacentPokemon(targetPokemon))
{
itemWeight = 80;
}
else
{
itemWeight = 5;
}
}
else
{
return 0;
}
break;
case ITEM_ID_WARP_SEED:
if (!targetAlly)
{
if (CanTargetAdjacentPokemon(targetPokemon))
{
itemWeight = 40;
}
else
{
itemWeight = 5;
}
}
else if (pokemonData->HP < pokemonData->maxHP && pokemonData->HP < 20)
{
if (!targetOther)
{
if (CanTargetAdjacentPokemon(targetPokemon))
{
itemWeight = 100;
}
else
{
itemWeight = 50;
}
}
else
{
itemWeight = 50;
}
}
break;
case ITEM_ID_PATSY_BAND:
itemWeight = 40;
break;
case ITEM_ID_SLEEP_SEED:
if (pokemonData->sleepStatus != SLEEP_STATUS_SLEEP &&
pokemonData->sleepStatus != SLEEP_STATUS_NAPPING &&
pokemonData->sleepStatus != SLEEP_STATUS_NIGHTMARE)
{
if (CanTargetAdjacentPokemon(targetPokemon))
{
itemWeight = 80;
}
else
{
itemWeight = 5;
}
}
else
{
return 0;
}
break;
case ITEM_ID_CHESTO_BERRY:
if (pokemonData->sleepStatus != SLEEP_STATUS_SLEEPLESS)
{
itemWeight = 5;
}
else
{
return 0;
}
break;
case ITEM_ID_JOY_SEED:
if (pokemonData->level < 99)
{
itemWeight = 80;
}
else
{
itemWeight = 0;
}
break;
case ITEM_ID_GINSENG:
itemWeight = 80;
break;
case ITEM_ID_RAWST_BERRY:
if (pokemonData->nonVolatileStatus == NON_VOLATILE_STATUS_BURNED)
{
return 50;
}
else
{
itemWeight = 0;
}
break;
case ITEM_ID_HUNGER_SEED:
if (GetBellyRoundedUp(pokemonData->belly) > 0)
{
return 50;
}
else
{
itemWeight = 0;
}
break;
case ITEM_ID_DOOM_SEED:
if (pokemonData->level > 1)
{
itemWeight = 80;
}
else
{
itemWeight = 0;
}
break;
case ITEM_ID_STUN_SEED:
if (pokemonData->immobilizeStatus == IMMOBILIZE_STATUS_PETRIFIED)
{
return 0;
}
else if (CanTargetAdjacentPokemon(targetPokemon))
{
itemWeight = 80;
}
else
{
itemWeight = 5;
}
break;
case ITEM_ID_BLAST_SEED:
if (CanTargetAdjacentPokemon(targetPokemon))
{
itemWeight = 80;
}
else
{
itemWeight = 30;
}
break;
case ITEM_ID_APPLE:
case ITEM_ID_BIG_APPLE:
case ITEM_ID_HUGE_APPLE:
if (GetBellyRoundedUp(pokemonData->belly) < 10)
{
return 100;
}
else
{
itemWeight = 0;
}
break;
case ITEM_ID_GRIMY_FOOD:
itemWeight = 30;
break;
case ITEM_ID_ROLLCALL_ORB:
move = pokemonData->moves; // Fixes a regswap.
if (targetOther)
{
itemWeight = 0;
}
else
{
itemWeight = 20;
}
break;
default:
itemWeight = 0;
}
return itemWeight;
}

View File

@@ -8,6 +8,7 @@
#include "dungeon_action.h"
#include "dungeon_ai_1.h"
#include "dungeon_ai_attack.h"
#include "dungeon_ai_item_weight.h"
#include "dungeon_ai_items.h"
#include "dungeon_capabilities.h"
#include "dungeon_capabilities_1.h"
@@ -35,7 +36,6 @@ enum ItemTargetFlag
};
extern s32 CalculateFacingDir(struct Position*, struct Position*);
extern u32 EvaluateItem(struct DungeonEntity*, struct ItemSlot*, u32);
extern void sub_8077274(struct DungeonEntity *, struct DungeonEntity *);
extern s32 gNumPotentialTargets;

View File

@@ -4,16 +4,16 @@
bool8 HasItem(struct DungeonEntity *pokemon, u8 itemIndex)
{
// Weird assignment to fix a regswap.
struct DungeonEntityData *entityData = entityData = pokemon->entityData;
if (!(entityData->heldItem.itemFlags & ITEM_FLAG_EXISTS))
struct DungeonEntityData *pokemonData = pokemonData = pokemon->entityData;
if (!(pokemonData->heldItem.itemFlags & ITEM_FLAG_EXISTS))
{
return FALSE;
}
if (entityData->heldItem.itemFlags & ITEM_FLAG_STICKY)
if (pokemonData->heldItem.itemFlags & ITEM_FLAG_STICKY)
{
return FALSE;
}
if (entityData->heldItem.itemIndex != itemIndex)
if (pokemonData->heldItem.itemIndex != itemIndex)
{
return FALSE;
}

View File

@@ -1,6 +1,7 @@
#include "global.h"
#include "file_system.h"
#include "item.h"
#include "moves.h"
#include "team_inventory.h"
#include "random.h"
#include "pokemon.h"
@@ -42,7 +43,6 @@ 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);
extern u32 GetMoveMaxPP(void*);
extern void sub_80073E0(u32);
extern void xxx_format_and_draw(u32, u32, u8 *, u32, u32);
extern s32 sub_8091E94(s32 a1, s32 a2, s32 a3);
@@ -698,7 +698,7 @@ u32 sub_80913E0(struct ItemSlot* slot, u32 a2, struct subStruct_203B240 ** a3)
xxx_format_and_draw(8, 24, GetItemDescription(slot->itemIndex), a2, 0);
if (GetItemType(slot->itemIndex) == ITEM_TYPE_TM) {
u8* buffer8 = buffer88 + 0x50; // field in struct
struct PokemonMove *buffer8 = (struct PokemonMove*) (buffer88 + 0x50); // field in struct
u16 move = GetItemMove(slot->itemIndex);
u8 moves_data;
u8* typestring;

View File

@@ -1,6 +1,7 @@
#include "global.h"
#include "moves.h"
#include "file_system.h"
#include "constants/move.h"
#include "constants/move_id.h"
struct MoveDataFile
@@ -36,7 +37,6 @@ extern u8 gUnknown_810992C[];
extern void sub_8093F10(struct PokemonMove *, struct PokemonMove *);
extern void sub_80928C0(u8 *, struct PokemonMove *, struct unkStruct_80928C0 *);
extern u32 GetMoveMaxPP(struct PokemonMove*);
bool8 DoesMoveCharge(u16 move);
extern void ExpandPlaceholdersBuffer(u8 *, u8 *, ...);