• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Anyone can help with an HP recovery ability? [SOLVED]

  • 19
    Posts
    6
    Years
    • Seen Oct 12, 2018
    So I'm trying to add an ability that recovers health at the end of the turn. I've tried using Ingrain's information but changing it to if i.hasWorkingAbility(:TIMEMACHINE) instead like below, but that caused a syntax error when I put it below ingrain and the same thing when I tried putting it under intimidate. Then I tried to modify Ice Body's information by getting rid of the "if hail' part basically, and that's what I have below. But no matter what I do, I can't seem to get this dang ability to work. Can anyone help out? Or if you have a similar ability, could you explain how you did it? Thanks in advanced.
    # Intimidate
    if self.hasWorkingAbility(:INTIMIDATE) && onactive
    PBDebug.log("[Ability triggered] #{pbThis}'s Intimidate")
    for i in 0...4
    if pbIsOpposing?(i) && [email protected].fainted?
    @battle.battlers.pbReduceAttackStatIntimidate(self)
    end
    end
    end
    # Time Machine
    if i.hasWorkingAbility(:TIMEMACHINE)
    i.effects[PBEffects::HealBlock]==0
    PBDebug.log("[Ability triggered] #{i.pbThis}'s Time Machine")
    hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
    pbDisplay(_INTL("{1}'s {2} reversed time and restored a little HP!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
    if i.fainted?
    return if !i.pbFaint
    end
    end

    # Download
     
    Last edited:
    Code:
    if i.hasWorkingAbility(:TIMEMACHINE)
    i.effects[PBEffects::HealBlock]==0

    Do you mean:
    Code:
    if i.hasWorkingAbility(:TIMEMACHINE) && i.effects[PBEffects::HealBlock]==0

    I don't think this will fix your syntax error, but it's very hard to tell because you didn't post which line has the error (you should get a line number in the error message, and will need to tell us the number of the first line in your quoted code too).
     
    Thanks for the help. While it has seemed to have gotten rid of the syntax error, I still am having trouble getting it to work. I've tried posting it beneath ingrain (line 3249 in PokeBattle_Battle) and it just didn't do anything at all. While posting it under intimidate (1077 PokeBattle_Battler) causes this crash as soon as a battle happens.
    ---------------------------
    Pokemon Essentials
    ---------------------------
    [Pok?mon Essentials version 17.2]

    Exception: NoMethodError

    Message: undefined method `hasWorkingAbility' for nil:NilClass

    PokeBattle_Battler:1078:in `pbAbilitiesOnSwitchIn_ebs'

    EliteBattle_Battle:492:in `pbAbilitiesOnSwitchIn'

    PokeBattle_Battle:2069:in `pbOnActiveAll'

    PokeBattle_Battle:2068:in `each'

    PokeBattle_Battle:2068:in `pbOnActiveAll'

    EliteBattle_Battle:213:in `pbStartBattleCore'

    PokeBattle_Battle:2340:in `pbStartBattle'

    PField_Battles:98:in `pbWildBattle_ebs'

    PField_Battles:97:in `pbSceneStandby'

    PField_Battles:99:in `pbWildBattle_ebs'

    Now this is the script I'm using.
    # Time Machine
    if i.hasWorkingAbility(:TIMEMACHINE) && i.effects[PBEffects::HealBlock]==0
    PBDebug.log("[Ability triggered] #{i.pbThis}'s Time Machine")
    hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
    pbDisplay(_INTL("{1}'s {2} reversed time and restored a little HP!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
    if i.fainted?
    return if !i.pbFaint
    end
    end

    Thanks for the help, by the way. I really appreciate it.
     
    Okay, so:
    1) if your ability should be triggered at the end of turn don't put it with intimidate as this is withhin the script that checks for abilities on switchin (or on active as its called)
    2) if you just say
    Code:
    i.hasWorkingAbility(:TIMEMACHINE)
    the game will go like "What the heck is i? That is empty. Not there. I don't know what "hasWorkingAbility" means for i"
    Sooo as you want to check each battler you need to put your code like this:
    Code:
    # Time Machine
    for i in priority
    next if i.isFainted? # i changed that because it's shorter :)
    if i.hasWorkingAbility(:TIMEMACHINE) && i.effects[PBEffects::HealBlock]==0
    PBDebug.log("[Ability triggered] #{i.pbThis}'s Time Machine")
    hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
    pbDisplay(_INTL("{1}'s {2} reversed time and restored a little HP!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
    end
    end

    And then you put this code somewhere around Ingrain. Keep in mind that everything that is above this script will trigge before this ability in battle. Means if you put it above Ingrain for example then first Timemachine triggers and then Ingrain. If you put it below Ingrain then Ingrain comes first and then your ability :)
     
    EDIT: Ego beat me to it, listen to him, he looked at the code and has given you a much more useful response :)

    Code:
    Exception: NoMethodError
    Message: undefined method `hasWorkingAbility' for nil:NilClass

    This is probably the result of you trying to call a method on a variable that isn't defined. I guess that "i" isn't in scope where you've added your script. In the nearby code what name is used to refer to the Pok?mon? It's probably something like pokemon, pkmn, or maybe battler, you're looking for a word before a "." where the word after the dot is something you'd expect to find on a Pok?mon, e.g. hasWorkingAbility, form, hp, etc etc.

    I don't have access to the code right now, so I can't check what the names should be.
     
    Last edited:
    EDIT: Ego beat me to it, listen to him, he looked at the code and has given you a much more useful response :)

    Code:
    Exception: NoMethodError
    Message: undefined method `hasWorkingAbility' for nil:NilClass

    This is probably the result of you trying to call a method on a variable that isn't defined. I guess that "i" isn't in scope where you've added your script. In the nearby code what name is used to refer to the Pok?mon? It's probably something like pokemon, pkmn, or maybe battler, you're looking for a word before a "." where the word after the dot is something you'd expect to find on a Pok?mon, e.g. hasWorkingAbility, form, hp, etc etc.

    I don't have access to the code right now, so I can't check what the names should be.

    I checked the code and the way i wrote it here should work :)
    The variabel "priority" holds the correct format to use "hasworkingability" on
    That's why you iterate through it using i as a local variable (similar to: foreach (var i in priority){ code} from c#)
     
    Thank you guys so much! This really helped me out and fixed up the issue. And thanks for explaining that kind of information to me. I've been following tutorials and they all kind of used intimidate as an example. This should help me out a lot in making future abilities. Now if only I could solve the graphical issues I've been having. Thanks again, though!
     
    Back
    Top