) which includes two models, a sound effect, and a few texture files. This archive can be unpacked directly into your mod_assets folder.
) which I modified slightly. So you will need to create a script entity in your map named
Code: Select all
projectiles = {}
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)
projectiles[timer.id] = {}
projectiles[timer.id].projectile_id = projectile.id
projectiles[timer.id].effect_id = effect.id
projectiles[timer.id].level = projectile.level
projectiles[timer.id].x = 0
projectiles[timer.id].y = 0
projectiles[timer.id].facing = projectile.facing
projectiles[timer.id].onHitEffect= onHitEffectName
local dx,dy = getForward(projectile.facing)
dy = -1 * dy
projectiles[timer.id].x = dx * 0.5
projectiles[timer.id].y = dy * 0.5
timer:addConnector('activate','fxScripts','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 addProjectileManualHit(caster, projectile, damageAmount, damageType, radius)
for key,value in pairs(projectiles) do
if value.projectile_id == projectile.id then
if caster then
projectiles[key].caster = caster:getOrdinal()
end
projectiles[key].damage = damageAmount
projectiles[key].damageType = damageType
projectiles[key].radius = radius
end
end
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'] = {0.25, 0.5, 1,30,5,1,true}
s['lightning_bolt_hit'] = {0.25, 0.5, 1,100,5,0.5,true}
s['magic_missile_hit'] = {1, 1, 1,40,10,1,true}
s['wizards_fire'] = {1, 0.9, 0.5,40,10,1,true}
s['wizards_life_fire'] = {1, 1, 1,120,10,1,true}
s['wizards_fire_hit'] = {1, 1, 0.95, 150,10,0.6,true}
local l = s[preset]
if not l then
l = {0, 0, 0, 0, 0, 0, false}
end
return l
end
function applyDamage(monster, weapon)
for key,value in pairs(projectiles) do
if value.projectile_id == weapon.id then
local e=projectiles[key]
-- add hit damage/exp if specified
if e.damage then
local r = 0
local dType = "physical"
local damageFlag = 0
-- get radius
if e.radius and e.radius > 1 then
r = e.radius - 1
end
--get damage type
if e.damageType then
dType = e.damageType
end
-- figure out which party member should get the experience
if e.caster ~= nil and e.caster > 0 then
damageFlag = 2 ^ (e.caster + 1)
end
for x=monster.x-r,monster.x+r do
for y=monster.y-r,monster.y+r do
--print("damage: " .. e.damage .. " " .. dType .. " l:" .. e.level .. " x:" .. x .. ", y:" .. y)
damageTile(e.level, x, y, (e.facing+2)%4, damageFlag, dType, e.damage)
end
end
end
return false
end
end
return true
end
function move_effect(timer)
local e = projectiles[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',e.level,e.px,e.py,e.facing)
ohfx:setParticleSystem(e.onHitEffect)
ohfx:translate(0, 1, 0)
local light = getLightPreset(e.onHitEffect)
if light then
ohfx:setLight(unpack(light))
end
end
projectiles[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
There are a series of objects and materials that need to be set up as well.
Code: Select all
defineParticleSystem{
name = "wizards_fire",
emitters = {
-- smoke
{
emissionRate = 30,
emissionTime = 0,
maxParticles = 100,
boxMin = {0.0, 0.0, 0.0},
boxMax = {0.0, 0.0, 0.0},
sprayAngle = {0,360},
velocity = {0.1,0.1},
texture = "assets/textures/particles/smoke_01.tga",
lifetime = {1,1.25},
color0 = {0.25, 0.25, 0.25},
opacity = 1,
fadeIn = 0.1,
fadeOut = 0.9,
size = {0.8, 1.1},
gravity = {0,0,0},
airResistance = 0.1,
rotationSpeed = 1,
blendMode = "Translucent",
},
-- flames
{
emissionRate = 100,
emissionTime = 0,
maxParticles = 100,
boxMin = {-0.03, -0.03, 0.03},
boxMax = { 0.03, 0.03, -0.03},
sprayAngle = {0,360},
velocity = {0.5, 0.7},
texture = "assets/textures/particles/torch_flame.tga",
frameRate = 35,
frameSize = 64,
frameCount = 16,
lifetime = {0.8, 0.8},
colorAnimation = true,
color0 = {2, 2, 2},
color1 = {1.0, 1.0, 1.0},
color2 = {1.0, 0.5, 0.25},
color3 = {1.0, 0.3, 0.1},
opacity = 1,
fadeIn = 0.15,
fadeOut = 0.3,
size = {0.25, 0.35},
gravity = {0,0,0},
airResistance = 1,
rotationSpeed = 1,
blendMode = "Additive",
objectSpace = true,
},
-- lightning rim
{
emissionRate = 20,
emissionTime = 0,
maxParticles = 15,
boxMin = { 0,0,0 },
boxMax = { 0,0,0 },
sprayAngle = {0,360},
velocity = {0,0},
texture = "mod_assets/textures/lightning_ball_blue.tga",
lifetime = {0.5,1},
colorAnimation = false,
color0 = {1, 1, 1},
opacity = 1,
fadeIn = 0.1,
fadeOut = 0.3,
size = {0.7, 0.8},
gravity = {0,0,0},
airResistance = 5,
rotationSpeed = 2,
blendMode = "Additive",
objectSpace = true,
},
-- lightning core
{
emissionRate = 20,
emissionTime = 0,
maxParticles = 3,
boxMin = { 0,0,0 },
boxMax = { 0,0,0 },
sprayAngle = {0,360},
velocity = {0,0},
texture = "mod_assets/textures/lightning_ball.tga",
lifetime = {0.4,0.5},
colorAnimation = false,
color0 = {1, 1, 1},
opacity = 1,
fadeIn = 0.1,
fadeOut = 0.3,
size = {0.7, 0.75},
gravity = {0,0,0},
airResistance = 5,
rotationSpeed = -2,
blendMode = "Additive",
objectSpace = true,
},
-- glow
{
spawnBurst = true,
emissionRate = 1,
emissionTime = 0,
maxParticles = 1,
boxMin = {0,0,0.0},
boxMax = {0,0,0.0},
sprayAngle = {0,30},
velocity = {0,0},
texture = "assets/textures/particles/glow.tga",
lifetime = {1000000, 1000000},
colorAnimation = false,
color0 = {0.25,0.32,0.5},
opacity = 0.3,
fadeIn = 0.1,
fadeOut = 0.1,
size = {1.0, 1.0},
gravity = {0,0,0},
airResistance = 1,
rotationSpeed = 2,
blendMode = "Additive",
objectSpace = true,
},
-- flame trail
{
emissionRate = 80,
emissionTime = 0,
maxParticles = 100,
boxMin = {0.0, 0.0, 0.0},
boxMax = {0.0, 0.0, 0.0},
sprayAngle = {0,360},
velocity = {0.1, 0.3},
texture = "assets/textures/particles/torch_flame.tga",
frameRate = 35,
frameSize = 64,
frameCount = 16,
lifetime = {0.15, 0.25},
colorAnimation = true,
color0 = {2, 2, 2},
color1 = {1.0, 1.0, 1.0},
color2 = {1.0, 0.5, 0.25},
color3 = {1.0, 0.3, 0.1},
opacity = 1,
fadeIn = 0.15,
fadeOut = 0.3,
size = {0.4, 0.9},
gravity = {0,0,0},
airResistance = 1.0,
rotationSpeed = 1,
blendMode = "Additive",
},
}
}
defineParticleSystem{
name = "wizards_life_fire",
emitters = {
-- smoke
{
emissionRate = 30,
emissionTime = 0,
maxParticles = 100,
boxMin = {0.0, 0.0, 0.0},
boxMax = {0.0, 0.0, 0.0},
sprayAngle = {0,360},
velocity = {0.1,0.1},
texture = "assets/textures/particles/smoke_01.tga",
lifetime = {2,3},
color0 = {0.25, 0.25, 0.25},
opacity = 1,
fadeIn = 0.1,
fadeOut = 0.9,
size = {1.8, 2.5},
gravity = {0,0,0},
airResistance = 0.1,
rotationSpeed = 1,
blendMode = "Translucent",
},
-- flames
{
emissionRate = 100,
emissionTime = 0,
maxParticles = 100,
boxMin = {-0.4, -0.4, 0.4},
boxMax = { 0.4, 0.4, -0.4},
sprayAngle = {0,360},
velocity = {0.5, 0.7},
texture = "assets/textures/particles/torch_flame.tga",
frameRate = 35,
frameSize = 64,
frameCount = 16,
lifetime = {0.8, 0.8},
colorAnimation = true,
color0 = {2, 2, 2},
color1 = {1.0, 1.0, 1.0},
color2 = {1.0, 0.5, 0.25},
color3 = {1.0, 0.3, 0.1},
opacity = 1,
fadeIn = 0.15,
fadeOut = 0.3,
size = {0.75, 0.95},
gravity = {0,0,0},
airResistance = 1,
rotationSpeed = 1,
blendMode = "Additive",
objectSpace = true,
},
-- lightning rim
{
emissionRate = 20,
emissionTime = 0,
maxParticles = 15,
boxMin = { 0,0,0 },
boxMax = { 0,0,0 },
sprayAngle = {0,360},
velocity = {0,0},
texture = "mod_assets/textures/lightning_ball_blue.tga",
lifetime = {0.5,1},
colorAnimation = false,
color0 = {1, 1, 1},
opacity = 1,
fadeIn = 0.1,
fadeOut = 0.3,
size = {1.8, 2.0},
gravity = {0,0,0},
airResistance = 5,
rotationSpeed = 2,
blendMode = "Additive",
objectSpace = true,
},
-- lightning core
{
emissionRate = 20,
emissionTime = 0,
maxParticles = 3,
boxMin = { 0,0,0 },
boxMax = { 0,0,0 },
sprayAngle = {0,360},
velocity = {0,0},
texture = "mod_assets/textures/lightning_ball.tga",
lifetime = {0.4,0.5},
colorAnimation = false,
color0 = {1, 1, 1},
opacity = 1,
fadeIn = 0.1,
fadeOut = 0.3,
size = {1.6, 1.8},
gravity = {0,0,0},
airResistance = 5,
rotationSpeed = -2,
blendMode = "Additive",
objectSpace = true,
},
-- glow
{
spawnBurst = true,
emissionRate = 1,
emissionTime = 0,
maxParticles = 1,
boxMin = {0,0,0.0},
boxMax = {0,0,0.0},
sprayAngle = {0,30},
velocity = {0,0},
texture = "assets/textures/particles/glow.tga",
lifetime = {1000000, 1000000},
colorAnimation = false,
color0 = {0.25,0.32,0.5},
opacity = 0.3,
fadeIn = 0.1,
fadeOut = 0.1,
size = {2.0, 2.2},
gravity = {0,0,0},
airResistance = 1,
rotationSpeed = 2,
blendMode = "Additive",
objectSpace = true,
},
-- flame trail
{
emissionRate = 80,
emissionTime = 0,
maxParticles = 100,
boxMin = {0.0, 0.0, 0.0},
boxMax = {0.0, 0.0, 0.0},
sprayAngle = {0,360},
velocity = {0.1, 0.3},
texture = "assets/textures/particles/torch_flame.tga",
frameRate = 35,
frameSize = 64,
frameCount = 16,
lifetime = {0.25, 0.4},
colorAnimation = true,
color0 = {2, 2, 2},
color1 = {1.0, 1.0, 1.0},
color2 = {1.0, 0.5, 0.25},
color3 = {1.0, 0.3, 0.1},
opacity = 1,
fadeIn = 0.15,
fadeOut = 0.3,
size = {1.6, 1.8},
gravity = {0,0,0},
airResistance = 1.0,
rotationSpeed = 1,
blendMode = "Additive",
},
}
}
defineParticleSystem{
name = "wizards_fire_hit",
emitters = {
-- smoke
{
emissionRate = 20,
emissionTime = 0.3,
maxParticles = 100,
boxMin = {0.0, 0.0, 0.0},
boxMax = {0.0, 0.0, 0.0},
sprayAngle = {0,100},
velocity = {0.1, 0.5},
texture = "assets/textures/particles/smoke_01.tga",
lifetime = {0.8,1.1},
color0 = {0.25, 0.20, 0.17},
opacity = 1,
fadeIn = 0.3,
fadeOut = 0.9,
size = {2, 3},
gravity = {0,0,0},
airResistance = 0.1,
rotationSpeed = 0.5,
blendMode = "Translucent",
},
-- flames
{
spawnBurst = true,
maxParticles = 50,
boxMin = {0.0, 0.0, 0.0},
boxMax = {0.0, 0.0, 0.0},
sprayAngle = {0,360},
velocity = {0,3},
objectSpace = true,
texture = "assets/textures/particles/torch_flame.tga",
frameRate = 35,
frameSize = 64,
frameCount = 16,
lifetime = {0.4,0.6},
color0 = {1, 0.9, 0.7},
opacity = 1,
fadeIn = 0.1,
fadeOut = 0.3,
size = {1, 2},
gravity = {0,0,0},
airResistance = 0.5,
rotationSpeed = 2,
blendMode = "Additive",
},
-- glow
{
spawnBurst = true,
emissionRate = 1,
emissionTime = 0,
maxParticles = 1,
boxMin = {0,0,-0.1},
boxMax = {0,0,-0.1},
sprayAngle = {0,30},
velocity = {0,0},
texture = "assets/textures/particles/glow.tga",
lifetime = {0.5, 0.5},
colorAnimation = false,
color0 = {1.500000, 1, 1},
opacity = 1,
fadeIn = 0.01,
fadeOut = 0.5,
size = {4, 4},
gravity = {0,0,0},
airResistance = 1,
rotationSpeed = 2,
blendMode = "Additive",
}
}
}