Fixed the properties system. Now, you can set a property dynamically and call it subsequently. An onPass hook can for example do:
Code: Select all
if exsp.sd[sId].customproperty == nil
exsp.sd[sId].customproperty = "Abracadabra"
end
I've also added sd[sId].distance, which returns the distance travelled by the spell since its launch (spinned spells keep on counting), and sd[sId].spell, which registers the original spell (for noLaunch purposes).
The following code, for example, creates a fireball which will split (launch side fireballs) every 3 squares. The spell power will also decrease by 3 each square. The splitted fireballs will split themselves again, until the power runs dry:
Code: Select all
exsp.cloneSpell('splitfireball',{
baseSpell = 'fireball'
}
)
exsp.addSpellHook('splitfireball',{
onPass = function(sId)
if exsp.sd[sId].power == nil then
exsp.sd[sId].power = 30
end
exsp.sd[sId].power = exsp.sd[sId].power - 3
if exsp.sd[sId].power < 1 then
exsp.spellDestroy(sId)
return false
end
if exsp.sd[sId].distance%3 == 0 then
local level, x, y = exsp.getPosition(sId)
exsp.spellCast('splitfireball', level, x, y, (exsp.sd[sId].facing-1)%4, exsp.sd[sId].power, exsp.sd[sId].ordinal)
exsp.spellCast('splitfireball', level, x, y, (exsp.sd[sId].facing+1)%4, exsp.sd[sId].power, exsp.sd[sId].ordinal)
end
end
}
)
Flatline, I've added esxp.allSpellsAt(level, x, y), which returns an iterator of all spells currently flying in a current square. Using exsp.sd[sId], you can then access their properties. All this works for spells though, not arrows. I'm not sure if projectiles can be detected in-flight.
All in all, I think the basic script structure is quite allright and bug-free now, I'll stop updating it 3 times a day and work on further hooks and functions for a while, then post a 1.3 update in a week or so. (And maybe continue my dungeon mod as well! )