- 428
- Posts
- 5
- Years
- Zekko
- Seen Nov 21, 2023
My goal is to make an ability like Ditto's Imposter, except instead of Transforming into your opponent it targets the final Pokemon in your party like "Illusion" would and Transforms Ditto into that last Pokemon in your party.
If you're wondering about the lines that start with "#", those are the other Choice codes I tried using for "Final Pokemon in party". They always create an error message saying my choice is an undefined method or variable.
Here's the code I'm using under the Illusion code just in case.
Code:
Battle::AbilityEffects::OnSwitchIn.add(:DOPPELGANGERSTYLE,
proc { |ability, battler, battle, switch_in|
next if !switch_in || battler.effects[PBEffects::Transform]
choice = @battle.pbLastInTeam(@index)
# choice = idxLastParty
# choice = battler.idxLastParty
next if choice.fainted?
next if choice.effects[PBEffects::Transform] ||
choice.effects[PBEffects::Illusion] ||
choice.effects[PBEffects::Substitute] > 0 ||
choice.effects[PBEffects::SkyDrop] >= 0 ||
choice.semiInvulnerable?
battle.pbShowAbilitySplash(battler, true)
battle.pbHideAbilitySplash(battler)
battle.pbAnimation(:TRANSFORM, battler, choice)
battle.scene.pbChangePokemon(battler, choice.pokemon)
battler.pbTransform(choice)
}
)
If you're wondering about the lines that start with "#", those are the other Choice codes I tried using for "Final Pokemon in party". They always create an error message saying my choice is an undefined method or variable.
Code:
[Pokémon Essentials version 20.1]
[v20.1 Hotfixes 1.0.2]
Script error in event 22 (coords 23,7), map 156 (Aaa's house)
Exception: NoMethodError
Message: undefined method `pbLastInTeam' for nil:NilClass
***Full script:
TrainerBattle.start(:YOUNGSTER, "CALVIN", 0)
Backtrace:
215:Battle_AbilityEffects:2912:in `block in <main>'
035:Event_Handlers:227:in `trigger'
215:Battle_AbilityEffects:265:in `triggerOnSwitchIn'
151:Battle_ActionSwitching:352:in `block in pbOnBattlerEnteringBattle'
151:Battle_ActionSwitching:331:in `each'
151:Battle_ActionSwitching:331:in `pbOnBattlerEnteringBattle'
151:Battle_ActionSwitching:306:in `pbOnAllBattlersEnteringBattle'
148:Battle_StartAndEnd:312:in `pbStartBattleCore'
148:Battle_StartAndEnd:270:in `pbStartBattle'
242:Overworld_BattleStarting:513:in `block (2 levels) in start_core'
Here's the code I'm using under the Illusion code just in case.
Code:
@effects[PBEffects::Illusion] = nil
if hasActiveAbility?(:ILLUSION)
idxLastParty = @battle.pbLastInTeam(@index)
if idxLastParty >= 0 && idxLastParty != @pokemonIndex
@effects[PBEffects::Illusion] = @battle.pbParty(@index)[idxLastParty]
end
end
if hasActiveAbility?(:DOPPELGANGERSTYLE)
idxLastParty = @battle.pbLastInTeam(@index)
end
@effects[PBEffects::Imprison] = false