IIRC TorchItemComponent makes the item use gfx indices 130 (not lit), 131 (lit, brightest), 132, 133, 134 (lit, dimmest), 135 (burnt out), and 104 (not lit, partly used). You can still use a custom atlas, so you can use custom icons for every step of the process, their indices are just locked at those values.
If you want to implement an effect like the light from Grimrock 1's Orb of Radiance, with the ability to use arbitrary color/range/etc, you might be interested in what I did
here for the Illumulet. It detects whether an item is worn, and if it is, disables the party's default light source and replaces it with a better one. When all such items are removed, the party's original light source is enabled again and the new one is disabled. Here is the relevant code:
Code: Select all
-- illumination has to be handled in party hook
defineObject{
name = "dm_necklace_illumulet",
baseObject = "base_dm_item",
components = {
{
class = "Model",
model = "mod_assets/dmcsb_pack/models/items/dm_amulet_illumulet.fbx",
},
{
class = "Item",
uiName = "Illumulet",
gfxAtlas = "mod_assets/dmcsb_pack/textures/gui/dm_icoatlas.tga",
gfxIndex = 24,
weight = 0.2,
impactSound = "dm_katana",
traits = { "necklace", "illumulet" },
onEquipItem = function(self, champion, slot)
if slot == ItemSlot.Necklace then
party.dm_illum:enable()
party.torch:disable()
end -- dm_illum's onUpdate takes care of disabling
end,
},
{
class = "Light",
brightness = 16,
color = vec(1,1,1),
range = 7,
castShadow = false,
offset = vec(-0.02926,0.055,-0.09462),
},
},
}
Code: Select all
defineObject{
name = "party",
baseObject = "party",
components = {
{ -- can't really modify torch's color, so duplicate it instead
-- luckily torch still updates when disabled, unlike regular
-- LightComponent onUpdate hooks.
-- Multiple illumulets do not stack (multiple torches, light
-- spells, etc. don't stack, so this is consistent).
class = "Light",
name = "dm_illum",
brightness = 0,
range = 11, -- a bit longer than torch (9)
castShadow = false,
enabled = false,
onUpdate = function(self)
for i=1,4 do
local necklace = party.party:getChampion(i):getItem(ItemSlot.Necklace)
if necklace and necklace:hasTrait("illumulet") then
local col = self.go.torch:getColor()
local brightness = self.go.torch:getBrightness()
local illumBrightness = 8*(math.noise(Time.currentTime())+1)
-- illumulet light is pure white. No stacking.
col[1] = col[1]*(brightness/8)+1
col[2] = col[2]*(brightness/8)+1
col[3] = col[3]*(brightness/8)+1
self:setColor(col)
if self.go.torch:getRange() == 9 then -- torch or light spell
self:setBrightness(math.max(brightness,illumBrightness))
self:setOffset(self.go.torch:getOffset())
else -- illumulet only
self:setBrightness(illumBrightness)
self:setOffset(vec(math.sin(Time.currentTime())*0.25,1.5,math.cos(Time.currentTime())*0.25-1))
end
self.go.torch:disable()
return
end
end
-- no illumulets worn, switch back to torch
self.go.torch:enable()
self:disable()
end,
},
},
}
It's easily adaptable to other items.