From c765102ee53dbf8e5bcb56b4dce5b1f1f6d98e58 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Mon, 21 May 2012 13:30:00 +0000
Subject: [PATCH] Duck and Dodge now is an Evasion effect triggered when the
 halfling takes damage Militant Mind now starts off capping at 5 foes and
 grants saves too Indomitable now clears existing stuns, dazes, and pins as
 well as prodiving free action

git-svn-id: http://svn.net-core.org/repos/t-engine4@5160 51575b47-30f0-44d4-a5cc-537603b46e54
---
 build/te4core.lua                             |  2 +-
 game/modules/tome/class/Actor.lua             |  9 +++-
 game/modules/tome/class/interface/Combat.lua  |  5 --
 game/modules/tome/data/talents/misc/races.lua | 49 +++++++++++++++----
 .../tome/data/timed_effects/mental.lua        |  4 +-
 .../modules/tome/data/timed_effects/other.lua |  8 ++-
 premake4.lua                                  |  5 +-
 7 files changed, 62 insertions(+), 20 deletions(-)

diff --git a/build/te4core.lua b/build/te4core.lua
index 67a680d8ab..b85cec8b0b 100644
--- a/build/te4core.lua
+++ b/build/te4core.lua
@@ -48,7 +48,7 @@ project "TEngine"
 		links { "IOKit" }
 
 	configuration "windows"
-		links { "mingw32", "SDLmain", "SDL", "SDL_ttf", "SDL_image", "openal32", "vorbisfile", "OPENGL32", "GLU32", "wsock32", "png12" }
+		links { "mingw32", "SDL2main", "SDL2", "SDL2_ttf", "SDL2_image", "openal32", "vorbisfile", "OPENGL32", "GLU32", "wsock32", "png" }
 		defines { [[TENGINE_HOME_PATH='"T-Engine"']], 'SELFEXE_WINDOWS'  }
 		prebuildcommands { "windres ../src/windows/icon.rc -O coff -o ../src/windows/icon.res" }
 		linkoptions { "../src/windows/icon.res" }
diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index 960ca459b0..d19fb94f01 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -546,7 +546,7 @@ function _M:act()
 			if act and self:reactionToward(act) < 0 and self:canSee(act) then nb_foes = nb_foes + 1 end
 		end
 		if nb_foes > 1 then
-			nb_foes = math.min(nb_foes, self:getTalentLevel(self.T_MILITANT_MIND))
+			nb_foes = math.min(nb_foes, 5)
 			self:setEffect(self.EFF_MILITANT_MIND, 4, {power=self:getTalentLevel(self.T_MILITANT_MIND) * nb_foes * 0.6})
 		end
 	end
@@ -1730,6 +1730,13 @@ function _M:onTakeHit(value, src)
 		self:setEffect(self.EFF_INVISIBILITY, 5, {power=self:attr("invis_on_hit_power")})
 		for tid, _ in pairs(self.invis_on_hit_disable) do self:forceUseTalent(tid, {ignore_energy=true}) end
 	end
+	
+	if self:knowTalent(self.T_DUCK_AND_DODGE) then
+		local t = self:getTalentFromId(self.T_DUCK_AND_DODGE)
+		if value >= self.max_life * t.getThreshold(self, t) then
+			self:setEffect(self.EFF_EVASION, t.getDuration(self, t), {chance=t.getEvasionChance(self, t)})
+		end
+	end
 
 	-- Damage shield on hit
 	if self:attr("contingency") and value >= self.max_life * self:attr("contingency") / 100 and not self:hasEffect(self.EFF_DAMAGE_SHIELD) then
diff --git a/game/modules/tome/class/interface/Combat.lua b/game/modules/tome/class/interface/Combat.lua
index ff25557565..f7832d43ff 100644
--- a/game/modules/tome/class/interface/Combat.lua
+++ b/game/modules/tome/class/interface/Combat.lua
@@ -325,11 +325,6 @@ function _M:attackTargetWith(target, weapon, damtype, mult, force_dam)
 	local dam, apr, armor = force_dam or self:combatDamage(weapon), self:combatAPR(weapon), target:combatArmor()
 	print("[ATTACK] to ", target.name, " :: ", dam, apr, armor, def, "::", mult)
 
-	if target:knowTalent(target.T_DUCK_AND_DODGE) then
-		local diff = util.bound((self.size_category or 3) - (target.size_category or 2), 0, 5)
-		def = def + diff * target:getTalentLevelRaw(target.T_DUCK_AND_DODGE) * 1.2
-	end
-
 	-- check repel
 	local repelled = false
 	if target:isTalentActive(target.T_REPEL) then
