OverusedNameHere
Head Dev - Pokémon Throne
- 23
- Posts
- 5
- Years
- he/she/they
- Florida, USA
- Seen May 25, 2023
Does anyone know how to make a move that changes its type based on what the foe is weaker to? I'm trying to fix up Flying Press to change it from having horrible coverage and high base power to a move that is either Fighting-type or Flying-type, depending on which the opponent is weaker to. I'm fairly new to coding, so any help really is appreciated. Here is my current code for Flying Press:
As such with my little knowledge of Ruby, when the move is selected in battle, I get the following error:
I have zero clue what the issue is and have been going at this, trial and error, for hours. Again, any help is appreciated. (And for those who care, Hawlucha is a monster so I'd be nerfing the BP back down to 80 should this become working)
Code:
class PokeBattle_Move_144 < PokeBattle_Move
def tramplesMinimize?(param=1)
return true if param==1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy
return true if param==2 # Double damage
return super
end
def pbCalcTypeModSingle(moveType,defType,user,target)
targetTypes = target.pbTypes(true)
type1 = targetTypes[0]
type2 = targetTypes[1] || type1
type3 = targetTypes[2] || type2
flyingEff = 0
#Calc flying-type effectiveness
attack_type = :FLYING
if Effectiveness.not_very_effective_type?(attack_type,type1,type2,type3)
flyingEff += 1
end
if Effectiveness.normal_type?(attack_type,type1,type2,type3)
flyingEff += 1
end
if Effectiveness.super_effective_type?(attack_type,type1,type2,type3)
flyingEff = 4
end
#Turns flying-type based on effectiveness of fighting-type
attack_type = :FIGHTING
#Opponent is ineffected by the Fighting-type
if Effectiveness.ineffective_type?(attack_type,type1,type2,type3) && flyingEff >= 1
@battle.pbDisplay(_INTL("{1}'s Flying Press became Flying-type!",user.pbThis))
moveType = :FLYING if GameData::Type.exists?(:FLYING)
else
#Opponent is resistant to the Fighting-type
if Effectiveness.not_very_effective_type?(attack_type,type1,type2,type3) && flyingEff >= 2
@battle.pbDisplay(_INTL("{1}'s Flying Press became Flying-type!",user.pbThis))
moveType = :FLYING if GameData::Type.exists?(:FLYING)
else
#Opponent is normally affected by the Fighting-type
if Effectiveness.normal_type?(attack_type,type1,type2,type3) && flyingEff == 4
@battle.pbDisplay(_INTL("{1}'s Flying Press became Flying-type!",user.pbThis))
moveType = :FLYING if GameData::Type.exists?(:FLYING)
end
end
end
end
end
As such with my little knowledge of Ruby, when the move is selected in battle, I get the following error:
[Pokémon Essentials version 19.1]
[Generation 8 Project v1.1.0]
[v19.1 Hotfixes 1.0.7]
[EBDX v1.2.3]
Exception: TypeError
Message: nil can't be coerced into Integer
Backtrace:
163:Move_Usage_Calculations:85:in `*'
163:Move_Usage_Calculations:85:in `block in pbCalcTypeMod'
163:Move_Usage_Calculations:85:in `each'
163:Move_Usage_Calculations:85:in `pbCalcTypeMod'
157:Battler_UseMove_SuccessChecks:308:in `pbSuccessCheckAgainstTarget'
155:Battler_UseMove:406:in `block in pbUseMove'
155:Battler_UseMove:403:in `each'
155:Battler_UseMove:403:in `pbUseMove'
[Elite Battle: DX] Scripted Battles.rb:65:in `pbUseMove'
155:Battler_UseMove:60:in `block in pbProcessTurn'
I have zero clue what the issue is and have been going at this, trial and error, for hours. Again, any help is appreciated. (And for those who care, Hawlucha is a monster so I'd be nerfing the BP back down to 80 should this become working)