- 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