Thanks everyone, it makes me feel I didn't go through every potential issue here...
OK, so far the easy part is done.
Raise dead spell
Code: Select all
defineSpell{
name = "raise_dead",
uiName = "Raise Dead",
gesture = 78965,
manaCost = 35,
onCast = function(champion, skillLevel)
local ix,iy = getForward(party.facing) -- get coordinates of the tile in front of the party
ix = (ix) + party.x
iy = (iy) + party.y
if findEntity("bodyguard") ~= nil then -- check if there is already one bodyguard summoned
hudPrint("You already control one ally")
playSound("spell_fizzle")
else
if party.map:checkLineOfFire(party.x,party.y,ix,iy,party.elevation) == true then
if not party.map:isBlocked(ix,iy,party.elevation)
then
spawn("timer",party.level,1,1,0,0,"bodyguard_timer")
bodyguard_timer.timer:setTimerInterval(30)
bodyguard_timer.timer:setDisableSelf(true)
bodyguard_timer.timer:setTriggerOnStart(false)
bodyguard_timer.timer:setCurrentLevelOnly(false)
bodyguard_timer.timer:addConnector("onActivate","bodyguard_script","bodyguardcheck")
spawn("bodyguard",party.level,ix,iy,party.facing,party.elevation,"bodyguard")
bodyguard_timer.timer:start()
else
playSound("spell_fizzle")
hudPrint("You can't cast that here")
end
else
playSound("spell_fizzle")
hudPrint("You can't cast that here")
end
end
end,
skill = "concentration",
requirements = { "concentration", 1 },
icon = 45,
spellIcon = 15,
description = "Bring out your dead !",
}
The spell checks if there is not already an ally summoned, and if the tile facing the party is within line of sight
and not blocked. If so, it spawns an undead bodyguard with a timer connected to a script to destroy the ally after 30s (I don't want him to be permanent) :
Code: Select all
function bodyguardcheck()
playSound("spell_fizzle")
if findEntity("bodyguard") ~= nil then -- it checks if by any chance the bodyguard was already killed
bodyguard.monster:die()
end
bodyguard_timer:destroy()
end
As for the bodyguard himself, brain:pursuit() works perfectly and now I have a nice little undead following my party
Code: Select all
{
class = "Brain",
name = "brain",
sight = 7, -- I boosted the sight to be sure it can follow the party. Not sure if it's very useful
morale = 100,
onThink = function(self)
if self.partyOnLevel then
if self.seesParty then self:pursuit()
else self:moveTowardsParty() end
else self:wait()
end
end,
},
The only thing so far is that the bodyguard is quite slow
but the player is not supposed to be that powerful in the arts of necromancy, I suppose.
Now for the thoughest part, I have to figure out how to make him attack other foes. I hope it's not too far beyond my scripting skills...
BTW, I don't mind if the bodyguard can be in the way of the party. Actually, those are pretty narrow corridors, it's up to the party to decide when to cast the spell
But I might consider Zo Kath Ra's tip.
PS : I have to say Eburt's post on BrainComponent was quite useful to me
viewtopic.php?f=22&t=9720&p=93615&hilit ... ent#p93615