summary refs log tree commit diff
path: root/auto-tune/hooks/load.lua
diff options
context:
space:
mode:
Diffstat (limited to 'auto-tune/hooks/load.lua')
-rw-r--r--auto-tune/hooks/load.lua57
1 files changed, 4 insertions, 53 deletions
diff --git a/auto-tune/hooks/load.lua b/auto-tune/hooks/load.lua
index 26c20ba..67da469 100644
--- a/auto-tune/hooks/load.lua
+++ b/auto-tune/hooks/load.lua
@@ -1,55 +1,6 @@
-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.info = function(self, t)
-			return ([[Alter the flow of energies of your equipped mindstars, changing their damage type between nature and mind.]]):tformat()
-		end
-		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")
+local ActorTalents = require "engine.interface.ActorTalents"
 
-			-- 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
+class:bindHook("ToME:load", function(self, data)
+	ActorTalents:loadDefinition('/data-auto_tune/attune-mindstar.lua')
 end)
+