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

Potion to heal the whole team

  • 22
    Posts
    11
    Years
    • Seen Jan 30, 2020
    I have made new Potions to heal the whole team, graphics, added them in the PBS folders.

    But i am not good at scripting, I found the code for Potions under 'PokemonItemEffects' added my new Potions in there just copyed the old potions just to add the same effect as a normal one but dont know the code to make it heal the whole team and not just one Pokemon, any help will be nice.

    I know ill need to add two one for field and one for in battles. if anyone can show me where?

    Spoiler:
     
    Humm.. I am a good coder, however, I am fairly new to Pokemon essentials, maybe I can help.
    Post your edited code here, and I will see if I can help.
     
    well i didnt edit them i just copied the normal one so i could test it with the new item, just changing the name to the new item, since i dunno how to script/code at all just little edits.


    ItemHandlers::UseOnPokemon.add(:PARTYPOTION,proc{|item,pokemon,scene|
    next pbHPItem(pokemon,20,scene)
    })


    ItemHandlers::BattleUseOnPokemon.add(:PARTYPOTION,proc{|item,pokemon,battler,scene|
    next pbBattleHPItem(pokemon,battler,20,scene)
    })
     
    "UseOnPokemon" and "BattleUseOnPokemon"
    Seem to be handlers specifically aimed towards selecting one pokemon. As I understand, that is not what you want.

    From the looks of it, you should use theese handelers:
    "UseFromBag" (used for field-items like repels)
    "UseInBattle" (used for battle-items like pokeballs)
    They do not seem to require you to select a pokemon.
    You be better off with for outside of battle and "UseInBattle" inside a battle.

    If you then run a healing effect on all pokemon in the party, you will have what you are looking for. I might take the time to make such a script for you, but not right now.
     
    yeah thanks it help a lot, i understand it more thankfully but cant seem to get it working, also seems there isn't any way to stop the screen popping either way since there isn't a right defining items way, but that wont mind as long as it heals all the Pokemon not just one dunno where to put any of the coding or anything.

    Spoiler:
     
    the healing code will look something like this
    Code:
    ItemHandlers::UseOnPokemon.add(:POTION,proc{|item,pokemon,scene|
    for i in $Trainer.party
           if i.hp>0 && !i.egg?
             i.heal
             screen.pbDisplay(_INTL("{1}'s HP was restored.",i.name))
    end
         end
    })

    and
    Code:
    ItemHandlers::BattleUseOnPokemon.add(:POTION,proc{|item,pokemon,battler,scene|
    for i in $Trainer.party
           if i.hp>0 && !i.egg?
             i.heal
             screen.pbDisplay(_INTL("{1}'s HP was restored.",i.name))
    end
         end
    })
     
    Last edited:
    "if i.hp<0 && !i.egg?" I read that as "if its health is less than 0, and it is not an egg"
    Is HP for pokemon stored as a negative value, or is there a slight mistake in that code?

    "if i.hp<0 && !i.egg?" I read that as "if its health is less than 0, and it is not an egg"
    Is HP for pokemon stored as a negative value, or is there a slight mistake in that code?
     
    well it doesn't crash like it would whenever i tried, but it doesn't heal anything either.

    well its a lot more close than whenever i tried.
     
    well it doesn't crash like it would whenever i tried, but it doesn't heal anything either.

    well its a lot more close than whenever i tried.

    kvagram was right, I made a typo. Should be ">" instead of "<" . Not that this does not revive fainted pokemon, it only heals them. And it heals them to full hp, since you didn't say by how much you wanted to heal each member.
     
    i got them for all the normal potions (potion, superpotion and hyperpotion)

    also if you change '<' to '>' it crashes now. :/

    also is it possible to just change: '
    for i in $Trainer.party if i.hp>0 && !i.egg?

    to: $Trainer.ablePokemonParty

    isnt that just asking the same thing? or not?
     
    If the game crashes, you should post the error if you can't deduce what caused it by the error.

    ablepokemonparty does the same thing, but it's in another class. So there's really no point in doing the work to call it or recreate it when you're only putting one line of code.
     
    the error:
    Spoiler:


    also it works in battle but only for the one pokemon i use it on but doesnt heal say they are healed (it says in the party when i view pokemon they have health but in battle they have the same health as before)

    well i dunno where to put where the hp is restored but im guessing its something like this: i.heal(20)

    heres my current codes:
    Spoiler:
     
    Code:
    ItemHandlers::UseOnPokemon.add(:PARTYPOTION,proc{|item,pokemon,scene|
    for i in 0..($Trainer.party.length-1)
    pokemon=$Trainer.party[i]
         next pbHPItem(pokemon,20,scene)
         end
    })

    Code:
    ItemHandlers::BattleUseOnPokemon.add(:PARTYPOTION,proc{|item,pokemon,battler,scene|
    for i in 0..($Trainer.party.length-1)
    pokemon=$Trainer.party[i]      
     next pbBattleHPItem(pokemon,battler,20,scene)
         end
    })

    try this
     
    Last edited:
    that still isn't working :/

    also it says on the wikia
    "It calls the def pbHPItem, which changes the HP of a single Pokemon, and tells it to add 20. That def will add as much HP as possible, up to that value"

    so doesn't 'pbHPItem' heal only one Pokemon? or am i reading that wrong?

    heres the new error:
    Spoiler:
     
    that still isn't working :/

    also it says on the wikia
    "It calls the def pbHPItem, which changes the HP of a single Pokemon, and tells it to add 20. That def will add as much HP as possible, up to that value"

    so doesn't 'pbHPItem' heal only one Pokemon? or am i reading that wrong?

    heres the new error:
    Spoiler:

    Try the edit. I don't have your code, so I don't know what lines are which, I'm just spitballin.

    pbHPitem does heal a single pokemon, but that's why I have it inside of the loop. It goes through and heals each one.
     
    Thanks a lot! works perfect thanks for all the help :)

    no prob

    for future reference in debugging, the "for each" error often occurs when the "for statement is called correctly. In the code I previously made, it just said
    Code:
    for i in $Trainer.party.length
    this didn't make sense (I don't know why I didn't notice before) because $Trainer.party.length is just going to be a single number. it needed to be change to
    Code:
    for i in 0..$Trainer.party.length
    so that it actually had an array of numbers to go through.
     
    Back
    Top