From a93fd722f31f37268f145af5426dc2753f620442 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Mon, 6 Sep 2010 19:35:56 +0000
Subject: [PATCH] When finding lore items they register in the combat log Added
 trails based on damage type to the Channel Staff spell, made it intoa real
 projectile and uses spell crit instead of physical crit

git-svn-id: http://svn.net-core.org/repos/t-engine4@1158 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Player.lua            |  1 +
 .../tome/class/interface/PlayerLore.lua       |  3 +
 .../tome/data/gfx/particles/acidtrail.lua     | 56 +++++++++++++++++++
 .../tome/data/gfx/particles/bolt_acid.lua     | 51 +++++++++++++++++
 .../tome/data/gfx/particles/bolt_dark.lua     | 51 +++++++++++++++++
 .../tome/data/gfx/particles/bolt_light.lua    | 51 +++++++++++++++++
 .../data/gfx/particles/bolt_lightning.lua     | 51 +++++++++++++++++
 .../tome/data/gfx/particles/darktrail.lua     | 56 +++++++++++++++++++
 .../tome/data/gfx/particles/icetrail.lua      | 56 +++++++++++++++++++
 .../data/gfx/particles/lightningtrail.lua     | 56 +++++++++++++++++++
 .../tome/data/gfx/particles/lighttrail.lua    | 56 +++++++++++++++++++
 .../tome/data/talents/spells/staff-combat.lua | 39 +++++++++----
 12 files changed, 515 insertions(+), 12 deletions(-)
 create mode 100644 game/modules/tome/data/gfx/particles/acidtrail.lua
 create mode 100644 game/modules/tome/data/gfx/particles/bolt_acid.lua
 create mode 100644 game/modules/tome/data/gfx/particles/bolt_dark.lua
 create mode 100644 game/modules/tome/data/gfx/particles/bolt_light.lua
 create mode 100644 game/modules/tome/data/gfx/particles/bolt_lightning.lua
 create mode 100644 game/modules/tome/data/gfx/particles/darktrail.lua
 create mode 100644 game/modules/tome/data/gfx/particles/icetrail.lua
 create mode 100644 game/modules/tome/data/gfx/particles/lightningtrail.lua
 create mode 100644 game/modules/tome/data/gfx/particles/lighttrail.lua

diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua
index a7f6a6f9fb..f73484259d 100644
--- a/game/modules/tome/class/Player.lua
+++ b/game/modules/tome/class/Player.lua
@@ -378,6 +378,7 @@ function _M:restCheck()
 		if self:getMana() < self:getMaxMana() and self.mana_regen > 0 then return true end
 		if self:getStamina() < self:getMaxStamina() and self.stamina_regen > 0 then return true end
 		if self.life < self.max_life and self.life_regen> 0 then return true end
+		if self.alchemy_golem and game.level:hasEntity(self.alchemy_golem) and self.alchemy_golem.life_regen > 0 and not self.alchemy_golem.dead and self.alchemy_golem.life < self.alchemy_golem.max_life then return true end
 	else
 		return true
 	end
diff --git a/game/modules/tome/class/interface/PlayerLore.lua b/game/modules/tome/class/interface/PlayerLore.lua
index ad1de5dc46..93b30916f6 100644
--- a/game/modules/tome/class/interface/PlayerLore.lua
+++ b/game/modules/tome/class/interface/PlayerLore.lua
@@ -61,6 +61,9 @@ function _M:learnLore(lore)
 	if not self.lore_known[lore] then
 		local l = self:getLore(lore)
 		Dialog:simpleLongPopup("Lore found: #0080FF#"..l.name, "#ANTIQUE_WHITE#"..l.lore, 400)
+		game.logPlayer(self, "Lore found: #0080FF#%s", l.name)
+		game.logPlayer(self, "#ANTIQUE_WHITE#%s", l.lore)
+		game.logPlayer(self, "You can read all your collected lore in tha game menu, by pressing Escape.")
 	end
 
 	self.lore_known[lore] = true
