Merge pull request #207 from DizzyEggg/decompile_pokemon_123

Decompile and clean pokemon files
This commit is contained in:
Diegoisawesome
2018-02-11 22:13:15 -06:00
committed by GitHub
63 changed files with 6451 additions and 9732 deletions

View File

@@ -8,7 +8,6 @@
#include "random.h"
#include "util.h"
#include "constants/items.h"
#include "pokemon_item_effects.h"
extern const struct BattleMove gBattleMoves[];
extern const u8 gTypeEffectiveness[];

View File

@@ -26,7 +26,6 @@
#include "data2.h"
#include "battle_setup.h"
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;
extern struct MusicPlayerInfo gMPlayInfo_BGM;
@@ -34,7 +33,6 @@ extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct BattleMove gBattleMoves[];
extern const u8 gFacilityClassToPicIndex[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
@@ -1246,7 +1244,7 @@ static void LinkOpponentHandleDrawTrainerPic(void)
if (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER)
{
if (gActiveBattler == 1)
if (gActiveBattler == B_POSITION_OPPONENT_LEFT)
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A);
else
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B);
@@ -1256,18 +1254,18 @@ static void LinkOpponentHandleDrawTrainerPic(void)
if ((gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_FIRE_RED
|| (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_LEAF_GREEN)
{
if (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender != 0)
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_10];
if (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender != MALE)
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_LEAF];
else
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_9];
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_RED];
}
else if ((gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_RUBY
|| (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_SAPPHIRE)
{
if (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender != 0)
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_12];
if (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender != MALE)
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_RS_MAY];
else
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_11];
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_RS_BRENDAN];
}
else
{
@@ -1286,17 +1284,17 @@ static void LinkOpponentHandleDrawTrainerPic(void)
|| (gLinkPlayers[GetMultiplayerId() ^ BIT_SIDE].version & 0xFF) == VERSION_LEAF_GREEN)
{
if (gLinkPlayers[GetMultiplayerId() ^ BIT_SIDE].gender != 0)
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_10];
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_LEAF];
else
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_9];
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_RED];
}
else if ((gLinkPlayers[GetMultiplayerId() ^ BIT_SIDE].version & 0xFF) == VERSION_RUBY
|| (gLinkPlayers[GetMultiplayerId() ^ BIT_SIDE].version & 0xFF) == VERSION_SAPPHIRE)
{
if (gLinkPlayers[GetMultiplayerId() ^ BIT_SIDE].gender != 0)
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_12];
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_RS_MAY];
else
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_11];
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_RS_BRENDAN];
}
else
{

View File

@@ -25,7 +25,6 @@
#include "data2.h"
#include "battle_setup.h"
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;
extern struct UnusedControllerStruct gUnknown_02022D0C;

View File

@@ -29,7 +29,6 @@
#include "data2.h"
#include "battle_setup.h"
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;
extern struct MusicPlayerInfo gMPlayInfo_BGM;

View File

@@ -25,7 +25,6 @@
#include "battle_setup.h"
#include "item_use.h"
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;
extern struct UnusedControllerStruct gUnknown_02022D0C;

View File

@@ -27,7 +27,6 @@
#include "item_use.h"
#include "battle_setup.h"
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;
extern struct MusicPlayerInfo gMPlayInfo_BGM;

View File

@@ -25,7 +25,6 @@
#include "data2.h"
#include "item_use.h"
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];

View File

@@ -24,7 +24,6 @@
#include "item_use.h"
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;

View File

@@ -30,8 +30,6 @@
#include "battle_setup.h"
#include "item_use.h"
extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;
extern s32 gUnknown_0203CD70;

View File

@@ -39,7 +39,6 @@ extern const struct CompressedSpriteSheet gTrainerBackPicTable[];
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
extern const union AnimCmd* const * const gMonAnimationsSpriteAnimsPtrTable[];
extern const struct SpriteTemplate gUnknown_08329D98[4];
extern const struct CompressedSpriteSheet gSpriteSheet_EnemyShadow;
extern const struct SpriteTemplate gSpriteTemplate_EnemyShadow;
extern const u8 gEnemyMonElevation[];

View File

