- 2
- Posts
- 7
- Years
- Seen Dec 1, 2016
Hi guys.
I'm completely new to Essentials, and I decided making a somewhat short game just to get my feet wet, but while I was able to create some maps and a couple sprites, I've failed quite epically on my first attempt to mess with the script.
I want to create a move called Invisibility, which increases Evasion by 6 stages for three turns, and then reduces it by 6 stages. Here's what I did (using Essentials 16.2, by the way):
In PokéBattle_MoveEffects, after the last line:
I tried to take bits of code from Acupressure, Double Team and Taunt for this. Acupressure because it's a stat raising move that can be targeted at the partner, Double Team because it can only raise Evasion, and Taunt because it creates a counter and reverts the effect after 3 turns.
In PokéBattle_MoveEffects, after the last line:
The code here is almost copy/paste from Taunt, and is placed directly below it. I only added a line to reduce Evasion by 6 once the counter hits zero.
In PBEffects, specifically battler effects:
I can teach Invisibility to a Pokémon through the Debug just fine, but as soon as I try to use it in battle, I get the following error:
Then, the battle proceeds - skipping my Pokémon's turn - and on the end of every turn, the following error shows up:
This continues even after my Pokémon has fainted, with the opponent attacking no target while the second error pops up every turn, not even giving me the choice to send another Pokémon or flee.
Any tips?
I'm completely new to Essentials, and I decided making a somewhat short game just to get my feet wet, but while I was able to create some maps and a couple sprites, I've failed quite epically on my first attempt to mess with the script.
I want to create a move called Invisibility, which increases Evasion by 6 stages for three turns, and then reduces it by 6 stages. Here's what I did (using Essentials 16.2, by the way):
- Defined a move called Invisibility in PBS\moves.txt
- Added an effect to that move in PokéBattle_MoveEffects (code below)
- Added and effect for this move in PBEffects, below the last one.
- Finally, created a section for this move in the "End of Round" section of PokeBattle_Battle, right below Taunt.
In PokéBattle_MoveEffects, after the last line:
Code:
#===============================================================================
# NOTE: If you're inventing new move effects, use function code 159 and onwards.
#===============================================================================
################################################################################
# 159: Increases user's evasion by +6 for three turns. (Invisibility) #Custom
################################################################################
class PokeBattle_Move_159 < PokeBattle_Move
def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
if opponent.effects[PBEffects::Invisibility]>0
@battle.pbDisplay(_INTL("But it failed!"))
return -1
end
if !opponent.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
@battle.pbDisplay(_INTL("But it failed!"))
return -1
end
if attacker.index!=opponent.index
if (opponent.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(attacker)) || opponent.pbOwnSide.effects[PBEffects::CraftyShield]
@battle.pbDisplay(_INTL("But it failed!"))
return -1
end
end
pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
opponent.effects[PBEffects::Invisibility]=3
opponent.pbIncreaseStat(PBStats::EVASION,6,attacker,false,self,showanim)
@battle.pbCommonAnimation("StatUp",opponent,nil)
@battle.pbDisplay(_INTL("{1} became invisible!",opponent.pbThis))
return 0
end
end
In PokéBattle_MoveEffects, after the last line:
Code:
# Invisibility - #Custom
for i in priority
next if i.isFainted?
if i.effects[PBEffects::Invisibility]>0
i.effects[PBEffects::Invisibility]-=1
if i.effects[PBEffects::Invisibility]==0
i.pbReduceStat(PBStats::EVASION,6,attacker,false,self,showanim)
pbDisplay(_INTL("{1}'s invisibility wore off!",i.pbThis))
PBDebug.log("[End of effect] #{i.pbThis} is no longer invisibile")
end
end
end
In PBEffects, specifically battler effects:
Code:
WeightChange = 104
Wish = 105
WishAmount = 106
WishMaker = 107
Yawn = 108
Invisibility = 109 #Custom
I can teach Invisibility to a Pokémon through the Debug just fine, but as soon as I try to use it in battle, I get the following error:
Code:
---------------------------
Pokemon Essentials
---------------------------
Exception: NoMethodError
Message: undefined method `>' for nil:NilClass
PokeBattle_MoveEffects:1257:in `pbEffect'
PokeBattle_Battler:2728:in `pbProcessMoveAgainstTarget'
PokeBattle_Battler:2684:in `each'
PokeBattle_Battler:2684:in `pbProcessMoveAgainstTarget'
PokeBattle_Battler:3160:in `pbUseMove'
PokeBattle_Battler:3140:in `loop'
PokeBattle_Battler:3163:in `pbUseMove'
PokeBattle_Battler:3361:in `pbProcessTurn'
PokeBattle_Battler:3360:in `logonerr'
PokeBattle_Battler:3360:in `pbProcessTurn'
Then, the battle proceeds - skipping my Pokémon's turn - and on the end of every turn, the following error shows up:
Code:
---------------------------
Pokemon Essentials
---------------------------
Exception: NoMethodError
Message: undefined method `>' for nil:NilClass
PokeBattle_Battle:3463:in `__clauses__pbEndOfRoundPhase'
PokeBattle_Battle:3461:in `each'
PokeBattle_Battle:3461:in `__clauses__pbEndOfRoundPhase'
PokeBattle_Clauses:42:in `pbEndOfRoundPhase'
PokeBattle_Battle:2591:in `pbStartBattleCore'
PokeBattle_Battle:2590:in `logonerr'
PokeBattle_Battle:2590:in `pbStartBattleCore'
PokeBattle_Battle:2572:in `loop'
PokeBattle_Battle:2595:in `pbStartBattleCore'
PokeBattle_Battle:2395:in `pbStartBattle'
This continues even after my Pokémon has fainted, with the opponent attacking no target while the second error pops up every turn, not even giving me the choice to send another Pokémon or flee.
Any tips?