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

Potion to heal the whole team

22
Posts
10
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:
     

    kvagram

    Lead coder, Generation 0
    40
    Posts
    9
    Years
  • 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.
     
    22
    Posts
    10
    Years
    • Seen Jan 30, 2020
    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)
    })
     

    kvagram

    Lead coder, Generation 0
    40
    Posts
    9
    Years
  • "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.
     
    22
    Posts
    10
    Years
    • Seen Jan 30, 2020
    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:
     
    1,224
    Posts
    10
    Years
  • 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:

    kvagram

    Lead coder, Generation 0
    40
    Posts
    9
    Years
  • "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?
     
    22
    Posts
    10
    Years
    • Seen Jan 30, 2020
    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.
     
    1,224
    Posts
    10
    Years
  • 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.
     
    22
    Posts
    10
    Years
    • Seen Jan 30, 2020
    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?
     
    1,224
    Posts
    10
    Years
  • 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.
     
    22
    Posts
    10
    Years
    • Seen Jan 30, 2020
    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:
     
    1,224
    Posts
    10
    Years
  • 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:
    22
    Posts
    10
    Years
    • Seen Jan 30, 2020
    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:
     
    1,224
    Posts
    10
    Years
  • 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.
     
    1,224
    Posts
    10
    Years
  • 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