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

[Error] This held item's simple code should increase speed by 1 on Switch-In, so why does it crash or prevent the game from starting?

429
Posts
4
Years
  • My game's either allowing me to play until I send out a Pokemon holding the AD18 which causes a crash, or the game refuses to start and puts up error messages playing the "sorry ) should be a } haha I mean ] haha I mean ) I mean too many )s I mean not enough )s" cycle with me no matter how I change the code. Sometimes changing the code lets me get into a battle, only for sending a Pokemon out holding the AD18 item to cause crashes. The error messages given say it doesn't know what I mean by "Item" if it doesn't just whine about the number of "{{]])end)"s

    This held item is just supposed to raise Speed by +1 when sent out. Like the "Intrepid Sword" ability but as an item that boosts Speed.

    Code:
    BattleHandlers::ItemOnSwitchIn.add(:AD18,
      proc { |item,battler,battle|
        battle.pbDisplay(_INTL("{1} gained 1 Speed stage from the Drive!",
          battler.pbRaiseStatStageByCause(:SPEED,1,battler,itemName))
      }
    )
     
    Last edited:

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    My game's either allowing me to play until I send out a Pokemon holding the AD18 which causes a crash, or the game refuses to start and puts up error messages playing the "sorry ) should be a } haha I mean ] haha I mean ) I mean too many )s I mean not enough )s" cycle with me no matter how I change the code. Sometimes changing the code lets me get into a battle, only for sending a Pokemon out holding the AD18 item to cause crashes. The error messages given say it doesn't know what I mean by "Item" if it doesn't just whine about the number of "{{]])end)"s

    This held item is just supposed to raise Speed by +1 when sent out. Like the "Intrepid Sword" ability but as an item that boosts Speed.

    Code:
    BattleHandlers::ItemOnSwitchIn.add(:AD18,
      proc { |item,battler,battle|
        battle.pbDisplay(_INTL("{1} gained 1 Speed stage from the Drive!",
          battler.pbRaiseStatStageByCause(:SPEED,1,battler,itemName))
      }
    )

    I mean. The error message for this is explicit. It tells you that "itemName" is not defined.
    You need one more line to define itemName as:

    Code:
    itemName = GameData::Item.get(item).name

    Anyway, that's not the only mistake I see; only this one is causing the crash. When you solve it, there will be other errors.
    1. The function embedding as you do it will not display the name of the Pokémon. The function battler.pbRaiseStatStageByCause(:SPEED,1,battler,itemName) will return a boolean value, basically stating whether the increase happened or not. Thus, you should separate both functions.
    2. So how do you get the name of the Pokémon? You should use battler.pbThis.
    3. But, actually, the function pbRaiseStatStageByCause already displays the annotation, so you don't need to write it.
    4. There is one more thing you should consider. Actually, in Essentials, you should check if you can raise the stats of the Pokémon, before actually doing it.

    In summary, your code should look like this:

    Code:
    BattleHandlers::ItemOnSwitchIn.add(:AD18,
      proc { |item,battler,battle|
        if battler.pbCanRaiseStatStage?(:SPEED,battler,nil,PokeBattle_SceneConstants::USE_ABILITY_SPLASH)
          if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
            battler.pbRaiseStatStage(:SPEED,1,battler)
          else
            itemName = GameData::Item.get(item).name
            battler.pbRaiseStatStageByCause(:SPEED,1,battler,itemName)
          end
        end
      }
    )

    Something else. Your item ID is "AD18", but you mention "Drive" in your text. I assume your item is called "American Drive 18" (I am joking about the "American" part), so your item ID should be "AMERICANDRIVE18". This is because when you will be debugging your code in 20 months (I am not joking or overestimating), you will likely waste time remembering what item is "AD18".
    Now for one item there should be no problem, but now assume you have 31 items, 64 moves, 18 abilities and 32 effects; it becomes mind-consuming.
     
    Last edited:
    429
    Posts
    4
    Years
  • American Drive! Funniest thing I've heard in ages. In truth I only plan to have a handful of these ADs with a pinned wordpad text file to remind me which one does what. I also have a reminder of each one's intended effect commented out near the name.

    Speaking of these ADs, does the engine support turning this modified ability into an item? When I tried changing BattleHandlers to BattleHandlers::TargetItem that caused crashes.

    Code:
    BattleHandlers::MoveBaseTypeModifierAbility.add(:AERILATE,
      proc { |ability,user,move,type|
        next :FLYING
      }
    )

    I intentionally removed the power boost and "Is this normal?" check from Aerilate to match my other -ate and -ize abilities, I made a new one up for each type and I was hoping to make items that do the same thing.
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    American Drive! Funniest thing I've heard in ages. In truth I only plan to have a handful of these ADs with a pinned wordpad text file to remind me which one does what. I also have a reminder of each one's intended effect commented out near the name.
    This is exactly what you shouldn't do.
    You shouldn't have an intermediary, a converter from what you see (your ID) and what you want (the item). Make coding easier for you.

    Speaking of these ADs, does the engine support turning this modified ability into an item? When I tried changing BattleHandlers to BattleHandlers::TargetItem that caused crashes.

    Code:
    BattleHandlers::MoveBaseTypeModifierAbility.add(:AERILATE,
      proc { |ability,user,move,type|
        next :FLYING
      }
    )

    Actually, right now, the only Battle Handlers that change types of moves are abilities.
    Check out the class PokeBattle_Move, and in particular this function:
    Code:
      def pbBaseType(user)
        ret = @type
        if ret && user.abilityActive?
          ret = BattleHandlers.triggerMoveBaseTypeModifierAbility(user.ability,user,self,ret)
        end
        return ret
      end
    You will need to adapt all the code from BattleHandlers.triggerMoveBaseTypeModifierAbility(user.ability,user,self,ret) to Battle Handlers. It's not difficult but it will require a bit of coding.

    I intentionally removed the power boost and "Is this normal?" check from Aerilate to match my other -ate and -ize abilities, I made a new one up for each type and I was hoping to make items that do the same thing.

    Now, your code means that any Pokémon with Aerilate, should convert any move of any type, to the Flying-type? (this is what your code does, right now).
     
    429
    Posts
    4
    Years
  • Aerilate (and all other -ate and -ize abilities) in my game convert any move the pokemon with the ability uses into the -ate ability's type. So Aerilate makes everything used by the Pokemon Flying type, Incinerate makes its moves Fire type, and Burninate makes its moves Dragon type. There's one ability per type right now, and I thought about adding a QMARKS-type ability called Obfuscate but since there are no ??? type pokemon this would mean no STAB, and if it did get STAB as a side effect of the ability, its unresisted attacks would be too strong on a setup sweeper with a wide movepool. So far this works in ability form, now I want to make held items that function the same way but fail if a -ate ability is active. I'll give the Drives better individual names when I think of some.

    Code:
    def pbBaseType(user)
      if !user.ability == :NORMALIZE
      ret = @type
      if user.item = AD1
    #    ret = :NORMAL
          ret = BattleHandlers.triggerMoveBaseTypeModifierAbility(:NORMAL,user,self,ret)
      end
      return ret
    end
      end

    I tried but the code didn't work with ret=:normal or the other thing.
     
    Last edited:
    Back
    Top