#Is there a way to adjust the % chance of existing items in a player's inventory?
1 messages · Page 1 of 1 (latest)
You have to create a copy of the item
Luckily Elfansoer already did most of the work for you
I don't know of a way besides whitelisting specific kvs to modify, if you want a more general mechanic. For specific items, you can override their parameters via KV or modifiers.
If only this bot was actually useful
Look for implementations of MODIFIER_PROPERTY_OVERRIDE_ABILITY_SPECIAL_VALUE
The simplest way would be to override their KVs. It's tedious, but doesn't require any coding knowledge
The modifiee way Firetoad suggested is a little more advanced but can handle a lot of items at once
Oh yeah that might work
Yeah, I need to hit every item in the game that has a passive % chance, but only for a specific hero (so I can't just adjust the KVs directly, I don't think). I'll dig into that modifier
I have an implementation of that somewhere, gimme 15min to get to the computer and I'll post here
oh wow, nice, thanks
here's the ability
"fateweaver_rig_the_dice"
{
"BaseClass" "ability_lua"
"AbilityBehavior" "DOTA_ABILITY_BEHAVIOR_PASSIVE"
"AbilityUnitTargetTeam" "DOTA_UNIT_TARGET_TEAM_FRIENDLY"
"AbilityUnitTargetType" "DOTA_UNIT_TARGET_HERO"
"ScriptFile" "jobs.lua"
"AbilityTextureName" "fateweaver_rig_the_dice"
"MaxLevel" "1"
"AbilityCastRange" "1200"
"AbilityCastPoint" "0.0"
"AbilityCooldown" "0"
"AbilityManaCost" "0"
"AbilitySpecial"
{
"01"
{
"var_type" "FIELD_INTEGER"
"multiplier" "100"
}
"02"
{
"var_type" "FIELD_INTEGER"
"radius" "1200"
}
}
}
and the related modifier
fateweaver_rig_the_dice = class({})
function fateweaver_rig_the_dice:GetIntrinsicModifierName()
return "modifier_fateweaver_rig_the_dice"
end
modifier_fateweaver_rig_the_dice = class({})
function modifier_fateweaver_rig_the_dice:IsHidden() return true end
function modifier_fateweaver_rig_the_dice:IsDebuff() return false end
function modifier_fateweaver_rig_the_dice:IsPurgable() return false end
function modifier_fateweaver_rig_the_dice:GetAttributes() return MODIFIER_ATTRIBUTE_IGNORE_INVULNERABLE + MODIFIER_ATTRIBUTE_PERMANENT end
function modifier_fateweaver_rig_the_dice:IsAura() return true end
function modifier_fateweaver_rig_the_dice:GetAuraRadius() return self.radius or 0 end
function modifier_fateweaver_rig_the_dice:GetAuraSearchFlags() return DOTA_UNIT_TARGET_FLAG_NOT_ILLUSIONS end
function modifier_fateweaver_rig_the_dice:GetAuraSearchTeam() return DOTA_UNIT_TARGET_TEAM_FRIENDLY end
function modifier_fateweaver_rig_the_dice:GetAuraSearchType() return DOTA_UNIT_TARGET_HERO end
function modifier_fateweaver_rig_the_dice:GetModifierAura() return "modifier_fateweaver_rig_the_dice_buff" end
function modifier_fateweaver_rig_the_dice:OnCreated(keys)
self:OnRefresh(keys)
end
function modifier_fateweaver_rig_the_dice:OnRefresh(keys)
self.radius = self:GetAbility():GetSpecialValueFor("radius")
end
modifier_fateweaver_rig_the_dice_buff = class({})
function modifier_fateweaver_rig_the_dice_buff:IsHidden() return false end
function modifier_fateweaver_rig_the_dice_buff:IsDebuff() return false end
function modifier_fateweaver_rig_the_dice_buff:IsPurgable() return false end
function modifier_fateweaver_rig_the_dice_buff:OnCreated(keys)
self.chance_multiplier = 1 + 0.01 * self:GetAbility():GetSpecialValueFor("multiplier")
end
function modifier_fateweaver_rig_the_dice_buff:DeclareFunctions()
return {
MODIFIER_PROPERTY_OVERRIDE_ABILITY_SPECIAL,
MODIFIER_PROPERTY_OVERRIDE_ABILITY_SPECIAL_VALUE
}
end
function modifier_fateweaver_rig_the_dice_buff:GetModifierOverrideAbilitySpecial(keys)
if (not keys.ability) or (not keys.ability_special_value) then return 0 end
if string.find(keys.ability_special_value, "chance") then
return 1
end
return 0
end
function modifier_fateweaver_rig_the_dice_buff:GetModifierOverrideAbilitySpecialValue(keys)
if string.find(keys.ability_special_value, "chance") then
local base_value = keys.ability:GetLevelSpecialValueNoOverride(keys.ability_special_value, keys.ability_special_level)
return math.min(100, base_value * (self.chance_multiplier or 1))
end
return 0
end
a few caveats:
- it's coded as an aura, but you can just use the aura buff as a passive modifier instead;
- it's a couple years old, so it might miss KVs for some abilities introduced since then;
hope it helps
Also is there still this caveat that this only works for valve abilities and not for custom ones
(or the other way around, I forget?)
That's fantastic, thanks man! I was also thinking of the ol' string.find( chance ), but wasn't sure where I should be finding.
I can adjust the the modifier directly for her custom abilities, I'm not too worried about that, but it's good to know if it doesn't work
It should work well for both.
Oh okay nice that they fixed it