• 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.
  • 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!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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] Primary Ability

  • 217
    Posts
    15
    Years
    • Seen Nov 29, 2021
    So I want to add a field to Pokemon called "Primary Ability", which evolved from my attempt at a cheap, hacky work-around to the amount of work required to give pokemon two active abilities.

    The basics of it, each pokemon will have an Primary Ability, that doesn't change. If it's that species, it'll have that Primary Ability. The Primary Ability can't be negated. Then the pokemon has a range of abilities as normal for its "secondary" ability.

    The only thing is, it involves compiler script, and I am completely lost at that.

    I also need to modify hasWorkingAbility (would hasAbility also need modifying?) to check whether the primary ability matches, but I'm assuming I can't do that until it's established in the compiler?
     
    I'm not confident editing the compiler as well but here goes my two cents:

    the method def pbCompilePokemonData has a section that presumably reads the abilites in the PBS pokemon.txt

    I'd start by editing:

    Code:
    "Abilities"=>[2,"EG",PBAbilities,PBAbilities],

    in

    "Abilities"=>[2,"EGG",PBAbilities,PBAbilities,PBAbilities],

    adding a second ability to the first couple pokémons and seeing which error pops up.
     
    I'm not entirely sure, but I believe that would just add a third non-hidden ability to be chosen on generation. What I'm looking for is an entirely new field, like adding a third type would be.

    Only, abilities have a whole lot more of referencing and complex coding compared to types.
     
    I'm not entirely sure, but I believe that would just add a third non-hidden ability to be chosen on generation. What I'm looking for is an entirely new field, like adding a third type would be.

    Only, abilities have a whole lot more of referencing and complex coding compared to types.

    Yeah that's right, I haven't put much thought into it. On a deeper analysis (but I might be just speculating again) I saw that abilites are more than often referenced through hasworkingability but only ever introduced with attr_accessor :ability and in the method def pbInitPokemon with @ability = pkmn.ability. Even the compiler all it seems to do is to read the PBS pokémon.txt. Maybe it's possible to add another piece of code called attr_accessor :secondaryability with its relative @secondaryability = pkmn.secondaryability in def pbInitPokemon.
     
    I tried adding this:
    Code:
     "PrimaryAbility"=>[56,"e",PBPrimaryAbilities],
    This:
    Code:
    def pbCompilePrimaryAbility
      records=[]
      movenames=[]
      movedescs=[]
      maxValue=0
      pbCompilerEachPreppedLine("PBS/abilities.txt"){|line,lineno|
         record=pbGetCsvRecord(line,lineno,[0,"vnss"])
         movenames[record[0]]=record[2]
         movedescs[record[0]]=record[3]
         maxValue=[maxValue,record[0]].max
         records.push(record)
      }
      MessageTypes.setMessages(MessageTypes::Abilities,movenames)
      MessageTypes.setMessages(MessageTypes::AbilityDescs,movedescs)
      code="class PBPrimaryAbilities\r\n"
      for rec in records
        code+="#{rec[1]}=#{rec[0]}\r\n"
      end
      code+="\r\ndef PBPrimaryAbilities.getName(id)\r\nreturn pbGetMessage(MessageTypes::Abilities,id)\r\nend"
      code+="\r\ndef PBPrimaryAbilities.getCount\r\nreturn #{records.length}\r\nend\r\n"
      code+="\r\ndef PBPrimaryAbilities.maxValue\r\nreturn #{maxValue}\r\nend\r\nend"
      eval(code)
      pbAddScript(code,"PBPrimaryAbilities")
    end
    And this:
    Code:
        yield(_INTL("Compiling primary ability data"))
        pbCompilePrimaryAbility
    Which is basically just educated guesswork, but it leads to:
    Exception: NameError

    Message: undefined local variable or method `datatype' for SerialRecord:Class

    Compiler:853:in `decode'

    Compiler:1625:in `readItemList'

    Compiler:1621:in `each'

    Compiler:1621:in `readItemList'

    Compiler:1618:in `pbRgssOpen'

    SpriteWindow:1776:in `open'

    SpriteWindow:1776:in `pbRgssOpen'

    Compiler:1618:in `readItemList'

    PScreen_Load:325:in `pbStartLoadScreen'

    Main:6:in `main'
     
    Back
    Top