diff --git a/include/constants/daycare.h b/include/constants/daycare.h index 782bbe9546..ae80105147 100644 --- a/include/constants/daycare.h +++ b/include/constants/daycare.h @@ -13,11 +13,7 @@ #define DAYCARE_ONE_MON 2 #define DAYCARE_TWO_MONS 3 -#if P_EGG_HATCH_LEVEL >= GEN_4 -#define EGG_HATCH_LEVEL 1 -#else -#define EGG_HATCH_LEVEL 5 -#endif +#define EGG_HATCH_LEVEL ((P_EGG_HATCH_LEVEL >= GEN_4) ? 1 : 5) #define EGG_GENDER_MALE 0x8000 // used to create a male egg from a female-only parent species (e.g. Nidoran) #define DAYCARE_LEVEL_MENU_EXIT 5 diff --git a/include/constants/global.h b/include/constants/global.h index d2a72d235d..521a4cea27 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -108,11 +108,7 @@ #define PLAYER_NAME_LENGTH 7 #define MAIL_WORDS_COUNT 9 #define EASY_CHAT_BATTLE_WORDS_COUNT 6 -#if B_EXPANDED_MOVE_NAMES == TRUE -#define MOVE_NAME_LENGTH 16 -#else -#define MOVE_NAME_LENGTH 12 -#endif +#define MOVE_NAME_LENGTH ((B_EXPANDED_MOVE_NAMES == TRUE) ? 16 : 12) #define NUM_QUESTIONNAIRE_WORDS 4 #define QUIZ_QUESTION_LEN 9 #define WONDER_CARD_TEXT_LENGTH 40 @@ -120,11 +116,7 @@ #define WONDER_CARD_BODY_TEXT_LINES 4 #define WONDER_NEWS_BODY_TEXT_LINES 10 #define TYPE_NAME_LENGTH 6 -#if B_EXPANDED_ABILITY_NAMES == TRUE -#define ABILITY_NAME_LENGTH 16 -#else -#define ABILITY_NAME_LENGTH 12 -#endif +#define ABILITY_NAME_LENGTH ((B_EXPANDED_ABILITY_NAMES == TRUE) ? 16 : 12) #define TRAINER_NAME_LENGTH 10 #define MAX_STAMP_CARD_STAMPS 7 diff --git a/include/constants/items.h b/include/constants/items.h index e6dbf28404..bc9fdf2dc4 100644 --- a/include/constants/items.h +++ b/include/constants/items.h @@ -649,11 +649,7 @@ #define CONFUSE_BERRY_HEAL_FRACTION 8 #endif -#if B_CONFUSE_BERRIES_HEAL >= GEN_7 - #define CONFUSE_BERRY_HP_FRACTION 4 -#else - #define CONFUSE_BERRY_HP_FRACTION 2 -#endif +#define CONFUSE_BERRY_HP_FRACTION ((B_CONFUSE_BERRIES_HEAL >= GEN_7) ? 4 : 2) #define ITEM_CHERI_BERRY 514 #define ITEM_CHESTO_BERRY 515 diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 4c98258ada..fd330b29f4 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -202,11 +202,7 @@ #define AFFECTION_FIVE_HEARTS 5 // Max friendship // Friendship value that the majority of species use. -#if P_UPDATED_FRIENDSHIP >= GEN_8 -#define STANDARD_FRIENDSHIP 50 -#else -#define STANDARD_FRIENDSHIP 70 -#endif +#define STANDARD_FRIENDSHIP ((P_UPDATED_FRIENDSHIP >= GEN_8) ? 50 : 70) #define MAX_FRIENDSHIP 255 #define MAX_SHEEN 255 @@ -215,17 +211,9 @@ #define MAX_PER_STAT_IVS 31 #define MAX_IV_MASK 31 #define USE_RANDOM_IVS (MAX_PER_STAT_IVS + 1) -#if P_EV_CAP >= GEN_6 -#define MAX_PER_STAT_EVS 252 -#else -#define MAX_PER_STAT_EVS 255 -#endif +#define MAX_PER_STAT_EVS ((P_EV_CAP >= GEN_6) ? 252 : 255) #define MAX_TOTAL_EVS 510 -#if I_VITAMIN_EV_CAP >= GEN_8 -#define EV_ITEM_RAISE_LIMIT MAX_PER_STAT_EVS -#else -#define EV_ITEM_RAISE_LIMIT 100 -#endif +#define EV_ITEM_RAISE_LIMIT ((I_VITAMIN_EV_CAP >= GEN_8) ? MAX_PER_STAT_EVS : 100) // Move category defines. #define BATTLE_CATEGORY_PHYSICAL 0 diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index e452e96d04..24678c66da 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -133,10 +133,8 @@ static u32 GetWildAiFlags(void) if (avgLevel >= 80) flags |= AI_FLAG_HP_AWARE; -#if B_VAR_WILD_AI_FLAGS != 0 - if (VarGet(B_VAR_WILD_AI_FLAGS) != 0) + if (B_VAR_WILD_AI_FLAGS != 0 && VarGet(B_VAR_WILD_AI_FLAGS) != 0) flags |= VarGet(B_VAR_WILD_AI_FLAGS); -#endif return flags; } diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 299d420de9..c919ba587a 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -1453,11 +1453,10 @@ static u32 GetSwitchinStatusDamage(u32 battler) { if (status & STATUS1_BURN) { - #if B_BURN_DAMAGE >= GEN_7 + if (B_BURN_DAMAGE >= GEN_7) statusDamage = maxHP / 16; - #else + else statusDamage = maxHP / 8; - #endif if(ability == ABILITY_HEATPROOF) statusDamage = statusDamage / 2; if (statusDamage == 0) @@ -1465,11 +1464,10 @@ static u32 GetSwitchinStatusDamage(u32 battler) } else if (status & STATUS1_FROSTBITE) { - #if B_BURN_DAMAGE >= GEN_7 + if (B_BURN_DAMAGE >= GEN_7) statusDamage = maxHP / 16; - #else + else statusDamage = maxHP / 8; - #endif if (statusDamage == 0) statusDamage = 1; } diff --git a/src/battle_anim_ice.c b/src/battle_anim_ice.c index 32db964d1b..7cc2395bf0 100644 --- a/src/battle_anim_ice.c +++ b/src/battle_anim_ice.c @@ -1303,7 +1303,7 @@ static void InitPoisonGasCloudAnim(struct Sprite *sprite) sprite->x = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2); sprite->y = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET); -#if B_UPDATED_MOVE_DATA >= GEN_5 + if (B_UPDATED_MOVE_DATA >= GEN_5) { s16 x, y; SetAverageBattlerPositions(gBattleAnimTarget, gBattleAnimArgs[7], &x, &y); @@ -1313,8 +1313,7 @@ static void InitPoisonGasCloudAnim(struct Sprite *sprite) sprite->data[4] = y + gBattleAnimArgs[4]; sprite->data[7] |= GetBattlerSpriteBGPriority(gBattleAnimTarget) << 8; } -#else - if (gBattleAnimArgs[7]) + else if (gBattleAnimArgs[7]) { sprite->data[1] = sprite->x + gBattleAnimArgs[1]; sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) + gBattleAnimArgs[3]; @@ -1330,7 +1329,6 @@ static void InitPoisonGasCloudAnim(struct Sprite *sprite) sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y) + gBattleAnimArgs[4]; sprite->data[7] |= GetBattlerSpriteBGPriority(gBattleAnimTarget) << 8; } -#endif if (IsContest()) { diff --git a/src/battle_dynamax.c b/src/battle_dynamax.c index cae33e82ab..f99e0e1890 100644 --- a/src/battle_dynamax.c +++ b/src/battle_dynamax.c @@ -946,11 +946,10 @@ void BS_TrySetStatus1(void) case STATUS1_SLEEP: if (CanSleep(gBattlerTarget)) { - #if B_SLEEP_TURNS >= GEN_5 - gBattleMons[gBattlerTarget].status1 |= STATUS1_SLEEP_TURN((Random() % 3) + 2); - #else - gBattleMons[gBattlerTarget].status1 |= STATUS1_SLEEP_TURN((Random() % 4) + 3); - #endif + if (B_SLEEP_TURNS >= GEN_5) + gBattleMons[gBattlerTarget].status1 |= STATUS1_SLEEP_TURN((Random() % 3) + 2); + else + gBattleMons[gBattlerTarget].status1 |= STATUS1_SLEEP_TURN((Random() % 4) + 3); gBattleCommunication[MULTISTRING_CHOOSER] = 4; effect++; } diff --git a/src/battle_main.c b/src/battle_main.c index 01c751d1fc..552ce52f74 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -2027,13 +2027,11 @@ u8 CreateNPCTrainerPartyFromTrainer(struct Pokemon *party, const struct Trainer } CalculateMonStats(&party[i]); - #if B_TRAINER_CLASS_POKE_BALLS >= GEN_7 - if (ball == -1) + if (B_TRAINER_CLASS_POKE_BALLS >= GEN_7 && ball == -1) { ball = gTrainerClasses[trainer->trainerClass].ball ?: ITEM_POKE_BALL; SetMonData(&party[i], MON_DATA_POKEBALL, &ball); } - #endif } } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 34c59ac4da..5568f243c1 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -14488,15 +14488,14 @@ static void Cmd_pickup(void) SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); } } - #if P_SHUCKLE_BERRY_JUICE == GEN_2 - else if (species == SPECIES_SHUCKLE + else if (P_SHUCKLE_BERRY_JUICE == GEN_2 + && species == SPECIES_SHUCKLE && heldItem == ITEM_ORAN_BERRY && (Random() % 16) == 0) { heldItem = ITEM_BERRY_JUICE; SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); } - #endif } } diff --git a/src/battle_util.c b/src/battle_util.c index e70e0f9191..c33f180e3e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1164,8 +1164,7 @@ void PrepareStringBattle(u16 stringId, u32 battler) else SET_STATCHANGER(STAT_SPATK, 2, FALSE); } -#if B_UPDATED_INTIMIDATE >= GEN_8 - else if (stringId == STRINGID_PKMNCUTSATTACKWITH && targetAbility == ABILITY_RATTLED + else if (B_UPDATED_INTIMIDATE >= GEN_8 && stringId == STRINGID_PKMNCUTSATTACKWITH && targetAbility == ABILITY_RATTLED && CompareStat(gBattlerTarget, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN)) { gBattlerAbility = gBattlerTarget; @@ -1173,7 +1172,6 @@ void PrepareStringBattle(u16 stringId, u32 battler) gBattlescriptCurrInstr = BattleScript_AbilityRaisesDefenderStat; SET_STATCHANGER(STAT_SPEED, 1, FALSE); } -#endif // Signal for the trainer slide-in system. if ((stringId == STRINGID_ITDOESNTAFFECT || stringId == STRINGID_PKMNWASNTAFFECTED || stringId == STRINGID_PKMNUNAFFECTED) @@ -8802,11 +8800,12 @@ static inline u32 CalcMoveBasePowerAfterModifiers(u32 move, u32 battlerAtk, u32 break; case ABILITY_TRANSISTOR: if (moveType == TYPE_ELECTRIC) - #if B_TRANSISTOR_BOOST >= GEN_9 - modifier = uq4_12_multiply(modifier, UQ_4_12(5325 / 4096)); - #else - modifier = uq4_12_multiply(modifier, UQ_4_12(1.5)); - #endif + { + if (B_TRANSISTOR_BOOST >= GEN_9) + modifier = uq4_12_multiply(modifier, UQ_4_12(5325 / 4096)); + else + modifier = uq4_12_multiply(modifier, UQ_4_12(1.5)); + } break; case ABILITY_DRAGONS_MAW: if (moveType == TYPE_DRAGON) @@ -10958,11 +10957,10 @@ bool32 IsAlly(u32 battlerAtk, u32 battlerDef) bool32 IsGen6ExpShareEnabled(void) { -#if I_EXP_SHARE_FLAG <= TEMP_FLAGS_END - return FALSE; -#else + if (I_EXP_SHARE_FLAG <= TEMP_FLAGS_END) + return FALSE; + return FlagGet(I_EXP_SHARE_FLAG); -#endif } bool32 MoveHasMoveEffect(u32 move, u32 moveEffect) diff --git a/src/bike.c b/src/bike.c index 10596418fd..de150dae4b 100644 --- a/src/bike.c +++ b/src/bike.c @@ -1053,12 +1053,8 @@ void Bike_HandleBumpySlopeJump(void) bool32 IsRunningDisallowed(u8 metatile) { -#if OW_RUNNING_INDOORS == GEN_3 - if (!gMapHeader.allowRunning || IsRunningDisallowedByMetatile(metatile) == TRUE) -#else - if (IsRunningDisallowedByMetatile(metatile) == TRUE) -#endif + if ((OW_RUNNING_INDOORS == GEN_3 && !gMapHeader.allowRunning) || IsRunningDisallowedByMetatile(metatile) == TRUE) return TRUE; - else - return FALSE; + + return FALSE; } diff --git a/src/data/items.h b/src/data/items.h index 161f59137d..d4dba9fd04 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -8,27 +8,13 @@ #define EVO_HELD_ITEM_FIELD_FUNC ItemUseOutOfBattle_CannotUse #endif -#if I_GEM_BOOST_POWER >= GEN_6 - #define GEM_BOOST_PARAM 30 -#else - #define GEM_BOOST_PARAM 50 -#endif +#define GEM_BOOST_PARAM ((I_GEM_BOOST_POWER >= GEN_6) ? 30 : 50) +#define TYPE_BOOST_PARAM ((I_TYPE_BOOST_POWER >= GEN_4) ? 20 : 10) // For non Pokémon-specific type-boosting held items. +#define POWER_ITEM_BOOST ((I_POWER_ITEM_BOOST >= GEN_7) ? 8 : 4) -#if I_TYPE_BOOST_POWER >= GEN_4 // For non Pokémon-specific type-boosting held items. - #define TYPE_BOOST_PARAM 20 -#else - #define TYPE_BOOST_PARAM 10 -#endif +#define X_ITEM_STAGES ((B_X_ITEMS_BUFF >= GEN_7) ? 2 : 1) -#if I_POWER_ITEM_BOOST >= GEN_7 - #define POWER_ITEM_BOOST 8 -#else - #define POWER_ITEM_BOOST 4 -#endif - -#define X_ITEM_STAGES (B_X_ITEMS_BUFF >= GEN_7) ? 2 : 1 - -#define TREASURE_FACTOR (I_SELL_VALUE_FRACTION >= GEN_9) ? 2: 1 +#define TREASURE_FACTOR ((I_SELL_VALUE_FRACTION >= GEN_9) ? 2 : 1) // Shared Item Description entries diff --git a/src/daycare.c b/src/daycare.c index 6ecc4c7669..97447e99d6 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -194,9 +194,7 @@ static void TransferEggMoves(void) // Check if you can inherit from them if (GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[k].mon, MON_DATA_SPECIES) != GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[i].mon, MON_DATA_SPECIES) - #if P_EGG_MOVE_TRANSFER >= GEN_9 - && GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[i].mon, MON_DATA_HELD_ITEM) != ITEM_MIRROR_HERB - #endif + && (P_EGG_MOVE_TRANSFER < GEN_9 || GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[i].mon, MON_DATA_HELD_ITEM) != ITEM_MIRROR_HERB) ) continue; @@ -492,9 +490,7 @@ static s32 GetParentToInheritNature(struct DayCare *daycare) for (i = 0; i < DAYCARE_MON_COUNT; i++) { if (ItemId_GetHoldEffect(GetBoxMonData(&daycare->mons[i].mon, MON_DATA_HELD_ITEM)) == HOLD_EFFECT_PREVENT_EVOLVE - #if P_NATURE_INHERITANCE == GEN_3 - && (GetBoxMonGender(&daycare->mons[i].mon) == MON_FEMALE || IS_DITTO(GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SPECIES))) - #endif + && (P_NATURE_INHERITANCE != GEN_3 || GetBoxMonGender(&daycare->mons[i].mon) == MON_FEMALE || IS_DITTO(GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SPECIES))) ) { slot = i; numWithEverstone++; @@ -503,11 +499,11 @@ static s32 GetParentToInheritNature(struct DayCare *daycare) if (numWithEverstone >= DAYCARE_MON_COUNT) return Random() & 1; -#if P_NATURE_INHERITANCE > GEN_4 - return slot; -#else + + if (P_NATURE_INHERITANCE > GEN_4) + return slot; + return Random() & 1 ? slot : -1; -#endif } static void _TriggerPendingDaycareEgg(struct DayCare *daycare) @@ -858,27 +854,28 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru numEggMoves = GetEggMoves(egg, sHatchedEggEggMoves); -#if P_MOTHER_EGG_MOVE_INHERITANCE >= GEN_6 - for (i = 0; i < MAX_MON_MOVES; i++) + if (P_MOTHER_EGG_MOVE_INHERITANCE >= GEN_6) { - if (sHatchedEggMotherMoves[i] != MOVE_NONE) + for (i = 0; i < MAX_MON_MOVES; i++) { - for (j = 0; j < numEggMoves; j++) + if (sHatchedEggMotherMoves[i] != MOVE_NONE) { - if (sHatchedEggMotherMoves[i] == sHatchedEggEggMoves[j]) + for (j = 0; j < numEggMoves; j++) { - if (GiveMoveToMon(egg, sHatchedEggMotherMoves[i]) == MON_HAS_MAX_MOVES) - DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggMotherMoves[i]); - break; + if (sHatchedEggMotherMoves[i] == sHatchedEggEggMoves[j]) + { + if (GiveMoveToMon(egg, sHatchedEggMotherMoves[i]) == MON_HAS_MAX_MOVES) + DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggMotherMoves[i]); + break; + } } } - } - else - { - break; + else + { + break; + } } } -#endif for (i = 0; i < MAX_MON_MOVES; i++) { @@ -899,23 +896,26 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru break; } } -#if P_TM_INHERITANCE < GEN_6 - for (i = 0; i < MAX_MON_MOVES; i++) + + if (P_TM_INHERITANCE < GEN_6) { - if (sHatchedEggFatherMoves[i] != MOVE_NONE) + for (i = 0; i < MAX_MON_MOVES; i++) { - for (j = 0; j < NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES; j++) + if (sHatchedEggFatherMoves[i] != MOVE_NONE) { - u16 moveId = ItemIdToBattleMoveId(ITEM_TM01 + j); - if (sHatchedEggFatherMoves[i] == moveId && CanLearnTeachableMove(GetMonData(egg, MON_DATA_SPECIES_OR_EGG), moveId)) + for (j = 0; j < NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES; j++) { - if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == MON_HAS_MAX_MOVES) - DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFatherMoves[i]); + u16 moveId = ItemIdToBattleMoveId(ITEM_TM01 + j); + if (sHatchedEggFatherMoves[i] == moveId && CanLearnTeachableMove(GetMonData(egg, MON_DATA_SPECIES_OR_EGG), moveId)) + { + if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == MON_HAS_MAX_MOVES) + DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFatherMoves[i]); + } } } } } -#endif + for (i = 0; i < MAX_MON_MOVES; i++) { if (sHatchedEggFatherMoves[i] == MOVE_NONE) @@ -1046,12 +1046,10 @@ static u16 DetermineEggSpeciesAndParentSlots(struct DayCare *daycare, u8 *parent eggSpecies = SPECIES_NIDORAN_M; else if (eggSpecies == SPECIES_ILLUMISE && daycare->offspringPersonality & EGG_GENDER_MALE) eggSpecies = SPECIES_VOLBEAT; -#if P_NIDORAN_M_DITTO_BREED >= GEN_5 - else if (eggSpecies == SPECIES_NIDORAN_M && !(daycare->offspringPersonality & EGG_GENDER_MALE)) + else if (P_NIDORAN_M_DITTO_BREED >= GEN_5 && eggSpecies == SPECIES_NIDORAN_M && !(daycare->offspringPersonality & EGG_GENDER_MALE)) eggSpecies = SPECIES_NIDORAN_F; - else if (eggSpecies == SPECIES_VOLBEAT && !(daycare->offspringPersonality & EGG_GENDER_MALE)) + else if (P_NIDORAN_M_DITTO_BREED >= GEN_5 && eggSpecies == SPECIES_VOLBEAT && !(daycare->offspringPersonality & EGG_GENDER_MALE)) eggSpecies = SPECIES_ILLUMISE; -#endif else if (eggSpecies == SPECIES_MANAPHY) eggSpecies = SPECIES_PHIONE; else if (eggSpecies == SPECIES_SINISTEA_ANTIQUE) diff --git a/src/field_poison.c b/src/field_poison.c index 202be30e20..fcbce0b0b2 100644 --- a/src/field_poison.c +++ b/src/field_poison.c @@ -45,9 +45,9 @@ static void FaintFromFieldPoison(u8 partyIdx) struct Pokemon *pokemon = &gPlayerParty[partyIdx]; u32 status = STATUS1_NONE; -#if OW_POISON_DAMAGE < GEN_4 - AdjustFriendship(pokemon, FRIENDSHIP_EVENT_FAINT_FIELD_PSN); -#endif + if (OW_POISON_DAMAGE < GEN_4) + AdjustFriendship(pokemon, FRIENDSHIP_EVENT_FAINT_FIELD_PSN); + SetMonData(pokemon, MON_DATA_STATUS, &status); GetMonData(pokemon, MON_DATA_NICKNAME, gStringVar1); StringGet_Nickname(gStringVar1); @@ -56,11 +56,7 @@ static void FaintFromFieldPoison(u8 partyIdx) static bool32 MonFaintedFromPoison(u8 partyIdx) { struct Pokemon *pokemon = &gPlayerParty[partyIdx]; -#if OW_POISON_DAMAGE < GEN_4 - if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 0 && GetAilmentFromStatus(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) -#else - if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 1 && GetAilmentFromStatus(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) -#endif + if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) == ((OW_POISON_DAMAGE < GEN_4) ? 0 : 1) && GetAilmentFromStatus(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) return TRUE; return FALSE; @@ -134,16 +130,13 @@ s32 DoPoisonFieldEffect(void) { // Apply poison damage hp = GetMonData(pokemon, MON_DATA_HP); - #if OW_POISON_DAMAGE < GEN_4 - if (hp == 0 || --hp == 0) + if (OW_POISON_DAMAGE < GEN_4 && (hp == 0 || --hp == 0)) { TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_FAINT); numFainted++; } - #else - if (hp == 1 || --hp == 1) + else if (OW_POISON_DAMAGE >= GEN_4 && (hp == 1 || --hp == 1)) numFainted++; - #endif SetMonData(pokemon, MON_DATA_HP, &hp); numPoisoned++; diff --git a/src/item_menu.c b/src/item_menu.c index 55ec0acca1..973ff5725a 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -2115,11 +2115,7 @@ static void Task_ItemContext_Sell(u8 taskId) } } -#if I_SELL_VALUE_FRACTION >= GEN_9 -#define ITEM_SELL_FACTOR 4 -#else -#define ITEM_SELL_FACTOR 2 -#endif +#define ITEM_SELL_FACTOR ((I_SELL_VALUE_FRACTION >= GEN_9) ? 4 : 2) static void DisplaySellItemPriceAndConfirm(u8 taskId) { diff --git a/src/item_use.c b/src/item_use.c index 5ebc79670e..de15640164 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -1040,12 +1040,15 @@ void Task_UseDigEscapeRopeOnField(u8 taskId) static void ItemUseOnFieldCB_EscapeRope(u8 taskId) { Overworld_ResetStateAfterDigEscRope(); - #if I_KEY_ESCAPE_ROPE < GEN_8 + if (I_KEY_ESCAPE_ROPE < GEN_8) + { RemoveUsedItem(); - #else + } + else + { CopyItemName(gSpecialVar_ItemId, gStringVar2); StringExpandPlaceholders(gStringVar4, gText_PlayerUsedVar2); - #endif + } gTasks[taskId].data[0] = 0; DisplayItemMessageOnField(taskId, gStringVar4, Task_UseDigEscapeRopeOnField); } diff --git a/src/pokemon.c b/src/pokemon.c index 0c445ab307..59c34f1c7b 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -57,11 +57,7 @@ #include "constants/union_room.h" #include "constants/weather.h" -#if P_FRIENDSHIP_EVO_THRESHOLD >= GEN_9 -#define FRIENDSHIP_EVO_THRESHOLD 160 -#else -#define FRIENDSHIP_EVO_THRESHOLD 220 -#endif +#define FRIENDSHIP_EVO_THRESHOLD ((P_FRIENDSHIP_EVO_THRESHOLD >= GEN_9) ? 160 : 220) struct SpeciesItem { @@ -3557,10 +3553,8 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov break; } dataSigned += evChange; - #if I_EV_LOWERING_BERRY_JUMP == GEN_4 - if (dataSigned > 100) + if (I_BERRY_EV_JUMP == GEN_4 && dataSigned > 100) dataSigned = 100; - #endif if (dataSigned < 0) dataSigned = 0; } @@ -3744,10 +3738,8 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov break; } dataSigned += evChange; - #if I_BERRY_EV_JUMP == GEN_4 - if (dataSigned > 100) + if (I_BERRY_EV_JUMP == GEN_4 && dataSigned > 100) dataSigned = 100; - #endif if (dataSigned < 0) dataSigned = 0; } @@ -4085,10 +4077,7 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, s // Prevent evolution with Everstone, unless we're just viewing the party menu with an evolution item if (holdEffect == HOLD_EFFECT_PREVENT_EVOLVE && mode != EVO_MODE_ITEM_CHECK - #if P_KADABRA_EVERSTONE >= GEN_4 - && species != SPECIES_KADABRA - #endif - ) + && (P_KADABRA_EVERSTONE < GEN_4 || species != SPECIES_KADABRA)) return SPECIES_NONE; switch (mode)