Ok I found how to use delayCall properly :
the function goes into a script entity named script_center
Code: Select all
function rockFall(x, y, direction, elevation)
spawn("rock_fall_spell",party.level,x-0.3+0.6*math.random(),y-0.3+0.6*math.random(),direction,elevation)
end
the object definition for the falling rock (multiple impacts sounds are a little annoying, what would you suggest for the sound?)
Code: Select all
defineObject{
name = "rock_fall_spell",
baseObject = "base_spell",
components = {
{
class = "Model",
model = "assets/models/items/rock.fbx",
rotation = vec(0, 0, 0),
},
{
class = "Projectile",
spawnOffsetY = 3,
velocity = 0,
gravity = 10,
radius = 0.1,
onProjectileHit = function(self, what, entity)
local damage = 5
if entity == party then
-- hudPrint("Hit the party!")
local i = math.random(1,4)
local champ = party.party:getChampionByOrdinal(i)
champ:playDamageSound()
champ:damage(rollDamage(damage), "physical")
elseif entity == nil then
--playSound("impact_generic")
elseif entity.monster ~= nil then
-- hudPrint("Hit monster")
damageTile(entity.level, entity.x, entity.y, 0, entity.elevation, DamageFlags.Impact, "physical", rollDamage(damage))
else
--playSound("impact_generic")
end
--self.go:spawn("rock")
end
},
},
}
and the spell definition :
Code: Select all
defineSpell{
name = "test",
uiName = "Test",
skill = "concentration",
requirements = {"concentration", 1},
gesture = 2,
manaCost = 0,
icon = 72,
spellIcon = 13,
description = "Throws something",
onCast = function(champion, x, y, direction, elevation, skillLevel)
if direction == 0 then y = y-1 else if direction == 1 then x = x+1 else if direction == 2 then y = y+1 else x = x-1 end end end
playSound("serpent_staff_launch")
local power = champion:getCurrentStat("willpower")*skillLevel/5
for i = 0, power, 1 do
delayedCall("script_center", 3*i/power, "rockFall", x, y, direction, elevation)
end
end
}
I just noticed that the party doesn't get XP when killing a monster with this spell, do you have any idea why ?