From 0d7b491cdc35763386b53eb6d869f8fad2808dac Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Tue, 21 Sep 2010 13:45:56 +0000
Subject: [PATCH] Added gloves/gauntlets and egos relating to them

git-svn-id: http://svn.net-core.org/repos/t-engine4@1272 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Actor.lua             |  12 +-
 game/modules/tome/class/Object.lua            |   4 +
 game/modules/tome/class/Trap.lua              |   2 +-
 game/modules/tome/class/interface/Combat.lua  |   2 +-
 .../modules/tome/data/chats/zemekkys-done.lua |  29 +++
 .../tome/data/general/objects/egos/gloves.lua | 171 ++++++++++++++++++
 .../tome/data/general/objects/gauntlets.lua   |  65 +++++++
 .../tome/data/general/objects/gloves.lua      |  64 +++++++
 .../tome/data/general/objects/objects.lua     |   3 +-
 src/main.c                                    |  41 +++++
 10 files changed, 384 insertions(+), 9 deletions(-)
 create mode 100644 game/modules/tome/data/chats/zemekkys-done.lua
 create mode 100644 game/modules/tome/data/general/objects/egos/gloves.lua
 create mode 100644 game/modules/tome/data/general/objects/gauntlets.lua
 create mode 100644 game/modules/tome/data/general/objects/gloves.lua

diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index 33fdbb4180..ea06adc5b0 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -616,11 +616,6 @@ function _M:onTakeHit(value, src)
 		end
 	end
 
-	-- Adds hate
-	if src and src.max_hate and src.max_hate > 0 then
-		src.hate = math.min(src.max_hate, src.hate + src.hate_per_kill)
-	end
-
 	-- Achievements
 	if src and src.resolveSource and src:resolveSource().player and value >= 600 then
 		world:gainAchievement("SIZE_MATTERS", src:resolveSource())
@@ -710,6 +705,11 @@ function _M:die(src)
 		t.on_kill(src, t)
 	end
 
+	-- Adds hate
+	if src and src.max_hate and src.max_hate > 0 then
+		src.hate = math.min(src.max_hate, src.hate + src.hate_per_kill)
+	end
+
 	-- Increase vim
 	if src and src.attr and src:attr("vim_on_death") and not self:attr("undead") then src:incVim(src:attr("vim_on_death")) end
 
@@ -1089,7 +1089,7 @@ function _M:postUseTalent(ab, ret)
 	if not ab.no_energy then
 		if ab.type[1]:find("^spell/") then
 			self:useEnergy(game.energy_to_act * self:combatSpellSpeed())
-		elseif ab.type[1]:find("^physical/") then
+		elseif ab.type[1]:find("^technique/") then
 			self:useEnergy(game.energy_to_act * self:combatSpeed())
 		else
 			self:useEnergy()
