Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Pokemon become fatigued over time, and this reduces their natural ability to heal over time while you walk. Overly fatigued pokemon have a chance of falling asleep outright. Fatigue is only cured with a heal at the Pokecenter, or a Sacred Ash. Really anywhere the heal method is specifically called. Credit to Riviera for the idea, and I'll probably edit this with the proper styled header once I have their approval for the implementation.
- FATIGUESTHEALFRACTION = 16 # 1/16 of total hp healed as a baseline.
- MAXFATIGUE = 100 # the maximum value of the fatigue, which also is used to make a percentage multiplier for the hp healed
- FATIGUETHRESHOLD = 30 # 30 fatigue to have chance of sleeping
- FATIGUESLEEPCHANCE = 4 # 1/4 chance of falling asleep
- class PokeBattle_Pokemon
- attr_accessor(:fatigue)
- def fatigue
- @fatigue=0 if !@fatigue
- return @fatigue
- end
- alias __fatigue_heal heal
- def heal
- self.__fatigue_heal
- @fatigue=0
- end
- end
- Events.onStepTaken+=proc {|sender,e|
- next if !$Trainer
- for pkmn in $Trainer.party
- next if pkmn.egg?
- pkmn.fatigue+=1
- pkmn.fatigue=MAXFATIGUE if pkmn.fatigue>MAXFATIGUE
- if pkmn.hp != pkmn.totalhp
- pkmn.hp+=(pkmn.totalhp/FATIGUESTHEALFRACTION*(1-(pkmn.fatigue/MAXFATIGUE))).ceil
- pkmn.hp=pkmn.totalhp if pkmn.hp>pkmn.totalhp
- end
- if pkmn.status==0 && pkmn.fatigue>FATIGUETHRESHOLD &&
- rand(FATIGUESLEEPCHANCE)==0
- if !(pkmn.hasAbility?(:VITALSPIRIT) || pkmn.hasAbility?(:INSOMNIA) ||
- pkmn.hasAbility?(:SWEETVEIL) || (pkmn.hasAbility?(:FLOWERVEIL) && pkmn.hasType?(:GRASS)) ||
- (pkmn.hasAbility?(:LEAFGUARD)&& $game_screen.weather_type==PBFieldWeather::Sun))
- pkmn.status=PBStatuses::SLEEP
- pkmn.statusCount=3
- end
- end
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement