From 13b1bc6daf660d2e3e5b23e998bd73c1fa6d80d8 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Wed, 11 May 2011 12:25:42 +0000
Subject: [PATCH] tweak tactical ai

git-svn-id: http://svn.net-core.org/repos/t-engine4@3339 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engines/default/engine/Zone.lua            |  2 +-
 game/modules/tome/ai/tactical.lua               |  8 ++++----
 game/modules/tome/class/GameState.lua           |  2 +-
 .../tome/class/generator/actor/Arena.lua        |  2 +-
 .../tome/data/general/npcs/orc-gorbat.lua       | 17 ++++++++++++++---
 .../tome/data/general/objects/scrolls.lua       |  4 +++-
 .../tome/data/talents/misc/inscriptions.lua     |  4 ++--
 7 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/game/engines/default/engine/Zone.lua b/game/engines/default/engine/Zone.lua
index 2910c631ac..553f0a81b7 100644
--- a/game/engines/default/engine/Zone.lua
+++ b/game/engines/default/engine/Zone.lua
@@ -167,7 +167,7 @@ function _M:checkFilter(e, filter, type)
 	if not filter then return true end
 	if filter.ignore and self:checkFilter(e, filter.ignore, type) then return false end
 
---	print("Checking filter", filter.type, filter.subtype)
+	forceprint("Checking filter", filter.type, filter.subtype, "::", e.type,e.subtype,e.name)
 	if filter.type and filter.type ~= e.type then return false end
 	if filter.subtype and filter.subtype ~= e.subtype then return false end
 	if filter.name and filter.name ~= e.name then return false end
