Hi!
I wrote an spells framework (EXSP) which is exactly for this purpose:
viewtopic.php?f=14&t=4459.
And test it in action here:
viewtopic.php?f=14&t=4860
The hooks are not placed on the monster, but on the spell.
The genreal purpose hook is onHit(self, level, x, y, hitType, [subType], [entity], [entity2], [entity3], [entity4]). When the spell hits something, you get the position, the hitType (monster, party, wall, door...), subType (alcove, button, lever...), and the entities if present. Entities 1-4 are for monster groups, which you get as individual monsters to do what you please.
Some proxy hooks are however provided for convenience which provide filtered results, such as onMonsterHit(self, monster, [monster2], [monster3], [monster4])
So, example hook would read:
Code: Select all
exsp:addSpellHooks("fireball",
{
onMonsterHit = function(self, monster)
if monster.name == "shrakk_torr" then
print("I just hit a Shrakk Torr, says the Fireball!")
end
end
})
More complete documentation here:
https://sites.google.com/site/exspwiki/home
I'll just clean up some inefficient/redundant code I found out while making the Lite version (you need the full to use the hooks) and post an update later today.