@@ -51,7 +51,7 @@
#include "international_string_util.h"
#include "pokeball.h"
struct UnknownPokemonStruct2
struct UnknownPokemonStruct4
{
/*0x00*/ u16 species;
/*0x02*/ u16 heldItem;
@@ -86,7 +86,6 @@ extern const u16 gBattleTextboxPalette[]; // battle textbox palette
extern const struct BgTemplate gUnknown_0831AA08[];
extern const struct WindowTemplate * const gUnknown_0831ABA0[];
extern const u8 gUnknown_0831ACE0[];
extern const u8 gStatStageRatios[][2];
extern const u8 * const gBattleScriptsForMoveEffects[];
extern const u8 * const gBattlescriptsForBallThrow[];
extern const u8 * const gBattlescriptsForRunningByItem[];
@@ -199,8 +198,8 @@ EWRAM_DATA static u32 sUnusedUnknownArray[25] = {0};
EWRAM_DATA u32 gBattleTypeFlags = 0;
EWRAM_DATA u8 gBattleTerrain = 0;
EWRAM_DATA u32 gUnknown_02022FF4 = 0;
EWRAM_DATA struct UnknownPokemonStruct2 gUnknown_02022FF8[3] = {0}; // what is it used for?
EWRAM_DATA struct UnknownPokemonStruct2* gUnknown_02023058 = NULL; // what is it used for?
EWRAM_DATA struct UnknownPokemonStruct4 gUnknown_02022FF8[3] = {0}; // what is it used for?
EWRAM_DATA struct UnknownPokemonStruct4* gUnknown_02023058 = NULL; // what is it used for?
EWRAM_DATA u8 *gUnknown_0202305C = NULL;
EWRAM_DATA u8 *gUnknown_02023060 = NULL;
EWRAM_DATA u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200] = {0};
@@ -791,7 +790,7 @@ static void CB2_HandleStartBattle(void)
gTasks[taskId].data[4] = gBlockRecvBuffer[enemyMultiplayerId][1];
sub_8185F90(gBlockRecvBuffer[playerMultiplayerId][1]);
sub_8185F90(gBlockRecvBuffer[enemyMultiplayerId][1]);
sub_8068AA4();
SetDeoxysStats();
gBattleCommunication[MULTIUSE_STATE]++;
}
break;
@@ -1203,9 +1202,9 @@ static void CB2_PreInitMultiBattle(void)
case 0:
if (gReceivedRemoteLinkPlayers != 0 && sub_800A520())
{
gUnknown_02023058 = Alloc(sizeof(struct UnknownPokemonStruct2) * 3);
gUnknown_02023058 = Alloc(sizeof(struct UnknownPokemonStruct4) * 3);
sub_80379F8(0);
SendBlock(bitmask_all_link_players_but_self(), gUnknown_02023058, sizeof(struct UnknownPokemonStruct2) * 3);
SendBlock(bitmask_all_link_players_but_self(), gUnknown_02023058, sizeof(struct UnknownPokemonStruct4) * 3);
gBattleCommunication[MULTIUSE_STATE]++;
}
break;
@@ -1223,12 +1222,12 @@ static void CB2_PreInitMultiBattle(void)
if ((!(gLinkPlayers[i].lp_field_18 & 1) && !(gLinkPlayers[playerMultiplierId].lp_field_18 & 1))
|| (gLinkPlayers[i].lp_field_18 & 1 && gLinkPlayers[playerMultiplierId].lp_field_18 & 1))
{
memcpy(gUnknown_02022FF8, gBlockRecvBuffer[i], sizeof(struct UnknownPokemonStruct2) * 3);
memcpy(gUnknown_02022FF8, gBlockRecvBuffer[i], sizeof(struct UnknownPokemonStruct4) * 3);
}
}
else
{
memcpy(gUnknown_02022FF8, gBlockRecvBuffer[i], sizeof(struct UnknownPokemonStruct2) * 3);
memcpy(gUnknown_02022FF8, gBlockRecvBuffer[i], sizeof(struct UnknownPokemonStruct4) * 3);
}
}
gBattleCommunication[MULTIUSE_STATE]++;
@@ -1287,7 +1286,7 @@ static void CB2_PreInitIngamePlayerPartnerBattle(void)
switch (gBattleCommunication[MULTIUSE_STATE])
{
case 0:
gUnknown_02023058 = Alloc(sizeof(struct UnknownPokemonStruct2) * 3);
gUnknown_02023058 = Alloc(sizeof(struct UnknownPokemonStruct4) * 3);
sub_80379F8(3);
gBattleCommunication[MULTIUSE_STATE]++;
*savedCallback = gMain.savedCallback;
@@ -1370,7 +1369,7 @@ static void CB2_HandleStartMultiBattle(void)
ResetBlockReceivedFlags();
sub_8036EB8(4, playerMultiplayerId);
SetAllPlayersBerryData();
sub_8068AA4();
SetDeoxysStats();
var = CreateTask(sub_8035D74, 0);
gTasks[var].data[1] = 0x10E;
gTasks[var].data[2] = 0x5A;

View File

@@ -1968,7 +1968,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
break;
case B_TXT_TRAINER1_CLASS: // trainer class name
if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE)
toCpy = gTrainerClassNames[GetSecretBaseTrainerNameIndex()];
toCpy = gTrainerClassNames[GetSecretBaseTrainerClass()];
else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_C00)
toCpy = gTrainerClassNames[sub_8068BB0()];
else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_3FE)

View File

@@ -12,7 +12,6 @@
#include "constants/hold_effects.h"
#include "util.h"
#include "pokemon.h"
#include "calculate_base_damage.h"
#include "random.h"
#include "battle_controllers.h"
#include "battle_interface.h"
@@ -32,7 +31,6 @@
#include "bg.h"
#include "string_util.h"
#include "pokemon_icon.h"
#include "pokemon_item_effects.h"
#include "m4a.h"
#include "mail.h"
#include "event_data.h"
@@ -6882,8 +6880,7 @@ static void atk74_hpthresholds2(void)
static void atk75_useitemonopponent(void)
{
gBattlerInMenuId = gBattlerAttacker;
ExecuteTableBasedItemEffect(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]], gLastUsedItem, gBattlerPartyIndexes[gBattlerAttacker], 0, 1);
PokemonUseItemEffects(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]], gLastUsedItem, gBattlerPartyIndexes[gBattlerAttacker], 0, 1);
gBattlescriptCurrInstr += 1;
}

View File

@@ -5,7 +5,6 @@
#include "battle_transition.h"
#include "main.h"
#include "task.h"
#include "pokemon_3.h"
#include "safari_zone.h"
#include "script.h"
#include "constants/game_stat.h"

View File

@@ -20,7 +20,6 @@
#include "battle_ai_script_commands.h"
#include "battle_controllers.h"
#include "event_data.h"
#include "calculate_base_damage.h"
#include "link.h"
#include "berry.h"

View File