diff --git a/game/modules/tome/ai/tactical.lua b/game/modules/tome/ai/tactical.lua
index a944d46abf..a460aadb79 100644
--- a/game/modules/tome/ai/tactical.lua
+++ b/game/modules/tome/ai/tactical.lua
@@ -279,22 +279,22 @@ newAI("use_tactical", function(self)
 		if avail.attack and self.ai_target.actor then
 			-- Use the foe/ally ratio from the best attack talent
 			table.sort(avail.attack, function(a,b) return a.val > b.val end)
-			want.attack = (avail.attack[1].nb_foes_hit or 1) - ally_compassion * (avail.attack[1].nb_allies_hit or 0) - self_compassion * (avail.attack[1].nb_self_hit or 0)
+			want.attack = avail.attack[1].val
 		end
 		if avail.disable and self.ai_target.actor then
 			-- Use the foe/ally ratio from the best disable talent
 			table.sort(avail.disable, function(a,b) return a.val > b.val end)
-			want.disable = (want.attack or 0) + (avail.disable[1].nb_foes_hit or 1) - ally_compassion * (avail.disable[1].nb_allies_hit or 0) - self_compassion * (avail.disable[1].nb_self_hit or 0)
+			want.disable = (want.attack or 0) + avail.disable[1].val
 		end
 		if avail.attackarea and self.ai_target.actor then
 			-- Use the foe/ally ratio from the best attackarea talent
 			table.sort(avail.attackarea, function(a,b) return a.val > b.val end)
-			want.attackarea = (want.attack or 0) + (avail.attackarea[1].nb_foes_hit or nb_foes_seen) - ally_compassion * (avail.attackarea[1].nb_allies_hit or nb_allies_seen) - self_compassion * (avail.attackarea[1].nb_self_hit or 0)
+			want.attackarea = avail.attackarea[1].val
 		end
 
 		-- Need buffs
 		if avail.buff and want.attack and want.attack > 0 then
-			want.buff = math.max(0.01, want.attack - 1)
+			want.buff = math.max(0.01, want.attack + 0.5)
 		end
 
 		print("Tactical ai report for", self.name)
diff --git a/game/modules/tome/class/GameState.lua b/game/modules/tome/class/GameState.lua
index fa7613824f..88bd04ba9e 100644
--- a/game/modules/tome/class/GameState.lua
+++ b/game/modules/tome/class/GameState.lua
@@ -949,7 +949,7 @@ function _M:entityFilter(zone, e, filter, type)
 		if not filter.ingore_material_restriction then
 			local min_mlvl = util.getval(zone.min_material_level)
 			local max_mlvl = util.getval(zone.max_material_level)
-			if min_mlvl then
+			if min_mlvl and not e.material_level_min_only then
 				if not e.material_level then return true end
 				if e.material_level < min_mlvl then return false end
 			end
diff --git a/game/modules/tome/class/generator/actor/Arena.lua b/game/modules/tome/class/generator/actor/Arena.lua
index d3887a073e..d20fec86fe 100644
--- a/game/modules/tome/class/generator/actor/Arena.lua
+++ b/game/modules/tome/class/generator/actor/Arena.lua
@@ -478,7 +478,7 @@ function _M:generateOne(e)
 			end
 		else
 			m.on_added = function (self)
-				if m.on_added_orig then m.on_added_orig(self) end
+				if self.on_added_orig then self.on_added_orig(self) end
 				game.level.arena.danger = game.level.arena.danger + self.arenaPower
 			end
 		end
diff --git a/game/modules/tome/data/general/npcs/orc-gorbat.lua b/game/modules/tome/data/general/npcs/orc-gorbat.lua
index a5df85a101..5c19075549 100644
--- a/game/modules/tome/data/general/npcs/orc-gorbat.lua
+++ b/game/modules/tome/data/general/npcs/orc-gorbat.lua
@@ -42,7 +42,7 @@ newEntity{
 	open_door = true,
 	resolvers.sustains_at_birth(),
 
-	resolvers.inscriptions(2, "infusion"),
+--	resolvers.inscriptions(2, "infusion"),
 
 	autolevel = "warrior",
 	ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=3, },
@@ -55,6 +55,17 @@ newEntity{
 	end,
 }
 
+newEntity{ base = "BASE_NPC_ORC_GORBAT",
+	name = "orc TEST", color=colors.YELLOW,
+	desc = [[A fierce orc attuned to the wilds.]],
+	level_range = {30, nil}, exp_worth = 1,
+	rarity = 1,
+	ai = "tactical",
+	ai_state = { talent_in=1, },
+	rank=3,
+	resolvers.inscriptions(1, {"speed rune"}),
+}
+
 newEntity{ base = "BASE_NPC_ORC_GORBAT",
 	name = "orc summoner", color=colors.YELLOW,
 	desc = [[A fierce orc attuned to the wilds.]],
@@ -110,7 +121,7 @@ newEntity{ base = "BASE_NPC_ORC_GORBAT",
 	resolvers.racial(),
 }
 
-newEntity{ base = "BASE_NPC_ORC",
+newEntity{ base = "BASE_NPC_ORC_GORBAT",
 	name = "orc master wyrmic", color=colors.LIGHT_STEEL_BLUE,
 	desc = [[A fierce soldier-orc highly trained in the discipline of dragons.]],
 	level_range = {30, nil}, exp_worth = 1,
@@ -143,7 +154,7 @@ newEntity{ base = "BASE_NPC_ORC",
 	resolvers.racial(),
 }
 
-newEntity{ base = "BASE_NPC_ORC",
+newEntity{ base = "BASE_NPC_ORC_GORBAT",
 	name = "orc mage-hunter", color=colors.HONEYDEW,
 	desc = [[An orc clad in massive armour, magic seems to die down all around him.]],
 	level_range = {30, nil}, exp_worth = 1,
diff --git a/game/modules/tome/data/general/objects/scrolls.lua b/game/modules/tome/data/general/objects/scrolls.lua
index 1ec6bd5637..e39c1d12ec 100644
--- a/game/modules/tome/data/general/objects/scrolls.lua
+++ b/game/modules/tome/data/general/objects/scrolls.lua
@@ -46,6 +46,7 @@ newEntity{
 	fire_destroy = {{100,1}, {200,2}, {400,5}, {600,10}, {1200,20}},
 	desc = [[Natural infusions may be grafted onto your body, granting you an on-demand ability.]],
 	egos = "/data/general/objects/egos/infusions.lua", egos_chance = resolvers.mbonus(30, 5),
+	material_level_min_only = true,
 
 	power_source = {nature=true},
 	use_simple = { name="inscribe your skin with the infusion.", use = function(self, who, inven, item)
@@ -68,6 +69,7 @@ newEntity{
 	fire_destroy = {{10,1}, {20,2}, {40,5}, {60,10}, {120,20}},
 	desc = [[Magical runes may be inscribed onto your body, granting you an on-demand ability.]],
 	egos = "/data/general/objects/egos/infusions.lua", egos_chance = resolvers.mbonus(30, 5),
+	material_level_min_only = true,
 
 	power_source = {arcane=true},
 	use_simple = { name="inscribe your skin with the rune.", use = function(self, who, inven, item)
@@ -356,7 +358,7 @@ newEntity{ base = "BASE_RUNE",
 		dur = resolvers.mbonus_level(4, 3),
 		power = resolvers.mbonus_level(30, 30, function(e, v) return v * 0.3 end),
 		use_stat_mod = 0.3,
-		nb_uses = resolvers.mbonus_level(7, 4),
+		nb_uses = 2, --resolvers.mbonus_level(7, 4),
 	},
 	inscription_talent = "RUNE:_SPEED",
 }
diff --git a/game/modules/tome/data/talents/misc/inscriptions.lua b/game/modules/tome/data/talents/misc/inscriptions.lua
index 6477ac115d..cacc178d03 100644
--- a/game/modules/tome/data/talents/misc/inscriptions.lua
+++ b/game/modules/tome/data/talents/misc/inscriptions.lua
@@ -410,7 +410,7 @@ newInscription{
 	type = {"inscriptions/runes", 1},
 	points = 1,
 	is_spell = true,
-	tactical = { DEFEND = 1, ESCAPE = 1 },
+	tactical = { DEFEND = 3, ESCAPE = 2 },
 	action = function(self, t)
 		local data = self:getInscriptionData(t.short_name)
 		self:setEffect(self.EFF_INVISIBILITY, data.dur, {power=data.power + data.inc_stat})
@@ -434,7 +434,7 @@ newInscription{
 	points = 1,
 	is_spell = true,
 	no_energy = true,
-	tactical = { BUFF = 2 },
+	tactical = { BUFF = 4 },
 	action = function(self, t)
 		local data = self:getInscriptionData(t.short_name)
 		self:setEffect(self.EFF_SPEED, data.dur, {power=(data.power + data.inc_stat) / 100})
-- 
GitLab