Advertiser Content

clawort

Male
Australia
Seen 4 Weeks Ago
Posted 4 Weeks Ago
82 posts
138 Days
I managed to get my ability Lucky Heal to work, but the way it functions is that it should only heal the user ONCE per battle if its HP is in red, but every time I test it out, it heals it multiple times! :(

Here's the code:
# Lucky Heal
if i.hasWorkingAbility(:LUCKYHEAL) && i.hp<=(i.totalhp/3).floor
if i.effects[PBEffects::LuckyHeal]==0 && i.effects[PBEffects::HealBlock]==0
PBDebug.log("[Ability triggered] #{i.pbThis}'s Lucky Heal")
hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
pbDisplay(_INTL("{1}'s {2} healed itself!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
elsif i.effects[PBEffects::LuckyHeal]==1
end
end

Please, what am I doing wrong?!

clawort

Male
Australia
Seen 4 Weeks Ago
Posted 4 Weeks Ago
82 posts
138 Days
You don't set the LuckyHeal effect to 1 after gaining HP, so the code for "Lucky Heal has not triggered yet in this battle" runs every time.

(Also once you've fixed this you might want to test if you can use the ability again after switching out and back in)
Okay but Idk how to make it only usable once!

I tried:
# Lucky Heal
if i.hasWorkingAbility(:LUCKYHEAL) && i.hp<=(i.totalhp/3).floor
if i.effects[PBEffects::LuckyHeal]==0 && i.effects[PBEffects::HealBlock]==0
PBDebug.log("[Ability triggered] #{i.pbThis}'s Lucky Heal")
hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
pbDisplay(_INTL("{1}'s {2} healed itself!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
elsif i.effects[PBEffects::LuckyHeal]>0
end
end
But it still kept doing it multiple times a battle and not once! :(

mgriffin

Online now
Posted 46 Minutes Ago
524 posts
5.2 Years
Okay but Idk how to make it only usable once!
I basically told you what do to:
You don't set the LuckyHeal effect to 1 after gaining HP
You need to set the "i.effects[PBEffects::LuckyHeal]" to 1 after healing the first time so that the second time the code runs your if doesn't match, and the elsif does.

mgriffin

Online now
Posted 46 Minutes Ago
524 posts
5.2 Years
Question: What's a Ruby tutorial?
Ruby is the programming language that you script in. Marin wrote a tutorial on PC but of course there are others out there.

At any rate I would recommend you take some responsibility for learning how to script (and Google in general, if you had searched "ruby tutorial" you would have known what I was talking about) and not coming onto the forums asking people to write all the code for you. But that's just my opinion, do what suits you.

Boonzeet

Pokémon Secrets of the Ages Developer

Male
United Kingdom
Seen 1 Week Ago
Posted May 26th, 2019
104 posts
10.2 Years
I don't understand how you'd have created this ability without know how to increment the variable.

if i.hasWorkingAbility(:LUCKYHEAL) && i.hp<=(i.totalhp/3).floor
  if i.effects[PBEffects::LuckyHeal]==0 && i.effects[PBEffects::HealBlock]==0
    PBDebug.log("[Ability triggered] #{i.pbThis}'s Lucky Heal")
    hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
    pbDisplay(_INTL("{1}'s {2} healed itself!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
    i.effects[PBEffects::LuckyHeal] += 1
  elsif i.effects[PBEffects::LuckyHeal]>0
  end
end
Solo artist and developer on Pokémon Secrets of the Ages. Project post coming soon!

My DeviantART

clawort

Male
Australia
Seen 4 Weeks Ago
Posted 4 Weeks Ago
82 posts
138 Days
Ruby is the programming language that you script in. Marin wrote a tutorial on PC but of course there are others out there.

At any rate I would recommend you take some responsibility for learning how to script (and Google in general, if you had searched "ruby tutorial" you would have known what I was talking about) and not coming onto the forums asking people to write all the code for you. But that's just my opinion, do what suits you.
Okay!

clawort

Male
Australia
Seen 4 Weeks Ago
Posted 4 Weeks Ago
82 posts
138 Days
I don't understand how you'd have created this ability without know how to increment the variable.

if i.hasWorkingAbility(:LUCKYHEAL) && i.hp<=(i.totalhp/3).floor
  if i.effects[PBEffects::LuckyHeal]==0 && i.effects[PBEffects::HealBlock]==0
    PBDebug.log("[Ability triggered] #{i.pbThis}'s Lucky Heal")
    hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
    pbDisplay(_INTL("{1}'s {2} healed itself!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
    i.effects[PBEffects::LuckyHeal] += 1
  elsif i.effects[PBEffects::LuckyHeal]>0
  end
end
Might try that!

clawort

Male
Australia
Seen 4 Weeks Ago
Posted 4 Weeks Ago
82 posts
138 Days
I don't understand how you'd have created this ability without know how to increment the variable.

if i.hasWorkingAbility(:LUCKYHEAL) && i.hp<=(i.totalhp/3).floor
  if i.effects[PBEffects::LuckyHeal]==0 && i.effects[PBEffects::HealBlock]==0
    PBDebug.log("[Ability triggered] #{i.pbThis}'s Lucky Heal")
    hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
    pbDisplay(_INTL("{1}'s {2} healed itself!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
    i.effects[PBEffects::LuckyHeal] += 1
  elsif i.effects[PBEffects::LuckyHeal]>0
  end
end
It doesn't work!

Poq

Seen 1 Week Ago
Posted 1 Week Ago
145 posts
1.9 Years
I decided to give up on Lucky Heal since it seems impossible to make it only work once.
It is definitely not impossible. In fact, you're very close to accomplishing it.

Now, Bonzeet showed you how to increment the lucky heal effect. But here's the other side if it - did you ever add LuckyHeal to the list of in battle effects? And did you initialize it (seeing it to 0) in the battle script?

As has been suggested, you need to look closer at essentials and learn more about ruby to understand how they work. We've all gone through that process. You're clearly driven and ambitious, so learning a bit more will definitely help you achieve your ambitions.

clawort

Male
Australia
Seen 4 Weeks Ago
Posted 4 Weeks Ago
82 posts
138 Days
It is definitely not impossible. In fact, you're very close to accomplishing it.

Now, Bonzeet showed you how to increment the lucky heal effect. But here's the other side if it - did you ever add LuckyHeal to the list of in battle effects? And did you initialize it (seeing it to 0) in the battle script?

As has been suggested, you need to look closer at essentials and learn more about ruby to understand how they work. We've all gone through that process. You're clearly driven and ambitious, so learning a bit more will definitely help you achieve your ambitions.
Thanks dude!
Advertiser Content