From 5032c896e655efceb34f5b010f9b56c7783c6e93 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Thu, 8 Jul 2010 19:18:40 +0000
Subject: [PATCH] gollllemmmmm

git-svn-id: http://svn.net-core.org/repos/t-engine4@892 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/PlayerDisplay.lua     |  62 +++---
 .../tome/data/talents/spells/golemancy.lua    | 191 ++++++++++++++++++
 .../tome/data/talents/spells/spells.lua       |   2 +-
 .../tome/data/zones/mount-doom/npcs.lua       |   1 +
 4 files changed, 228 insertions(+), 28 deletions(-)
 create mode 100644 game/modules/tome/data/talents/spells/golemancy.lua

diff --git a/game/modules/tome/class/PlayerDisplay.lua b/game/modules/tome/class/PlayerDisplay.lua
index 0100ece545..80d5890956 100644
--- a/game/modules/tome/class/PlayerDisplay.lua
+++ b/game/modules/tome/class/PlayerDisplay.lua
@@ -44,16 +44,17 @@ end
 
 -- Displays the stats
 function _M:display()
-	if not game.player or not game.player.changed then return self.surface end
+	local player = game.player
+	if not player or not player.changed then return self.surface end
 
 	self.surface:erase(self.bgcolor[1], self.bgcolor[2], self.bgcolor[3])
 
-	local cur_exp, max_exp = game.player.exp, game.player:getExpChart(game.player.level+1)
+	local cur_exp, max_exp = player.exp, player:getExpChart(player.level+1)
 
 	local h = 0
-	self.surface:drawColorStringBlended(self.font, "Level: #00ff00#"..game.player.level, 0, h, 255, 255, 255) h = h + self.font_h
+	self.surface:drawColorStringBlended(self.font, "Level: #00ff00#"..player.level, 0, h, 255, 255, 255) h = h + self.font_h
 	self.surface:drawColorStringBlended(self.font, ("Exp:  #00ff00#%2d%%"):format(100 * cur_exp / max_exp), 0, h, 255, 255, 255) h = h + self.font_h
-	self.surface:drawColorStringBlended(self.font, ("Gold: #00ff00#%0.2f"):format(game.player.money or 0), 0, h, 255, 255, 255) h = h + self.font_h
+	self.surface:drawColorStringBlended(self.font, ("Gold: #00ff00#%0.2f"):format(player.money or 0), 0, h, 255, 255, 255) h = h + self.font_h
 
 	h = h + self.font_h
 
@@ -62,46 +63,53 @@ function _M:display()
 		h = h + self.font_h
 	end
 
-	if game.player:getAir() < game.player.max_air then
-		self.surface:drawColorStringBlended(self.font, ("Air level: %d/%d"):format(game.player:getAir(), game.player.max_air), 0, h, 255, 0, 0) h = h + self.font_h
+	if player:getAir() < player.max_air then
+		self.surface:drawColorStringBlended(self.font, ("Air level: %d/%d"):format(player:getAir(), player.max_air), 0, h, 255, 0, 0) h = h + self.font_h
 		h = h + self.font_h
 	end
 
 	self.surface:erase(colors.VERY_DARK_RED.r, colors.VERY_DARK_RED.g, colors.VERY_DARK_RED.b, 255, self.bars_x, h, self.bars_w, self.font_h)
-	self.surface:erase(colors.DARK_RED.r, colors.DARK_RED.g, colors.DARK_RED.b, 255, self.bars_x, h, self.bars_w * game.player.life / game.player.max_life, self.font_h)
-	self.surface:drawColorStringBlended(self.font, ("#c00000#Life:    #ffffff#%d/%d"):format(game.player.life, game.player.max_life), 0, h, 255, 255, 255) h = h + self.font_h
-	if game.player:knowTalent(game.player.T_STAMINA_POOL) then
+	self.surface:erase(colors.DARK_RED.r, colors.DARK_RED.g, colors.DARK_RED.b, 255, self.bars_x, h, self.bars_w * player.life / player.max_life, self.font_h)
+	self.surface:drawColorStringBlended(self.font, ("#c00000#Life:    #ffffff#%d/%d"):format(player.life, player.max_life), 0, h, 255, 255, 255) h = h + self.font_h
+
+	if player.alchemy_golem then
+		self.surface:erase(colors.VERY_DARK_RED.r, colors.VERY_DARK_RED.g, colors.VERY_DARK_RED.b, 255, self.bars_x, h, self.bars_w, self.font_h)
+		self.surface:erase(colors.DARK_RED.r, colors.DARK_RED.g, colors.DARK_RED.b, 255, self.bars_x, h, self.bars_w * player.alchemy_golem.life / player.alchemy_golem.max_life, self.font_h)
+		self.surface:drawColorStringBlended(self.font, ("#c00000#Golem:   #ffffff#%d/%d"):format(player.alchemy_golem.life, player.alchemy_golem.max_life), 0, h, 255, 255, 255) h = h + self.font_h
+	end
+
+	if player:knowTalent(player.T_STAMINA_POOL) then
 		self.surface:erase(0xff / 6, 0xcc / 6, 0x80 / 6, 255, self.bars_x, h, self.bars_w, self.font_h)