diff --git a/game/modules/tome/data/talents/misc/races.lua b/game/modules/tome/data/talents/misc/races.lua
index 239f06c823..8dba448edb 100644
--- a/game/modules/tome/data/talents/misc/races.lua
+++ b/game/modules/tome/data/talents/misc/races.lua
@@ -497,11 +497,12 @@ newTalent{
 		self:setEffect(self.EFF_HALFLING_LUCK, 5, {
 			physical=10 + self:getCun() / 2,
 			spell=10 + self:getCun() / 2,
+			mind=10 + self:getCun() / 2,
 		})
 		return true
 	end,
 	info = function(self, t)
-		return ([[Call upon the luck and cunning of the Little Folk to increase your physical and spell critical strike chance by %d%% for 5 turns.
+		return ([[Call upon the luck and cunning of the Little Folk to increase your physical, mental, and spell critical strike chance by %d%% for 5 turns.
 		The bonus will increase with the Cunning stat.]]):format(10 + self:getCun() / 2, 10 + self:getCun() / 2)
 	end,
 }
@@ -512,10 +513,16 @@ newTalent{
 	require = racial_req2,
 	points = 5,
 	mode = "passive",
+	getThreshold = function(self, t) return math.max(10, (15 - self:getTalentLevelRaw(t))) / 100 end,
+	getEvasionChance = function(self, t) return self:getStat("lck") end,
+	getDuration = function(self, t) return 1 + math.ceil(self:getTalentLevel(t)/2) end,
 	info = function(self, t)
-		return ([[Halfling have long learnt to use their small stature as an advantage when fighting the other races.
-		Increases defense in melee based on the size difference between the attacker and you (+%d defence per size).]]):
-		format(self:getTalentLevelRaw(t) * 1.2)
+		local threshold = t.getThreshold(self, t)
+		local evasion = t.getEvasionChance(self, t)
+		local duration = t.getDuration(self, t)
+		return ([[Your incredible luck kicks in at just the right moment to save your skin.
+		Whenever you take %d%% or more of your life from a single attack you gain Evasion equal to your luck stat (currently %d%%) for the next %d turns.]]):
+		format(threshold * 100, evasion, duration)
 	end,
 }
 
@@ -527,8 +534,8 @@ newTalent{
 	mode = "passive",
 	info = function(self, t)
 		return ([[Halflings have always been a very organised and methodical race, the more foes they face the more organised they are.
-		If two or more foes are in sight your physical power, spellpower and mindpower are increased by %0.1f per foes (up to %d foes).]]):
-		format(self:getTalentLevel(t) * 0.6, self:getTalentLevel(t))
+		If two or more foes are in sight your physical power, physical save, spellpower, spell save, mental save, and mindpower are increased by %0.1f per foes (up to 5 foes).]]):
+		format(self:getTalentLevel(t) * 0.6)
 	end,
 }
 
@@ -539,14 +546,38 @@ newTalent{
 	points = 5,
 	no_energy = true,
 	cooldown = function(self, t) return 50 - self:getTalentLevel(t) * 5 end,
-	tactical = { DEFEND = 1 },
+	tactical = { DEFEND = 1,  CURE = 1 },
+	getRemoveCount = function(self, t) return 1 + self:getTalentLevel(t) end,
+	getDuration = function(self, t) return 1 + self:getTalentLevel(t) end,
 	action = function(self, t)
-		self:setEffect(self.EFF_FREE_ACTION, 3 + self:getTalentLevel(t), {})
+		local effs = {}
+
+		-- Go through all effects
+		for eff_id, p in pairs(self.tmp) do
+			local e = self.tempeffect_def[eff_id]
+			if e.subtype.stun or e.subtype.pin then -- Daze is stun subtype
+				effs[#effs+1] = {"effect", eff_id}
+			end
+		end
+
+		for i = 1, t.getRemoveCount(self, t) do
+			if #effs == 0 then break end
+			local eff = rng.tableRemove(effs)
+
+			if eff[1] == "effect" then
+				self:removeEffect(eff[2])
+			end
+		end
+	
+		self:setEffect(self.EFF_FREE_ACTION, t.getDuration(self, t), {})
 		return true
 	end,
 	info = function(self, t)
+		local duration = t.getDuration(self, t)
+		local count = t.getRemoveCount(self, t)
 		return ([[Halflings are one of the more powerful military force of the known world, they have been at war with most other races for thousand of years.
-		Instantly makes you immune to stuns, dazes and pinning effects for %d turns.]]):format(3 + self:getTalentLevel(t))
+		Removes %d stun, daze, or pin effects and makes you immune to stuns, dazes and pins for %d turns.
+		This talent takes no time to use.]]):format(duration, count)
 	end,
 }
 
