Jump to content

Raising Reborn's Ability limit


BlueTowel

Recommended Posts

  • Veterans

Hi! 

 

TL;DR: How can I increase the Ability limit without breaking the game? I couldn't work it out in a timely manner, and may work around the issue by combining identical abilities with different names.

 

While testing new Abilities for Alt Forms v0.6 with 8th Gen, I reached Ability #256 "Steely Spirit" and discovered it was blank. I checked Ability #257 "Wandering Spirit", and it was Ability #1 "Stench"!

So I asked on pokecommunity for advice on this problem, and Vendily (<3) pointed me towards a thread where the problem was in the Compiler assigning but one byte, or 256 entries, for the Ability index.

 

So I edited the Compiler, changing 

def pbCompilePokemonData

's 

  optionaltypes={
     "BattlerPlayerY"=>[0,"i"],
     "BattlerEnemyY"=>[0,"i"],
     "BattlerAltitude"=>[0,"i"],
     "EggMoves"=>[0,"*E",PBMoves],
     "FormNames"=>[0,"S"],
     "RegionalNumbers"=>[0,"*w"],
     "Evolutions"=>[0,"*ses",nil,PBEvolution],
     "Habitat"=>[7,"e",["","Grassland","Forest","WatersEdge","Sea","Cave","Mountain","RoughTerrain","Urban","Rare"]],
     "Type2"=>[9,"e",PBTypes],
     "Abilities"=>[29,"eg",PBAbilities,PBAbilities],
     "HiddenAbility"=>[40,"eggg",PBAbilities,PBAbilities,PBAbilities,PBAbilities],
     "WildItemCommon"=>[48,"*E",PBItems],
     "WildItemUncommon"=>[50,"*E",PBItems],
     "WildItemRare"=>[52,"*E",PBItems]
  }

to

  optionaltypes={
     "BattlerPlayerY"=>[0,"i"],
     "BattlerEnemyY"=>[0,"i"],
     "BattlerAltitude"=>[0,"i"],
     "EggMoves"=>[0,"*E",PBMoves],
     "FormNames"=>[0,"S"],
     "RegionalNumbers"=>[0,"*w"],
     "Evolutions"=>[0,"*ses",nil,PBEvolution],
     "Abilities"=>[2,"EG",PBAbilities,PBAbilities],
     "Habitat"=>[7,"e",["","Grassland","Forest","WatersEdge","Sea","Cave","Mountain","RoughTerrain","Urban","Rare"]],
     "Type2"=>[9,"e",PBTypes],
     "HiddenAbility"=>[40,"EGGG",PBAbilities,PBAbilities,PBAbilities,PBAbilities],
     "WildItemCommon"=>[48,"*E",PBItems],
     "WildItemUncommon"=>[50,"*E",PBItems],
     "WildItemRare"=>[52,"*E",PBItems]
  }

in order to match later versions of Essentials which don't have the same Ability limit.

 

I also changed the # Ability entry in PokeBattle_Pokemon to use pbDexDataOffset(dexdata,@species,2) instead of pbDexDataOffset(dexdata,@species,29) and changed all the fgetb to fgetw, but it didn't work.

Full #Ability code before and after in spoilers below.

Spoiler

Before

Spoiler


################################################################################
# Ability
################################################################################
# Returns the index of this Pokémon's ability.
  def abilityIndex
    abil=@abilityflag!=nil ? @abilityflag : (@personalID%3)
    return abil
  end

# Returns the ID of this Pokemon's ability.
  def ability
    abil=abilityIndex
    dexdata=pbOpenDexData
    pbDexDataOffset(dexdata,@species,29)
    ret1=dexdata.fgetb
    ret2=dexdata.fgetb
    pbDexDataOffset(dexdata,@species,40)
    h1=dexdata.fgetb
    h2=dexdata.fgetb
    h3=dexdata.fgetb
    h4=dexdata.fgetb
    dexdata.close
    ret=ret1
    if abil==2
      return h1 if h1>0
      abil=(@personalID&1)
    elsif abil==3
      return h2 if h2>0
      abil=(@personalID&1)
    elsif abil==4
      return h3 if h3>0
      abil=(@personalID&1)
    elsif abil==5
      return h4 if h4>0
      abil=(@personalID&1)
    end
    if abil==1
      ret=ret2
      ret=ret1 if ret2==0
    end
    return ret
  end

# Sets this Pokémon's ability to a particular ability (if possible).
  def setAbility(value)
    @abilityflag=value
  end

# Returns the list of abilities this Pokémon can have.
  def getAbilityList
    abils=[]; ret=[[],[]]
    dexdata=pbOpenDexData
    pbDexDataOffset(dexdata,@species,29)
    abils.push(dexdata.fgetb)
    abils.push(dexdata.fgetb)
    pbDexDataOffset(dexdata,@species,40)
    abils.push(dexdata.fgetb)
    abils.push(dexdata.fgetb)
    abils.push(dexdata.fgetb)
    abils.push(dexdata.fgetb)
    dexdata.close
    for i in 0...abils.length
      next if !abils[i] || abils[i]<=0
      ret[0].push(abils[i]); ret[1].push(i)
    end
    return ret
  end

 

 

After

Spoiler


