Fix ReturnMoveAction

This commit is contained in:
DizzyEggg 2024-12-04 12:49:41 +01:00
parent db1f3b00b1
commit 86232a8ceb
9 changed files with 102 additions and 63 deletions

View File

@ -1,21 +1,8 @@
.section .rodata
.global gUnknown_80F54B4
gUnknown_80F54B4: @ 80F54B4
.4byte 0, 0, 0, 1
.4byte 0, 1, 1, 2
.4byte 0, 1, 2, 3
.4byte 1, 2, 3, 3
.global gUnknown_80F54F4
gUnknown_80F54F4: @ 80F54F4
.incbin "baserom.gba", 0xF54F4, 0xA0
.global gWarpScarfActivationChances
gWarpScarfActivationChances: @ 80F5594
@ replacing .incbin "baserom.gba", 0xF5594, 0x28
.2byte 0, 6, 12, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210, 230, 250, 270, 290, 310, 999, 0
.global gUnknown_80F55BC
gUnknown_80F55BC: @ 80F55BC
.2byte 50, 5, 100, 10, 200, 15, 300, 20, 400, 25, 500, 30, 600, 35, 700, 40, 800, 45, 1000, 45, 10000, 9999, -1, 1

View File

@ -171,5 +171,12 @@ extern const struct CastformWeatherData gCastformByWeather[WEATHER_COUNT];
#define EFFECTIVENESS_SUPER 3
extern const s16 gTypeEffectivenessChart[NUM_TYPES][NUM_TYPES];
extern const s32 gEffectivenessChart[NUM_EFFECTIVENESS][NUM_EFFECTIVENESS];
#define BELLY_GO_DOWN_VALUES_COUNT 20
extern const s48_16 gBellyGoDownValues[BELLY_GO_DOWN_VALUES_COUNT];
#define WARP_SCARF_ACTIVATION_CHANCES_COUNT 20
extern const s16 gWarpScarfActivationChances[WARP_SCARF_ACTIVATION_CHANCES_COUNT];
#endif

View File

@ -38,7 +38,7 @@ s24_8 s24_8_mul(s24_8 x, s24_8 y);
bool8 F48_16_IsZero(s48_16 *a);
void F48_16_SDiv(s48_16 *dst, s48_16 *a, s48_16 *b);
void F48_16_SMul(s48_16 *dst, s48_16 *a, s48_16 *b);
void F48_16_SMul(s48_16 *dst, const s48_16 *a, const s48_16 *b);
s24_8 FP24_8_Hypot(s24_8 x, s24_8 y);
void FP48_16_FromS32(s48_16 *dst, s32 src);

View File