@@ -1,275 +0,0 @@
#include "global.h"
#include "constants/abilities.h"
#include "battle.h"
#include "battle_setup.h"
#include "constants/hold_effects.h"
#include "event_data.h"
#include "item.h"
#include "constants/items.h"
#include "pokemon.h"
#include "constants/species.h"
#include "constants/moves.h"
#include "constants/battle_move_effects.h"
bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 bank);
extern const struct BattleMove gBattleMoves[];
extern const u8 gHoldEffectToType[][2];
extern const u8 gStatStageRatios[][2];
#define APPLY_STAT_MOD(var, mon, stat, statIndex) \
{ \
(var) = (stat) * (gStatStageRatios)[(mon)->statStages[(statIndex)]][0]; \
(var) /= (gStatStageRatios)[(mon)->statStages[(statIndex)]][1]; \
}
s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 sideStatus, u16 powerOverride, u8 typeOverride, u8 bankAtk, u8 bankDef)
{
u32 i;
s32 damage = 0;
s32 damageHelper;
u8 type;
u16 attack, defense;
u16 spAttack, spDefense;
u8 defenderHoldEffect;
u8 defenderHoldEffectParam;
u8 attackerHoldEffect;
u8 attackerHoldEffectParam;
if (!powerOverride)
gBattleMovePower = gBattleMoves[move].power;
else
gBattleMovePower = powerOverride;
if (!typeOverride)
type = gBattleMoves[move].type;
else
type = typeOverride & 0x3F;
attack = attacker->attack;
defense = defender->defense;
spAttack = attacker->spAttack;
spDefense = defender->spDefense;
if (attacker->item == ITEM_ENIGMA_BERRY)
{
attackerHoldEffect = gEnigmaBerries[bankAtk].holdEffect;
attackerHoldEffectParam = gEnigmaBerries[bankAtk].holdEffectParam;
}
else
{
attackerHoldEffect = ItemId_GetHoldEffect(attacker->item);
attackerHoldEffectParam = ItemId_GetHoldEffectParam(attacker->item);
}
if (defender->item == ITEM_ENIGMA_BERRY)
{
defenderHoldEffect = gEnigmaBerries[bankDef].holdEffect;
defenderHoldEffectParam = gEnigmaBerries[bankDef].holdEffectParam;
}
else
{
defenderHoldEffect = ItemId_GetHoldEffect(defender->item);
defenderHoldEffectParam = ItemId_GetHoldEffectParam(defender->item);
}
if (attacker->ability == ABILITY_HUGE_POWER || attacker->ability == ABILITY_PURE_POWER)
attack *= 2;
if (ShouldGetStatBadgeBoost(FLAG_BADGE01_GET, bankAtk))
attack = (110 * attack) / 100;
if (ShouldGetStatBadgeBoost(FLAG_BADGE05_GET, bankDef))
defense = (110 * defense) / 100;
if (ShouldGetStatBadgeBoost(FLAG_BADGE07_GET, bankAtk))
spAttack = (110 * spAttack) / 100;
if (ShouldGetStatBadgeBoost(FLAG_BADGE07_GET, bankDef))
spDefense = (110 * spDefense) / 100;
for (i = 0; i < 17; i++)
{
if (attackerHoldEffect == gHoldEffectToType[i][0]
&& type == gHoldEffectToType[i][1])
{
if (type <= 8)
attack = (attack * (attackerHoldEffectParam + 100)) / 100;
else
spAttack = (spAttack * (attackerHoldEffectParam + 100)) / 100;
break;
}
}
if (attackerHoldEffect == HOLD_EFFECT_CHOICE_BAND)
attack = (150 * attack) / 100;
if (attackerHoldEffect == HOLD_EFFECT_SOUL_DEW && !(gBattleTypeFlags & (BATTLE_TYPE_FRONTIER)) && (attacker->species == SPECIES_LATIAS || attacker->species == SPECIES_LATIOS))
spAttack = (150 * spAttack) / 100;
if (defenderHoldEffect == HOLD_EFFECT_SOUL_DEW && !(gBattleTypeFlags & (BATTLE_TYPE_FRONTIER)) && (defender->species == SPECIES_LATIAS || defender->species == SPECIES_LATIOS))
spDefense = (150 * spDefense) / 100;
if (attackerHoldEffect == HOLD_EFFECT_DEEP_SEA_TOOTH && attacker->species == SPECIES_CLAMPERL)
spAttack *= 2;
if (defenderHoldEffect == HOLD_EFFECT_DEEP_SEA_SCALE && defender->species == SPECIES_CLAMPERL)
spDefense *= 2;
if (attackerHoldEffect == HOLD_EFFECT_LIGHT_BALL && attacker->species == SPECIES_PIKACHU)
spAttack *= 2;
if (defenderHoldEffect == HOLD_EFFECT_METAL_POWDER && defender->species == SPECIES_DITTO)
defense *= 2;
if (attackerHoldEffect == HOLD_EFFECT_THICK_CLUB && (attacker->species == SPECIES_CUBONE || attacker->species == SPECIES_MAROWAK))
attack *= 2;
if (defender->ability == ABILITY_THICK_FAT && (type == TYPE_FIRE || type == TYPE_ICE))
spAttack /= 2;
if (attacker->ability == ABILITY_HUSTLE)
attack = (150 * attack) / 100;
if (attacker->ability == ABILITY_PLUS && AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_MINUS, 0, 0))
spAttack = (150 * spAttack) / 100;
if (attacker->ability == ABILITY_MINUS && AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_PLUS, 0, 0))
spAttack = (150 * spAttack) / 100;
if (attacker->ability == ABILITY_GUTS && attacker->status1)
attack = (150 * attack) / 100;
if (defender->ability == ABILITY_MARVEL_SCALE && defender->status1)
defense = (150 * defense) / 100;
if (type == TYPE_ELECTRIC && AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, 0, 0xFD, 0))
gBattleMovePower /= 2;
if (type == TYPE_FIRE && AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, 0, 0xFE, 0))
gBattleMovePower /= 2;
if (type == TYPE_GRASS && attacker->ability == ABILITY_OVERGROW && attacker->hp <= (attacker->maxHP / 3))
gBattleMovePower = (150 * gBattleMovePower) / 100;
if (type == TYPE_FIRE && attacker->ability == ABILITY_BLAZE && attacker->hp <= (attacker->maxHP / 3))
gBattleMovePower = (150 * gBattleMovePower) / 100;
if (type == TYPE_WATER && attacker->ability == ABILITY_TORRENT && attacker->hp <= (attacker->maxHP / 3))
gBattleMovePower = (150 * gBattleMovePower) / 100;
if (type == TYPE_BUG && attacker->ability == ABILITY_SWARM && attacker->hp <= (attacker->maxHP / 3))
gBattleMovePower = (150 * gBattleMovePower) / 100;
if (gBattleMoves[gCurrentMove].effect == EFFECT_EXPLOSION)
defense /= 2;
if (IS_MOVE_PHYSICAL(type))
{
if (gCritMultiplier == 2)
{
if (attacker->statStages[STAT_ATK] > 6)
APPLY_STAT_MOD(damage, attacker, attack, STAT_ATK)
else
damage = attack;
}
else
APPLY_STAT_MOD(damage, attacker, attack, STAT_ATK)
damage = damage * gBattleMovePower;
damage *= (2 * attacker->level / 5 + 2);
if (gCritMultiplier == 2)
{
if (defender->statStages[STAT_DEF] < 6)
APPLY_STAT_MOD(damageHelper, defender, defense, STAT_DEF)
else
damageHelper = defense;
}
else
APPLY_STAT_MOD(damageHelper, defender, defense, STAT_DEF)
damage = damage / damageHelper;
damage /= 50;
if ((attacker->status1 & STATUS1_BURN) && attacker->ability != ABILITY_GUTS)
damage /= 2;
if ((sideStatus & SIDE_STATUS_REFLECT) && gCritMultiplier == 1)
{
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMonsInBattle(2) == 2)
damage = 2 * (damage / 3);
else
damage /= 2;
}
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMonsInBattle(2) == 2)
damage /= 2;
// moves always do at least 1 damage.
if (damage == 0)
damage = 1;
}
if (type == TYPE_MYSTERY)
damage = 0; // is ??? type. does 0 damage.
if (IS_MOVE_SPECIAL(type))
{
if (gCritMultiplier == 2)
{
if (attacker->statStages[STAT_SPATK] > 6)
APPLY_STAT_MOD(damage, attacker, spAttack, STAT_SPATK)
else
damage = spAttack;
}
else
APPLY_STAT_MOD(damage, attacker, spAttack, STAT_SPATK)
damage = damage * gBattleMovePower;
damage *= (2 * attacker->level / 5 + 2);
if (gCritMultiplier == 2)
{
if (defender->statStages[STAT_SPDEF] < 6)
APPLY_STAT_MOD(damageHelper, defender, spDefense, STAT_SPDEF)
else
damageHelper = spDefense;
}
else
APPLY_STAT_MOD(damageHelper, defender, spDefense, STAT_SPDEF)
damage = (damage / damageHelper);
damage /= 50;
if ((sideStatus & SIDE_STATUS_LIGHTSCREEN) && gCritMultiplier == 1)
{
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMonsInBattle(2) == 2)
damage = 2 * (damage / 3);
else
damage /= 2;
}
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMonsInBattle(2) == 2)
damage /= 2;
// are effects of weather negated with cloud nine or air lock
if (!AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_CLOUD_NINE, 0, 0)
&& !AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_AIR_LOCK, 0, 0))
{
if (gBattleWeather & WEATHER_RAIN_TEMPORARY)
{
switch (type)
{
case TYPE_FIRE:
damage /= 2;
break;
case TYPE_WATER:
damage = (15 * damage) / 10;
break;
}
}
// any weather except sun weakens solar beam
if ((gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_HAIL)) && gCurrentMove == MOVE_SOLAR_BEAM)
damage /= 2;
// sunny
if (gBattleWeather & WEATHER_SUN_ANY)
{
switch (type)
{
case TYPE_FIRE:
damage = (15 * damage) / 10;
break;
case TYPE_WATER:
damage /= 2;
break;
}
}
}
// flash fire triggered
if ((gBattleResources->flags->flags[bankAtk] & UNKNOWN_FLAG_FLASH_FIRE) && type == TYPE_FIRE)
damage = (15 * damage) / 10;
}
return damage + 2;
}

