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

[Scripting Question] Problem making custom move

Arkadious

Developer of Fragmentum
50
Posts
8
Years
Hi everyone,

I'm trying to make a move variant of spike which, when a pokemon enters the battlefield, instead of taking damage or being poisoned, becomes paralyzed instead. I'm using Essentials 17.1

The code for the move is here:
Code:
################################################################################
# Entry hazard. Lays poison spikes on the opposing side (max. 1 layer).
# (Charged Spikes)
################################################################################
class PokeBattle_Move_160 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if attacker.pbOpposingSide.effects[PBEffects::ChargedSpikes]>=1
      @battle.pbDisplay(_INTL("But it failed!"))
      return -1
    end
    pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
    attacker.pbOpposingSide.effects[PBEffects::ChargedSpikes]=true
    if [email protected]?(attacker.index)
      @battle.pbDisplay(_INTL("Charged spikes were scattered all around the opposing team's feet!"))
    else
      @battle.pbDisplay(_INTL("Charged spikes were scattered all around your team's feet!"))
    end
    return 0
  end
end

and the code for the part in PokeBattle_Battle is here:
Code:
      # Charged Spikes
      if pkmn.OwnSide.effects[PBEffects::ChargedSpikes] && !pkmn.isFainted?
        if !pkmn.isAirborne?(moldbreaker)
          if pkmn.pbCanParalyze?(moldbreaker)
            PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Charged Spikes")
            pkmn.pbParalyze(nil,_INTL("{1} was paralyzed by the charged spikes!",pkmn.pbThis))
          end
        end
      end

However, when I use the move, and when an opponent sends out a Pokemon after it faints, I get two errors:
Code:
Exception: NoMethodError
Message: undefined method `>=' for false:FalseClass
PokeBattle_MoveEffects:1751:in `pbEffect'
PokeBattle_Battler:3146:in `pbUseMove'
PokeBattle_Battler:3145:in `logonerr'
PokeBattle_Battler:3145:in `pbUseMove'
PokeBattle_Battler:3378:in `pbProcessTurn'
PokeBattle_Battler:3377:in `logonerr'
PokeBattle_Battler:3377:in `pbProcessTurn'
PokeBattle_Battle:2838:in `pbAttackPhase'
PokeBattle_Battle:2835:in `each'
PokeBattle_Battle:2835:in `pbAttackPhase'

Exception: NoMethodError
Message: undefined method `OwnSide' for #  PokeBattle_Battler:0xcf145d8
PokeBattle_Battle:2155:in `pbOnActiveOne'
PokeBattle_Battle:1332:in `pbRecallAndReplace'
PokeBattle_Battle:1259:in `pbSwitch'
PokeBattle_Battle:1230:in `each'
PokeBattle_Battle:1230:in `pbSwitch'
PokeBattle_Battle:3862:in `__clauses__pbEndOfRoundPhase'
PokeBattle_Clauses:42:in `pbEndOfRoundPhase'
PokeBattle_Battle:2545:in `pbStartBattleCore'
PokeBattle_Battle:2544:in `logonerr'
PokeBattle_Battle:2544:in `pbStartBattleCore'

What exactly have I done wrong, and how can I fix it. Any help is appreciated. Thanks.
 
Last edited:

Arkadious

Developer of Fragmentum
50
Posts
8
Years
So I figured out that I needed to change:
Code:
if attacker.pbOpposingSide.effects[PBEffects::ChargedSpikes]>=1
to
Code:
if attacker.pbOpposingSide.effects[PBEffects::ChargedSpikes]
for the move effects part, but I'm not sure what else I need to do to get it to work properly.
Code:
[Pokémon Essentials version 17.1]
Exception: NoMethodError
Message: undefined method `OwnSide' for # PokeBattle_Battler:0xc4858e8
PokeBattle_Battle:2155:in `pbOnActiveOne'
PokeBattle_Battle:1332:in `pbRecallAndReplace'
PokeBattle_Battle:1259:in `pbSwitch'
PokeBattle_Battle:1230:in `each'
PokeBattle_Battle:1230:in `pbSwitch'
PokeBattle_Battle:3862:in `__clauses__pbEndOfRoundPhase'
PokeBattle_Clauses:42:in `pbEndOfRoundPhase'
PokeBattle_Battle:2545:in `pbStartBattleCore'
PokeBattle_Battle:2544:in `logonerr'
PokeBattle_Battle:2544:in `pbStartBattleCore'
 
1,680
Posts
8
Years
  • Age 23
  • Seen today
It's pbOwnSide, not OwnSide. Most default methods in Essentials start with pb.

EDIT: Oh, that sounded a lot harsher than I was going for (not harsh at all).
 
Last edited:

Arkadious

Developer of Fragmentum
50
Posts
8
Years
It's pbOwnSide, not OwnSide. Most default methods in Essentials start with pb.

EDIT: Oh, that sounded a lot harsher than I was going for (not harsh at all).

All good man, thanks! Two letters are pretty easy thing to miss :) I'm getting a slightly different error now, and it's only the one error now.
Code:
[Pokémon Essentials version 17.1]
Exception: ArgumentError
Message: wrong number of arguments(1 for 2)
PokeBattle_Battle:2157:in `pbCanParalyze?'
PokeBattle_Battle:2157:in `pbOnActiveOne'
PokeBattle_Battle:1332:in `pbRecallAndReplace'
PokeBattle_Battle:1259:in `pbSwitch'
PokeBattle_Battle:1230:in `each'
PokeBattle_Battle:1230:in `pbSwitch'
PokeBattle_Battle:3862:in `__clauses__pbEndOfRoundPhase'
PokeBattle_Clauses:42:in `pbEndOfRoundPhase'
PokeBattle_Battle:2545:in `pbStartBattleCore'
PokeBattle_Battle:2544:in `logonerr'
I've had a look at the code for Thunder Wave and Toxic Spikes to see what I should do but the code really just doesn't to want to work.
 
Last edited:
1,680
Posts
8
Years
  • Age 23
  • Seen today
Sice I'm not at my computer, I'm just gonna point the things to watch for.
Your error message states that you only gave 1 argument to pbCanParalyze? but it requires 2.
pbCanParalyze? is in PokeBattle_BattlerEffects, though a CTRL+SHIFT+F for def pbCanParalyze? would bring us to the same place.

Now look for the arguments that are not set to equal something. It should be the first 2. (If it asks for the attacker, I think you can just put nil instead.)

EDIT: Yeah, it looks like you copied pbCanPoisonSpikes?, which only takes moldbreaker as an argument. pbCanParalyze? takes the arguments attacker, showMessages, and move=nil. We can ignore move as this is an effect outside of a move, so we just need attacker, which is nil, because the spikes are the attackers. showMessages you can leave true if you want the game to report the failed attempts, or false to fail quietly (pbCanPoisonSpikes? fails silently for reference)

Alternatively, create your own version of pbCanPoisonSpikes?, pbCanParalyzeSpikes?.
 
Last edited:

Arkadious

Developer of Fragmentum
50
Posts
8
Years
Thanks for all the help. I did what you suggested and it actually worked. Pretty obvious what I needed to change once it was pointed out what was wrong. I got it to work by changing:
Code:
if pkmn.pbCanParalyze?(moldbreaker)
to:
Code:
if pkmn.pbCanParalyze?(moldbreaker,nil)
I probably could've made it simpler by making a new thing like pkmn.pbCanParalyzeSpikes, not to mention that if I do it that way, I can make more customized messages for the spikes.
 
Last edited:
Back
Top