diff --git a/game/modules/tome/data/gfx/particles/acidtrail.lua b/game/modules/tome/data/gfx/particles/acidtrail.lua
new file mode 100644
index 0000000000..8a1f268001
--- /dev/null
+++ b/game/modules/tome/data/gfx/particles/acidtrail.lua
@@ -0,0 +1,56 @@
+-- ToME - Tales of Middle-Earth
+-- Copyright (C) 2009, 2010 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
+
+local nb = 0
+
+return { generator = function()
+	local radius = 0
+	local sradius = (radius + 0.5) * (engine.Map.tile_w + engine.Map.tile_h) / 2
+	local ad = rng.float(0, 360)
+	local a = math.rad(ad)
+	local r = rng.float(0.1, sradius / 2)
+	local x = r * math.cos(a)
+	local y = r * math.sin(a)
+	local bx = math.floor(x / engine.Map.tile_w)
+	local by = math.floor(y / engine.Map.tile_h)
+	local static = rng.percent(40)
+
+	return {
+		trail = 1,
+		life = 3 + 9 * (sradius - r) / sradius,
+		size = 3, sizev = 0, sizea = 0,
+
+		x = x, xv = 0, xa = 0,
+		y = y, yv = 0, ya = 0,
+		dir = 0, dirv = 0, dira = 0,
+		vel = 0, velv = 0, vela = 0,
+
+		r = rng.range(0, 0)/255,   rv = 0, ra = 0,
+		g = rng.range(80, 200)/255,   gv = 0.005, ga = 0.0005,
+		b = rng.range(0, 0)/255,      bv = 0, ba = 0,
+		a = rng.range(255, 255)/255,    av = static and -0.034 or 0, aa = 0.005,
+	}
+end, },
+function(self)
+	if nb < 1 then
+		self.ps:emit(40)
+	end
+	nb = nb + 1
+end,
+40
diff --git a/game/modules/tome/data/gfx/particles/bolt_acid.lua b/game/modules/tome/data/gfx/particles/bolt_acid.lua
new file mode 100644
index 0000000000..b76742f6e8
--- /dev/null
+++ b/game/modules/tome/data/gfx/particles/bolt_acid.lua
@@ -0,0 +1,51 @@
+-- ToME - Tales of Middle-Earth
+-- Copyright (C) 2009, 2010 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 { generator = function()
+	local radius = 0
+	local sradius = (radius + 0.5) * (engine.Map.tile_w + engine.Map.tile_h) / 2
+	local ad = rng.float(0, 360)
+	local a = math.rad(ad)
+	local r = rng.float(0, sradius / 4)
+	local x = r * math.cos(a)
+	local y = r * math.sin(a)
+	local bx = math.floor(x / engine.Map.tile_w)
+	local by = math.floor(y / engine.Map.tile_h)
+	local static = rng.percent(40)
+
+	return {
+		trail = 1,
+		life = 6,
+		size = 3, sizev = 0, sizea = 0,
+
+		x = x, xv = 0, xa = 0,
+		y = y, yv = 0, ya = 0,
+		dir = a, dirv = 0, dira = 0,
+		vel = sradius / 2 / 6, velv = 0, vela = 0,
+
+		r = rng.range(0, 0)/255,   rv = 0, ra = 0,
+		g = rng.range(80, 200)/255,   gv = 0.005, ga = 0.0005,
+		b = rng.range(0, 0)/255,      bv = 0, ba = 0,
+		a = rng.range(255, 255)/255,    av = static and -0.034 or 0, aa = 0.005,
+	}
+end, },
+function(self)
+	self.ps:emit(30)
+end,
+30*6
diff --git a/game/modules/tome/data/gfx/particles/bolt_dark.lua b/game/modules/tome/data/gfx/particles/bolt_dark.lua
new file mode 100644
index 0000000000..b11791e0c6
--- /dev/null
+++ b/game/modules/tome/data/gfx/particles/bolt_dark.lua
@@ -0,0 +1,51 @@
+-- ToME - Tales of Middle-Earth
+-- Copyright (C) 2009, 2010 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 { generator = function()
+	local radius = 0
+	local sradius = (radius + 0.5) * (engine.Map.tile_w + engine.Map.tile_h) / 2
+	local ad = rng.float(0, 360)
+	local a = math.rad(ad)
+	local r = rng.float(0, sradius / 4)
+	local x = r * math.cos(a)
+	local y = r * math.sin(a)
+	local bx = math.floor(x / engine.Map.tile_w)
+	local by = math.floor(y / engine.Map.tile_h)
+	local static = rng.percent(40)
+
+	return {
+		trail = 1,
+		life = 6,
+		size = 3, sizev = 0, sizea = 0,
+
+		x = x, xv = 0, xa = 0,
+		y = y, yv = 0, ya = 0,
+		dir = a, dirv = 0, dira = 0,
+		vel = sradius / 2 / 6, velv = 0, vela = 0,
+
+		r = rng.range(0, 40)/255,   rv = 0, ra = 0,
+		g = rng.range(0, 40)/255,   gv = 0.005, ga = 0.0005,
+		b = rng.range(0, 40)/255,      bv = 0, ba = 0,
+		a = rng.range(255, 255)/255,    av = static and -0.034 or 0, aa = 0.005,
+	}
+end, },
+function(self)
+	self.ps:emit(30)
+end,
+30*6
diff --git a/game/modules/tome/data/gfx/particles/bolt_light.lua b/game/modules/tome/data/gfx/particles/bolt_light.lua
new file mode 100644
index 0000000000..d353ae64e5
--- /dev/null
+++ b/game/modules/tome/data/gfx/particles/bolt_light.lua
@@ -0,0 +1,51 @@
+-- ToME - Tales of Middle-Earth
+-- Copyright (C) 2009, 2010 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 { generator = function()
+	local radius = 0
+	local sradius = (radius + 0.5) * (engine.Map.tile_w + engine.Map.tile_h) / 2
+	local ad = rng.float(0, 360)
+	local a = math.rad(ad)
+	local r = rng.float(0, sradius / 4)
+	local x = r * math.cos(a)
+	local y = r * math.sin(a)
+	local bx = math.floor(x / engine.Map.tile_w)
+	local by = math.floor(y / engine.Map.tile_h)
+	local static = rng.percent(40)
+
+	return {
+		trail = 1,
+		life = 6,
+		size = 3, sizev = 0, sizea = 0,
+
+		x = x, xv = 0, xa = 0,
+		y = y, yv = 0, ya = 0,
+		dir = a, dirv = 0, dira = 0,
+		vel = sradius / 2 / 6, velv = 0, vela = 0,
+
+		r = rng.range(220, 255)/255,  rv = 0, ra = 0,
+		g = rng.range(200, 230)/255,  gv = 0, ga = 0,
+		b = 0,                        bv = 0, ba = 0,
+		a = rng.range(25, 220)/255,   av = 0, aa = 0,
+	}
+end, },
+function(self)
+	self.ps:emit(30)
+end,
+30*6
diff --git a/game/modules/tome/data/gfx/particles/bolt_lightning.lua b/game/modules/tome/data/gfx/particles/bolt_lightning.lua
new file mode 100644
index 0000000000..43dba88e11
--- /dev/null
+++ b/game/modules/tome/data/gfx/particles/bolt_lightning.lua
@@ -0,0 +1,51 @@
+-- ToME - Tales of Middle-Earth
+-- Copyright (C) 2009, 2010 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 { generator = function()
+	local radius = 0
+	local sradius = (radius + 0.5) * (engine.Map.tile_w + engine.Map.tile_h) / 2
+	local ad = rng.float(0, 360)
+	local a = math.rad(ad)
+	local r = rng.float(0, sradius / 4)
+	local x = r * math.cos(a)
+	local y = r * math.sin(a)
+	local bx = math.floor(x / engine.Map.tile_w)
+	local by = math.floor(y / engine.Map.tile_h)
+	local static = rng.percent(40)
+
+	return {
+		trail = 1,
+		life = 6,
+		size = 3, sizev = 0, sizea = 0,
+
+		x = x, xv = 0, xa = 0,
+		y = y, yv = 0, ya = 0,
+		dir = a, dirv = 0, dira = 0,
+		vel = sradius / 2 / 6, velv = 0, vela = 0,
+
+		r = rng.range(180, 220)/255,  rv = 0, ra = 0,
+		g = rng.range(240, 255)/255,  gv = 0, ga = 0,
+		b = rng.range(220, 240)/255,  bv = 0, ba = 0,
+		a = rng.range(255, 255)/255,  av = 0, aa = 0,
+	}
+end, },
+function(self)
+	self.ps:emit(30)
+end,
+30*6
diff --git a/game/modules/tome/data/gfx/particles/darktrail.lua b/game/modules/tome/data/gfx/particles/darktrail.lua
new file mode 100644
index 0000000000..a9de0633ac
--- /dev/null
+++ b/game/modules/tome/data/gfx/particles/darktrail.lua
@@ -0,0 +1,56 @@
+-- ToME - Tales of Middle-Earth
+-- Copyright (C) 2009, 2010 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
+
+local nb = 0
+
+return { generator = function()
+	local radius = 0
+	local sradius = (radius + 0.5) * (engine.Map.tile_w + engine.Map.tile_h) / 2
+	local ad = rng.float(0, 360)
+	local a = math.rad(ad)
+	local r = rng.float(0.1, sradius / 2)
+	local x = r * math.cos(a)
+	local y = r * math.sin(a)
+	local bx = math.floor(x / engine.Map.tile_w)
+	local by = math.floor(y / engine.Map.tile_h)
+	local static = rng.percent(40)
+
+	return {
+		trail = 1,
+		life = 3 + 9 * (sradius - r) / sradius,
+		size = 3, sizev = 0, sizea = 0,
+
+		x = x, xv = 0, xa = 0,
+		y = y, yv = 0, ya = 0,
+		dir = 0, dirv = 0, dira = 0,
+		vel = 0, velv = 0, vela = 0,
+
+		r = rng.range(0, 40)/255,   rv = 0, ra = 0,
+		g = rng.range(0, 40)/255,   gv = 0.005, ga = 0.0005,
+		b = rng.range(0, 40)/255,      bv = 0, ba = 0,
+		a = rng.range(255, 255)/255,    av = static and -0.034 or 0, aa = 0.005,
+	}
+end, },
+function(self)
+	if nb < 1 then
+		self.ps:emit(40)
+	end
+	nb = nb + 1
+end,
+40
diff --git a/game/modules/tome/data/gfx/particles/icetrail.lua b/game/modules/tome/data/gfx/particles/icetrail.lua
new file mode 100644
index 0000000000..95d74ea0cf
--- /dev/null
+++ b/game/modules/tome/data/gfx/particles/icetrail.lua
@@ -0,0 +1,56 @@
+-- ToME - Tales of Middle-Earth
+-- Copyright (C) 2009, 2010 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
+
+local nb = 0
+
+return { generator = function()
+	local radius = 0
+	local sradius = (radius + 0.5) * (engine.Map.tile_w + engine.Map.tile_h) / 2
+	local ad = rng.float(0, 360)
+	local a = math.rad(ad)
+	local r = rng.float(0.1, sradius / 2)
+	local x = r * math.cos(a)
+	local y = r * math.sin(a)
+	local bx = math.floor(x / engine.Map.tile_w)
+	local by = math.floor(y / engine.Map.tile_h)
+	local static = rng.percent(40)
+
+	return {
+		trail = 1,
+		life = 3 + 9 * (sradius - r) / sradius,
+		size = 3, sizev = 0, sizea = 0,
+
+		x = x, xv = 0, xa = 0,
+		y = y, yv = 0, ya = 0,
+		dir = 0, dirv = 0, dira = 0,
+		vel = 0, velv = 0, vela = 0,
+
+		r = 0,   rv = 0, ra = 0,
+		g = rng.range(170, 210)/255,   gv = 0, ga = 0,
+		b = rng.range(200, 255)/255,   gv = 0, ga = 0,
+		a = rng.range(230, 225)/255,   av = 0, aa = 0,
+	}
+end, },
+function(self)
+	if nb < 1 then
+		self.ps:emit(40)
+	end
+	nb = nb + 1
+end,
+40
diff --git a/game/modules/tome/data/gfx/particles/lightningtrail.lua b/game/modules/tome/data/gfx/particles/lightningtrail.lua
new file mode 100644
index 0000000000..5bb45fbf9d
--- /dev/null
+++ b/game/modules/tome/data/gfx/particles/lightningtrail.lua
@@ -0,0 +1,56 @@
+-- ToME - Tales of Middle-Earth
+-- Copyright (C) 2009, 2010 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
+
+local nb = 0
+
+return { generator = function()
+	local radius = 0
+	local sradius = (radius + 0.5) * (engine.Map.tile_w + engine.Map.tile_h) / 2
+	local ad = rng.float(0, 360)
+	local a = math.rad(ad)
+	local r = rng.float(0.1, sradius / 2)
+	local x = r * math.cos(a)
+	local y = r * math.sin(a)
+	local bx = math.floor(x / engine.Map.tile_w)
+	local by = math.floor(y / engine.Map.tile_h)
+	local static = rng.percent(40)
+
+	return {
+		trail = 1,
+		life = 3 + 9 * (sradius - r) / sradius,
+		size = 3, sizev = 0, sizea = 0,
+
+		x = x, xv = 0, xa = 0,
+		y = y, yv = 0, ya = 0,
+		dir = 0, dirv = 0, dira = 0,
+		vel = 0, velv = 0, vela = 0,
+
+		r = rng.range(180, 220)/255,  rv = 0, ra = 0,
+		g = rng.range(240, 255)/255,  gv = 0, ga = 0,
+		b = rng.range(220, 240)/255,  bv = 0, ba = 0,
+		a = rng.range(255, 255)/255,  av = 0, aa = 0,
+	}
+end, },
+function(self)
+	if nb < 1 then
+		self.ps:emit(40)
+	end
+	nb = nb + 1
+end,
+40
diff --git a/game/modules/tome/data/gfx/particles/lighttrail.lua b/game/modules/tome/data/gfx/particles/lighttrail.lua
new file mode 100644
index 0000000000..f12c010289
--- /dev/null
+++ b/game/modules/tome/data/gfx/particles/lighttrail.lua
@@ -0,0 +1,56 @@
+-- ToME - Tales of Middle-Earth
+-- Copyright (C) 2009, 2010 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
+
+local nb = 0
+
+return { generator = function()
+	local radius = 0
+	local sradius = (radius + 0.5) * (engine.Map.tile_w + engine.Map.tile_h) / 2
+	local ad = rng.float(0, 360)
+	local a = math.rad(ad)
+	local r = rng.float(0.1, sradius / 2)
+	local x = r * math.cos(a)
+	local y = r * math.sin(a)
+	local bx = math.floor(x / engine.Map.tile_w)
+	local by = math.floor(y / engine.Map.tile_h)
+	local static = rng.percent(40)
+
+	return {
+		trail = 1,
+		life = 3 + 9 * (sradius - r) / sradius,
+		size = 3, sizev = 0, sizea = 0,
+
+		x = x, xv = 0, xa = 0,
+		y = y, yv = 0, ya = 0,
+		dir = 0, dirv = 0, dira = 0,
+		vel = 0, velv = 0, vela = 0,
+
+		r = rng.range(220, 255)/255,  rv = 0, ra = 0,
+		g = rng.range(200, 230)/255,  gv = 0, ga = 0,
+		b = 0,                        bv = 0, ba = 0,
+		a = rng.range(25, 220)/255,   av = 0, aa = 0,
+	}
+end, },
+function(self)
+	if nb < 1 then
+		self.ps:emit(40)
+	end
+	nb = nb + 1
+end,
+40
diff --git a/game/modules/tome/data/talents/spells/staff-combat.lua b/game/modules/tome/data/talents/spells/staff-combat.lua
index ebefca896a..3aef35ddeb 100644
--- a/game/modules/tome/data/talents/spells/staff-combat.lua
+++ b/game/modules/tome/data/talents/spells/staff-combat.lua
@@ -28,31 +28,46 @@ newTalent{
 	},
 	range = 10,
 	reflectable = true,
