• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • 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
    2
    Years
    • 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
     
    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