From 4a4709db06185acceaa9aa22ae449d193115a1f8 Mon Sep 17 00:00:00 2001 From: Rabbit Whispers Date: Fri, 20 Jun 2025 19:23:29 -0500 Subject: auto-tune: switch mindstar damage types on equip --- auto-tune/data/attune-mindstar.lua | 67 ++++++++++++++++++++++++++++++++++++++ auto-tune/hooks/load.lua | 57 +++----------------------------- auto-tune/init.lua | 12 +++---- 3 files changed, 76 insertions(+), 60 deletions(-) create mode 100644 auto-tune/data/attune-mindstar.lua diff --git a/auto-tune/data/attune-mindstar.lua b/auto-tune/data/attune-mindstar.lua new file mode 100644 index 0000000..7a4d9a6 --- /dev/null +++ b/auto-tune/data/attune-mindstar.lua @@ -0,0 +1,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 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) + diff --git a/auto-tune/init.lua b/auto-tune/init.lua index f65cfc2..f5aad24 100644 --- a/auto-tune/init.lua +++ b/auto-tune/init.lua @@ -1,19 +1,17 @@ long_name = "Auto-Tune Mindstars" -short_name = "auto-tune" +short_name = "auto_tune" for_module = "tome" -addon_version = {0,1,0} +addon_version = {0,2,0} version = {1,7,6} -weight = 40 +weight = 20 author = {"Rabbit Whispers"} homepage = {"starfall.systems"} description = [[May mismatched mindstars bother you no more. -Your equipped mindstars will now have the same damage type after you use Attune Mindstar. Psionically wielded mindstars are also attuned, in case you have some other addon that makes that relevant. - -If you have an actual use for mindstars with different damage types, consider Fine Tune Mindstars by nsrr or Mindstar Tuning by Zizzo.]] +After you use Attune Mindstar, your equipped mindstars (including any psionically wielded mindstars) will now have the same damage type. Any new mindstars will change to your preferred damage type immediately when wielded.]] tags = {"mindstar", "attune mindstar"} -data = false +data = true hooks = true overload = false superload = false -- cgit