• 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?".
  • Staff applications for our PokéCommunity Daily and Social Media team are now open! Interested in joining staff? Then click here for more info!
  • 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.

Adding Dream World Abilities to the Wild

AmethystRain

pixie-powered judgment!
  • 253
    Posts
    12
    Years
    • Seen Nov 28, 2022
    Okay, so I totally feel annoying for asking two questions right in a row, but, whatever! :X

    Actually, last night I spent a good four hours peeling through the scripts to see if I could figure this out myself, but being that I'm not very familiar with Ruby and its logic yet, I eventually resigned...

    Anyway, my goal should be pretty self-explanatory from the title.
    I searched the other forum posts in this area for this as well, and while it looks like there was one tutorial about this, it was never completed. Furthermore, it was made, as I gather, before HiddenAbility appeared in pokemon.txt so I'm hoping that there's a simpler way now.

    Through my digging, I think it would be in this part of PokeBattle_Pokemon, right?
    Code:
    def abilityflag
        return @abilityflag if @abilityflag
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,@species,29)
        ret1=dexdata.fgetb
        ret2=dexdata.fgetb
        dexdata.close
        if ret1==ret2 || ret2==0
          return 0
        end
        return (@personalID&1)
      end
    
    # Gets the ID of this Pokemon's ability
      def ability
        abil=@abilityflag ? @abilityflag : (@personalID&1)
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,@species,29)
        ret1=dexdata.fgetb
        ret2=dexdata.fgetb
        pbDexDataOffset(dexdata,@species,37)
        ret3=dexdata.fgetb
        dexdata.close
        ret=ret1
        if abil==2
          if ret3>0
            return ret3
          else
            abil=(@personalID&1)
          end
        end
        if abil==1
          ret=ret2
          if ret2==0
            ret=ret1
          end
        end
        return ret
      end

    I'm just... not sure where to go from here. I tried! QQ

    Anyway, any insight into how I might be able to work this would be much appreciated.
     
    That's the right part of the scripts. Just add/change the red lines as follows:

    Code:
    def abilityflag
      return @abilityflag if @abilityflag
      dexdata=pbOpenDexData
      pbDexDataOffset(dexdata,@species,29)
      ret1=dexdata.fgetb
      ret2=dexdata.fgetb
      [COLOR=Red]pbDexDataOffset(dexdata,@species,37)
      ret3=dexdata.fgetb[/COLOR]
      dexdata.close
      [COLOR=Red]if ret3==0[/COLOR]
        if ret1==ret2 || ret2==0
          return 0
        [COLOR=Red]else[/COLOR]
          return (@personalID&1)
        [COLOR=Red]end[/COLOR]
      [COLOR=Red]else
        return (@personalID%3)
      end[/COLOR]
    end
    Note that in the last "return" line, it uses a percentage mark rather than an ampersand. This will return either 0, 1 or 2, which corresponds to the two regular plus one hidden ability. Each ability will have 1/3 chance of being used.

    Be a bit careful with this, though. It doesn't consider the possibilities of the third (hidden) ability being the same as either of the other two. What this means is that you can either have 1 ability, 2 abilities (50% chance of each regular ability, with no hidden ability), 3 abilities (33% chance of each) or 2 abilities (66%/33% chance, when the hidden ability is the same as a regular ability). This is more of a choice than you would otherwise have, but you just need to remember to fill up the regular abilities first.

    Here's a "for your information" paragraph. The &1 means "take the last digit from the binary version of @personalID" (which is either 0 or 1, because that's how binary rolls). &2 would mean "take the penultimate digit", which is also either 0 or 1, which doesn't help up here. The percentage mark means "divide by, and take the remainder", so %3 can only give a remainder of 0, 1 or 2 - these correspond to the abilities nicely so we'll use this. @personalID is a huge number, so there's practically the same chance of getting each remainder, hence the 1/3 chance of each ability.
     
    Last edited:
    ...Clever! I definitely would NOT have figured out the digit randomisation, much less the modulus, no matter the hours I poured over it.

    I'm a little bit confused about your note of caution though, or just that last sentence- "you just need to remember to fill up the regular abilities first."
    Does that mean if a Pokemon has only one natural ability and a dream world I should just make the dreamworld ability the secondary natural ability?
     
    If you have one natural ability and one hidden ability, then there will be 2/3 chance of having the regular ability and 1/3 chance of having the hidden ability. The abilityflag itself will still be 1, but it'll use ability 0 (but you're unlikely to ever care about that).

    I don't think there'll be any actual problems with this. I think the only issue is that, if you want a 50/50 chance of having either of two abilities, they must both be the regular abilities (with no hidden ability defined). It's just the probabilities you need to keep an eye on.
     
    I use this:
    Events.onWildPokemonCreate+=proc {|sender,e|
    pokemon=e[0]
    if $game_switches[140]
    i=rand(3)
    pokemon.abilityflag=0 if i==0
    pokemon.abilityflag=1 if i==1
    pokemon.abilityflag=2 if i==2
    end
    }
    You activate it in the map of beginning of the game:
    Switch 140 ON

    Certainly, does someone know how to do that you could choose the ability of the Pokemon of the trainers?
     
    I use this:

    You activate it in the map of beginning of the game:
    Switch 140 ON

    Certainly, does someone know how to do that you could choose the ability of the Pokemon of the trainers?
    Code:
    In PokemonTrainers change
    Code:
    for poke in trainer[3]
        species=poke[0]
        level=poke[1]
        pokemon=PokeBattle_Pokemon.new(species,level,opponent)
    to
    Code:
    cont=0
    for poke in trainer[3]
        species=poke[0]
        level=poke[1]
        pokemon=PokeBattle_Pokemon.new(species,level,opponent)
        pokemon.abilityflag=0 if $game_switches[170+count]
        pokemon.abilityflag=1 if $game_switches[176+count]
        pokemon.abilityflag=2 if $game_switches[182+count]
        cont+=1

    If the switch 170 is on the trainer first pokémon will have the first ability
    If the switch 171 is on the trainer second pokémon will have the first ability
    If the switch 172 is on the trainer third pokémon will have the first ability
    If the switch 173 is on the trainer forth pokémon will have the first ability
    If the switch 174 is on the trainer fifth pokémon will have the first ability
    If the switch 175 is on the trainer sixth pokémon will have the first ability

    If the switch 176 is on the trainer first pokémon will have the second ability
    If the switch 177 is on the trainer second pokémon will have the second ability
    If the switch 178 is on the trainer third pokémon will have the second ability
    If the switch 179 is on the trainer forth pokémon will have the second ability
    If the switch 180 is on the trainer fifth pokémon will have the second ability
    If the switch 181 is on the trainer sixth pokémon will have the second ability

    If the switch 182 is on the trainer first pokémon will have the hidden ability
    If the switch 183 is on the trainer second pokémon will have the hidden ability
    If the switch 184 is on the trainer third pokémon will have the hidden ability
    If the switch 185 is on the trainer forth pokémon will have the hidden ability
    If the switch 186 is on the trainer fifth pokémon will have the hidden ability
    If the switch 187 is on the trainer sixth pokémon will have the hidden ability

    Method 2:

    Change it instead to:
    Code:
    cont=0
    for poke in trainer[3]
        species=poke[0]
        level=poke[1]
        pokemon=PokeBattle_Pokemon.new(species,level,opponent)
        pokemon.abilityflag=pbGet(170+count) if 3>pbGet(170+count) && pbGet(170+count)>-1
        cont+=1

    If the variable 170 is 0,1 or 2 the trainer first pokémon will have this abilityflag
    If the variable 171 is 0,1 or 2 the trainer second pokémon will have this abilityflag
    If the variable 172 is 0,1 or 2 the trainer third pokémon will have this abilityflag
    If the variable 173 is 0,1 or 2 the trainer forth pokémon will have this abilityflag
    If the variable 174 is 0,1 or 2 the trainer fifth pokémon will have this abilityflag
    If the variable 175 is 0,1 or 2 the trainer sixth pokémon will have this abilityflag

    The best way is to change the compiler so you can set a flag in PBS, to do this put a "poke[10]" above the "poke[9]" in some scripts, and use it to determine the ability flag.
    Note that I don't test.
     
    Okay, then it is as I thought. Thank you very much. ^^

    As for the setting abilities for trainers, that's very useful too... But if I were to, for instance, use that method 2 way, does that mean I'd have to set those variables for every trainer battle?
     
    Okay, then it is as I thought. Thank you very much. ^^

    As for the setting abilities for trainers, that's very useful too... But if I were to, for instance, use that method 2 way, does that mean I'd have to set those variables for every trainer battle?
    Only just remember to set after battle to -1 or you can put after the line 'def pbEndBattle(result)' in PokeBattle_ActualScene:
    Code:
    for i in 170..176
      game_variables[i]=-1
    end
     
    Hah! Silly me forgot that these variables hold negatives. I'm used to working with ones that won't. Brilliant, thank you~
     
    Alternatively, you could wait until the next Essentials release which will contain a much easier method of doing just this (the "flag in PBS" thing FL mentioned above).
     
    Thank you, FL, but before beginning the battle against the trainer this happens:

    Exception: RuntimeError
    Message: Script error within event 7, map 1 (Pokémon Center):
    Exception: NameError
    Message: Section107:28:in `pbLoadTrainer'undefined local variable or method `count' for #<Interpreter:0x34b0430>
    ***Full script:
    pbTrainerBattle(PBTrainers::LEADER_Roxanne,"Roxy",_I("I enjoyed it."),false,0)
    :\
     
    Confirming the above error. Here's my version of the error for reference:

    Code:
    Exception: RuntimeError
    Message: Script error within event 10, map 38 (Grand Hall):
    Exception: NameError
    Message: Section107:28:in `pbLoadTrainer'undefined local variable or method `count' for #<Interpreter:0xc13a238>
    ***Full script:
    pbTrainerBattle(PBTrainers::Cain,"Cain",_I("Cute AND talented~"),false,0,true)
    Interpreter:243:in `pbExecuteScript'
    PokemonTrainers:24:in `each'
    PokemonTrainers:24:in `pbLoadTrainer'
    PokemonTrainers:7:in `each'
    PokemonTrainers:7:in `pbLoadTrainer'
    PokemonTrainers:309:in `pbTrainerBattle'
    (eval):1:in `pbExecuteScript'
    Interpreter:788:in `eval'
    Interpreter:243:in `pbExecuteScript'
    Interpreter:788:in `command_111'
    
    Interpreter:276:in `pbExecuteScript'
    Interpreter:788:in `command_111'
    Interpreter:320:in `execute_command'
    Interpreter:193:in `update'
    Interpreter:106:in `loop'
    Interpreter:198:in `update'
    Scene_Map:103:in `update'
    Scene_Map:101:in `loop'
    Scene_Map:114:in `update'
    Scene_Map:68:in `main'

    For the time being I'll just remove that bit and wait till support for it is built in. Thanks, though~
     
    It's not difficult to read the error message (the variable count isn't defined), then look at the tiny amount of code you added to figure out why. It's because the code sometimes calls it cont instead - this is a typo (it could have been worse). Make them all the same, and it'll work.
     
    Back
    Top