From edc148dbcdb5fd7a15cd07381df2a8916fef73ea Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Thu, 11 Aug 2011 21:03:38 +0000
Subject: [PATCH] limit

git-svn-id: http://svn.net-core.org/repos/t-engine4@4115 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/data/talents/spells/shades.lua | 9 ++++++---
 src/wait.c                                       | 5 +++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/game/modules/tome/data/talents/spells/shades.lua b/game/modules/tome/data/talents/spells/shades.lua
index 56056a9ce1..bbf639d6e9 100644
--- a/game/modules/tome/data/talents/spells/shades.lua
+++ b/game/modules/tome/data/talents/spells/shades.lua
@@ -219,6 +219,7 @@ newTalent{
 	tactical = { ATTACK = 2, ESCAPE = 1 },
 	requires_target = true,
 	getDuration = function(self, t) return math.floor(3 + self:getTalentLevel(t)) end,
+	getHealth = function(self, t) return 0.2 + self:combatTalentSpellDamage(t, 20, 500) / 1000 end,
 	action = function(self, t)
 		-- Find space
 		local x, y = util.findFreeGrid(self.x, self.y, 1, true, {[Map.ACTOR]=true})
@@ -242,7 +243,8 @@ newTalent{
 		m.on_added_to_level = nil
 
 		m.energy.value = 0
-		m.life = m.life
+		m.max_life = m.max_life * t.getHealth(self, t)
+		m.life = util.bound(m.life, 0, m.max_life)
 		m.forceLevelup = function() end
 		m.on_die = nil
 		m.on_acquire_target = nil
@@ -269,7 +271,8 @@ newTalent{
 		return true
 	end,
 	info = function(self, t)
-		return ([[Through the shadows you forge a temporary copy of yourself, existing for %d turns.]]):
-		format(t.getDuration(self, t))
+		return ([[Through the shadows you forge a temporary copy of yourself, existing for %d turns.
+		The copy possess your exact talents and stats and has %d%% life.]]):
+		format(t.getDuration(self, t), t.getHealth(self, t) * 100)
 	end,
 }
diff --git a/src/wait.c b/src/wait.c
index 5c687d4a5f..cd6c07b976 100644
--- a/src/wait.c
+++ b/src/wait.c
@@ -93,6 +93,11 @@ static void hook_wait_display(lua_State *L, lua_Debug *ar)
 {
 	waited_count++;
 	SDL_PumpEvents();
+
+	static int last_tick = 0;
+	int now = SDL_GetTicks();
+	if (now - last_tick < 300) return;
+	last_tick = now;
 	on_redraw();
 }
 
-- 
GitLab