[vJass] Antiharras 1.0

User avatar
Enalias
Site Admin
Site Admin
Posts: 200
Joined: Sat Sep 15, 2018 1:57 pm
Reputation: 9
Location: Florida, U.S.A.
Website: http://chaosrealm.co/memberlist.php?mod ... rofile&u=2
Discord: https://discord.gg/BUEZkef
Twitch: https://www.twitch.tv/enalias
Contact:
United States of America

[vJass] Antiharras 1.0

#1

Post by Enalias » Mon Nov 05, 2018 11:28 am

When you attack an enemy hero, this system makes its adjacents allies units attack you.
Useful for AoS maps.
Created by: Fire_Arkangel

Systems required:
- Alloc
- AutoIndex
- TimerUtils

Code:
Spoiler
Show
//==========================================================
//ANTI HARRAS SYSTEM [DOTA REMAKE]
//VERSION: 1.1
//----------------------------------------------------------
//When you attack an enemy hero, this system makes its
//adjacents allies units attack you.
//==========================================================
// CREATED BY: FIRE_ARKANGEL
//----------------------------------------------------------
//IF YOU FIND ANY BUG, SEND A E-MAIL TO:
//[email protected]
//---------------------------------------------------------
// REQUIRES:
// - ALLOC
// http://www.thehelper.net/threads/alloc.146460/
// - AUTOINDEX
// http://www.wc3c.net/showthread.php?t=105643
// - TIMERUTILS
// http://www.wc3c.net/showthread.php?t=101322
//==========================================================
library Antiharras requires Alloc, AutoIndex, TimerUtils
//DON'T MESS HERE
globals
private timer array hero_timers
private group array units
private real array initial_x[1][1]
private real array initial_y[1][1]
endglobals
//-------------------------------------
private struct System extends array

implement Alloc

//CONFIGURATIONS:
private static constant real RADIUS = 800.0
private static constant real AGGRO_TIME = 3.0
//-------------------------------------------
private static group indexed_heroes
private unit attacked

private method destroy takes nothing returns nothing
local integer id = GetUnitId(this.attacked)
call DestroyGroup(units[id])
call GroupRemoveUnit(indexed_heroes, this.attacked)
set hero_timers[id] = null
set units[id] = null
set this.attacked = null
call this.deallocate()
endmethod

private static method come_back takes nothing returns nothing
local thistype this = GetTimerData(GetExpiredTimer())
local integer hero_id = GetUnitId(this.attacked)
local integer unit_id
loop
set bj_lastCreatedUnit = FirstOfGroup(units[GetUnitId(this.attacked)])
exitwhen bj_lastCreatedUnit == null
set unit_id = GetUnitId(bj_lastCreatedUnit)
call IssuePointOrder(bj_lastCreatedUnit, "move", initial_x[hero_id][unit_id], initial_y[hero_id][unit_id])
call GroupRemoveUnit(units[hero_id], bj_lastCreatedUnit)
endloop
call this.destroy()
call ReleaseTimer(GetExpiredTimer())
endmethod

private static method attack takes nothing returns nothing
local thistype this
local integer hero_id
local integer unit_id
if IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and IsUnitType(GetAttacker(), UNIT_TYPE_HERO) then
set hero_id = GetUnitId(GetTriggerUnit())
if not IsUnitInGroup(GetTriggerUnit(), indexed_heroes) then
set this = thistype.allocate()
set this.attacked = GetTriggerUnit()
set units[hero_id] = CreateGroup()
call thistype.pick_units(this.attacked, GetAttacker())
set hero_timers[hero_id] = NewTimerEx(this)
call TimerStart(hero_timers[hero_id], AGGRO_TIME, false, function thistype.come_back)
call GroupAddUnit(indexed_heroes, this.attacked)
else
call thistype.pick_units(GetTriggerUnit(), GetAttacker())
call TimerStart(hero_timers[hero_id], AGGRO_TIME, false, function thistype.come_back)
endif
endif
endmethod

private static method pick_units takes unit attacked, unit attacker returns nothing
local real x = GetUnitX(attacked)
local real y = GetUnitY(attacked)
local integer hero_id = GetUnitId(attacked)
local integer unit_id
set bj_lastCreatedGroup = CreateGroup()
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, RADIUS, null)
loop
set bj_lastCreatedUnit = FirstOfGroup(bj_lastCreatedGroup)
if GetWidgetLife(bj_lastCreatedUnit) > 0.405 and IsUnitAlly(bj_lastCreatedUnit, GetOwningPlayer(attacked)) and GetPlayerController(GetOwningPlayer(bj_lastCreatedUnit)) != MAP_CONTROL_USER and not IsUnitInGroup(bj_lastCreatedUnit, units[hero_id]) then
set unit_id = GetUnitId(bj_lastCreatedUnit)
set initial_x[hero_id][unit_id] = GetUnitX(bj_lastCreatedUnit)
set initial_y[hero_id][unit_id] = GetUnitY(bj_lastCreatedUnit)
call IssueTargetOrder(bj_lastCreatedUnit, "attack", attacker)
call GroupAddUnit(units[hero_id], bj_lastCreatedUnit)
endif
call GroupRemoveUnit(bj_lastCreatedGroup, bj_lastCreatedUnit)
endloop
call DestroyGroup(bj_lastCreatedGroup)
endmethod

private static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i > 11
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_ATTACKED, null)
set i = i + 1
endloop
call TriggerAddAction(t, function thistype.attack)
set indexed_heroes = CreateGroup()
set t = null
endmethod

endstruct

endlibrary
You do not have the required permissions to view the files attached to this post.

Return to “Systems”

×