local combat = Combat()
local config ={
bossName = "Demon" -- Boss name here
}
function onCastSpell(creature, variant)
local spectators = Game.getSpectators(creature:getPosition(), false, false, 7, 7, 7, 7) -- (7,7,7,7) is how many tiles away it will detect creatures.
if #spectators > 0 then
for i = 1, #spectators do
if spectators[i]:getName() == config.bossName then
local boss = spectators[i]
local bossMaxHp = boss:getMaxHealth()
creature:getPosition():sendDistanceEffect(boss:getPosition(), CONST_ANI_SMALLHOLY)
boss:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)...
local config = {
level = 70,
magicLevel = 40,
targetName = "Specific Boss Name"
}
local combat = Combat()
combat:setParameter(COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
combat:setArea(createCombatArea(AREA_CIRCLE6X6))
function onTargetCreature(creature, target)
if target:isPlayer() then
return false
end
if target:getName() == config.targetName then
local min = (config.level / 5) + (config.magicLevel * 4.6) + 30
local max = (config.level / 5) + (config.magicLevel * 9.6) + 125
doTargetCombatHealth(creature, target, COMBAT_HEALING, min, max, CONST_ME_MAGIC_BLUE)
creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
return true
end
combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
function onCastSpell(creature, variant)
return combat:execute(creature, variant)
end
It didn't work for me, don't know why.local config = { level = 70, magicLevel = 40, targetName = "Specific Boss Name" } local combat = Combat() combat:setParameter(COMBAT_PARAM_DISPEL, CONDITION_PARALYZE) combat:setArea(createCombatArea(AREA_CIRCLE6X6)) function onTargetCreature(creature, target) if target:isPlayer() then return false end if target:getName() == config.targetName then local min = (config.level / 5) + (config.magicLevel * 4.6) + 30 local max = (config.level / 5) + (config.magicLevel * 9.6) + 125 doTargetCombatHealth(creature, target, COMBAT_HEALING, min, max, CONST_ME_MAGIC_BLUE) creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) end return true end combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature") function onCastSpell(creature, variant) return combat:execute(creature, variant) end
<instant name="bosshealer" words="###161" aggressive="1" needtarget="1" blockwalls="1" needlearn="1" script="monster/bosshealer.lua" />
<attack name="bosshealer" interval="1000" chance="90" target="0" min="300" max="500">
<attribute key="areaEffect" value="redspark" />
</attack>
Not entirely sure why it wouldn't work. It might be that you have written target, max and min values + attributes. I don't think you should have that. This is how I have it setup:It didn't work for me, don't know why.
Spells.xml
Monster.xml
No errors on TFS
<attack name="bosshealer" interval="2000" chance="100" />
<instant name="bosshealer" words="###60" aggressive="1" blockwalls="1" needtarget="0" needlearn="1" script="monster/bosshealer.lua" />
I've tried like this and the same resullt, no errors on TFS, but no healing done.Not entirely sure why it wouldn't work. It might be that you have written target, max and min values + attributes. I don't think you should have that. This is how I have it setup:
XML:<attack name="bosshealer" interval="2000" chance="100" />
XML:<instant name="bosshealer" words="###60" aggressive="1" blockwalls="1" needtarget="0" needlearn="1" script="monster/bosshealer.lua" />
local combat = Combat()
local config ={
bossName = "Demon" -- Boss name here
}
function onCastSpell(creature, variant)
local spectators = Game.getSpectators(creature:getPosition(), false, false, 7, 7, 7, 7) -- (7,7,7,7) is how many tiles away it will detect creatures.
if #spectators > 0 then
for i = 1, #spectators do
if spectators[i]:getName() == config.bossName then
local boss = spectators[i]
local bossMaxHp = boss:getMaxHealth()
creature:getPosition():sendDistanceEffect(boss:getPosition(), CONST_ANI_SMALLHOLY)
boss:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
local minHeal = bossMaxHp * 0.02
local maxHeal = bossMaxHp * 0.05
addEvent(doTargetCombatHealth, 0, creature:getId(), boss:getId(), COMBAT_HOLYDAMAGE, minHeal, maxHeal, CONST_ME_HOLYAREA)
break
end
end
end
return true
end
I've tried like this and the same resullt, no errors on TFS, but no healing done.
local config = {
level = 70,
magicLevel = 40,
targetName = "Specific Boss Name"
}
local combat = Combat()
combat:setParameter(COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
combat:setArea(createCombatArea(AREA_CIRCLE6X6))
function onTargetCreature(creature, target)
if target:isPlayer() then
return false
end
if target:getName() == config.targetName then
local min = (config.level / 5) + (config.magicLevel * 4.6) + 30
local max = (config.level / 5) + (config.magicLevel * 9.6) + 125
doTargetCombatHealth(creature, target, COMBAT_HEALING, min, max, CONST_ME_MAGIC_BLUE)
creature:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_SMALLHOLY) -- Add this to see that it works
creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
return true
end
combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
function onCastSpell(creature, variant)
return combat:execute(creature, variant)
end