Question: How should I do this for item_lua items? My current conception of how it would be done is item_lua returns intrinsic modifier A which has the flag MODIFIER_ATTRIBUTE_MULTIPLE. A then returns intrinsic modifier B which does not have the flag MODIFIER_ATTRIBUTE_MULTIPLE for the non-stackable attributes/stats. Does this sound correct? Or is that a more proper/better way to do this?
#Implementation of Lua Item with both stackable and non-stackable passive attributes/stats
1 messages · Page 1 of 1 (latest)
Return intrinsic modifier with non stackable stats, in that non stackable modifier oncreate apply another one with stackable stats and in ondestroy remove it.
You probably may use even one modifier to simplify things, but no idea what you want to do exactly
For example: Heart of Tarrasue has both stackable and non-stackable stats:
-The strength stacks with multiple copies
-The regeneration does not stack with multiple copies
How is this done/how would you do this?
Exactly as said
Intrinsic modifiers are inherently given the MULTIPLE attribute, and regular modifiers arent
So having multiple of the item will give the base stats, but only one instance of the bonus stats will be applied
You'll have to make sure that the bonus is removed when all instances of the parent item is removed, and only when all are removed
Something about this suggests my implementation of a heart with an active wasn't done correctly, as I had to specifically put the flag in for the stats
Im like 99.99% sure that intrinsic doesn't magically make specified modifier as MULTIPLE one
Some properties have unique copy that designed for such purpose. For your case there is MODIFIER_PROPERTY_HEALTH_REGEN_PERCENTAGE_UNIQUE and it may work in custom games
Unless theres some stuff under the hood dotas doing that seperates them
Idk, around year ago i fixed non stackable items by going 1 by 1 for every item modifier and adding MODIFIER_ATTRIBUTE_MULTIPLE to them
It would be also weird. What if you want non stackable item at all?
Weird, I've never had an issue with intrinsics not stacking
A non stackable item would just not have an intrinsic, and only have the bonus
also, what's the difference between making a property in the kv file and announcing one in the lua file? The lua file takes precedence I suppose, but you can take a hybrid approach like marking the modifier_attribute_multiple in the kv file and not having to touch the lua file?
By kv you most likely mean datadriven approach that is deprecated and supported like "dota compiles at valve = ok"
Yeah
A lot of the datadriven stuff is outdated
Wouldnt recommend it
(all new properties unsupported, some features causing awesome bugs and so on)
To properly answer the question though, a modifier created via datadriven means in the ability KV would possibly work, but honestly I dont know if you can declare datadriven modifiers inside a lua ability KV
For example i had enigma midnight pulse implemented as datadriven aura that worked for literally years and one day it suddenly started oneshot allies and heal enemies. I rewrote it from 0 in lua and issues solved
So, the datadriven one should have most of its "Casting" portion removed and moved to the Lua file? Or moved to abilityvalues section?
Oh you mean the ability KV declarations? Yeah Lua overwrites the KV ones
Its handy because you can return different values on client and server
Casting outside of cast range (like blink dagger) is done by returning 99999 on server and the actual cast range on client
Datadriven is like that (you define most logic in kv file itself like OnSpellStart, modifier OnIntervalThink and so on):
Oh man I havent seen or used datadriven in years
I got so used to lua
So if it's strictly kv file for item_lua, can I take a hybrid approach? Cause I kinda want to keep all the numbers stuff in the kv file where it's easier ot examine all of them
I thought you were talking about modifier properties here
You can mix ability KVs perfectly fine
MODIFIER_ATTRIBUTE_MULTIPLE is a modifier property iirc, so I think you're saying "no" to that instance though. I wanted ot put it in the kv file instead of having it hardcoded into the lua file
AbilityValues are where 90% of the balance is done, so the more numerical values you can pull out into the KV the better
To clarify what I was saying;
- you cant use datadriven function declarations in a lua class ability KV
- I believe you cant declare a datadriven modifier in a lua ability KV, but even if you could I would highly recommend against it
so if i'm not sure how to pass it to the Lua file, I just dump whatever I can into the abilityvalues right? Since all flags are technically just bits and can be represented as integers (lol)
Found 1 function for GetSpecialValueFor
🇸 🇨 CDOTABaseAbility:GetSpecialValueFor(name: string): float
Gets a value from this ability's special value block for its current level.
Special Value = AbilityValues
KV declarations ("AbilityManaCost" "50")
Basically write a GetManaCost() function for you internally
However, the lua script is loaded on game start, so only the KV values are visible in hero select
Which is why you declare them in KV
Tooltips
And its just more convenient 90% of the time
well although it kinda deviated into another important question, nevertheless this information was very helpful. Thanks to all.
I'll just add something small here: KVs are great for holding base values for abilities, which the lua code can then use as anchor.
For example, you can have a talent that reduces the cooldown of the ability by 10. You would have code that takes the base cooldown defined by the KV and return it - 10.
---@type CDOTA_Modifier_Lua
modifier_item_test = class({})
function modifier_item_test:OnCreated(params)
if IsServer() then
local buffs = self:GetParent():FindAllModifiersByName(self:GetName())
for i, buff in ipairs(buffs) do
buff:SetStackCount(i)
end
end
end
function modifier_item_test:OnRemoved()
if IsServer() then
local buffs = self:GetParent():FindAllModifiersByName(self:GetName())
for i, buff in ipairs(buffs) do
buff:SetStackCount(i)
end
end
end
function modifier_item_test:GetAttributes()
return MODIFIER_ATTRIBUTE_MULTIPLE
end
function modifier_item_test:DeclareFunctions()
return {
MODIFIER_PROPERTY_HEALTH_BONUS,
MODIFIER_PROPERTY_MANA_BONUS,
}
end
function modifier_item_test:GetModifierHealthBonus()
return 1000
end
function modifier_item_test:GetModifierManaBonus()
if self:GetStackCount() == 1 then
return 1000
end
end
one of the most simply way to achieve this I think,
use stackcount to determine which buff is truly effective, if you wont use it elsewhere
just add a condition in the property which you need it unstackable
and you can make some of properties stack limited ( just change == to <=