• 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] Trouble with Function Codes

  • 18
    Posts
    6
    Years
    • Seen Sep 26, 2023
    Hi, I need help to add two new move effects. These moves effects are similar to King's Shield but one reduces the speed that it's call Icy Shield (Ice Type) and the other the defense that it's called Meteor Shield (Fighting Type) but these effects jump me error when I try to use then. I like if someone teach me from the start to understand or give me these alredy done.

    Sorry if my english it's not good
     
    Last edited:
  • 658
    Posts
    7
    Years
    Hi, I need help to add two new move effects. These moves effects are similar to King's Shield but one reduces the speed that it's call Icy Shield (Ice Type) and the other the defense that it's called Meteor Shield (Fighting Type) but these effects jump me error when I try to use then. I like if someone teach me from the start to understand or give me these alredy done.

    Sorry if my english it's not good

    Use Ctrl+Shift+F in the Script Window and search for KINGSHIELD and copy paste the code with the changes you want to make. I'd help you more if I had access to my PC right now. Can you please post the error you are getting?
     
  • 18
    Posts
    6
    Years
    • Seen Sep 26, 2023
    Use Ctrl+Shift+F in the Script Window and search for KINGSHIELD and copy paste the code with the changes you want to make. I'd help you more if I had access to my PC right now. Can you please post the error you are getting?


    Icy Shield:

    Mesage: unintialized constant PBEffects::IcyShield
    PokeBattle_Battler:2966:in 'pbSuccesCheck'
    PokeBattle_Battler:3333:in 'pbProcessMoveAgainstTarget'
    PokeBattle_Battler:3329:in 'each'
    PokeBattle_Battler:3329:in 'pbProcessMoveAgainstTarget'
    PokeBattle_Battler:3918:in 'pbUseMove'
    PokeBattle_Battler:3918:in 'loop'
    PokeBattle_Battler:3941:in 'pbUseMove'
    PokeBattle_Battler:4146:in 'pbProcessTurn'
    PokeBattle_Battler:4145:in 'logonerr'
    PokeBattle_Battler:4145:in 'pbProcessTurn'

    Meteor Shield:

    Mesage: unintialized constant PBEffects::MeteorShield
    PokeBattle_MoveEffects:2796:in 'pbEffect'
    PokeBattle_Battler:3894:in 'pbUseMovet'
    PokeBattle_Battler:3893:in 'logonerr'
    PokeBattle_Battler:3893:in 'pbUseMove'
    PokeBattle_Battler:4146:in 'pbProcessTurn'
    PokeBattle_Battler:4145:in 'logonerr'
    PokeBattle_Battler:4145:in 'pbProcessTurn'
    PokeBattle_Battler:3146:in 'pbAttackPhase'
    PokeBattle_Battler:3143:in 'each'
    PokeBattle_Battler:3143:in 'pbAttackPhase'



    These are the errors
     
  • 1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    You need to define those effects in the PBEffects part of the scripts. Basically just picking an unused number, and making sure that you also initialize the effects array on your battlers.
     
  • 18
    Posts
    6
    Years
    • Seen Sep 26, 2023
    You need to define those effects in the PBEffects part of the scripts. Basically just picking an unused number, and making sure that you also initialize the effects array on your battlers.

    Can you please teach me how to do it?. 'cause i'm a beginner in ruby coding
     
  • 1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    Can you please teach me how to do it?. 'cause i'm a beginner in ruby coding

    Have you looked in the PBEffects section? It's just a list of names and numbers. Find the section that has the KingsShield bit, and add two new lines at the bottom (with the appropriate numbers—will be obvious) for your missing PBEffects (i.e. IcyShield and MeteorShield).

    Then if you still get crashes search for any other places where PBEffects::KingsShield is mentioned, and add similar code but for your new effects.
     
  • 18
    Posts
    6
    Years
    • Seen Sep 26, 2023
    Have you looked in the PBEffects section? It's just a list of names and numbers. Find the section that has the KingsShield bit, and add two new lines at the bottom (with the appropriate numbers—will be obvious) for your missing PBEffects (i.e. IcyShield and MeteorShield).

    Then if you still get crashes search for any other places where PBEffects::KingsShield is mentioned, and add similar code but for your new effects.

    Now the protect effect of the two moves are always there , when i activate the attack the effect starts to run, but when i go to the next turn and the wild pokemon attack the effect of meteor shield or icy shield stays there
     
  • 1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    Now the protect effect of the two moves are always there , when i activate the attack the effect starts to run, but when i go to the next turn and the wild pokemon attack the effect of meteor shield or icy shield stays there

    Okay, well there must be a place where PBEffects::KingsShield is mentioned which turns off the effect at the end of the turn, but you haven't copied that bit for yours.
     
  • 18
    Posts
    6
    Years
    • Seen Sep 26, 2023
    Okay, well there must be a place where PBEffects::KingsShield is mentioned which turns off the effect at the end of the turn, but you haven't copied that bit for yours.

    ###############################################################################
    # El usuario se protege contra movimientos de daño esta ronda.
    # Reduce la Velocidad del usuario de un movimiento de contacto en 2 niveles.
    # (Escudo Gélido/Icy Shield)
    ################################################################################
    class PokeBattle_Move_20A < PokeBattle_Move
    def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if attacker.effects[PBEffects::IcyShield]
    @battle.pbDisplay(_INTL("¡Pero falló!"))
    return -1
    end
    ratesharers=[
    0xAA, # Detección, Protección
    0xAB, # Anticipo
    0xAC, # Vastaguardia
    0xE8, # Aguante
    0x14B, # Escudo Real
    0x14C, # Barrera Espinosa
    0x184, # Obstruct
    0x20A, # IcyShield
    0x20B # MeteorShield
    ]
    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 && # Escoge un movimiento
    !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("¡Pero falló!"))
    return -1
    end
    pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
    attacker.effects[PBEffects::IcyShield]=true
    attacker.effects[PBEffects::ProtectRate]*=2
    @battle.pbDisplay(_INTL("¡{1} se está protegiendo!",attacker.pbThis))
    return 0
    end
    end

    ###############################################################################
    # El usuario se protege contra movimientos de daño esta ronda.
    # Reduce la Defensa del usuario de un movimiento de contacto en 2 niveles.
    # (Escudo Estelar/Meteor Shield)
    ################################################################################
    class PokeBattle_Move_20B < PokeBattle_Move
    def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if attacker.effects[PBEffects::MeteorShield]
    @battle.pbDisplay(_INTL("¡Pero falló!"))
    return -1
    end
    ratesharers=[
    0xAA, # Detección, Protección
    0xAB, # Anticipo
    0xAC, # Vastaguardia
    0xE8, # Aguante
    0x14B, # Escudo Real
    0x14C, # Barrera Espinosa
    0x184, # Obstruct
    0x20A, # IcyShield
    0x20B # MeteorShield
    ]
    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 && # Escoge un movimiento
    !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("¡Pero falló!"))
    return -1
    end
    pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
    attacker.effects[PBEffects::MeteorShield]=true
    attacker.effects[PBEffects::ProtectRate]*=2
    @battle.pbDisplay(_INTL("¡{1} se está protegiendo!",attacker.pbThis))
    return 0
    end
    end

    Can you correct the wrong parts?
     
  • 1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    I don't think it's in that part of the code. Try searching all scripts with Ctrl+Shift+F for PBEffects::KingsShield
     
    Back
    Top