• 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 not quite working

20
Posts
11
Years
    • Seen Sep 11, 2022
    Hi, I just wanna start by saying that I love you guys and everything that you do here. Its really taught me a lot and I'm finally ready to venture out into the water on my own...

    Or so I thought. I have been making a few fairly simple abilities, i.e. Slush Rush, and have had some success. My most recent ability though has been a tiny road block. I'm attempting to basically create the frozen type equivalent of Poison Point, Frost Bite(credit for idea goes to insertbrackets). So I copied the code for Poison Point and change a few things to do freezy stuff but it so far, hasn't been successful. In battle when a Pokemon would get frozen it results in an error message(attached below) and isn't actually frozen. I would really love some guidance and maybe I'd finally be able to give back to this amazing community. Attachments below
     

    Attachments

    • Code in Question.txt
      827 bytes · Views: 6
    • Error.txt
      859 bytes · Views: 3
    Last edited:
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    The error message says that you're passing two arguments but pbFreeze only takes one—the message.

    You can tell it takes only the message because in PokeBattle_BattlerEffects there's this:
    Code:
    def pbFreeze(msg=nil)
     
    Last edited:
    20
    Posts
    11
    Years
    • Seen Sep 11, 2022
    I got it. At first I was like wow, that didn't tell me anything. I wanted to respond with a big huh? But I decided to give it a looksie. I decided the code directly underneath what you pointed me to was the answer. The test was no good. So I looked again. I decided to go look at the Paralyze status. I see:

    def pbParalyze(attacker=nil,msg=nil)

    Okay cool. Then I go look at Burn:

    def pbBurn(attacker=nil,msg=nil)

    Neat.... Let's check Poison:

    def pbPoison(attacker=nil,msg=nil,toxic=false)

    Hmm. Hmmmmm. What do these things have in common? Obviously I don't need the toxic. And I already have the msg=nil. Sooooooooo, what if I added attacker=nil?

    And presto! We got a frozen Pokemon! Wooo! mgriffin, you rock. Seriously. No hand holding, but you gave me exactly what I needed to know. Thank you so much I really appreciate it.
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    Your solution works, but generally speaking it's risky to add an extra argument to a function (particularly if it's not at the end) because there may be other places in the code that call pbFreeze.

    For example imagine this code already existed:

    Code:
    if !target.hasType(:ICE)
      target.pbFreeze("Super-duper frozen")
    end
    Well your change would mean that attacker would be "Super-duper frozen" and msg would be nil, and the special message wouldn't display any more.

    Luckily as far as I know Essentials never actually passed a custom message, so like I say, your change is fine. And please don't take this the wrong way, you did a good job investigating the problem and finding a solution!

    Just for completeness sake, the change I would have made would have been this:

    Code:
            if target.hasWorkingAbility(:FROSTBITE,true) && @battle.pbRandom(10)<3 &&
               user.pbCanFreeze?(nil,false)
              PBDebug.log("[Ability triggered] #{target.pbThis}'s Frost Bite")
              user.pbFreeze(_INTL("{1}'s {2} Frozen {3}! It won't be able to move!",target.pbThis,
                 PBAbilities.getName(target.ability),user.pbThis(true)))
            end

    All I did was take away "target" from the call, which is kinda the opposite of your change :)

    But again, well done on solving it yourself!
     
    20
    Posts
    11
    Years
    • Seen Sep 11, 2022
    I appreciate the feedback. I will make the appropriate changes for completeness. This has been a wonderful learning experience and I truly appreciate you taking the time to teach me. Now I will continue to try build more and more elaborate abilities.
     
    Back
    Top