Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Pokemon fall asleep after a battle if and only if they are not at full health and they do not already have a status, as well as a bit of a random chance. The trainer has to walk a bit before the pokemon might fall asleep. I have the rates set way too high. Pokemon have a chance to wake up when their hp is full. 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.
- OVERWORLDRESTSTEPTHRESHOLD = 30 # 30 steps to have chance of sleeping
- OVERWORLDRESTSLEEPCHANCE = 4 # 1/4 chance of falling asleep
- OVERWORLDRESTWAKECHANCE = 4 # 1/4 chance of staying asleep at full health
- OVERWORLDRESTHEALFRACTION = 16 # 1/16 of total hp healed
- class PokeBattle_Pokemon
- attr_accessor(:overworldreststeps)
- def overworldreststeps
- @overworldreststeps=0 if !@overworldreststeps
- return @overworldreststeps
- end
- end
- Events.onEndBattle+=proc {|sender,e|
- decision = e[0]
- canlose = e[1]
- for pkmn in $Trainer.party
- pkmn.overworldreststeps=0
- end
- }
- Events.onStepTaken+=proc {|sender,e|
- next if !$Trainer
- for pkmn in $Trainer.party
- pkmn.overworldreststeps+=1
- if pkmn.status==0 && pkmn.hp!=pkmn.totalhp &&
- pkmn.overworldreststeps>OVERWORLDRESTSTEPTHRESHOLD &&
- rand(OVERWORLDRESTSLEEPCHANCE)==0
- pkmn.status=PBStatuses::SLEEP
- pkmn.statusCount=3
- end
- if pkmn.status==PBStatuses::SLEEP
- pkmn.hp+=(pkmn.totalhp/OVERWORLDRESTHEALFRACTION).floor
- pkmn.hp=pkmn.totalhp if pkmn.hp>pkmn.totalhp
- if pkmn.hp==pkmn.totalhp
- pkmn.healStatus if rand(OVERWORLDRESTWAKECHANCE)==0
- end
- end
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement