From 60d420e2766d07df2f6c59356c1f0dea93b938c0 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Wed, 11 Aug 2010 14:15:55 +0000
Subject: [PATCH] High level NPCs ca have stats over 60 Orc corruptors in
 Rak'Shor Pride

git-svn-id: http://svn.net-core.org/repos/t-engine4@1007 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engine/Zone.lua                          |  2 +-
 game/modules/tome/class/Actor.lua             |  7 ++-
 game/modules/tome/class/Game.lua              |  9 +--
 game/modules/tome/class/Player.lua            |  3 +
 game/modules/tome/data/damage_types.lua       | 14 +++++
 .../tome/data/general/npcs/orc-rak-shor.lua   | 25 ++++++++
 .../tome/data/gfx/particles/blightzone.lua    | 47 +++++++++++++++
 game/modules/tome/data/talents/misc/npcs.lua  | 60 +++++++++++++++++++
 game/modules/tome/data/timed_effects.lua      |  2 +-
 .../tome/data/zones/high-peak/zone.lua        |  3 +-
 10 files changed, 164 insertions(+), 8 deletions(-)
 create mode 100644 game/modules/tome/data/gfx/particles/blightzone.lua

diff --git a/game/engine/Zone.lua b/game/engine/Zone.lua
index 9388d42406..8b2c8589d4 100644
--- a/game/engine/Zone.lua
+++ b/game/engine/Zone.lua
@@ -21,7 +21,7 @@ require "engine.class"
 local Savefile = require "engine.Savefile"
 local Map = require "engine.Map"
 local Astar = require "engine.Astar"
---local print = function() end
+local print = function() end
 
 --- Defines a zone: a set of levels, with depth, nps, objects, level generator, ...
 module(..., package.seeall, class.make)
diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index 4d24236809..ba682e64c3 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -621,8 +621,13 @@ end
 function _M:learnStats(statorder)
 	self.auto_stat_cnt = self.auto_stat_cnt or 1
 	local nb = 0
+	local max = 60
+
+	-- Allow to go over a natural 60, up to 80 at level 50
+	if not self.no_auto_high_stats then max = 60 + (self.level * 20 / 50) end
+
 	while self.unused_stats > 0 do
-		if self:getStat(statorder[self.auto_stat_cnt]) < 60 then
+		if self:getStat(statorder[self.auto_stat_cnt]) < max then
 			self:incStat(statorder[self.auto_stat_cnt], 1)
 			self.unused_stats = self.unused_stats - 1
 		end
diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua
index 39a9eb9ada..193c9b1d72 100644
--- a/game/modules/tome/class/Game.lua
+++ b/game/modules/tome/class/Game.lua
@@ -471,14 +471,15 @@ function _M:setupCommands()
 			if config.settings.tome.cheat then
 				self.player:forceLevelup(50)
 				self.player.no_breath = 1
+				self.player.invulnerable = 1
 				self.player.esp.all = 1
 				self.player.esp.range = 50
 				self.player.inc_damage.all = 100000
---				self:changeLevel(15, "high-peak")
+				self:changeLevel(2, "rak-shor-pride")
 --				self:changeLevel(1, "town-gates-of-morning")
-				self:changeLevel(1, "wilderness-arda-fareast")
-				game.memory_levels["wilderness-arda-fareast-1"] = game.level
-				self.player:grantQuest("orc-pride")
+--				self:changeLevel(1, "wilderness-arda-fareast")
+--				game.memory_levels["wilderness-arda-fareast-1"] = game.level
+--				self.player:grantQuest("orc-pride")
 --				self.player:grantQuest("escort-duty")
 			end
 		end,
diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua
index 87609cfcdc..c0b1ebee36 100644
--- a/game/modules/tome/class/Player.lua
+++ b/game/modules/tome/class/Player.lua
@@ -60,7 +60,10 @@ function _M:init(t, no_default)
 	if t.fixed_rating == nil then t.fixed_rating = true end
 
 	t.move_others = true
+
+	-- Dont give free resists & higher stat max to players
 	t.no_auto_resists = true
+	t.no_auto_high_stats = true
 
 	t.lite = t.lite or 0
 
diff --git a/game/modules/tome/data/damage_types.lua b/game/modules/tome/data/damage_types.lua
index f5f18d9a6f..3c2b3e1ef9 100644
--- a/game/modules/tome/data/damage_types.lua
+++ b/game/modules/tome/data/damage_types.lua
@@ -648,3 +648,17 @@ newDamageType{
 		end
 	end,
 }
+
+-- Corrupted blood, blight damage + potential diseases
+newDamageType{
+	name = "corrupted blood", type = "CORRUPTED_BLOOD",
+	projector = function(src, x, y, type, dam)
+		if _G.type(dam) == "number" then dam = {dam=dam} end
+		DamageType:get(DamageType.BLIGHT).projector(src, x, y, DamageType.BLIGHT, dam.dam)
+		local target = game.level.map(x, y, Map.ACTOR)
+		if target and target:canBe("disease") then
+			local eff = rng.table{{target.EFF_ROTTING_DISEASE, "con"}, {target.EFF_DECREPITUDE_DISEASE, "dex"}, {target.EFF_WEAKNESS_DISEASE, "str"}}
+			target:setEffect(eff[1], dam.dur or 5, { src = src, [eff[2]] = dam.disease_power, dam = dam.disease_dam or (dam.dam / 5) })
+		end
+	end,
+}
diff --git a/game/modules/tome/data/general/npcs/orc-rak-shor.lua b/game/modules/tome/data/general/npcs/orc-rak-shor.lua
index 1e8f474d59..120a655265 100644
--- a/game/modules/tome/data/general/npcs/orc-rak-shor.lua
+++ b/game/modules/tome/data/general/npcs/orc-rak-shor.lua
@@ -92,3 +92,28 @@ newEntity{ base = "BASE_NPC_ORC_RAK_SHOR",
 		[Talents.T_CURSE_OF_VULNERABILITY]=5,
 	},
 }
+
+newEntity{ base = "BASE_NPC_ORC_RAK_SHOR",
+	name = "orc corruptor", color=colors.GREY,
+	desc = [[An orc dressed in black robes. He mumbles is a harsh tongue.]],
+	level_range = {27, nil}, exp_worth = 1,
+	rarity = 1,
+	rank = 3,
+	max_life = resolvers.rngavg(160,180), life_rating = 15,
+	resolvers.equip{
+		{type="weapon", subtype="staff", autoreq=true},
+		{type="armor", subtype="cloth", autoreq=true},
+	},
+	combat_armor = 0, combat_def = 5,
+
+	inc_damage = { [DamageType.BLIGHT] = resolvers.mbonus(20, 10) },
+
+	resolvers.talents{
+		[Talents.T_SOUL_ROT]=5,
+		[Talents.T_BLOOD_GRASP]=5,
+		[Talents.T_CURSE_OF_VULNERABILITY]=5,
+		[Talents.T_BLIGHTZONE]=3,
+--		[Talents.T_BONE_SHIELD]=5,
+		[Talents.T_BLOOD_SPRAY]=4,
+	},
+}
diff --git a/game/modules/tome/data/gfx/particles/blightzone.lua b/game/modules/tome/data/gfx/particles/blightzone.lua
new file mode 100644
index 0000000000..add3653b7e
--- /dev/null
+++ b/game/modules/tome/data/gfx/particles/blightzone.lua
@@ -0,0 +1,47 @@
+-- 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 ad = rng.range(0, 360)
+	local a = math.rad(ad)
+	local dir = math.rad(ad + 90)
+	local r = rng.range(1, 20)
+	local dirv = math.rad(1)
+
+	return {
+		trail = 1,
+		life = 10,
+		size = 1, sizev = 0.5, sizea = 0,
+
+		x = r * math.cos(a), xv = -0.1, xa = 0,
+		y = r * math.sin(a), yv = -0.1, ya = 0,
+		dir = math.rad(rng.range(0, 360)), dirv = 0, dira = 0,
+		vel = 0.1, 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(155, 255)/255,  av = 0, aa = 0.005,
+	}
+end, },
+function(self)
+	self.ps:emit(4)
+end,
+40,
+"particle_torus"
diff --git a/game/modules/tome/data/talents/misc/npcs.lua b/game/modules/tome/data/talents/misc/npcs.lua
index 949e75a6a1..5d43b88d40 100644
--- a/game/modules/tome/data/talents/misc/npcs.lua
+++ b/game/modules/tome/data/talents/misc/npcs.lua
@@ -867,6 +867,39 @@ newTalent{
 	end,
 }
 
