Skip to content
Snippets Groups Projects
Commit 740bf8f2 authored by DarkGod's avatar DarkGod
Browse files

New super-awesome fireflash effect

parent 783f9f5a
No related branches found
No related tags found
No related merge requests found
......@@ -355,6 +355,21 @@ Again, thank you, and enjoy Eyal!
end
end
function _M:isFriend(login)
return self.friends[login]
end
function _M:addFriend(login, id)
core.profile.pushOrder(table.serialize{o="AddFriend", id=id})
-- CRASH ON ADD
end
function _M:removeFriend(login, id)
self.friends[login] = nil
core.profile.pushOrder(table.serialize{o="RemoveFriend", id=id})
end
function _M:join(channel)
if not profile.auth then return end
core.profile.pushOrder(string.format("o='ChatJoin' channel=%q", channel))
......
......@@ -2204,6 +2204,12 @@ function _M:setupMouse(mouse)
end))
end },
}
table.print(user)
if profile.chat:isFriend(user.login) then
table.insert(extra.add_map_action, 3, { name="Remove Friend", fct=function() Dialog:yesnoPopup("Remove Friend", "Really remove "..user.login.." from your friends?", function(ret) if ret then profile.chat:removeFriend(user.login, user.id) end end) end })
else
table.insert(extra.add_map_action, 3, { name="Add Friend", fct=function() Dialog:yesnoPopup("Add Friend", "Really add "..user.login.." to your friends?", function(ret) if ret then profile.chat:addFriend(user.login, user.id) end end) end })
end
end
end
game.tooltip.old_tmx = -100
......
......@@ -24,9 +24,11 @@ if core.shader.active(4) then
use_shader = {type="fireball"}
base_size = 64
size_factor = size_factor or 1
local dir = 0
if proj_x and src_x then
dir = 180 + math.deg(math.atan2(proj_y-src_y, proj_x-src_x))
dir = math.deg(math.atan2(proj_y-src_y, proj_x-src_x))
end
return {
......@@ -34,7 +36,7 @@ return {
generator = function()
return {
life = 1000,
size = 80, sizev = 0, sizea = 0,
size = size_factor * 80, sizev = 0, sizea = 0,
x = 0, xv = 0, xa = 0,
y = 0, yv = 0, ya = 0,
......@@ -50,7 +52,7 @@ end, },
function(self)
self.ps:emit(1)
end,
1, "particles_images/fireball"
1, "particles_images/fireflash"
--------------------------------------------------------------------------------------
......
......@@ -21,17 +21,23 @@
-- Advanced shaders
--------------------------------------------------------------------------------------
if core.shader.active(4) then
use_shader = {type="shockwave"}
use_shader = {type="fireflash"}
base_size = 64
local nb = 0
local dir = 0
if proj_x and src_x then
dir = math.deg(math.atan2(proj_y-src_y, proj_x-src_x))
end
return {
system_rotation = dir, system_rotationv = 0,
generator = function()
return {
life = 16,
life = 32,
--size = 30, sizev = 2.1*64*radius/16, sizea = 0,
size = 2.1*64*radius, sizev = 0, sizea = 0,
size = 3.5*64*radius, sizev = 0, sizea = 0,
x = 0, xv = 0, xa = 0,
y = 0, yv = 0, ya = 0,
......@@ -50,7 +56,7 @@ function(self)
end
nb = nb + 1
end,
1, "particles_images/flamesshockwave"
1, "particles_images/fireflash"
--------------------------------------------------------------------------------------
......
game/modules/tome/data/gfx/particles_images/fireflash.png

267 KiB

uniform sampler2D tex;
uniform float tick;
uniform float time_factor;
uniform float tick_start;
uniform float projectile_time_factor;
uniform float explosion_time_factor;
uniform float is_exploding;
vec4 permute( vec4 x ) {
return mod( ( ( x * 34.0 ) + 1.0 ) * x, 289.0 );
}
vec4 taylorInvSqrt( vec4 r ) {
return 1.79284291400159 - 0.85373472095314 * r;
}
float snoise( vec3 v ) {
const vec2 C = vec2( 1.0 / 6.0, 1.0 / 3.0 );
const vec4 D = vec4( 0.0, 0.5, 1.0, 2.0 );
// First corner
vec3 i = floor( v + dot( v, C.yyy ) );
vec3 x0 = v - i + dot( i, C.xxx );
// Other corners
vec3 g = step( x0.yzx, x0.xyz );
vec3 l = 1.0 - g;
vec3 i1 = min( g.xyz, l.zxy );
vec3 i2 = max( g.xyz, l.zxy );
vec3 x1 = x0 - i1 + 1.0 * C.xxx;
vec3 x2 = x0 - i2 + 2.0 * C.xxx;
vec3 x3 = x0 - 1. + 3.0 * C.xxx;
// Permutations
float antialiasingRadius = 0.99; //1.0 is no antialiasing, 0.0 - fully smoothed(looks worse)
i = mod( i, 289.0 );
vec4 p = permute( permute( permute(
i.z + vec4( 0.0, i1.z, i2.z, 1.0 ) )
+ i.y + vec4( 0.0, i1.y, i2.y, 1.0 ) )
+ i.x + vec4( 0.0, i1.x, i2.x, 1.0 ) );
float snoise( vec3 v );
// Gradients
// ( N*N points uniformly over a square, mapped onto an octahedron.)
float n_ = 1.0 / 7.0; // N=7
vec3 ns = n_ * D.wyz - D.xzx;
vec4 j = p - 49.0 * floor( p * ns.z *ns.z ); // mod(p,N*N)
vec4 x_ = floor( j * ns.z );
vec4 y_ = floor( j - 7.0 * x_ ); // mod(j,N)
vec4 x = x_ *ns.x + ns.yyyy;
vec4 y = y_ *ns.x + ns.yyyy;
vec4 h = 1.0 - abs( x ) - abs( y );
vec4 b0 = vec4( x.xy, y.xy );
vec4 b1 = vec4( x.zw, y.zw );
vec4 s0 = floor( b0 ) * 2.0 + 1.0;
vec4 s1 = floor( b1 ) * 2.0 + 1.0;
vec4 sh = -step( h, vec4( 0.0 ) );
vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;
vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;
vec3 p0 = vec3( a0.xy, h.x );
vec3 p1 = vec3( a0.zw, h.y );
vec3 p2 = vec3( a1.xy, h.z );
vec3 p3 = vec3( a1.zw, h.w );
// Normalise gradients
vec4 norm = taylorInvSqrt( vec4( dot( p0, p0 ), dot( p1, p1 ), dot( p2, p2 ), dot( p3, p3 ) ) );
p0 *= norm.x;
p1 *= norm.y;
p2 *= norm.z;
p3 *= norm.w;
// Mix final noise value
vec4 m = max( 0.6 - vec4( dot( x0, x0 ), dot( x1, x1 ), dot( x2, x2 ), dot( x3, x3 ) ), 0.0 );
m = m * m;
return 42.0 * dot( m*m, vec4( dot( p0, x0 ), dot( p1, x1 ),
dot( p2, x2 ), dot( p3, x3 ) ) );
}
vec2 snoise2(vec3 pos)
vec4 Uberblend(vec4 col0, vec4 col1)
{
return vec2(snoise(pos), snoise(pos + vec3(0.0, 0.0, 1.0)));
// return vec4((1.0 - col0.a) * (col1.rgb) + col0.a * (col1.rgb * col1.a + col0.rgb * (1.0 - col1.a)), min(1.0, col0.a + col1.a));
// return vec4((1.0 - col1.a) * (col0.rgb) + col1.a * (col1.rgb * col1.a + col0.rgb * (1.0 - col1.a)), min(1.0, col0.a + col1.a));
return vec4(
(1.0 - col0.a) * (1.0 - col1.a) * (col0.rgb * col0.a + col1.rgb * col1.a) / (col0.a + col1.a + 1e-1) +
(1.0 - col0.a) * (0.0 + col1.a) * (col1.rgb) +
(0.0 + col0.a) * (1.0 - col1.a) * (col0.rgb * (1.0 - col1.a) + col1.rgb * col1.a) +
(0.0 + col0.a) * (0.0 + col1.a) * (col1.rgb),
min(1.0, col0.a + col1.a));
}
float GetFireDelta(float currTime, vec2 pos, float freqMult, float stretchMult, float scrollSpeed, float evolutionSpeed)
......@@ -167,7 +90,7 @@ vec4 GetFireBallColor(float currTime, vec2 pos, float freqMult, float stretchMul
verticalPos = min(0.99, verticalPos);
verticalPos = max(0.01, verticalPos);
fireballColor = texture2D(tex, vec2(0.75, verticalPos));
fireballColor = texture2D(tex, 0.5 * vec2(0.75, verticalPos) + vec2(0.5, 0.5));
fireballColor.a = 1.0;
}else
{
......@@ -205,26 +128,237 @@ vec4 GetFireBallColor(float currTime, vec2 pos, float freqMult, float stretchMul
verticalPos = min(0.99, verticalPos);
verticalPos = max(0.01, verticalPos);
fireballColor = texture2D(tex, vec2(0.25, verticalPos));
fireballColor = texture2D(tex, 0.5 * vec2(0.25, verticalPos) + vec2(0.5, 0.5));
}
}
return fireballColor;
}
void main(void)
{
vec2 radius = gl_TexCoord[0].xy - vec2(0.5, 0.5);
vec2 radius = vec2(0.5, 0.5) - gl_TexCoord[0].xy;
float shieldIntensity = 0.1; //physically affects shield layer thickness
//radius.x *= ellispoidalFactor; //for simple ellipsoid
//comment next line for regular spherical shield
//radius.x *= (1.0 + ellipsoidalFactor) * 0.5 + (ellipsoidalFactor - 1.0) * 0.5 * pow(cos(tick / time_factor * oscillationSpeed), 2.0);
//on-hit wobbling effect
float coreEndTime = 0.6;
float outerSphereStartTime = 0.2;
float outerSphereEndTime = 0.6; //0.38
float debrisStartTime = 0.2;
/*float coreEndTime = 0.3;
float outerSphereStartTime = 0.15;
float outerSphereEndTime = 0.4; //0.38
float debrisStartTime = 0.15;*/
float outerSphereIntensity = 1.5;
float radiusLen = length(radius);
float ballRadius = 0.1;
float coronaWidth = 0.05;
vec4 c;
c = GetFireBallColor(tick / time_factor + 0.0 , radius, 6.0, 15.0, 1.0, 2.9, ballRadius, ballRadius + coronaWidth, vec2(1.0, 0.0), 0.75);
c.a *= gl_Color.a;
float antialiasingCoef = 1.0;
gl_FragColor = c;
vec4 sphereColor = vec4(0.0, 0.0, 0.0, 0.0);
float phase = clamp((tick - tick_start) / explosion_time_factor, 0.0, 1.0);
if(is_exploding < 0.5)
phase = 0;
float innerSpherePhase = clamp(phase / coreEndTime, 0.0, 1.0);
//vec3 color = clamp(gl_Color.rgb * (1.0 + pow(innerSpherePhase, 2.0) * 10.0), 0.0, 1.0);
float projectileRadius = 0.1;
float coronaWidth = 0.05;
float radiusScale = (1.0 - pow(1.0 - innerSpherePhase, 5.0));
float innerSphereRadius = 0.3 * radiusScale + projectileRadius * (1.0 - radiusScale);
vec4 projectileColor = GetFireBallColor(tick / projectile_time_factor + 0.0 , radius, 6.0, 15.0, 1.0, 2.9, innerSphereRadius, innerSphereRadius + coronaWidth * (1.0 - radiusScale), vec2(1.0, 0.0), 0.75);
vec4 resultColor;
if(phase > 0.0)
{
float sinAlpha = radiusLen / innerSphereRadius;
float alpha = 0.0;
if(sinAlpha > 1.0)
{
sphereColor = vec4(0.0, 0.0, 0.0, 0.0);
}else
{
if(sinAlpha > antialiasingRadius)
{
antialiasingCoef = (1.0 - sinAlpha) / (1.0 - antialiasingRadius);
}
alpha = asin(sinAlpha);
vec2 sphericalProjectedCoord = vec2(0.5, 0.5) + radius * (alpha / (3.141592 / 2.0)) / radiusLen;
vec4 blackColor = projectileColor;//vec4(0.0, 0.0, 0.0, 1.0);
float fracturePhase = innerSpherePhase;
vec2 texCoord = sphericalProjectedCoord * 0.6;
texCoord.x = mod(texCoord.x, 0.995) * 0.5;
texCoord.y = mod(texCoord.y, 0.995) * 0.5;
vec4 fractureColor = texture2D(tex, texCoord);
float phaseSubstraction = (1.0 - fracturePhase) * 0.5;
float fractureShininess = 0.2 + clamp((fractureColor.a - phaseSubstraction) / (1.0 - phaseSubstraction + 0.1), 0.0, 1.0) * (0.5 + fracturePhase * 130.0);
float resultShininess = fractureShininess * shieldIntensity / cos(alpha);
sphereColor = blackColor + vec4(fractureColor.rgb * resultShininess, 0.0);
sphereColor.a *= min(1.0, sphereColor.a) * antialiasingCoef;
}
float rayPhase = clamp(innerSpherePhase * 2.5 + 0.2, 0.0, 1.0);
vec2 raysTexPos = (clamp(radius / (radiusScale + 1e-5) + vec2(0.5, 0.5), 0.01, 0.99)) * vec2(0.5, 0.5) + vec2(0.5, 0.0);
vec4 raysTexColor = texture2D(tex, raysTexPos);
float raysSubtraction = (1.0 - rayPhase) * 1.0;
vec4 raysColor = vec4(raysTexColor.rgb, clamp((raysTexColor.a - raysSubtraction) / (1.0 - raysSubtraction) * (0.5 + rayPhase * 2.0), 0.0, 1.0));
vec4 coreColor = Uberblend(projectileColor, Uberblend(sphereColor, raysColor));
vec4 debrisColor = vec4(0.0, 0.0, 0.0, 0.0);
float debrisPhase = clamp((phase - debrisStartTime) / (1.0 - debrisStartTime), 0.0, 1.0);
if(debrisPhase > 0.0)
{
float debrisSize = 0.5 + (1.0 - pow(1.0 - debrisPhase, 2.0)) * 0.5;
vec2 debrisTexPos = (clamp(radius / (debrisSize + 1e-3) + vec2(0.5, 0.5), 0.01, 0.99)) * vec2(0.5, 0.5) + vec2(0.0, 0.5);
debrisColor = texture2D(tex, debrisTexPos);
float debrisIntensity = (1.0 - pow(debrisPhase, 2.0)) * 0.5;
float debrisSubtraction = pow(debrisPhase, 5.0);
debrisColor.a = clamp((debrisColor.a - debrisSubtraction) / (1.0 - debrisSubtraction) * debrisIntensity * 5.0, 0.0, 1.0);
}
float outerSpherePhase = clamp((phase - outerSphereStartTime) / (outerSphereEndTime - outerSphereStartTime), 0.0, 1.0);
vec4 outerSphereColor = vec4(0.0, 0.0, 0.0, 0.0);
if(outerSpherePhase > 0)
{
float outerSphereRadius = innerSphereRadius + (0.5 - innerSphereRadius) * outerSpherePhase;
float sinAlpha = radiusLen / outerSphereRadius;
float alpha = 0.0;
if(sinAlpha < 1.0)
{
antialiasingCoef = 1.0;
if(sinAlpha > antialiasingRadius)
{
antialiasingCoef = (1.0 - sinAlpha) / (1.0 - antialiasingRadius);
}
alpha = asin(sinAlpha);
vec2 sphericalProjectedCoord = vec2(0.5, 0.5) + radius * (alpha / (3.141592 / 2.0)) / radiusLen;
vec2 texCoord = sphericalProjectedCoord * 0.6;
texCoord.x = (mod(texCoord.x, 0.99) + 0.005) * 0.5;// + 0.505;
texCoord.y = (mod(texCoord.y, 0.99) + 0.005) * 0.5;// + 0.505;
vec4 outerSphereTexColor = texture2D(tex, texCoord);
outerSphereColor = vec4(outerSphereTexColor.rgb * 10.0, 1.0 - exp(-5.0 * outerSphereTexColor.a * shieldIntensity / cos(alpha)));
outerSphereColor.a *= antialiasingCoef;
outerSphereColor.a *= 1.0 - pow(outerSpherePhase, 1.0);
}
float coreTransperency = pow(1.0 - outerSpherePhase, 2.0);
coreColor.a *= coreTransperency;
}
resultColor = debrisColor;
resultColor = Uberblend(resultColor, coreColor);
resultColor = Uberblend(resultColor, outerSphereColor);
}else
{
resultColor = projectileColor;
}
gl_FragColor = resultColor;
}
vec4 permute( vec4 x ) {
return mod( ( ( x * 34.0 ) + 1.0 ) * x, 289.0 );
}
vec4 taylorInvSqrt( vec4 r ) {
return 1.79284291400159 - 0.85373472095314 * r;
}
float snoise( vec3 v ) {
const vec2 C = vec2( 1.0 / 6.0, 1.0 / 3.0 );
const vec4 D = vec4( 0.0, 0.5, 1.0, 2.0 );
// First corner
vec3 i = floor( v + dot( v, C.yyy ) );
vec3 x0 = v - i + dot( i, C.xxx );
// Other corners
vec3 g = step( x0.yzx, x0.xyz );
vec3 l = 1.0 - g;
vec3 i1 = min( g.xyz, l.zxy );
vec3 i2 = max( g.xyz, l.zxy );
vec3 x1 = x0 - i1 + 1.0 * C.xxx;
vec3 x2 = x0 - i2 + 2.0 * C.xxx;
vec3 x3 = x0 - 1. + 3.0 * C.xxx;
// Permutations
i = mod( i, 289.0 );
vec4 p = permute( permute( permute(
i.z + vec4( 0.0, i1.z, i2.z, 1.0 ) )
+ i.y + vec4( 0.0, i1.y, i2.y, 1.0 ) )
+ i.x + vec4( 0.0, i1.x, i2.x, 1.0 ) );
// Gradients
// ( N*N points uniformly over a square, mapped onto an octahedron.)
float n_ = 1.0 / 7.0; // N=7
vec3 ns = n_ * D.wyz - D.xzx;
vec4 j = p - 49.0 * floor( p * ns.z *ns.z ); // mod(p,N*N)
vec4 x_ = floor( j * ns.z );
vec4 y_ = floor( j - 7.0 * x_ ); // mod(j,N)
vec4 x = x_ *ns.x + ns.yyyy;
vec4 y = y_ *ns.x + ns.yyyy;
vec4 h = 1.0 - abs( x ) - abs( y );
vec4 b0 = vec4( x.xy, y.xy );
vec4 b1 = vec4( x.zw, y.zw );
vec4 s0 = floor( b0 ) * 2.0 + 1.0;
vec4 s1 = floor( b1 ) * 2.0 + 1.0;
vec4 sh = -step( h, vec4( 0.0 ) );
vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;
vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;
vec3 p0 = vec3( a0.xy, h.x );
vec3 p1 = vec3( a0.zw, h.y );
vec3 p2 = vec3( a1.xy, h.z );
vec3 p3 = vec3( a1.zw, h.w );
// Normalise gradients
vec4 norm = taylorInvSqrt( vec4( dot( p0, p0 ), dot( p1, p1 ), dot( p2, p2 ), dot( p3, p3 ) ) );
p0 *= norm.x;
p1 *= norm.y;
p2 *= norm.z;
p3 *= norm.w;
// Mix final noise value
vec4 m = max( 0.6 - vec4( dot( x0, x0 ), dot( x1, x1 ), dot( x2, x2 ), dot( x3, x3 ) ), 0.0 );
m = m * m;
return 42.0 * dot( m*m, vec4( dot( p0, x0 ), dot( p1, x1 ),
dot( p2, x2 ), dot( p3, x3 ) ) );
}
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009 - 2014 Nicolas Casalini
-- 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
......@@ -22,10 +22,8 @@ return {
vert = nil,
args = {
tex = { texture = 0 },
color = color or {0.4, 0.7, 1.0},
time_factor = time_factor or 4000,
ellipsoidalFactor = ellipsoidalFactor or 1.0, --1 is perfect circle, >1 is ellipsoidal
oscillationSpeed = oscillationSpeed or 0.0, --oscillation between ellipsoidal and spherical form
projectile_time_factor = time_factor or 2000,
explosion_time_factor = explosion_time_factor or 1000,
is_exploding = 0,
},
clone = false,
}
-- 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 = "fireball",
vert = nil,
args = {
tex = { texture = 0 },
projectile_time_factor = time_factor or 2000,
explosion_time_factor = explosion_time_factor or 1200,
is_exploding = is_exploding or 1,
},
resetargs = {
tick_start = function() return core.game.getFrameTime() end,
},
}
......@@ -140,7 +140,7 @@ newTalent{
direct_hit = true,
requires_target = true,
target = function(self, t)
return {type="ball", range=self:getTalentRange(t), radius=self:getTalentRadius(t), selffire=self:spellFriendlyFire(), talent=t, display={particle="bolt_fire", trail="firetrail"}, sound_stop="talents/fireflash"}
return {type="ball", range=self:getTalentRange(t), radius=self:getTalentRadius(t), selffire=self:spellFriendlyFire(), talent=t, display={particle="bolt_fire", particle_args={size_factor=1.5}}, sound_stop="talents/fireflash"}
end,
getDamage = function(self, t) return self:combatTalentSpellDamage(t, 28, 280) end,
action = function(self, t)
......@@ -148,7 +148,7 @@ newTalent{
local x, y = self:getTarget(tg)
if not x or not y then return nil end
self:projectile(tg, x, y, DamageType.FIRE, self:spellCrit(t.getDamage(self, t)), function(self, tg, x, y, grids)
game.level.map:particleEmitter(x, y, tg.radius, "fireflash", {radius=tg.radius, tx=x, ty=y})
game.level.map:particleEmitter(x, y, tg.radius, "fireflash", {radius=tg.radius, proj_x=x, proj_y=y, src_x=self.x, src_y=self.y})
if self:attr("burning_wake") then
game.level.map:addEffect(self,
x, y, 4,
......
......@@ -589,6 +589,16 @@ function _M:orderPing(o)
self.server_latency = lat
end
function _M:orderAddFriend(o)
self:command("FRND", "ADD", o.id)
self:read("200")
end
function _M:orderRemoveFriend(o)
self:command("FRND", "DEL", o.id)
self:read("200")
end
function _M:orderFunFactsGrab(o)
if self.funfacts then
cprofile.pushEvent(string.format("e='FunFacts' data=%q", self.funfacts))
......
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