- 4
- Posts
- 8
- Years
- Seen May 31, 2024
I'm new to coding and am trying to make a modified version of Sky Attack, but the catch is that if a non-Dark Pokemon tries to use it, if will fail, similar to how Dark Void can only be used by Darkrai. While it works as intended for the most part, it seems to only actually check if the move is usable (thus displaying the "But it failed!" message) during the second turn of the attack, while the first turn is spent charging regardless if the user is Dark or not. Is it possible to make the check happen during the turn the move is selected? Here is how the code looks now:
Code:
class PokeBattle_Move_159 < PokeBattle_Move
def pbMoveFailed(attacker,opponent)
return true if !attacker.pbHasType?(:DARK)
return false
end
def pbTwoTurnAttack(attacker)
@immediate=false
if !@immediate && attacker.hasWorkingItem(:POWERHERB)
@immediate=true
end
return false if @immediate
return attacker.effects[PBEffects::TwoTurnAttack]==0
end
def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
if @immediate || attacker.effects[PBEffects::TwoTurnAttack]>0
pbShowAnimation(@id,attacker,opponent,1,alltargets,showanimation) # Charging anim
@battle.pbDisplay(_INTL("{1} became cloaked in a deep darkness!",attacker.pbThis))
end
if @immediate
@battle.pbCommonAnimation("UseItem",attacker,nil)
@battle.pbDisplay(_INTL("{1} became fully charged due to its Power Herb!",attacker.pbThis))
attacker.pbConsumeItem
end
return 0 if attacker.effects[PBEffects::TwoTurnAttack]>0
return super(attacker,opponent,hitnum,alltargets,showanimation)
end