Skip to content

Commit

Permalink
Make wards invisible unless you get close to them (#912)
Browse files Browse the repository at this point in the history
* Make wards invisible unless you get close to them

* Make invisiaura invisible
  • Loading branch information
chrisinajar authored May 27, 2017
1 parent de2c255 commit ea4da86
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
2 changes: 2 additions & 0 deletions game/scripts/vscripts/components/glyph/glyph.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
67 changes: 67 additions & 0 deletions game/scripts/vscripts/modifiers/modifier_ward_invisibility.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ea4da86

Please sign in to comment.