diff options
Diffstat (limited to 'auto-tune/hooks/load.lua')
-rw-r--r-- | auto-tune/hooks/load.lua | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/auto-tune/hooks/load.lua b/auto-tune/hooks/load.lua new file mode 100644 index 0000000..1e3a421 --- /dev/null +++ b/auto-tune/hooks/load.lua @@ -0,0 +1,50 @@ +class:bindHook("ToME:load", function(self, data) + local Talents = require "engine.interface.ActorTalents" + local TD = Talents.talents_def + + if TD.T_ATTUNE_MINDSTAR then + TD.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 + + game.logPlayer(self, "Found a %s in %s", o:getName{do_color=1}, slot) + 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_damage_type = engine.DamageType.MIND + if primary.combat.damtype == engine.DamageType.MIND then + wanted_damage_type = engine.DamageType.NATURE + end + + -- update damage types + if mh then mh.combat.damtype = wanted_damage_type end + if oh then oh.combat.damtype = wanted_damage_type end + if tk then tk.combat.damtype = wanted_damage_type end + + game.logPlayer(self, "You attune your mindstar(s) to deal %s%s#LAST# damage.", engine.DamageType.dam_def[wanted_damage_type].text_color, engine.DamageType.dam_def[wanted_damage_type].name) + end + end +end) |