• 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 Function code trouble

  • 10
    Posts
    7
    Years
    • Seen Feb 28, 2018
    I don't quite understand how to create new move functions, so I need a little help understanding how to create some.

    Some of the moves I need help with:

    Excavate
    Rock-type move similar to Dig but steals the targets held item.

    Sludgeslam
    Poison-type move that can either paralyze or poison the the target.

    Smash Barrier
    Psychic-type move in which damage is doubled if the target used Reflect or Light Screen.

    Soothing tone
    Fairy-type move that puts the target to sleep and raises users Sp. Atk. and Sp. Def.

    Zero Beam
    Ghost-type move that does damage and changes the targets type to Ghost.

    DesiBlast
    Normal-type move that damages and lowers Def. and Sp. Def.
     
  • 971
    Posts
    7
    Years
    • Age 21
    • Seen Nov 28, 2022
    I managed to keep everything as Move classes in PokeBattle_MoveEffects. Change the "CF1" with whatever the function code is. Make sure that the chosen function code does not interfere with any other function codes.

    Code:
    #===============
    # Excavate
    #===============
    class PokeBattle_Move_CF1 < PokeBattle_Move
      def pbTwoTurnAttack(attacker)
        @immediate=false
        if !@immediate && attacker.hasWorkingItem(:POWERHERB)
          @immediate=true
        end
        return false if @immediate
        return attacker.effects[PBEffects::TwoTurnAttack]==0
      end
    
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        if @immediate || attacker.effects[PBEffects::TwoTurnAttack]>0
          pbShowAnimation(@id,attacker,opponent,1,alltargets,showanimation) # Charging anim
          @battle.pbDisplay(_INTL("{1} burrowed its way under the ground!",attacker.pbThis))
        end
        if @immediate
          @battle.pbCommonAnimation("UseItem",attacker,nil)
          @battle.pbDisplay(_INTL("{1} became fully charged due to its Power Herb!",attacker.pbThis))
          attacker.pbConsumeItem
        end
        return 0 if attacker.effects[PBEffects::TwoTurnAttack]>0
        super(attacker,opponent,hitnum,alltargets,showanimation)
        if attacker.item == 0 && opponent.item > 0
          item = opponent.item
          attacker.item = item
          opponent.item = 0
          @battle.pbDisplay(_INTL("{1} stole {2}'s {3}!", attacker.pbThis, opponent.pbThis, PBItems.getName(item)))
        end
        return 0
      end
    end
    The move currently does not function like Dig, as in, being unable to be hit. For that, you will have to add the function code of the move in every list that has Dig in it. Since there are probably quite a few places where the function code of dig is referenced, I did not bother to add it. Also because you'd likely have a different function code.

    Code:
    #===============
    # Sludgeslam
    #===============
    class PokeBattle_Move_CF1 < PokeBattle_Move
      def pbEffectAfterHit(attacker, opponent, turneffects)
        int = rand(10)
        if int == 0
          opponent.pbParalyze(attacker)
        elsif int == 1
          opponent.pbPoison(attacker)
        end
        return 0
      end
    end

    Code:
    #===============
    # Smash Barrier
    #===============
    class PokeBattle_Move_CF1 < PokeBattle_Move
      def pbBaseDamage(basedmg,attacker,opponent)
        if attacker.pbOpposingSide.effects[PBEffects::LightScreen] > 0 ||
           attacker.pbOpposingSide.effects[PBEffects::Reflect] > 0
          return basedmg * 2
        end
        return basedmg
      end
    end

    Code:
    #===============
    # Soothing Tone
    #===============
    class PokeBattle_Move_CF1 < PokeBattle_Move
      def pbEffect(attacker, opponent, hitnums = 0, alltargets = nil, showanimation = true)
        opponent.pbSleep
        if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
          attacker.pbIncreaseStat(PBStats::SPATK,1,attacker,false,self)
        end
        if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
          attacker.pbIncreaseStat(PBStats::SPDEF,1,attacker,false,self)
        end
        return 0
      end
    end

    Code:
    #================
    # Zero Beam
    #================
    class PokeBattle_Move_CF1 < PokeBattle_Move
      def pbEffectAfterHit(attacker, opponent, turneffects)
        opponent.type1 = getConst(PBTypes,:GHOST)
        opponent.type2 = getConst(PBTypes,:GHOST)
        opponent.effects[PBEffects::Type3] = -1
        @battle.pbDisplay(_INTL("{1}'s type was changed to the Ghost type!", opponent.pbThis))
      end
    end

    Code:
    #================
    # DesiBlast
    #================
    class PokeBattle_Move_CF1 < PokeBattle_Move
      def pbEffectAfterHit(attacker, opponent, turneffects)
        showanim = true
        if !opponent.pbCanReduceStatStage?(PBStats::DEFENSE,opponent,false,self) &&
           !opponent.pbCanReduceStatStage?(PBStats::DEFENSE,opponent,false,self)
          @battle.pbDisplay(_INTL("{1}'s stats won't go any lower!", opponent.pbThis))
          return -1
        end
        if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,opponent,false,self)
          opponent.pbReduceStat(PBStats::DEFENSE,1,opponent,false,self,showanim)
          showanim = false
        end
        if opponent.pbCanReduceStatStage?(PBStats::SPDEF,opponent,false,self)
          opponent.pbReduceStat(PBStats::SPDEF,1,opponent,false,self,showanim)
          showanim=false
        end
        return 0
      end
    end
     
  • 10
    Posts
    7
    Years
    • Seen Feb 28, 2018
    Wow! Thanks so much! I really appreciate you doing that for me.

    Do you know of any tutorials that can help me figure out how to start making them myself?
     
  • 971
    Posts
    7
    Years
    • Age 21
    • Seen Nov 28, 2022
    Wow! Thanks so much! I really appreciate you doing that for me.

    Do you know of any tutorials that can help me figure out how to start making them myself?

    The first step is to learn how Ruby kind of works. Learn the syntax, learn how to use functions and data types and that stuff.

    If you've done that, I would choose one thing you want to delve deeper into. If you want to make moves, I'd take a good look through the MoveEffects script. Some functions are very self explanatory - pbBaseDamage, for example, does something with the base damage. Making a move isn't something you can look up a tutorial for. You have to look at other moves and try to understand how they work. Two-turn-moves are a bit more tricky, so I wouldn't touch those unless you have a better understanding of what you're doing. Usually you can just copy from other move effects, but if you use your knowledge of code, you can come up with good strategies. For example, for Excavate, I could put the check for the opponent's item where I did, because if the Pokémon is in a TwoTurnAttack, it will return 0 to the function - which means any code after it will not be executed. If it's not the first turn of a TwoTurnAttack, it will run the rest of the code and ultimately return 0 (which is basically saying that the move was executed successfully). But to do things like that, you have to be at least a little bit familiar with Ruby. If you don't know what "super" does, for example, you should look it up and see how it works.

    But of course, this isn't something you can achieve in one day. I haven't been a programmer for a long time myself - about 3/4 months roughly - and I'd say I've only been improving ever since.
     
    Back
    Top