Okay, here's what you have to do to add an effect to your berries, or literally any other item you want.
Go to script section PItem_ItemEffects. This is where the effects are in v16+. There are a few different effects that we can make based on how the item is used (from the bag, in the field, on a pokemon, etc). We are interested in ItemHandlers::UseOnPokemon so scroll down to line 937, the bottom that section of code, so stuff stays organized. Still with me? Great!
This here is a basic use of item script, with all the parts
Code:
ItemHandlers::UseOnPokemon.add(:ITEMNAME,proc{|item,pokemon,scene|
next (boolean)
})
item and pokemon are variables that represents the used item and the pokemon it was used on. scene isn't all that important, don't worry about that.
boolean is either true if the item was used or false if it wasn't. Use from bag is different, but that doesn't matter here either.
So, your first effect is increase the happiness by 1 or 2.
Code:
ItemHandlers::UseOnPokemon.add(:HAPPYBERRY,proc{|item,pokemon,scene|
Kernel.pbMessage(_INTL("{1} liked the berry!.",pokemon.name))
pokemon.happiness+=1
pokemon.happiness=[[255,pokemon.happiness].min,0].max
next true
})
This is bare-boned, I would add some better dialogue or not let the player feed the berry if the happiness is max. Whatever.
Now, you have some 10 berries with the same effect. You don't want to write that 10 times do you? Fortunately, there is something for that too.
Code:
ItemHandlers::UseOnPokemon.copy(:HAPPYBERRY,:FRIENDBERRY,:JOYBERRY,:YOUGETTHEPOINTBERRY)
This will copy the effect from the first berry to the rest. Neat, right?
Okay, Curing of attraction berry. Never made a battle item, but let's give it a shot.
This is probably a BattleUseOnBattler effect, since only Battlers have in battle effects, (Pokemon in battle have a battler assigned to them which includes the inbattle stats like increasing and decreasing and confusion.)
Code:
ItemHandlers::BattleUseOnBattler.add(:ITEMNAME,proc{|item,battler,scene|
return (boolean)
})
battler is what I mentioned earlier, and you can see the main code attached to it in the PokeBattle_Battler.
Code:
ItemHandlers::BattleUseOnBattler.add(:UNATTRACTBERRY,proc{|item,battler,scene|
battle = battler.battle
if battler.effects[PBEffects::Attract]>=0
battle.pbDisplay(_INTL("{1} is nolonger infatuated",battler.pbThis))
pbCureAttract
return true
else
battle.pbDisplay(_INTL("It won't have any effect."))
return false
end
})
battle.pbDisplay is how we make a battle message appear. We check if the battler is infatuated and if so cure it. but we don't lose the item if the battler is not infatuated.
Raising a lowered stat, can't really be done here. it's a battle effect, kind of like Leftovers. But, we can still do this.
Go to script section PokeBattle_BattlerEffects, line 803 in def pbCanReduceStatStage?
Add the lines in red.
Code:
if stat==PBStats::ACCURACY && hasWorkingAbility(:KEENEYE)
abilityname=PBAbilities.getName(self.ability)
@battle.pbDisplay(_INTL("{1}'s {2} prevents accuracy loss!",pbThis,abilityname)) if showMessages
return false
end
[COLOR="Red"]if hasWorkingItem(:STATBERRY)
berryname=PBItems.getName(self.item)
pbConsumeItem
@battle.pbDisplay(_INTL("{1} ate the {2} to avoid the stat loss!",pbThis,berryname)) if showMessages
return false
end[/COLOR]
DISCLAMER: I have tested none of this.
Have fun.
OH, oh!
Relevant Wiki. Sorry, I forgot.