Apollos
Dude who does stuff
[TFS 1.1]
Here's a party healing script I edited, it's working but I want to loop the addevent instead of calling it over and over. Seen some threads on how you have to loop a certain way, so how would you loop in this script.
Here's a party healing script I edited, it's working but I want to loop the addevent instead of calling it over and over. Seen some threads on how you have to loop a certain way, so how would you loop in this script.
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
local condition = createConditionObject(CONDITION_REGENERATION)
setConditionParam(condition, CONDITION_PARAM_SUBID, 1)
setConditionParam(condition, CONDITION_PARAM_BUFF_SPELL, 1)
setConditionParam(condition, CONDITION_PARAM_TICKS, 2 * 10 * 1000)
setConditionParam(condition, CONDITION_PARAM_HEALTHGAIN, 200)
setConditionParam(condition, CONDITION_PARAM_HEALTHTICKS, 2000)
local function sendEffect(cid, pid)
doSendMagicEffect(getCreaturePosition(pid), CONST_ME_BUBBLES)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BUBBLES)
end
local baseMana = 120
function onCastSpell(cid, var)
local pos = getCreaturePosition(cid)
local membersList = getPartyMembers(cid)
if(membersList == nil or type(membersList) ~= 'table' or #membersList <= 1) then
doPlayerSendCancel(cid, "No party members in range.")
doSendMagicEffect(pos, CONST_ME_POFF)
return false
end
local affectedList = {}
for _, pid in ipairs(membersList) do
if(getDistanceBetween(getCreaturePosition(pid), pos) <= 36) then
table.insert(affectedList, pid)
end
end
local tmp = #affectedList
if(tmp <= 1) then
doPlayerSendCancel(cid, "No party members in range.")
doSendMagicEffect(pos, CONST_ME_POFF)
return false
end
local mana = math.ceil((0.9 ^ (tmp - 1) * baseMana) * tmp)
if(getPlayerMana(cid) < mana) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHMANA)
doSendMagicEffect(pos, CONST_ME_POFF)
return false
end
if(doCombat(cid, combat, var) ~= true) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
doSendMagicEffect(pos, CONST_ME_POFF)
return false
end
doPlayerAddMana(cid, -(mana - baseMana), FALSE)
doPlayerAddManaSpent(cid, (mana - baseMana))
for _, pid in ipairs(affectedList) do
doAddCondition(pid, condition)
doAddCondition(cid, condition)
addEvent(sendEffect, 2000, cid.uid, pid)
addEvent(sendEffect, 4000, cid.uid, pid)
addEvent(sendEffect, 6000, cid.uid, pid)
addEvent(sendEffect, 8000, cid.uid, pid)
return true
end
end