- 28 Янв 2018
- 137
- 4
Собственно решил переписать хроносферу войда, с использованием по большей части луа на примере дота имба.
Вопрос почему при активации, скилл не создает хроносферу, и что за ошибка в консоли, т.к если закомментить 28-ю строку (AddFOWViewer) то ошибки нет, но и скилл так-же не работает.
Код LUA: chronosphere_datadriven_new.lua
Код ошибки из консоли:
Вопрос почему при активации, скилл не создает хроносферу, и что за ошибка в консоли, т.к если закомментить 28-ю строку (AddFOWViewer) то ошибки нет, но и скилл так-же не работает.
Код LUA: chronosphere_datadriven_new.lua
chronosphere_datadriven_new = class({})
LinkLuaModifier("chronosphere_datadriven_new_aura", "hero/chronosphere_datadriven_new.lua", LUA_MODIFIER_MOTION_NONE) Handle applier
LinkLuaModifier("chronosphere_datadriven_new_handler", "hero/chronosphere_datadriven_new.lua", LUA_MODIFIER_MOTION_NONE)
LinkLuaModifier("chronosphere_datadriven_new_caster_buff", "hero/chronosphere_datadriven_new.lua", LUA_MODIFIER_MOTION_NONE)
function chronosphere_datadriven_new:GetCooldown(nLevel)
if self:GetCaster():HasScepter() then
return self:GetSpecialValueFor( "cooldown_scepter" )
end
return self.BaseClass.GetCooldown( self, nLevel )
end
function chronosphere_datadriven_new:GetAOERadius()
return self:GetSpecialValueFor( "radius" )
end
function chronosphere_datadriven_new:OnSpellStart()
local caster = self:GetCaster()
local ability = self
local chrono_center = self:GetAbsOrigin()
local duration = self:GetSpecialValueFor( "duration" )
local vision_radius = self:GetSpecialValueFor("vision_radius")
local radius = self:GetSpecialValueFor("radius")
if caster:HasScepter() then
return self:GetSpecialValueFor( "duration_scepter" )
end
AddFOWViewer(caster:GetTeamNumber(), chrono_center, vision_radius, radius, duration, false)
local mod = CreateModifierThinker(caster, ability, "chronosphere_datadriven_new_aura",
{duration = duration}, chrono_center, vision_radius, caster:GetTeamNumber(), false)
end
modifier_chronosphere_datadriven_new_aura = class({})
function modifier_chronosphere_datadriven_new_aura:IsPurgable() return false end
function modifier_chronosphere_datadriven_new_aura:IsHidden() return true end
function modifier_chronosphere_datadriven_new_aura:IsAura() return true end
function modifier_chronosphere_datadriven_new_aura:GetAuraSearchTeam()
return DOTA_UNIT_TARGET_TEAM_BOTH
end
function modifier_chronosphere_datadriven_new_aura:GetAuraSearchFlags()
return DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES + DOTA_UNIT_TARGET_FLAG_INVULNERABLE
end
function modifier_chronosphere_datadriven_new_aura:GetAuraSearchType()
return DOTA_UNIT_TARGET_CREEP + DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BUILDING + DOTA_UNIT_TARGET_OTHER
end
function modifier_chronosphere_datadriven_new_aura:GetModifierAura()
return "modifier_chronosphere_datadriven_new_handler"
end
function modifier_chronosphere_datadriven_new_aura:GetAuraRadius()
return self.radius
end
function modifier_chronosphere_datadriven_new_aura:OnCreated()
if IsServer() then
self.caster = self:GetCaster()
self.ability = self:GetAbility()
self.parent = self:GetParent()
self.radius = self.ability:GetSpecialValueFor("radius")
local particle = ParticleManager:CreateParticle("particles/units/heroes/hero_faceless_void/faceless_void_chronosphere.vpcf", PATTACH_WORLDORIGIN, self.parent)
ParticleManager:SetParticleControl(particle, 0, self.parent:GetAbsOrigin())
ParticleManager:SetParticleControl(particle, 1, Vector(self.radius, self.radius, self.radius))
self:AddParticle(particle, false, false, -1, false, false)
Timers:CreateTimer(FrameTime(), function()
if self:GetStackCount() > 0 then
self:StartIntervalThink(0.1)
self.modifiers = {}
end
end)
end
end
function modifier_chronosphere_datadriven_new_aura:OnRemoved()
if IsServer() then
if self.modifiers then
for _,mod in pairs(self.modifiers) do
if not mod:IsNull() then modestroy() end
end
end
end
end
function modifier_chronosphere_datadriven_new_aura:OnIntervalThink()
local radius = self:GetAuraRadius()
local caster = self:GetCaster()
-- Find the caster and unit under their control under the Chronosphere, and give them the attack speed bonus modifier
local units = FindUnitsInRadius(caster:GetTeamNumber(), self:GetParent():GetAbsOrigin(), nil, radius, DOTA_UNIT_TARGET_TEAM_FRIENDLY, DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC, DOTA_UNIT_TARGET_FLAG_INVULNERABLE, FIND_ANY_ORDER, false)
for _,unit in ipairs(units) do
if unit == caster or unit:GetPlayerOwner() == caster:GetPlayerOwner() then
if not self.modifiers[unit:GetEntityIndex()] then
local mod = unit:AddNewModifier(caster, self:GetAbility(), "modifier_chronosphere_datadriven_new_caster_buff", {})
table.insert(self.modifiers, unit:GetEntityIndex(),mod)
end
end
end
-- Iterate through the units belonging to the caster and see if they're inside the Chronosphere. If not, remove the modifier.
local parent = self:GetParent()
for id,mod in pairs(self.modifiers) do
local unit = EntIndexToHScript(id)
if CalcDistanceBetweenEntityOBB(parent, unit) > self:GetAuraRadius() then
if not mod:IsNull() then modestroy() end
self.modifiers[id] = nil -- table.remove(self.modifiers, id) didn't work
end
end
end
modifier_chronosphere_datadriven_new_handler = class({})
function modifier_chronosphere_datadriven_new_handler:IsHidden() return true end
function modifier_chronosphere_datadriven_new_handler:IsPurgable() return false end
function modifier_chronosphere_datadriven_new_handler:IsDebuff()
if self:GetStackCount() == 1 or self:GetStackCount() == 4 then
return false end
return true
end
function modifier_chronosphere_datadriven_new_handler:OnCreated()
if IsServer() then
self.parent = self:GetParent()
self.caster = self:GetCaster()
if self.parent == self.caster or self.parent:GetPlayerOwner() == self.caster:GetPlayerOwner() then
self:SetStackCount(0)
end
self:StartIntervalThink(FrameTime())
end
end
function modifier_chronosphere_datadriven_new_handler:OnIntervalThink()
if IsServer() then
-- Normal frozen enemy gets interrupted all the time
if self:GetStackCount() == 0 then
-- Make certain people are stunned
self.parent:AddNewModifier(self.caster, self:GetAbility(), "modifier_stunned", {duration = FrameTime()})
self.parent:InterruptMotionControllers(true)
local modifiers = self.parent:FindAllModifiers()
for _,modifier in pairs(modifiers) do
if modifier.IsMotionController then
if modifier:IsMotionController() then
modifierestroy()
end
end
end
end
end
end
function modifier_chronosphere_datadriven_new_handlereclareFunctions()
local funcs ={ MODIFIER_EVENT_ON_ORDER,
MODIFIER_PROPERTY_MOVESPEED_MAX,
}
return funcs
end
function modifier_chronosphere_datadriven_new_handler:CheckState()
local stacks = self:GetStackCount()
local state = {}
if stacks == 0 then
if self:GetParent():HasModifier("modifier_slark_shadow_dance") then
state = {[MODIFIER_STATE_STUNNED] = true,
[MODIFIER_STATE_FROZEN] = true}
end
state = { [MODIFIER_STATE_FROZEN] = true,
[MODIFIER_STATE_ROOTED] = true,
[MODIFIER_STATE_STUNNED] = true,
[MODIFIER_STATE_SILENCED] = true,
[MODIFIER_STATE_INVISIBLE] = false,}
elseif stacks == 1 or stacks == 4 then
state = { [MODIFIER_STATE_NO_UNIT_COLLISION] = true,
[MODIFIER_STATE_FLYING_FOR_PATHING_PURPOSES_ONLY] = true, }
end
return state
end
function modifier_chronosphere_datadriven_new_handler:GetPriority()
if self:GetStackCount() == 0 then
return MODIFIER_PRIORITY_HIGH end
end
function modifier_chronosphere_datadriven_new_handler:GetModifierMoveSpeed_Max()
if self:GetStackCount() == 0 or self:GetStackCount() == 0 then
return self:GetAbility():GetSpecialValueFor("movement_speed") end
end
modifier_chronosphere_datadriven_new_caster_buff = class({})
function modifier_chronosphere_datadriven_new_caster_buff:IsPurgable() return false end
function modifier_chronosphere_datadriven_new_caster_buff:IsHidden() return false end
function modifier_chronosphere_datadriven_new_caster_buff:IsDebuff() return false end
function modifier_chronosphere_datadriven_new_caster_buff:GetEffectName()
return "particles/units/heroes/hero_faceless_void/faceless_void_chrono_speed.vpcf"
end
function modifier_chronosphere_datadriven_new_caster_buff:GetEffectAttachType()
return PATTACH_ABSORIGIN_FOLLOW
end
LinkLuaModifier("chronosphere_datadriven_new_aura", "hero/chronosphere_datadriven_new.lua", LUA_MODIFIER_MOTION_NONE) Handle applier
LinkLuaModifier("chronosphere_datadriven_new_handler", "hero/chronosphere_datadriven_new.lua", LUA_MODIFIER_MOTION_NONE)
LinkLuaModifier("chronosphere_datadriven_new_caster_buff", "hero/chronosphere_datadriven_new.lua", LUA_MODIFIER_MOTION_NONE)
function chronosphere_datadriven_new:GetCooldown(nLevel)
if self:GetCaster():HasScepter() then
return self:GetSpecialValueFor( "cooldown_scepter" )
end
return self.BaseClass.GetCooldown( self, nLevel )
end
function chronosphere_datadriven_new:GetAOERadius()
return self:GetSpecialValueFor( "radius" )
end
function chronosphere_datadriven_new:OnSpellStart()
local caster = self:GetCaster()
local ability = self
local chrono_center = self:GetAbsOrigin()
local duration = self:GetSpecialValueFor( "duration" )
local vision_radius = self:GetSpecialValueFor("vision_radius")
local radius = self:GetSpecialValueFor("radius")
if caster:HasScepter() then
return self:GetSpecialValueFor( "duration_scepter" )
end
AddFOWViewer(caster:GetTeamNumber(), chrono_center, vision_radius, radius, duration, false)
local mod = CreateModifierThinker(caster, ability, "chronosphere_datadriven_new_aura",
{duration = duration}, chrono_center, vision_radius, caster:GetTeamNumber(), false)
end
modifier_chronosphere_datadriven_new_aura = class({})
function modifier_chronosphere_datadriven_new_aura:IsPurgable() return false end
function modifier_chronosphere_datadriven_new_aura:IsHidden() return true end
function modifier_chronosphere_datadriven_new_aura:IsAura() return true end
function modifier_chronosphere_datadriven_new_aura:GetAuraSearchTeam()
return DOTA_UNIT_TARGET_TEAM_BOTH
end
function modifier_chronosphere_datadriven_new_aura:GetAuraSearchFlags()
return DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES + DOTA_UNIT_TARGET_FLAG_INVULNERABLE
end
function modifier_chronosphere_datadriven_new_aura:GetAuraSearchType()
return DOTA_UNIT_TARGET_CREEP + DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BUILDING + DOTA_UNIT_TARGET_OTHER
end
function modifier_chronosphere_datadriven_new_aura:GetModifierAura()
return "modifier_chronosphere_datadriven_new_handler"
end
function modifier_chronosphere_datadriven_new_aura:GetAuraRadius()
return self.radius
end
function modifier_chronosphere_datadriven_new_aura:OnCreated()
if IsServer() then
self.caster = self:GetCaster()
self.ability = self:GetAbility()
self.parent = self:GetParent()
self.radius = self.ability:GetSpecialValueFor("radius")
local particle = ParticleManager:CreateParticle("particles/units/heroes/hero_faceless_void/faceless_void_chronosphere.vpcf", PATTACH_WORLDORIGIN, self.parent)
ParticleManager:SetParticleControl(particle, 0, self.parent:GetAbsOrigin())
ParticleManager:SetParticleControl(particle, 1, Vector(self.radius, self.radius, self.radius))
self:AddParticle(particle, false, false, -1, false, false)
Timers:CreateTimer(FrameTime(), function()
if self:GetStackCount() > 0 then
self:StartIntervalThink(0.1)
self.modifiers = {}
end
end)
end
end
function modifier_chronosphere_datadriven_new_aura:OnRemoved()
if IsServer() then
if self.modifiers then
for _,mod in pairs(self.modifiers) do
if not mod:IsNull() then modestroy() end
end
end
end
end
function modifier_chronosphere_datadriven_new_aura:OnIntervalThink()
local radius = self:GetAuraRadius()
local caster = self:GetCaster()
-- Find the caster and unit under their control under the Chronosphere, and give them the attack speed bonus modifier
local units = FindUnitsInRadius(caster:GetTeamNumber(), self:GetParent():GetAbsOrigin(), nil, radius, DOTA_UNIT_TARGET_TEAM_FRIENDLY, DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC, DOTA_UNIT_TARGET_FLAG_INVULNERABLE, FIND_ANY_ORDER, false)
for _,unit in ipairs(units) do
if unit == caster or unit:GetPlayerOwner() == caster:GetPlayerOwner() then
if not self.modifiers[unit:GetEntityIndex()] then
local mod = unit:AddNewModifier(caster, self:GetAbility(), "modifier_chronosphere_datadriven_new_caster_buff", {})
table.insert(self.modifiers, unit:GetEntityIndex(),mod)
end
end
end
-- Iterate through the units belonging to the caster and see if they're inside the Chronosphere. If not, remove the modifier.
local parent = self:GetParent()
for id,mod in pairs(self.modifiers) do
local unit = EntIndexToHScript(id)
if CalcDistanceBetweenEntityOBB(parent, unit) > self:GetAuraRadius() then
if not mod:IsNull() then modestroy() end
self.modifiers[id] = nil -- table.remove(self.modifiers, id) didn't work
end
end
end
modifier_chronosphere_datadriven_new_handler = class({})
function modifier_chronosphere_datadriven_new_handler:IsHidden() return true end
function modifier_chronosphere_datadriven_new_handler:IsPurgable() return false end
function modifier_chronosphere_datadriven_new_handler:IsDebuff()
if self:GetStackCount() == 1 or self:GetStackCount() == 4 then
return false end
return true
end
function modifier_chronosphere_datadriven_new_handler:OnCreated()
if IsServer() then
self.parent = self:GetParent()
self.caster = self:GetCaster()
if self.parent == self.caster or self.parent:GetPlayerOwner() == self.caster:GetPlayerOwner() then
self:SetStackCount(0)
end
self:StartIntervalThink(FrameTime())
end
end
function modifier_chronosphere_datadriven_new_handler:OnIntervalThink()
if IsServer() then
-- Normal frozen enemy gets interrupted all the time
if self:GetStackCount() == 0 then
-- Make certain people are stunned
self.parent:AddNewModifier(self.caster, self:GetAbility(), "modifier_stunned", {duration = FrameTime()})
self.parent:InterruptMotionControllers(true)
local modifiers = self.parent:FindAllModifiers()
for _,modifier in pairs(modifiers) do
if modifier.IsMotionController then
if modifier:IsMotionController() then
modifierestroy()
end
end
end
end
end
end
function modifier_chronosphere_datadriven_new_handlereclareFunctions()
local funcs ={ MODIFIER_EVENT_ON_ORDER,
MODIFIER_PROPERTY_MOVESPEED_MAX,
}
return funcs
end
function modifier_chronosphere_datadriven_new_handler:CheckState()
local stacks = self:GetStackCount()
local state = {}
if stacks == 0 then
if self:GetParent():HasModifier("modifier_slark_shadow_dance") then
state = {[MODIFIER_STATE_STUNNED] = true,
[MODIFIER_STATE_FROZEN] = true}
end
state = { [MODIFIER_STATE_FROZEN] = true,
[MODIFIER_STATE_ROOTED] = true,
[MODIFIER_STATE_STUNNED] = true,
[MODIFIER_STATE_SILENCED] = true,
[MODIFIER_STATE_INVISIBLE] = false,}
elseif stacks == 1 or stacks == 4 then
state = { [MODIFIER_STATE_NO_UNIT_COLLISION] = true,
[MODIFIER_STATE_FLYING_FOR_PATHING_PURPOSES_ONLY] = true, }
end
return state
end
function modifier_chronosphere_datadriven_new_handler:GetPriority()
if self:GetStackCount() == 0 then
return MODIFIER_PRIORITY_HIGH end
end
function modifier_chronosphere_datadriven_new_handler:GetModifierMoveSpeed_Max()
if self:GetStackCount() == 0 or self:GetStackCount() == 0 then
return self:GetAbility():GetSpecialValueFor("movement_speed") end
end
modifier_chronosphere_datadriven_new_caster_buff = class({})
function modifier_chronosphere_datadriven_new_caster_buff:IsPurgable() return false end
function modifier_chronosphere_datadriven_new_caster_buff:IsHidden() return false end
function modifier_chronosphere_datadriven_new_caster_buff:IsDebuff() return false end
function modifier_chronosphere_datadriven_new_caster_buff:GetEffectName()
return "particles/units/heroes/hero_faceless_void/faceless_void_chrono_speed.vpcf"
end
function modifier_chronosphere_datadriven_new_caster_buff:GetEffectAttachType()
return PATTACH_ABSORIGIN_FOLLOW
end
Код ошибки из консоли:
[ W VScript ]: Script Runtime Error: ...p1\scripts\vscripts\hero\chronosphere_datadriven_new.lua:29: AddFOWViewer called with 6 arguments - expected 5
[ W VScript ]: stack traceback:
[ W VScript ]: [C]: in function 'AddFOWViewer'
[ W VScript ]: ...p1\scripts\vscripts\hero\chronosphere_datadriven_new.lua:29: in function <...p1\scripts\vscripts\hero\chronosphere_datadriven_new.lua:18>
[ W VScript ]: stack traceback:
[ W VScript ]: [C]: in function 'AddFOWViewer'
[ W VScript ]: ...p1\scripts\vscripts\hero\chronosphere_datadriven_new.lua:29: in function <...p1\scripts\vscripts\hero\chronosphere_datadriven_new.lua:18>