This has four parts, as we need to set up the entry hazard, the default for the effect, the move that causes it, and edit moves that wipe the field to account for Soft Pillow (but I won't be doing that part, too lazy). Searching all script sections (CTRL + SHIFT + F if you weren't aware) for Entry hazards, I found a comment in just the right spot in Battle_Action_Switching, which makes perfect sense, since you know, entry hazard. I'm going to copy the Sticky Web code, as it's the simplest.
From there, it's a matter of adjusting the conditions. It'll only trigger if SoftPillow is set up as an effect, so we change StickyWeb, and we need to add in the not flying or psychic check. I left in the airborne check, but you can remove it if it's not needed.
Instead of lowering speed, it puts to sleep. Using our Naptime code and the poison spikes above, we use
pbCanSleep?(nil,false)
because we don't want a failure message, and entry effects have no user. we also toss in a
pbRandom(100)<30
for that 30% chance. You'll see pbRandom all over the battle code.
Code:
# Soft Pillow
if battler.pbOwnSide.effects[PBEffects::SoftPillow] && !battler.fainted? &&
!(battler.pbHasType?(:FLYING) || battler.pbHasType?(:PSYCHIC)) && !battler.airborne?
pbDisplay(_INTL("{1} landed in a soft pillow!",battler.pbThis))
if pbRandom(100)<30 && battler.pbCanSleep?(nil,false)
battler.pbSleep(_INTL("{1} was tempted to sleep!",battler.pbThis))
end
end
Don't forget to set up Soft Pillow as an effect in PBEffects! Add it under the
These effects apply to a side
comment.
Now we set up the value for the effect. Searching for StickyWeb eventually leads us to
class PokeBattle_ActiveSide
. we can just tuck in
@effects[PBEffects::SoftPillow] = false
right in there with the rest.
Finally the move effect. Once again, we search for sticky web, this time with a space, since most function codes are labeled with their move names when they are unique. That leads us to
class PokeBattle_Move_153
. You can make a copy, give it a new function code and replace all references to sticky web with SoftPillow.
Then it's just a matter of searching for
[PBEffects::StickyWeb]
for all the spots it's used, as that will bring you to the moves that wipe the field clean. Just 2 moves, so you can edit Defog and Rapid Spin. It'll also point you to the AI, which is a simple, don't use this move if you already have an active sticky web. You should copy with the new function code and SoftPillow effect, so your trainers will know how to use it.