+newTalent{
+	name = "Blightzone",
+	type = {"corruption/other", 1},
+	points = 5,
+	cooldown = 13,
+	vim = 27,
+	range = 20,
+	action = function(self, t)
+		local duration = self:getTalentLevel(t) + 2
+		local radius = 4
+		local dam = self:combatTalentSpellDamage(t, 4, 65)
+		local tg = {type="ball", range=self:getTalentRange(t), radius=radius}
+		local x, y = self:getTarget(tg)
+		if not x or not y then return nil end
+		local _ _, x, y = self:canProject(tg, x, y)
+		-- Add a lasting map effect
+		game.level.map:addEffect(self,
+			x, y, duration,
+			DamageType.BLIGHT, dam,
+			radius,
+			5, nil,
+			{type="blightzone"},
+			nil, self:spellFriendlyFire()
+		)
+		game:playSoundNear(self, "talents/cloud")
+		return true
+	end,
+	info = function(self)
+		return ([[Corrupted vapour rises at the target location doing %0.2f blight damage every turn for %d turns.
+		The damage will increase with Magic stat.]]):format(self:combatTalentSpellDamage(t, 5, 65), self:getTalentLevel(t) + 2)
+	end,
+}
+
 newTalent{
 	name = "Blood Grasp",
 	type = {"corruption/other", 1},
@@ -888,6 +921,33 @@ newTalent{
 		The damage will increase with Magic stat.]]):format(self:combatTalentSpellDamage(t, 10, 220))
 	end,
 }
+newTalent{
+	name = "Blood Spray",
+	type = {"corruption/other", 1},
+	points = 5,
+	cooldown = 7,
+	vim = 24,
+	range = function(self, t) return math.ceil(3 + self:getTalentLevel(t)) end,
+	action = function(self, t)
+		local tg = {type="cone", range=0, radius=self:getTalentRange(t), talent=t}
+		local x, y = self:getTarget(tg)
+		if not x or not y then return nil end
+		self:project(tg, x, y, DamageType.CORRUPTED_BLOOD, {
+			dam = self:spellCrit(self:combatTalentSpellDamage(t, 10, 170)),
+			disease_chance = 20 + self:getTalentLevel(t) * 10,
+			disease_dam = self:spellCrit(self:combatTalentSpellDamage(t, 10, 220)) / 6,
+			disease_power = self:combatTalentSpellDamage(t, 10, 20),
+			dur = 6,
+		}, {type="blood"})
+		game:playSoundNear(self, "talents/slime")
+		return true
+	end,
+	info = function(self)
+		return ([[You extract corrupted blood from your own body, hitting everything in a frontal cone for %0.2f blight damage.
+		Each affected creature has a %d%% chance of being infected by a random disease doing %0.2f blight damage over 6 turns.
+		The damage will increase with Magic stat.]]):format(self:combatTalentSpellDamage(t, 10, 170), 20 + self:getTalentLevel(t) * 10, self:combatTalentSpellDamage(t, 10, 220))
+	end,
+}
 
 newTalent{
 	name = "Curse of Vulnerability",
diff --git a/game/modules/tome/data/timed_effects.lua b/game/modules/tome/data/timed_effects.lua
index 73a0d64079..70035520be 100644
--- a/game/modules/tome/data/timed_effects.lua
+++ b/game/modules/tome/data/timed_effects.lua
@@ -819,7 +819,7 @@ newEffect{
 	end,
 	-- Lost of CON
 	activate = function(self, eff)
-		eff.tmpid = self:addTemporaryValue("inc_stats", {[Stats.STAT_CON] = eff.con})
+		eff.tmpid = self:addTemporaryValue("inc_stats", {[Stats.STAT_CON] = -eff.con})
 	end,
 	deactivate = function(self, eff)
 		self:removeTemporaryValue("inc_stats", eff.tmpid)
diff --git a/game/modules/tome/data/zones/high-peak/zone.lua b/game/modules/tome/data/zones/high-peak/zone.lua
index 9126c17391..3f00ce666d 100644
--- a/game/modules/tome/data/zones/high-peak/zone.lua
+++ b/game/modules/tome/data/zones/high-peak/zone.lua
@@ -34,7 +34,8 @@ return {
 		map = {
 			class = "engine.generator.map.Roomer",
 			nb_rooms = 10,
-			rooms = {"simple", "pilar", {"money_vault",5}},
+			rooms = {"simple", "pilar", {"pit",6}},
+			rooms_config = {pit={filters={{type="orc"}, {type="undead"}, {type="naga"}}}},
 			lite_room_chance = 100,
 			['.'] = "FLOOR",
 			['#'] = "WALL",
-- 
GitLab