Page 1 of 1
Willpower added to spell damage
Posted: Wed Dec 19, 2012 9:36 pm
by LordGarth
Is it possible to add the mage's willpower to spell damage they do?
Thx,
LG
Re: Willpower added to spell damage
Posted: Wed Dec 19, 2012 10:31 pm
by Diarmuid
Hi,
In native LoG, you can add the following code:
Code: Select all
onCastSpell = function(champion, spellName)
if spellName == "fireball" then
local dx, dy = getForward(party.facing)
local willpower = caster:getStat("willpower")
spawn("fireball", party.level, party.x+dx, party.y+dy, party.facing_:setAttackPower(30+willpower)
end
end
The problem is that the fireball will be spawned one square ahead.
Now if you have my new spells framework installed (shameless plug) you can instead do :
Code: Select all
onCastSpell = function(champion, spellName)
if spellName == "fireball" then
local willpower = caster:getStat("willpower")
exsp.spellCast("fireball", 30+willpower, caster:getOrdinal())
end
end
simpler syntax and you get the fireball to launch from the party square.
Re: Willpower added to spell damage
Posted: Thu Dec 20, 2012 5:30 pm
by LordGarth
Is there some code I could add to the defineObject of the spell or under define spell?
LG
Re: Willpower added to spell damage
Posted: Thu Dec 20, 2012 6:13 pm
by Diarmuid
Sure, it works too, either of the following ones.
Code: Select all
defineSpell{
name = "fireball",
...all fireball properties...
onCast = function(caster,x,y,direction,skill)
local dx, dy = getForward(direction)
local willpower = caster:getStat("willpower")
spawn("fireball", party.level, x+dx, y+dy, direction):setAttackPower(30+willpower)
end,
}
defineSpell{
name = "fireball",
...all fireball properties...
onCast = function(caster,x,y,direction,skill)
local willpower = caster:getStat("willpower")
exsp.spellCast("fireball", caster, 30+willpower)
end,
end,
}
BUT!!!!
I realized that with the normal spawn, you won't get experience points calculated correctly for the caster... while with EXSP any spell cast by the party, default or custom, will always carry the ordinal and if it damages a monster, experience will be correctly awarded.
Your post also gave me the idea to simplify my syntax for exsp.spellCast, in the next update (v1.3.2, which also supports the new grimrock 1.3.6) you'll be able to just send the caster object as in the code above and it calculates the ordinal automatically.
Re: Willpower added to spell damage
Posted: Thu Dec 20, 2012 6:37 pm
by LordGarth
Under defineObject can I have attackPower = (30+willpower),
LG
Re: Willpower added to spell damage
Posted: Thu Dec 20, 2012 7:08 pm
by Diarmuid
I haven't tried, but probably no, as these are definitions, not scripts. You'll probably get a
"number expected", got something error... You can always try and tell us how it goes
