Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion Items/dormantFungus.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
local sprite = Resources.sprite_load(NAMESPACE, "DormantFungus", path.combine(PATH, "Sprites/Items/dormantFungus.png"), 1, 18, 18)
local sprite_footstep = Resources.sprite_load(NAMESPACE, "DormantFungusFootstep", path.combine(PATH, "Sprites/Items/Effects/dungus.png"), 24, 14, 24)
local sound = Resources.sfx_load(NAMESPACE, "DormantFungus", path.combine(PATH, "Sounds/Items/dormantFungus.ogg"))

local dormantFungus = Item.new(NAMESPACE, "dormantFungus")
dormantFungus:set_sprite(sprite)
dormantFungus:set_tier(Item.TIER.common)
dormantFungus:set_loot_tags(Item.LOOT_TAG.category_healing)

dormantFungus:clear_callbacks()

local parDungus = Particle.new(NAMESPACE, "parDungus")
parDungus:set_sprite(sprite_footstep, true, true, false)
parDungus:set_life(96, 96)
parDungus:set_alpha3(1, 1, 0)

local dungusShroomSync = Packet.new()
dungusShroomSync:onReceived(function(msg)
local actor = msg:read_instance()

if not actor:exists() then return end

-- copied and pasted from uranium horseshoe basically
parDungus:create(actor.x, actor.bbox_bottom + 1, 1)
end)

local function sync_dungus(actor)
if not gm._mod_net_isHost() then
log.warning("sync_dungus called on client!")
return
end

local msg = dungusShroomSync:message_begin()
msg:write_instance(actor)
msg:send_to_all()
end

dormantFungus:onPostStep(function(actor, stack)
if gm._mod_net_isClient() then return end

Expand All @@ -22,6 +49,15 @@ dormantFungus:onPostStep(function(actor, stack)
local regen = math.ceil(actor.maxhp * (1 - 1 / (0.02 * stack + 1)))
actor:heal(regen)
gm.sound_play_networked(sound, 1, (0.9 + math.random() * 0.2), actor.x, actor.y)

-- copied and pasted from uranium horseshoe basically
if Helper.is_false(actor.free) then
parDungus:create(actor.x, actor.bbox_bottom + 1, 1)

if gm._mod_net_isOnline() then
sync_dungus(actor) -- particles arent synced by default so we have to use a packet for that
end
end
else
actor_data.dungusTimer = actor_data.dungusTimer - 1
end
Expand Down
Binary file added Sprites/Items/Effects/dungus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading