- 10
- Posts
- 5
- Years
- Seen Dec 22, 2020
So I wanted to try to script a move myself for the first time. I'm having a few difficulties though. I'm trying to recreate the move Jaw Lock from Gen 8.
Current state: Upon using Jaw Lock, it correctly shows the message "Both Pokémon can no longer escape!", but I can still switch out my Pokemon.
Here's what I did.
In PBEffects under the part where it says "These effects apply to the battle (i.e. both sides)":
In PokeBattle_MoveEffects:
In PokeBattle_Battle in the "pbCanSwitch?" part:
Again in PokeBattle_Battle in the "pbEndOfRoundPhase" part:
Current state: Upon using Jaw Lock, it correctly shows the message "Both Pokémon can no longer escape!", but I can still switch out my Pokemon.
Here's what I did.
In PBEffects under the part where it says "These effects apply to the battle (i.e. both sides)":
Code:
JawLock = 14
In PokeBattle_MoveEffects:
Code:
################################################################################
# Deals damage and makes both the target and the user unable to switch out.
#(Jaw Lock)
################################################################################
class PokeBattle_Move_266 < PokeBattle_Move
def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
if pbIsDamaging?
ret=super(attacker,opponent,hitnum,alltargets,showanimation)
if opponent.damagestate.calcdamage>0 && !opponent.damagestate.substitute &&
!opponent.isFainted?
if opponent.effects[PBEffects::JawLock]==0 || attacker.effects[PBEffects::JawLock]==0
@battle.field.effects[PBEffects::JawLock]=1
@battle.pbDisplay(_INTL("Both Pokémon can no longer escape!",opponent.pbThis))
end
end
return ret
end
end
end
In PokeBattle_Battle in the "pbCanSwitch?" part:
Code:
if @field.effects[PBEffects::JawLock]>0
pbDisplayPaused(_INTL("{1} can't be switched out!",thispkmn.pbThis)) if showMessages
return false
end
Again in PokeBattle_Battle in the "pbEndOfRoundPhase" part:
Code:
# Jaw Lock
if @field.effects[PBEffects::JawLock]==1
for i in 0...4
@field.effects[PBEffects::JawLock]=0 if @battlers[i].isFainted?
end
end