This causes entities that were forcefully put to sleep through magic or so to wake up instantly. The game normally only checks for deep sleep for retargeting, to avoid this specifically from happening, so why is it not checked for target suggestion?
function Combat:SuggestTarget(target) if self.target == nil and target ~= nil then -- verify if we're even supposed to be able to receive a target if self.inst.components.sleeper ~= nil and self.inst.components.sleeper:IsInDeepSleep() then return end --print("Combat:SuggestTarget", self.inst, target) self:SetTarget(target) return true end end
The only issue this would cause (leaving aside the changed behavior) is that treeguards specifically will not properly wake up and aggro, but that can be fixed too!
local function WakeUpLeif(inst, doer) -- verify we're still asleep if inst.components.sleeper ~= nil and inst.components.sleeper:IsAsleep() then inst.components.sleeper:WakeUp() end -- suggest target now if everything's valid if doer ~= nil and doer:IsValid() and inst.components.combat ~= nil then inst.components.combat:SuggestTarget(doer) end end -- in both evergreens.lua (in chop_tree function) and leif_idol.lua (in WakeUpNearbyLeifs function) local ents = TheSim:FindEntities(x, y, z, TUNING.LEIF_REAWAKEN_RADIUS, LEIF_TAGS) for i, v in ipairs(ents) do -- asleep, suggest target after waking up if v.components.sleeper ~= nil and v.components.sleeper:IsAsleep() then -- optional deep sleep check, could be a thing for chopping, but not for burning an idol, just a suggestion if not v.components.sleeper:IsInDeepSleep() then v:DoTaskInTime(math.random(), WakeUpLeif, doer) end elseif doer ~= nil then -- not asleep, suggest target immediately as usual v.components.combat:SuggestTarget(doer) end end
Note: some leader-like entities can wake up others through some more direct means, like Bee Queen and the Eye of Terror/Twins, and others gain sleep resistance (like Klaus' deers), and this won't affect that behavior.
- Put a hound (or any entity that can suggest targets to nearby friendlies when attacked, like bees, beefalos, etc, or when attacking, like bunnymen) to sleep with a panflute or mushrooms spores, or so.
- Attack a nearby friendly of the creature now in deep sleep.
- Observe how they'll wake up immediately due to gaining a new target, despite supposedly being forced to sleep for a set amount of time.
This won't work on bats, they.. have their own issue when sleeping and getting attacked or so. I haven't checked them yet but I guess it might be a mix of needing to meet teamattacker conditions and/or lacking a listener to wake up when attacked (pengulls do wake up, but may not retaliate due to teamattacker conditions).
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now