In Generation III the Sitrus Berry healed only 30 HP, an effect inherited from the Gold Berry in Generation II. In Generation IV it was improved to heal one quarter of the user's max HP. ## Contents 1. [Define a constant](#1-define-a-constant) 2. [Use the constant](#2-use-the-constant) 3. [Teach the game what to do with it](#3-teach-the-game-what-to-do-with-it) 4. [Edit the held item effect](#4-edit-the-held-item-effect) 5. [Add hold effect define and usage for non-battle engine users](#5-add-hold-effect-define-and-usage) ## 1. Define a new constant Edit `include/constants/item_effects.h`: ```diff // Special HP recovery amounts for ITEM4_HEAL_HP #define ITEM6_HEAL_FULL ((u8) -1) #define ITEM6_HEAL_HALF ((u8) -2) -#define ITEM6_HEAL_LVL_UP ((u8) -3) +#define ITEM6_HEAL_QUARTER ((u8) -3) +#define ITEM6_HEAL_LVL_UP ((u8) -4) ``` ## 2. Use the constant Edit `src/data/pokemon/item_effects.h`: ```diff const u8 gItemEffect_SitrusBerry[7] = { [4] = ITEM4_HEAL_HP, - [6] = 30, + [6] = ITEM6_HEAL_QUARTER, }; ``` ## 3. Teach the game what to do with it Edit `src\pokemon.c` (inside the intimidatingly large function `PokemonUseItemEffects`): ```diff // Get amount of HP to restore dataUnsigned = itemEffect[var_3C++]; switch (dataUnsigned) { case ITEM6_HEAL_FULL: dataUnsigned = GetMonData(mon, MON_DATA_MAX_HP, NULL) - GetMonData(mon, MON_DATA_HP, NULL); break; case ITEM6_HEAL_HALF: dataUnsigned = GetMonData(mon, MON_DATA_MAX_HP, NULL) / 2; if (dataUnsigned == 0) dataUnsigned = 1; break; +case ITEM6_HEAL_QUARTER: + dataUnsigned = GetMonData(mon, MON_DATA_MAX_HP, NULL) / 4; + if (dataUnsigned == 0) + dataUnsigned = 1; + break; case ITEM6_HEAL_LVL_UP: dataUnsigned = gBattleScripting.levelUpHP; break; } ``` ## 4. Edit the held item effect So far, we've only edited the outside of battle effects of the Sitrus Berry. Go to `src\data\items.h` and look for the Sitrus Berry. There are two important lines here: ```diff .holdEffect = HOLD_EFFECT_RESTORE_HP, .holdEffectParam = 30, ``` We'll want to change these to: ```diff .holdEffect = HOLD_EFFECT_RESTORE_PCT_HP, .holdEffectParam = 25, //restores 25% of the max HP ``` If you're using the battle engine by Dizzyegg/rhh, you're all done! Otherwise, you'll need to do step 5. ## 5. Add hold effect define and usage Go to `include\constants\hold_effects.h` and define a new hold effect: ```diff #define HOLD_EFFECT_RESTORE_PCT_HP 67 ``` Now go to `src/battle_util.c` and look for this section in the function `ItemBattleEffects` ```diff case HOLD_EFFECT_RESTORE_HP: if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / 2 && !moveTurn) { gBattleMoveDamage = battlerHoldEffectParam; if (gBattleMons[battlerId].hp + battlerHoldEffectParam > gBattleMons[battlerId].maxHP) gBattleMoveDamage = gBattleMons[battlerId].maxHP - gBattleMons[battlerId].hp; gBattleMoveDamage *= -1; BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem); effect = 4; } break; ``` You're going to want to add another case directly below this case. Copy paste this in: ```diff case HOLD_EFFECT_RESTORE_PCT_HP: if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / 2 && !moveTurn) { gBattleMoveDamage = (gBattleMons[battlerId].maxHP * battlerHoldEffectParam) / 100; if (gBattleMons[battlerId].hp + battlerHoldEffectParam > gBattleMons[battlerId].maxHP) gBattleMoveDamage = gBattleMons[battlerId].maxHP - gBattleMons[battlerId].hp; gBattleMoveDamage *= -1; BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem); effect = 4; } break; ``` That's all!