diff options
-rw-r--r-- | asm/code_80428A0.s | 4 | ||||
-rw-r--r-- | asm/code_80521D0.s | 4 | ||||
-rw-r--r-- | asm/code_8057144.s | 4 | ||||
-rw-r--r-- | asm/code_8057824.s | 4 | ||||
-rw-r--r-- | asm/code_80718D8.s | 243 | ||||
-rw-r--r-- | asm/code_808333C.s | 11 | ||||
-rw-r--r-- | asm/code_808417C.s (renamed from asm/code_8084160.s) | 18 | ||||
-rw-r--r-- | include/dungeon_entity.h | 6 | ||||
-rw-r--r-- | include/dungeon_pokemon_attributes_1.h | 10 | ||||
-rwxr-xr-x | ld_script.txt | 2 | ||||
-rw-r--r-- | src/dungeon_ai_items.c | 1 | ||||
-rw-r--r-- | src/dungeon_pokemon_attributes_1.c | 124 | ||||
-rw-r--r-- | src/dungeon_random.c | 5 | ||||
-rw-r--r-- | src/dungeon_random_1.c | 9 | ||||
-rw-r--r-- | src/moves.c | 2 |
15 files changed, 157 insertions, 290 deletions
diff --git a/asm/code_80428A0.s b/asm/code_80428A0.s index 49ef590..bb4e09e 100644 --- a/asm/code_80428A0.s +++ b/asm/code_80428A0.s @@ -1099,7 +1099,7 @@ _08043318: movs r0, 0xA strh r0, [r1] ldr r0, [r2] - bl sub_80840D8 + bl SetDungeonRNG _08043346: ldr r0, [r4] ldr r1, _080434C4 @@ -4197,4 +4197,4 @@ ResetAction: bx lr thumb_func_end ResetAction - .align 2, 0
\ No newline at end of file + .align 2, 0 diff --git a/asm/code_80521D0.s b/asm/code_80521D0.s index 8e97c19..417d5da 100644 --- a/asm/code_80521D0.s +++ b/asm/code_80521D0.s @@ -5863,7 +5863,7 @@ sub_8055640: lsrs r4, 24 adds r0, r6, 0 adds r1, r5, 0 - bl sub_8071A44 + bl CalculateMovePower mov r8, r0 adds r0, r5, 0 bl GetMoveCriticalHitChance @@ -5917,7 +5917,7 @@ sub_80556BC: lsls r4, 24 lsrs r4, 24 adds r1, r5, 0 - bl sub_8071A44 + bl CalculateMovePower mov r8, r0 adds r0, r5, 0 bl GetMoveCriticalHitChance diff --git a/asm/code_8057144.s b/asm/code_8057144.s index 8aecb64..795e7cf 100644 --- a/asm/code_8057144.s +++ b/asm/code_8057144.s @@ -218,7 +218,7 @@ sub_805727C: _080572D2: adds r0, r4, 0 _080572D4: - bl sub_8084160 + bl RollPercentChance_2 lsls r0, 24 lsrs r4, r0, 24 b _080572E0 @@ -276,7 +276,7 @@ _08057324: _08057336: lsls r0, r4, 1 _08057338: - bl sub_8084160 + bl RollPercentChance_2 lsls r0, 24 lsrs r0, 24 _08057340: diff --git a/asm/code_8057824.s b/asm/code_8057824.s index 7ea4a18..3943de2 100644 --- a/asm/code_8057824.s +++ b/asm/code_8057824.s @@ -4918,7 +4918,7 @@ _08059E8A: lsrs r4, 24 adds r0, r6, 0 adds r1, r7, 0 - bl sub_8071A44 + bl CalculateMovePower adds r5, r0, 0 adds r0, r7, 0 bl GetMoveCriticalHitChance @@ -5100,7 +5100,7 @@ _08059FFE: lsrs r4, 24 adds r0, r6, 0 adds r1, r7, 0 - bl sub_8071A44 + bl CalculateMovePower adds r5, r0, 0 adds r0, r7, 0 bl GetMoveCriticalHitChance diff --git a/asm/code_80718D8.s b/asm/code_80718D8.s index 699dad9..caa62de 100644 --- a/asm/code_80718D8.s +++ b/asm/code_80718D8.s @@ -5,249 +5,6 @@ .text - thumb_func_start LoadIQSkills -LoadIQSkills: - push {r4-r6,lr} - ldr r5, [r0, 0x70] - ldrb r1, [r5, 0x6] - cmp r1, 0 - beq _08071978 - adds r4, r5, 0 - adds r4, 0x90 - adds r0, r4, 0 - movs r1, 0x8 - bl SetIQSkill - adds r0, r4, 0 - movs r1, 0x6 - bl SetIQSkill - adds r0, r4, 0 - movs r1, 0x2 - bl SetIQSkill - adds r0, r5, 0 - adds r0, 0xF7 - ldrb r0, [r0] - cmp r0, 0 - beq _08071954 - adds r0, r4, 0 - movs r1, 0x12 - bl SetIQSkill -_08071954: - ldrb r0, [r5, 0x9] - ldr r1, _08071974 - movs r2, 0 - ldrsh r1, [r1, r2] - cmp r0, r1 - blt _08071968 - adds r0, r4, 0 - movs r1, 0x16 - bl SetIQSkill -_08071968: - adds r1, r5, 0 - adds r1, 0x94 - movs r0, 0x2 - strb r0, [r1] - b _080719BE - .align 2, 0 -_08071974: .4byte gItemMasterMinWildLevel -_08071978: - adds r0, r5, 0 - adds r0, 0x90 - strb r1, [r0] - adds r2, r5, 0 - adds r2, 0x91 - strb r1, [r2] - adds r2, 0x1 - strb r1, [r2] - movs r4, 0x1 - adds r6, r0, 0 -_0807198C: - movs r1, 0xC - ldrsh r0, [r5, r1] - lsls r1, r4, 24 - lsrs r1, 24 - bl HasIQForSkill - lsls r0, 24 - cmp r0, 0 - beq _080719B8 - movs r1, 0x1 - lsls r1, r4 - adds r0, r5, 0 - adds r0, 0x8C - bl IsIQSkillSet - lsls r0, 24 - cmp r0, 0 - beq _080719B8 - adds r0, r6, 0 - adds r1, r4, 0 - bl SetIQSkill -_080719B8: - adds r4, 0x1 - cmp r4, 0x17 - ble _0807198C -_080719BE: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end LoadIQSkills - - thumb_func_start CanSeeTeammate -CanSeeTeammate: - push {r4-r6,lr} - adds r5, r0, 0 - ldr r0, [r5, 0x70] - ldrb r0, [r0, 0x6] - cmp r0, 0 - beq _080719D6 - b _08071A0A -_080719D2: - movs r0, 0x1 - b _08071A0C -_080719D6: - movs r6, 0 -_080719D8: - ldr r0, _08071A14 - ldr r0, [r0] - lsls r1, r6, 2 - ldr r2, _08071A18 - adds r0, r2 - adds r0, r1 - ldr r4, [r0] - adds r0, r5, 0 - bl EntityExists - lsls r0, 24 - cmp r0, 0 - beq _08071A04 - cmp r5, r4 - beq _08071A04 - adds r0, r5, 0 - adds r1, r4, 0 - bl CanSee - lsls r0, 24 - cmp r0, 0 - bne _080719D2 -_08071A04: - adds r6, 0x1 - cmp r6, 0x3 - ble _080719D8 -_08071A0A: - movs r0, 0 -_08071A0C: - pop {r4-r6} - pop {r1} - bx r1 - .align 2, 0 -_08071A14: .4byte gDungeonGlobalData -_08071A18: .4byte 0x0001357c - thumb_func_end CanSeeTeammate - - thumb_func_start GetMoveType_2 -GetMoveType_2: - push {lr} - adds r3, r0, 0 - adds r2, r1, 0 - ldrh r1, [r2, 0x2] - movs r0, 0xA2 - lsls r0, 1 - cmp r1, r0 - beq _08071A38 - adds r0, r2, 0 - bl GetMoveType - lsls r0, 24 - lsrs r0, 24 - b _08071A3E -_08071A38: - ldr r0, [r3, 0x70] - adds r0, 0x3E - ldrb r0, [r0] -_08071A3E: - pop {r1} - bx r1 - thumb_func_end GetMoveType_2 - - thumb_func_start sub_8071A44 -sub_8071A44: - push {r4,lr} - adds r2, r0, 0 - adds r4, r1, 0 - ldrh r1, [r4, 0x2] - movs r0, 0xA2 - lsls r0, 1 - cmp r1, r0 - beq _08071A60 - adds r0, r4, 0 - bl GetMovePower - ldrb r1, [r4, 0x5] - adds r0, r1 - b _08071A6A -_08071A60: - ldr r0, [r2, 0x70] - movs r1, 0x3C - ldrsh r0, [r0, r1] - ldrb r4, [r4, 0x5] - adds r0, r4 -_08071A6A: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8071A44 - - thumb_func_start ToolboxEnabled -ToolboxEnabled: - push {lr} - movs r1, 0x2 - ldrsh r0, [r0, r1] - bl IsToolboxEnabled - lsls r0, 24 - cmp r0, 0 - beq _08071A84 - movs r0, 0x1 - b _08071A86 -_08071A84: - movs r0, 0 -_08071A86: - pop {r1} - bx r1 - thumb_func_end ToolboxEnabled - - thumb_func_start sub_8071A8C -sub_8071A8C: - push {r4,lr} - adds r4, r0, 0 - bl EntityExists - lsls r0, 24 - cmp r0, 0 - beq _08071AC2 - ldr r1, [r4, 0x70] - adds r0, r1, 0 - adds r0, 0xA4 - ldrb r0, [r0] - cmp r0, 0x1 - beq _08071AC2 - adds r0, r1, 0 - adds r0, 0x40 - ldrb r0, [r0] - cmp r0, 0x4A - beq _08071AB4 - cmp r0, 0x47 - bne _08071AB8 -_08071AB4: - movs r0, 0x1 - b _08071ABA -_08071AB8: - movs r0, 0 -_08071ABA: - cmp r0, 0 - bne _08071AC2 - movs r0, 0x1 - b _08071AC4 -_08071AC2: - movs r0, 0 -_08071AC4: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8071A8C - thumb_func_start SetVisualFlags SetVisualFlags: push {r4,r5,lr} diff --git a/asm/code_808333C.s b/asm/code_808333C.s index 5677a42..bd38800 100644 --- a/asm/code_808333C.s +++ b/asm/code_808333C.s @@ -1865,15 +1865,4 @@ _080840D0: .4byte 0xffff0000 _080840D4: .4byte 0x00ffffff thumb_func_end sub_80840A4 - thumb_func_start sub_80840D8 -sub_80840D8: - ldr r2, _080840E4 - movs r1, 0x1 - orrs r1, r0 - str r1, [r2] - bx lr - .align 2, 0 -_080840E4: .4byte gDungeonRngState - thumb_func_end sub_80840D8 - .align 2, 0 diff --git a/asm/code_8084160.s b/asm/code_808417C.s index fce2f1b..03b4f3b 100644 --- a/asm/code_8084160.s +++ b/asm/code_808417C.s @@ -5,24 +5,6 @@ .text - thumb_func_start sub_8084160 -sub_8084160: - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x64 - bl DungeonRandomCapped - cmp r0, r4 - blt _08084172 - movs r0, 0 - b _08084174 -_08084172: - movs r0, 0x1 -_08084174: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8084160 - thumb_func_start sub_808417C sub_808417C: push {r4-r6,lr} diff --git a/include/dungeon_entity.h b/include/dungeon_entity.h index f4e836c..29fda0a 100644 --- a/include/dungeon_entity.h +++ b/include/dungeon_entity.h @@ -34,7 +34,7 @@ struct DungeonEntityData /* 0x9 */ u8 level; /* 0xA */ u8 partyIndex; // Leader is 0, partner is 1, etc. u8 fillB; - /* 0xC */ u16 IQ; + /* 0xC */ s16 IQ; /* 0xE */ s16 HP; /* 0x10 */ s16 maxHP; // Bosses have higher HP than normal for their level. This is the max HP they would normally have given their level. @@ -60,7 +60,7 @@ struct DungeonEntityData /* 0x30 */ s32 specialAttackMultiplier; /* 0x34 */ s32 defenseMultiplier; /* 0x38 */ s32 specialDefenseMultiplier; - u8 fill3C[0x3E - 0x3C]; + /* 0x3C */ s16 hiddenPowerPower; /* 0x3E */ u8 hiddenPowerType; u8 fill3F; /* 0x40 */ u8 joinLocation; // Uses the dungeon index in dungeon.h. @@ -151,7 +151,7 @@ struct DungeonEntityData u8 fillF3; /* 0xF4 */ bool8 grudgeStatus; /* 0xF5 */ bool8 exposedStatus; - u8 fillF7; + u8 fillF6; /* 0xF7 */ bool8 isBoss; u8 fillF8[0xFA - 0xF8]; /* 0xFA */ u8 terrifiedTurnsLeft; // Doubles as a bool for whether the Pokémon is terrified. diff --git a/include/dungeon_pokemon_attributes_1.h b/include/dungeon_pokemon_attributes_1.h index ccf68e5..cdfa989 100644 --- a/include/dungeon_pokemon_attributes_1.h +++ b/include/dungeon_pokemon_attributes_1.h @@ -8,6 +8,14 @@ bool8 CanSeeInvisible(struct DungeonEntity *pokemon); // 0x718AC bool8 HasTactic(struct DungeonEntity *pokemon, u8 tactic); // 0x718D8 -bool8 HasIQSkill(struct DungeonEntity* pokemon, u8 IQSkill); +bool8 HasIQSkill(struct DungeonEntity *pokemon, u8 IQSkill); + +void LoadIQSkills(struct DungeonEntity *pokemon); +bool8 CanSeeTeammate(struct DungeonEntity * pokemon); +u8 GetMoveType_2(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove); + +// 0x71A44 +s32 CalculateMovePower(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove); +bool8 ToolboxEnabled(struct DungeonEntityData *pokemon); #endif diff --git a/ld_script.txt b/ld_script.txt index 209fedc..0dce9c7 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -226,7 +226,7 @@ SECTIONS { src/dungeon_random.o(.text); asm/code_808411C.o(.text); src/dungeon_random_1.o(.text); - asm/code_8084160.o(.text); + asm/code_808417C.o(.text); src/code_80848F0.o(.text); asm/code_80848F0.o(.text); src/dungeon_util_1.o(.text); diff --git a/src/dungeon_ai_items.c b/src/dungeon_ai_items.c index fc10e85..4afc928 100644 --- a/src/dungeon_ai_items.c +++ b/src/dungeon_ai_items.c @@ -33,7 +33,6 @@ enum ItemTargetFlag extern s32 CalculateFacingDir(struct Position*, struct Position*); extern u32 EvaluateItem(struct DungeonEntity*, struct ItemSlot*, u8); -extern bool8 ToolboxEnabled(struct DungeonEntityData*); extern void sub_8077274(struct DungeonEntity *, struct DungeonEntity *); extern void TargetThrownItem(struct DungeonEntity*, struct DungeonEntity*, struct ItemSlot*, u8, bool8); diff --git a/src/dungeon_pokemon_attributes_1.c b/src/dungeon_pokemon_attributes_1.c index 02e9af0..d3b8cab 100644 --- a/src/dungeon_pokemon_attributes_1.c +++ b/src/dungeon_pokemon_attributes_1.c @@ -1,12 +1,28 @@ #include "global.h" +#include "dungeon_global_data.h" #include "dungeon_pokemon_attributes_1.h" +#include "dungeon_util.h" +#include "pokemon.h" +#include "constants/dungeon.h" +#include "constants/iq_skill.h" +#include "constants/move_id.h" #include "constants/status.h" #include "constants/tactic.h" -extern bool8 IsIQSkillSet(u8 *, u32); +extern s16 gItemMasterMinWildLevel; + extern u8 HasItem(struct DungeonEntity *, u32); +extern bool8 IsIQSkillSet(u8 *, u32); +extern void SetIQSkill(u8 *param_1, u32 skillIndex); +extern bool8 HasIQForSkill(s32 pokeIQ, u8 IQSkillIndex); + +extern bool8 CanSee(struct DungeonEntity *, struct DungeonEntity *); + +extern u8 GetMoveType(struct PokemonMove *move); +extern s32 GetMovePower(struct PokemonMove *move); + bool8 CanSeeInvisible(struct DungeonEntity *pokemon) { struct DungeonEntityData *pokemonData = pokemon->entityData; @@ -32,12 +48,114 @@ bool8 HasTactic(struct DungeonEntity *pokemon, u8 tactic) return pokemonData->tactic == tactic; } -bool8 HasIQSkill(struct DungeonEntity* pokemon, u8 IQSkill) +bool8 HasIQSkill(struct DungeonEntity *pokemon, u8 IQSkill) { return IsIQSkillSet(pokemon->entityData->IQSkillsEnabled, 1 << IQSkill); } -bool8 HasIQSkillPair(struct DungeonEntity* pokemon, u8 IQSkill1, u8 IQSkill2) +bool8 HasIQSkillPair(struct DungeonEntity *pokemon, u8 IQSkill1, u8 IQSkill2) { return IsIQSkillSet(pokemon->entityData->IQSkillsEnabled, 1 << IQSkill1 | 1 << IQSkill2); } + +void LoadIQSkills(struct DungeonEntity *pokemon) +{ + u8 *iVar2; + s32 IQSkill; + struct DungeonEntityData *pokemonData; + + pokemonData = pokemon->entityData; + if (pokemonData->isEnemy) { + iVar2 = pokemonData->IQSkillsEnabled; + SetIQSkill(iVar2, IQ_SKILL_STATUS_CHECKER); + SetIQSkill(iVar2, IQ_SKILL_PP_CHECKER); + SetIQSkill(iVar2, IQ_SKILL_ITEM_CATCHER); + if (pokemonData->isBoss) + SetIQSkill(iVar2, IQ_SKILL_SELF_CURER); + if (pokemonData->level >= gItemMasterMinWildLevel) + SetIQSkill(iVar2, IQ_SKILL_ITEM_MASTER); + pokemonData->tactic = TACTIC_GO_AFTER_FOES; + } + else { + pokemonData->IQSkillsEnabled[0] = 0; + pokemonData->IQSkillsEnabled[1] = 0; + pokemonData->IQSkillsEnabled[2] = 0; + for(IQSkill = IQ_SKILL_TYPE_ADVANTAGE_MASTER; IQSkill < NUM_IQ_SKILLS; IQSkill++) + { + if (HasIQForSkill(pokemonData->IQ,IQSkill) && + IsIQSkillSet(pokemonData->IQSkillsSelected, 1 << IQSkill)) + { + SetIQSkill(pokemonData->IQSkillsEnabled,IQSkill); + } + } + } +} + +bool8 CanSeeTeammate(struct DungeonEntity * pokemon) +{ + struct DungeonEntity *teamMember; + s32 memberIdx; + + if (pokemon->entityData->isEnemy) { + return FALSE; + } + else + { + for(memberIdx = 0; memberIdx < MAX_TEAM_MEMBERS; memberIdx++) + { + teamMember = gDungeonGlobalData->teamPokemon[memberIdx]; + if (EntityExists(pokemon) && (pokemon != teamMember) && (CanSee(pokemon,teamMember))) + { + return TRUE; + } + } + return FALSE; + } +} + +u8 GetMoveType_2(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove) +{ + if(pokeMove->moveID == MOVE_HIDDEN_POWER) + return pokemon->entityData->hiddenPowerType; + else + return GetMoveType(pokeMove); +} + +s32 CalculateMovePower(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove) +{ + if(pokeMove->moveID == MOVE_HIDDEN_POWER) + return (pokemon->entityData->hiddenPowerPower + pokeMove->powerBoost); + else + return (GetMovePower(pokeMove) + pokeMove->powerBoost); +} + +bool8 ToolboxEnabled(struct DungeonEntityData *pokemon) +{ + if(!IsToolboxEnabled(pokemon->entityID)) + return FALSE; + return TRUE; +} + +static inline bool8 sub_8071A8C_sub(struct DungeonEntityData *pokemonData) +{ + if(pokemonData->joinLocation == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON || + pokemonData->joinLocation == DUNGEON_RESCUE_TEAM_BASE) + return TRUE; + else + return FALSE; +} + +bool8 sub_8071A8C(struct DungeonEntity *pokemon) +{ + struct DungeonEntityData *pokemonData; + if(EntityExists(pokemon)) + { + pokemonData = pokemon->entityData; + if(pokemonData->clientType != CLIENT_TYPE_CLIENT) + { + if(!sub_8071A8C_sub(pokemonData)) + return TRUE; + } + } + return FALSE; +} diff --git a/src/dungeon_random.c b/src/dungeon_random.c index 86b1c79..6f180d3 100644 --- a/src/dungeon_random.c +++ b/src/dungeon_random.c @@ -3,6 +3,11 @@ extern u32 gDungeonRngState; +void SetDungeonRNG(u32 value) +{ + gDungeonRngState = (value | 1); +} + s32 DungeonRandom(void) { gDungeonRngState = 1566083941 * gDungeonRngState + 1; diff --git a/src/dungeon_random_1.c b/src/dungeon_random_1.c index a6941f3..418a51c 100644 --- a/src/dungeon_random_1.c +++ b/src/dungeon_random_1.c @@ -11,3 +11,12 @@ bool8 RollPercentChance(s32 percentChance) } return FALSE; } + +bool8 RollPercentChance_2(s32 percentChance) +{ + if (DungeonRandomCapped(100) < percentChance) + { + return TRUE; + } + return FALSE; +} diff --git a/src/moves.c b/src/moves.c index 0f59f0b..e5998db 100644 --- a/src/moves.c +++ b/src/moves.c @@ -246,7 +246,7 @@ u8 GetMoveHitCount(struct PokemonMove *move) return gMovesData[move->moveID].hitCount; } -s16 GetMovePower(struct PokemonMove *move) +s32 GetMovePower(struct PokemonMove *move) { return gMovesData[move->moveID].power; } |