Update
- Added melf's acid arrow (strikes caster.level/3 times)
- added fw.repeatFunction(count,interval,callbackargs,callback,instant)
Thanks to Mebaru for the basic idea, I needed this for acid arrow so i implemented it. Enjoy
- fixed alcove:onInsertItem hook (there was an error in official documentation or bug in the LoG code, but alcove:onInsertItem must return true or else the alcove won't accept items)
- Custom projetile spells now give XP to caster!
@djoldgames: You can fix consumables by adding them to to consumable list
for example if you have consumable named rations put this code to the logfw_init.main function (or in some other function)
fw.lists.item.consumable['rations'] = true
Other way to fix it is to add a onUseItem-hook which returns true to your consumable. Consumables caused me some trouble because their hooks must return true by default but other item hooks must return nil, so I had to add a list of consumables to framework.lua so I could check if item is consumable in onUseItemHook (see framework.lua)
Here is the source for melf's acid arrow, It wasn't easy to implement
Code: Select all
-- MELF'S ACID ARROW ***
function melfs_acid_arrow(caster, x, y, direction, skill)
playSoundAt("fireball_launch",party.level,x,y)
-- pass the caster.id to hook
fw.setHookVars('monsters','eob_spells_acid_arrow','onProjectileHit',fw.getId(caster))
fw.addHooks('monsters','eob_spells_acid_arrow',{
onProjectileHit = function(monster,projectile,damage,damageType)
if projectile.name == 'acid_arrow' then
local caster = fw.getById(fw.getHookVars())
local callback = function(caster_id,target_id)
local target = fw.getById(target_id)
local caster = fw.getById(caster_id)
local originator = 2 ^ (caster:getOrdinal()+1)
local modifier = math.ceil(caster:getLevel()/2)
local damage = math.random(2,eob_spells.settings.melfs_acid_arrow.damage)
damageTile(target.level,target.x,target.y,(target.facing + 2)%4,originator+1, 'physical',8)
end
local attacks = math.ceil(caster:getLevel()/3)
fw.repeatFunction(attacks,1,{fw.getId(caster),fw.getId(monster)},callback,true)
-- remove hook for performance reasons
fw.removeHooks('monsters','eob_spells_acid_arrow')
return false
end
end
})
shootProjectile('acid_arrow', party.level, x, y, direction, 14, 0, 0, 0, 0, 0,
0, party, true)
end
Edit: damn, just noticed that there is upvalue (originator) in that callback function, I will fix it.
Edit2: upvalue fixed