The custom spell (with impossible gesture) would certainly do it, but the nature of the effect is well suited to a being a character condition. As a condition, it can be easily applied to any champion, and effectively handles itself after that; it can also be detected (per champion). Since this is a potion, several PCs might be using them at the same time, whether deliberately or accidental. So the effect should take duplicates into account.
A condition automatically applies an effect icon to the champion's portrait for its duration, and has built in functions to place start, middle, and ending code for both the principle effect, and any cosmetic polishing to it.
Code: Select all
--Place this in one of the starting scripts; eg. spells.lua or other
defineCondition{
name = "nightvision",
uiName = "Nightvision",
description = "Temporarily enhances the ability to see in the dark.",
icon = 7, --[icon & iconAtlas can reference a custom image for the portrait-overlay]--
iconAtlas = "assets/textures/gui/conditions.tga", --
beneficial = true,
harmful = false,
tickInterval = .05,
onStart = function(self, champion)
if not party.nightsight then party:createComponent("Light", "nightsight")
party.nightsight:setOffset(vec(0,1.3,-1)) ---------------[Position of light source]--
party.nightsight:setType("spot")
party.nightsight:setSpotAngle(117)
party.nightsight:setSpotSharpness(0)
party.nightsight:setRange(9)
end
self:setDuration(60) -----------------------------------[Default duration of nighvision effect]--
playSound("spell_out_of_energy")
end,
onStop = function(self, champion)
--OPTIONAL message
hudPrint(champion:getName():capitalize().."\'s nightvision has expired")
--
local count = 0
for x = 1, 4 do
if party.party:getChampion(x):hasCondition("nightvision") then
count = count + 1
end
end
if count < 2 then party:removeComponent("nightsight") end
playSound("spell_expires")
end,
onTick = function(self, champion)
local count = 0
for x = 1, 4 do
if party.party:getChampion(x):hasCondition("nightvision") then
count = count + 1
end
end
if count < 2 then
if Config.getRenderingQuality()>1 then
if party.nightsight then
party.nightsight:setColor(vec(5,20,7)) --------------------------------[green tint]--
local jitter = math.abs(math.sin(self:getDuration()*.5)*2) ----[variable attenuation of the light]--
party.nightsight:setBrightness(jitter)
end
end
end
end,
}
defineObject{
name = "potion_nightvision",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Nightvision Potion",
gfxIndex = 146,
weight = 0.3,
stackable = true,
traits = { "potion" },
},
{
class = "UsableItem",
sound = "consume_potion",
onUseItem = function(self, champion)
champion:setCondition('nightvision')
end,
},
},
}