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

[Question] [SOLVED] Mints Items (SWSH)

WolfPP

Spriter/ Pixel Artist
  • 1,309
    Posts
    5
    Years
    Am trying to make a script for Mints items (from SWSH). So, what I have so far:
    Spoiler:


    The question is, the code doesn't recognize what is 'stats' (even if 'attack', if I write 'pokemon.attack'):
    Spoiler:


    IDK if is possible to put some attr_reader or access inside 'PItem_ItemEffects' or 'PItem_Items'...
     
    Last edited:

    WolfPP

    Spriter/ Pixel Artist
  • 1,309
    Posts
    5
    Years
    "There are some attributes of a Pokémon that cannot be changed directly."
    Let's wait until someone can answer me how to change it indirectly.
     
  • 658
    Posts
    7
    Years
    What if we create a new attribute for the Pokemon called BirthNature which will be displayed in the summary screen and will be used for breeding. The regular Nature will be what is used to calculate stats and so A Timid Pokemon by Birth, can have the stats of an Adamant Pokémon (When adamant mint is used) but display Timid in the stat screen and behave like a Timid Pokemon while breeding.

    As I am typing this, it seems a little ambitious but might be doable.
     

    WolfPP

    Spriter/ Pixel Artist
  • 1,309
    Posts
    5
    Years
    What if we create a new attribute for the Pokemon called BirthNature which will be displayed in the summary screen and will be used for breeding. The regular Nature will be what is used to calculate stats and so A Timid Pokemon by Birth, can have the stats of an Adamant Pokémon (When adamant mint is used) but display Timid in the stat screen and behave like a Timid Pokemon while breeding.

    As I am typing this, it seems a little ambitious but might be doable.

    Good idea but I think we just need to find a way to create a new 'def', copying how these works:
    Code:
    # Returns the specified stat of this Pokémon (not used for total HP).
      def calcStat(base,level,iv,ev,pv)
        return ((((base*2+iv+(ev>>2))*level/100).floor+5)*pv/100).floor
      end
    
    # Recalculates this Pokémon's stats.
      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])
          else
            stats[i]=calcStat(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
     

    Lord X-Giga-X

    Sardonyx's Evil Dev
  • 42
    Posts
    5
    Years
    • Seen Apr 4, 2022
    I've actually been working on some coding for mint items myself. And while I don't have the coding for the items themselves set up yet, I did set up some coding for a secondary nature. Although kinda the reverse of what Golisopod User suggested. The second nature account I set up is for the nature that's taken into account for stat calculation. And it was actually a lot simpler than it sounds at first.

    So what I ended up doing is of course setting up a flag for the secondary nature, adding the following line at the list of attributes in PokeBattle_Pokemon:
    Code:
    attr_accessor(:nature2flag)
    (As note, I've named all of the involved coding and defs like this for easy reference for myself. Name them as you choose.)

    Next, I added the following def under def nature:
    Code:
      def nature2
        return @nature2flag if @nature2flag!=nil
        return self.nature
      end
    This returns the secondary nature, or the original nature of the Pokémon if one is not set. This is important because in def calcStats, I changed
    Code:
    nature=self.nature
    to
    Code:
    nature=self.nature2
    Normally, this would only mean the stat nature would factor into stat calculation. But because nature2 returns the original nature if the stat nature flag is not set, it'll still calculate stats using the original nature.

    I also created a new def for setting the stat nature copied from the original def setNature(value) to test the change in Debug before eventually moving on to the items. And of course edited the summary page showing the nature's stat effects to use nature2 rather nature.

    I'm going to do more testing with this coding in general, although so far I've had no issues. Hope this helps.


    EDIT: Going back into it, I also made a copy of def hasNature? for the stat nature.
     
    Last edited:
    Back
    Top