From 49c00b543bcff89438181b11822571ada813d354 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Tue, 5 Jan 2010 01:26:48 +0000
Subject: [PATCH] combat

git-svn-id: http://svn.net-core.org/repos/t-engine4@200 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/interface/Combat.lua        |  8 ++++++++
 game/modules/tome/data/general/objects/2hmaces.lua  |  2 +-
 game/modules/tome/data/general/objects/2hswords.lua |  2 +-
 game/modules/tome/data/general/objects/knifes.lua   | 12 ++++++------
 game/modules/tome/data/general/objects/swords.lua   |  2 +-
 game/modules/tome/data/zones/trollshaws/objects.lua |  1 +
 6 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/game/modules/tome/class/interface/Combat.lua b/game/modules/tome/class/interface/Combat.lua
index 99e524f737..bd44e82b06 100644
--- a/game/modules/tome/class/interface/Combat.lua
+++ b/game/modules/tome/class/interface/Combat.lua
@@ -124,6 +124,8 @@ function _M:attackTargetWith(target, weapon, damtype, mult)
 	local hitted = false
 	if self:checkHit(atk, def) then
 		local dam = dam - math.max(0, armor - apr)
+		local damrange = self:combatDamageRange(weapon)
+		dam = rng.range(dam, dam * damrange)
 		local crit
 		dam = dam * mult
 		dam, crit = self:physicalCrit(dam, weapon)
@@ -197,6 +199,12 @@ function _M:combatCrit(weapon)
 	return self.combat_physcrit + (self:getCun() - 10) * 0.3 + (weapon.physcrit or 1)
 end
 
+--- Gets the damage range
+function _M:combatDamageRange(weapon)
+	weapon = weapon or self.combat
+	return (self.combat_damrange or 0) + (weapon.damrange or 1.3)
+end
+
 --- Gets the damage
 function _M:combatDamage(weapon)
 	weapon = weapon or self.combat
diff --git a/game/modules/tome/data/general/objects/2hmaces.lua b/game/modules/tome/data/general/objects/2hmaces.lua
index aef1eea6b7..e136b64c22 100644
--- a/game/modules/tome/data/general/objects/2hmaces.lua
+++ b/game/modules/tome/data/general/objects/2hmaces.lua
@@ -6,7 +6,7 @@ newEntity{
 	display = "\\", color=colors.SLATE,
 	encumber = 5,
 	rarity = 3,
-	combat = { talented = "mace", },
+	combat = { talented = "mace", damrange = 1.5 },
 	desc = [[Massive two-handed maul.]],
 	twohanded = true,
 }
diff --git a/game/modules/tome/data/general/objects/2hswords.lua b/game/modules/tome/data/general/objects/2hswords.lua
index ff103a99cb..f5dc384c51 100644
--- a/game/modules/tome/data/general/objects/2hswords.lua
+++ b/game/modules/tome/data/general/objects/2hswords.lua
@@ -6,7 +6,7 @@ newEntity{
 	display = "/", color=colors.SLATE,
 	encumber = 3,
 	rarity = 3,
-	combat = { talented = "sword", },
+	combat = { talented = "sword", damrange = 1.6 },
 	desc = [[Massive two-handed swords.]],
 	twohanded = true,
 }
diff --git a/game/modules/tome/data/general/objects/knifes.lua b/game/modules/tome/data/general/objects/knifes.lua
index b4384412f1..5519b72ef5 100644
--- a/game/modules/tome/data/general/objects/knifes.lua
+++ b/game/modules/tome/data/general/objects/knifes.lua
@@ -5,7 +5,7 @@ newEntity{
 	display = "/", color=colors.WHITE,
 	encumber = 1,
 	rarity = 3,
-	combat = { talented = "knife", },
+	combat = { talented = "knife", damrange = 1.3 },
 	desc = [[Sharp, long, and deadly.]],
 --	egos = "/data/general/objects/egos/swords.lua", egos_chance = resolvers.mbonus(40, 5),
 }
@@ -19,7 +19,7 @@ newEntity{ base = "BASE_KNIFE",
 		dam = resolvers.rngavg(4,6),
 		apr = 5,
 		physcrit = 4,
-		dammod = {dex=1},
+		dammod = {dex=0.45,str=0.45},
 	},
 }
 
@@ -32,7 +32,7 @@ newEntity{ base = "BASE_KNIFE",
 		dam = resolvers.rngavg(8,15),
 		apr = 6,
 		physcrit = 5,
-		dammod = {dex=1},
+		dammod = {dex=0.45,str=0.45},
 	},
 }
 
@@ -45,7 +45,7 @@ newEntity{ base = "BASE_KNIFE",
 		dam = resolvers.rngavg(18,25),
 		apr = 7,
 		physcrit = 6,
-		dammod = {dex=1},
+		dammod = {dex=0.45,str=0.45},
 	},
 }
 
@@ -58,7 +58,7 @@ newEntity{ base = "BASE_KNIFE",
 		dam = resolvers.rngavg(38,45),
 		apr = 9,
 		physcrit = 8,
-		dammod = {dex=1},
+		dammod = {dex=0.45,str=0.45},
 	},
 }
 
@@ -71,6 +71,6 @@ newEntity{ base = "BASE_KNIFE",
 		dam = resolvers.rngavg(48,55),
 		apr = 9,
 		physcrit = 10,
-		dammod = {dex=1},
+		dammod = {dex=0.45,str=0.45},
 	},
 }
diff --git a/game/modules/tome/data/general/objects/swords.lua b/game/modules/tome/data/general/objects/swords.lua
index d2554bdcb2..c3c9df1b66 100644
--- a/game/modules/tome/data/general/objects/swords.lua
+++ b/game/modules/tome/data/general/objects/swords.lua
@@ -5,7 +5,7 @@ newEntity{
 	display = "/", color=colors.SLATE,
 	encumber = 3,
 	rarity = 3,
-	combat = { talented = "sword", },
+	combat = { talented = "sword", damrange = 1.4},
 	desc = [[Sharp, long, and deadly.]],
 --	egos = "/data/general/objects/egos/swords.lua", egos_chance = resolvers.mbonus(40, 5),
 }
diff --git a/game/modules/tome/data/zones/trollshaws/objects.lua b/game/modules/tome/data/zones/trollshaws/objects.lua
index 005406a4f4..3448445381 100644
--- a/game/modules/tome/data/zones/trollshaws/objects.lua
+++ b/game/modules/tome/data/zones/trollshaws/objects.lua
@@ -12,5 +12,6 @@ newEntity{ base = "BASE_GREATMAUL",
 		apr = 7,
 		physcrit = 1.5,
 		dammod = {str=1.3},
+		damrange = 1.7,
 	},
 }
-- 
GitLab