• 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] Attempting to make a move that heals the ally when you do damage (again, sorta)

  • 6
    Posts
    348
    Days
    • Seen Nov 24, 2023
    Hello

    A few months ago, I tried making a Pollen Puff-like effect that hits everyone on the field at once. Turns out, the original Pollen Puff code doesn't work very well with hitting everyone on the field.
    In an attempt to get this working, I instead looked at making a move that heals you ally when it does damage. However, I've tried using Flame Burst as a base, and I don't really know what I'm doing

    Even though I doubt it can help, here's my latest attempt at getting the code to run:

    Code:
    class Battle::Move::HealAllyOrDamageFoeAndCureTargetBurn < Battle::Move
      def pbEffectWhenDealingDamage(user, target)
        hitAlly = []
        battler.allAllies.each do |b|
          next if !b.near?(battler.index)
          hitAlly.push([b.index, b.hp])
          b.hpGain = (target.totalhp / 2).round
        end
        if hitAlly.length == 2
          @battle.pbDisplay(_INTL("The bursting flame hit {1} and {2}!",
                                  @battle.battlers[hitAlly[0][0]].pbThis(true),
                                  @battle.battlers[hitAlly[1][0]].pbThis(true)))
        elsif hitAlly.length > 0
          hitAlly.each do |b|
            @battle.pbDisplay(_INTL("The bursting flame hit {1}!",
                                    @battle.battlers[b[0]].pbThis(true)))
          end
        end
        hitAlly.each { |b| @battle.battlers[b[0]].pbItemHPHealCheck }
      end
    end

    Is there anyone here who might be able to help me with getting this to work?

    Thanks
     
  • 188
    Posts
    9
    Years
    • Seen May 16, 2024
    What you should do is use two separate arrays for the two values you're working with.
    Code:
    class Battle::Move::HealAllyOrDamageFoeAndCureTargetBurn < Battle::Move
      def pbEffectWhenDealingDamage(user, target)
        hitAllyId = []
        hitAllyHp = []
        battler.allAllies.each do |b|
          next if !b.near?(battler.index)
          hitAllyId.push(b.index)
          hitAllyHp.push(b.hp)
          b.hpGain = (target.totalhp / 2).round
        end
        if hitAllyId.length == 2
          @battle.pbDisplay(_INTL("The bursting flame hit {1} and {2}!",
                                  @battle.battlers[hitAllyId[0].pbThis(true),
                                  @battle.battlers[hitAllyId[1].pbThis(true)))
        elsif hitAllyId.length > 0
          hitAllyId.each do |b|
            @battle.pbDisplay(_INTL("The bursting flame hit {1}!",
                                    @battle.battlers[b].pbThis(true)))
          end
        end
        hitAllyId.each { |b| @battle.battlers[b].pbItemHPHealCheck }
      end
    end
     
    Last edited:
    Back
    Top