Как сделать лайфстил за убийство крипа?

gravish

Новичок
1 Дек 2022
7
0
Проект
Кастомка(названия пока-что нет)
"item_wolf_tooth"
{
"BaseClass" "item_datadriven"
"ID" "4003"
"AbilityBehavior" "DOTA_ABILITY_BEHAVIOR_PASSIVE"
"Model" "models/props_gameplay/red_box.vmdl"
"AbilityUnitTargetType" "DOTA_UNIT_TARGET_HERO"
"Effect" "particles/generic_gameplay/dropped_item.vpcf"
"AbilityTextureName" "item_wolftooth"
"ItemCost" "45"
"itemShopTags" "lifesteal"
"ItemQuality" "common"
"ItemAliases" "wolf tooth,wt"
"ItemDeclarations" "DECLARE_PURCHASES_TO_SPECTATORS"
"AbilitySpecial"
{

"01"
{
"var_type" "FIELD_INTEGER"
"hp_restore" "20"
}
}
"RunScript"
{
"ScriptFile" "items/wolftooth.lua"
"Function" "wolftooth_lifesteal"
}
}
wolftooth=class{{}}

function wolftooth_lifesteal(keys)
local hp = GetValuefor("hp_restore")
local attacker = keys.caster
local killed = keys.entity_killed
if attacker and killed:IsCreep()
attacker:SetHealth(attacker:GetHealth()+hp)
SendOverheadEventMessage(nil,OVERHEAD_ALERT_HEAL,attacker,hp,nil)
end
end

Я - новичок и пытаюсь разобраться что да как, поэтому подскажите что не так.
 

gravish

Новичок
1 Дек 2022
7
0
Проект
Кастомка(названия пока-что нет)
Я - разобрался, кому нужно - в addon_game_mode.lua.
function CAddonTemplateGameMode:OnEntityKilled(keys)

local eAttacker = EntIndexToHScript(keys.entindex_attacker)
local eKilled = EntIndexToHScript(keys.entindex_killed)

if eAttacker and eAttacker:IsHero() and eKilled:IsCreep() then
for i= 0 ,5 ,1 do
local current_item = eAttacker:GetItemInSlot(i)
if current_item ~= nil then
if current_item:GetName() == "item_wolf_tooth" then
local nHeal = 20
eAttacker:SetHealth(eAttacker:GetHealth() + nHeal)
SendOverheadEventMessage(nil, OVERHEAD_ALERT_HEAL, eAttacker, nHeal, nil)
end
end
end
end

end
(local nHeal - кол-во хила за крипа,
Lua:
if current_item:GetName() == "item_wolf_tooth" then
здесь "item_wolf_tooth" - название вашего предмета.
И в InitGameMode добавить
Lua:
ListenToGameEvent("entity_killed",Dynamic_Wrap(CAddonTemplateGameMode, "OnEntityKilled"),self)
 

vulkantsk

Супермодератор
Команда форума
21 Июн 2017
1,147
196
www.dotabuff.com
Проект
Roshan defense
Метод интересный, но не правильный )
Ты можешь сделать луа предмет + сделать евент
MODIFIER_EVENT_ON_DEATH
 

valentinelotus

Пользователь
21 Фев 2023
18
1
Проект
dota2nice
Метод интересный, но не правильный )
Ты можешь сделать луа предмет + сделать евент
MODIFIER_EVENT_ON_DEATH
Можешь объяснить почему у моего предмета нет названия и он не дает статов хоть все прописано в скрипте и в предмете?
 
Реклама: