- 18 Фев 2020
- 123
- 14
- Проект
- Evo Land
По какой то причине когда я ставлю юнита у меня создается дами в центре карты (а не там где место стройки) и если я строю юнита меньше по размеру модели то дами как я понял не создается если уже был другой но больше или еще что то, что мне не ясно.
вот ошибка
Вот функция BuildingHelper:
вот ошибка
Lua:
Script Runtime Error: scripts\vscripts\libraries\buildinghelper.lua:722: Can't call CEntityInstance:GetEntityIndex on an object of type [none]
stack traceback:
[C]: in function 'GetEntityIndex'
scripts\vscripts\libraries\buildinghelper.lua:722: in function 'AddBuilding'
...me\dota_addons\hero_defense\scripts\vscripts\builder.lua:15: in function <...me\dota_addons\hero_defense\scripts\vscripts\builder.lua:4>
Lua:
function BuildingHelper:AddBuilding(keys)
-- Callbacks
local callbacks = BuildingHelper:SetCallbacks(keys)
local builder = keys.caster
local ability = keys.ability
local abilName = ability:GetAbilityName()
local buildingTable = BuildingHelper:SetupBuildingTable(abilName, builder)
buildingTable:SetVal("AbilityHandle", ability)
-- Prepare the builder, if it hasn't already been done
if not builder.buildingQueue then
BuildingHelper:InitializeBuilder(builder)
end
local size = buildingTable:GetVal("ConstructionSize", "number")
local unitName = buildingTable:GetVal("UnitName", "string")
-- Handle self-ghosting
if unitName == "self" then
unitName = builder:GetUnitName()
end
local fMaxScale = buildingTable:GetVal("MaxScale", "float")
if not fMaxScale then
-- If no MaxScale is defined, check the "ModelScale" KeyValue. Otherwise just default to 1
local fModelScale = GetUnitKV(unitName, "ModelScale")
if fModelScale then
fMaxScale = fModelScale
else
fMaxScale = 1
end
end
buildingTable:SetVal("MaxScale", fMaxScale)
local color = Vector(255,255,255)
if RECOLOR_GHOST_MODEL then
color = Vector(0,255,0)
end
-- Basic event table to send
local event = { state = "active", size = size, scale = fMaxScale, builderIndex = builder:GetEntityIndex() }
-- Set the active variables and callbacks
local playerID = builder:GetMainControllingPlayer()
local player = PlayerResource:GetPlayer(playerID)
local playerTable = BuildingHelper:GetPlayerTable(playerID)
playerTable.activeBuilder = builder
playerTable.activeBuilding = unitName
playerTable.activeBuildingTable = buildingTable
playerTable.activeCallbacks = callbacks
-- Offset Z on the model particle
event.modelOffset = GetUnitKV(unitName, "ModelOffset") or 0
-- npc_dota_creature doesn't render cosmetics on the particle ghost, use hero names instead
unitName = GetUnitKV(unitName, "OverrideBuildingGhost") or unitName
-- Get a model dummy to pass it to panorama
local mgd = BuildingHelper:GetOrCreateDummy(unitName)
event.entindex = mgd:GetEntityIndex()
-- Range overlay
if mgd:HasAttackCapability() then
event.range = buildingTable:GetVal("AttackRange", "number") + mgd:GetHullRadius()
end
-- Make a pedestal dummy if required
local pedestal = buildingTable:GetVal("PedestalModel")
if pedestal then
local prop = BuildingHelper:GetOrCreateProp(pedestal)
mgd.prop = prop
-- Add values to the event table
event.propIndex = prop:GetEntityIndex()
event.propScale = buildingTable:GetVal("PedestalModelScale", "float") or mgd:GetModelScale()
event.offsetZ = buildingTable:GetVal("PedestalOffset", "float") or 0
end
-- Adjust the Model Orientation
local yaw = buildingTable:GetVal("ModelRotation", "float")
mgd:SetAngles(0, -yaw, 0)
CustomGameEventManager:Send_ServerToPlayer(player, "building_helper_enable", event)
end