+	proj_speed = 20,
 	action = function(self, t)
 		local weapon = self:hasStaffWeapon()
 		if not weapon then
 			game.logPlayer(self, "You need a staff to use this spell.")
 			return
 		end
+		local combat = weapon.combat
 
-		local tg = {type="bolt", range=self:getTalentRange(t), talent=t}
-		local x, y, target = self:getTarget(tg)
-		if not x or not y or not target then return nil end
-		local _ _, x, y = self:canProject(tg, x, y)
-		target = game.level.map(x, y, Map.ACTOR)
-		if not x or not y or not target then return nil end
+		local trail = "firetrail"
+		local particle = "bolt_fire"
+		local explosion = "flame"
+
+		if     combat.damtype == DamageType.COLD then      explosion = "freeze"              particle = "ice_shards"     trail = "icetrail"
+		elseif combat.damtype == DamageType.ACID then      explosion = "acid"                particle = "bolt_acid"      trail = "acidtrail"
+		elseif combat.damtype == DamageType.LIGHTNING then explosion = "lightning_explosion" particle = "bolt_lightning" trail = "lightningtrail"
+		elseif combat.damtype == DamageType.LIGHT then     explosion = "light"               particle = "bolt_light"     trail = "lighttrail"
+		elseif combat.damtype == DamageType.DARKNESS then  explosion = "dark"                particle = "bolt_dark"      trail = "darktrail"
+		elseif combat.damtype == DamageType.NATURE then    explosion = "slime"               particle = "bolt_slime"     trail = "slimetrail"
+		elseif combat.damtype == DamageType.BLIGHT then    explosion = "slime"               particle = "bolt_slime"     trail = "slimetrail"
+		end
+
+		-- Compute damage
+		local dam = self:combatDamage(combat)
+		local damrange = self:combatDamageRange(combat)
+		dam = rng.range(dam, dam * damrange)
+		dam = self:spellCrit(dam)
+		dam = dam * self:combatTalentWeaponDamage(t, 0.4, 1.1)
+
+		local tg = {type="bolt", range=self:getTalentRange(t), talent=t, display = {particle=particle, trail=trail}}
+		local x, y = self:getTarget(tg)
+		if not x or not y then return nil end
+		self:projectile(tg, x, y, combat.damtype, dam, {type=explosion})
 
-		self.combat_apr = self.combat_apr + 10000
-		self.combat_atk = self.combat_atk + 10000
-		local speed, hit = self:attackTargetWith(target, weapon.combat, nil, self:combatTalentWeaponDamage(t, 0.4, 1.1))
-		self.combat_atk = self.combat_atk - 10000
-		self.combat_apr = self.combat_apr - 10000
 		game:playSoundNear(self, "talents/arcane")
 		return true
 	end,
 	info = function(self, t)
 		return ([[Channel raw mana through your staff, projecting a bolt of your staff damage type doing %d%% staff damage.
-		This attack always has a 95%% chance to hit and ignores target armour.]]):
+		This attack always has a 100%% chance to hit and ignores target armour.]]):
 		format(self:combatTalentWeaponDamage(t, 0.4, 1.1) * 100)
 	end,
 }
-- 
GitLab