diff --git a/include/dungeon_damage.h b/include/dungeon_damage.h new file mode 100644 index 000000000..33ae014f2 --- /dev/null +++ b/include/dungeon_damage.h @@ -0,0 +1,13 @@ +#ifndef GUARD_DUNGEON_DAMAGE_H +#define GUARD_DUNGEON_DAMAGE_H + +#include "structs/dungeon_entity.h" +#include "structs/str_damage.h" + +void HandleDealingDamage(Entity *attacker, Entity *target, struct DamageStruct *dmgStruct, bool32 isFalseSwipe, bool32 giveExp, s16 arg4, bool32 arg8, s32 argC); +s32 WeightWeakTypePicker(Entity *user, Entity *target, u8 moveType); +void CalcDamage(Entity *attacker, Entity *target, u8 moveType, s32 movePower, s32 critChance, struct DamageStruct *dmgStruct, s24_8 arg8, u16 moveId, bool8 arg_10); +void sub_806F2BC(Entity *attacker, Entity *target, u8 moveType, s32 a2, struct DamageStruct *dmgStruct); +void DealDamageToEntity(Entity *entity, s32 dmg, s32 r6, s32 r4); + +#endif diff --git a/include/type_effectiveness.h b/include/type_effectiveness.h deleted file mode 100644 index 3cb0a0778..000000000 --- a/include/type_effectiveness.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef GUARD_TYPE_EFFECTIVENESS_H -#define GUARD_TYPE_EFFECTIVENESS_H - -#include "structs/dungeon_entity.h" - -s32 WeightWeakTypePicker(Entity *user, Entity *target, u8 moveType); - -#endif diff --git a/src/code_806CD90.c b/src/code_806CD90.c index 18ad1b95f..cb61efb31 100644 --- a/src/code_806CD90.c +++ b/src/code_806CD90.c @@ -39,7 +39,7 @@ const u8 gUnknown_8106EC8[][13] = { {7, 7, 7, 7, 7, 5, 6, 7, 7, 7, 7, 11, 7}, }; -const u8 gUnknown_8106EEF[] = {0x03, 0x04, 0x05, 0x00, 0x00, 0x70, 0x6b, 0x73, 0x64, 0x69, 0x72, 0x30, 0x00 }; +const u8 gUnknown_8106EEF[] = {0x03, 0x04, 0x05, 0x0}; extern s32 gDungeonFramesCounter; diff --git a/src/code_8073CF0.c b/src/code_8073CF0.c index ef23d906d..93f79a058 100644 --- a/src/code_8073CF0.c +++ b/src/code_8073CF0.c @@ -31,8 +31,8 @@ #include "dungeon_config.h" #include "dungeon_strings.h" #include "dungeon_engine.h" +#include "dungeon_damage.h" -extern void DealDamageToEntity(Entity *, s32, u32, u32); extern void sub_805229C(void); extern void sub_807E8F0(Entity *); extern void sub_80444F4(Entity *pokemon); diff --git a/src/code_8075708.c b/src/code_8075708.c index 148fdfb3a..32e60ce3a 100644 --- a/src/code_8075708.c +++ b/src/code_8075708.c @@ -44,7 +44,6 @@ extern void sub_8073D14(Entity *); extern void sub_8075708(Entity *entity); -extern void DealDamageToEntity(Entity *, s32, u32, u32); extern void sub_805229C(void); extern void sub_807E8F0(Entity *); extern void sub_80444F4(Entity *pokemon); diff --git a/src/dungeon_ai_attack.c b/src/dungeon_ai_attack.c index 3625d9398..e73015b1e 100644 --- a/src/dungeon_ai_attack.c +++ b/src/dungeon_ai_attack.c @@ -29,9 +29,9 @@ #include "structs/str_dungeon.h" #include "targeting_flags.h" #include "dungeon_misc.h" -#include "type_effectiveness.h" #include "dungeon_pos_data.h" #include "dungeon_engine.h" +#include "dungeon_damage.h" #define REGULAR_ATTACK_INDEX 4 diff --git a/src/dungeon_damage.c b/src/dungeon_damage.c index 1842b8312..0619b1c90 100644 --- a/src/dungeon_damage.c +++ b/src/dungeon_damage.c @@ -1,11 +1,12 @@ #include "global.h" +#include "globaldata.h" +#include "dungeon_damage.h" #include "constants/ability.h" #include "structs/str_dungeon.h" #include "dungeon_logic.h" #include "pokemon_types.h" #include "dungeon_message.h" #include "string_format.h" -#include "type_effectiveness.h" #include "constants/move_id.h" #include "constants/monster.h" #include "constants/status.h" @@ -16,7 +17,6 @@ #include "status.h" #include "dungeon_random.h" #include "dungeon_items.h" -#include "structs/str_damage.h" #include "dungeon_util.h" #include "dungeon_config.h" #include "dungeon_strings.h" @@ -61,7 +61,6 @@ extern bool8 sub_806FA5C(Entity *, Entity *, struct unkStruct_8069D4C *); extern void EntityUpdateStatusSprites(Entity *); extern void sub_806F500(void); extern void PointCameraToMonster(Entity *); -extern bool8 sub_806E100(s48_16 *param_1, Entity *pokemon, Entity *target, u8 type, struct DamageStruct *dmgStruct); extern void sub_8041B74(Entity *pokemon); extern void sub_8041B5C(Entity *pokemon); extern void sub_8042940(Entity *r0); @@ -87,6 +86,8 @@ extern const s16 gUnknown_810AC68; extern const s16 gUnknown_810AC62; static bool8 HandleDealingDamageInternal(Entity *attacker, Entity *target, struct DamageStruct *r5, bool32 isFalseSwipe, bool32 giveExp, s16 arg4_, s32 arg8); +static bool8 sub_806E100(s48_16 *param_1, Entity *pokemon, Entity *target, u8 type, DamageStruct *dmgStruct); + void DealDamageToEntity(Entity *entity, s32 dmg, s32 r6, s32 r4); void sub_806F63C(Entity *param_1); @@ -265,7 +266,7 @@ void HandleDealingDamage(Entity *attacker, Entity *target, struct DamageStruct * } } -static inline u8 ItemId(Item *item) +static inline u32 ItemId(Item *item) { return item->id; } @@ -767,7 +768,7 @@ static bool8 HandleDealingDamageInternal(Entity *attacker, Entity *target, struc return TRUE; } -bool8 sub_806E100(s48_16 *param_1, Entity *pokemon, Entity *target, u8 type, DamageStruct *dmgStruct) +static bool8 sub_806E100(s48_16 *param_1, Entity *pokemon, Entity *target, u8 type, DamageStruct *dmgStruct) { bool8 torrentFlag; bool8 overgrowFlag; diff --git a/src/dungeon_move.c b/src/dungeon_move.c index 2909f3196..0b24bf708 100644 --- a/src/dungeon_move.c +++ b/src/dungeon_move.c @@ -6,7 +6,6 @@ #include "constants/iq_skill.h" #include "constants/status.h" #include "constants/weather.h" -#include "structs/str_damage.h" #include "dungeon_move_util.h" #include "effect_main.h" #include "effect_data.h" @@ -27,6 +26,7 @@ #include "dungeon_random.h" #include "dungeon_strings.h" #include "dungeon_util.h" +#include "dungeon_damage.h" #include "math.h" #include "move_effects_target.h" #include "move_orb_actions_1.h" @@ -46,8 +46,6 @@ #include "dungeon_engine.h" extern void sub_80429C8(Entity *r0); -extern void HandleDealingDamage(Entity *attacker, Entity *target, struct DamageStruct *dmgStruct, bool32 isFalseSwipe, bool32 giveExp, s16 arg4, bool32 arg8, s32 argC); -extern void CalcDamage(Entity *, Entity *, u8, u32, u32, struct DamageStruct *dmgStruct, s24_8, u16, u32); extern s16 sub_8057600(Move *move, s32 itemID); extern void sub_803ED30(s32, Entity *r0, u8, s32); extern void sub_8042238(Entity *pokemon, Entity *target); @@ -63,7 +61,6 @@ extern void sub_800E3AC(s32 a0, DungeonPos *pos, s32 a2); extern void sub_8041168(Entity *entity, Entity *entity2, Move *,DungeonPos *); extern Entity *sub_80696A8(Entity *a0); extern Entity *GetMonsterAtPos(DungeonPos *pos); -extern void sub_806F2BC(Entity *attacker, Entity *target, u8 moveType, s32 a2, struct DamageStruct *dmgStruct); extern s32 sub_800ED20(u16 param_1); extern void sub_8042930(Entity *r0); extern void sub_8041B48(Entity *pokemon); diff --git a/src/dungeon_move_util.c b/src/dungeon_move_util.c index 64be5cab9..172f269d0 100644 --- a/src/dungeon_move_util.c +++ b/src/dungeon_move_util.c @@ -5,7 +5,6 @@ #include "constants/iq_skill.h" #include "constants/status.h" #include "constants/weather.h" -#include "structs/str_damage.h" #include "dungeon_move_util.h" #include "effect_main.h" #include "effect_data.h" @@ -42,10 +41,9 @@ #include "dungeon_run_end.h" #include "dungeon_pos_data.h" #include "dungeon_engine.h" +#include "dungeon_damage.h" extern void sub_80429C8(Entity *r0); -extern void HandleDealingDamage(Entity *attacker, Entity *target, struct DamageStruct *dmgStruct, bool32 isFalseSwipe, bool32 giveExp, s16 arg4, bool32 arg8, s32 argC); -extern void CalcDamage(Entity *, Entity *, u8, u32, u32, struct DamageStruct *dmgStruct, s24_8, u16, u32); extern void sub_806A1E8(Entity *pokemon); extern void sub_804178C(u32); extern void EnemyEvolution(Entity *); diff --git a/src/move_orb_actions_1.c b/src/move_orb_actions_1.c index 27bad3b31..14a8a489b 100644 --- a/src/move_orb_actions_1.c +++ b/src/move_orb_actions_1.c @@ -32,14 +32,13 @@ #include "dungeon_config.h" #include "dungeon_misc.h" #include "dungeon_strings.h" +#include "dungeon_damage.h" extern void sub_806A5B8(Entity *entity); void sub_8075900(Entity *pokemon, u8 r1); extern void sub_807EC28(bool8); extern void sub_806F370(Entity *r0, Entity *r1, u32, u32, u8 *, u8, s32, u32, u32, u32); -extern void CalcDamage(Entity *, Entity *, u8, u32, u32, s32 *, u32, u16, u32); extern void MudWaterSportEffect(u32); -extern void CalcDamage(Entity *, Entity *, u8, u32, u32, s32 *, u32, u16, u32); extern void sub_806A6E8(Entity *); extern void EndAbilityImmuneStatus(Entity *, Entity *); @@ -54,7 +53,6 @@ bool8 RollSecondaryEffect(Entity *pokemon, s32 chance); bool8 sub_80571F0(Entity * pokemon, Move *move); extern void sub_806F370(Entity *r0, Entity *r1, u32, u32, u8 *, u8, s32, u32, u32, u32); -extern void DealDamageToEntity(Entity *, s32, u32, u32); extern s16 sub_8057600(Move *move, s32 itemID); // Note: For some reason I have to define these as an array of 1 to match asm. diff --git a/src/move_orb_actions_2.c b/src/move_orb_actions_2.c index e531d30fa..dd7027400 100644 --- a/src/move_orb_actions_2.c +++ b/src/move_orb_actions_2.c @@ -33,9 +33,9 @@ #include "dungeon_config.h" #include "dungeon_misc.h" #include "dungeon_strings.h" +#include "dungeon_damage.h" extern void sub_806F370(Entity *r0, Entity *r1, u32, u32, u8 *, u8, s32, u32, u32, u32); -extern void CalcDamage(Entity *, Entity *, u8, u32, u32, s32 *, u32, u16, u32); extern void EndAbilityImmuneStatus(Entity *, Entity *); extern u8 sub_806F4A4(Entity *, u32); @@ -43,8 +43,6 @@ extern void HandleExplosion(Entity *pokemon, Entity *target, DungeonPos *pos, u3 extern void nullsub_92(Entity *); extern u8 sub_807EAA0(u32, u32); -extern void DealDamageToEntity(Entity *, s32, u32, u32); - extern u32 gUnknown_8106A4C; extern u32 gUnknown_8106A50; diff --git a/src/move_orb_actions_3.c b/src/move_orb_actions_3.c index b950a179c..b3ba4f236 100644 --- a/src/move_orb_actions_3.c +++ b/src/move_orb_actions_3.c @@ -35,7 +35,7 @@ #include "move_orb_actions_4.h" #include "structs/dungeon_entity.h" #include "structs/map.h" -#include "structs/str_dungeon.h" +#include "dungeon_damage.h" #include "pokemon_types.h" #include "trap.h" #include "weather.h" @@ -44,7 +44,6 @@ extern void sub_807EC28(bool8); extern void sub_806F370(Entity *r0, Entity *r1, u32, u32, u8 *, u8, s32, u32, u32, u32); -extern void CalcDamage(Entity *, Entity *, u8, u32, u32, s32 *, u32, u16, u32); static void sub_805A7D4(Entity *, Entity *, Item *, DungeonPos *); extern void MudWaterSportEffect(u32); extern void sub_806A6E8(Entity *); @@ -78,7 +77,7 @@ bool8 JumpKickMoveAction(Entity * pokemon,Entity * target,Move * move,s32 param_ u32 movePower; u32 moveCritChance; bool8 flag; - s32 local_30 [4]; + DamageStruct dmgStruct; u8 auStack_20; flag = FALSE; @@ -89,14 +88,14 @@ bool8 JumpKickMoveAction(Entity * pokemon,Entity * target,Move * move,s32 param_ moveType = GetMoveTypeForMonster(pokemon,move); movePower = GetMovePower(pokemon,move); moveCritChance = GetMoveCritChance(move); - CalcDamage(pokemon,target,moveType,movePower,moveCritChance,local_30,0x100,move->id,0); + CalcDamage(pokemon,target,moveType,movePower,moveCritChance,&dmgStruct, IntToF248_2(1),move->id,0); SetMessageArgument_2(gFormatBuffer_Monsters[0],GetEntInfo(pokemon),0); TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC7C8); - local_30[0] = local_30[0] / 2; - if (local_30[0] == 0) { - local_30[0] = 1; + dmgStruct.dmg /= 2; + if (dmgStruct.dmg == 0) { + dmgStruct.dmg = 1; } - sub_806F370(pokemon,pokemon,local_30[0],0,&auStack_20,0,0x1f7,0x13,1,0); + sub_806F370(pokemon,pokemon,dmgStruct.dmg,0,&auStack_20,0,0x1f7,0x13,1,0); } return flag; } @@ -128,7 +127,7 @@ bool8 HiJumpKickMoveAction(Entity * pokemon,Entity * target,Move * move,s32 para u32 movePower; u32 moveCritChance; bool8 flag; - s32 local_30 [4]; + DamageStruct dmgStruct; u8 auStack_20; flag = FALSE; @@ -139,14 +138,14 @@ bool8 HiJumpKickMoveAction(Entity * pokemon,Entity * target,Move * move,s32 para moveType = GetMoveTypeForMonster(pokemon,move); movePower = GetMovePower(pokemon,move); moveCritChance = GetMoveCritChance(move); - CalcDamage(pokemon,target,moveType,movePower,moveCritChance,local_30,0x200,move->id,0); + CalcDamage(pokemon,target,moveType,movePower,moveCritChance,&dmgStruct,IntToF248_2(2),move->id,0); SetMessageArgument_2(gFormatBuffer_Monsters[0],GetEntInfo(pokemon),0); TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC7C8); - local_30[0] = local_30[0] / 2; - if (local_30[0] == 0) { - local_30[0] = 1; + dmgStruct.dmg /= 2; + if (dmgStruct.dmg == 0) { + dmgStruct.dmg = 1; } - sub_806F370(pokemon,pokemon,local_30[0],0,&auStack_20,0,0x1f8,0x13,1,0); + sub_806F370(pokemon,pokemon,dmgStruct.dmg,0,&auStack_20,0,0x1f8,0x13,1,0); } return flag; } diff --git a/src/move_orb_actions_4.c b/src/move_orb_actions_4.c index fe5792c9c..141e143cd 100644 --- a/src/move_orb_actions_4.c +++ b/src/move_orb_actions_4.c @@ -35,6 +35,7 @@ #include "weather.h" #include "dungeon_config.h" #include "dungeon_strings.h" +#include "dungeon_damage.h" extern void sub_807F43C(Entity *, Entity *); extern void HandleOneRoomOrb(Entity *, Entity *); @@ -49,8 +50,6 @@ extern bool8 sub_806AA0C(s32, u32); extern void sub_806BB6C(Entity *, s32); extern void HandleSwitcherOrb(Entity *, Entity *, u32); -extern void DealDamageToEntity(Entity *, s32, u32, u32); - extern u32 gUnknown_8106A50; extern u32 gUnknown_8106A4C; diff --git a/src/move_orb_effects_4.c b/src/move_orb_effects_4.c index b2e254902..fac477089 100644 --- a/src/move_orb_effects_4.c +++ b/src/move_orb_effects_4.c @@ -34,7 +34,6 @@ extern void sub_807EC28(bool8); extern s32 GetMonsterApparentID(Entity *param_1, s16 param_2); extern void sub_806A898(Entity *, u32, u32); extern void HealTargetHP(Entity *pokemon, Entity *r1, s16, s16, u32); -extern void DealDamageToEntity(Entity *, s16, u32, u32); extern void ResetMonEntityData(EntityInfo *, u32); extern void sub_80420C8(Entity *r0); extern void nullsub_68(Entity *); diff --git a/src/move_orb_effects_5.c b/src/move_orb_effects_5.c index 1664a2b19..1f9a824ef 100644 --- a/src/move_orb_effects_5.c +++ b/src/move_orb_effects_5.c @@ -27,6 +27,7 @@ #include "dungeon_logic.h" #include "dungeon_strings.h" #include "dungeon_pos_data.h" +#include "dungeon_damage.h" extern void UpdateMinimap(); extern void EntityUpdateStatusSprites(Entity *); @@ -35,7 +36,6 @@ extern void sub_807EC28(bool8); extern s32 GetMonsterApparentID(Entity *param_1, s16 param_2); extern void sub_806A898(Entity *, u32, u32); extern void HealTargetHP(Entity *pokemon, Entity *r1, s16, s16, u32); -extern void DealDamageToEntity(Entity *, s16, u32, u32); extern void ResetMonEntityData(EntityInfo *, u32); extern void sub_80420C8(Entity *r0); extern void nullsub_68(Entity *); diff --git a/src/trap.c b/src/trap.c index 68a859f4f..dc18ef295 100644 --- a/src/trap.c +++ b/src/trap.c @@ -31,6 +31,7 @@ #include "dungeon_strings.h" #include "sprite.h" #include "dungeon_pos_data.h" +#include "dungeon_damage.h" extern u32 gUnknown_8106A4C; extern u32 gUnknown_8106A50; @@ -40,7 +41,6 @@ bool8 sub_806AA0C(s32, s32); void sub_80421EC(DungeonPos *, u32); u8 GetFloorType(void); void sub_8045BF8(u8 *, Item *); -void DealDamageToEntity(Entity *,s16,u32,u32); void sub_806F480(Entity *, u32); void sub_804225C(Entity *, DungeonPos *, u8); void EnemyEvolution(Entity *); diff --git a/src/type_effectiveness.c b/src/type_effectiveness.c deleted file mode 100644 index f3a88d6de..000000000 --- a/src/type_effectiveness.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "global.h" -#include "type_effectiveness.h" -#include "constants/ability.h" -#include "constants/status.h" -#include "constants/weather.h" -#include "structs/str_dungeon.h" -#include "dungeon_message.h" -#include "dungeon_logic.h" -#include "dungeon_util.h" -#include "math.h" -#include "status.h" -#include "dungeon_config.h" - - - -