Example:
Code: Select all
---------------------------------------------------------------------------------------------------------------------------
data/gfx/particles/sand_trail.lua
---------------------------------------------------------------------------------------------------------------------------
base_size = 2
local toggle = false
return { generator = function()
local ad = rng.range(0, 360)
local a = math.rad(ad)
local size = rng.range(6,35)
local halfSize = size / 2
return {
trail = 1,
life = rng.range(10,35),
size = size, sizev = rng.range(-1,2)/18, sizea = rng.range(-2,1)/18,
x = rng.range(-engine.Map.tile_w * 0.4 - halfSize, engine.Map.tile_w * 0.4 - halfSize), xv = 0, xa = 0,
y = rng.range(-engine.Map.tile_h * 0.4 - halfSize, engine.Map.tile_h * 0.4 - halfSize), yv = 0, ya = 0,
dir = 10, dirv = 0, dira = 0,
vel = 0.3, velv = -0.03, vela = 0,
r = rng.range(46,56)/255, rv = 0, ra = 0,
g = rng.range(18,25)/255, gv = 0, ga = 0,
b = 0 / 255, bv = 0, ba = 0,
a = rng.range(50, 65) / 255, av = -1/400 , aa = 0
}
end, },
function(self)
self.nb = (self.nb or 0) + 1
if self.nb < 10 then
self.ps:emit(2)
end
end,
260
Code: Select all
newTalent{
name = "Cloud of sand",
type = {"sand/control", 4},
require = sand_req3,
points = 5,
stamina = 10,
cooldown = 25,
no_energy = true,
tactical = { DISABLE = 3, DEFEND = 3, ESCAPE = 1 },
createCloud = function(summoner, x, y, duration)
local e = Object.new{
name = "sand cloud",
block_sight=true,
canAct = false,
x = x, y = y,
damage = damage,
duration = duration,
summoner = summoner,
summoner_gain_exp = true,
act = function(self)
local Map = require "engine.Map"
self:useEnergy()
if self.duration <= 0 then
-- remove it from the map
if self.particles then game.level.map:removeParticleEmitter(self.particles) end
game.level.map:remove(self.x, self.y, Map.TERRAIN+3)
game.level:removeEntity(self)
else
self.duration = self.duration - 1
end
end,
}
game.level:addEntity(e)
game.level.map(x, y, Map.TERRAIN+3, e)
-- add particles
e.particles = Particles.new("sand_cloud", 1, { })
e.particles.x = x
e.particles.y = y
game.level.map:addParticleEmitter(e.particles)
end,
action = function(self, t)
local getDuration = math.floor(5 + self:getTalentLevel(t)/2 + self:getTalentLevel(t)/5 * self:getWil(10))
local getRange = self:getTalentLevelRaw(t)
local x, y = self.x, self.y
local negRange = -getRange
local posRange = getRange
t.createCloud(self, x, y, getDuration+rng.range(0, 2))
-- make sure the player is surrounded by the cloud
for i = -1, 1 do for j = -1, 1 do if game.level.map:isBound(x + i, y + j) then
if not game.level.map:checkAllEntities(x + i, y + j, "block_sight") then
t.createCloud(self, x+i, y+j, getDuration+rng.range(0, 1))
end
end end end
-- make more clouds in skill range with high chance
for i = negRange, posRange do for j = negRange, posRange do if game.level.map:isBound(x + i, y + j) then
if not game.level.map:checkAllEntities(x + i, y + j, "block_sight") and rng.percent(90) then
t.createCloud(self, x+i, y+j, getDuration+rng.range(0, 1))
end
end end end
-- give a small chance of +1 range clouds
for i = negRange-1, posRange+1 do for j = negRange-1, posRange+1 do if game.level.map:isBound(x + i, y + j) then
if not game.level.map:checkAllEntities(x + i, y + j, "block_sight") and rng.percent(20) then
t.createCloud(self, x+i, y+j, getDuration+rng.range(0, 1))
end
end end end
return true
end,
info = function(self, t)
return ([[You cover the area around you in a thick cloud of sand, blocking all light in a radius of %d for %d turns.]]):format(self:getTalentLevelRaw(t), math.floor(5 + self:getTalentLevel(t)/2 + self:getTalentLevel(t)/5 * self:getWil(10)))
end,
}