• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • 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] New Ability Help [Essentials 21.1] using Pledge Effects

  • 9
    Posts
    193
    Days
    • They/Them
    • UK
    • Seen Dec 8, 2024
    Hey y'all!

    So I want to make an trio of abilities which sets up one of the three Pledge Effects: Swamp, Sea Of Fire, and Rainbow, as if they were such abilities as Misty Surge, Drought, etc. But I have no idea how to code this. I tried this in Battle_Ability Effects, using the Misty Surge code as a base, and as an example for Sea of Fire:

    Battle::AbilityEffects::OnSwitchIn.add(:BLAZINGHONOUR,
    proc { |ability, battler, battle, switch_in|
    next if battle.field.terrain == :SeaOfFIre
    battle.pbShowAbilitySplash(battler)
    battle.pbStartTerrain(battler, :SeaOfFire)
    }
    )

    And well, that didn't work.

    I have an idea that it needs to instead link to a move effect, but I also have no idea how to do this, since I have no coding experience. Any help on this would be greatly appreciated, and at the bare minimum, I can credit you in my in-progress fangame, Pokemon Lazulite.
     
    Okay, so the good news is that you had the right first step!
    When adding a new ability or move, the best thing to first do is look at the ones already there!
    1) With that mentality, we also look at the second step
    The mistake you then made was to set Sea Of Fire as a terrain, which it isn't. It is a field (or a side?) effect
    We want to have the Sea Of Fire added, so let's look at the move effect for it
    We can find the move effect by searching "seaoffire" in the all scripts section
    NOTE: If that doesn't work, try it with spaces. Sometimes Maruno adds these things as comments, so search "sea of fire" if the last line doesn't work!

    2) So we see about twenty options come up, but don't worry, as most of them aren't relevant. We are specifically looking for the Move Effect
    In the options, about ten of them have anything to do with move effects (As you see on the left), so first we will look at where we most think the lines will be. If it's not there, we search again
    My Spidops senses tell me it is in the BaseEffects page, in the clump around Line 600
    Found it! So what I like to do is copy the whole thing to a Notepad file so the scripts arent messed with

    3) So I have moved the entire MoveEffects class over. Most of it we won't be using
    The bits we are interested in are the parts that check if the pledge effect happens (ie. is it already there?) and the bits that set up the effect
    So, we have a look and cut out the irrelevant bits (Just trust that I did this!)
    ... A lot of it is irrelevant to us, as we are only after the effects
    So the lines we cut out are:
    Code:
        msg = nil
        animName = nil
        case @comboEffect
        when :SeaOfFire   # Grass + Fire
          if user.pbOpposingSide.effects[PBEffects::SeaOfFire] == 0
            user.pbOpposingSide.effects[PBEffects::SeaOfFire] = 4
            msg = _INTL("A sea of fire enveloped {1}!", user.pbOpposingTeam(true))
            animName = (user.opposes?) ? "SeaOfFire" : "SeaOfFireOpp"
          end
        when :Rainbow   # Fire + Water
          if user.pbOwnSide.effects[PBEffects::Rainbow] == 0
            user.pbOwnSide.effects[PBEffects::Rainbow] = 4
            msg = _INTL("A rainbow appeared in the sky on {1}'s side!", user.pbTeam(true))
            animName = (user.opposes?) ? "RainbowOpp" : "Rainbow"
          end
        when :Swamp   # Water + Grass
          if user.pbOpposingSide.effects[PBEffects::Swamp] == 0
            user.pbOpposingSide.effects[PBEffects::Swamp] = 4
            msg = _INTL("A swamp enveloped {1}!", user.pbOpposingTeam(true))
            animName = (user.opposes?) ? "Swamp" : "SwampOpp"
          end
        end
        @battle.pbDisplay(msg) if msg
        @battle.pbCommonAnimation(animName) if animName

    4) These are useful, as they contain both the lines that ask if it is possible to set up a Pledge move, and the ones that do the effect!
    It also contains the lines for the other Pledge Moves!
    So, we now go back to our bestie Misty Surge! You have already found that so we have it here:
    Code:
    Battle::AbilityEffects::OnSwitchIn.add(:MISTYSURGE,
      proc { |ability, battler, battle, switch_in|
        next if battle.field.terrain == :Misty
        battle.pbShowAbilitySplash(battler)
        battle.pbStartTerrain(battler, :Misty)
        # NOTE: The ability splash is hidden again in def pbStartTerrain.
      }
    )
    We will add that to the bottom of our Notepad file

    5) Now is the hard/fun part! We do a Frankenstein of Misty Surge and the Pledge Effects!
    And because you used the correct spelling of honour in your ability name, I will be generous, and do all three Pledge Moves for you!
    For the benefit of you/anyone watching, I'll do a step-by-step!
    a) Change Misty Surge to your ability name (You already did this!)
    b) It is a switch in effect, so first two lines can stay the same
    c) We can still set this ability during Misty Surge, so line 3 gets deleted
    d) It is still a switch in ability, so line 4 stays
    e) The fifth line is to be replaced by our Pledge move effect

    6) Our Frankenstein ability now looks like this:
    Code:
    Battle::AbilityEffects::OnSwitchIn.add(:BLAZINGHONOUR,
      proc { |ability, battler, battle, switch_in|
        next if battle.field.terrain == :Misty
        battle.pbShowAbilitySplash(battler)
        if user.pbOpposingSide.effects[PBEffects::SeaOfFire] == 0
          user.pbOpposingSide.effects[PBEffects::SeaOfFire] = 4
          msg = _INTL("A sea of fire enveloped {1}!", user.pbOpposingTeam(true))
          animName = (user.opposes?) ? "SeaOfFire" : "SeaOfFireOpp"
        end
        # NOTE: The ability splash is hidden again in def pbStartTerrain.
      }
    )
    There are quite a few problems!
    a) The local variable "user" which isn't any of the words next to the proc!
    This means that the game would crash with a pesky NoMethodError should this ability run
    So, we have to replace every instance of "user" with "battler"
    b) The ability splash comes up before checking to see if there is already a Sea of Fire
    This would not crash the game, but would confuse a player wondering what the ability did, as the splash would show up and appear to do nothing
    So, let's copy Misty Surge, and have it ignore the ability completely if there is already a Sea of Fire there
    We swap former Lines 4 and 5, and add a "next" in front of our new Line 4, a bit like Misty Surge did
    c) "next if" would do the opposite of what we want it to do (We want it to NOT run IF the effect is NOT 0. So "next unless" or " > 0" would work BUT NOT BOTH!
    d) We now no longer need the "end" that was in Line 9, so we get rid of that line entirely, and then indent it properly, because even beginners should correctly indent lines or else you look at your code 3 years later and have a meltdown

    7) Let's look at Frankenstein again
    Code:
    Battle::AbilityEffects::OnSwitchIn.add(:BLAZINGHONOUR,
      proc { |ability, battler, battle, switch_in|
        next unless battler.pbOpposingSide.effects[PBEffects::SeaOfFire] == 0
        battle.pbShowAbilitySplash(battler)
        battler.pbOpposingSide.effects[PBEffects::SeaOfFire] = 4
        msg = _INTL("A sea of fire enveloped {1}!", battler.pbOpposingTeam(true))
        animName = (battler.opposes?) ? "SeaOfFire" : "SeaOfFireOpp"
        # NOTE: The ability splash is hidden again in def pbStartTerrain.
      }
    )
    This code will not crash the game, but will definitely not work as intended
    a) We have set the name and animation to local variables, but nothing is then done about it
    b) And Maruno left us a nice note saying that we basically have to turn off the splash!
    Let's fix a) by looking at the Pledge Move effect code, and copying that at the end
    We also remove the @ in front of the "battle" to avoid confusing local and class variables!
    And for b), we look for literally any code that hides the ability hash. The opposite of "show" is "hide" so logically it would be called "pbHideAbilitySplash" Let's look for it in the all search function
    It is there! So, after checking that, we replace Maruno's NOTE line with the hiding of the ability splash by copying line 4 and replacing "Show" with "Hide"

    8) And here we are!
    Blazing Honour
    Spoiler:

    This should work. There are a few minor nerdy nitpicks in here (eg. No need to have the "if msg") but other than that, this should be good to go!
    Just put it somewhere, and it should work
    After a few times doing it, all those steps will become more obvious and will take less time and thinking and be more obvious and practise makes perfect etc.

    So, using this same logic, we can do the other Pledge moves! We might as well!
    NOTE: None of the abilities I've done here have been tested, so please make sure to test it! Do this with all your stuff!
    Rainbow Honour
    Spoiler:


    Swamp Honour (shoutout to my boy Shrek!)
    Spoiler:



    Hope this helps!
    Swdfm
    I do like to be credited, but only for resources, so don't worry too much about crediting me this time around!
    I would like your permission to make this into a Tutorial though! This was a lot of fun!
     
    You're getting credit, and of course you can make a tutorial of this. Link it us when it's done :D also I love you - I'll report back when I get to test the code <3
     
    Battle::AbilityEffects::OnSwitchIn.add(:BLAZINGHONOUR, proc { |ability, battler, battle, switch_in| next unless battler.pbOpposingSide.effects[PBEffects::SeaOfFire] == 0 battle.pbShowAbilitySplash(battler) battler.pbOpposingSide.effects[PBEffects::SeaOfFire] = 4 msg = _INTL("A sea of fire enveloped {1}!", battler.pbOpposingTeam(true)) animName = (battler.opposes?) ? "SeaOfFire" : "SeaOfFireOpp" battle.pbDisplay(msg) if msg battle.pbCommonAnimation(animName) if animName battle.pbHideAbilitySplash(battler) } )
    Blazing Honour works perfectly :D Rainbow honour was just missing the "battle.pbShowAbilitySplash(battler)" line, but otherwise worked.

    Swamp Honour (Shrek 1&2 are classics) however causes the game to crash/not function with the following error:
    [Pokémon Essentials version 21.1]
    [v21.1 Hotfixes 1.0.9]

    Exception: NameError
    Message: undefined local variable or method `user' for nil:NilClass

    Backtrace:
    Battle_AbilityEffects:2932:in `block in <main>'
    Event_Handlers:195:in `trigger'
    [Generation 9 Pack] [000] Ability Handlers.rb:21:in `triggerOnSwitchIn'
    Battle_ActionSwitching:353:in `block in pbOnBattlerEnteringBattle'
    Battle_ActionSwitching:332:in `each'
    Battle_ActionSwitching:332:in `pbOnBattlerEnteringBattle'
    Battle_AttackPhase:65:in `block in pbAttackPhaseSwitch'
    Battle_AttackPhase:49:in `each'
    Battle_AttackPhase:49:in `pbAttackPhaseSwitch'
    [Deluxe Battle Kit] [003] Command Menu Refactor.rb:404:in `pbAttackPhase'

    I traced this back to the line:

    animName = (user.opposes?) ? "Swamp" : "SwampOpp"

    I looked at the other examples, replaced 'User' with 'battler', and that fixed it. I also added the "battle.pbShowAbilitySplash(battler)" line too.

    You have single-handedly saved me a big headache, and taught me something new <3 - THANK YOU SO MUCH!!!

    I sent ya a friend request on Discord too :)
     
    Blazing Honour works perfectly :D Rainbow honour was just missing the "battle.pbShowAbilitySplash(battler)" line, but otherwise worked.

    Swamp Honour (Shrek 1&2 are classics) however causes the game to crash/not function with the following error:
    [Pokémon Essentials version 21.1]
    [v21.1 Hotfixes 1.0.9]

    Exception: NameError
    Message: undefined local variable or method `user' for nil:NilClass

    Backtrace:
    Battle_AbilityEffects:2932:in `block in <main>'
    Event_Handlers:195:in `trigger'
    [Generation 9 Pack] [000] Ability Handlers.rb:21:in `triggerOnSwitchIn'
    Battle_ActionSwitching:353:in `block in pbOnBattlerEnteringBattle'
    Battle_ActionSwitching:332:in `each'
    Battle_ActionSwitching:332:in `pbOnBattlerEnteringBattle'
    Battle_AttackPhase:65:in `block in pbAttackPhaseSwitch'
    Battle_AttackPhase:49:in `each'
    Battle_AttackPhase:49:in `pbAttackPhaseSwitch'
    [Deluxe Battle Kit] [003] Command Menu Refactor.rb:404:in `pbAttackPhase'

    I traced this back to the line:

    animName = (user.opposes?) ? "Swamp" : "SwampOpp"

    I looked at the other examples, replaced 'User' with 'battler', and that fixed it. I also added the "battle.pbShowAbilitySplash(battler)" line too.

    You have single-handedly saved me a big headache, and taught me something new <3 - THANK YOU SO MUCH!!!

    I sent ya a friend request on Discord too :)
    Youre welcome
    Glad you worked out Swamp error without prompting!
     
    Back
    Top