• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Dawn, Gloria, Juliana, or Summer - 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] Edit a base stat depending on held item

hirokimura

Miltank's Fanboy Number One
  • 150
    Posts
    7
    Years
    Hey !
    I'd like to know if it's possible to edit BS based on a held item.
    Let's say I have a Charizard (BS Speed -> 100) I'd like to make it's BS speed become 140 if it holds an item, and only while holding it.
    Is it doable?
    Thanks !
     
    in the code, locate def calcStats and replace it with something like this
    Code:
      def calcStat(base,level,iv,ev,pv)
        base = (statnumber) if isSpecies?(species) && hasWorkingItem(item)
        return ((((base*2+iv+(ev>>2))*level/100).floor+5)*pv/100).floor
      end
    this will appear in the stat screen, as opposed to what the quick powder method the above post mentioned
     
    Thanks for the answers, really :)
    Anther quick question, do you know if there is a way of targeting a specific stat? Like if I want to target atk or speed only. By the way I understand the class definition it takes every stats in consideration.
     
    duplicating def calcStats into 5 variants each according to each stat and using that would work also. something akin to this should work
    Code:
      def calcATK(base,level,iv,ev,pv)
        return ((((base*2+iv+(ev>>2))*level/100).floor+5)*pv/100).floor
      end
    
      def calcDEF(base,level,iv,ev,pv)
        return ((((base*2+iv+(ev>>2))*level/100).floor+5)*pv/100).floor
      end
    
      def calcSPE(base,level,iv,ev,pv)
        return ((((base*2+iv+(ev>>2))*level/100).floor+5)*pv/100).floor
      end
    
      def calcSPA(base,level,iv,ev,pv)
        return ((((base*2+iv+(ev>>2))*level/100).floor+5)*pv/100).floor
      end
    
      def calcSPE(base,level,iv,ev,pv)
        return ((((base*2+iv+(ev>>2))*level/100).floor+5)*pv/100).floor
      end
    
      def calcStats
        nature=self.nature
        stats=[]
        pvalues=[100,100,100,100,100]
        nd5=(nature/5).floor
        nm5=(nature%5).floor
        if nd5!=nm5
          pvalues[nd5]=110
          pvalues[nm5]=90
        end
        level=self.level
        bs=self.baseStats
        for i in 0..5
          base=bs[i]
          if i==PBStats::HP
            stats[i]=calcHP(base,level,@iv[i],@ev[i])
          elsif i==PBStats::ATTACK
            stats[i]=calcATK(base,level,@iv[i],@ev[i],pvalues[i-1])
          elsif i==PBStats::DEFENSE
            stats[i]=calcDEF(base,level,@iv[i],@ev[i],pvalues[i-1])
          elsif i==PBStats::SPEED
            stats[i]=calcSPE(base,level,@iv[i],@ev[i],pvalues[i-1])
          elsif i==PBStats::SPATK
            stats[i]=calcSPA(base,level,@iv[i],@ev[i],pvalues[i-1])
          elsif i==PBStats::SPDEF
            stats[i]=calcSPE(base,level,@iv[i],@ev[i],pvalues[i-1])
          end
        end
        diff=@totalhp-@hp
        @totalhp=stats[0]
        @hp=@totalhp-diff
        @hp=0 if @hp<=0
        @hp=@totalhp if @hp>@totalhp
        @attack=stats[1]
        @defense=stats[2]
        @speed=stats[3]
        @spatk=stats[4]
        @spdef=stats[5]
      end
    of course apply the modification I gave above to the proper sections, with any modifications you want to be in a similar vein to use it.
     
    Nice answer ! Thanks for taking so much time to explain this ! I'll try to mess it a bit and post a resource when I'll be able to do what I want :)
    Thank you :)
     
    Nice answer ! Thanks for taking so much time to explain this ! I'll try to mess it a bit and post a resource when I'll be able to do what I want :)
    Thank you :)

    credit should also go to pokemon emyprean. they gave me the basis for this brain child with their card system.
     
    No problem ! To be honest, when I'm looking at the code carefully, this seems so complete, I mean, if I'm doing it right, I'll just post the final code here and let you decide to post it or not as a resource, since I won't have to do anything xD
    Thanks so much for the help !
     
    Back
    Top