<action itemid="2353" script="burning_heart.lua" />
local config = {
minHeal = 300,
maxHeal = 600,
exhaust = 1000, -- milliseconds
infiniteItem = true
}
local exhaustedCreatures = {}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local playerId = player:getId()
local currentTime = os.mtime()
-- check exhaust
if exhaustedCreatures[playerId] and exhaustedCreatures[playerId] > currentTime then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are exhausted.")
return true
end
-- add exhaust
exhaustedCreatures[playerId] = currentTime + config.exhaust
-- heal player
local healAmount = math.random(config.minHeal, config.maxHeal)
player:addHealth(healAmount)
-- remove item, if not infinite
if not config.infiniteItem then
item:remove(1)
end
return true
end
Need to edit items.xml to equip for arrow slotAnd so that they can be put on where arrow are given.
Hello. Super, everything works! Could you add a line when I click is effect CONST_ME_MAGIC_RED ?
local config = {
minHeal = 300,
maxHeal = 600,
exhaust = 1000, -- milliseconds
effect = CONST_ME_MAGIC_RED,
infiniteItem = true
}
local exhaustedCreatures = {}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local playerId = player:getId()
local currentTime = os.mtime()
-- check exhaust
if exhaustedCreatures[playerId] and exhaustedCreatures[playerId] > currentTime then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are exhausted.")
return true
end
-- add exhaust
exhaustedCreatures[playerId] = currentTime + config.exhaust
-- heal player
local healAmount = math.random(config.minHeal, config.maxHeal)
player:addHealth(healAmount)
player:getPosition():sendMagicEffect(config.effect)
-- remove item, if not infinite
if not config.infiniteItem then
item:remove(1)
end
return true
end
<item id="2353" article="a" name="burning heart">
<attribute key="description" value="<3" />
<attribute key="weight" value="400" />
<attribute key="weaponType" value="ammunition" />
<attribute key="ammoType" value="arrow" />
<attribute key="decayTo" value="0" />
<attribute key="duration" value="86400" />
items.xmlThank you the effect works
What exactly should I edit in movements.xml?
In Items.xml I edited like this:
<item id="2353" article="a" name="burning heart">
<attribute key="description" value="<3" />
<attribute key="slotType" value="ammo" />
<attribute key="weight" value="400" />