Items - Wielder stat scaling

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
Wayback
Yeek
Posts: 12
Joined: Tue Aug 31, 2021 6:31 pm

Items - Wielder stat scaling

#1 Post by Wayback »

I'm currently working on an Addon that adds a bunch of new ego affixes and semi-random rares with interesting abilities and running into a roadblock with trying to make an item whose bonuses scale with certain stats.

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,
}

HousePet
Perspiring Physicist
Posts: 6182
Joined: Sun Sep 09, 2012 7:43 am

Re: Items - Wielder stat scaling

#2 Post by HousePet »

Tricky. There is no easy way to do this.

However, you might be able to copy Tarrasca (or just look at it and decide to do something else).
My feedback meter decays into coding. Give me feedback and I make mods.

Wayback
Yeek
Posts: 12
Joined: Tue Aug 31, 2021 6:31 pm

Re: Items - Wielder stat scaling

#3 Post by Wayback »

Thanks! Yea, looked at that one and as you note, it is a beast when it comes to the coding. I'm branching off into a new direction and might try creating a set of passive talents for items only that I can call and will do that scaling. Will report back on how that does or doesn't go.

HousePet
Perspiring Physicist
Posts: 6182
Joined: Sun Sep 09, 2012 7:43 am

Re: Items - Wielder stat scaling

#4 Post by HousePet »

I considered mentioning that option, but it will be a lot of work and likely be a bit confusing. So I wasn't going to suggest it for egos.
My feedback meter decays into coding. Give me feedback and I make mods.

Wayback
Yeek
Posts: 12
Joined: Tue Aug 31, 2021 6:31 pm

Re: Items - Wielder stat scaling

#5 Post by Wayback »

I did end up going with a passive talent on the main item itself since I'm finding that spinning up new passives is pretty quick. As for doing some randomizing in the egos themselves, I wanted to cover some randomization for other power sources (like steam) without creating a ton of new affixes for different combinations with the same name and got the below to work.

Code: Select all

newEntity{
	power_source = {arcane=true},
	name = " of the cog", suffix=true, instant_resolve=true,
	keywords = {cog=true},
	level_range = {1, 50},
	rarity = 5,
	cost = 6,
	wielder = {
		combat_steampower = resolvers.mbonus_material(10, 2),
	},
	resolvers.genericlast(function(e)
		local eff = rng.table{"phy", "min", "spl",}
			if eff == "phy" then e.wielder.combat_physresist = resolvers.mbonus_material(10, 5)
			elseif eff == "min" then e.wielder.combat_mentalresist = resolvers.mbonus_material(10, 5)
			elseif eff == "spl" then e.wielder.combat_spellresist = resolvers.mbonus_material(10, 5)
		end
	end),
}

Post Reply