Jump to content

Recommended Posts

47 minutes ago, overmouse said:

 


		local ents = TheSim:FindEntities(pos.x, pos.y, pos.z, 3, nil, {"FX", "NOCLICK", "DECOR", "INLIMBO"})
		for k,v in pairs(ents) do 
			if v.components.burnable and not v.components.fueled and not v.components.burnable.lightningimmune then
				v.components.burnable:Ignite()
			end
		end

 

Small niggle, but since you're excluding entities with the tag "INLIMBO" you don't need to check if they're not in limbo.

Heya guys.

So i got hits from strike with this code:

function SeasonManager:DoImmutableLightningStrike(pos,target,inst)
	local inst=GetPlayer()
	local lightning = SpawnPrefab("lightning")
	pos = Vector3(target.Transform:GetWorldPosition())
	lightning.Transform:SetPosition(pos:Get())

	if target then
		if target.components.playerlightningtarget then
		    local mult = TUNING.ELECTRIC_WET_DAMAGE_MULT * inst.components.moisture:GetMoisturePercent()
            local damage = -(TUNING.LIGHTNING_DAMAGE + (mult * TUNING.LIGHTNING_DAMAGE))
            inst.components.health:DoDelta(damage, false, "lightning")
            inst.sg:GoToState("electrocute")
			target.components.playerlightningtarget:DoStrike()
		else
			target:PushEvent("lightningstrike", {rod=target})
		end
	else
		local ents = TheSim:FindEntities(pos.x, pos.y, pos.z, 3, nil, {"FX", "NOCLICK", "DECOR", "INLIMBO"})
		for k,v in pairs(ents) do 
			if not v:IsInLimbo() then
				if v.components.burnable and not v.components.fueled and not v.components.burnable.lightningimmune then
					v.components.burnable:Ignite()
				end
			end
		end
	end
end

 

But now i get strange bug:

When character wear SnakeSkin clothes (which should defend him from lightning strike in original DS) - he got hits for 10hp.

When not - hits make 20hp damage.

 

Where's logic mistake in my code? It should allways do the normal amount of damage...

 

@Arkathorn

mmm.. Not shure that i still understand this. You give me code, it contains

target.components.playerlightningtarget:DoStrike()

Then i push the button affected to 

SeasonManager:DoImmutableLightningStrike(pos,target,inst)

and it makes DoStrike, hitting to player, ignoring rods, but not SnakeSkin.

But why when i combine it with these

Quote

local inst=GetPlayer()
local mult = TUNING.ELECTRIC_WET_DAMAGE_MULT * inst.components.moisture:GetMoisturePercent()
local damage = -(TUNING.LIGHTNING_DAMAGE + (mult * TUNING.LIGHTNING_DAMAGE))
inst.components.health:DoDelta(damage, false, "lightning")
inst.sg:GoToState("electrocute")

- it makes additional hit trough SnakeSkin? I don't see here any calls Strike function? :/

@@Arkathorn

 

inst.components.health:DoDelta(damage, false, "lightning")

makes damage and spawning lightning prefab.

So now it looks like: 

function SeasonManager:DoImmutableLightningStrike(pos,target,inst)
	local damage = -10
	local inst=GetPlayer()
	local lightning = SpawnPrefab("lightning")
	local pos = Vector3(target.Transform:GetWorldPosition())
	lightning.Transform:SetPosition(pos:Get())
		if target then
			if target.components.playerlightningtarget then
			inst.components.health:DoDelta(damage, false, "lightning")
			else
			target:PushEvent("lightningstrike", {rod=target})
			end
		else
		local ents = TheSim:FindEntities(pos.x, pos.y, pos.z, 3, nil, {"FX", "NOCLICK", "DECOR", "INLIMBO"})
		for k,v in pairs(ents) do 
			if not v:IsInLimbo() then
				if v.components.burnable and not v.components.fueled and not v.components.burnable.lightningimmune then
					v.components.burnable:Ignite()
				end
			end
		end
	end
end

and all goin okay. Ignoring rods and make 10 damage from lighting, ignoring any snakeskin items on character

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