Jump to content

Sleep dart sleepiness issues


hoxi
  • Pending

When hitting a creature with enough darts to match their sleep resistance (which causes them to fall asleep after X seconds, X being that resistance value), things work fine.

However, this falls apart when using one more dart before the creature falls asleep. This will cause them to sleep and wake up in the same frame, seamlessly, due to suggesting the attacker as a target and pushing a fake attack event to make them play a hit animation. This causes them to lose all sleepiness, which then causes them to wake up instantly when falling asleep due to the delayed sleep task from matching sleep resistance with the previous shot (why is this task not cancelled when successfully put to sleep?).

Another issue of something that got changed between Don't Starve and Don't Starve Together and is arguably buggy, is that hitting a sleeping target still pushes suggests the attacker as a target and pushes a fake attack event, causing the target to wake up and lose all sleepiness, instead of just resetting the sleep timer, which works fine with other sleepiness sources

 

Anyhow, in blowdarts.lua:

local function sleepattack(inst, attacker, target)
	if not target:IsValid() then
		--target killed or removed in combat damage phase
		return
	end

	if target.SoundEmitter ~= nil then
		target.SoundEmitter:PlaySound("dontstarve/wilson/blowdart_impact_sleep")
	end

	local knocked_out = false

	if target.components.sleeper ~= nil then
		target.components.sleeper:AddSleepiness(1, 15, inst)

		-- intentionally will also work on already asleep targets, otherwise they'll wake up
		knocked_out = target.components.sleeper:IsAsleep()
	elseif target.components.grogginess ~= nil then --and not target.components.grogginess:IsKnockedOut() then -- don't allow reapplication to already knocked out players?
		target.components.grogginess:AddGrogginess(1, 15)

		-- maybe keep it as usual for players?
		--knocked_out = target.components.grogginess:IsKnockedOut()
	end

	if not knocked_out then
		if target.components.combat ~= nil and not target:HasTag("player") then
			target.components.combat:SuggestTarget(attacker)
		end
		target:PushEvent("attacked", { attacker = attacker, damage = 0, weapon = inst })
	end
end

Also it would be nice if these sleepiness and sleep time values (1, 15) weren't hardcoded into the functions and were instead defined in TUNING.


Steps to Reproduce
  1. Shoot a hound with a sleep dart 3 times, then wait 3 seconds.
  2. Notice how the hound will fall asleep as intended.
  3. Now shoot it 4 times instead (if you're debugging, you should see its sleepiness go from 3 to 0 here, due to sleeping and waking up instantly), then wait 3 seconds.
  4. Notice how it will fall asleep and immediately wake up (due to not having sleepiness and being able to find targets).



User Feedback


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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...