Jump to content

Recommended Posts

While the addition of the NOBLOCK tag for some shadowy entities that rely on sanity is a really welcome change that I feel it's been overdue, shadow creatures, and a few other entities, like Gestalts, can still get in the way of blocking your mouse and from doing certain actions (controllers are unaffected as far as I'm aware due to the nature of the controls, but please correct me if I'm wrong).

 

This can be annoying in cases of entities not visible to a player due to high sanity/low enlightenment, but also for cases of having shadow dominance or gestalt protection (Bone Helmet, Enlightened Crown, etc), which make some creatures passive until you force attack.

 

It would be possible to prevent them from doing so by giving them a CanMouseThrough function, similar to a few other entities, accounting for being able to do anything at all when hovering over them, like force attacking pacified shadow creatures (you can prevent Woodie from considering shadow creatures as a target for a moose charge with this, unless force attacking), capturing a Gestalt or Greater Gestalt with the Phasmo-Encapsulator, etc.

 

Here's an example of the function I've been using for a while for Shadow creatures and Nightmare creatures (from ruins) specifically, based on what Klei did with farm soil and mini signs, I haven't really encountered any issues yet:

local function IsLowPriorityAction(act, force_attack, is_hostile)
	return act == nil or not is_hostile and not force_attack
end

-- suggestion: if a position was passed through CanMouseThrough, if possible, you could avoid having to do a inst:GetPosition() call
local function CanMouseThrough(inst)
	-- needed?
	--if TheInput:ControllerAttached() then
	--	return false, false
	--end

	local player = ThePlayer

	if player ~= nil and player.components.playeractionpicker ~= nil then
		-- cache CONTROL_FORCE_ATTACK maybe?
		local force_attack = player.components.playercontroller ~= nil and player.components.playercontroller:IsControlPressed(CONTROL_FORCE_ATTACK)
		local hostile = inst.HostileToPlayerTest ~= nil and inst:HostileToPlayerTest(player)
		local lmb, rmb = player.components.playeractionpicker:DoGetMouseActions(inst:GetPosition(), inst)
		return IsLowPriorityAction(rmb, force_attack, hostile)
			and IsLowPriorityAction(lmb, force_attack, hostile), not hostile -- mousethrough if the action isn't important, keepnone only if not hostile
	end

	return true, true -- mousethrough, keepnone
end

 

For cases like Shadow Leeches, Shadow Hands, or newer potential cases, the hostile line can just simply check with a function like this since being insane is the only requirement to attack them:

local function is_crazy_hostile_fn(inst, player)
	local sanity = player.replica.sanity
	if sanity ~= nil and sanity:IsCrazy() then
		return true
	end
	return false
end

 

For Gestalts, Greater Gestalts, and the new Greaterer Gestalts in the beta, it's a bit more complicated because there's an issue with transparency with them in the first place, reported here.

But regardless of those issues being fixed or not, simply checking for the same conditions (plus checking for the new Phasmo-Encapsulator action), would be enough to also make Gestalts not get in the way of the cursor either:

local function CanMouseThrough(inst)
	-- TODO needs to account for phasmo-encapsulator action

	if TheWorld.ismastersim then
		if inst.components.inspectable ~= nil then
			return false, false
		end
	elseif inst:HasTag("inspectable") then
		return false, false
	end

	return true, true
end

 

And that's about it!

It's nothing huge, but I know it's something some people would appreciate. I've seen some complaints here and there about this stuff getting in the way, and it got in the way for myself so I looked into it a while back. Given that this beta has a lot of quality of life stuff, and some shadowy creatures got the NOBLOCK tag, I thought it'd be a good time to suggest this too!

Edited by hoxi
Typo fixes, forgot to include a function oops
  • Like 6

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