Need help with custom Sketch-like move
Hi... I'm kind of new here, picked up RPGMXP about a month back and recently started playing around in Essentials.
I have a move I'd like to create, and I'd like some help in doing it. The idea is for the move to check for the enemy Pokemon's ID, then replace itself with a new move based on the enemy it's facing. So assuming I'm up against a Venosaur, the move would check that opponent.species is PBSpecies :: VENUSAUR, then replace itself with the move VINEWHIP.
Since the concept is similar to what Sketch does, I used Sketch as a base and came up with this:
Code:
################################################################################
# This move permanently turns into a new move based on the ID of the target.
################################################################################
class PokeBattle_Move_XXX < PokeBattle_Move ### NOTE: change func code indicator
def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
################################################################################
# defines variables to check species of opponent and move to learn
################################################################################
transcribe = 0
speciesCheck = opponent.species
################################################################################
# Case statement when SpeciesCheck = a, Transcribe = b
################################################################################
case speciesCheck
when 1 #BULBASAUR
transcribe = 208 ##VINEWHIP
return 0
when 2 #IVYSAUR
transcribe = 208
return 0
when 3 #VENOSAUR
transcribe = 208
return 0
else
@battle.pbDisplay(_INTL("But it failed!"))
return -1
end
################################################################################
# Checks if the battler already has the move attempting to be learned.
################################################################################
for i in attacker.moves
if i.id==transcribe
@battle.pbDisplay(_INTL("But it failed!"))
return -1
end
end
pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
for i in 0...attacker.moves.length ## check each move known by attacker ##
if attacker.moves[i].id==@id ## if current move being selected is this move ##
newmove=PBMove.new(transcribe) ## gets movedata from PBMove, stores in variable newmove ##
attacker.moves[i]=PokeBattle_Move.pbFromPBMove(@battle,newmove) ## changes this move in-battle to newmove ##
[email protected](attacker.index) ## identifies the move user within out-of-battle party, designates it as party ##
party[attacker.pokemonIndex].moves[i]=newmove ## changes the move with the same name as this move of the actor in the party with same name as attacker to newmove ##
movename=PBMoves.getName(transcribe) ## checks name of copied move ##
@battle.pbDisplay(_INTL("{1} sketched {2}!",attacker.pbThis,movename)) ## displays text {1} = name of this attacker, {2} = movename of copied move ##
return 0 ## returns 0: move successful ##
end
end
@battle.pbDisplay(_INTL("But it failed!")) ## generic Else statement. If for some reason no other conditionals fulfilled, this will display. (each for counts as an elsif statement I guess) ##
return -1
end
end
So what I'd like is if anyone could take a look at this chunk and tell me if there's anything I did horribly wrong...?
EDIT: Tested and failed. No error message, not "But it failed!" Just that nothing happened at all. Anyone can point out where I went wrong?
RESOLVED: Issue was that I returned 0 prematurely.