[1.0.4] Tactical AI incorrectly thinks it is hitting itself

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 incorrectly thinks it is hitting itself

#1 Post by jenx »

This occurs with Talents like Grasping Moss, which have no required target.

For some reason, this code in Tactical.lua

Code: Select all

				-- 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
and the talent code:

Code: Select all

newTalent{
	name = "Grasping Moss",
	type = {"wild-gift/moss", 1},
	require = gifts_req1,
	points = 5,
	cooldown = 16,
	equilibrium = 5,
	no_energy = true,
	tactical = { ATTACKAREA = {NATURE=1}, DISABLE = {pin = 1} },
	getDamage = function(self, t) return self:combatTalentMindDamage(t, 6, 40) end,
	getDuration = function(self, t) return 3 + math.ceil(self:getTalentLevel(t)) end,
	getSlow = function(self, t) return 30 + math.ceil(self:getTalentLevel(t) * 6) end,
	getPin = function(self, t) return 20 + math.ceil(self:getTalentLevel(t) * 5) end,
	range = 0,
	radius = function(self, t)
		return 2 + math.floor(self:getTalentLevelRaw(t)/2)
	end,
	target = function(self, t)
		return {type="ball", range=self:getTalentRange(t), radius=self:getTalentRadius(t)}
	end,
	action = function(self, t)
		-- Add a lasting map effect
		game.level.map:addEffect(self,
			self.x, self.y, t.getDuration(self, t),
			DamageType.GRASPING_MOSS, {dam=self:mindCrit(t.getDamage(self, t)), pin=t.getPin(self, t), slow=t.getSlow(self, t)},
			self:getTalentRadius(t),
			5, nil,
			{type="moss"},
			nil, false, false
		)
		activate_moss(self, t.id)
		game:playSoundNear(self, "talents/slime")
		return true
	end,
	info = function(self, t)
		local damage = t.getDamage(self, t)
		local duration = t.getDuration(self, t)
		local slow = t.getSlow(self, t)
		local pin = t.getPin(self, t)
		local radius = self:getTalentRadius(t)
		return ([[Instantly grow a moss circle of radius %d at your feet.
		Each turn the moss deals %0.2f nature damage to any foes with in its radius.
		This moss is very thick and sticky, all foes passing through it have their movement speed reduced by %d%% and have %d%% chances to be stuck on the ground for 4 turns.
		The moss lasts %d turns.
		Using a moss talent takes no turn but places all other moss talents on a 3 turns cooldown.
		The damage will increase with your Mindpower.]]):
		format(radius, damDesc(self, DamageType.NATURE, damage), slow, pin, duration)
	end,
}
result in the tactical ai thinking that this talent will hit itself. Hence it never uses it (or similar talents).

I'm hoping someone can help me adjust the checking routine in tactical.lua.
MADNESS rocks

Post Reply