• 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.
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • 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.

[Custom Feature Question] Custom move

  • 1
    Posts
    6
    Years
    • Seen Oct 17, 2018
    I'm just now diving into the technical side of my fan game.. I'm very green when it comes to programming, but decided to give it a shot on my own, digging through function codes for several hours (with little success) before seeking help. :frown:

    I'm trying to make a move that functions similarly to Soak, but turns the opponent to the Normal type instead of the water type, and also deals damage before changing the type.
    Getting it to change to the Normal type was easy enough, but while fiddling with the code I could only get the move to either deal damage or convert the opponent's type--never both. If someone would help explain to me how I could edit the code to make that happen (and maybe a quick explanation on how it works), I'd greatly appreciate it! :smile:
     
    Go to your scripts and find the pokebattle_moveeffects and find soak or your new move. I'm going using soak as a reference. This is what I have for soak

    Code:
    class PokeBattle_Move_061 < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        if opponent.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(attacker)
          @battle.pbDisplay(_INTL("But it failed!"))  
          return -1
        end
    return -1 if pbTypeImmunityByAbility(pbType(@type,attacker,opponent),attacker,opponent)
        if isConst?(attacker.ability,PBAbilities,:MULTITYPE) || 
          isConst?(attacker.ability,PBAbilities,:RKSSYSTEM)
          @battle.pbDisplay(_INTL("But it failed!"))
          return -1
        end
        pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
        if opponent.type1==getConst(PBTypes,:WATER) &&
           opponent.type2==getConst(PBTypes,:WATER) &&
           (opponent.effects[PBEffects::Type3]<0 ||
           opponent.effects[PBEffects::Type3]==getConst(PBTypes,:WATER))
          @battle.pbDisplay(_INTL("But it failed!"))
          return -1
        end
        opponent.type1=getConst(PBTypes,:WATER)
        opponent.type2=getConst(PBTypes,:WATER)
        opponent.effects[PBEffects::Type3]=-1
        typename=PBTypes.getName(getConst(PBTypes,:WATER))
        @battle.pbDisplay(_INTL("{1} transformed into the {2} type!",opponent.pbThis,typename))
        return 0
      end
    end

    When I saw your post the first move that came to mind was spectral thief because it has an effect then does damage. I found this line of code- return super(attacker,opponent,hitnum,alltargets,showanimation)
    I then checked with some status effects for moves that do damage and have a chance to cause a status condition and saw this line- return super(attacker,opponent,hitnum,alltargets,showanimation) if pbIsDamaging?
    That line of code should be the one that does damage so to have it go before the soak effect I would put it like this

    Code:
    class PokeBattle_Move_061 < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        return super(attacker,opponent,hitnum,alltargets,showanimation) if pbIsDamaging?
        if opponent.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(attacker)
          @battle.pbDisplay(_INTL("But it failed!"))  
          return -1
        end
    I haven't tested this but I think this should work. Make sure the return super starts at the same row as the ifs it should be 2 tab clicks. Hope this helps!
     
    Last edited by a moderator:
    Back
    Top