• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • 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] Passive Item Effect in Battle

  • 21
    Posts
    4
    Years
    • Seen Sep 19, 2022
    I'm looking to have a key item the player gets as a reward for completing a quest that permanently increases the power of bug-type moves by a little. Like a Silver Powder, but that is always in effect, and doesn't need to be held by a Pokemon in battle. Does anyone know if there is a way I can make this work?
    If so, I was also hoping to be able to use the same idea to make a similar item that has the effect of an Amulet Coin. So the player's prize money from battles will double if they just have this item in their bag, rather than having a Pokemon hold it in battle.
     
    Money is easy. In the Script Section Battle_StartandEnd, find this section of code:
    Code:
    def pbGainMoney
        return if !@internalBattle || !@moneyGain
        # Money rewarded from opposing trainers
        if trainerBattle?
          tMoney = 0
          @opponent.each_with_index do |t, i|
            tMoney += pbMaxLevelInTeam(1, i) * t.base_money
          end
          tMoney *= 2 if @field.effects[PBEffects::AmuletCoin]
          tMoney *= 2 if @field.effects[PBEffects::HappyHour]
          oldMoney = pbPlayer.money
          pbPlayer.money += tMoney
          moneyGained = pbPlayer.money - oldMoney

    In between these two lines
    Code:
    tMoney *= 2 if @field.effects[PBEffects::HappyHour]
          oldMoney = pbPlayer.money

    add
    Code:
    tMoney *= 2 if $bag.has?(:LEMONADE)

    With Lemonade being a placeholder for your key item. You can learn how to make key items on the wiki if you need to.

    For the damage item, go to Move_UsageCalculations and find the line of code that says:
    Code:
    def pbCalcDamageMultipliers(user, target, numTargets, type, baseDmg, multipliers)

    Underneath it put
    Code:
    if ($bag.has?(:SILVERPOWDER) && type == :BUG)
           multipliers[:base_damage_multiplier] *= 1.2
        end

    With Silver Powder being a place holder for your item.
     
    Amazing! Thank you for all of the help!
    Unfortunately, they both returned errors when trying to implement them. :/ I maybe should have mentioned that I'm using version 1.18. Do you think that might be where the problem is? And if you think there are any changes that can be made to make the codes usable in the version my game is using? I included the errors below, in case that's helpful.
    Any advice would be greatly appreciated! And thank you again for all of the amazing help you've given me already! :)

    The error for the Amulet Coin item was:

    [Pokémon Essentials version 18.1]
    Exception: RuntimeError
    Message: Script error within event 13 (coords 16,3), map 137 (Cascade Park Gym):
    Exception: NoMethodError
    Message: Battle_StartAndEnd:349:in `pbGainMoney'undefined method `has?' for nil:NilClass

    ***Full script:
    pbTrainerBattle(:LEADER_Norma,"Norma",_I("Aww, boo!"),false,0)

    Backtrace:
    Interpreter:197:in `pbExecuteScript'
    Battle_StartAndEnd:417:in `pbEndOfBattle'
    Battle_StartAndEnd:330:in `pbBattleLoop'
    Battle_StartAndEnd:300:in `pbStartBattleCore'
    Battle_StartAndEnd:258:in `pbStartBattle'
    Sky Battle:400:in `pbTrainerBattleCore'
    Sky Battle:399:in `pbSceneStandby'
    Sky Battle:401:in `pbTrainerBattleCore'
    Sky Battle:398:in `pbBattleAnimation'
    Sky Battle:398:in `pbTrainerBattleCore'

    Backtrace:
    Interpreter:246:in `pbExecuteScript'
    Interpreter:658:in `command_111'
    Interpreter:272:in `execute_command'
    Interpreter:155:in `update'
    Interpreter:102:in `loop'
    Interpreter:158:in `update'
    Scene_Map:162:in `follow_update'
    Scene_Map:160:in `loop'
    Scene_Map:169:in `follow_update'
    Follower_Main:1325:in `update'

    And the error for the Silver Powder item was:

    [Pokémon Essentials version 18.1]
    Exception: NoMethodError
    Message: undefined method `has?' for nil:NilClass

    Backtrace:
    Move_Usage_Calculations:252:in `pbCalcDamage'
    Battler_UseMove:619:in `pbProcessMoveHit'
    Battler_UseMove:611:in `each'
    Battler_UseMove:611:in `pbProcessMoveHit'
    Battler_UseMove:422:in `pbUseMove'
    Battler_UseMove:420:in `each'
    Battler_UseMove:420:in `pbUseMove'
    Battler_UseMove:59:in `pbProcessTurn'
    Battler_UseMove:58:in `logonerr'
    Battler_UseMove:58:in `pbProcessTurn'
     
    Back
    Top