Kod:
local config =
{
level = 8, -- player level required for use wand
exhaustion = 1 * 1000, --exhaustion in milisecunds
}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, config.exhaustion)
function onUse(cid, item, fromPosition, itemEx, toPosition)
if (not isPlayer(itemEx.uid)) then
return true
end
if(isKnight(cid) == TRUE or isPaladin(cid)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You must be druid or sercerer to use this item.')
return true
end
if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You are exhausted.')
return true
end
local playerLevel = getPlayerLevel(cid)
if (playerLevel < config.level) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Your level is too low.')
return true
end
local playerMana = getPlayerMana(cid)
if (playerMana < manaForLevel(cid)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You don\'t have enough mana.')
return true
end
local playerMagic = getPlayerMagLevel(cid)
local healthTemplate = ((playerLevel * 0.2) * (playerMagic * 0.5))
local maxHealth = getCreatureMaxHealth(cid)
local actuallHealth = getCreatureHealth(cid)
local healthMargin = maxHealth - actuallHealth
if(healthMargin == 0) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You have max health points.')
return true
end
if (healthTemplate < 10) then
healthTemplate = 10
end
if (healthTemplate > healthMargin) then
healthTemplate = healthMargin
end
doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
doCreatureAddHealth(cid, healthTemplate)
doCreatureAddMana(cid, -manaForLevel(cid))
doCreatureSay(itemEx.uid, "[Health:"..healthTemplate.."][Mana:"..-manaForLevel(cid).."].", TALKTYPE_ORANGE_1)
doAddCondition(cid, exhaust)
return true
end
function manaForLevel(cid)
local level = getPlayerLevel(cid)
local magLevel = getPlayerMagLevel(cid)
if (level < 100) then
return level * 2 / 4
else
return level * 25 / magLevel
end
end
Kod:
<action itemid="7424" event="script" value="healthWand.lua"/>
Zakładki