Page 1 of 1

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

Posted: Wed May 08, 2013 11:44 am
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)

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

Posted: Wed May 08, 2013 1:47 pm
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.

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

Posted: Wed May 08, 2013 2:20 pm
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).

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

Posted: Wed May 08, 2013 2:37 pm
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.

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

Posted: Wed May 08, 2013 2:53 pm
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.