View File

@@ -44,7 +44,6 @@ struct EggHatchData
u8 textColor[3];
};
extern struct SpriteTemplate gUnknown_0202499C;
extern void (*gFieldCallback)(void);
extern const struct CompressedSpriteSheet gMonFrontPicTable[];
@@ -434,12 +433,12 @@ static u8 EggHatchCreateMonSprite(u8 a0, u8 switchID, u8 pokeID, u16* speciesLoc
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species],
gMonSpritesGfxPtr->sprites[(a0 * 2) + 1],
species, pid);
LoadCompressedObjectPalette(sub_806E794(mon));
LoadCompressedObjectPalette(GetMonSpritePalStruct(mon));
*speciesLoc = species;
}
break;
case 1:
sub_806A068(sub_806E794(mon)->tag, r5);
sub_806A068(GetMonSpritePalStruct(mon)->tag, r5);
spriteID = CreateSprite(&gUnknown_0202499C, 120, 75, 6);
gSprites[spriteID].invisible = 1;
gSprites[spriteID].callback = SpriteCallbackDummy;

View File

@@ -48,7 +48,6 @@ extern u16 gBattle_BG2_X;
extern u16 gBattle_BG2_Y;
extern u16 gBattle_BG3_X;
extern u16 gBattle_BG3_Y;
extern struct SpriteTemplate gUnknown_0202499C;
extern bool8 gAffineAnimsDisabled;
extern u16 gMoveToLearn;
extern const u8 gSpeciesNames[][11];

View File