-		self.surface:erase(0xff / 3, 0xcc / 3, 0x80 / 3, 255, self.bars_x, h, self.bars_w * game.player:getStamina() / game.player.max_stamina, self.font_h)
-		self.surface:drawColorStringBlended(self.font, ("#ffcc80#Stamina: #ffffff#%d/%d"):format(game.player:getStamina(), game.player.max_stamina), 0, h, 255, 255, 255) h = h + self.font_h
+		self.surface:erase(0xff / 3, 0xcc / 3, 0x80 / 3, 255, self.bars_x, h, self.bars_w * player:getStamina() / player.max_stamina, self.font_h)
+		self.surface:drawColorStringBlended(self.font, ("#ffcc80#Stamina: #ffffff#%d/%d"):format(player:getStamina(), player.max_stamina), 0, h, 255, 255, 255) h = h + self.font_h
 	end
-	if game.player:knowTalent(game.player.T_MANA_POOL) then
+	if player:knowTalent(player.T_MANA_POOL) then
 		self.surface:erase(0x7f / 5, 0xff / 5, 0xd4 / 5, 255, self.bars_x, h, self.bars_w, self.font_h)
-		self.surface:erase(0x7f / 2, 0xff / 2, 0xd4 / 2, 255, self.bars_x, h, self.bars_w * game.player:getMana() / game.player.max_mana, self.font_h)
-		self.surface:drawColorStringBlended(self.font, ("#7fffd4#Mana:    #ffffff#%d/%d"):format(game.player:getMana(), game.player.max_mana), 0, h, 255, 255, 255) h = h + self.font_h
+		self.surface:erase(0x7f / 2, 0xff / 2, 0xd4 / 2, 255, self.bars_x, h, self.bars_w * player:getMana() / player.max_mana, self.font_h)
+		self.surface:drawColorStringBlended(self.font, ("#7fffd4#Mana:    #ffffff#%d/%d"):format(player:getMana(), player.max_mana), 0, h, 255, 255, 255) h = h + self.font_h
 	end
-	if game.player:knowTalent(game.player.T_EQUILIBRIUM_POOL) then
+	if player:knowTalent(player.T_EQUILIBRIUM_POOL) then
 		self.surface:erase(0x00 / 5, 0xff / 5, 0x74 / 5, 255, self.bars_x, h, self.bars_w, self.font_h)
-		self.surface:erase(0x00 / 2, 0xff / 2, 0x74 / 2, 255, self.bars_x, h, self.bars_w * math.min(1, math.log(1 + game.player:getEquilibrium() / 100)), self.font_h)
-		self.surface:drawColorStringBlended(self.font, ("#00ff74#Equi:    #ffffff#%d"):format(game.player:getEquilibrium()), 0, h, 255, 255, 255) h = h + self.font_h
+		self.surface:erase(0x00 / 2, 0xff / 2, 0x74 / 2, 255, self.bars_x, h, self.bars_w * math.min(1, math.log(1 + player:getEquilibrium() / 100)), self.font_h)
+		self.surface:drawColorStringBlended(self.font, ("#00ff74#Equi:    #ffffff#%d"):format(player:getEquilibrium()), 0, h, 255, 255, 255) h = h + self.font_h
 	end
