I've kind-of-sort-of got it working using the on_wear function, but the downside is that the bonus there does not update as the player's stat updates until the item is removed and re-equipped. What I would really like to do is have it set directly in the actual Wielder section, like [DamageType.LIGHT] = who:getMag(), but it doesnt seem to like that and trying to wrap the wielder section in a function so that I can reference 'who' has not worked either.
I've also tried setting a value higher up on the item, like scale_stat_bonus1 = function(self, who) return who:getMag()end, and then doing [DamageType.LIGHT] = scale_stat_bonus1, but no luck on that either.
Going back the on_wear, I've tried hacking together a CallbackonAct to update the stats when worn, but it just doesn't work correctly.
I haven't been able to find any items or egos that do this specifically, the Eternity and Untouchable Artifacts are close, but not quite, so I figured I would ask here to see if there is something simple I am missing since I am relatively new to modding Tome. It is interesting to note that the special_desc updates its bonuses on the fly as the player's stat's change, but I can't get that behavior to carry over.
Any help or pointing in the right direction would be much appreciated. The code for the item in question is below.
Code: Select all
newEntity{ base = "BASE_HELM",
power_source = {unnatural=true},
unique = true,
name = "Netheric Diadem", image = "object/artifact/crown_of_command.png",
unided_name = _t"strange dark crown",
desc = _t[[A symbol of rulership from a lost reality, long ago consumed by the Void.]],
level_range = {30, 50},
rarity = 230,
cost = resolvers.rngrange(225,350),
material_level = 3,
special_desc = function(self, who) return ("When worn, increases Light resist by %d%% (Magic) and Nature resist by %d%% (Willpower). If your stats change, re-equip this item to adjust the bonuses."):tformat(who:getMag(),who:getWil()) end,
wielder = {
damage_affinity={
[DamageType.DARKNESS] = resolvers.mbonus_material(10, 5),
[DamageType.TEMPORAL] = resolvers.mbonus_material(10, 5),
},
resists = {
[DamageType.LIGHT] = 0,
[DamageType.NATURE] = 0,
all = 0,
},
talents_mastery_bonus = {
["demented"] = 0.3,
},
},
on_wear = function(self, who)
local Stats = require "engine.interface.ActorStats"
local DamageType = require "engine.DamageType"
self.worn_by = who
self:specialWearAdd({"wielder","resists"}, {[DamageType.LIGHT] = who:getMag(), [DamageType.NATURE] = who:getWil()})
game.logPlayer(who, "#VIOLET#The diadem resonates with your power, making you resistant to the enemies of the Void.")
end,
finish = function(self, zone, level)
game.state:addRandartProperties(self, {lev = 0, egos = 2,
power_source = {psionic = true},
force_themes = {"dark", "temporal", "mind"}})
end,
}