@@ -87,7 +87,6 @@ extern void sub_81ABA88(u8);
extern void sub_80B7CC8(void);
extern void flagmods_08054D70(void);
extern u8* sub_806CF78(u16);
extern bool8 ExecuteTableBasedItemEffect_(struct Pokemon*, u16, u8, u8);
extern void sub_81B89F0(void);
extern u8 GetItemEffectType(u16);
extern struct MapConnection *sub_8088A8C(s16, s16);
@@ -984,7 +983,7 @@ void ItemUseInBattle_StatIncrease(u8 taskId)
{
u16 partyId = gBattlerPartyIndexes[gBattlerInMenuId];
if (ExecuteTableBasedItemEffect_(&gPlayerParty[partyId], gSpecialVar_ItemId, partyId, 0) != FALSE)
if (ExecuteTableBasedItemEffect(&gPlayerParty[partyId], gSpecialVar_ItemId, partyId, 0) != FALSE)
{
if (!InBattlePyramid())
DisplayItemMessage(taskId, 1, gText_WontHaveEffect, bag_menu_inits_lists_menu);

View File

@@ -50,7 +50,6 @@ struct PokeblockFeedStruct
extern u16 gSpecialVar_ItemId;
extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern struct SpriteTemplate gUnknown_0202499C;
extern const u8 gBattleTerrainPalette_Frontier[];
extern const u8 gBattleTerrainTiles_Building[];
@@ -837,7 +836,7 @@ static u8 CreateMonSprite(struct Pokemon* mon)
gSprites[spriteId].callback = SpriteCallbackDummy;
sPokeblockFeed->noMonFlip = TRUE;
if (!IsPokeSpriteNotFlipped(species))
if (!IsMonSpriteNotFlipped(species))
{
gSprites[spriteId].affineAnims = sSpriteAffineAnimTable_MonNoFlip;
gSprites[spriteId].oam.affineMode = 3;

6094
src/pokemon.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,457 +0,0 @@
#include "global.h"
#include "pokemon.h"
#include "random.h"
#include "main.h"
#include "constants/species.h"
#include "constants/abilities.h"
#include "constants/items.h"
#include "constants/trainers.h"
#include "constants/moves.h"
#include "string_util.h"
#include "text.h"
//Extracts the upper 16 bits of a 32-bit number
#define HIHALF(n) (((n) & 0xFFFF0000) >> 16)
//Extracts the lower 16 bits of a 32-bit number
#define LOHALF(n) ((n) & 0xFFFF)
extern u8 sav1_map_get_name(void);
// EWRAM vars
EWRAM_DATA u8 sLearningMoveTableID = 0;
EWRAM_DATA u8 gPlayerPartyCount = 0;
EWRAM_DATA u8 gEnemyPartyCount = 0;
EWRAM_DATA struct Pokemon gPlayerParty[PARTY_SIZE] = {0};
EWRAM_DATA struct Pokemon gEnemyParty[PARTY_SIZE] = {0};
// const rom data
const u16 gSpeciesToHoennPokedexNum[] = {203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 156, 157, 112, 113, 227, 228, 229, 230, 231, 232, 233, 234, 153, 154, 138, 139, 63, 64, 88, 89, 90, 235, 236, 237, 238, 239, 240, 241, 242, 158, 159, 243, 244, 245, 246, 247, 248, 249, 39, 40, 41, 73, 74, 75, 250, 251, 252, 66, 67, 57, 58, 59, 253, 254, 255, 256, 82, 83, 257, 92, 93, 258, 259, 106, 107, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 84, 85, 270, 271, 272, 273, 274, 275, 276, 108, 109, 169, 170, 277, 278, 279, 184, 185, 50, 51, 143, 144, 280, 281, 282, 283, 284, 167, 285, 52, 53, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 65, 181, 182, 155, 324, 137, 325, 326, 162, 163, 327, 328, 329, 91, 55, 56, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 161, 164, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 168, 357, 358, 359, 103, 104, 360, 361, 180, 362, 363, 364, 365, 115, 366, 367, 186, 165, 166, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 42, 43, 44, 25, 26, 34, 35, 114, 27, 28, 32, 33, 99, 100, 61, 62, 145, 131, 132, 60, 105, 68, 127, 128, 183, 129, 130, 140, 141, 97, 98, 116, 117, 118, 48, 49, 78, 79, 101, 102, 173, 174, 175, 119, 120, 171, 172, 125, 126, 54, 110, 111, 80, 81, 69, 76, 77, 121, 122, 160, 148, 149, 94, 36, 37, 38, 95, 96, 150, 45, 46, 47, 176, 177, 178, 152, 146, 147, 124, 123, 179, 70, 71, 72, 142, 86, 87, 133, 134, 135, 136, 29, 30, 31, 187, 188, 189, 190, 191, 192, 193, 194, 195, 198, 199, 200, 196, 197, 201, 202, 151};
const u16 gSpeciesToNationalPokedexNum[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 290, 291, 292, 276, 277, 285, 286, 327, 278, 279, 283, 284, 320, 321, 300, 301, 352, 343, 344, 299, 324, 302, 339, 340, 370, 341, 342, 349, 350, 318, 319, 328, 329, 330, 296, 297, 309, 310, 322, 323, 363, 364, 365, 331, 332, 361, 362, 337, 338, 298, 325, 326, 311, 312, 303, 307, 308, 333, 334, 360, 355, 356, 315, 287, 288, 289, 316, 317, 357, 293, 294, 295, 366, 367, 368, 359, 353, 354, 336, 335, 369, 304, 305, 306, 351, 313, 314, 345, 346, 347, 348, 280, 281, 282, 371, 372, 373, 374, 375, 376, 377, 378, 379, 382, 383, 384, 380, 381, 385, 386, 358};
const u16 gHoennToNationalOrder[] = {252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 63, 64, 65, 290, 291, 292, 293, 294, 295, 296, 297, 118, 119, 129, 130, 298, 183, 184, 74, 75, 76, 299, 300, 301, 41, 42, 169, 72, 73, 302, 303, 304, 305, 306, 66, 67, 68, 307, 308, 309, 310, 311, 312, 81, 82, 100, 101, 313, 314, 43, 44, 45, 182, 84, 85, 315, 316, 317, 318, 319, 320, 321, 322, 323, 218, 219, 324, 88, 89, 109, 110, 325, 326, 27, 28, 327, 227, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 174, 39, 40, 349, 350, 351, 120, 121, 352, 353, 354, 355, 356, 357, 358, 359, 37, 38, 172, 25, 26, 54, 55, 360, 202, 177, 178, 203, 231, 232, 127, 214, 111, 112, 361, 362, 363, 364, 365, 366, 367, 368, 369, 222, 170, 171, 370, 116, 117, 230, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 29, 30, 31, 32, 33, 34, 35, 36, 46, 47, 48, 49, 50, 51, 52, 53, 56, 57, 58, 59, 60, 61, 62, 69, 70, 71, 77, 78, 79, 80, 83, 86, 87, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 102, 103, 104, 105, 106, 107, 108, 113, 114, 115, 122, 123, 124, 125, 126, 128, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 173, 175, 176, 179, 180, 181, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 215, 216, 217, 220, 221, 223, 224, 225, 226, 228, 229, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411};
const struct SpindaSpot gSpindaSpotGraphics[] =
{
{16, 7, INCBIN_U16("graphics/spinda_spots/spot_0.bin")},
{40, 8, INCBIN_U16("graphics/spinda_spots/spot_1.bin")},
{22, 25, INCBIN_U16("graphics/spinda_spots/spot_2.bin")},
{34, 26, INCBIN_U16("graphics/spinda_spots/spot_3.bin")}
};
#include "data/pokemon/item_effects.h"
const s8 gNatureStatTable[][5] =
{
// Atk Def Spd Sp.Atk Sp.Def
{ 0, 0, 0, 0, 0}, // Hardy
{ +1, -1, 0, 0, 0}, // Lonely
{ +1, 0, -1, 0, 0}, // Brave
{ +1, 0, 0, -1, 0}, // Adamant
{ +1, 0, 0, 0, -1}, // Naughty
{ -1, +1, 0, 0, 0}, // Bold
{ 0, 0, 0, 0, 0}, // Docile
{ 0, +1, -1, 0, 0}, // Relaxed
{ 0, +1, 0, -1, 0}, // Impish
{ 0, +1, 0, 0, -1}, // Lax
{ -1, 0, +1, 0, 0}, // Timid
{ 0, -1, +1, 0, 0}, // Hasty
{ 0, 0, 0, 0, 0}, // Serious
{ 0, 0, +1, -1, 0}, // Jolly
{ 0, 0, +1, 0, -1}, // Naive
{ -1, 0, 0, +1, 0}, // Modest
{ 0, -1, 0, +1, 0}, // Mild
{ 0, 0, -1, +1, 0}, // Quiet
{ 0, 0, 0, 0, 0}, // Bashful
{ 0, 0, 0, +1, -1}, // Rash
{ -1, 0, 0, 0, +1}, // Calm
{ 0, -1, 0, 0, +1}, // Gentle
{ 0, 0, -1, 0, +1}, // Sassy
{ 0, 0, 0, -1, +1}, // Careful
{ 0, 0, 0, 0, 0}, // Quirky
};
#include "data/pokemon/tmhm_learnsets.h"
#include "data/pokemon/trainer_class_lookups.h"
#include "data/pokemon/cry_ids.h"
#include "data/pokemon/experience_tables.h"
#include "data/pokemon/base_stats.h"
#include "data/pokemon/level_up_learnsets.h"
#include "data/pokemon/evolution.h"
#include "data/pokemon/level_up_learnset_pointers.h"
// code
void ZeroBoxMonData(struct BoxPokemon *boxMon)
{
u8 *raw = (u8 *)boxMon;
u32 i;
for (i = 0; i < sizeof(struct BoxPokemon); i++)
raw[i] = 0;
}
void ZeroMonData(struct Pokemon *mon)
{
u32 arg;
ZeroBoxMonData(&mon->box);
arg = 0;
SetMonData(mon, MON_DATA_STATUS, &arg);
SetMonData(mon, MON_DATA_LEVEL, &arg);
SetMonData(mon, MON_DATA_HP, &arg);
SetMonData(mon, MON_DATA_MAX_HP, &arg);
SetMonData(mon, MON_DATA_ATK, &arg);
SetMonData(mon, MON_DATA_DEF, &arg);
SetMonData(mon, MON_DATA_SPEED, &arg);
SetMonData(mon, MON_DATA_SPATK, &arg);
SetMonData(mon, MON_DATA_SPDEF, &arg);
arg = 255;
SetMonData(mon, MON_DATA_MAIL, &arg);
}
void ZeroPlayerPartyMons(void)
{
s32 i;
for (i = 0; i < PARTY_SIZE; i++)
ZeroMonData(&gPlayerParty[i]);
}
void ZeroEnemyPartyMons(void)
{
s32 i;
for (i = 0; i < PARTY_SIZE; i++)
ZeroMonData(&gEnemyParty[i]);
}
void CreateMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId)
{
u32 arg;
ZeroMonData(mon);
CreateBoxMon(&mon->box, species, level, fixedIV, hasFixedPersonality, fixedPersonality, otIdType, fixedOtId);
SetMonData(mon, MON_DATA_LEVEL, &level);
arg = 255;
SetMonData(mon, MON_DATA_MAIL, &arg);
CalculateMonStats(mon);
}
void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId)
{
u8 speciesName[POKEMON_NAME_LENGTH + 1];
u32 personality;
u32 value;
u16 checksum;
ZeroBoxMonData(boxMon);
if (hasFixedPersonality)
personality = fixedPersonality;
else
personality = Random32();
SetBoxMonData(boxMon, MON_DATA_PERSONALITY, &personality);
//Determine original trainer ID
if (otIdType == OT_ID_RANDOM_NO_SHINY) //Pokemon cannot be shiny
{
u32 shinyValue;
do
{
value = Random32();
shinyValue = HIHALF(value) ^ LOHALF(value) ^ HIHALF(personality) ^ LOHALF(personality);
} while (shinyValue < 8);
}
else if (otIdType == OT_ID_PRESET) //Pokemon has a preset OT ID
{
value = fixedOtId;
}
else //Player is the OT
{
value = gSaveBlock2Ptr->playerTrainerId[0]
| (gSaveBlock2Ptr->playerTrainerId[1] << 8)
| (gSaveBlock2Ptr->playerTrainerId[2] << 16)
| (gSaveBlock2Ptr->playerTrainerId[3] << 24);
}
SetBoxMonData(boxMon, MON_DATA_OT_ID, &value);
checksum = CalculateBoxMonChecksum(boxMon);
SetBoxMonData(boxMon, MON_DATA_CHECKSUM, &checksum);
EncryptBoxMon(boxMon);
GetSpeciesName(speciesName, species);
SetBoxMonData(boxMon, MON_DATA_NICKNAME, speciesName);
SetBoxMonData(boxMon, MON_DATA_LANGUAGE, &gGameLanguage);
SetBoxMonData(boxMon, MON_DATA_OT_NAME, gSaveBlock2Ptr->playerName);
SetBoxMonData(boxMon, MON_DATA_SPECIES, &species);
SetBoxMonData(boxMon, MON_DATA_EXP, &gExperienceTables[gBaseStats[species].growthRate][level]);
SetBoxMonData(boxMon, MON_DATA_FRIENDSHIP, &gBaseStats[species].friendship);
value = sav1_map_get_name();
SetBoxMonData(boxMon, MON_DATA_MET_LOCATION, &value);
SetBoxMonData(boxMon, MON_DATA_MET_LEVEL, &level);
SetBoxMonData(boxMon, MON_DATA_MET_GAME, &gGameVersion);
value = ITEM_POKE_BALL;
SetBoxMonData(boxMon, MON_DATA_POKEBALL, &value);
SetBoxMonData(boxMon, MON_DATA_OT_GENDER, &gSaveBlock2Ptr->playerGender);
if (fixedIV < 32)
{
SetBoxMonData(boxMon, MON_DATA_HP_IV, &fixedIV);
SetBoxMonData(boxMon, MON_DATA_ATK_IV, &fixedIV);
SetBoxMonData(boxMon, MON_DATA_DEF_IV, &fixedIV);
SetBoxMonData(boxMon, MON_DATA_SPEED_IV, &fixedIV);
SetBoxMonData(boxMon, MON_DATA_SPATK_IV, &fixedIV);
SetBoxMonData(boxMon, MON_DATA_SPDEF_IV, &fixedIV);
}
else
{
u32 iv;
value = Random();
iv = value & 0x1F;
SetBoxMonData(boxMon, MON_DATA_HP_IV, &iv);
iv = (value & 0x3E0) >> 5;
SetBoxMonData(boxMon, MON_DATA_ATK_IV, &iv);
iv = (value & 0x7C00) >> 10;
SetBoxMonData(boxMon, MON_DATA_DEF_IV, &iv);
value = Random();
iv = value & 0x1F;
SetBoxMonData(boxMon, MON_DATA_SPEED_IV, &iv);
iv = (value & 0x3E0) >> 5;
SetBoxMonData(boxMon, MON_DATA_SPATK_IV, &iv);
iv = (value & 0x7C00) >> 10;
SetBoxMonData(boxMon, MON_DATA_SPDEF_IV, &iv);
}
if (gBaseStats[species].ability2)
{
value = personality & 1;
SetBoxMonData(boxMon, MON_DATA_ALT_ABILITY, &value);
}
GiveBoxMonInitialMoveset(boxMon);
}
void CreateMonWithNature(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 nature)
{
u32 personality;
do
{
personality = Random32();
}
while (nature != GetNatureFromPersonality(personality));
CreateMon(mon, species, level, fixedIV, 1, personality, OT_ID_PLAYER_ID, 0);
}
void CreateMonWithGenderNatureLetter(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 gender, u8 nature, u8 unownLetter)
{
u32 personality;
if ((u8)(unownLetter - 1) < 28)
{
u16 actualLetter;
do
{
personality = Random32();
actualLetter = ((((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 0x3)) % 28);
}
while (nature != GetNatureFromPersonality(personality)
|| gender != GetGenderFromSpeciesAndPersonality(species, personality)
|| actualLetter != unownLetter - 1);
}
else
{
do
{
personality = Random32();
}
while (nature != GetNatureFromPersonality(personality)
|| gender != GetGenderFromSpeciesAndPersonality(species, personality));
}
CreateMon(mon, species, level, fixedIV, 1, personality, OT_ID_PLAYER_ID, 0);
}
// This is only used to create Wally's Ralts.
void CreateMaleMon(struct Pokemon *mon, u16 species, u8 level)
{
u32 personality;
u32 otId;
do
{
otId = Random32();
personality = Random32();
}
while (GetGenderFromSpeciesAndPersonality(species, personality) != MON_MALE);
CreateMon(mon, species, level, 32, 1, personality, OT_ID_PRESET, otId);
}
void CreateMonWithIVsPersonality(struct Pokemon *mon, u16 species, u8 level, u32 ivs, u32 personality)
{
CreateMon(mon, species, level, 0, 1, personality, OT_ID_PLAYER_ID, 0);
SetMonData(mon, MON_DATA_IVS, &ivs);
CalculateMonStats(mon);
}
void CreateMonWithIVsOTID(struct Pokemon *mon, u16 species, u8 level, u8 *ivs, u32 otId)
{
CreateMon(mon, species, level, 0, 0, 0, OT_ID_PRESET, otId);
SetMonData(mon, MON_DATA_HP_IV, &ivs[0]);
SetMonData(mon, MON_DATA_ATK_IV, &ivs[1]);
SetMonData(mon, MON_DATA_DEF_IV, &ivs[2]);
SetMonData(mon, MON_DATA_SPEED_IV, &ivs[3]);
SetMonData(mon, MON_DATA_SPATK_IV, &ivs[4]);
SetMonData(mon, MON_DATA_SPDEF_IV, &ivs[5]);
CalculateMonStats(mon);
}
void CreateMonWithEVSpread(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 evSpread)
{
s32 i;
s32 statCount = 0;
u16 evAmount;
u8 temp;
CreateMon(mon, species, level, fixedIV, 0, 0, 0, 0);
temp = evSpread;
for (i = 0; i < 6; i++)
{
if (temp & 1)
statCount++;
temp >>= 1;
}
evAmount = 510 / statCount;
temp = 1;
for (i = 0; i < 6; i++)
{
if (evSpread & temp)
SetMonData(mon, MON_DATA_HP_EV + i, &evAmount);
temp <<= 1;
}
CalculateMonStats(mon);
}
void sub_806819C(struct Pokemon *mon, struct UnknownPokemonStruct *src)
{
s32 i;
u8 nickname[30];
u8 language;
u8 value;
CreateMon(mon, src->species, src->level, 0, 1, src->personality, 1, src->otId);
for (i = 0; i < 4; i++)
SetMonMoveSlot(mon, src->moves[i], i);
SetMonData(mon, MON_DATA_PP_BONUSES, &src->ppBonuses);
SetMonData(mon, MON_DATA_HELD_ITEM, &src->heldItem);
SetMonData(mon, MON_DATA_FRIENDSHIP, &src->friendship);
StringCopy(nickname, src->nickname);
if (nickname[0] == EXT_CTRL_CODE_BEGIN && nickname[1] == EXT_CTRL_CODE_JPN)
{
language = LANGUAGE_JAPANESE;
StripExtCtrlCodes(nickname);
}
else
{
language = GAME_LANGUAGE;
}
SetMonData(mon, MON_DATA_LANGUAGE, &language);
SetMonData(mon, MON_DATA_NICKNAME, nickname);
SetMonData(mon, MON_DATA_HP_EV, &src->hpEV);
SetMonData(mon, MON_DATA_ATK_EV, &src->attackEV);
SetMonData(mon, MON_DATA_DEF_EV, &src->defenseEV);
SetMonData(mon, MON_DATA_SPEED_EV, &src->speedEV);
SetMonData(mon, MON_DATA_SPATK_EV, &src->spAttackEV);
SetMonData(mon, MON_DATA_SPDEF_EV, &src->spDefenseEV);
value = src->altAbility;
SetMonData(mon, MON_DATA_ALT_ABILITY, &value);
value = src->hpIV;
SetMonData(mon, MON_DATA_HP_IV, &value);
value = src->attackIV;
SetMonData(mon, MON_DATA_ATK_IV, &value);
value = src->defenseIV;
SetMonData(mon, MON_DATA_DEF_IV, &value);
value = src->speedIV;
SetMonData(mon, MON_DATA_SPEED_IV, &value);
value = src->spAttackIV;
SetMonData(mon, MON_DATA_SPATK_IV, &value);
value = src->spDefenseIV;
SetMonData(mon, MON_DATA_SPDEF_IV, &value);
MonRestorePP(mon);
CalculateMonStats(mon);
}
u8 BattleFrontierGetOpponentLvl(u8);
void sub_8068338(struct Pokemon *mon, struct UnknownPokemonStruct *src, bool8 lvl50)
{
s32 i;
u8 nickname[30];
u8 level;
u8 language;
u8 value;
if (gSaveBlock2Ptr->frontierChosenLvl != 0)
level = BattleFrontierGetOpponentLvl(gSaveBlock2Ptr->frontierChosenLvl);
else if (lvl50)
level = 50;
else
level = src->level;
CreateMon(mon, src->species, level, 0, 1, src->personality, 1, src->otId);
for (i = 0; i < 4; i++)
SetMonMoveSlot(mon, src->moves[i], i);
SetMonData(mon, MON_DATA_PP_BONUSES, &src->ppBonuses);
SetMonData(mon, MON_DATA_HELD_ITEM, &src->heldItem);
SetMonData(mon, MON_DATA_FRIENDSHIP, &src->friendship);
StringCopy(nickname, src->nickname);
if (nickname[0] == EXT_CTRL_CODE_BEGIN && nickname[1] == EXT_CTRL_CODE_JPN)
{
language = LANGUAGE_JAPANESE;
StripExtCtrlCodes(nickname);
}
else
{
language = GAME_LANGUAGE;
}
SetMonData(mon, MON_DATA_LANGUAGE, &language);
SetMonData(mon, MON_DATA_NICKNAME, nickname);
SetMonData(mon, MON_DATA_HP_EV, &src->hpEV);
SetMonData(mon, MON_DATA_ATK_EV, &src->attackEV);
SetMonData(mon, MON_DATA_DEF_EV, &src->defenseEV);
SetMonData(mon, MON_DATA_SPEED_EV, &src->speedEV);
SetMonData(mon, MON_DATA_SPATK_EV, &src->spAttackEV);
SetMonData(mon, MON_DATA_SPDEF_EV, &src->spDefenseEV);
value = src->altAbility;
SetMonData(mon, MON_DATA_ALT_ABILITY, &value);
value = src->hpIV;
SetMonData(mon, MON_DATA_HP_IV, &value);
value = src->attackIV;
SetMonData(mon, MON_DATA_ATK_IV, &value);
value = src->defenseIV;
SetMonData(mon, MON_DATA_DEF_IV, &value);
value = src->speedIV;
SetMonData(mon, MON_DATA_SPEED_IV, &value);
value = src->spAttackIV;
SetMonData(mon, MON_DATA_SPATK_IV, &value);
value = src->spDefenseIV;
SetMonData(mon, MON_DATA_SPDEF_IV, &value);
MonRestorePP(mon);
CalculateMonStats(mon);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -21,6 +21,11 @@
#include "text.h"
#include "window.h"
#include "event_data.h"
#include "gpu_regs.h"
#include "menu.h"
#include "international_string_util.h"
#include "scanline_effect.h"
#include "menu_helpers.h"
struct ContestMove
{
@@ -42,7 +47,6 @@ extern struct BgTemplate gUnknown_0861CBB4;
extern u8 gUnknown_0203CF20;
extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern s8 gUnknown_0861CC1C[];
extern u8 gUnknown_08329D22[];
extern u8 gUnknown_0203CF21;
extern struct UnkStruct_61CC04 gUnknown_0861CC04;
extern struct UnkStruct_61CC04 gUnknown_0861CC10;
@@ -65,20 +69,9 @@ extern u8 gUnknown_0861CE7B[];
extern struct WindowTemplate gUnknown_0861CCEC;
extern struct WindowTemplate gUnknown_0861CD14;
extern void sub_806F2AC(u8 a, u8 b);
void sub_81C488C(u8 a);
extern void do_scheduled_bg_tilemap_copies_to_vram(void);
extern u8 sub_81221EC();
extern u8 sub_81221AC();
extern void SetVBlankHBlankCallbacksToNull();
extern void ResetVramOamAndBgCntRegs();
extern void clear_scheduled_bg_copies_to_vram();
extern void ScanlineEffect_Stop();
extern void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable);
extern void ShowBg(u8 a);
extern void SetGpuReg(u8 regOffset, u16 value);
extern void schedule_bg_copy_tilemap_to_vram(u8 a);
extern void SetBgTilemapBuffer(u8 bg, void *tilemap);
extern u8 gUnknown_08D9862C;
extern u8 gUnknown_08D98CC8;
extern u8 gUnknown_08D987FC;
@@ -93,9 +86,6 @@ extern struct CompressedSpritePalette gUnknown_0861D100;
extern struct CompressedSpritePalette gUnknown_0861D07C;
extern u8 gMoveTypes_Pal;
extern u8 gUnknown_08D97D0C;
extern void reset_temp_tile_data_buffers();
extern void decompress_and_copy_tile_data_to_vram(u8 a, void* tiledata, u8 b, u8 c, u8 d);
extern u8 free_temp_tile_data_buffers_if_possible();
extern void sub_81C1E20(u8 taskId);
extern u8 *GetMonNickname(struct Pokemon *mon, u8 *dest);
extern u16 SpeciesToPokedexNum(u16 species);
@@ -158,11 +148,7 @@ extern u8 gText_ThreeDashes[];
extern u8 gUnknown_0861CE97[];
extern struct BattleMove gBattleMoves[];
extern u32 ChangeBgX(u8 bg, u32 value, u8 op);
extern void sub_8199C30(u8 a, u8 b, u8 c, u8 d, u8 e, u8 f);
extern void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, const u8* colors, s8 speed, u8 *str);
extern s32 GetStringCenterAlignXOffset(u8 fontId, u8 *str, s32 totalWidth);
extern s32 GetStringRightAlignXOffset(u8 fontId, u8 *str, s32 totalWidth);
extern bool8 sub_81A6BF4();
extern bool8 sub_81B9E94();
extern void UnkTextUtil_Reset();

View File

@@ -100,7 +100,6 @@ EWRAM_DATA static u16 sUnknown_0203CCDC[6] = {0};
EWRAM_DATA static u8 sUnknown_0203CCE8 = 0;
extern u32 sub_81A513C(void);
extern void PlayMapChosenOrBattleBGM(bool8);
// this file's functions
static u8 sub_8185278(u8 *arg0, u8 *arg1, u8 *arg2);

View File

@@ -22,7 +22,6 @@ extern u16 gBattle_BG2_X;
extern u16 gBattle_BG2_Y;
extern u16 gBattle_BG3_X;
extern u16 gBattle_BG3_Y;
extern struct SpriteTemplate gUnknown_0202499C;
extern const union AnimCmd * const * const gMonAnimationsSpriteAnimsPtrTable[];

View File

@@ -31,7 +31,6 @@
#include "mystery_event_script.h"
#include "palette.h"
#include "party_menu.h"
#include "pokemon_3.h"
#include "pokemon_storage_system.h"
#include "random.h"
#include "overworld.h"