• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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] Custom ability help

Kamkam2005

Infernitaur
62
Posts
4
Years
  • I'm trying to create 3 custom abilities. How would I script these three? (using V 18.1, and I also have little experience coding.)
    1- Pandora's Gift: Pandora's Gift heals an ally's HP when the user is sent in (done)
    2- Pandora's Curse: Pandora's curse makes the opponent faint when the user faints (done)
    3- Peaceful Soul: Peaceful Soul makes the user unable to attack for the first 2 turns. (done)
     
    Last edited:
    1,408
    Posts
    10
    Years
    • Seen today
    First one sounds fairly simply. You just wanna copy another "switch-in" ability, like Intimidate, and mod it. Unfortunately, there aren't any existing switch-in abilities that do something to Pokemon on your side of the field, so there aren't better examples to work off of. But Intimidate should be ok, you just obviously want to reverse its effects to apply to the same side as the battler, rather than the other side. And of course, swap out the attack drop effect for a heal on someone other than the user.

    The second ability sounds like you can just copy Aftermath, but make the damage it deals equal to the attacker's total HP, rather than just a fraction.
     

    Kamkam2005

    Infernitaur
    62
    Posts
    4
    Years
  • The code mostly works, but there's no healing effect. How do I fix this?

    BattleHandlers::AbilityOnSwitchIn.add(:PANDORASGIFT,
    proc { |ability,battler,battle|
    battle.pbShowAbilitySplash(battler)
    battle.eachSameSideBattler(battler.index) do |ally|
    next if !ally.near?(battler)
    battler.pbRecoverHP(battler.totalhp/4)
    end
    battle.pbHideAbilitySplash(battler)
    }
    )
     
    1,408
    Posts
    10
    Years
    • Seen today
    The code mostly works, but there's no healing effect. How do I fix this?

    BattleHandlers::AbilityOnSwitchIn.add(:PANDORASGIFT,
    proc { |ability,battler,battle|
    battle.pbShowAbilitySplash(battler)
    battle.eachSameSideBattler(battler.index) do |ally|
    next if !ally.near?(battler)
    battler.pbRecoverHP(battler.totalhp/4)
    end
    battle.pbHideAbilitySplash(battler)
    }
    )

    Well the goal here is to heal a teammate right? So you want to apply pbRecoverHP on ally, not battler. "Battler" in this case is referring to the user of the ability, which isn't who you're trying to heal. Besides that it looks fine. I would probably add some other "next if" lines to take specific scenarios into account. Like, the ability probably shouldn't trigger at all if all potential allies are already at full HP, or if the Heal Block is in play that would prevent them from being healed.
     

    Kamkam2005

    Infernitaur
    62
    Posts
    4
    Years
  • Thanks. Both abilities are now working as intended. Once I have more experience with coding, I'll work on improving them a bit.
     

    Kamkam2005

    Infernitaur
    62
    Posts
    4
    Years
  • I'm trying to make an ability called Peaceful Soul. Basically, a pokemon with this ability doesn't attack for the first 2 turns, since it's a pacifist. How exactly would I code this?
     
    Last edited:

    Swdfm

    Game Developer
    245
    Posts
    5
    Years
    • he/him
    • UK
    • Seen Dec 8, 2023
    Have a look at the code for Slow Start, and Truant and do some sort of weird combination for the two. You will likely have to add another PBEffect
     

    Kamkam2005

    Infernitaur
    62
    Posts
    4
    Years
  • That code mostly worked, but I don't know how to remove the random part of it. and make it happen for 2 turns only. I copied the Switch in part from Slow Start in BattleHandlers_Abilities and the code for Truant in Battle_Phase_Attack and Battler_UseMove_SuccessChecks. Here's the code-

    BattleHandlers_Abilities- BattleHandlers::AbilityOnSwitchIn.add(:PEACEFULSOUL,
    proc { |ability,battler,battle|
    battle.pbShowAbilitySplash(battler)
    battler.effects[PBEffects::Peaceful] = 2
    if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
    battle.pbDisplay(_INTL("{1} won't attack!",battler.pbThis))
    else
    battle.pbDisplay(_INTL("{1} won't attack because of its {2}!",
    battler.pbThis,battler.abilityName))
    end
    battle.pbHideAbilitySplash(battler)
    }
    )

    Battler_UseMove_SuccessChecks- if hasActiveAbility?(:PEACEFULSOUL)
    @effects[PBEffects::Peaceful] = !@effects[PBEffects::Peaceful]
    if !@effects[PBEffects::Peaceful]
    @battle.pbShowAbilitySplash(self)
    @battle.pbDisplay(_INTL("{1} won't attack!",pbThis))
    @lastMoveFailed = true
    @battle.pbHideAbilitySplash(self)
    return false
    end
    end

    Battle_Phase_Attack- next if b.hasActiveAbility?(:PEACEFULSOUL) && b.effects[PBEffects::Peaceful]
     
    Last edited:
    1,408
    Posts
    10
    Years
    • Seen today
    That code mostly worked, but I don't know how to remove the random part of it. and make it happen for 2 turns only. I copied the Switch in part from Slow Start in BattleHandlers_Abilities and the code for Truant in Battle_Phase_Attack and Battler_UseMove_SuccessChecks. Here's the code-

    BattleHandlers_Abilities- BattleHandlers::AbilityOnSwitchIn.add(:PEACEFULSOUL,
    proc { |ability,battler,battle|
    battle.pbShowAbilitySplash(battler)
    battler.effects[PBEffects::Peaceful] = 2
    if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
    battle.pbDisplay(_INTL("{1} won't attack!",battler.pbThis))
    else
    battle.pbDisplay(_INTL("{1} won't attack because of its {2}!",
    battler.pbThis,battler.abilityName))
    end
    battle.pbHideAbilitySplash(battler)
    }
    )

    Battler_UseMove_SuccessChecks- if hasActiveAbility?(:PEACEFULSOUL)
    @effects[PBEffects::Peaceful] = !@effects[PBEffects::Peaceful]
    if !@effects[PBEffects::Peaceful]
    @battle.pbShowAbilitySplash(self)
    @battle.pbDisplay(_INTL("{1} won't attack!",pbThis))
    @lastMoveFailed = true
    @battle.pbHideAbilitySplash(self)
    return false
    end
    end

    Battle_Phase_Attack- next if b.hasActiveAbility?(:PEACEFULSOUL) && b.effects[PBEffects::Peaceful]

    When you post code, use the
    Code:
    [ /CODE] tags. It just makes it easier to read the formatting sometimes.
    
    To make the ability consistent, in the second chunk of code, i'd remove the first line above the "if" statement, and then write the "if" statement as
    [CODE]if @effects[PBEffects::Peaceful]>0

    And then in pbEndOfRoundPhase, have @effects[PBEffects::Peaceful] be reduced by 1 at the end of each turn as long if it's equal to a number higher than zero.
    I haven't tested it myself, but just from eyeballing it, that should resolve the every other turn effect of Truant, and make it trigger every turn that PBEffects::Peaceful is greater than zero. Then at the end of each turn, PBEffects::Peaceful is reduced by one, until it reaches zero.

    An alternative way to do this, which imo is a cleaner version since it doesn't require you to add a new PBEffect and add all this extra code to places, is to just make it so that the ability only activates if @turnCount<=2. This way, it'll trigger on the Pokemon's first two turns, but once its turnCount exceeds two, it will no longer activate.
     
    Back
    Top