Vendily

Overworld Fatigue

Jun 19th, 2019
139
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # 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.
  2. FATIGUESTHEALFRACTION     = 16 # 1/16 of total hp healed as a baseline.
  3. MAXFATIGUE                 = 100 # the maximum value of the fatigue, which also is used to make a percentage multiplier for the hp healed
  4. FATIGUETHRESHOLD           = 30 # 30 fatigue to have chance of sleeping
  5. FATIGUESLEEPCHANCE          = 4  # 1/4 chance of falling asleep
  6.  
  7. class PokeBattle_Pokemon
  8.   attr_accessor(:fatigue)
  9.  
  10.   def fatigue
  11.     @fatigue=0 if !@fatigue
  12.     return @fatigue
  13.   end
  14.  
  15.   alias __fatigue_heal heal
  16.   def heal
  17.     self.__fatigue_heal
  18.     @fatigue=0
  19.   end
  20. end
  21.  
  22. Events.onStepTaken+=proc {|sender,e|
  23.    next if !$Trainer
  24.    for pkmn in $Trainer.party
  25.      next if pkmn.egg?
  26.      pkmn.fatigue+=1
  27.      pkmn.fatigue=MAXFATIGUE if pkmn.fatigue>MAXFATIGUE
  28.      if pkmn.hp != pkmn.totalhp
  29.        pkmn.hp+=(pkmn.totalhp/FATIGUESTHEALFRACTION*(1-(pkmn.fatigue/MAXFATIGUE))).ceil
  30.        pkmn.hp=pkmn.totalhp if pkmn.hp>pkmn.totalhp
  31.      end
  32.      if pkmn.status==0 && pkmn.fatigue>FATIGUETHRESHOLD &&
  33.          rand(FATIGUESLEEPCHANCE)==0
  34.        if !(pkmn.hasAbility?(:VITALSPIRIT) || pkmn.hasAbility?(:INSOMNIA) ||
  35.             pkmn.hasAbility?(:SWEETVEIL) || (pkmn.hasAbility?(:FLOWERVEIL) && pkmn.hasType?(:GRASS)) ||
  36.             (pkmn.hasAbility?(:LEAFGUARD)&& $game_screen.weather_type==PBFieldWeather::Sun))
  37.           pkmn.status=PBStatuses::SLEEP
  38.           pkmn.statusCount=3
  39.        end
  40.      end
  41.    end
  42. }
RAW Paste Data