Skip to content
Snippets Groups Projects
Commit 8b5bef6a authored by DarkGod's avatar DarkGod
Browse files

New awesome effect on body of ice and stone skin

parent 66159192
No related branches found
No related tags found
No related merge requests found
......@@ -62,6 +62,9 @@ newBirthDescriptor{
function(actor)
actor:addShaderAura("body_of_fire", "awesomeaura", {time_factor=3500, alpha=1, flame_scale=1.1}, "particles_images/wings.png")
end,
function(actor)
actor:addShaderAura("body_of_ice", "crystalineaura", {}, "particles_images/spikes.png")
end,
},
talents_types = {
["spell/explosives"]={true, 0.3},
......
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009 - 2014 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
base_size = 32
toback = true
return { generator = function()
local ad = rng.range(0, 360)
local a = math.rad(ad)
local dir = math.rad(90)
local r = rng.range(18, 22)
local dirchance = rng.chance(2)
local x = rng.range(-16, 16)
local y = -20 + math.abs(math.sin(x / 16) * 8)
return {
trail = 1,
life = rng.range(20, 28),
size = rng.range(3, 4), sizev = 0, sizea = -0.005,
x = x, xv = 0, xa = 0,
y = y, yv = 0.5, ya = 0.06,
dir = 0, dirv = 0, dira = 0,
vel = 0, velv = 0, vela = 0,
r = 0.624, rv = 0, ra = 0,
g = 0.820, gv = 0, ga = 0,
b = 0.933, bv = 0, ba = 0,
a = 0.2, av = 0.1, aa = 0,
}
end, },
function(self)
self.ps:emit(1)
end,
10,
"weather/snowflake"
game/modules/tome/data/gfx/particles_images/spikes.png

12.5 KiB

uniform sampler2D displMapTex;
uniform sampler2D normalMapTex;
uniform float spikeLength;
uniform float spikeWidth;
uniform float spikeOffset;
uniform float growthSpeed;
uniform float tick;
uniform float tick_start;
uniform float time_factor;
uniform vec3 color;
void main(void)
{
vec2 radius = gl_TexCoord[0].xy - vec2(0.5, 0.5);
float innerRadius = 0.25;
float outerRadius = 0.5;
vec2 planarPos;
vec4 displacement = texture2D(displMapTex, gl_TexCoord[0].xy);
vec2 point = gl_TexCoord[0].xy;
float eps = 0.05;
vec2 basisY = vec2(
texture2D(displMapTex, point + vec2(eps, 0.0)).a - texture2D(displMapTex, point + vec2(-eps, 0.0)).a,
-texture2D(displMapTex, point + vec2(0.0, eps)).a + texture2D(displMapTex, point + vec2(0.0, -eps)).a);
basisY /= length(basisY) + 0.001;
vec2 basisX = vec2(basisY.y, -basisY.x);
planarPos.x = displacement.b * 6.0 / spikeWidth + spikeOffset;
planarPos.y = displacement.a * 20.0 / (spikeLength * clamp((tick - tick_start) / time_factor * growthSpeed, 0.0, 1.0) + 0.001);
vec4 normalMap = texture2D(normalMapTex, vec2(planarPos.x, clamp(1.0 - planarPos.y, 0.01, 0.99)));
vec3 localNormal = normalMap.rgb;
localNormal -= vec3(0.5, 0.5, 0.5);
localNormal.x = -localNormal.x;
localNormal.z = -localNormal.z;
localNormal /= length(localNormal);
vec3 globalNormal;
globalNormal.xy = basisX * localNormal.x + basisY * localNormal.y;
globalNormal.z = localNormal.z;
vec2 lightDir2 = vec2(cos(tick / time_factor), sin(tick / time_factor));
float ang = 3.1415 * 0.2;
vec3 lightDir3 = vec3(lightDir2 * sin(ang), cos(ang));
float diffuse = clamp(-dot(lightDir3, globalNormal), 0.0, 1.0);
float specular = 0.0;
if(dot(lightDir3, globalNormal) < 0.0)
{
vec3 reflectedLight = lightDir3 - globalNormal * dot(lightDir3, globalNormal) * 2.0;
specular += pow(clamp(-dot(reflectedLight, vec3(0.0, 0.0, 1.0)), 0.0, 1.0), 30.0);
}
//vec3(0.624, 0.820, 0.933);
vec4 resultColor = vec4(color * diffuse + vec3(1.0, 1.0, 1.0) * specular, normalMap.a * gl_Color.a);
gl_FragColor = resultColor;///
}
\ No newline at end of file
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
return {
frag = "crystalineaura",
vert = nil,
args = {
displMapTex = { texture = 0 },
normalMapTex = { texture = 1 },
spikeLength = spikeLength or 1.0, -- 1.0 means normal length, 0.5 is half-sized spikes, 2.0 is double-sized, etc
spikeWidth = spikeWidth or 1.0, -- use different values for different effects. 1.0 is normal width
spikeOffset = spikeOffset or 0.0, -- use different values for different effects. such as offset = 0.0 for ice spikes and 0.123123 for rock spikes
growthSpeed = growthSpeed or 1.0, -- 1.0 is normal growth speed
time_factor = time_factor or 500,
color = color or {0.624, 0.820, 0.933},
},
resetargs = {
tick_start = function() return core.game.getTime() end,
},
clone = false,
}
......@@ -31,12 +31,16 @@ newTalent{
getArmor = function(self, t) return self:combatTalentSpellDamage(t, 10, 23) end,
activate = function(self, t)
game:playSoundNear(self, "talents/earth")
return {
local ret = {
armor = self:addTemporaryValue("combat_armor", t.getArmor(self, t)),
particle = self:addParticles(Particles.new("stone_skin", 1)),
}
if not self:addShaderAura("stone_skin", "crystalineaura", {time_factor=1500, spikeOffset=0.123123, spikeLength=0.9, spikeWidth=3, growthSpeed=2, color={0xD7/255, 0x8E/255, 0x45/255}}, "particles_images/spikes.png") then
ret.particle = self:addParticles(Particles.new("stone_skin", 1))
end
return ret
end,
deactivate = function(self, t, p)
self:removeShaderAura("stone_skin")
self:removeParticles(p.particle)
self:removeTemporaryValue("combat_armor", p.armor)
return true
......
......@@ -120,12 +120,16 @@ newTalent{
activate = function(self, t)
game:playSoundNear(self, "talents/ice")
local ret = {}
self:addShaderAura("body_of_ice", "crystalineaura", {}, "particles_images/spikes.png")
ret.particle = self:addParticles(Particles.new("snowfall", 1))
self:talentTemporaryValue(ret, "resists", {[DamageType.PHYSICAL] = t.getResistance(self, t) * 0.6})
self:talentTemporaryValue(ret, "damage_affinity", {[DamageType.COLD] = t.getAffinity(self, t)})
self:talentTemporaryValue(ret, "ignore_direct_crits", t.critResist(self, t))
return ret
end,
deactivate = function(self, t, p)
self:removeParticles(p.particle)
self:removeShaderAura("body_of_ice")
return true
end,
info = function(self, t)
......
......@@ -2414,8 +2414,12 @@ newEffect{
self:effectTemporaryValue(eff, "on_melee_hit", {[DamageType.COLD]=eff.dam})
self:effectTemporaryValue(eff, "all_damage_convert", DamageType.COLD)
self:effectTemporaryValue(eff, "all_damage_convert_percent", 50)
self:addShaderAura("ice_armour", "crystalineaura", {}, "particles_images/spikes.png")
eff.particle = self:addParticles(Particles.new("snowfall", 1))
end,
deactivate = function(self, eff)
self:removeShaderAura("ice_armour")
self:removeParticles(eff.particle)
end,
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment