Useful for AoS maps
Created by: Fire_Arkangel
Code:
Spoiler
Show
//==========================================================
//ANTIBACKDOOR [DOTA REMAKE]
//VERSION: 1.0
//----------------------------------------------------------
//Make buildings invulnerable if there's no an creep around
//==========================================================
// CREATED BY: FIRE_ARKANGEL
//----------------------------------------------------------
//IF YOU FIND ANY BUG, SEND A E-MAIL TO:
//abner.math.c@gmail.com
//==========================================================
scope Antibackdoor
private struct System extends array
//CONFIGURATIONS:
private static constant real RADIUS_DETECTION = 800.0 //DETECTION OF CREEPS AROUND BUILDINGS
private static constant real PERIODIC_TIME = 0.1 //TIME TO CHECK IF THERE'S CREEPS AROUND
//------------------------------------------------------------------------------------------
private static method periodic takes nothing returns nothing
local group g
local unit u
local real x
local real y
local integer i
set bj_lastCreatedGroup = CreateGroup()
call GroupEnumUnitsInRect(bj_lastCreatedGroup, bj_mapInitialPlayableArea, null)
loop
set bj_lastCreatedUnit = FirstOfGroup(bj_lastCreatedGroup)
exitwhen bj_lastCreatedUnit == null
if IsUnitType(bj_lastCreatedUnit, UNIT_TYPE_STRUCTURE) then
set g = CreateGroup()
set x = GetUnitX(bj_lastCreatedUnit)
set y = GetUnitY(bj_lastCreatedUnit)
set i = 0
call GroupEnumUnitsInRange(g, x, y, RADIUS_DETECTION, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if IsUnitAlly(u, GetOwningPlayer(bj_lastCreatedUnit)) and GetWidgetLife(u) > 0.405 and not IsUnitType(u, UNIT_TYPE_STRUCTURE) then
set i = i + 1
endif
call GroupRemoveUnit(g, u)
endloop
call DestroyGroup(g)
call SetUnitInvulnerable(bj_lastCreatedUnit, (i == 0))
endif
call GroupRemoveUnit(bj_lastCreatedGroup, bj_lastCreatedUnit)
endloop
call DestroyGroup(bj_lastCreatedGroup)
set g = null
set u = null
endmethod
private static method onInit takes nothing returns nothing
call TimerStart(CreateTimer(), PERIODIC_TIME, true, function thistype.periodic)
endmethod
endstruct
endscope
//ANTIBACKDOOR [DOTA REMAKE]
//VERSION: 1.0
//----------------------------------------------------------
//Make buildings invulnerable if there's no an creep around
//==========================================================
// CREATED BY: FIRE_ARKANGEL
//----------------------------------------------------------
//IF YOU FIND ANY BUG, SEND A E-MAIL TO:
//abner.math.c@gmail.com
//==========================================================
scope Antibackdoor
private struct System extends array
//CONFIGURATIONS:
private static constant real RADIUS_DETECTION = 800.0 //DETECTION OF CREEPS AROUND BUILDINGS
private static constant real PERIODIC_TIME = 0.1 //TIME TO CHECK IF THERE'S CREEPS AROUND
//------------------------------------------------------------------------------------------
private static method periodic takes nothing returns nothing
local group g
local unit u
local real x
local real y
local integer i
set bj_lastCreatedGroup = CreateGroup()
call GroupEnumUnitsInRect(bj_lastCreatedGroup, bj_mapInitialPlayableArea, null)
loop
set bj_lastCreatedUnit = FirstOfGroup(bj_lastCreatedGroup)
exitwhen bj_lastCreatedUnit == null
if IsUnitType(bj_lastCreatedUnit, UNIT_TYPE_STRUCTURE) then
set g = CreateGroup()
set x = GetUnitX(bj_lastCreatedUnit)
set y = GetUnitY(bj_lastCreatedUnit)
set i = 0
call GroupEnumUnitsInRange(g, x, y, RADIUS_DETECTION, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if IsUnitAlly(u, GetOwningPlayer(bj_lastCreatedUnit)) and GetWidgetLife(u) > 0.405 and not IsUnitType(u, UNIT_TYPE_STRUCTURE) then
set i = i + 1
endif
call GroupRemoveUnit(g, u)
endloop
call DestroyGroup(g)
call SetUnitInvulnerable(bj_lastCreatedUnit, (i == 0))
endif
call GroupRemoveUnit(bj_lastCreatedGroup, bj_lastCreatedUnit)
endloop
call DestroyGroup(bj_lastCreatedGroup)
set g = null
set u = null
endmethod
private static method onInit takes nothing returns nothing
call TimerStart(CreateTimer(), PERIODIC_TIME, true, function thistype.periodic)
endmethod
endstruct
endscope