• 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] I need help with my new status v17.2

  • 67
    Posts
    4
    Years
    • He/Him
    • Seen Nov 16, 2023
    So I made this new status called shock and it is kind of a mixture of paralysis and burn it can stop a pokemon from moving and every turn it takes 1/16th max health however it only last 5 turns my issue is making it go away after five turns everything else seems to work but that I copied a lot of the sleep status code in the duration but I'll let you guys take a look

    #===============================================================================
    # Shock
    #===============================================================================
    def pbCanShock?(attacker,showMessages,move=nil)
    return false if fainted?
    return false if !attacker || attacker.fainted?
    if status==PBStatuses::SHOCK
    @battle.pbDisplay(_INTL("{1} is already Shocked!",pbThis)) if showMessages
    return false
    end
    if self.status!=0 ||
    @effects[PBEffects::Substitute]>0
    @battle.pbDisplay(_INTL("But it failed!")) if showMessages
    return false
    end
    if self.status!=0 || damagestate.substitute || (effects[PBEffects::Substitute]>0 && !PBMoveData.new(@battle.lastMoveUsed).isSoundBased?)
    @battle.pbDisplay(_INTL("But it failed!")) if showMessages
    return false
    end
    if @battle.field.effects[PBEffects::MistyTerrain]>0 &&
    !self.isAirborne?(attacker && attacker.hasMoldBreaker)
    @battle.pbDisplay(_INTL("The Misty Terrain prevented {1} from being shocked!",pbThis(true))) if showMessages
    return false
    end
    if pbHasType?(:ICE)
    @battle.pbDisplay(_INTL("But it failed!")) if showMessages
    return false
    end
    if pbHasType?(:ICE) && !hasWorkingItem(:RINGTARGET) && USENEWBATTLEMECHANICS
    @battle.pbDisplay(_INTL("It doesn't affect {1}...",pbThis(true))) if showMessages
    return false
    end
    if !attacker || !attacker.hasMoldBreaker
    if hasWorkingAbility(:LIMBER) ||
    (hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)) ||
    (hasWorkingAbility(:LEAFGUARD) && (@battle.pbWeather==PBWeather::SUNNYDAY ||
    @battle.pbWeather==PBWeather::HARSHSUN))
    @battle.pbDisplay(_INTL("{1}'s {2} prevents shock!",pbThis,PBAbilities.getName(self.ability))) if showMessages
    return false
    end
    if pbPartner.hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)
    abilityname=PBAbilities.getName(pbPartner.ability)
    @battle.pbDisplay(_INTL("{1}'s partner's {2} prevents shock!",pbThis,abilityname)) if showMessages
    return false
    end
    end
    if pbOwnSide.effects[PBEffects::Safeguard]>0 &&
    (!attacker || !attacker.hasWorkingAbility(:INFILTRATOR))
    @battle.pbDisplay(_INTL("{1}'s team is protected by Safeguard!",pbThis)) if showMessages
    return false
    end
    return true
    end

    def pbCanShockSynchronize?(opponent)
    return false if self.status!=0
    return false if @battle.field.effects[PBEffects::MistyTerrain]>0 && !self.isAirborne?
    return false if pbHasType?(:ICE) && !hasWorkingItem(:RINGTARGET) && USENEWBATTLEMECHANICS
    if hasWorkingAbility(:LIMBER) ||
    (hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)) ||
    (hasWorkingAbility(:LEAFGUARD) && (@battle.pbWeather==PBWeather::SUNNYDAY ||
    @battle.pbWeather==PBWeather::HARSHSUN))
    @battle.pbDisplay(_INTL("{1}'s {2} prevents {3}'s {4} from working!",
    pbThis,PBAbilities.getName(self.ability),
    opponent.pbThis(true),PBAbilities.getName(opponent.ability)))
    return false
    end
    if pbPartner.hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)
    @battle.pbDisplay(_INTL("{1}'s {2} prevents {3}'s {4} from working!",
    pbPartner.pbThis,PBAbilities.getName(pbPartner.ability),
    opponent.pbThis(true),PBAbilities.getName(opponent.ability)))
    return false
    end
    return true
    end

    def pbShock(attacker=nil,msg=nil)
    self.status=PBStatuses::SHOCK
    self.statusCount=5
    self.statusCount=(self.statusCount/5).floor if self.pbHasType?(:ELECTRIC)
    @battle.pbCommonAnimation("Paralysis",self,nil)
    if msg && msg!=""
    @battle.pbDisplay(msg)
    else
    @battle.pbDisplay(_INTL("{1} is Shocked! It may be unable to move!",pbThis))
    end
    PBDebug.log("[Status change] #{pbThis} was shocked")
    if attacker && self.index!=attacker.index &&
    self.hasWorkingAbility(:SYNCHRONIZE)
    if attacker.pbCanShockSynchronize?(self)
    PBDebug.log("[Ability triggered] #{self.pbThis}'s Synchronize")
    attacker.pbShock(nil,_INTL("{1}'s {2} shocked {3}! It may be unable to move!",
    self.pbThis,PBAbilities.getName(self.ability),attacker.pbThis(true)))
    end
    end
    end

    def pbShockSelf(duration=-1)
    self.status=PBStatuses::SHOCK
    if duration>0
    self.statusCount=duration
    else
    self.statusCount=5
    end
    self.statusCount=(self.statusCount/5).floor if self.pbHasType?(:ELECTRIC)
    pbCancelMoves
    @battle.pbCommonAnimation("Paralysis",self,nil)
    PBDebug.log("[Status change] #{pbThis} was shocked (#{self.statusCount} turns)")
    end
     
    Maybe part of the problem is that statusCount doesn't get decreased anywhere? I guess there must be some code that does the decreasing for sleep (probably as part of the sleep check) that you need to replicate for your status.
     
    Maybe part of the problem is that statusCount doesn't get decreased anywhere? I guess there must be some code that does the decreasing for sleep (probably as part of the sleep check) that you need to replicate for your status.

    I added the status count decrease here

    if value!=PBStatuses::POISON && value!=PBStatuses::SLEEP && value!=PBStatuses::SHOCK
    @statusCount=0
    @pokemon.statusCount=0 if @pokemon
    end

    or atleast I think I did cause those were all the scripts in sleep I could find that could help me put this status effect on a timer

    this near the 100 lines of pokebattle battler
     
    Never Mind I found the code that fixed it I also Applied it to freeze to make it last 4 turns
     
    Back
    Top