diff --git a/game/modules/tome/class/Object.lua b/game/modules/tome/class/Object.lua
index ae3a934fae..1ac5a53264 100644
--- a/game/modules/tome/class/Object.lua
+++ b/game/modules/tome/class/Object.lua
@@ -295,6 +295,10 @@ function _M:getTextualDesc()
 		desc[#desc+1] = ("Allows you to breathe in: %s."):format(table.concat(ts, ','))
 	end
 
+	if w.combat_critical_power then desc[#desc+1] = ("Increases critical damage modifier: +%d%%."):format(w.combat_critical_power) end
+
+	if w.disarm_bonus then desc[#desc+1] = ("Increases trap disarming bonus: %d."):format(w.disarm_bonus) end
+
 	if w.combat_physresist then desc[#desc+1] = ("Increases physical save: %s."):format(w.combat_physresist) end
 	if w.combat_spellresist then desc[#desc+1] = ("Increases spell save: %s."):format(w.combat_spellresist) end
 	if w.combat_mentalresist then desc[#desc+1] = ("Increases mental save: %s."):format(w.combat_mentalresist) end
diff --git a/game/modules/tome/class/Trap.lua b/game/modules/tome/class/Trap.lua
index f137d2644a..cdc7db5629 100644
--- a/game/modules/tome/class/Trap.lua
+++ b/game/modules/tome/class/Trap.lua
@@ -54,7 +54,7 @@ function _M:canDisarm(x, y, who)
 
 	-- do we know how to disarm?
 	if who:knowTalent(who.T_TRAP_DISARM) then
-		local power = who:getTalentLevel(who.T_TRAP_DISARM) * who:getCun(25)
+		local power = who:getTalentLevel(who.T_TRAP_DISARM) * who:getCun(25) + (who:attr("disarm_bonus") or 0)
 		if who:checkHit(power, self.disarm_power) then
 			return true
 		end
diff --git a/game/modules/tome/class/interface/Combat.lua b/game/modules/tome/class/interface/Combat.lua
index 8324debeaa..734c1be3d5 100644
--- a/game/modules/tome/class/interface/Combat.lua
+++ b/game/modules/tome/class/interface/Combat.lua
@@ -550,7 +550,7 @@ function _M:physicalCrit(dam, weapon, target)
 
 	print("[PHYS CRIT %]", chance)
 	if rng.percent(chance) then
-		dam = dam * 1.5
+		dam = dam * (1.5 + (self.combat_critical_power or 0))
 		crit = true
 	end
 	return dam, crit
diff --git a/game/modules/tome/data/chats/zemekkys-done.lua b/game/modules/tome/data/chats/zemekkys-done.lua
new file mode 100644
index 0000000000..6e05ea9313
--- /dev/null
+++ b/game/modules/tome/data/chats/zemekkys-done.lua
@@ -0,0 +1,29 @@
+-- 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
+
+newChat{ id="welcome",
+	text = [[What? Ah it is you @playername@.
+I take it you are satisfied with the portal.]],
+	answers = {
+		{"Yes thank you."},
+		{"Whatever."},
+	}
+}
+
+return "welcome"
diff --git a/game/modules/tome/data/general/objects/egos/gloves.lua b/game/modules/tome/data/general/objects/egos/gloves.lua
new file mode 100644
index 0000000000..6c2ac5d51a
--- /dev/null
+++ b/game/modules/tome/data/general/objects/egos/gloves.lua
@@ -0,0 +1,171 @@
+-- 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 Stats = require "engine.interface.ActorStats"
+local DamageType = require "engine.DamageType"
+
+newEntity{
+	name = " of disarming", suffix=true, instant_resolve=true,
+	level_range = {10, 50},
+	rarity = 5,
+	cost = 6,
+	wielder = {
+		disarm_bonus = resolvers.mbonus_material(25, 5, function(e, v) return v * 1.2 end),
+	},
+}
+
+newEntity{
+	name = " of criticals", suffix=true, instant_resolve=true,
+	level_range = {20, 50},
+	rarity = 9,
+	cost = 15,
+	wielder = {
+		combat_spellcrit = resolvers.mbonus_material(15, 5, function(e, v) return v * 1.4 end),
+		combat_physcrit = resolvers.mbonus_material(15, 5, function(e, v) return v * 1.4 end),
+	},
+}
+
+newEntity{
+	name = " of mighty criticals", suffix=true, instant_resolve=true,
+	level_range = {30, 50},
+	rarity = 12,
+	cost = 25,
+	wielder = {
+		combat_critical_power = resolvers.mbonus_material(35, 5, function(e, v) v=v/100 return v * 200, v end),
+	},
+}
+
+newEntity{
+	name = " of attack", suffix=true, instant_resolve=true,
+	level_range = {1, 50},
+	rarity = 5,
+	cost = 5,
+	wielder = {
+		combat_atk = resolvers.mbonus_material(15, 10, function(e, v) return v * 1 end),
+	},
+}
+
+newEntity{
+	name = " of damage", suffix=true, instant_resolve=true,
+	level_range = {10, 50},
+	rarity = 7,
+	cost = 10,
+	wielder = {
+		combat_dam = resolvers.mbonus_material(15, 5, function(e, v) return v * 3 end),
+	},
+}
+
+newEntity{
+	name = "cinder ", prefix=true, instant_resolve=true,
+	level_range = {1, 50},
+	rarity = 3,
+	cost = 5,
+	wielder = {
+		inc_damage={ [DamageType.FIRE] = resolvers.mbonus_material(8, 3, function(e, v) return v * 0.8 end), },
+	},
+}
+
+newEntity{
+	name = "polar ", prefix=true, instant_resolve=true,
+	level_range = {1, 50},
+	rarity = 3,
+	cost = 5,
+	wielder = {
+		inc_damage={ [DamageType.COLD] = resolvers.mbonus_material(8, 3, function(e, v) return v * 0.8 end), },
+	},
+}
+
+newEntity{
+	name = "corrosive ", prefix=true, instant_resolve=true,
+	level_range = {1, 50},
+	rarity = 3,
+	cost = 5,
+	wielder = {
+		inc_damage={ [DamageType.ACID] = resolvers.mbonus_material(8, 3, function(e, v) return v * 0.8 end), },
+	},
+}
+
+newEntity{
+	name = "charged ", prefix=true, instant_resolve=true,
+	level_range = {1, 50},
+	rarity = 3,
+	cost = 5,
+	wielder = {
+		inc_damage={ [DamageType.LIGHTNING] = resolvers.mbonus_material(8, 3, function(e, v) return v * 0.8 end), },
+	},
+}
+
+newEntity{
+	name = "naturalist ", prefix=true, instant_resolve=true,
+	level_range = {1, 50},
+	rarity = 3,
+	cost = 5,
+	wielder = {
+		inc_damage={ [DamageType.NATURE] = resolvers.mbonus_material(8, 3, function(e, v) return v * 0.8 end), },
+	},
+}
+
+newEntity{
+	name = "blighted ", prefix=true, instant_resolve=true,
+	level_range = {1, 50},
+	rarity = 3,
+	cost = 5,
+	wielder = {
+		inc_damage={ [DamageType.BLIGHT] = resolvers.mbonus_material(8, 3, function(e, v) return v * 0.8 end), },
+	},
+}
+
+newEntity{
+	name = "powerful ", prefix=true, instant_resolve=true,
+	level_range = {1, 50},
+	rarity = 3,
+	cost = 5,
+	wielder = {
+		inc_damage={ [DamageType.PYSICAL] = resolvers.mbonus_material(8, 3, function(e, v) return v * 0.8 end), },
+	},
+}
+
+newEntity{
+	name = " of strength (#STATBONUS#)", suffix=true,
+	level_range = {1, 50},
+	rarity = 6,
+	cost = 4,
+	wielder = {
+		inc_stats = { [Stats.STAT_STR] = resolvers.mbonus_material(4, 2, function(e, v) return v * 3 end) },
+	},
+}
+
+newEntity{
+	name = " of dexterity (#STATBONUS#)", suffix=true,
+	level_range = {1, 50},
+	rarity = 6,
+	cost = 4,
+	wielder = {
+		inc_stats = { [Stats.STAT_DEX] = resolvers.mbonus_material(4, 2, function(e, v) return v * 3 end) },
+	},
+}
+
+newEntity{
+	name = " of magic (#STATBONUS#)", suffix=true,
+	level_range = {1, 50},
+	rarity = 6,
+	cost = 4,
+	wielder = {
+		inc_stats = { [Stats.STAT_MAG] = resolvers.mbonus_material(4, 2, function(e, v) return v * 3 end) },
+	},
+}
diff --git a/game/modules/tome/data/general/objects/gauntlets.lua b/game/modules/tome/data/general/objects/gauntlets.lua
new file mode 100644
index 0000000000..4834559626
--- /dev/null
+++ b/game/modules/tome/data/general/objects/gauntlets.lua
@@ -0,0 +1,65 @@
+-- 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 Talents = require "engine.interface.ActorTalents"
+
+newEntity{
+	define_as = "BASE_GAUNTLET",
+	slot = "HANDS",
+	type = "armor", subtype="hands",
+	add_name = " (#ARMOR#)",
+	display = "[", color=colors.UMBER,
+	image = resolvers.image_material("gauntlets", "metal"),
+	require = { talent = { Talents.T_HEAVY_ARMOUR_TRAINING }, },
+	encumber = 1.5,
+	rarity = 9,
+	metallic = true,
+	desc = [[Metal gloves protecting the hands up to the middle of the lower arm.]],
+	egos = "/data/general/objects/egos/gloves.lua", egos_chance = { prefix=resolvers.mbonus(40, 5), suffix=resolvers.mbonus(40, 5) },
+}
+
+newEntity{ base = "BASE_GAUNTLET",
+	name = "iron gauntlets",
+	level_range = {1, 20},
+	cost = 5,
+	material_level = 1,
+	wielder = {
+		combat_armor = 1,
+	},
+}
+
+newEntity{ base = "BASE_GAUNTLET",
+	name = "dwarven-steel gauntlets",
+	level_range = {20, 40},
+	cost = 7,
+	material_level = 3,
+	wielder = {
+		combat_armor = 2,
+	},
+}
+
+newEntity{ base = "BASE_GAUNTLET",
+	name = "mithril gauntlets",
+	level_range = {40, 50},
+	cost = 10,
+	material_level = 5,
+	wielder = {
+		combat_armor = 3,
+	},
+}
diff --git a/game/modules/tome/data/general/objects/gloves.lua b/game/modules/tome/data/general/objects/gloves.lua
new file mode 100644
index 0000000000..0c4b9f8597
--- /dev/null
+++ b/game/modules/tome/data/general/objects/gloves.lua
@@ -0,0 +1,64 @@
+-- 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 Talents = require "engine.interface.ActorTalents"
+
+newEntity{
+	define_as = "BASE_GLOVE",
+	slot = "HANDS",
+	type = "armor", subtype="hands",
+	add_name = " (#ARMOR#)",
+	display = "[", color=colors.UMBER,
+	image = resolvers.image_material("gloves", "leather"),
+	encumber = 1,
+	rarity = 9,
+	metallic = true,
+	desc = [[Light gloves which do not seriously hinder finger movements, while still protecting the hands somewhat.]],
+	egos = "/data/general/objects/egos/gloves.lua", egos_chance = { prefix=resolvers.mbonus(40, 5), suffix=resolvers.mbonus(40, 5) },
+}
+
+newEntity{ base = "BASE_GLOVE",
+	name = "rough leather gloves",
+	level_range = {1, 20},
+	cost = 5,
+	material_level = 1,
+	wielder = {
+		combat_armor = 1,
+	},
+}
+
+newEntity{ base = "BASE_GLOVE",
+	name = "hardened leather gloves",
+	level_range = {20, 40},
+	cost = 7,
+	material_level = 3,
+	wielder = {
+		combat_armor = 2,
+	},
+}
+
+newEntity{ base = "BASE_GLOVE",
+	name = "drakeskin leather gloves",
+	level_range = {40, 50},
+	cost = 10,
+	material_level = 5,
+	wielder = {
+		combat_armor = 3,
+	},
+}
diff --git a/game/modules/tome/data/general/objects/objects.lua b/game/modules/tome/data/general/objects/objects.lua
index f2c40b5cce..b563f6df27 100644
--- a/game/modules/tome/data/general/objects/objects.lua
+++ b/game/modules/tome/data/general/objects/objects.lua
@@ -68,7 +68,8 @@ loadIfNot("/data/general/objects/helms.lua")
 loadIfNot("/data/general/objects/wizard-hat.lua")
 loadIfNot("/data/general/objects/leather-boots.lua")
 loadIfNot("/data/general/objects/heavy-boots.lua")
---loadIfNot("/data/general/objects/gloves.lua")
+loadIfNot("/data/general/objects/gloves.lua")
+loadIfNot("/data/general/objects/gauntlets.lua")
 
 -- Mounts
 loadIfNot("/data/general/objects/mounts.lua")
diff --git a/src/main.c b/src/main.c
index 59ba8d34af..39d61e786b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -567,6 +567,45 @@ void setupRealtime(float freq)
 	}
 }
 
+void create_mode_list()
+{
+	SDL_PixelFormat format;
+	SDL_Rect **modes;
+	int loops = 0;
+	int bpp = 0;
+	do
+	{
+		//format.BitsPerPixel seems to get zeroed out on my windows box
+		switch(loops)
+		{
+			case 0://32 bpp
+				format.BitsPerPixel = 32;
+				bpp = 32;
+				break;
+			case 1://24 bpp
+				format.BitsPerPixel = 24;
+				bpp = 24;
+				break;
+			case 2://16 bpp
+				format.BitsPerPixel = 16;
+				bpp = 16;
+				break;
+		}
+
+		//get available fullscreen/hardware modes
+		modes = SDL_ListModes(&format, SDL_FULLSCREEN);
+		if (modes)
+		{
+			int i;
+			for(i=0; modes[i]; ++i)
+			{
+				printf("Available resolutions: %dx%dx%d\n", modes[i]->w, modes[i]->h, bpp/*format.BitsPerPixel*/);
+			}
+		}
+	}while(++loops != 3);
+//	return mode_list;
+}
+
 /* general OpenGL initialization function */
 int initGL()
 {
@@ -771,6 +810,8 @@ int main(int argc, char *argv[])
 		return -1;
 	}
 
+	create_mode_list();
+
 	SDL_WM_SetIcon(IMG_Load_RW(PHYSFSRWOPS_openRead("/engines/default/data/gfx/te4-icon.png"), TRUE), NULL);
 
 //	screen = SDL_SetVideoMode(WIDTH, HEIGHT, 32, SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE | SDL_HWSURFACE | SDL_RESIZABLE);
-- 
GitLab