@ -33,7 +33,6 @@ extern void sub_8041B74(Entity *pokemon);
extern void sub_8041B5C(Entity *pokemon);
extern void HandleDealingDamage(Entity *attacker, Entity *target, struct DamageStruct *dmgStruct, bool32 isFalseSwipe, bool32 giveExp, s16 arg4, bool32 arg8, s32 argC);
extern const s32 gUnknown_80F54B4[NUM_EFFECTIVENESS][NUM_EFFECTIVENESS];
extern const s16 gUnknown_810AC60;
extern const s16 gUnknown_810AC68;
extern const s16 gUnknown_810AC64;
@ -470,7 +469,7 @@ void sub_806F370(Entity *pokemon, Entity *target, s32 dmg, s32 giveExp, bool8 *t
typeEffectiveness[i] = effectiv;
}
if (AbilityIsActive(target, ABILITY_WONDER_GUARD)) {
if (gUnknown_80F54B4[typeEffectiveness[0]][typeEffectiveness[1]] != EFFECTIVENESS_SUPER) {
if (gEffectivenessChart[typeEffectiveness[0]][typeEffectiveness[1]] != EFFECTIVENESS_SUPER) {
dmgNew = 0;
}
}

View File

@ -84,9 +84,7 @@ extern const u8 *gPtrProtectSavedItMessage;
extern const u8 *gPtrStenchWavedOffMessage;
extern const u8 *gUnknown_80FA124[];
extern const s16 gWarpScarfActivationChances[];
extern const s16 gUnknown_80F4E0C;
extern s48_16 gUnknown_80F54F4[8];
extern const s32 gUnknown_80F60DC[];
extern const DungeonPos gUnknown_80F4D44[];
@ -273,8 +271,8 @@ void sub_8074094(Entity *entity)
sub_805229C();
sub_807E8F0(entity);
if (HasHeldItem(entity, ITEM_WARP_SCARF)) {
if (++entityInfo->turnsSinceWarpScarfActivation > 19)
entityInfo->turnsSinceWarpScarfActivation = 19;
if (++entityInfo->turnsSinceWarpScarfActivation >= WARP_SCARF_ACTIVATION_CHANCES_COUNT)
entityInfo->turnsSinceWarpScarfActivation = WARP_SCARF_ACTIVATION_CHANCES_COUNT - 1;
if (DungeonRandInt(100) < gWarpScarfActivationChances[entityInfo->turnsSinceWarpScarfActivation]) {
entityInfo->turnsSinceWarpScarfActivation = 0;
sub_80444F4(entity);
@ -296,28 +294,28 @@ void sub_8074094(Entity *entity)
bool8 sound;
const u8 *str = NULL;
s32 r4 = 10;
s32 arrIndex = 10;
if (HasHeldItem(entity, ITEM_TIGHT_BELT))
r4 = 0;
arrIndex = 0;
if (HasHeldItem(entity, ITEM_STAMINA_BAND))
r4--;
arrIndex--;
if (IQSkillIsEnabled(entity, IQ_ENERGY_SAVER))
r4--;
arrIndex--;
if (HasHeldItem(entity, ITEM_DIET_RIBBON))
r4++;
arrIndex++;
if (HasHeldItem(entity, ITEM_HEAL_RIBBON))
r4++;
arrIndex++;
if (HasHeldItem(entity, ITEM_MUNCH_BELT))
r4++;
arrIndex++;
if (r4 < 0)
r4 = 0;
if (r4 > 19)
r4 = 19;
if (arrIndex < 0)
arrIndex = 0;
if (arrIndex >= BELLY_GO_DOWN_VALUES_COUNT)
arrIndex = BELLY_GO_DOWN_VALUES_COUNT - 1;
sp8.hi = 0;
sp8.lo = 6554;
F48_16_SMul(&sp10, &sp8, &gUnknown_80F54F4[r4]);
F48_16_SMul(&sp10, &sp8, &gBellyGoDownValues[arrIndex]);
if (entityInfo->unk153 > 1)
sp10.lo += (gUnknown_80F60DC[entityInfo->unk153] << 0x10);
entityInfo->unk153 = 0;

View File

@ -305,3 +305,57 @@ const s16 gTypeEffectivenessChart[NUM_TYPES][NUM_TYPES] = {
[TYPE_DARK] = {NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, RESIST, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, RESIST, RESIST},
[TYPE_STEEL] = {NEUTRAL, NEUTRAL, RESIST, RESIST, NEUTRAL, RESIST, SUPER, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, NEUTRAL, NEUTRAL, RESIST}
};
const s32 gEffectivenessChart[NUM_EFFECTIVENESS][NUM_EFFECTIVENESS] = {
[IMMUNE] = {
[IMMUNE] = IMMUNE,
[RESIST] = IMMUNE,
[NEUTRAL] = IMMUNE,
[SUPER] = RESIST,
},
[RESIST] = {
[IMMUNE] = IMMUNE,
[RESIST] = RESIST,
[NEUTRAL] = RESIST,
[SUPER] = NEUTRAL,
},
[NEUTRAL] = {
[IMMUNE] = IMMUNE,
[RESIST] = RESIST,
[NEUTRAL] = NEUTRAL,
[SUPER] = SUPER,
},
[SUPER] = {
[IMMUNE] = RESIST,
[RESIST] = NEUTRAL,
[NEUTRAL] = SUPER,
[SUPER] = SUPER,
},
};
// Todo: change to readable format
const s48_16 gBellyGoDownValues[BELLY_GO_DOWN_VALUES_COUNT] =
{
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0x199A},
{0, 0x4000},
{0, 0x8000},
{0, 0xC000},
{0, 0x10000},
{0, 0x20000},
{0, 0x40000},
{0, 0x80000},
{0, 0x100000},
{0, 0x200000},
{0, 0x400000},
{0, 0x800000},
{0, 0x800000},
{0, 0x800000},
};
const s16 gWarpScarfActivationChances[WARP_SCARF_ACTIVATION_CHANCES_COUNT] = {0, 6, 12, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210, 230, 250, 270, 290, 310, 999, 0};

View File

@ -581,7 +581,7 @@ bool8 FP48_16_SLessThan(s48_16 *a, s48_16 *b)
}
}
void F48_16_SMul(s48_16 *dst, s48_16 *a, s48_16 *b)
void F48_16_SMul(s48_16 *dst, const s48_16 *a, const s48_16 *b)
{
bool8 aIsNegative;
bool8 bIsNegative;
@ -694,7 +694,7 @@ static void F48_16_UMul(s48_16 *dst, s48_16 *a, s48_16 *b)
#endif
u32 r6;
s32 i;
if (F48_16_IsZero(a)) {
dst->hi = 0;
dst->lo = 0;

View File

@ -68,7 +68,6 @@ extern u8 *gUnknown_80FAC74[];
extern u8 *gUnknown_80FAC54[];
extern s16 gUnknown_80F4DB8;
extern s16 gUnknown_80F4DBA;
extern s16 gUnknown_80F55BC[];
extern u8 *gUnknown_80FAE00[];
extern u8 *gUnknown_80FADD8[];
extern s16 gUnknown_80F4E02;
@ -717,34 +716,31 @@ bool8 WillOWispMoveAction(Entity *pokemon, Entity *target, Move *move, s32 param
return TRUE;
}
struct TestStruct
{
s16 a;
s16 b;
};
extern const struct TestStruct gUnknown_80F55BC[];
bool8 ReturnMoveAction(Entity * pokemon,Entity * target,Move * move,s32 param_4)
{
s16 *psVar3;
s32 index;
s32 r6;
bool8 local_24;
EntityInfo *entityInfo;
s32 IQ;
s32 i;
bool8 local_24;
EntityInfo *entityInfo = GetEntInfo(pokemon);
s32 dmg = 1;
entityInfo = GetEntInfo(pokemon);
r6 = 1;
index = 0;
if (0 <= gUnknown_80F55BC[0]) {
IQ = entityInfo->IQ;
for(psVar3 = &gUnknown_80F55BC[index]; (999 > index) && (*psVar3 >= 0); psVar3 = psVar3 + 2, index++)
{
if ((IQ < *psVar3)){
r6 = psVar3[1];
goto _080580B0;
}
for (i = 0; i < 999 && gUnknown_80F55BC[i].a >= 0; i++) {
if (entityInfo->IQ < gUnknown_80F55BC[i].a) {
dmg = gUnknown_80F55BC[i].b;
break;
}
}
_080580B0:
sub_806F370(pokemon,target,r6,1,&local_24,GetMoveType(move),sub_8057600(move,param_4),0,1,0);
local_24 = local_24 == 0;
return local_24;
}
sub_806F370(pokemon,target,dmg,1,&local_24,GetMoveType(move),sub_8057600(move,param_4),0,1,0);
local_24 = (local_24 == 0);
return local_24;
}
bool8 GrudgeMoveAction(Entity *pokemon, Entity * target, Move *move, s32 param_4)

View File

@ -58,8 +58,6 @@ extern u8 *gUnknown_80FEDC8[];
extern u8 *gUnknown_80FEDA8[];
extern u8 *gUnknown_80FED88[];
extern const s32 gUnknown_80F54B4[NUM_EFFECTIVENESS][NUM_EFFECTIVENESS];
void sub_80428D8(Entity *);
void sub_8042978(Entity *);
void sub_804298C(Entity *);
@ -123,7 +121,7 @@ bool8 sub_806E100(s48_16 *param_1, Entity *pokemon, Entity *target, u8 type, str
gDungeon->unk134.unk13C[index] = effectiveness;
}
param_5->effectiveness = gUnknown_80F54B4[local_38[0]][local_38[1]];
param_5->effectiveness = gEffectivenessChart[local_38[0]][local_38[1]];
bVar4 = TRUE;
if ((param_5->effectiveness != EFFECTIVENESS_SUPER) && (bVar4 = FALSE, hasWonderGuard)) {
temp = gUnknown_8106EFC[1];