• 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!
  • 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] How would I recreate this code in version 18 of essentials

  • 67
    Posts
    4
    Years
    • He/Him
    • Seen Nov 16, 2023
    how would I recreate this in v18

    ################################################################################
    # Increases the user and its partner's Speed by 1 stage. (Turbo Boost)
    # If user is flying boost speed by 2 stages
    ################################################################################
    class PokeBattle_Move_200 < PokeBattle_Move
    def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    return super(attacker,opponent,hitnum,alltargets,showanimation) if pbIsDamaging?
    return -1 if !attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,true,self) &&
    !attacker.pbPartner.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,true,self)
    pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
    increment=1
    if attacker.pbHasType?(:FLYING) ||
    attacker.pbPartner.pbHasType?(:FLYING)
    attacker.pbIncreaseStat(PBStats::SPEED,2,attacker,false,self)
    attacker.pbPartner.pbIncreaseStat(PBStats::SPEED,2,attacker,false,self)
    elsif !attacker.pbHasType?(:FLYING) ||
    !attacker.pbPartner.pbHasType?(:FLYING)
    attacker.pbIncreaseStat(PBStats::SPEED,1,attacker,false,self)
    attacker.pbPartner.pbIncreaseStat(PBStats::SPEED,1,attacker,false,self)
    return 0
    end
    end

    def pbAdditionalEffect(attacker,opponent)
    if attacker.pbHasType?(:FLYING) ||
    attacker.pbPartner.pbHasType?(:FLYING)
    next if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
    attacker.pbIncreaseStat(PBStats::SPEED,2,attacker,false,self)
    elsif !attacker.pbHasType?(:FLYING) ||
    !attacker.pbPartner.pbHasType?(:FLYING)
    next if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
    attacker.pbIncreaseStat(PBStats::SPEED,1,attacker,false,self)
    end
    if attacker.pbHasType?(:FLYING) ||
    attacker.pbPartner.pbHasType?(:FLYING)
    next if attacker.pbPartner.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
    attacker.pbIncreaseStat(PBStats::SPEED,2,attacker,false,self)
    elsif !attacker.pbHasType?(:FLYING) ||
    !attacker.pbPartner.pbHasType?(:FLYING)
    !attacker.pbPartner.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
    attacker.pbIncreaseStat(PBStats::SPEED,1,attacker,false,self)
    end
    end
    end
     
    Hey there :)
    I don't know if that's exactly how you imagined the move, but it should do the trick. If you want me to adapt it in any way be sure to ask.
    Be sure to define the move's target as NearAlly in the PBS File to get the move to function correctly.
    Spoiler:
     
    Last edited:
    thank you so much by any chance do you know what "b" means in the new code for essentials v18 I'm still learning and I would just like to understand this part of the code "targets.each do |b|" I'm guessing it is defining it in some way or calling to it but I am not sure.
     
    Here you go:
    The function
    Code:
    def pbMoveFailed?(user,targets)
    that's embeded in your move's code gives us two arguments to play with. First of all "user" which is a simple variable referring to the user of this move.
    "targets" on the other hand is an array which contains all the move's targets. Usually it looks like this "[target]" but with a multi targeting move it could also be this [target1, target2, target3]. Now in this method we must check if the move fails but we don't get the simple variable
    "target" to work with.
    I guess you're familiar with for loops (f.ex. "for i in targets" etc.). Doing this
    Code:
    targets.each do |b|
    works in the same way. Basically the following code will be executed for each element of our array ("targets"). The "|b|" has the same purpose as the "i" in the afore mentioned for loop. It is the variable referring to the current object of the array the code is executed on and can of course have any name. "b" is just normally used in essentials code as it's short for battler.
    This
    Code:
    array.each do |something|
    does the same as this
    Code:
    for something in array


    Also quick update on the move:
    Code:
    def pbEffectGeneral(user)
        incre = 1
        incre = 2 if [B]user[/B].pbHasType?(:FLYING)
        user.pbRaiseStatStage(PBStats::SPEED,incre,user,true) if user.pbCanRaiseStatStage?(PBStats::SPEED,user,self)
      end
     
    Ok thanks I get it now this will help me with coding in the defensive tm that acts like defense curl but for your side of the team normally and acts like cosmic power for you and your side of the field when paired with a rock type
     
    but uh just one last thing for this code how would I make this work with also allowing me to trigger the effect in doubles if my ally has the flying typing because attacker.pbPartner is no longer a method
     
    Back
    Top