Added 2 new eob-spells to demo-dungeon. (spells are not in framework.lua yet, because the magic system is under heavy development)
- Burning hands: just deals some fire damage to front of party.
- Shield: This was pretty tough. But now it works almost like in EoB.
It deflects magic missiles completely and reduces damage of missile and throwing weapons(throwing weapon damage is reduced more than missile).
- Improved magic missile so that it shoots from the tile where party is.
- Also refactored magic-related code so that it's more reusable, there is now fw_magic script entity(for general magic-related functions) and eob_spell script entity(for EoB spells only)
- added champion-specific hooks (only onProjectileHit currently) Shield spell uses this. Hook-namespaces for champions are champion_1,champion_2,champion_3,champion_4. The number is ordinal number of a champion.
- added a scroll which enables or disables turn based combat

So you can choose if you wan't to use it or not. Scroll is spawned automatically to 1st champions inventory if turn_based module is activated.
- added 2 pressure plates to 1st room for testing purposes. Other shoot arrows and other magic-missiles. You can test shield-spell with it.
New spell definitions:
Code: Select all
createSpell{
name = "burning_hands",
uiName = "Burning hands",
skill = "fire_magic",
level = 0,
runes = "B",
manaCost = 10,
}
createSpell{
name = "shield",
uiName = "Shield",
skill = "fire_magic",
level = 0,
runes = "D",
manaCost = 10,
}
eob_spells script entity
Code: Select all
settings = {}
settings.useCasterLevelAsModifier = false
settings.hold_monster = {}
settings.hold_monster.duration = 5 --seconds + (skill/2)
settings.hold_monster.immune= {
skeleton_archer=true,
skeleton_warrior=true
}
settings.magic_missile = {}
settings.magic_missile.damage = 5 -- damage * (skill / 2)
settings.shield = {}
settings.shield.duration = 5 --seconds + (skill/2)
settings.shield.missiles = 6 -- how many damagepoints are subtracted (max value)
settings.shield.throwing = 8 -- how many damagepoints are subtracted (max value)
settings.burning_hands = {}
settings.burning_hands.damage = 3 -- damage+skill*2
function activate()
fw_magic.addSpell('hold_monster',holdMonster)
fw_magic.addSpell('magic_missile',magicMissile)
fw_magic.addSpell('burning_hands',burningHands)
fw_magic.addSpell('shield',shield)
end
-- BURNING HANDS --
function burningHands(caster, x, y, direction, skill)
if (useCasterLevelAsModifier) then skill = caster:getLevel() end
local dx,dy = getForward(direction)
playSoundAt("fireburst",party.level,x,y)
damageTile(party.level, x+dx, y+dy, direction, 0, 'fire', settings.burning_hands.damage+skill*2)
end
-- SHIELD --
function shield(caster, x, y, direction, skill)
if (useCasterLevelAsModifier and caster.getLevel) then skill = caster:getLevel() end
local timerId = fw_magic.createSpellTimer(caster,settings.shield.duration+skill/2,{'eob_spells','shieldDestructor'})
playSoundAt("fireball_launch",party.level,x,y)
fw.addHooks(fw.getId(caster),timerId,{
onProjectileHit = function(champion,projectile,damage,damageType)
if projectile.name == 'magic_missile' then
hudPrint('Magic missile deflected')
return false
end
if help.isEntityType(projectile,'item_missileweapon') then
champion:damage(damage - math.random(settings.shield.missiles), damageType)
hudPrint('Shield spell deflected some damage')
champion:playDamageSound()
return false
end
if help.isEntityType(projectile,'item_throwingweapon') then
champion:damage(damage - math.random(settings.shield.throwing), damageType)
hudPrint('Shield spell deflected some damage')
champion:playDamageSound()
return false
end
end
}
)
end
function shieldDestructor(timer)
fw_magic.spellTimerDestructor(timer)
hudPrint('Effect of shield spell worn out.')
end
-- MAGIC MISSILE --
function magicMissile(caster, x, y, direction, skill)
if (useCasterLevelAsModifier) then skill = champ:getLevel() end
if caster and caster.getOrdinal then caster = party end
playSoundAt("fireball_launch",party.level,x,y)
shootProjectile('magic_missile', party.level, x, y, direction, 14, 0, 0, 0, 0, 0,
settings.magic_missile.damage * (skill / 2), caster, true)
end
-- HOLD MONSTER --
function holdMonster(champ, x, y, direction, skill)
if (useCasterLevelAsModifier) then skill = champ:getLevel() end
local holdMonster = function() return false end
local monster = help.nextEntityAheadOf(party,3,'monster')
if not monster then return false end
if settings.hold_monster.immune[monster.name] then return false end
local timerId = fw_magic.createSpellTimer(monster,settings.hold_monster.duration+(skill/2))
playSoundAt("frostbolt_launch",party.level,party.x,party.y)
fw.debugPrint(monster.id..' held')
--dynamically add hooks which prevents monster to attack or move
-- use spellId as hook-id so the hook can be removed on destructor
fw.addHooks(monster.id,timerId,{
onMove = holdMonster,
onAttack = holdMonster,
onRangedAttack = holdMonster,
onTurn = holdMonster
},
1)
return true
end
As you can see I added settings to the top of the eob_spells, so that the spell-properties can be altered in runtime. If you want to change the duration of shield, just set a new value in your own script entity.
eg.
eob_spells.settings.shield.duration = 10
edit: link
https://docs.google.com/open?id=0B7cR7s ... UN4SGZGNEk