Как сделать, чтобы предмет падал так-же как и rapier?

Qw91

Пользователь
16 Июн 2018
11
0
Как сделать, чтобы предмет падал как рапира, и тот кто её поднял был владельцем?
 

Qw91

Пользователь
16 Июн 2018
11
0
Я нашёл как сделать, но когда добавляю этот код к сатанику, то ничего не происходит. Но если это "BasicClass" "datadriven" то работает.
Код:
        {
            "RunScript"
            {
                "ScriptFile"        "scripts/vscripts/itemfunctions.lua"
                "Function"            "DropItemOnDeath"
            }
        }

print ( '[ItemFunctions] creating itemFunctions' )
itemFunctions = {}
itemFunctions.__index = itemFunctions
end

function itemFunctions:new()
print ( '[ItemFunctions] itemFunctions:new' )
o = o or {}
setmetatable( o, itemFunctions )
return o
end

function itemFunctions:start()
print('[ItemFunctions] itemFunctions started!')
end

function DropItemOnDeath(keys)
print( '[ItemFunctions] DropItemOnDeath Called' )
local killedUnit = EntIndexToHScript( keys.caster_entindex )
local itemName = tostring(keys.ability:GetAbilityName())
keys.ability gets the actual ability and then GetAbilityName()
if killedUnit:IsHero() or killedUnit:HasInventory() then
for itemSlot = 0, 5, 1 do
if killedUnit ~= nil then
local Item = killedUnit:GetItemInSlot( itemSlot )
if Item ~= nil and Item:GetName() == itemName then
local newItem = CreateItem(itemName, nil, nil)
CreateItemOnPositionSync(killedUnit:GetOrigin(), newItem)
killedUnit:RemoveItem(Item)
end
end
end
end
end

"item_dmgtest_datadriven"
{
"ID" "2100"
"AbilityBehavior" "DOTA_ABILITY_BEHAVIOR_PASSIVE"
"BaseClass" "item_datadriven"
"Model" "models/props_gameplay/divine_rapier.vmdl"
"AbilityTextureName" "rapier"


// Item Info
//---------------------------------------------------------------------------------------------------------
"ItemCost" "6200"
"ItemDroppable" "0"
"ItemSellable" "0"
"ItemKillable" "0"
"ItemQuality" "epic"
"ItemShopTags" "damage"
"ItemAliases" "rapier"
"ItemShareability" "ITEM_NOT_SHAREABLE"
"ItemDeclarations" "DECLARE_PURCHASES_TO_TEAMMATES | DECLARE_PURCHASES_TO_SPECTATORS | DECLARE_PURCHASES_IN_SPEECH"
"OnOwnerDied"
{
"RunScript"
{
"ScriptFile" "scripts/vscripts/itemfunctions.lua"
"Function" "DropItemOnDeath"
}
}

"Modifiers"
{
"modifier_rapier"
{
"Passive" "1"
"IsHidden" "1"
"Properties"
{
"MODIFIER_PROPERTY_BASEATTACK_BONUSDAMAGE" "%bonus_damage"
}
}
}
// Special
//---------------------------------------------------------------------------------------------------------
"AbilitySpecial"
{
"01"
{
"var_type" "FIELD_INTEGER"
"bonus_damage" "300"
}
}
}
 

HappyFeedFriends

Друзья CG
14 Авг 2017
540
32
Проект
Battle Heroes Arena
Я нашёл как сделать, но когда добавляю этот код к сатанику, то ничего не происходит. Но если это "BasicClass" "datadriven" то работает.
Код:
        {
            "RunScript"
            {
                "ScriptFile"        "scripts/vscripts/itemfunctions.lua"
                "Function"            "DropItemOnDeath"
            }
        }

print ( '[ItemFunctions] creating itemFunctions' )
itemFunctions = {}
itemFunctions.__index = itemFunctions
end

function itemFunctions:new()
print ( '[ItemFunctions] itemFunctions:new' )
o = o or {}
setmetatable( o, itemFunctions )
return o
end

function itemFunctions:start()
print('[ItemFunctions] itemFunctions started!')
end

function DropItemOnDeath(keys)
print( '[ItemFunctions] DropItemOnDeath Called' )
local killedUnit = EntIndexToHScript( keys.caster_entindex )
local itemName = tostring(keys.ability:GetAbilityName())
keys.ability gets the actual ability and then GetAbilityName()
if killedUnit:IsHero() or killedUnit:HasInventory() then
for itemSlot = 0, 5, 1 do
if killedUnit ~= nil then
local Item = killedUnit:GetItemInSlot( itemSlot )
if Item ~= nil and Item:GetName() == itemName then
local newItem = CreateItem(itemName, nil, nil)
CreateItemOnPositionSync(killedUnit:GetOrigin(), newItem)
killedUnit:RemoveItem(Item)
end
end
end
end
end

"item_dmgtest_datadriven"
{
"ID" "2100"
"AbilityBehavior" "DOTA_ABILITY_BEHAVIOR_PASSIVE"
"BaseClass" "item_datadriven"
"Model" "models/props_gameplay/divine_rapier.vmdl"
"AbilityTextureName" "rapier"


// Item Info
//---------------------------------------------------------------------------------------------------------
"ItemCost" "6200"
"ItemDroppable" "0"
"ItemSellable" "0"
"ItemKillable" "0"
"ItemQuality" "epic"
"ItemShopTags" "damage"
"ItemAliases" "rapier"
"ItemShareability" "ITEM_NOT_SHAREABLE"
"ItemDeclarations" "DECLARE_PURCHASES_TO_TEAMMATES | DECLARE_PURCHASES_TO_SPECTATORS | DECLARE_PURCHASES_IN_SPEECH"
"OnOwnerDied"
{
"RunScript"
{
"ScriptFile" "scripts/vscripts/itemfunctions.lua"
"Function" "DropItemOnDeath"
}
}

"Modifiers"
{
"modifier_rapier"
{
"Passive" "1"
"IsHidden" "1"
"Properties"
{
"MODIFIER_PROPERTY_BASEATTACK_BONUSDAMAGE" "%bonus_damage"
}
}
}
// Special
//---------------------------------------------------------------------------------------------------------
"AbilitySpecial"
{
"01"
{
"var_type" "FIELD_INTEGER"
"bonus_damage" "300"
}
}
}
Лови от меня подарок

Код:
function CDOTABaseAbility:ComicsVsAnimeItemDrop(caster)
    local itemName = tostring(self:GetAbilityName())
    if caster:IsHero() or caster:HasInventory() then
        local newItem = CreateItem(itemName, nil, nil)
        CreateItemOnPositionSync(caster:GetOrigin(), newItem)
        caster:RemoveItem(self)
    end
end
Запиши его в файл какой-либо,который бы читался через require() или в addon_game_mode.lua,и когда тебе нужно,что бы айтем выпадал,прописывай что-то такое ( Абилка:ComicsVsAnimeItemDrop(кто роняет)) Сразу скажу,прописывается это в lua скрипте айтема,для большего комфорта. Но ты можешь модифицировать как хочешь.
 
  • Нравится
Реакции: Qw91
Реклама: