Как сделать съедобный предмет?

Zek13f1

Активный
11 Июл 2019
96
3
Есть какой шаблон/ пример предмета, который можно съесть, при этом всех бафы предметы оставались?
 

VortDyn

Пользователь
26 Ноя 2018
16
6
При помощи базового класса item_lua
ты просто можешь сделать так, чтобы при активации предмета он пропадал и давал тебе модификатор, который не будет пропадать при смерти.
Здесь простенький предмет, который дает силу. Если его съесть, предмет исчезнет и будет давать силу постоянно.


Код:
// npc_items_custom.txt

"item_cheese_custom"
    {
        "ID"                            "5502"
        "BaseClass"                        "item_lua"
        "ScriptFile"                    "abilities/item_cheese_custom"
        "AbilityTextureName"            "item_recipe"

        "AbilityBehavior"                "DOTA_ABILITY_BEHAVIOR_TOGGLE"

        "ItemCost"                        "100"
        "ItemAliases"                    "cheese"
      

        "AbilitySpecial"
        {
            "01"
            {
                "var_type"                "FIELD_INTEGER"
                "bonus_str"                "13"
            }
        }
    }



Код:
// abilities/item_cheese_custom.lua

item_cheese_custom = class({})

LinkLuaModifier("modifier_item_cheese_custom", "abilities/item_cheese_custom", LUA_MODIFIER_MOTION_NONE)
LinkLuaModifier("modifier_item_cheese_custom_passive", "abilities/item_cheese_custom", LUA_MODIFIER_MOTION_NONE)


function item_cheese_custom:GetIntrinsicModifierName()
    return "modifier_item_cheese_custom"
end

function item_cheese_custom:OnToggle()
    self:GetCaster():AddNewModifier(self:GetCaster(), nil, "modifier_item_cheese_custom_passive", {})
    self:Destroy()
end




modifier_item_cheese_custom = class({
    IsHidden                = function(self) return true end,
    IsPurgable              = function(self) return false end,
    IsDebuff                = function(self) return false end,
    IsBuff                  = function(self) return true end,
    RemoveOnDeath           = function(self) return false end,
    DeclareFunctions        = function(self)
        return {
            MODIFIER_PROPERTY_STATS_STRENGTH_BONUS,
        }
    end,
})

function modifier_item_cheese_custom:OnCreated(params)
    bonus_str = self:GetAbility():GetSpecialValueFor("bonus_str")
end

function modifier_item_cheese_custom:GetModifierBonusStats_Strength()
    return bonus_str
end




modifier_item_cheese_custom_passive = class({
    IsHidden                = function(self) return false end,
    IsPurgable              = function(self) return false end,
    IsDebuff                = function(self) return false end,
    IsBuff                  = function(self) return true end,
    RemoveOnDeath           = function(self) return true end,
    DeclareFunctions        = function(self)
        return {
            MODIFIER_PROPERTY_STATS_STRENGTH_BONUS,
        }
    end,
})

function modifier_item_cheese_custom_passive:GetModifierBonusStats_Strength()
    return bonus_str
end
 
Последнее редактирование:
  • Нравится
Реакции: vulkantsk
Реклама: