Jump to content

Spitter spiders set no attack cooldown on starting a spit attack


hoxi
  • Pending

In SGspider, in the "spitter_attack" state:

onenter = function(inst, target)
	if inst.weapon and inst.components.inventory then
		inst.components.inventory:Equip(inst.weapon)
	end
	if inst.components.locomotor then
		inst.components.locomotor:StopMoving()
	end
	inst.components.combat:StartAttack() -- this is missing here
	inst.AnimState:PlayAnimation("spit")
	inst.sg.statemem.target = target
end

This causes the spitter spiders to instantly spit again as soon as their "taunt" state (the growl/roar, which is what "spitter_attack" exits into) ends or is interrupted by an attack, since a hit can interrupt the taunt state, but the hit state (also used by spider warriors and mutated spiders) can be interrupted by anything, including starting an attack, which will happen immediately due to no cooldown.

If it's deemed that they should be able to spit faster than they can melee, at the very least set it properly in some way so they don't instantly spit again a frame after they get hit, it just looks clunky and works weirdly.

Here's also another thing I thought could be looked into, given that it looks really weird and it affects all 3 spiders that don't care about being hit when it comes to attacking:

EventHandler("attacked", function(inst)
	if not inst.components.health:IsDead() then
		if inst:HasTag("spider_warrior") or inst:HasTag("spider_spitter") or inst:HasTag("spider_moon") then
			if not inst.sg:HasStateTag("attack") then -- don't interrupt attack or exit shield
				inst.sg:GoToState("hit") -- can still attack
			end
		elseif not inst.sg:HasStateTag("shield") then
			inst.sg:GoToState("hit_stunlock")  -- can't attack during hit reaction
		end
	end
end)

The if not inst.sg:HasStateTag("attack") then line could be changed to if not inst.sg:HasAnyStateTag("attack", "moving") then or maybe something a bit more intricate, but this would at least prevent those spiders from playing the hit animation while moving, which doesn't really stop them, and which will be interrupted next frame. This is especially noticeable when they're set on fire and hit while panicking.

This also won't change their behavior, it's mainly to fix visual issues.

An alternative is to put this inside the if not inst.sg:HasStateTag("attack") then block:

if (inst.components.burnable ~= nil and inst.components.burnable:IsBurning()) or inst.components.combat:GetCooldown() > 1 then
	inst.sg:GoToState("hit_stunlock") -- can't interrupt
else
	inst.sg:GoToState("hit") -- can interrupt
end

This would allow them to be stunned by hits only when they're burning or their attack cooldown is high enough to not be supposed to attack before exiting the hit stun state (rough 1 second check, you could potentially get a more precise number). This however would change their behavior slightly.


Steps to Reproduce
  1. Have a spitter spider attack you.
  2. Hit it as soon as the spit animation ends or at any point during the growl, or leave it alone.
  3. Notice how if hit, it will immediately start another spit attack. Or if left alone, it will start it as soon as it's done with the growl animation.
  4. Now get really close to it so it tries to do a melee attack.
  5. Notice how the time between attacks is longer after a melee attack.
  • Like 1



User Feedback




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...