• 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.

[Scripting Question] Custom Abilities - Change Moves to Dual-Typing

sonicfan7895

Just a dude, I guess
  • 120
    Posts
    14
    Years
    Hello all! My last post regarding this matter got necro-ed and I thought I might try this again.

    I am working on a couple of games in Essentials, and I had the idea to make some abilities like Refrigerate and Pixilate, except they change a move into a dual-typing (i.e. Flying Press). I feel that this time around I go into great detail and actually show what's going on instead of being vague about it.

    Spoiler:


    Here's my current code in PokeBattle_Move (lines 78-108):

    Code:
    def pbModifyType(type,attacker,opponent)
        if type>=0
          if attacker.hasWorkingAbility(:NORMALIZE) && hasConst?(PBTypes,:NORMAL)
            type=getConst(PBTypes,:NORMAL)
          elsif isConst?(type,PBTypes,:NORMAL)
            if attacker.hasWorkingAbility(:AERILATE) && hasConst?(PBTypes,:FLYING)
              type=getConst(PBTypes,:FLYING)
              @powerboost=true
            elsif attacker.hasWorkingAbility(:REFRIGERATE) && hasConst?(PBTypes,:ICE)
              type=getConst(PBTypes,:ICE)
              @powerboost=true
            elsif attacker.hasWorkingAbility(:PIXILATE) && hasConst?(PBTypes,:FAIRY)
              type=getConst(PBTypes,:FAIRY)
              @powerboost=true
            elsif attacker.hasWorkingAbility(:CORRUPTION) && hasConst?(PBTypes,:DARK)
              type=getConst(PBTypes,:DARK)
              @powerboost=true
            elsif attacker.hasWorkingAbility(:METALLURGY) && hasConst?(PBTypes,:STEEL)
              type=getConst(PBTypes,:STEEL)
              @powerboost=true
            elsif attacker.hasWorkingAbility(:MAGMARIZE) && hasConst?(PBTypes,:FIRE)
              type=getConst(PBTypes,:FIRE)
              @powerboost=true
            [S-HIGHLIGHT]elsif attacker.hasWorkingAbility(:DEMONIZE) && hasConst?(PBTypes,:GHOST,:DARK)
              type=getConst(PBTypes,:GHOST,:DARK)
              @powerboost=true[/S-HIGHLIGHT]
            end
          end
        end
        return type
      end

    From my current PokeBattle_Move (lines 659-667):

    Code:
    if (attacker.hasWorkingAbility(:AERILATE) ||
           attacker.hasWorkingAbility(:REFRIGERATE) ||
           attacker.hasWorkingAbility(:CORRUPTION) ||
           attacker.hasWorkingAbility(:METALLURGY) ||
           attacker.hasWorkingAbility(:MAGMARIZE) ||
           [S-HIGHLIGHT]attacker.hasWorkingAbility(:DEMONIZE)[/S-HIGHLIGHT] ||
           attacker.hasWorkingAbility(:PIXILATE)) && @powerboost
          damagemult=(damagemult*1.3).round
        end

    And from my current Pokemon_MegaEvolution (lines 1743-1768), where I intend to place the ability:

    Code:
    MultipleForms.register(:ZOROARK,{
    "getMegaForm"=>proc{|pokemon|
       next 1 if isConst?(pokemon.item,PBItems,:ZOROITE)
       next
    },
    "getBaseStats"=>proc{|pokemon|
       next [60,80,80,150,150,85] if pokemon.form==1
       next
    },
    "getAbilityList"=>proc{|pokemon|
       next [[[S-HIGHLIGHT]getID(PBAbilities,:DEMONIZE)[/S-HIGHLIGHT],0]] if pokemon.form==1
       next
    },
    "height"=>proc{|pokemon|
       next 19 if pokemon.form==1
       next
    },
    "weight"=>proc{|pokemon|
       next 895 if pokemon.form==1
       next
    },
    "type2"=>proc{|pokemon|
       next getID(PBTypes,:GHOST) if pokemon.form==1
       next
    },
    })

    Seems all well and good, especially on paper. But then, when I go to actually use the move with my intended Mega, I get this error (this is a picture of the said error, I promise):
    https://drive.google.com/open?id=0B7naGiszoz_raklUVlJzTWxvT2c

    What can I do to remedy this? I really want this to be a thing in my team's game...

    Any help is appreciated greatly! Thanks in advance!
     
    Last edited by a moderator:
    Code:
    type=getConst(PBTypes,:GHOST,:DARK)
    This is the line. You can't do two types like that.
    Code:
    type=getConst(PBTypes,:GHOST)
    is the proper way to do that. The question becomes how to add the Dark typing. It wouldn't be in the by adding it to the pbModifyType function.

    To add the Dark type, go to the function pbTypeModifier, found on line 358 of PokeBattle_Move. Add in the red lines, which are an alteration of the code Flying Press uses.

    Code:
      def pbTypeModifier(type,attacker,opponent)
        return 8 if type<0
        return 8 if isConst?(type,PBTypes,:GROUND) && opponent.pbHasType?(:FLYING) &&
                    opponent.hasWorkingItem(:IRONBALL) && !USENEWBATTLEMECHANICS
        atype=type # attack type
        otype1=opponent.type1
        otype2=opponent.type2
        otype3=opponent.effects[PBEffects::Type3] || -1
        # Roost
        if isConst?(otype1,PBTypes,:FLYING) && opponent.effects[PBEffects::Roost]
          if isConst?(otype2,PBTypes,:FLYING) && isConst?(otype3,PBTypes,:FLYING)
            otype1=getConst(PBTypes,:NORMAL) || 0
          else
            otype1=otype2
          end
        end
        if isConst?(otype2,PBTypes,:FLYING) && opponent.effects[PBEffects::Roost]
          otype2=otype1
        end
        # Get effectivenesses
        mod1=PBTypes.getEffectiveness(atype,otype1)
        mod2=(otype1==otype2) ? 2 : PBTypes.getEffectiveness(atype,otype2)
        mod3=(otype3<0 || otype1==otype3 || otype2==otype3) ? 2 : PBTypes.getEffectiveness(atype,otype3)
        if opponent.hasWorkingItem(:RINGTARGET)
          mod1=2 if mod1==0
          mod2=2 if mod2==0
          mod3=2 if mod3==0
        end
        # Foresight
        if attacker.hasWorkingAbility(:SCRAPPY) ||
           opponent.effects[PBEffects::Foresight]
          mod1=2 if isConst?(otype1,PBTypes,:GHOST) && PBTypes.isIneffective?(atype,otype1)
          mod2=2 if isConst?(otype2,PBTypes,:GHOST) && PBTypes.isIneffective?(atype,otype2)
          mod3=2 if isConst?(otype3,PBTypes,:GHOST) && PBTypes.isIneffective?(atype,otype3)
        end
        # Miracle Eye
        if opponent.effects[PBEffects::MiracleEye]
          mod1=2 if isConst?(otype1,PBTypes,:DARK) && PBTypes.isIneffective?(atype,otype1)
          mod2=2 if isConst?(otype2,PBTypes,:DARK) && PBTypes.isIneffective?(atype,otype2)
          mod3=2 if isConst?(otype3,PBTypes,:DARK) && PBTypes.isIneffective?(atype,otype3)
        end
        # Delta Stream's weather
        if @battle.pbWeather==PBWeather::STRONGWINDS
          mod1=2 if isConst?(otype1,PBTypes,:FLYING) && PBTypes.isSuperEffective?(atype,otype1)
          mod2=2 if isConst?(otype2,PBTypes,:FLYING) && PBTypes.isSuperEffective?(atype,otype2)
          mod3=2 if isConst?(otype3,PBTypes,:FLYING) && PBTypes.isSuperEffective?(atype,otype3)
        end
        # Smack Down makes Ground moves work against fliers
        if !opponent.isAirborne?(attacker.hasMoldBreaker) ||
           @function==0x11C # Smack Down
          mod1=2 if isConst?(otype1,PBTypes,:FLYING) && isConst?(atype,PBTypes,:GROUND)
          mod2=2 if isConst?(otype2,PBTypes,:FLYING) && isConst?(atype,PBTypes,:GROUND)
          mod3=2 if isConst?(otype3,PBTypes,:FLYING) && isConst?(atype,PBTypes,:GROUND)
        end
        if @function==0x135 && !attacker.effects[PBEffects::Electrify] # Freeze-Dry
          mod1=4 if isConst?(otype1,PBTypes,:WATER)
          if isConst?(otype2,PBTypes,:WATER)
            mod2=(otype1==otype2) ? 2 : 4
          end
          if isConst?(otype3,PBTypes,:WATER)
            mod3=(otype1==otype3 || otype2==otype3) ? 2 : 4
          end
        end
    [COLOR="Red"]    if isConst?(type,PBTypes,:GHOST) && @powerboost &&
               attacker.hasWorkingAbility(:DEMONIZE)
          type2=getConst(PBTypes,:DARK) || -1
          if type2>=0
            mult=PBTypes.getCombinedEffectiveness(type2,opponent.type1,opponent.type2)
            if opponent.effects[PBEffects::Type3]>=0 &&
               opponent.effects[PBEffects::Type3]!=opponent.type1 &&
               opponent.effects[PBEffects::Type3]!=opponent.type2
              mult*=PBTypes.getEffectiveness(type2,opponent.effects[PBEffects::Type3])
            else
              mult*=2
            end
          end
          return mod1*mod2*mod3*(mult/8.0)
        end[/COLOR]
        return mod1*mod2*mod3
      end

    Note that the if statement checks to see if the move is a Ghost type move that got the power boost from an -Iate ability. That is because by the time that pbTypeModifier runs, pbModifyType has already modified the type of the Normal type move.
     
    Last edited:
    Note that the if statement checks to see if the move is a Ghost type move that got the power boost from an -Iate ability. That is because by the time that pbTypeModifier runs, pbModifyType has already modified the type of the Normal type move.

    Ahh! I see how that works now! Thank you very much, you have no idea how much that helps me out. :)
     
    Back
    Top