-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Update Sitrus Berry's effect to Gen 4 standard
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.
- Define a constant
- Use the constant
- Teach the game what to do with it
- Edit the held item effect
- Add hold effect define and usage for non-battle engine users
- Update item description
Edit include/constants/item_effects.h
:
// 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)
Edit src/data/pokemon/item_effects.h
:
const u8 gItemEffect_SitrusBerry[7] = {
[4] = ITEM4_HEAL_HP,
- [6] = 30,
+ [6] = ITEM6_HEAL_QUARTER,
};
Edit src\pokemon.c
(inside the intimidatingly large function PokemonUseItemEffects
):
// 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;
}
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:
.holdEffect = HOLD_EFFECT_RESTORE_HP,
.holdEffectParam = 30,
We'll want to change these to:
.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.
Go to include\constants\hold_effects.h
and define a new hold effect:
#define HOLD_EFFECT_RESTORE_PCT_HP 67
Now go to src/battle_util.c
and look for this section in the function ItemBattleEffects
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:
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 + gBattleMoveDamage > gBattleMons[battlerId].maxHP)
gBattleMoveDamage = gBattleMons[battlerId].maxHP - gBattleMons[battlerId].hp;
gBattleMoveDamage *= -1;
BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem);
effect = ITEM_HP_CHANGE;
}
break;
Lastly, we'll need to edit the Sitrus Berry item description to reflect its new effect.
Open src\data\text\item_descriptions.h
and locate static const u8 sSitrusBerryDesc[] = _(
You can copy/paste the following code snippet, or edit it as you see fit (though be mindful of the character limit per line).
static const u8 sSitrusBerryDesc[] = _(
"A hold item that\n"
"restores 25% of\n"
"max HP in battle.");
That's all!