-	if game.player:knowTalent(game.player.T_POSITIVE_POOL) then
+	if player:knowTalent(player.T_POSITIVE_POOL) then
 		self.surface:erase(colors.GOLD.r / 5, colors.GOLD.g / 5, colors.GOLD.b / 5, 255, self.bars_x, h, self.bars_w, self.font_h)
-		self.surface:erase(colors.GOLD.r / 2, colors.GOLD.g / 2, colors.GOLD.b / 2, 255, self.bars_x, h, self.bars_w * game.player:getPositive() / game.player.max_positive, self.font_h)
-		self.surface:drawColorStringBlended(self.font, ("#7fffd4#Positive:#ffffff#%d/%d"):format(game.player:getPositive(), game.player.max_positive), 0, h, 255, 255, 255) h = h + self.font_h
+		self.surface:erase(colors.GOLD.r / 2, colors.GOLD.g / 2, colors.GOLD.b / 2, 255, self.bars_x, h, self.bars_w * player:getPositive() / player.max_positive, self.font_h)
+		self.surface:drawColorStringBlended(self.font, ("#7fffd4#Positive:#ffffff#%d/%d"):format(player:getPositive(), player.max_positive), 0, h, 255, 255, 255) h = h + self.font_h
 	end
-	if game.player:knowTalent(game.player.T_NEGATIVE_POOL) then
+	if player:knowTalent(player.T_NEGATIVE_POOL) then
 		self.surface:erase(colors.GREY.r / 5, colors.GREY.g / 5, colors.GREY.b / 5, 255, self.bars_x, h, self.bars_w, self.font_h)
-		self.surface:erase(colors.GREY.r / 2, colors.GREY.g / 2, colors.GREY.b / 2, 255, self.bars_x, h, self.bars_w * game.player:getNegative() / game.player.max_negative, self.font_h)
-		self.surface:drawColorStringBlended(self.font, ("#7fffd4#Negative:#ffffff#%d/%d"):format(game.player:getNegative(), game.player.max_negative), 0, h, 255, 255, 255) h = h + self.font_h
+		self.surface:erase(colors.GREY.r / 2, colors.GREY.g / 2, colors.GREY.b / 2, 255, self.bars_x, h, self.bars_w * player:getNegative() / player.max_negative, self.font_h)
+		self.surface:drawColorStringBlended(self.font, ("#7fffd4#Negative:#ffffff#%d/%d"):format(player:getNegative(), player.max_negative), 0, h, 255, 255, 255) h = h + self.font_h
 	end
 
 	h = h + self.font_h
-	for tid, act in pairs(game.player.sustain_talents) do
-		if act then self.surface:drawColorStringBlended(self.font, ("#LIGHT_GREEN#%s"):format(game.player:getTalentFromId(tid).name), 0, h, 255, 255, 255) h = h + self.font_h end
+	for tid, act in pairs(player.sustain_talents) do
+		if act then self.surface:drawColorStringBlended(self.font, ("#LIGHT_GREEN#%s"):format(player:getTalentFromId(tid).name), 0, h, 255, 255, 255) h = h + self.font_h end
 	end
-	for eff_id, p in pairs(game.player.tmp) do
-		local e = game.player.tempeffect_def[eff_id]
+	for eff_id, p in pairs(player.tmp) do
+		local e = player.tempeffect_def[eff_id]
 		if e.status == "detrimental" then
 			self.surface:drawColorStringBlended(self.font, ("#LIGHT_RED#%s"):format(e.desc), 0, h, 255, 255, 255) h = h + self.font_h
 		else
