- 7 Янв 2019
- 51
- 2
- Проект
- Reborn in progress
Есть код, который я изменил под себя и пытался дописать его, вроде бы все должно работать, но не работает). Приложу исходный код, может кто поможет.
function modifier_respawn:OnCreated( kv )
Timers:CreateTimer(0,function()
local ability = self:GetAbility()
self.respawn_duration = ability:GetSpecialValueFor("respawn_duration")
self.spawn_loc = self:GetCaster():GetAbsOrigin()
self.caster_fw = self:GetCaster():GetForwardVector()
end)
end
function modifier_respawn:OnDeath(data)
local unit = data.unit
local caster = self:GetCaster()
if unit == self:GetCaster() then
local spawn_loc = self.spawn_loc
local caster_fw = self.caster_fw
local unit_name = caster:GetUnitName()
local team = caster:GetTeam()
local respawn_duration = self:GetAbility():GetSpecialValueFor("respawn_duration")
Timers:CreateTimer(self.respawn_duration, function()
local unit = CreateUnitByName(unit_name, self.spawn_loc, true, nil, nil, team)
unit:SetForwardVector(caster_fw)
end)
end
end
Timers:CreateTimer(0,function()
local ability = self:GetAbility()
self.respawn_duration = ability:GetSpecialValueFor("respawn_duration")
self.spawn_loc = self:GetCaster():GetAbsOrigin()
self.caster_fw = self:GetCaster():GetForwardVector()
end)
end
function modifier_respawn:OnDeath(data)
local unit = data.unit
local caster = self:GetCaster()
if unit == self:GetCaster() then
local spawn_loc = self.spawn_loc
local caster_fw = self.caster_fw
local unit_name = caster:GetUnitName()
local team = caster:GetTeam()
local respawn_duration = self:GetAbility():GetSpecialValueFor("respawn_duration")
Timers:CreateTimer(self.respawn_duration, function()
local unit = CreateUnitByName(unit_name, self.spawn_loc, true, nil, nil, team)
unit:SetForwardVector(caster_fw)
end)
end
end