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

152
Posts
11
Years
    • Seen May 11, 2015
    So, I'm trying to add in effects for new moves, but I've run into some trouble.

    Here's the code:
    Code:
    class PokeBattle_Move_138 < PokeBattle_Move
      def pbEffect(attacker,opponent)
        if attacker.hp==attacker.totalhp
          @battle.pbDisplay(_INTL("{1}'s HP is full!",attacker.pbThis))
          return -1
        end
        if attacker.pbTooHigh?(PBStats::DEFENSE) &&
           attacker.pbTooHigh?(PBStats::SPDEF)
          @battle.pbDisplay(_INTL("{1}'s stats won't go higher!",attacker.pbThis))
          return -1
        end
        @battle.pbAnimation(@id,attacker,nil)
          hpgain=(attacker.totalhp/2).floor
          attacker.pbRecoverHP(hpgain)
          @battle.pbDisplay(_INTL("{1} regained health!",attacker.pbThis))
        end
        if !attacker.pbTooHigh?(PBStats::DEFENSE)
          @battle.pbCommonAnimation("StatUp",attacker,nil)
          attacker.pbIncreaseStatBasic(PBStats::DEFENSE,1)
          @battle.pbDisplay(_INTL("{1}'s Defense rose!",attacker.pbThis))
        end
        if !attacker.pbTooHigh?(PBStats::SPDEF)
          @battle.pbCommonAnimation("StatUp",attacker,nil)
          attacker.pbIncreaseStatBasic(PBStats::SPDEF,1)
          @battle.pbDisplay(_INTL("{1}'s Special Defense rose!",attacker.pbThis))
        end
          return 0
        end
      end
    end

    The move is supposed to raise the user's Defense and Sp. Defense, and restores 1/2 of the user's max HP. However, when I run, I'm told that that there's a syntax error at line 7589. Which is the second to last "end." So I tried a little more tweaking, into this:

    Code:
    class PokeBattle_Move_138 < PokeBattle_Move
      def pbEffect(attacker,opponent)
        if attacker.hp==attacker.totalhp ||
          attacker.pbTooHigh?(PBStats::DEFENSE) &&
          attacker.pbTooHigh?(PBStats::SPDEF)
          @battle.pbDisplay(_INTL("But it failed!",attacker.pbThis))
          return -1
        end
        @battle.pbAnimation(@id,attacker,nil)
          hpgain=(attacker.totalhp/2).floor
          attacker.pbRecoverHP(hpgain)
        end
        if !attacker.pbTooHigh?(PBStats::DEFENSE)
          @battle.pbCommonAnimation("StatUp",attacker,nil)
          attacker.pbIncreaseStatBasic(PBStats::DEFENSE,1)
          @battle.pbDisplay(_INTL("{1}'s Defense rose!",attacker.pbThis))
        end
        if !attacker.pbTooHigh?(PBStats::SPDEF)
          @battle.pbCommonAnimation("StatUp",attacker,nil)
          attacker.pbIncreaseStatBasic(PBStats::SPDEF,1)
          @battle.pbDisplay(_INTL("{1}'s Special Defense rose!",attacker.pbThis))
        end
        return -1
      end
    end

    And again, there's a syntax error, which is now on the last "end" (line 7585)

    I honestly have no idea what I'm doing. Someone help me.
     
    Last edited:

    Luka S.J.

    Jealous Croatian
    1,270
    Posts
    15
    Years
  • So, I'm trying to add in effects for new moves, but I've run into some trouble.

    Here's the code:
    Code:
    class PokeBattle_Move_138 < PokeBattle_Move
      def pbEffect(attacker,opponent)
        if attacker.hp==attacker.totalhp
          @battle.pbDisplay(_INTL("{1}'s HP is full!",attacker.pbThis))
          return -1
        end
        if attacker.pbTooHigh?(PBStats::DEFENSE) &&
           attacker.pbTooHigh?(PBStats::SPDEF)
          @battle.pbDisplay(_INTL("{1}'s stats won't go higher!",attacker.pbThis))
          return -1
        end
        @battle.pbAnimation(@id,attacker,nil)
          hpgain=(attacker.totalhp/2).floor
          attacker.pbRecoverHP(hpgain)
          @battle.pbDisplay(_INTL("{1} regained health!",attacker.pbThis))
        [COLOR="red"]end[/COLOR]
        if !attacker.pbTooHigh?(PBStats::DEFENSE)
          @battle.pbCommonAnimation("StatUp",attacker,nil)
          attacker.pbIncreaseStatBasic(PBStats::DEFENSE,1)
          @battle.pbDisplay(_INTL("{1}'s Defense rose!",attacker.pbThis))
        end
        if !attacker.pbTooHigh?(PBStats::SPDEF)
          @battle.pbCommonAnimation("StatUp",attacker,nil)
          attacker.pbIncreaseStatBasic(PBStats::SPDEF,1)
          @battle.pbDisplay(_INTL("{1}'s Special Defense rose!",attacker.pbThis))
        end
          return 0
        [COLOR="Red"]end[/COLOR]
      end
    end

    These two ends shouldn't be there.
     
    Back
    Top