Battle::AbilityEffects::OnSwitchIn.add(:OMNIGROWTH,
proc { |ability, battler, battle, switch_in|
battle.pbShowAbilitySplash(battler)
if !battler.pbOwnedByPlayer?
wild_omnigrowth_count = Pokemon::WILD_OMNIGROWTH_COUNT
wild_random_omnigrowth_count = battle.pbRandom(wild_omnigrowth_count)
battler.update_omnigrowth_count(wild_random_omnigrowth_count)
end
battle.pbDisplay(_INTL("{1}渴望有价值的对手!", battler.pbThis))
battle.pbDisplay(_INTL("{1}已经打倒了{2}名对手!", battler.pbThis, battler.omnigrowth_count)) if battler.omnigrowth_count > 0
battle.pbHideAbilitySplash(battler)
}
)
Battle::AbilityEffects::SpeedCalc.add(:OMNIGROWTH,
proc { |ability, battler, mult|
next mult * (1 + battler.omnigrowth_count_power_speed_up)
}
)
Battle::AbilityEffects::DamageCalcFromUser.add(:OMNIGROWTH,
proc { |ability, user, target, move, mults, power, type|
mults[:attack_multiplier] *= 1 + user.omnigrowth_count_power_speed_up
mults[:power_multiplier] *= 1 + user.omnigrowth_move_power_up(move.id)
}
)
Battle::AbilityEffects::DamageCalcFromTarget.add(:OMNIGROWTH,
proc { |ability, user, target, move, mults, power, type|
mults[:defense_multiplier] *= 1 - user.omnigrowth_count_defense_down
}
)
Battle::AbilityEffects::OnEndOfUsingMove.add(:OMNIGROWTH,
proc { |ability, user, targets, move, battle|
num_fainted = targets.count { |b| b.damageState.fainted }
next if num_fainted == 0
battle.pbShowAbilitySplash(user)
user.update_omnigrowth_count(num_fainted)
user.update_omnigrowth_move(move.id, num_fainted)
battle.pbDisplay(_INTL("{1}变得更加强大了!", user.pbThis))
battle.pbDisplay(_INTL("{1}已经打倒了{2}名对手!", user.pbThis, user.omnigrowth_count))
battle.pbHideAbilitySplash(user)
}
)
class Pokemon
WILD_OMNIGROWTH_COUNT = 30
POWER_SPEED_UP_RATE = 0.5
DENFESE_DOWN_RATE = 0.1
def omnigrowth_count
@omnigrowth_count ||= 0
end
def update_omnigrowth_count(amount = 1)
@omnigrowth_count += amount
end
def omnigrowth_count_power_speed_up
omnigrowth_count * 0.01 * POWER_SPEED_UP_RATE
end
def omnigrowth_count_defense_down
omnigrowth_count * 0.01 * DENFESE_DOWN_RATE
end
def omnigrowth_move
@omnigrowth_move ||= Hash.new(0)
end
def update_omnigrowth_move(move_id, amount = 1)
@omnigrowth_move[move_id] += amount
end
def omnigrowth_move_power_up(move_id)
omnigrowth_move[move_id] * 0.01 * POWER_SPEED_UP_RATE
end
end
class Battle::Battler
def omnigrowth_count
@pokemon.omnigrowth_count
end
def omnigrowth_count_power_speed_up
@pokemon.omnigrowth_count_power_speed_up
end
def omnigrowth_count_defense_down
@pokemon.omnigrowth_count_defense_down
end
def update_omnigrowth_count(amount = 1)
@pokemon.update_omnigrowth_count(amount)
end
def omnigrowth_move_power_up(move_id)
@pokemon.omnigrowth_move_power_up(move_id)
end
def update_omnigrowth_move(move_id, amount = 1)
@pokemon.update_omnigrowth_move(move_id, amount)
end
end