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

[Scripting Question] Trying to make a conditional one-shot move

AwesomeJr44

Lechonker
15
Posts
5
Years
    • Seen Aug 15, 2023
    I'm trying to make a new move that acts as a one-shot move (Like Fissure or Sheer Cold) but only triggers the one-shot when the target is below 50% HP, and if the target is above 50% HP, uses the move's base power instead. The move would also not have the level-based accuracy that moves like Sheer Cold typically have (Where a having a higher level increases the move's accuracy). I know the basics of creating a move, but I'm not great at scripting, so I have no clue how to make this effect. Does anyone know how to script something like this?


    Thanks in advance!
     

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • Ok, what did you so far? Show to us :)

    Did you try to copy Sheer Cold's scriot and edit? If not, do it and post here :D
     

    AwesomeJr44

    Lechonker
    15
    Posts
    5
    Years
    • Seen Aug 15, 2023
    Sorry I couldn't respond sooner, school has been really busy and I haven't had much time to do anything else.
    I think this might work, but I'm not 100% sure.

    class PokeBattle_Move_15D < PokeBattle_Move
    def pbAccuracyCheck(attacker,opponent)
    if !attacker.hasMoldBreaker && opponent.hasWorkingAbility(:STURDY)
    @battle.pbDisplay(_INTL("{1} was protected by {2}!",opponent.pbThis,PBAbilities.getName(opponent.ability)))
    return false
    end
    if opponent.hp<=opponent.totalhp/2
    def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    damage=pbEffectFixedDamage(opponent.totalhp,attacker,opponent,hitnum,alltargets,showanimation)
    if opponent.fainted?
    @battle.pbDisplay(_INTL("It's a one-hit KO!"))
    end
    return damage
    end
    end

    I removed the accuracy checks and added Brine's enemy HP check (I forgot Brine even existed until a few minutes ago) to the one hit. Does this look like it would work?
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    At the very least, your if belongs inside the def, like so:
    Code:
    def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
      if opponent.hp<=opponent.totalhp/2
        damage=pbEffectFixedDamage(opponent.totalhp,attacker,opponent,hitnum,alltargets,showanimation)
        if opponent.fainted?
          @battle.pbDisplay(_INTL("It's a one-hit KO!"))
        end
        return damage
      end
    end

    I think you're also missing a final end—when you introduce an if you need an end. You'll also need an else for when the opponent isn't in that HP range because all moves must return a number that is the amount of damage dealt. That could be "return 0" if you want the move to do nothing, but I think you wanted it to do regular damage, so you're looking for something involving super IIRC.
     

    AwesomeJr44

    Lechonker
    15
    Posts
    5
    Years
    • Seen Aug 15, 2023
    Would the else look like this? (Base power is 60)

    def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if opponent.hp<=opponent.totalhp/2
    damage=pbEffectFixedDamage(opponent.totalhp,attacker,opponent,hitnum,alltargets,showanimation)
    if opponent.fainted?
    @battle.pbDisplay(_INTL("It's a one-hit KO!"))
    end
    return damage
    else
    return 60
    end
    end
    end
    end

    or this?

    def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if opponent.hp<=opponent.totalhp/2
    damage=pbEffectFixedDamage(opponent.totalhp,attacker,opponent,hitnum,alltargets,showanimation)
    if opponent.fainted?
    @battle.pbDisplay(_INTL("It's a one-hit KO!"))
    end
    else
    return 60
    end
    end
    end
    end
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    The first looks closer, because there shouldn't be an end between if and else. Having said that, I think both of those will make the move do a fixed 60 damage if the foe has > 50% HP. Try it and see. If it doesn't work properly, then, again, have a look for how to use "super". There are some examples of other pbEffects that use it IIRC.

    btw it's much easier to read your code to see if the ends align properly if you use [code]...[/code] tags, and indent.
     

    AwesomeJr44

    Lechonker
    15
    Posts
    5
    Years
    • Seen Aug 15, 2023
    Code:
    super(type,attacker,opponent)
    I think this might be the super that mgriffin was referring to, but can someone confirm this? I don't have the scripting knowledge to know what this does.
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    I think it's more likely to be something like:
    Code:
    super(attacker,opponent,hitnum,alltargets,showanimation)
    Which I guess ought to run the default pbEffect (which just does normal base damage stuff, IIRC).
     

    AwesomeJr44

    Lechonker
    15
    Posts
    5
    Years
    • Seen Aug 15, 2023
    After finally getting the free time to test it, everything seems to be working properly! Thank you for your help!
     
    Back
    Top