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

Ability Effect Based On Opponents Level

148
Posts
11
Years
Like the title says, I'm trying to make an ability that gives the pokemon a boost when it switches in depending on the level of the opponent. Keep getting an error.

Code:
    if isConst?(opponent.ability,PBAbilities,:FATHERSBOND)  &&  if opponent.level<=1 #Level Greater then 1
          if opponent.pbCanIncreaseStatStage?(PBStats::DEFENSE)
            opponent.pbIncreaseStatBasic(PBStats::DEFENSE,1)
            @battle.pbCommonAnimation("StatUp",opponent,nil)
            @battle.pbDisplay(_INTL("{1} detected a minor threat to his child",
               opponent.pbThis,PBAbilities.getName(opponent.ability)))
             end
           end
         end

Plan to make different effects for levels 20, 30, 40, etc...


The Error
Spoiler:


I figure it has something to do with the "if opponent.level<=1" line, but I don't know how to tell by reading the error. Any help would be great.
 
148
Posts
11
Years
I got rid of the error, but nothing happens.

Code:
   if isConst?(ability,PBAbilities,:FATHERSBOND)  &&  if pbOpposing1.level<=1 #Level Greater then 1
          if opponent.pbCanIncreaseStatStage?(PBStats::DEFENSE)
            opponent.pbIncreaseStatBasic(PBStats::DEFENSE,1)
            @battle.pbCommonAnimation("StatUp",opponent,nil)
            @battle.pbDisplay(_INTL("{1} detected a minor threat to his child",
               opponent.pbThis,PBAbilities.getName(opponent.ability)))
             end
           end
 
1,224
Posts
10
Years
Code:
 if isConst?(ability,PBAbilities,:FATHERSBOND)  &&  pbOpposing1.level>=1 #Level Greater then 1

took out the second if. Don't know if that solves your problem, but it doesn't need to be there. Also changed your operator to >= because that is greater than or equal to. <= is less than or equal to
 
148
Posts
11
Years
Code:
 if isConst?(ability,PBAbilities,:FATHERSBOND)  &&  pbOpposing1.level>=1 #Level Greater then 1

took out the second if. Don't know if that solves your problem, but it doesn't need to be there. Also changed your operator to >= because that is greater than or equal to. <= is less than or equal to

Changing it from less than to greater than brought the same error as before back up. Turns out less than or equal is what I wanted for this anyways seeing as every 10 or so levels I'd like for a new effect to happen.

I looked at other abilities in this section, namely Download, and stat boosts are written differently. Thinking that's why nothing is happening.

I'm used to writing them like this
Code:
if opponent.pbCanIncreaseStatStage?(PBStats::DEFENSE)
            opponent.pbIncreaseStatBasic(PBStats::DEFENSE,1)


Download has them like this
Code:
if !pbTooHigh?(PBStats::ATTACK)
          pbIncreaseStatBasic(PBStats::ATTACK,1)
          @battle.pbDisplay(_INTL("{1}'s {2} boosted its Attack!",
             pbThis,PBAbilities.getName(ability)))
        end

are things like that handled differently depending on which section their written in?
 
148
Posts
11
Years
Got it to work! In case anyone wanted to see it,

EDIT: Since I couldn't get it to have different effects for every 10 or so levels, I just made it give a boost whenever the opponent is at a higher level.
Code:
  if isConst?(ability,PBAbilities,:FATHERSBOND)  &&  self.level<pbOpposing1.level  &&  onactive
          if !pbTooHigh?(PBStats::ATTACK)
          pbIncreaseStatBasic(PBStats::ATTACK,1)
          @battle.pbCommonAnimation("StatUp",self,nil)
          @battle.pbDisplay(_INTL("{1} senses a threat to his child!",
             pbThis,PBAbilities.getName(ability)))
             end
           end

It works fine if there's just the one "less than or equal to" in the code. But I would like to have it change for every 10 or 20 levels. Every time I try, it gives every level boost. Very frustrating.
 
Last edited:
19
Posts
9
Years
  • Age 31
  • Seen Aug 23, 2015
Could you do something that gives it a range? Like
Code:
pbOpposing1.level>=1  &&  pbOpposing1.level<=10

For greater than or equal 1, less then or equal to 10, and then set up the ability again but with
Code:
pbOpposing1.level>=11  &&  pbOpposing1.level<=20
for equal to or greater than 11, less than or equal to 20 and go like that?
 
148
Posts
11
Years
Could you do something that gives it a range? Like
Code:
pbOpposing1.level>=1  &&  pbOpposing1.level<=10

For greater than or equal 1, less then or equal to 10, and then set up the ability again but with
Code:
pbOpposing1.level>=11  &&  pbOpposing1.level<=20
for equal to or greater than 11, less than or equal to 20 and go like that?

I thought about that. I turned essentials off and really dont want to look at it anymore right now though :P

EDIT:

It seems to have worked. I've never spent so long trying to figure an ability out. Did learn how to use a few new things, so it was definitely worth the trouble.

Code:
################################################################################
# Father's Bond Levels
################################################################################ 
    #Father's Bond Level 1:
  if isConst?(ability,PBAbilities,:FATHERSBOND)  &&  pbOpposing1.level>=1  &&  pbOpposing1.level<=10  &&  onactive
          if !pbTooHigh?(PBStats::ATTACK)
          pbIncreaseStatBasic(PBStats::ATTACK,1)
          @battle.pbCommonAnimation("StatUp",self,nil)
          @battle.pbDisplay(_INTL("{1} senses a threat to his child!",
             pbThis,PBAbilities.getName(ability)))
             end
           end
      #End of Father's Bond Level 1
      
    #Father's Bond Level 2:
  if isConst?(ability,PBAbilities,:FATHERSBOND)  &&  pbOpposing1.level>=11  &&  pbOpposing1.level<=20  &&  onactive
          if !pbTooHigh?(PBStats::SPEED)
          pbIncreaseStatBasic(PBStats::SPEED,1)
          @battle.pbCommonAnimation("StatUp",self,nil)
          @battle.pbDisplay(_INTL("{1} senses a big threat to his child!",
             pbThis,PBAbilities.getName(ability)))
             end
           end
      #End of Father's Bond Level 2
 
Last edited:
1,224
Posts
10
Years
Could you do something that gives it a range? Like
Code:
pbOpposing1.level>=1  &&  pbOpposing1.level<=10

For greater than or equal 1, less then or equal to 10, and then set up the ability again but with
Code:
pbOpposing1.level>=11  &&  pbOpposing1.level<=20
for equal to or greater than 11, less than or equal to 20 and go like that?

Basically that, but you can do it easier. Just something like

Code:
case 
when pbOpposing1.level>20
dothinghere
when pbOpposing1.level>10
dootherthinghere
else
doelsethinghere
end
 
Back
Top