v18 [Scripting Help] Move that boosts DEF +1 and heals 1/4 HP

This thread pertains to v18 of Pokémon Essentials.

ValiantSoul

World Traveller
Member
Joined
Sep 12, 2020
Posts
97
Hey everyone,

I'm looking to code a move that does as the title suggests. I'm a total rookie with coding and such, so I've been trying to craft existsing code together to create the desired affect, to no avail. Would anyone be able to help me creating a Function Code for such a move?

Just to clarify, I'm using V18.1!

Cheers,
ValiantSoul
 

WolfPP

Discord Wolf#1235
Member
Joined
Aug 24, 2018
Posts
130
Age
29
Open the script section and use CTRL SHIFT F to find how Harder move works and also Recover, to merge them (about Recover, check inside move.txt because it is a heal move type). Remember to change to heal 1/4 total hp inside that new script.
 

ValiantSoul

World Traveller
Member
Joined
Sep 12, 2020
Posts
97
So, my knowledge being limited, would it look like this?

Ruby:
class PokeBattle_Move_512 < PokeBattle_StatUpMove
  def initialize(battle,move)
    super
    @statUp = [PBStats::DEFENSE,1]
  end

  def pbHealAmount(user)
    return (user.totalhp/4.0).round
    super
  end
end

But that's clearly missing something, as only the first effect triggers...
 
Last edited:

TechSkylander1518

Wiki Dweeb
Member
So, my knowledge being limited, would it look like this?

Ruby:
class PokeBattle_Move_512 < PokeBattle_StatUpMove
  def initialize(battle,move)
    super
    @statUp = [PBStats::DEFENSE,1]
  end

  def pbHealAmount(user)
    return (user.totalhp/4.0).round
    super
  end
end

But that's clearly missing something, as only the first effect triggers...
In v18, moves started to be put in subclasses to make it easier to adapt a basic function- for example, the class PokeBattle_StatUpMove has all the code for raising a stat, and the individual function code classes just specific which stat is raised and by how much. That's why you only needed to define @statUp, and you didn't have to worry about any other code- checking if the user could raise their stats, checking if the move had failed, etc. But pbHealAmount doesn't mean anything for a PokeBattle_StatUpMove, because it's only designed for stat changes, not healing. You'll have to combine some of the code for healing moves into your new function to

If we Ctrl+Shift+F for PokeBattle_HealingMove (Recover's class), we can find it in Move_Effects_Generic-
Ruby:
class PokeBattle_HealingMove < PokeBattle_Move
  def healingMove?;       return true; end
  def pbHealAmount(user); return 1;    end

  def pbMoveFailed?(user,targets)
    if user.hp==user.totalhp
      @battle.pbDisplay(_INTL("{1}'s HP is full!",user.pbThis))
      return true
    end
    return false
  end

  def pbEffectGeneral(user)
    amt = pbHealAmount(user)
    user.pbRecoverHP(amt)
    @battle.pbDisplay(_INTL("{1}'s HP was restored.",user.pbThis))
  end
end
We can look over this and see what we need to bring to our new function code.

  • We'll definitely want to copy over def healingMove?; return true; end - this is the check used for things like Heal Block, and we don't want the move to get around that
  • We probably don't want to copy over the checks for the move failing- the user should still be able to raise their defense even if they're at full HP. (We don't need to worry about the user going over their max HP, because pbRecoverHP automatically checks that and adjusts it.
  • We will want to copy over what's in pbEffectGeneral, since that's what does the actual healing- however, since PokeBattle_StatUpMove also has its own pbEffectGeneral, we can't just copy it over as-is, we have to combine the two into one.
Luckily, this isn't too hard, because we can use super to get what's already been defined in the superclass and just add onto it.

Ruby:
  def pbEffectGeneral(user)
   super
    amt = (user.totalhp/4.0).round
    user.pbRecoverHP(amt)
    @battle.pbDisplay(_INTL("{1}'s HP was restored.",user.pbThis))
  end
(I cut out the middle man of pbHealAmount here, because there's no point in defining it separately when we're doing it like this)

All together, it'd look like this:


Ruby:
class PokeBattle_Move_512 < PokeBattle_StatUpMove
  def initialize(battle,move)
    super
    @statUp = [PBStats::DEFENSE,1]
  end

  def healingMove?;       return true; end

  def pbEffectGeneral(user)
   super
    amt = (user.totalhp/4.0).round
    user.pbRecoverHP(amt)
    @battle.pbDisplay(_INTL("{1}'s HP was restored.",user.pbThis))
  end
end
 
Top