Re: LoG Framework (new: AD&D style spell book and 9 EoB spel
Posted: Sat Nov 03, 2012 11:45 pm
Ok, new update.
- Added light effects to spell projectiles (fireball,flame arrow, acid arrow and magic missile currently). It was pretty tricky, but solution was to spawn fx entity which moves at the same speed as the shot projectile. It works and it is not performance killer, as I thought it would be.
- added fireball spell
- added fw_fx script entity
- function fw_fx.addProjectileEffect(projectile,effectName,speed,onHitEffectName)
projectile = projectile entity
effectName = particle effect (eg. fireball)
speed = speed of the effect(must be same as the projectile)
onHitEffectName = particle effect which is played when projectile hits the target (or wall)
- added eob_spells.addSpellsToMonsters(monsterNamespace,spellName,amount,targets)
usage example: eob_spells.addSpellsToMonsters('snail','magic_missile',10,{'party','crowern'})
adds 10 magic missiles to each snail, and snails will use it against party and crowerns
- probably some other changes/fixes that I can't remeber
source of fw_fx, it can be used without the framework, so I thought I'd post it here.
You can add particle effects to any projectile in run time with it.
Updated demo dungeon to google drive: https://docs.google.com/open?id=0B7cR7s ... UN4SGZGNEk
- Added light effects to spell projectiles (fireball,flame arrow, acid arrow and magic missile currently). It was pretty tricky, but solution was to spawn fx entity which moves at the same speed as the shot projectile. It works and it is not performance killer, as I thought it would be.
- added fireball spell
- added fw_fx script entity
- function fw_fx.addProjectileEffect(projectile,effectName,speed,onHitEffectName)
projectile = projectile entity
effectName = particle effect (eg. fireball)
speed = speed of the effect(must be same as the projectile)
onHitEffectName = particle effect which is played when projectile hits the target (or wall)
- added eob_spells.addSpellsToMonsters(monsterNamespace,spellName,amount,targets)
usage example: eob_spells.addSpellsToMonsters('snail','magic_missile',10,{'party','crowern'})
adds 10 magic missiles to each snail, and snails will use it against party and crowerns
- probably some other changes/fixes that I can't remeber
source of fw_fx, it can be used without the framework, so I thought I'd post it here.
Code: Select all
effects = {}
function addProjectileEffect(projectile,effectName,speed,onHitEffectName)
local timer = spawn('timer',projectile.level,projectile.x,projectile.y,projectile.facing)
local effect = spawn('fx',projectile.level,projectile.x,projectile.y,projectile.facing)
effects[timer.id] = {}
effects[timer.id].projectile_id = projectile.id
effects[timer.id].effect_id = effect.id
effects[timer.id].x = 0
effects[timer.id].y = 0
effects[timer.id].onHitEffect= onHitEffectName
local dx,dy = getForward(projectile.facing)
dy = -1 * dy
effects[timer.id].x = dx * 0.5
effects[timer.id].y = dy * 0.5
timer:addConnector('activate','fw_fx','move_effect')
timer:setTimerInterval(0.5/speed)
local light = getLightPreset(effectName)
if light then
effect:setLight(unpack(light))
end
effect:translate(0.5*dx,1,0.5*dy)
effect:setParticleSystem(effectName)
timer:activate()
return effect
end
function getLightPreset(preset)
--FX:setLight(red, green, blue, brightness, range, time, castShadow)
local s = {}
s['fireball'] = {1, 0.5, 0.25,15,7,200,true}
s['fireball_hit'] = {1, 0.5, 0.25,40,7,1,true}
s['magic_missile'] = {1, 1, 1,15,7,200,true}
s['poison_bolt'] = {0.25, 0.6, 0.2,4,4,200,true}
s['lightning_bolt_hit'] = {0.25, 0.5, 1,40,10,1,true}
s['magic_missile_hit'] = {1, 1, 1,40,10,1,true}
return s[preset]
end
function move_effect(timer)
local e = effects[timer.id]
local p = findEntity(e.projectile_id)
local fx = findEntity(e.effect_id)
if not p then
if e.onHitEffect then
local ohfx = spawn('fx',fx.level,e.px,e.py,fx.facing)
ohfx:setParticleSystem(e.onHitEffect)
ohfx:translate(0,1,0)
local light = getLightPreset(e.onHitEffect)
if light then
ohfx:setLight(unpack(light))
end
end
effects[timer.id] = nil
timer:deactivate()
timer:destroy()
fx:destroy()
return
end
e.px = p.x
e.py = p.y
fx:translate(e.x,0,e.y)
end
Updated demo dungeon to google drive: https://docs.google.com/open?id=0B7cR7s ... UN4SGZGNEk