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
|
class:bindHook("ToME:load", function(self, data)
local Talents = require "engine.interface.ActorTalents"
local DamageType = require "engine.DamageType"
if Talents.talents_def.T_ATTUNE_MINDSTAR then
Talents.talents_def.T_ATTUNE_MINDSTAR.action = function(self, t)
-- do nothing if disarmed
if self:attr("disarmed") then
return nil
end
local hasValidMindstar = function(who, slot)
local o = who:getInven(slot) and who: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[who.T_ATTUNE_MINDSTAR] then
return nil
end
return o
end
local mh = hasValidMindstar(self, "MAINHAND")
local oh = hasValidMindstar(self, "OFFHAND")
local tk = 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
-- update damage types
local attune = function (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(mh, wanted)
attune(oh, wanted)
attune(tk, wanted)
end
end
end)
|