diff --git a/game/modules/tome/data/timed_effects/mental.lua b/game/modules/tome/data/timed_effects/mental.lua
index 91c6c835dc..8c50764255 100644
--- a/game/modules/tome/data/timed_effects/mental.lua
+++ b/game/modules/tome/data/timed_effects/mental.lua
@@ -1593,7 +1593,7 @@ newEffect{
 newEffect{
 	name = "HALFLING_LUCK", image = "talents/halfling_luck.png",
 	desc = "Halflings's Luck",
-	long_desc = function(self, eff) return ("The target's luck and cunning combine to grant it %d%% higher combat critical chance and %d%% higher spell critical chance."):format(eff.physical, eff.spell) end,
+	long_desc = function(self, eff) return ("The target's luck and cunning combine to grant it %d%% higher combat critical chance, %d%% higher mental critical chance, and %d%% higher spell critical chance."):format(eff.physical, eff.mind, eff.spell) end,
 	type = "mental",
 	subtype = { focus=true },
 	status = "beneficial",
@@ -1603,10 +1603,12 @@ newEffect{
 	activate = function(self, eff)
 		eff.pid = self:addTemporaryValue("combat_physcrit", eff.physical)
 		eff.sid = self:addTemporaryValue("combat_spellcrit", eff.spell)
+		eff.mid = self:addTemporaryValue("combat_mindcrit", eff.mind)
 	end,
 	deactivate = function(self, eff)
 		self:removeTemporaryValue("combat_physcrit", eff.pid)
 		self:removeTemporaryValue("combat_spellcrit", eff.sid)
+		self:removeTemporaryValue("combat_mindcrit", eff.mid)
 	end,
 }
 
diff --git a/game/modules/tome/data/timed_effects/other.lua b/game/modules/tome/data/timed_effects/other.lua
index 51bd8969f7..803550c91e 100644
--- a/game/modules/tome/data/timed_effects/other.lua
+++ b/game/modules/tome/data/timed_effects/other.lua
@@ -496,7 +496,7 @@ newEffect{
 newEffect{
 	name = "MILITANT_MIND", image = "talents/militant_mind.png",
 	desc = "Militant Mind",
-	long_desc = function(self, eff) return ("Increases physical power, spellpower and mindpower by %d."):format(eff.power) end,
+	long_desc = function(self, eff) return ("Increases physical power, physical save, spellpower, spell save, mindpower, and mental save by %d."):format(eff.power) end,
 	type = "other",
 	subtype = { miscellaneous=true },
 	status = "beneficial",
@@ -505,11 +505,17 @@ newEffect{
 		eff.damid = self:addTemporaryValue("combat_dam", eff.power)
 		eff.spellid = self:addTemporaryValue("combat_spellpower", eff.power)
 		eff.mindid = self:addTemporaryValue("combat_mindpower", eff.power)
+		eff.presid = self:addTemporaryValue("combat_physresist", eff.power)
+		eff.sresid = self:addTemporaryValue("combat_spellresist", eff.power)
+		eff.mresid = self:addTemporaryValue("combat_mentalresist", eff.power)
 	end,
 	deactivate = function(self, eff)
 		self:removeTemporaryValue("combat_dam", eff.damid)
 		self:removeTemporaryValue("combat_spellpower", eff.spellid)
 		self:removeTemporaryValue("combat_mindpower", eff.mindid)
+		self:removeTemporaryValue("combat_physresist", eff.presid)
+		self:removeTemporaryValue("combat_spellresist", eff.sresid)
+		self:removeTemporaryValue("combat_mentalresist", eff.mresid)
 	end,
 }
 
diff --git a/premake4.lua b/premake4.lua
index 08980cafd3..84485c2c11 100644
--- a/premake4.lua
+++ b/premake4.lua
@@ -28,10 +28,11 @@ solution "TEngine"
 
 configuration "windows"
 	libdirs {
-		"/c/mingw2/lib",
+		"/c/code/SDL/lib",
 	}
 	includedirs {
-		"/c/mingw2/include/SDL",
+		"/c/code/SDL/include/SDL2",
+		"/c/code/SDL/include",
 		"/c/mingw2/include/GL",
 	}
 
-- 
GitLab