![Question :?:](./images/smilies/icon_question.gif)
Is their away to script a magic dead zone where no champion can cast a spell? Just a point in the right direction would be good so I can learn more.
thanks
Delak
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onCastSpell = function(self, champion, spellName)
if party.level = 1 and party.x > 3 and party.x < 8 and party.y > 3 and party.y < 8 then
hudPrint("Your magic fails to work here...");
return false;
end
return true;
end,
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onCastSpell = function(self, champion, spellName)
if party.level == 1 and party.x > 3 and party.x < 8 and party.y > 3 and party.y < 8 then
hudPrint("Your magic fails to work here...");
return false;
end
return true;
end,
}
Code: Select all
-- Add the onCastSpell hook and have it run a script called antimagic inside a Lua script entity called checkAntiMagic
cloneObject{
name = "party",
baseObject = "party",
onCastSpell = function(self, spell)
local returnValue = checkAntiMagic.antimagic()
return returnValue
end,
}
-- Make a custom object that denotes the location of the anti-magic zone: you can use anything, but I used an invisible pressure plate
cloneObject{
name = "antimagic_zone",
baseObject = "pressure_plate_hidden",
}
Code: Select all
function antimagic()
-- Set here the number of levels you want to check for the presence of antimagic_zone objects
local LevelAmount = 5
local returnValue = true
for l=1,LevelAmount do
for i in allEntities(l) do
if i.name == "antimagic_zone" then
if party.x == i.x and party.y == i.y and party.level == i.level then
returnValue = false
hudPrint ("Your spell fizzles! You are standing on an anti-magic zone!")
break
end
end
end
end
return returnValue
Code: Select all
function antimagic(caster,spell)
for i in entitiesAt(party.level,party.x,party.y) do
-- hudPrint(i.name .. " with id = " .. i.id)
if i.name == "antimagic_zone"
then
hudPrint(caster:getName() .. "'s spell fizzles! You are standing on an anti-magic zone!")
return false
end
end
return true
end