From ea4da86a60b029d0e34fe199e06116dc2dd19fbf Mon Sep 17 00:00:00 2001 From: Chris Vickery Date: Sat, 27 May 2017 14:01:19 -0700 Subject: [PATCH] Make wards invisible unless you get close to them (#912) * Make wards invisible unless you get close to them * Make invisiaura invisible --- .../vscripts/components/glyph/glyph.lua | 2 + .../modifiers/modifier_ward_invisibility.lua | 67 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 game/scripts/vscripts/modifiers/modifier_ward_invisibility.lua diff --git a/game/scripts/vscripts/components/glyph/glyph.lua b/game/scripts/vscripts/components/glyph/glyph.lua index af97aa592d..4353b34b3d 100644 --- a/game/scripts/vscripts/components/glyph/glyph.lua +++ b/game/scripts/vscripts/components/glyph/glyph.lua @@ -1,4 +1,5 @@ LinkLuaModifier("modifier_kill", LUA_MODIFIER_MOTION_NONE) +LinkLuaModifier("modifier_ward_invisibility", "modifiers/modifier_ward_invisibility.lua", LUA_MODIFIER_MOTION_NONE) if Glyph == nil then Debug.EnabledModules['filters:glyph'] = false @@ -62,6 +63,7 @@ function Glyph:CastWard(playerID) local ward = CreateUnitByName("npc_dota_observer_wards", position, true, nil, hero, hero:GetTeam()) ward:AddNewModifier(ward, nil, "modifier_kill", { duration = 360 }) + ward:AddNewModifier(ward, nil, "modifier_ward_invisibility", { }) end function Glyph:ResetWardCooldown(playerID) diff --git a/game/scripts/vscripts/modifiers/modifier_ward_invisibility.lua b/game/scripts/vscripts/modifiers/modifier_ward_invisibility.lua new file mode 100644 index 0000000000..eba7b59c99 --- /dev/null +++ b/game/scripts/vscripts/modifiers/modifier_ward_invisibility.lua @@ -0,0 +1,67 @@ +LinkLuaModifier('modifier_ward_invisibility_enemy', 'modifiers/modifier_ward_invisibility.lua', LUA_MODIFIER_MOTION_NONE) + +modifier_ward_invisibility = class({}) +modifier_ward_invisibility_enemy = class({}) + +function modifier_ward_invisibility_enemy:IsHidden() + return true +end + +function modifier_ward_invisibility:OnCreated() + self.isInvis = true + self.id = "ward_" .. tostring(math.random()) +end +function modifier_ward_invisibility:OnRefresh() + self.isInvis = true + self.id = "ward_" .. tostring(math.random()) +end + +function modifier_ward_invisibility:CheckState() + return { + [MODIFIER_STATE_INVISIBLE] = self.isInvis, + } +end + +function modifier_ward_invisibility:IsHidden() + return true +end + +-------------------------------------------------------------------------- +-- aura stuff + +function modifier_ward_invisibility:IsAura() + return true +end + +function modifier_ward_invisibility:GetAuraSearchType() + return DOTA_UNIT_TARGET_HERO +end + +function modifier_ward_invisibility:GetAuraSearchTeam() + return DOTA_UNIT_TARGET_TEAM_ENEMY +end + +function modifier_ward_invisibility:GetAuraRadius() + return 300 +end + +function modifier_ward_invisibility:GetModifierAura() + return "modifier_ward_invisibility_enemy" +end + +function modifier_ward_invisibility:GetAuraEntityReject(entity) + if self.isInvis then + print(self.id .. ': showing self') + end + self.isInvis = false + + Timers:RemoveTimer(self.id) + Timers:CreateTimer(self.id, { + endTime = 3, + callback = function() + print(self.id .. ': hiding self') + self.isInvis = true + end + }) + return false +end