Here's another funky spell I was stoked about when I realized how to get it work
Hold Monster
An earth magic spell.. currently level 5 with a mana cost of 30 and two runes - Earth(G) + Physicality(F).
The idea behind the spell is that the monster directly in front of the party is paralyzed unable to move, turn or attack for the duration of the spell (2 seconds per skill level). Like the Push Monster spell it can be used to get away from a dangerous opponent, or simply give the party a respite from attack.
The spell uses a number of monster hooks (onMove; onTurn and onAttack), so if you already use any of these hooks for other things, you will need to tweak the monster definitions.
Here are the parts:
spells.lua
Code: Select all
-- Hold Monster Spell
defineSpell{
name = "hold_monster",
uiName = "Hold Monster",
skill = "earth_magic",
level = 5,
runes = "FG",
manaCost = 30,
onCast = function(caster, x, y, direction, skill)
return hold_monster_spell_script.startHold(caster,x,y,direction,skill)
end,
}
monsters.lua
Code: Select all
local monstersList = {"crab","crowern","cube","goromorg","green_slime","herder","herder_big","herder_small","herder_swarm","ice_lizard","ogre","scavenger","scavenger_swarm","shrakk_torr","skeleton_archer","skeleton_archer_patrol","skeleton_patrol","skeleton_warrior","snail","spider","tentacles","uggardian","warden","wyvern"
}
for i=1,# monstersList do
cloneObject{
name = monstersList[i],
baseObject = monstersList[i],
onMove = function(monster)
return hold_monster_spell_script.checkHeld(monster)
end,
onTurn = function(monster)
return hold_monster_spell_script.checkHeld(monster)
end,
onAttack = function(monster)
return hold_monster_spell_script.checkHeld(monster)
end,
}
end
script entity called
hold_monster_spell_script
Code: Select all
held_monster = ""
function checkHeld(monster)
if monster.id == held_monster then
if findEntity("holding_fx") ~= nil then
holding_fx:destroy()
end
spawn("fx", monster.level, monster.x, monster.y, monster.facing,"holding_fx")
:setParticleSystem("death_dust")
return false
else
return true
end
end
function destroyTimer()
local h_timer = findEntity("hold_timer")
if h_timer ~= nil then
h_timer:destroy()
end
end
function isInTable(table, element)
for _,value in pairs(table) do
if value == element then
return true
end
end
return false
end
function whichMonster(level,eggs,why)
local allMonsters = {"crab", "crowern", "goromorg", "green_slime", "herder", "herder_big", "herder_small", "herder_swarm", "ice_lizard", "molt_slime", "ogre", "scavenger", "scavenger_swarm", "shrakk_torr", "skeleton_archer", "skeleton_archer_patrol", "skeleton_warrior", "snail", "spider", "uggardian", "warden", "wyvern"}
for i in entitiesAt(level,eggs,why) do
if isInTable(allMonsters,i.name) then
return i.id
end
end
return ""
end
function startHold(caster,x,y,direction,skill)
destroyTimer()
spawn("timer",party.level,party.x,party.y,party.facing,"hold_timer")
:setTimerInterval(2*skill)
:addConnector("activate","hold_monster_spell_script","stopHold")
:activate()
local dx,dy = getForward(party.facing)
held_monster = whichMonster(party.level,party.x+dx,party.y+dy)
spawn("fx", party.level, party.x+dx, party.y+dy, party.facing, "death_dust")
:setParticleSystem("death_dust")
end
function stopHold()
-- hudPrint("Stopping Hold")
held_monster = ""
destroyTimer()
end