diff --git a/game/modules/tome/data/talents/spells/golemancy.lua b/game/modules/tome/data/talents/spells/golemancy.lua
new file mode 100644
index 0000000000..2a383aacbe
--- /dev/null
+++ b/game/modules/tome/data/talents/spells/golemancy.lua
@@ -0,0 +1,191 @@
+-- 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 function makeGolem()
+	return require("mod.class.NPC").new{
+		type = "construct", subtype = "golem",
+		display = 'g', color=colors.WHITE,
+		level_range = {1, 50},
+
+		combat = { dam=10, atk=10, apr=0, dammod={str=1} },
+
+		body = { INVEN = 50, MAINHAND=1, OFFHAND=1, BODY=1,},
+		infravision = 20,
+		rank = 3,
+		size_category = 4,
+
+		autolevel = "warrior",
+		ai = "summoned", ai_real = "dumb_talented_simple", ai_state = { talent_in=4, ai_move="move_astar" },
+		energy = { mod=1 },
+		stats = { str=14, dex=12, mag=10, con=12 },
+
+		no_auto_resists = true,
+		open_door = true,
+		blind_immune = 1,
+		fear_immune = 1,
+		see_invisible = 2,
+		no_breath = 1,
+	}
+end
+
+newTalent{
+	name = "Refit Golem",
+	type = {"spell/golemancy", 1},
+	require = spells_req1,
+	points = 1,
+	action = function(self, t)
+		if not self.alchemy_golem then
+			self.alchemy_golem = game.zone:finishEntity(game.level, "actor", makeGolem())
+			if not self.alchemy_golem then return end
+			self.alchemy_golem.faction = self.faction
+			self.alchemy_golem.summoner = self
+			self.alchemy_golem.summoner_gain_exp = true
+		end
+
+		if game.level:hasEntity(self.alchemy_golem) then
+		else
+			-- Find space
+			local x, y = util.findFreeGrid(self.x, self.y, 5, true, {[Map.ACTOR]=true})
+			if not x then
+				game.logPlayer(self, "Not enough space to summon!")
+				return
+			end
+			game.zone:addEntity(game.level, self.alchemy_golem, "actor", x, y)
+		end
+
+		game:playSoundNear(self, "talents/arcane")
+		return true
+	end,
+	info = function(self, t)
+		return ([[Carve %d to %d alchemist gems out of natural gems.
+		Alchemists gems are used for lots of other spells.]]):format(40, 80)
+	end,
+}
+
+newTalent{
+	name = "Golem: Taunt",
+	type = {"spell/golemancy", 1},
+	require = spells_req1,
+	points = 5,
+	range = function(self, t)
+		return math.ceil(5 + self:getDex(12))
+	end,
+	computeDamage = function(self, t, ammo)
+		local inc_dam = 0
+		local damtype = DamageType.FIRE
+		local particle = "ball_fire"
+		if self:isTalentActive(self.T_ACID_INFUSION) then inc_dam = self:getTalentLevel(self.T_ACID_INFUSION) * 0.05; damtype = DamageType.ACID; particle = "ball_acid"
+		elseif self:isTalentActive(self.T_LIGHTNING_INFUSION) then inc_dam = self:getTalentLevel(self.T_LIGHTNING_INFUSION) * 0.05; damtype = DamageType.LIGHTNING; particle = "ball_lightning"
+		elseif self:isTalentActive(self.T_FROST_INFUSION) then inc_dam = self:getTalentLevel(self.T_FROST_INFUSION) * 0.05; damtype = DamageType.ICE; particle = "ball_ice"
+		else inc_dam = self:getTalentLevel(self.T_FIRE_INFUSION) * 0.05
+		end
+		local dam = self:combatTalentSpellDamage(t, 15, 150, (ammo.alchemist_power + self:combatSpellpower()) / 2)
+		dam = dam * (1 + inc_dam)
+		return dam, damtype, particle
+	end,
+	action = function(self, t)
+		local ammo = self:hasAlchemistWeapon()
+		if not ammo then
+			game.logPlayer(self, "You need to ready alchemist gems in your quiver.")
+			return
+		end
+
+		local tg = {type="ball", range=self:getTalentRange(t), radius=self:getTalentLevelRaw(self.T_EXPLOSION_EXPERT), talent=t}
+		if tg.radius == 0 then tg.type = "hit" end
+		local x, y = self:getTarget(tg)
+		if not x or not y then return nil end
+
+		ammo = self:removeObject(self:getInven("QUIVER"), 1)
+		if not ammo then return end
+
+		local dam, damtype, particle = t.computeDamage(self, t, ammo)
+		local prot = self:getTalentLevelRaw(self.T_ALCHEMIST_PROTECTION) * 0.2
+
+		local grids = self:project(tg, x, y, function(tx, ty)
+			-- Protect yourself
+			local d = dam
+			if tx == self.x and ty == self.y then d = dam * (1 - prot) end
+			DamageType:get(damtype).projector(self, tx, ty, damtype, self:spellCrit(d))
+		end)
+
+		local _ _, x, y = self:canProject(tg, x, y)
+		game.level.map:particleEmitter(x, y, tg.radius, particle, {radius=tg.radius, grids=grids, tx=x, ty=y})
+
+		game:playSoundNear(self, "talents/arcane")
+		return true
+	end,
+	info = function(self, t)
+		local ammo = self:hasAlchemistWeapon()
+		local dam, damtype = 1, DamageType.FIRE
+		if ammo then dam, damtype = t.computeDamage(self, t, ammo) end
+		return ([[Imbue an alchemist gem with an explosive charge of mana and throw it.
+		The gem will explode for %0.2f %s damage.
+		The damage will improve with better gems and Magic stat and the range with your dexterity.]]):format(dam, DamageType:get(damtype).name)
+	end,
+}
+
+newTalent{
+	name = "Golem: Knockback",
+	type = {"spell/golemancy", 2},
+	require = spells_req2,
+	mode = "passive",
+	points = 5,
+	info = function(self, t)
+		return ([[Your alchemist bombs now affect a radius of %d around them.]]):format(self:getTalentLevelRaw(t))
+	end,
+}
+
+newTalent{
+	name = "Golem: Crush",
+	type = {"spell/golemancy", 3},
+	require = spells_req3,
+	mode = "passive",
+	points = 5,
+	on_learn = function(self, t)
+		self.resists[DamageType.FIRE] = (self.resists[DamageType.FIRE] or 0) + 3
+		self.resists[DamageType.COLD] = (self.resists[DamageType.COLD] or 0) + 3
+		self.resists[DamageType.LIGHTNING] = (self.resists[DamageType.LIGHTNING] or 0) + 3
+		self.resists[DamageType.ACID] = (self.resists[DamageType.ACID] or 0) + 3
+	end,
+	on_unlearn = function(self, t)
+		self.resists[DamageType.FIRE] = self.resists[DamageType.FIRE] - 3
+		self.resists[DamageType.COLD] = self.resists[DamageType.COLD] - 3
+		self.resists[DamageType.LIGHTNING] = self.resists[DamageType.LIGHTNING] - 3
+		self.resists[DamageType.ACID] = self.resists[DamageType.ACID] - 3
+	end,
+	info = function(self, t)
+		return ([[Improves your resistance against your own bombs elemental damage by %d%% and against external one byt %d%%.]]):
+		format(self:getTalentLevelRaw(t) * 20, self:getTalentLevelRaw(t) * 3)
+	end,
+}
+
+newTalent{
+	name = "Invoke Golem",
+	type = {"spell/golemancy",4},
+	require = spells_req4,
+	points = 5,
+	action = function(self, t)
+		game:playSoundNear(self, "talents/arcane")
+		return true
+	end,
+	info = function(self, t)
+		return ([[Carve %d to %d alchemist gems out of muliple natural gems, combining their powers.
+		Alchemists gems are used for lots of other spells.]]):format(40, 80)
+	end,
+}
diff --git a/game/modules/tome/data/talents/spells/spells.lua b/game/modules/tome/data/talents/spells/spells.lua
index 3eec6f5a59..6e1948eb35 100644
--- a/game/modules/tome/data/talents/spells/spells.lua
+++ b/game/modules/tome/data/talents/spells/spells.lua
@@ -77,4 +77,4 @@ load("/data/talents/spells/enhancement.lua")
 
 load("/data/talents/spells/alchemy.lua")
 load("/data/talents/spells/infusion.lua")
---load("/data/talents/spells/golemancy.lua")
+load("/data/talents/spells/golemancy.lua")
diff --git a/game/modules/tome/data/zones/mount-doom/npcs.lua b/game/modules/tome/data/zones/mount-doom/npcs.lua
index 5b2bf6953a..1a66b03837 100644
--- a/game/modules/tome/data/zones/mount-doom/npcs.lua
+++ b/game/modules/tome/data/zones/mount-doom/npcs.lua
@@ -271,6 +271,7 @@ This one looks even nastier and looks toward you with what seems to be disdain.
 	move_others=true,
 
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, NECK=1 },
+	ai = "dumb_talented_simple", ai_state = { talent_in=1, ai_move="move_astar" },
 
 	resolvers.equip{
 		{type="jewelry", subtype="amulet", defined="FIERY_CHOKER"},
-- 
GitLab