################################################################################
# Ability
################################################################################
# Returns the index of this Pokémon's ability.
  def abilityIndex
    abil=@abilityflag!=nil ? @abilityflag : (@personalID%3)
    return abil
  end

# Returns the ID of this Pokemon's ability.
  def ability
    abil=abilityIndex
    dexdata=pbOpenDexData
    pbDexDataOffset(dexdata,@species,2)
    ret1=dexdata.fgetw
    ret2=dexdata.fgetw
    pbDexDataOffset(dexdata,@species,40)
    h1=dexdata.fgetw
    h2=dexdata.fgetw
    h3=dexdata.fgetw
    h4=dexdata.fgetw
    dexdata.close
    ret=ret1
    if abil==2
      return h1 if h1>0
      abil=(@personalID&1)
    elsif abil==3
      return h2 if h2>0
      abil=(@personalID&1)
    elsif abil==4
      return h3 if h3>0
      abil=(@personalID&1)
    elsif abil==5
      return h4 if h4>0
      abil=(@personalID&1)
    end
    if abil==1
      ret=ret2
      ret=ret1 if ret2==0
    end
    return ret
  end

# Sets this Pokémon's ability to a particular ability (if possible).
  def setAbility(value)
    @abilityflag=value
  end

# Returns the list of abilities this Pokémon can have.
  def getAbilityList
    abils=[]; ret=[[],[]]
    dexdata=pbOpenDexData
    pbDexDataOffset(dexdata,@species,2)
    abils.push(dexdata.fgetw)
    abils.push(dexdata.fgetw)
    pbDexDataOffset(dexdata,@species,40)
    abils.push(dexdata.fgetw)
    abils.push(dexdata.fgetw)
    abils.push(dexdata.fgetw)
    abils.push(dexdata.fgetw)
    dexdata.close
    for i in 0...abils.length
      next if !abils[i] || abils[i]<=0
      ret[0].push(abils[i]); ret[1].push(i)
    end
    return ret
  end

 

 

Abilities still worked correctly, but each Pokémon had two instances of its first Ability, and four instances of its Hidden Ability, which occurred in both the debug menu and when catching a sample of wild Pokémon (8 Abras, 3 had Synchronize, 5 had Magic Guard).

 

So I tried just importing the whole section from Essentials v17.2, code spoilered below, and changing self.fSpecies to @species in the pbDexDataOffset because Reborn doesn't have fSpecies...

Spoiler

################################################################################
# Ability
################################################################################
# Returns the index of this Pokémon's ability.
  def abilityIndex
    abil=@abilityflag!=nil ? @abilityflag : (@personalID&1)
    return abil
  end

# Returns the ID of this Pokémon's ability.
  def ability
    abil=abilityIndex
    abils=getAbilityList
    ret1=0; ret2=0
    for i in 0...abils.length
      next if !abils[i][0] || abils[i][0]<=0
      return abils[i][0] if abils[i][1]==abil
      ret1=abils[i][0] if abils[i][1]==0
      ret2=abils[i][0] if abils[i][1]==1
    end
    abil=(@personalID&1) if abil>=2
    return ret2 if abil==1 && ret2>0
    return ret1
  end

# Returns whether this Pokémon has a particular ability.
  def hasAbility?(value=0)
    if value==0
      return self.ability>0
    else
      if value.is_a?(String) || value.is_a?(Symbol)
        value=getID(PBAbilities,value)
      end
      return self.ability==value
    end
    return false
  end

# Sets this Pokémon's ability to a particular ability (if possible).
  def setAbility(value)
    @abilityflag=value
  end

  def hasHiddenAbility?
    abil=abilityIndex
    return abil!=nil && abil>=2
  end

# Returns the list of abilities this Pokémon can have.
  def getAbilityList
    abils=[]; ret=[]
    dexdata=pbOpenDexData
    pbDexDataOffset(dexdata,self.fSpecies,2)
    abils.push(dexdata.fgetw)
    abils.push(dexdata.fgetw)
    pbDexDataOffset(dexdata,self.fSpecies,40)
    abils.push(dexdata.fgetw)
    abils.push(dexdata.fgetw)
    abils.push(dexdata.fgetw)
    abils.push(dexdata.fgetw)
    dexdata.close
    for i in 0...abils.length
      next if !abils[i] || abils[i]<=0
      ret.push([abils[i],i])
    end
    return ret
  end

 

But this just straight up broke Abilities, with Pokémon having blank Ability entries and lists. Frankensteining bits of each together accomplished nothing either.

 

So I cycled back to looking at fgetw to see how it differs from fgetb, read up on arrays a bit, and I can see that they differ in more than just byte sizes, so I'm not sure how to go about changing the code to increase the Ability limit.

Spoiler

  def fgetb
    x=0
    ret=0
    each_byte do |i|
      ret=i || 0
      break
    end
    return ret
  end

  def fgetw
    x=0
    ret=0
    each_byte do |i|
      break if !i
      ret|=(i<<x)
      x+=8
      break if x==16
    end
    return ret
  end

 

I was recommended to work around it rather than try to change it, so for now I'm folding Libero into Protean and Propeller Tail into Stalwart.

But I thought I should ask, is this an easy problem for anyone to solve?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...