[1.0.1] Two errors in Mind Storm lua code ???

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.1] Two errors in Mind Storm lua code ???

#1 Post by jenx »

Here is a section of the Mind Storm lua code:

Code: Select all

	doMindStorm = function(self, t, p)
		local tgts = {}
		local tgts_oc = {}
		local grids = core.fov.circle_grids(self.x, self.y, self:getTalentRange(t), true)
		for x, yy in pairs(grids) do for y, _ in pairs(grids[x]) do
			local a = game.level.map(x, y, Map.ACTOR)
			if a and self:reactionToward(a) < 0 then
				tgts[#tgts+1] = a
				tgts_oc[#tgts_oc+1] = a
			end
		end end	
		
		local wrath = self:hasEffect(self.EFF_FOCUSED_WRATH)
		
		-- Randomly take targets
		local tg = self:getTalentTarget(t)
		for i = 1, t.getTargetCount(self, t) do
			if #tgts <= 0 or self:getFeedback() < 5 then break end
			local a, id = rng.table(tgts)
			table.remove(tgts, id)
			-- Divert the Bolt?
			if wrath then
				self:projectile(tg, wrath.target.x, wrath.target.y, DamageType.MIND, self:mindCrit(t.getDamage(self, t), nil, wrath.power))
			else
				self:projectile(tg, a.x, a.y, DamageType.MIND, self:mindCrit(t.getDamage(self, t)))
			end
			self:incFeedback(-5)
		end
Two questions.
(1) should
for x, yy in pairs(grids) do for y, _ in pairs(grids[x]) do
be
for x, y in pairs(grids) do for y, _ in pairs(grids[x]) do

(2) the description says each bolt costs 1 feedback, yet it says:
self:incFeedback(-5)

should this be
self:incFeedback(-1)
MADNESS rocks

nate
Wyrmic
Posts: 261
Joined: Fri Jan 18, 2013 8:35 am

Re: [1.0.1] Two errors in Mind Storm lua code ???

#2 Post by nate »

jenx wrote:Here is a section of the Mind Storm lua code:

Two questions.
(1) should
for x, yy in pairs(grids) do for y, _ in pairs(grids[x]) do
be
for x, y in pairs(grids) do for y, _ in pairs(grids[x]) do
No-- although it doesn't really matter, your code is equivalent to the existing code (yy is not used, and if both in pairs used 'y', the second, nested in pairs would take precedence).

As a little more explanation in case you're curious, trying to learn how all this works, "grids" is a table of tables such that you can use it to look up x, y coordinates-- grids[n][n] should be understood as grids[x][y]. So you need to do an "in pairs" on two different tables: grids, and grids[x]. When you're doing the first in pairs on grids, you're getting a key and a value for each 'x' in grids. The key is setup such that it represents the x coordinate of the grid being considered, but the value is just the address of a subtable of 'grids'-- the value of grids[x] is unimportant. If one was going to be anal, one might instead suggest "for x, _ in pairs(grids) do for y, _ in pairs(grids[x]) do", since you're just discarding that initial value.
Proud father of Fx4fx and Chronometer add-ons; proud mother of Fated add-on

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: [1.0.1] Two errors in Mind Storm lua code ???

#3 Post by edge2054 »

I'm working on a patch now and I'll fix the cost discrepancy. No promises that it will make it into 1.0.2 though.

Either way though the cost should be 5 so the description is wrong. (I missed the description when I raised the cost).

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

Re: [1.0.1] Two errors in Mind Storm lua code ???

#4 Post by jenx »

excellent - I'm trying out the discharge tree on inghtmare mode. I still can't get my head around how it works, but I'm learning. One other issue with mindstorm is, if an npc swaps places with you, or you're knocked back, etc, it ends. I think it should only turn off though if the player initiatives the move/talent etc.
MADNESS rocks

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: [1.0.1] Two errors in Mind Storm lua code ???

#5 Post by edge2054 »

That's working as intended.

Keep in mind from the players perspective if you want to stop a psionic channel you have limited options. Forcing the enemy to move is a strategic option.

Post Reply