• 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] Function Code Help

163
Posts
5
Years
  • Okay I am making a Function Code for a new move. It is called Sky Lunge and the move fails if the target is heavier than the user.

    Idk how to make a Function Code that does it so would someone please help?
     

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • Burn your neurons and edit Sucker Punch for what you want:

    Code:
    ################################################################################
    # Fails if the target didn't chose a damaging move to use this round, or has
    # already moved. (Sucker Punch)
    ################################################################################
    class PokeBattle_Move_116 < PokeBattle_Move
      def pbMoveFailed(attacker,opponent)
        return true if @battle.choices[opponent.index][0]!=1 # Didn't choose a move
        [email protected][opponent.index][2]
        return true if !oppmove || oppmove.id<=0 || oppmove.pbIsStatus?
        return true if opponent.hasMovedThisRound? && oppmove.function!=0xB0 # Me First
        return false
      end
    end

    Check Heavy Slam's code to recognize the weight:
    Code:
    ################################################################################
    # Power increases the heavier the user is than the target. (Heat Crash, Heavy Slam)
    ################################################################################
    class PokeBattle_Move_09B < PokeBattle_Move
      def pbBaseDamage(basedmg,attacker,opponent)
        n=(attacker.weight/opponent.weight(attacker)).floor
        ret=40
        ret=60 if n>=2
        ret=80 if n>=3
        ret=100 if n>=4
        ret=120 if n>=5
        return ret
      end
    end

    Good luck.
     

    Poq

    144
    Posts
    6
    Years
    • Seen Aug 28, 2021
    Also, this might go without saying, but make sure to assign a unique code to it as well. In the scripts where move functions are defined, you'll see this pattern at the start:
    Code:
    class PokeBattle_Move_[COLOR="red"]###[/COLOR] < PokeBattle_Move
    where ### is the actual function code - the one that you would assign to the move in the PBS. It's a three digit hexadecimal number. Base essentials goes up to 158 with function codes, so the next available would be 159, then 15A, up to 15F, then 160. But they don't have to be sequential. You could just start up at 500 and guarantee that you're not overriding another code.

    And sorry if this is all stuff you're aware of - just trying to provide a thorough answer and maybe help out someone else who comes across this post in the future.
     
    163
    Posts
    5
    Years
  • Burn your neurons and edit Sucker Punch for what you want:

    Code:
    ################################################################################
    # Fails if the target didn't chose a damaging move to use this round, or has
    # already moved. (Sucker Punch)
    ################################################################################
    class PokeBattle_Move_116 < PokeBattle_Move
      def pbMoveFailed(attacker,opponent)
        return true if @battle.choices[opponent.index][0]!=1 # Didn't choose a move
        [email protected][opponent.index][2]
        return true if !oppmove || oppmove.id<=0 || oppmove.pbIsStatus?
        return true if opponent.hasMovedThisRound? && oppmove.function!=0xB0 # Me First
        return false
      end
    end

    Check Heavy Slam's code to recognize the weight:
    Code:
    ################################################################################
    # Power increases the heavier the user is than the target. (Heat Crash, Heavy Slam)
    ################################################################################
    class PokeBattle_Move_09B < PokeBattle_Move
      def pbBaseDamage(basedmg,attacker,opponent)
        n=(attacker.weight/opponent.weight(attacker)).floor
        ret=40
        ret=60 if n>=2
        ret=80 if n>=3
        ret=100 if n>=4
        ret=120 if n>=5
        return ret
      end
    end

    Good luck.

    Yeah but...

    How do I do that?

    Also, I think I already started so, is this correct?
    ################################################################################
    # Fails if the target is heavier than the user. (Sky Lunge)
    ################################################################################
    class PokeBattle_Move_15A < PokeBattle_Move
    def pbMoveFailed(attacker,opponent)
    return (attacker.weight<opponent.weight)
    end
     
    163
    Posts
    5
    Years
  • Also, this might go without saying, but make sure to assign a unique code to it as well. In the scripts where move functions are defined, you'll see this pattern at the start:
    Code:
    class PokeBattle_Move_[COLOR="red"]###[/COLOR] < PokeBattle_Move
    where ### is the actual function code - the one that you would assign to the move in the PBS. It's a three digit hexadecimal number. Base essentials goes up to 158 with function codes, so the next available would be 159, then 15A, up to 15F, then 160. But they don't have to be sequential. You could just start up at 500 and guarantee that you're not overriding another code.

    And sorry if this is all stuff you're aware of - just trying to provide a thorough answer and maybe help out someone else who comes across this post in the future.

    Already got that! :D
     

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • ################################################################################
    # Fails if the target is heavier than the user. (Sky Lunge)
    ################################################################################
    class PokeBattle_Move_15A < PokeBattle_Move
    def pbMoveFailed(attacker,opponent)
    return (attacker.weight<opponent.weight)
    end

    Pay attention, you need to put 'return true if' and then 'return false', like you saw in Sucker Punch. Also, you don't need '()' between code.
     

    Poq

    144
    Posts
    6
    Years
    • Seen Aug 28, 2021
    Pay attention, you need to put 'return true if' and then 'return false', like you saw in Sucker Punch. Also, you don't need '()' between code.

    Actually, I think that syntax is fine since (attacker.weight<opponent.weight) will already be a boolean value. The only change I might add is
    Code:
    class PokeBattle_Move_15A < PokeBattle_Move
      def pbMoveFailed(attacker,opponent)
        return [COLOR="red"]((attacker.weight<opponent.weight) rescue false)[/COLOR] 
      end
    just to catch any errors.
     
    163
    Posts
    5
    Years
  • Actually, I think that syntax is fine since (attacker.weight<opponent.weight) will already be a boolean value. The only change I might add is
    Code:
    class PokeBattle_Move_15A < PokeBattle_Move
      def pbMoveFailed(attacker,opponent)
        return [COLOR="red"]((attacker.weight<opponent.weight) rescue false)[/COLOR] 
      end
    just to catch any errors.

    Okay! Thanks!
     
    163
    Posts
    5
    Years
  • Okay so it works!

    Everything functions correctly. The move works on Pokemon that are lighter than the user but not heavier than the user!

    This is the function code I used:
    ################################################################################
    # Fails if the target is heavier than the user. (Sky Lunge)
    ################################################################################
    class PokeBattle_Move_15A < PokeBattle_Move
    def pbMoveFailed(attacker,opponent)
    return true if ((attacker.weight<opponent.weight) rescue false)
    return false
    end
    end
     
    Back
    Top