summary refs log tree commit diff
path: root/auto-tune/data/attune-mindstar.lua
blob: 7a4d9a6c711a3b026ca5be957fce2c9729f4e717 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
local Talents = require "engine.interface.ActorTalents"
local DamageType = require "engine.DamageType"

attune_mindstar = Talents.talents_def.T_ATTUNE_MINDSTAR
if attune_mindstar then
	attune_mindstar.hasValidMindstar = function(self, slot)
		local o = self:getInven(slot) and self:getInven(slot)[1]

		if not o or not o.combat or not o.combat.talented == "mindstar" then
			return nil
		-- exclude fixedarts (those that don't teach Attune Mindstar)
		elseif not o.wielder or not o.wielder.learn_talent or not o.wielder.learn_talent[self.T_ATTUNE_MINDSTAR] then
			return nil
		end
		
		return o
	end -- hasValidMindstar

	attune_mindstar.attune = function(self, o, dt)
		if not o then return end
		o.combat.damtype = dt
		game.logPlayer(self, "You attune your %s to deal %s%s#LAST# damage.", o:getName{do_color=1}, DamageType:get(dt).text_color, DamageType:get(dt).name)
	end -- attune

	Talents.talents_def.T_ATTUNE_MINDSTAR.action = function(self, t)
		-- do nothing if disarmed
		if self:attr("disarmed") then
			return nil
		end

		local mh = t.hasValidMindstar(self, "MAINHAND")
		local oh = t.hasValidMindstar(self, "OFFHAND")
		local tk = t.hasValidMindstar(self, "PSIONIC_FOCUS")

		-- find the first valid mindstar so we can switch all of them to the opposite of that one
		local primary = mh or oh or tk
		if not primary then
			game.logPlayer(self, "You can't attune a mindstar you're not wielding!")
			return
		end

		local wanted = DamageType.MIND
		if primary.combat.damtype == DamageType.MIND then
			wanted = DamageType.NATURE
		end

		self._preferred_mindstar_type = wanted

		-- update damage types
		t.attune(self, mh, wanted)
		t.attune(self, oh, wanted)
		t.attune(self, tk, wanted)
	end --action

	attune_mindstar.callbackOnWear = function(self, t, o)
		if not self._preferred_mindstar_type then return end
		if not o or not o.combat or not o.combat.talented == "mindstar" then return end
		if not o.wielder or not o.wielder.learn_talent or not o.wielder.learn_talent[self.T_ATTUNE_MINDSTAR] then return end
		if o.combat.damtype == self._preferred_mindstar_type then return end

		t.attune(self, o, self._preferred_mindstar_type)
	end --callbackOnWear

	attune_mindstar.info = function(self, t)
		return ([[Alter the flow of energies of your equipped mindstars, changing their damage type between nature and mind.]]):tformat()
	end
end