• 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!
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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 move based off of King's Shield

gooberg

Broseph
  • 4
    Posts
    9
    Years
    • Seen Mar 7, 2025
    As the title says, I'm trying to create a new move effect based off of King's Shield's effect. It's supposed to lower Speed by two stages instead of Attack, and I was gonna call it "Slime Trap".

    I thought it'd be as easy as replacing King's Shield and changing 'attack' to 'speed' in the code, but now I'm not so sure. This is what I get using the script editor:

    ################################################################################
    # User is protected against damaging moves this round. Decreases the Attack of
    # the user of a stopped contact move by 2 stages. (King's Shield)
    ################################################################################
    class PokeBattle_Move_159 < PokeBattle_Move
    def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if attacker.effects[PBEffects::KingsShield]
    @battle.pbDisplay(_INTL("But it failed!"))
    return -1
    end
    ratesharers=[
    0xAA, # Detect, Protect
    0xAB, # Quick Guard
    0xAC, # Wide Guard
    0xE8, # Endure
    0x14B, # King's Shield
    0x14C # Spiky Shield
    ]
    if !ratesharers.include?(PBMoveData.new(attacker.lastMoveUsed).function)
    attacker.effects[PBEffects::ProtectRate]=1
    end
    unmoved=false
    for poke in @battle.battlers
    next if poke.index==attacker.index
    if @battle.choices[poke.index][0]==1 && # Chose a move
    !poke.hasMovedThisRound?
    unmoved=true; break
    end
    end
    if !unmoved ||
    (!USENEWBATTLEMECHANICS &&
    @battle.pbRandom(65536)>=(65536/attacker.effects[PBEffects::ProtectRate]).floor)
    attacker.effects[PBEffects::ProtectRate]=1
    @battle.pbDisplay(_INTL("But it failed!"))
    return -1
    end
    pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
    attacker.effects[PBEffects::KingsShield]=true
    attacker.effects[PBEffects::ProtectRate]*=2
    @battle.pbDisplay(_INTL("{1} protected itself!",attacker.pbThis))
    return 0
    end
    end

    I'm not really seeing where I can edit the stat being lowered, and I don't know what the heck 'ratesharers' are, either. I'd appreciate it if I could get some advice on what exactly I need to do to add this move in.
     
    As the title says, I'm trying to create a new move effect based off of King's Shield's effect. It's supposed to lower Speed by two stages instead of Attack, and I was gonna call it "Slime Trap".

    I thought it'd be as easy as replacing King's Shield and changing 'attack' to 'speed' in the code, but now I'm not so sure. This is what I get using the script editor:



    I'm not really seeing where I can edit the stat being lowered, and I don't know what the heck 'ratesharers' are, either. I'd appreciate it if I could get some advice on what exactly I need to do to add this move in.

    That's because you're looking in the wrong place.

    Look for # King's Shield using CTRL+Shift+F and look in the PokeBattle_Battlers Section. You will find it there.
     
    That's because you're looking in the wrong place.

    Look for # King's Shield using CTRL+Shift+F and look in the PokeBattle_Battlers Section. You will find it there.


    Thanks a lot for your help! I copy/pasted the King's Shield code and changed the name (KingShield --> SlimeTrap) and stat affected (ATTACK --> SPEED), then added 'SlimeTrap' as effect 109 in the same section as KingsShield in PBEffects.

    I assume I still need to edit the PokeBattle_MoveEffects code to actually finish up the move? I've copied and edited the code in PokeBattle_MoveEffects like so:

    ################################################################################
    # User is protected against damaging moves this round. Decreases the Speed of
    # the user of a stopped contact move by 2 stages. (SlimeTrap)
    ################################################################################
    class PokeBattle_Move_159 < PokeBattle_Move
    def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if attacker.effects[PBEffects::SlimeTrap]
    @battle.pbDisplay(_INTL("But it failed!"))
    return -1
    end
    ratesharers=[
    0xAA, # Detect, Protect
    0xAB, # Quick Guard
    0xAC, # Wide Guard
    0xE8, # Endure
    0x14B, # King's Shield
    0x14C # Spiky Shield
    ]
    if !ratesharers.include?(PBMoveData.new(attacker.lastMoveUsed).function)
    attacker.effects[PBEffects::ProtectRate]=1
    end
    unmoved=false
    for poke in @battle.battlers
    next if poke.index==attacker.index
    if @battle.choices[poke.index][0]==1 && # Chose a move
    !poke.hasMovedThisRound?
    unmoved=true; break
    end
    end
    if !unmoved ||
    (!USENEWBATTLEMECHANICS &&
    @battle.pbRandom(65536)>=(65536/attacker.effects[PBEffects::ProtectRate]).floor)
    attacker.effects[PBEffects::ProtectRate]=1
    @battle.pbDisplay(_INTL("But it failed!"))
    return -1
    end
    pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
    attacker.effects[PBEffects::SlimeTrap]=true
    attacker.effects[PBEffects::ProtectRate]*=2
    @battle.pbDisplay(_INTL("{1} protected itself!",attacker.pbThis))
    return 0
    end
    end

    Is there anything left that I'm forgetting?
     
    Last edited:
    Is there anything left that I'm forgetting?

    Yes. First add the move effect. Then go in PokeBattle_Battle and in def pbEndOfRoundPhase add
    Code:
    @battlers[i].effects[PBEffects::SlimeTrap] = false
    where you see the line
    "@battlers.effects[PBEffects::Protect] = false"
     
    Back
    Top