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

Changing move category depending on attacker's best stat?

824
Posts
8
Years
  • Code:
    class PokeBattle_Move_169 < PokeBattle_Move
      def pbIsPhysical?(type,attacker)
        if @battle.field.effects[PBEffects::WonderRoom]>0
          return attacker.spatk>=attacker.attack
        else
          return attacker.attack>attacker.spatk
        end
      end
    
      def pbIsSpecial?(type,attacker)
        if @battle.field.effects[PBEffects::WonderRoom]>0
          return attacker.attack>attacker.spatk
        else
          return attacker.spatk>=attacker.attack
        end
      end
    
    end

    Untested. I also took the liberty of including Wonder Room's effect (since it makes Physical moves Special and vice versa).

    However, to make this work, you'd have to go into PokeBattle_Move, find "def pbIsPhysical?(type)" and change it to "def pbIsPhysical?(type,attacker=nil)", do something similar to "def pbIsSpecial?(type)", then go through the entirety of the rest of that script section hunting for pbIsPhysical? or pbIsSpecial?, so you can add the second argument.

    I could do the last paragraph for you, but I'd need a copy of your PokeBattle_Move since I've made some heavy edits to mine and don't know what edits you've made to yours.


    I actually used Hidden Power to help me out on this one, since this is very Hidden-Power-esque in that the move changes based on the user's strengths. Thing is, pbType(), the function used to determine the move's final typing before it actually hits, already uses the term "attacker" as an argument, most likely due to Hidden power.
     
    Last edited:
    91
    Posts
    14
    Years
    • Seen Sep 5, 2015
    This is my PokeBattle_Move. http://pastebin.com/DPqbnR5y And this is after editing "def pbIsPhysical?(type,attacker=nil) and Special. http://pastebin.com/83VJksyP

    Problem is, the move is not doing damage. I changed the function code in the PBS Moves file in Hidden Power to my new function, but I feel it's lacking something such as
    "def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)"
    because it's also not doing its animation.

    Thank you very much for your help.
     
    Last edited:
    824
    Posts
    8
    Years
  • This is my PokeBattle_Move. http://pastebin.com/DPqbnR5y And this is after editing "def pbIsPhysical?(type,attacker=nil) and Special. http://pastebin.com/83VJksyP

    Problem is, the move is not doing damage. I changed the function code in the PBS Moves file in Hidden Power to my new function, but I feel it's lacking something such as
    "def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)"
    because it's also not doing its animation.

    Thank you very much for your help.

    Interesting, Didn't know Wonder Room was a Gen VI Pack thing. Will do updates now.
     
    824
    Posts
    8
    Years
  • http://pastebin.com/cdTBBn2P

    Replace your Pokebattle_Move with that.

    Code:
    ################################################################################
    # Power and type depends on the user's IVs.
    ################################################################################
    class PokeBattle_Move_090 < PokeBattle_Move
      def pbType(type,attacker,opponent)
        hp=pbHiddenPower(attacker.iv)
        return hp[0]
      end
    
      def pbBaseDamage(basedmg,attacker,opponent)
        hp=pbHiddenPower(attacker.iv)
        return hp[1]
      end
    
      def pbIsPhysical?(type,attacker)
        if attacker.attack==attacker.spatk
          if attacker.defense==attacker.spdef
            return ($Trainer.id)%2==0
          end
          return attacker.defense>attacker.spdef
        end
        return attacker.attack>attacker.spatk
      end
    
      def pbIsSpecial?(type,attacker)
        if attacker.attack==attacker.spatk
          if attacker.defense==attacker.spdef
            return ($Trainer.id)%2==1
          end
          return attacker.defense<attacker.spdef
        end
        return attacker.attack<attacker.spatk
      end
    end
    
    def pbHiddenPower(iv)
      powermin=30
      powermax=70
      type=0; base=0
      types=[]
      for i in 0..PBTypes.maxValue
        types.push(i) if !PBTypes.isPseudoType?(i) && !isConst?(i,PBTypes,:FAIRY) &&
                         !isConst?(i,PBTypes,:NORMAL) && !isConst?(i,PBTypes,:SHADOW)
      end
      type|=(iv[PBStats::HP]&1)
      type|=(iv[PBStats::ATTACK]&1)<<1
      type|=(iv[PBStats::DEFENSE]&1)<<2
      type|=(iv[PBStats::SPEED]&1)<<3
      type|=(iv[PBStats::SPATK]&1)<<4
      type|=(iv[PBStats::SPDEF]&1)<<5
      type=(type*(types.length-1)/63).floor
      hptype=types[type]
      base|=(iv[PBStats::HP]&2)>>1
      base|=(iv[PBStats::ATTACK]&2)
      base|=(iv[PBStats::DEFENSE]&2)<<1
      base|=(iv[PBStats::SPEED]&2)<<2
      base|=(iv[PBStats::SPATK]&2)<<3
      base|=(iv[PBStats::SPDEF]&2)<<4
      base=(base*(powermax-powermin)/63).floor+powermin
      return [hptype,base]
    end

    This should replace the existing Hidden Power code. I removed Fairy from consideration since the Gen VI pack didn't do that, which screws with Hidden Power's mechanics. If you don't have Fairy type in your game it shouldn't matter.

    The way I have this working is as follows:
    If the Pokemon's attack is greater than it's special attack, the move is Physical. If the special attack is greater, the move is Special.
    If the two are exactly the same, the game turns to its Defense and Special Defense to determine which is greater.
    If those are exactly the same, the game looks at the player's Trainer ID and if it's even, the move is Physical, if it's odd the move is Special. I wanted this case to be random each time the move was chosen, but then it would be weird because it would decide EVERY TIME the code asks whether the move was physical or Special. So I thought about using the number of turns, but I couldn't find any way to call that forth.
     
    91
    Posts
    14
    Years
    • Seen Sep 5, 2015
    Very interesting. Perhaps it could randomize a variable and take the even or odd.

    Did you test this? Using Hidden Power does absolutely nothing. Moreover, after the turn in which I use it, that means, the next turn after that, I will again get the "xxx used Hidden Power!" message, again doing nothing.
     
    824
    Posts
    8
    Years
  • Very interesting. Perhaps it could randomize a variable and take the even or odd.

    Did you test this? Using Hidden Power does absolutely nothing. Moreover, after the turn in which I use it, that means, the next turn after that, I will again get the "xxx used Hidden Power!" message, again doing nothing.

    That's very very odd. I didn't make any changes that could have made it a two-turn attack, and I'm applying the same logic to physicality and specialness that Hidden Power, Weather Ball, and Judgement/Techno Blast apply to type. Maybe we need Maruno or Mej to tell us what I'm doing wrong.

    You're telling me that it does nothing even after the changes in post #4?
     
    91
    Posts
    14
    Years
    • Seen Sep 5, 2015
    That's very very odd. I didn't make any changes that could have made it a two-turn attack, and I'm applying the same logic to physicality and specialness that Hidden Power, Weather Ball, and Judgement/Techno Blast apply to type. Maybe we need Maruno or Mej to tell us what I'm doing wrong.

    You're telling me that it does nothing even after the changes in post #4?

    Yeah, I'm checking if it could have been something I shouldn't have touched, but no,

    Perhaps it's related to PkBattle_Move line 1065?
    Code:
        if @function==90 # Hidden Power
          type=getConst(PBTypes,:NORMAL) || 0
        end
    Perhaps that's trying to set it as a normal type move, and then the function 90 excludes Normal type from the calculation, so it does nothing.

    Upon another check, it's not that the message repeats, but rather that the last message hadn't ended by the time I was choosing a new command, because it also happened with the dummy Blissey's attack. It got stuck after I chose my next move.


    Edit: Huh... Not a single move is doing damage... Status/Stat boosts work fine though. Something related to all the attacker=nil?
     
    824
    Posts
    8
    Years
  • Yeah, I'm checking if it could have been something I shouldn't have touched, but no,

    Perhaps it's related to PkBattle_Move line 1065?
    Code:
        if @function==90 # Hidden Power
          type=getConst(PBTypes,:NORMAL) || 0
        end
    Perhaps that's trying to set it as a normal type move, and then the function 90 excludes Normal type from the calculation, so it does nothing.
    No, I doubt that's it. The line of code you're quoting is just so moves like Bide and Mirror Coat count HP damage as Normal type damage, not whatever the Hidden Power actually was.

    The "Exclusion of normal" is so the game ignores Normal type when counting the number of types that Hidden Power can be.

    Upon another check, it's not that the message repeats, but rather that the last message hadn't ended by the time I was choosing a new command, because it also happened with the dummy Blissey's attack. It got stuck after I chose my next move.
    Okay, so it's not a two-turn attack, it's just the attack doesn't stop because it doesn't do damage. Hmm...

    EDIT: Okay, I've found instances of pbIsPhysical? and pbIsSpecial? in PokeBattle_Battler, PokeBattle_Battle, and PokeBattle_AI. Will need to edit those, too.
     
    Last edited:
    91
    Posts
    14
    Years
    • Seen Sep 5, 2015
    No, I doubt that's it. The line of code you're quoting is just so moves like Bide and Mirror Coat count HP damage as Normal type damage, not whatever the Hidden Power actually was.

    The "Exclusion of normal" is so the game ignores Normal type when counting the number of types that Hidden Power can be.


    Okay, so it's not a two-turn attack, it's just the attack doesn't stop because it doesn't do damage. Hmm...

    You won't believe how I just fixed the "all moves do no damage".

    Line 705
    Code:
    if type>=0 && pbIsSpecial?(type,attacker)
    It's type. in the pasta you posted :p
    Changed that into a , and moves back to doing damage (checked twice).

    Still no luck with Hidden Power. Im comparing the PokeBattle_MoveEffects to a vanilla one, but there are no big differences.
     
    824
    Posts
    8
    Years
  • Adding
    Code:
    ,attacker=nil
    ? Even to those that didn't have "attacker)" before?

    On my way!

    NO NO NO! DON'T!

    1.) it's "attacker", not "attacker=nil"
    2.) sometimes the attacker isn't named "attacker", but sometimes something like "user" or something.

    Doing it your way could end up just deleting your battler mid move, or throw up a game-crashing error.
     
    824
    Posts
    8
    Years
  • In PokeBattle_Battler, both of the instances of "pbIsPhysical?" are in the following context:
    Code:
    move.pbIsPhysical?(movetype)
    Change them to
    Code:
    move.pbIsPhysical?(movetype[COLOR="Red"],user[/COLOR])

    There's one instance of "pbIsSpecial?", do the same thing:
    Code:
    move.pbIsSpecial?(movetype[COLOR="red"],user[/COLOR])




    In PokeBattle_Battle, there's one line of code involving both pbIsPhysical? and pbIsSpecial?. I'm not sure if your copy will have this line since it has to do with the Assult Vest.
    Code:
        if thispkmn.hasWorkingItem(:ASSAULTVEST) && !(thismove.pbIsPhysical?(thismove.type[COLOR="red"],thispkmn[/COLOR]) || thismove.pbIsSpecial?(thismove.type[COLOR="red"],thispkmn[/COLOR]))
    If you do have that line, add the red stuff.





    in Pokebattle_AI, you can go through and just add ",attacker" before the close parenthesis on every instance of the two functions since it's just an altered version of the damage calculation subroutine from PokeBattle_Move to allow the AI to choose which move is better.
     
    Last edited:
    91
    Posts
    14
    Years
    • Seen Sep 5, 2015
    It's working! I'm testing several Pokémon against a Wobbufet. When Aerodactly uses it, Mirror Coat fails, and Counter works. When Magneton uses it, the opposite happens.

    YOU DID IT

    Now I'm trying to figure out how to ignore all those calculations and make it only use a certain type for all species, but that's easy compared to everything else.
     
    824
    Posts
    8
    Years
  • It's working! I'm testing several Pokémon against a Wobbufet. When Aerodactly uses it, Mirror Coat fails, and Counter works. When Magneton uses it, the opposite happens.

    YOU DID IT

    Woot!



    Now I'm trying to figure out how to ignore all those calculations and make it only use a certain type for all species, but that's easy compared to everything else.

    Are you considering removing the "type is determined by the User's IVs" mechanic? Just remove the entire "def pbType" function from the Hidden Power code in Pokebattle_MoveEffects
     
    91
    Posts
    14
    Years
    • Seen Sep 5, 2015
    Woot!





    Are you considering removing the "type is determined by the User's IVs" mechanic? Just remove the entire "def pbType" function from the Hidden Power code in Pokebattle_MoveEffects

    You must be a wizard, because what you do is magic. I'll go ahead and edit my first post, so that other nabs such as me can get helped easily.
     
    Back
    Top