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

Help with Stall/ stalling items

1,224
Posts
10
Years
  • I'm trying to implement some of the older abilities that don't work for the Gen 6 project, and I'm having a bit of trouble implementing Stall. I'm not entirely sure about how pbPriority's ordering actually works, and I can't seem to get it. Hopefully you guys can help me out. Changes highlighted in red.

    Code:
    def pbPriority(ignorequickclaw=false)
        if @usepriority
          # use stored priority if round isn't over yet
          return @priority
        end
        speeds=[]
        quickclaw=[]
        priorities=[]
        temp=[]
        stall=[]
        slowitem=[]
        @priority.clear
        maxpri=0
        minpri=0
        # Calculate each Pokémon's speed
        for i in 0...4
          speeds[i]=@battlers[i].pbSpeed
          quickclaw[i]=@battlers[i].hasWorkingItem(:QUICKCLAW)
          quickclaw[i]=false if @choices[i][0]!=1
          quickclaw[i]=false if ignorequickclaw
          [COLOR="red"]#Check for Stall or Lagging Tail or Full Incense
          stall[i]=(@battlers[i].hasWorkingAbility(:STALL))?true:false
          slowitem[i]=(@battlers[i].hasWorkingItem(:LAGGINGTAIL) || @battlers[i].hasWorkingItem(:FULLINCENSE))?true:false[/COLOR]
        end
        # Find the maximum and minimum priority
        for i in 0...4
          # For this function, switching and using items
          # is the same as using a move with a priority of 0
          pri=0
          if @choices[i][0]==1 # Is a move
            pri=@choices[i][2].priority
            pri+=1 if @battlers[i].hasWorkingAbility(:PRANKSTER) &&
                      @choices[i][2].basedamage==0 # Is status move
            pri+=1 if @battlers[i].hasWorkingAbility(:GALEWINGS) && 
               isConst?(@choices[i][2].type,PBTypes,:FLYING)
          end
          priorities[i]=pri
          if i==0
            maxpri=pri
            minpri=pri
          else
            maxpri=pri if maxpri<pri
            minpri=pri if minpri>pri
          end
        end
        # Find and order all moves with the same priority
        curpri=maxpri
        loop do
          temp.clear
          for j in 0...4
            if priorities[j]==curpri
              temp[temp.length]=j
            end
          end
          # Sort by speed
          if temp.length==1
            @priority[@priority.length]=@battlers[temp[0]]
          else
            n=temp.length
            usequickclaw=(pbRandom(16)<3)
            for m in 0..n-2
              for i in 1..n-1
                if quickclaw[temp[i]] && usequickclaw
                  cmp=(quickclaw[temp[i-1]]) ? 0 : -1 #Rank higher if without Quick Claw, or equal if with it
                elsif quickclaw[temp[i-1]] && usequickclaw
                  cmp=1 # Rank lower
                [COLOR="Red"]elsif stall[temp[i]] #Check for stall
                  cmp=(stall[temp[i-1]]) ? 0 : 1
                elsif slowitem[temp[i]] #Check for slowing items
                  cmp=(slowitem[temp[i-1]]) ? 0 : 1[/COLOR]
                else #check regular pokemon
                  cmp=(speeds[temp[i]]>speeds[temp[i-1]]) ? -1 : (speeds[temp[i]]==speeds[temp[i]])? 0 : 1 #Rank higher to higher-speed battler
                end
                if cmp<0
                  # put higher-speed Pokémon first
                  swaptmp=temp[i]
                  temp[i]=temp[i-1]
                  temp[i-1]=swaptmp
                elsif cmp==0
                  # swap at random if speeds are equal
                  if pbRandom(2)==0
                    swaptmp=temp[i]
                    temp[i]=temp[i-1]
                    temp[i-1]=swaptmp
                  end
                end
              end
            end
            #Now add the temp array to priority
            for i in temp
              @priority[@priority.length]=@battlers[i]
            end
          end
          curpri-=1
          break unless curpri>=minpri
        end
    =begin
        prioind=[
           @priority[0].index,
           @priority[1].index,
           @priority[2] ? @priority[2].index : -1,
           @priority[3] ? @priority[3].index : -1
        ]
        print("#{speeds.inspect} #{prioind.inspect}")
    =end
        @usepriority=true
        return @priority
      end

    It seems to sometimes work, but not always, so I've obviously done something wrong.
     
    Last edited:

    DeKay

    Mega Evolved
    22
    Posts
    9
    Years
    • Seen Oct 11, 2015
    Well I like the changes so far. But you forgot to mark half of the code that was changed.
    Also. Why did you remove the part where it only checks for stall if quickclaw isn't used. Because Quickclaw still works over stall. This would "reset" the priority.

    Code:
    def pbPriority(ignorequickclaw=false)
        if @usepriority
          # use stored priority if round isn't over yet
          return @priority
        end
        speeds=[]
        quickclaw=[]
        priorities=[]
        temp=[]
    [COLOR=Red]    stall=[][/COLOR]
    [COLOR=Red]    slowitem=[][/COLOR]
        @priority.clear
        maxpri=0
        minpri=0
        # Calculate each Pokémon's speed
        for i in 0...4
          speeds[i]=@battlers[i].pbSpeed
          quickclaw[i]=@battlers[i].hasWorkingItem(:QUICKCLAW)
          quickclaw[i]=false if @choices[i][0]!=1
          quickclaw[i]=false if ignorequickclaw
          #Check for Stall or Lagging Tail or Full Incense
    [COLOR=Red]      stall[i]=(@battlers[i].hasWorkingAbility(:STALL)) ? true : false
          slowitem[i]=(@battlers[i].hasWorkingItem(:LAGGINGTAIL) || @battlers[i].hasWorkingItem(:FULLINCENSE)) ? true : false[/COLOR]
        end
        # Find the maximum and minimum priority
        for i in 0...4
          # For this function, switching and using items
          # is the same as using a move with a priority of 0
          pri=0
          if @choices[i][0]==1 # Is a move
            pri=@choices[i][2].priority
            pri+=1 if @battlers[i].hasWorkingAbility(:PRANKSTER) &&
                      @choices[i][2].basedamage==0 # Is status move
            pri+=1 if @battlers[i].hasWorkingAbility(:GALEWINGS) && 
               isConst?(@choices[i][2].type,PBTypes,:FLYING)
          end
          priorities[i]=pri
          if i==0
            maxpri=pri
            minpri=pri
          else
            maxpri=pri if maxpri<pri
            minpri=pri if minpri>pri
          end
        end
        # Find and order all moves with the same priority
        curpri=maxpri
        loop do
          temp.clear
          for j in 0...4
            if priorities[j]==curpri
              temp[temp.length]=j
            end
          end
          # Sort by speed
          if temp.length==1                                                 [COLOR=Blue]#This could be the problem | If this is executed it wont check for the enemy having Stall || Slowitem.[/COLOR]
            @priority[@priority.length]=@battlers[temp[0]]
          else
            n=temp.length
            [COLOR=Red]usequickclaw=(pbRandom(16)<3)[/COLOR] [COLOR=Red]#Fix for the actual 18.75% Chance for activation. (It's not 20%)[/COLOR]
            for m in 0..n-2
              for i in 1..n-1
                if quickclaw[temp[i]] && usequickclaw
                  cmp=(quickclaw[temp[i-1]]) ? 0 : -1 #Rank higher if without Quick Claw, or equal if with it
                elsif quickclaw[temp[i-1]] && usequickclaw
                  cmp=1 # Rank lower
    [COLOR=Red]            elsif stall[temp[i]] [COLOR=Lime]&& !(usequickclaw)[/COLOR] #Check for stall [COLOR=Lime]&& not usage of quickclaw[/COLOR]
                  cmp=(stall[temp[i-1]]) ? 0 : 1
                elsif slowitem[temp[i]] #Check for slowing items
                  cmp=(slowitem[temp[i-1]]) ? 0 : 1[/COLOR]
    [COLOR=Navy]            elsif stall[temp[i-1]] #This is a suggestion on how to fix the sometimes not activating part - how do we get the quickclaw check in again?
                  cmp=-1
                elsif slowitem[temp[i-1]] #We will still miss out on the fact that slowitem should make slower than stall - which might not happen. (also shouldn't we put stall and slowitem BEHIND speedcheck? - not sure about that
                  cmp=-1[/COLOR]
                else #check regular pokemon
                  cmp=(speeds[temp[i]]>speeds[temp[i-1]]) ? -1 : (speeds[temp[i]]==speeds[temp[i]])? 0 : 1 #Rank higher to higher-speed battler
                end
                if cmp<0
                  # put higher-speed Pokémon first
                  swaptmp=temp[i]
                  temp[i]=temp[i-1]
                  temp[i-1]=swaptmp
                elsif cmp==0
                  # swap at random if speeds are equal
                  if pbRandom(2)==0
                    swaptmp=temp[i]
                    temp[i]=temp[i-1]
                    temp[i-1]=swaptmp
                  end
                end
              end
            end
            #Now add the temp array to priority
            for i in temp
              @priority[@priority.length]=@battlers[i]
            end
          end
          curpri-=1
          break unless curpri>=minpri
        end
    =begin
        prioind=[
           @priority[0].index,
           @priority[1].index,
           @priority[2] ? @priority[2].index : -1,
           @priority[3] ? @priority[3].index : -1
        ]
        print("#{speeds.inspect} #{prioind.inspect}")
    =end
        @usepriority=true
        return @priority
      end
     
    1,224
    Posts
    10
    Years
  • Well I like the changes so far. But you forgot to mark half of the code that was changed.
    Also. Why did you remove the part where it only checks for stall if quickclaw isn't used. Because Quickclaw still works over stall. This would "reset" the priority.

    Code:
    def pbPriority(ignorequickclaw=false)
        if @usepriority
          # use stored priority if round isn't over yet
          return @priority
        end
        speeds=[]
        quickclaw=[]
        priorities=[]
        temp=[]
    [COLOR=Red]    stall=[][/COLOR]
    [COLOR=Red]    slowitem=[][/COLOR]
        @priority.clear
        maxpri=0
        minpri=0
        # Calculate each Pokémon's speed
        for i in 0...4
          speeds[i]=@battlers[i].pbSpeed
          quickclaw[i]=@battlers[i].hasWorkingItem(:QUICKCLAW)
          quickclaw[i]=false if @choices[i][0]!=1
          quickclaw[i]=false if ignorequickclaw
          #Check for Stall or Lagging Tail or Full Incense
    [COLOR=Red]      stall[i]=(@battlers[i].hasWorkingAbility(:STALL)) ? true : false
          slowitem[i]=(@battlers[i].hasWorkingItem(:LAGGINGTAIL) || @battlers[i].hasWorkingItem(:FULLINCENSE)) ? true : false[/COLOR]
        end
        # Find the maximum and minimum priority
        for i in 0...4
          # For this function, switching and using items
          # is the same as using a move with a priority of 0
          pri=0
          if @choices[i][0]==1 # Is a move
            pri=@choices[i][2].priority
            pri+=1 if @battlers[i].hasWorkingAbility(:PRANKSTER) &&
                      @choices[i][2].basedamage==0 # Is status move
            pri+=1 if @battlers[i].hasWorkingAbility(:GALEWINGS) && 
               isConst?(@choices[i][2].type,PBTypes,:FLYING)
          end
          priorities[i]=pri
          if i==0
            maxpri=pri
            minpri=pri
          else
            maxpri=pri if maxpri<pri
            minpri=pri if minpri>pri
          end
        end
        # Find and order all moves with the same priority
        curpri=maxpri
        loop do
          temp.clear
          for j in 0...4
            if priorities[j]==curpri
              temp[temp.length]=j
            end
          end
          # Sort by speed
          if temp.length==1                                                 [COLOR=Blue]#This could be the problem | If this is executed it wont check for the enemy having Stall || Slowitem.[/COLOR]
            @priority[@priority.length]=@battlers[temp[0]]
          else
            n=temp.length
            [COLOR=Red]usequickclaw=(pbRandom(16)<3)[/COLOR] [COLOR=Red]#Fix for the actual 18.75% Chance for activation. (It's not 20%)[/COLOR]
            for m in 0..n-2
              for i in 1..n-1
                if quickclaw[temp[i]] && usequickclaw
                  cmp=(quickclaw[temp[i-1]]) ? 0 : -1 #Rank higher if without Quick Claw, or equal if with it
                elsif quickclaw[temp[i-1]] && usequickclaw
                  cmp=1 # Rank lower
    [COLOR=Red]            elsif stall[temp[i]] [COLOR=Lime]&& !(usequickclaw)[/COLOR] #Check for stall [COLOR=Lime]&& not usage of quickclaw[/COLOR]
                  cmp=(stall[temp[i-1]]) ? 0 : 1
                elsif slowitem[temp[i]] #Check for slowing items
                  cmp=(slowitem[temp[i-1]]) ? 0 : 1[/COLOR]
    [COLOR=Navy]            elsif stall[temp[i-1]] #This is a suggestion on how to fix the sometimes not activating part - how do we get the quickclaw check in again?
                  cmp=-1
                elsif slowitem[temp[i-1]] #We will still miss out on the fact that slowitem should make slower than stall - which might not happen. (also shouldn't we put stall and slowitem BEHIND speedcheck? - not sure about that
                  cmp=-1[/COLOR]
                else #check regular pokemon
                  cmp=(speeds[temp[i]]>speeds[temp[i-1]]) ? -1 : (speeds[temp[i]]==speeds[temp[i]])? 0 : 1 #Rank higher to higher-speed battler
                end
                if cmp<0
                  # put higher-speed Pokémon first
                  swaptmp=temp[i]
                  temp[i]=temp[i-1]
                  temp[i-1]=swaptmp
                elsif cmp==0
                  # swap at random if speeds are equal
                  if pbRandom(2)==0
                    swaptmp=temp[i]
                    temp[i]=temp[i-1]
                    temp[i-1]=swaptmp
                  end
                end
              end
            end
            #Now add the temp array to priority
            for i in temp
              @priority[@priority.length]=@battlers[i]
            end
          end
          curpri-=1
          break unless curpri>=minpri
        end
    =begin
        prioind=[
           @priority[0].index,
           @priority[1].index,
           @priority[2] ? @priority[2].index : -1,
           @priority[3] ? @priority[3].index : -1
        ]
        print("#{speeds.inspect} #{prioind.inspect}")
    =end
        @usepriority=true
        return @priority
      end

    It checks for quick claw first, so I don't think it needs to.

    Edit: This seems to fix it. Have to test against other stalling pokemon and such.
     
    Last edited:

    DeKay

    Mega Evolved
    22
    Posts
    9
    Years
    • Seen Oct 11, 2015
    Edited the above post, but it seems to work. Have to test what happens when there's more than one stalling pokemon or item, and double battles still.
    We should also check for slowitem before stall because lagging tail will slow yourself down further than stall.
    Meaning we have to check in this Order:
    Code:
                if quickclaw[temp[i]] && usequickclaw
                  cmp=(quickclaw[temp[i-1]]) ? 0 : -1 #Rank higher if without Quick Claw, or equal if with it
                elsif quickclaw[temp[i-1]] && usequickclaw
                  cmp=1 # Rank lower
                elsif slowitem[temp[i]]
                  cmp=(slowitem[temp[i-1]]) ? 0 : 1
                elsif slowitem[temp[i-1]] 
                  cmp=-1              
                elsif stall[temp[i]]
                  cmp=(stall[temp[i-1]]) ? 0 : 1
                elsif stall[temp[i-1]] 
                  cmp=-1
                else #check regular pokemon
                  cmp=(speeds[temp[i]]>speeds[temp[i-1]]) ? -1 : (speeds[temp[i]]==speeds[temp[i]])? 0 : 1 #Rank higher to higher-speed battler
                end

    Btw. is the quickclaw usage usually smart? Because in that case we would have to change the usequickclaw part. to not use quickclaw if the enemy has stall or a slowitem.
     
    Last edited:
    1,224
    Posts
    10
    Years
  • We should also check for slowitem before stall because lagging tail will slow yourself down further than stall.
    Meaning we have to check in this Order:
    Code:
                if quickclaw[temp[i]] && usequickclaw
                  cmp=(quickclaw[temp[i-1]]) ? 0 : -1 #Rank higher if without Quick Claw, or equal if with it
                elsif quickclaw[temp[i-1]] && usequickclaw
                  cmp=1 # Rank lower
                elsif slowitem[temp[i]]
                  cmp=(slowitem[temp[i-1]]) ? 0 : 1
                elsif slowitem[temp[i-1]] 
                  cmp=-1              
                elsif stall[temp[i]]
                  cmp=(stall[temp[i-1]]) ? 0 : 1
                elsif stall[temp[i-1]] 
                  cmp=-1
                else #check regular pokemon
                  cmp=(speeds[temp[i]]>speeds[temp[i-1]]) ? -1 : (speeds[temp[i]]==speeds[temp[i]])? 0 : 1 #Rank higher to higher-speed battler
                end

    Btw. is the quickclaw usage usually smart? Because in that case we would have to change the usequickclaw part. to not use quickclaw if the enemy has stall or a slowitem.

    Quickclaw overrides Stall.
     

    DeKay

    Mega Evolved
    22
    Posts
    9
    Years
    • Seen Oct 11, 2015
    Quickclaw overrides Stall.
    I know that happens in the code. And the last change would also make slowitem override stall. (which it is supposed to)

    But that wasn't my question.
    In case Pokemon A holds quickclaw and Pokemon B has stall.
    It would be kind of useless for Pokemon A's quickclaw to activate since it will be faster no matter what. Is there a mechanic in the normal Pokemon games that will prevent quickclaw from being activated if the Pokemon holding it would be faster anyways?
    If so - we should add that as well while we're at it.
     
    1,224
    Posts
    10
    Years
  • I know that happens in the code. And the last change would also make slowitem override stall. (which it is supposed to)

    But that wasn't my question.
    In case Pokemon A holds quickclaw and Pokemon B has stall.
    It would be kind of useless for Pokemon A's quickclaw to activate since it will be faster no matter what. Is there a mechanic in the normal Pokemon games that will prevent quickclaw from being activated if the Pokemon holding it would be faster anyways?
    If so - we should add that as well while we're at it.

    I've already fixed the item vs Stall thing in my code. But preventing quickclaw is kinda useless anyway, it's just more checks to accomplish the same thing. I've updated the scripts with this and some other things I've marked on the docs that need testing. I have to go to work, so if you or someone else would test them for me that'd be grand.
     
    Back
    Top