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

[Question] Im having trouble with a new ability

2
Posts
4
Years
    • Seen Jan 16, 2024
    I am very new to scripting for pokemon essentials so i need help
    Basically Im trying to make an ability, called carnivore so that it allows biting moves to act like giga drain but im getting weird results like in this clip
    Is there anyway to get it to work so that biting moves act exactly like giga drain under this ability?

    This is the script im using:
    Battle::AbilityEffects::DamageCalcFromUser.add(:CARNIVORE,
    proc { |ability, user, target, move, mults, baseDmg, type|
    if move.bitingMove?

    original_target_hp = target.hp


    damage_dealt = target.pbReduceHP(baseDmg, false)


    target.pbFaint if target.hp <= 0


    hp_restored = original_target_hp - target.hp


    user.pbRecoverHP(hp_restored) if hp_restored > 0
    end
    }
    )
     

    Atlat

    Atlat
    63
    Posts
    4
    Years
    • Seen yesterday
    I believe your issue stems from the fact that your essentially dealing damage and healing in the code where you're supposed to be affecting how much damage your attack is doing. So right off the bat, I would change DamageCalcFromUser to OnDealingHit. Next, you need to calculate how much damage is dealt, not deal damage within the code itself. Shell Bell code helps here. Finally, you need to restore half the damage dealt. Try out this code.

    Battle::AbilityEffects::OnDealingHit.add(:CARNIVORE,
    proc { |ability, user, target, move, battle|
    next if !move.bitingMove?
    next if !user.canHeal?
    totalDamage = target.damageState.totalHPLost
    battle.pbShowAbilitySplash(user)
    amt = (totalDamage / 2).floor
    user.pbRecoverHPFromDrain(amt,target)
    battle.pbHideAbilitySplash(user)
    }
    )
     
    Last edited:
    Back
    Top