Sportacus
Intermediate OT User
- Joined
- Aug 3, 2008
- Messages
- 718
- Reaction score
- 104
I have a spell, that when cast, it does an area affect buff, that increases the everyone in the partys magic level by 1.
The spell so far works for only party members, but it ignores the area of effect, and buffs all members of the party, regardless of where they are at.
I need the spell to work only in the area (5x5), and of course, for it to work on party members only.
here is the script.
The spell so far works for only party members, but it ignores the area of effect, and buffs all members of the party, regardless of where they are at.
I need the spell to work only in the area (5x5), and of course, for it to work on party members only.
here is the script.
Code:
local combat = createCombatObject()
local area = createCombatArea(AREA_CROSS5X5)
setCombatArea(combat, area)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_SUBID, 3)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setConditionParam(condition, CONDITION_PARAM_TICKS, 2 * 60 * 1000)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 1)
local config = {
baseMana = 120,
hardcoreManaSpent = getConfigValue("addManaSpentInPvPZone")
}
function onCastSpell(cid, var)
local pos, membersList = getCreaturePosition(cid), getPartyMembers(cid)
if(membersList == nil or type(membersList) ~= 'table' or table.maxn(membersList) <= 1) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOPARTYMEMBERSINRANGE)
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 = table.maxn(affectedList)
if(tmp <= 1) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOPARTYMEMBERSINRANGE)
doSendMagicEffect(pos, CONST_ME_POFF)
return false
end
local mana = math.ceil((0.9 ^ (tmp - 1) * config.baseMana) * tmp)
if(getCreatureMana(cid) < mana) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHMANA)
doSendMagicEffect(pos, CONST_ME_POFF)
return false
end
if(not doCombat(cid, combat, var)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
doSendMagicEffect(pos, CONST_ME_POFF)
return false
end
doCreatureAddMana(cid, -(mana - config.baseMana), false)
if(not getPlayerFlagValue(cid, PlayerFlag_NotGainMana) and (not getTileInfo(getThingPosition(cid)).hardcore or config.hardcoreManaSpent)) then
doPlayerAddSpentMana(cid, (mana - config.baseMana))
end
for _, pid in ipairs(affectedList) do
doAddCondition(pid, condition)
end
return true
end