[1.0.4] tactical ai never uses Mindlash...

Where bugs go to lie down and rest

Moderator: Moderator

Post Reply
Message
Author
jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

[1.0.4] tactical ai never uses Mindlash...

#1 Post by jenx »

...but I can't figure out why. I only know that my tactical addon ai spits out to the log every talent that is available *and* can be used. Mindlash is available, but can't be used, because it never retrieves a tactic from the talent.

The problem is that this code from tactical.lua:

Code: Select all

if t_avail then
				-- Project the talent if possible, counting foes and allies hit
				local foes_hit = {}
				local allies_hit = {}
				local self_hit = {}
				local typ = engine.Target:getType(tg or default_tg)
				if tg or self:getTalentRequiresTarget(t) then
					local target_actor = self.ai_target.actor or self
					self:project(typ, ax, ay, function(px, py)
						local act = game.level.map(px, py, engine.Map.ACTOR)
						if act and not act.dead then
							if self:reactionToward(act) < 0 then
								print("[DEBUG] hit a foe!")
								foes_hit[#foes_hit+1] = act
							elseif (typ.selffire) and (act == self) then
								print("[DEBUG] hit self!")
								self_hit[#self_hit+1] = act
							elseif typ.friendlyfire then
								print("[DEBUG] hit an ally!")
								allies_hit[#allies_hit+1] = act
							end
						end
					end)
				end
				-- Evaluate the tactical weights and weight functions
				for tact, val in pairs(t.tactical) do
					if type(val) == "function" then val = val(self, t, self.ai_target.actor) or 0 end
					-- Handle damage_types and resistances
					local nb_foes_hit, nb_allies_hit, nb_self_hit = 0, 0, 0
					if type(val) == "table" then
						for damtype, damweight in pairs(val) do
							-- Allows a shortcut to just say FIRE instead of DamageType.FIRE in talent's tactical table
							damtype = DamageType[damtype] or damtype
							-- Checks a weapon's damtype
							if damtype == "weapon" then
								damtype = (weapon and weapon.damtype) or DamageType.PHYSICAL
							end
							local pen = 0
							if self.resists_pen then pen = (self.resists_pen.all or 0) + (self.resists_pen[damtype] or 0) end
							local check_resistance = function(actor_list)
								local weighted_sum = 0
								for i, act in ipairs(actor_list) do
									local res = math.min((act.resists.all or 0) + (act.resists[damtype] or 0), (act.resists_cap.all or 0) + (act.resists_cap[damtype] or 0))
									res = res * (100 - pen) / 100
									local damweight = damweight
									if type(damweight) == "function" then damweight = damweight(self, t, act) or 0 end
									-- Handles status effect immunity
									damweight = damweight * (act:canBe(damtype) and 1 or 0)
									weighted_sum = weighted_sum + damweight * (100 - res) / 100
								end
								return weighted_sum
							end
							nb_foes_hit = check_resistance(foes_hit)
							nb_self_hit = check_resistance(self_hit)
							nb_allies_hit = check_resistance(allies_hit)
						end
						val = 1
					-- Or assume no resistances
					else
						nb_foes_hit = #foes_hit
						nb_self_hit = #self_hit
						nb_allies_hit = #allies_hit
					end
					-- Apply the selffire and friendlyfire options
					nb_self_hit = nb_self_hit * (type(typ.selffire) == "number" and typ.selffire / 100 or 1)
					nb_allies_hit = nb_allies_hit * (type(typ.friendlyfire) == "number" and typ.friendlyfire / 100 or 1)
					-- Use the player set ai_talents weights
					val = val * (self.ai_talents and self.ai_talents[t.id] or 1) * (1 + lvl / 5)
					-- Update the weight by the dummy projection data
					-- Also force scaling if the talent requires a target (stand-in for canProject)
					if self:getTalentRequiresTarget(t) or nb_foes_hit > 0 or nb_allies_hit > 0 or nb_self_hit > 0 then
						val = val * (nb_foes_hit - ally_compassion * nb_allies_hit - self_compassion * nb_self_hit)
					end
					-- Only take values greater than 0... allows the ai_talents to turn talents off
					if val > 0 and not self:hasEffect(self.EFF_RELOADING) then
						if not avail[tact] then avail[tact] = {} end
						-- Save the tactic, if the talent is instant it gets a huge bonus
						-- Note the addition of a less than one random value, this means the sorting will randomly shift equal values
						val = ((t.no_energy==true) and val * 10 or val) + rng.float(0, 0.9)
						avail[tact][#avail[tact]+1] = {val=val, tid=tid, nb_foes_hit=nb_foes_hit, nb_allies_hit=nb_allies_hit, nb_self_hit=nb_self_hit}
						print(self.name, self.uid, "tactical ai talents can use", t.name, tid, tact, "weight", val)
						ok = true
					end
				end
never returns a tactic from the talent:

Code: Select all

newTalent{
	name = "Mindlash",
	type = {"psionic/focus", 1},
	require = psi_wil_req1,
	points = 5,
	random_ego = "attack",
	cooldown = function(self, t)
		local c = 5
		local gem_level = getGemLevel(self)
		return math.max(c - gem_level, 0)
	end,
	psi = 10,
	tactical = { ATTACK = function(self, t, target)
		local val = { PHYSICAL = 2}
		local gem_level = getGemLevel(self)
		if gem_level > 0 and not target.dead and self:knowTalent(self.T_CONDUIT) and self:isTalentActive(self.T_CONDUIT) then
			local c =  self:getTalentFromId(self.T_CONDUIT)
			local auras = self:isTalentActive(c.id)
			if auras.k_aura_on then
				val.PHYSICAL = val.PHYSICAL + 1
			end
			if auras.t_aura_on then
				val.FIRE = 1
			end
			if auras.c_aura_on then
				val.LIGHTNING = 1
			end
			return val
		end
		return 0
	end },
MADNESS rocks

Hachem_Muche
Uruivellas
Posts: 744
Joined: Thu Nov 18, 2010 6:42 pm

Re: [1.0.4] tactical ai never uses Mindlash...

#2 Post by Hachem_Muche »

The talent tactical table definition has an error that causes mindlash to have zero weight unless conduit is active.
fix:

Code: Select all

 game/modules/tome/data/talents/psionic/focus.lua | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/game/modules/tome/data/talents/psionic/focus.lua b/game/modules/tome/data/talents/psionic/focus.lua
index 2ef66e7..e5916d7 100644
--- a/game/modules/tome/data/talents/psionic/focus.lua
+++ b/game/modules/tome/data/talents/psionic/focus.lua
@@ -49,9 +49,8 @@ newTalent{
 			if auras.c_aura_on then
 				val.LIGHTNING = 1
 			end
-			return val
 		end
-		return 0
+		return val
 	end },
 	range = function(self, t)
 		local r = 5
Author of the Infinite 500 and PlenumTooltip addons, and the joys of Scaling in ToME.

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: [1.0.4] tactical ai never uses Mindlash...

#3 Post by jenx »

Hachem_Muche wrote:The talent tactical table definition has an error that causes mindlash to have zero weight unless conduit is active.
fix:

Code: Select all

 game/modules/tome/data/talents/psionic/focus.lua | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/game/modules/tome/data/talents/psionic/focus.lua b/game/modules/tome/data/talents/psionic/focus.lua
index 2ef66e7..e5916d7 100644
--- a/game/modules/tome/data/talents/psionic/focus.lua
+++ b/game/modules/tome/data/talents/psionic/focus.lua
@@ -49,9 +49,8 @@ newTalent{
 			if auras.c_aura_on then
 				val.LIGHTNING = 1
 			end
-			return val
 		end
-		return 0
+		return val
 	end },
 	range = function(self, t)
 		local r = 5
I was pretty sure it was the val = 0 line, but I couldn't see why. Hopefully this goes into 1.0.5.

Testing tactical.lua has shown me how many talents are not used or misused (too early, too late, wrong location). I'm working my way through them slowly.

Perhaps I should open a debug character and run through the farportal to find random bosses....?
MADNESS rocks

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: [1.0.4] tactical ai never uses Mindlash...

#4 Post by jenx »

Hachem_Muche wrote:The talent tactical table definition has an error that causes mindlash to have zero weight unless conduit is active.
fix:

Code: Select all

 game/modules/tome/data/talents/psionic/focus.lua | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/game/modules/tome/data/talents/psionic/focus.lua b/game/modules/tome/data/talents/psionic/focus.lua
index 2ef66e7..e5916d7 100644
--- a/game/modules/tome/data/talents/psionic/focus.lua
+++ b/game/modules/tome/data/talents/psionic/focus.lua
@@ -49,9 +49,8 @@ newTalent{
 			if auras.c_aura_on then
 				val.LIGHTNING = 1
 			end
-			return val
 		end
-		return 0
+		return val
 	end },
 	range = function(self, t)
 		local r = 5
i can confirm that Mindlash now works for tactical.lua with these changes, as I'm testing it in my addon.
MADNESS rocks

Doctornull
Sher'Tul Godslayer
Posts: 2402
Joined: Tue Jun 18, 2013 10:46 pm
Location: Ambush!

Re: [1.0.4] tactical ai never uses Mindlash...

#5 Post by Doctornull »

Nice. This ought to make Spire dragons a bit more ... inspired? :lol:
Check out my addons: Nullpack (classes), Null Tweaks (items & talents), and New Gems fork.

Post Reply