Jump to content

Crab King yellow gems targeting the whole boat


mr. brj
  • Pending

If there is a total worth of 4 or 5 yellow gems socketed into the Crab King (for example 1 pearl + 1 or 2 yellow gems), the geyser attack targets the whole boat even if only a small fraction of the boat is touching the geyser attack's bubbles.


Steps to Reproduce

1) Start the Crab King fight using 4-5 yellow gems or using 1-2 yellow gems+pearl

2) Don't completely dodge the geyser attack

3) Watch your boat/raft get wrecked

  • Sad Dupe 1



User Feedback


A second "crabking_geyserspawner" entity is spawning just before the initial spell ends (and these spawn on top of boats, which is usual behavior when a spell cast starts), and when the spell cast actually ends, both of those spawners go off and fire the geysers.

After testing and logging some things, this is what seems to be happening, going from standard behavior up until the problem:

  • Crab King enters the "cast_loop" state.
  • If "casting_timer" timer doesn't exist for Crab King, start a spell cast and start a timer. This can be a geysers or freezing timer.
  • Crab King proceeds to loop in this state. Whenever the "loop" animation ends, an "animdone" event fires, causing him to exit the state and reenter it again. Outside of external means (like being frozen). He will only stop looping and proceed to the "cast_pst" state once the "casting_timer" timer expires. Through a "timerdone" event.
  • Here's the problem. These events are buffered, and then fired sequentially in the order they were buffered. Both the animation and timer can be done when the state is updated, so "animover" is fired first (likely due to animations being engine-sided so they come before lua updates). This results in reentering the state, checking that the cast timer doesn't exist (as the event is yet to be pushed), and causes another spell to start. Then immediately after, "timerdone" is fired, both the initial and new geysers go off, and Crab King exits into "cast_pst".

A simple way to prevent the issue from happening without altering much would be to do the following with the event handler:

EventHandler("animover", function(inst)
	if not inst.components.timer:TimerExists("casting_timer") then
		-- alternatively, to avoid copying the same code in two different places
		-- do nothing here, as the other event should fire immediately after
		inst.sg:ClearBufferedEvents()
		inst.sg:GoToState("cast_pst", inst.isfreezecast)
	else
		inst.sg.statemem.keepcast = true
		inst.sg:GoToState("cast_loop")
	end
end)

-- alternatively could add an extra check to "cast_loop" besides the timer check, something set from the startcastspell function
-- the solution above might be more cleaner overall and result in 1 state change instead of 2

Edit: I think inst.sg:ClearBufferedEvents() might not be needed there because of going to a different state?

 

Here's the basic logging I used using the server announcer to see it in real time, with the fix above:

[00:02:19]: [Announcement] Entering cast_pre state.
[00:02:19]: [Announcement] Exiting cast_pre state.
[00:02:19]: [Announcement] Starting spell cast. Is freeze: false
[00:02:25]: [Announcement] 'animover' called, and 'casting_timer' was also done, clearing events buffer and going into cast_pst.
[00:02:25]: [Announcement] Exiting cast_loop state and ending spell.
[00:02:25]: [Announcement] Entering cast_pst state.
[00:02:26]: [Announcement] Exiting cast_pst state.

The fact that this can happen does mean that anything that uses "animdone" and "timerdone" can technically cause this without proper checks, so keep that in mind.

 

While I'm at it, I noticed an oversight in said state:

onexit = function(inst)
	if not inst.sg.statemem.keepcast then
		local isfreezecast = inst.is_freezecast

		inst:DoTaskInTime(0,function()
			inst.endcastspell(inst, isfreezecast) -- can't use inst.is_freezecast here, as it will always be nil
		end)

		inst.SoundEmitter:KillSound("crabmagic")
		inst.isfreezecast = nil
	end
end

So some code can never be executed in endcastspell.

Edited by hoxi
Formatting and updating some info
  • Big Ups 1

Share this comment


Link to comment
Share on other sites



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