I have this spell, that is a summon bomb and it works perfectly. However, when I put sprites bigger than 32x32, I need to put offset (x,y) for the effect to appear where I want, but when I do this, the effect is appearing on the caster, instead of appearing where the summon died. What am I doing wrong?
spell.lua:
creaturescript.lua:
spell.lua:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setArea(createCombatArea(AREA_SQUARE1X1))
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_BLOCKSHIELD, true)
function onGetFormulaValues(player, skill, attack, skill, factor)
local maxHealth = player:getMaxHealth()
local maxMana = player:getMaxMana()
local playlvl = player:getLevel()
local min = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 0,55
local max = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 1,1
return -min, -max
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(cid, var)
local player = Player(cid)
if player == nil then
return false
end
local playerPos = player:getPosition()
if #player:getSummons() >= 2 then
player:sendCancelMessage("You cannot summon more creatures.")
playerPos:sendMagicEffect(CONST_ME_POFF)
return false
end
local creatureId = doSummonCreature("Barrelbomb", playerPos)
if creatureId == false then
player:sendCancelMessage(RET_NOTENOUGHROOM)
playerPos:sendMagicEffect(CONST_ME_POFF)
return false
end
local monster = Monster(creatureId)
monster:setMaster(player)
monster:registerEvent("barrelbomb")
addEvent(function(cid)
local creature = Creature(cid)
if creature ~= nil then
local player = creature:getMaster()
if player then
combat:execute(player, numberToVariant(cid))
else
combat:execute(creature, numberToVariant(cid))
end
local creaturePos = creature:getPosition()
creaturePos.x = creaturePos.x +1
creaturePos.y = creaturePos.y +1
creaturePos:sendMagicEffect(122)
creature:remove()
end
end, 5000, creatureId)
monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
playerPos:sendMagicEffect(CONST_ME_MAGIC_BLUE)
return true
end
creaturescript.lua:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setArea(createCombatArea(AREA_SQUARE1X1))
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_BLOCKSHIELD, true)
function onGetFormulaValues(player, skill, attack, skill, factor)
local maxHealth = player:getMaxHealth()
local maxMana = player:getMaxMana()
local playlvl = player:getLevel()
local min = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 0,55
local max = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 1,1
return -min, -max
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onDeath(creature, variant, cid, ...)
local creature = Creature(cid)
local master = creature:getMaster()
if master then
combat:execute(master, numberToVariant(cid))
else
combat:setFormula(COMBAT_FORMULA_DAMAGE, -10, 0, -20, 0)
local creaturePos = creature:getPosition()
creaturePos.x = creaturePos.x +1
creaturePos.y = creaturePos.y +1
creaturePos:sendMagicEffect(122)
combat:execute(creature, numberToVariant(cid))
end
return true
end