From 146c93eee1118f11d92196ec1bc85844ce6d3084 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Wed, 9 Jun 2010 23:40:31 +0000
Subject: [PATCH] money auto-pickup

git-svn-id: http://svn.net-core.org/repos/t-engine4@768 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Player.lua            | 20 +++++++++++++++----
 .../tome/data/general/npcs/cold-drake.lua     |  4 ++--
 .../tome/data/general/objects/money.lua       |  2 ++
 .../tome/data/zones/carn-dum/objects.lua      |  6 ++++--
 4 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua
index 54353ddd19..35ef20fbec 100644
--- a/game/modules/tome/class/Player.lua
+++ b/game/modules/tome/class/Player.lua
@@ -89,11 +89,23 @@ function _M:move(x, y, force)
 	if moved then
 		game.level.map:moveViewSurround(self.x, self.y, 8, 8)
 
-		local obj = game.level.map:getObject(self.x, self.y, 1)
-		if obj and game.level.map:getObject(self.x, self.y, 2) then
+		-- Autopickup money
+		local i, nb = 1, 0
+		local obj = game.level.map:getObject(self.x, self.y, i)
+		while obj do
+			if obj.auto_pickup then
+				self:pickupFloor(i, true)
+				self:sortInven()
+			else
+				nb = nb + 1
+				i = i + 1
+			end
+			obj = game.level.map:getObject(self.x, self.y, i)
+		end
+		if nb >= 2 then
 			game.logSeen(self, "There is more than one objects lying here.")
-		elseif obj then
-			game.logSeen(self, "There is an item here: %s", obj:getName{do_color=true})
+		elseif nb == 1 then
+			game.logSeen(self, "There is an item here: %s", game.level.map:getObject(self.x, self.y, 1):getName{do_color=true})
 		end
 	end
 
diff --git a/game/modules/tome/data/general/npcs/cold-drake.lua b/game/modules/tome/data/general/npcs/cold-drake.lua
index 6c54c9c213..aeb02cba1a 100644
--- a/game/modules/tome/data/general/npcs/cold-drake.lua
+++ b/game/modules/tome/data/general/npcs/cold-drake.lua
@@ -48,13 +48,13 @@ newEntity{
 newEntity{ base = "BASE_NPC_COLD_DRAKE",
 	name = "cold drake hatchling", color=colors.WHITE, display="d",
 	desc = [[A drake hatchling, not too powerful in itself, but it usually comes with its brothers and sisters.]],
-	level_range = {7, 50}, exp_worth = 1,
+	level_range = {8, 50}, exp_worth = 1,
 	rarity = 7,
 	rank = 1, size_category = 2,
 	max_life = resolvers.rngavg(40,60),
 	combat_armor = 5, combat_def = 0,
 	on_melee_hit = {[DamageType.COLD]=resolvers.mbonus(7, 2)},
-	combat = { dam=resolvers.rngavg(15,20), atk=15, apr=25, dammod={str=0.7} },
+	combat = { dam=resolvers.rngavg(10,15), atk=15, apr=5, dammod={str=0.6} },
 
 	make_escort = {
 		{type="dragon", subtype="cold", name="cold drake hatchling", number=3, no_subescort=true},
diff --git a/game/modules/tome/data/general/objects/money.lua b/game/modules/tome/data/general/objects/money.lua
index 04cecf1e70..9cf87aa5fe 100644
--- a/game/modules/tome/data/general/objects/money.lua
+++ b/game/modules/tome/data/general/objects/money.lua
@@ -27,6 +27,7 @@ newEntity{
 	desc = [[All that glitters is not gold, all that is gold does not glitter.]],
 	on_prepickup = function(self, who, id)
 		who.money = who.money + self.money_value / 10
+		game.logPlayer(who, "You pickup %0.2f gold pieces.", self.money_value / 10)
 		-- Remove from the map
 		game.level.map:removeObject(who.x, who.y, id)
 		if who.player then
@@ -36,6 +37,7 @@ newEntity{
 		end
 		return true
 	end,
+	auto_pickup = true,
 }
 
 newEntity{ base = "BASE_MONEY", define_as = "MONEY_SMALL",
diff --git a/game/modules/tome/data/zones/carn-dum/objects.lua b/game/modules/tome/data/zones/carn-dum/objects.lua
index 15fe5bb4a9..e4a962b783 100644
--- a/game/modules/tome/data/zones/carn-dum/objects.lua
+++ b/game/modules/tome/data/zones/carn-dum/objects.lua
@@ -19,9 +19,10 @@
 
 load("/data/general/objects/objects.lua")
 
--- Artifact, droped by Rantha
+local Stats = require "engine.interface.ActorStats"
 
-newEntity{ base = "BASE_SHIELD",
+-- Artifact, droped by Rantha
+newEntity{ base = "BASE_LEATHER_BOOT",
 	define_as = "FROST_TREADS",
 	name = "Frost Treads", unique=true,
 	desc = [[A pair of leather boots. Cold to the touch, they radiate a cold blue light.]],
@@ -40,5 +41,6 @@ newEntity{ base = "BASE_SHIELD",
 			[DamageType.COLD] = 20,
 			[DamageType.NATURE] = 10,
 		},
+		inc_stats = { [Stats.STAT_STR] = 4, [Stats.STAT_DEX] = 4, [Stats.STAT_CUN] = 4, },
 	},
 }
-- 
GitLab