Jump to content

Recommended Posts

13 hours ago, WORLDSBIGGEST said:

but I can't tell what I need to add or take out to remove the spark effects. 

Removing

SpawnPrefab("sparks").Transform:SetPosition(x, y, z)

removes the spark spawning.

You can do your own thing too:

local function DoMoistureDamage(inst)
	local moisturepercent = inst.components.moisture:GetMoisturePercent()
	local damage = Remap(moisturepercent, 0, 1, 0, 2)
	inst.components.health:DoDelta(-damage, true, "water", false, nil, true)
end

local function OnMoistureDelta(inst, data)
	local moisture = data.new
	if moisture > 0 then
		if not inst.moisturetask then
			inst.moisturetask = inst:DoPeriodicTask(1, DoMoistureDamage)
		end
	else
		if inst.moisturetask then
			inst.moisturetask:Cancel()
			inst.moisturetask = nil
		end
	end
end

local function RemoveMoistureVulnerable(inst)
	inst:RemoveEventCallback("moisturedelta", OnMoistureDelta)
	if inst.moisturetask then
		inst.moisturetask:Cancel()
		inst.moisturetask = nil
	end
end

local function MakeMoistureVulnerable(inst)
	inst:ListenForEvent("moisturedelta", OnMoistureDelta)
end

local function master_postinit(inst)
	inst:ListenForEvent("ms_respawnedfromghost", MakeMoistureVulnerable)
	inst:ListenForEvent("ms_becameghost", RemoveMoistureVulnerable)
	MakeMoistureVulnerable(inst)
end

This just takes moisture into account, unlike WX-78, that cares about the world raining and the waterproofness of your clothes.

14 minutes ago, WORLDSBIGGEST said:

character to take extra damage from bee stings, and take continuous damage similar to when a character is poisoned

local function PoisonTick(inst)
	if inst.poisonticks > 0 then
		inst.poisonticks = inst.poisonticks - 1
		inst.components.health:DoDelta(-1, true, "beepoison", false, nil, true)
		inst:DoTaskInTime(1, PoisonTick)
	end
end

local function EditCombat(inst)
	local self = inst.components.combat
	local _GetAttacked = self.GetAttacked
	self.GetAttacked = function(self, attacker, damage, weapon, stimuli)
		if attacker and attacker:HasTag("bee") and damage then
			-- Take extra damage
			damage = damage * 1.5
			-- Poison mechanic
			self.inst.poisonticks = 10
			self.inst:DoTaskInTime(1, PoisonTick)
		end
		return _GetAttacked(self, attacker, damage, weapon, stimuli)
	end
end

local function master_postinit(inst)
	EditCombat(inst)
end

You tune stuff within the function that runs when your character is attacked.

Hm, I tried both methods, but while the game ran normally my character didn't take damage. I added the spark prefab to test it and my character started sparking like wx78 does, but still no damage. 

I haven't tested the bee sting code yet though! Free time has been scarce lately woops

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