Elaborating on Anti harass system like dota's

RaiJin

New Member
Reaction score
40
JASS:
library AH initializer Anti_Init requires PUI

globals
    private boolean array IsActive
    public  real array  prevX
    public  real array  prevY
    private group array creeps
    private trigger     IssueOrderPoint = CreateTrigger()
    private trigger     IssueOrderTarg  = CreateTrigger()
    private trigger     IssueOrderCreep = CreateTrigger()
endglobals

//My Locals
globals
    private integer unitid
    private unit    first
endglobals

private function HeroFilter takes nothing returns boolean
    return IsUnitType(GetAttacker(),UNIT_TYPE_HERO) and IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) and IsUnitEnemy(GetAttacker(),GetOwningPlayer(GetTriggerUnit()))
endfunction

private function CreepFilterTarget takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO)==false and IsUnitType(GetAttacker(),UNIT_TYPE_HERO)==true
endfunction

private function CreepFilter takes nothing returns boolean
    local integer unitid = GetUnitTypeId(GetFilterUnit())
    if IsActive[GetUnitIndex(GetFilterUnit())] then
        return false
    endif
    return (unitid == 'h005' or unitid =='h008' or unitid =='h00A') and IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(first))==true
endfunction

private function CreepAttack takes nothing returns nothing
    call IssueTargetOrder(GetEnumUnit(),"attack",first)
    set IsActive[GetUnitIndex(GetEnumUnit())]=true
endfunction

private function PointC takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO)==true
endfunction

private function antiend takes nothing returns nothing
    set first=GetTriggerUnit()
    set unitid=GetUnitIndex(first)
    if creeps[unitid]==null then
        return
    endif
    loop
        set first=FirstOfGroup(creeps[unitid])
        exitwhen first==null
        call GroupRemoveUnit(creeps[unitid],first)
        call IssueImmediateOrder(first,"holdposition")
        call IssuePointOrder(first,"attack",prevX[GetUnitIndex(first)],prevY[GetUnitIndex(first)])
        set IsActive[GetUnitId(first)]=false
    endloop
endfunction

private function antiendCREEP takes nothing returns nothing
    set first=GetAttacker()
    set unitid=GetUnitIndex(first)
    if creeps[unitid]==null then
        return
    endif
    loop
        set first=FirstOfGroup(creeps[unitid])
        exitwhen first==null
        call GroupRemoveUnit(creeps[unitid],first)
        call IssueImmediateOrder(first,"holdposition")
        call IssuePointOrder(first,"attack",prevX[GetUnitIndex(first)],prevY[GetUnitIndex(first)])
        set IsActive[GetUnitId(first)]=false
    endloop
endfunction

private function antistart takes nothing returns nothing
    set first=GetAttacker()
    set unitid=GetUnitIndex(first)
    if creeps[unitid]==null then
        set creeps[unitid]=CreateGroup()
    endif
    call GroupEnumUnitsInRange(creeps[unitid],GetUnitX(first),GetUnitY(first),425,Condition(function CreepFilter))
    call ForGroup(creeps[unitid],function CreepAttack)
endfunction

private function Anti_Init takes nothing returns nothing
    local integer i  = 0
    loop
        call TriggerRegisterPlayerUnitEvent(IssueOrderTarg , Player(i),EVENT_PLAYER_UNIT_ATTACKED,           null)
        call TriggerRegisterPlayerUnitEvent(IssueOrderCreep ,Player(i),EVENT_PLAYER_UNIT_ATTACKED,           null)
        call TriggerRegisterPlayerUnitEvent(IssueOrderPoint, Player(i),EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null)
        call TriggerRegisterPlayerUnitEvent(IssueOrderPoint, Player(i),EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER , null)
        set i=i+1
        exitwhen i==12
    endloop
    set i=0
    loop
        set IsActive<i>=false
        set i=i+1
        exitwhen i==100
    endloop
    call TriggerAddCondition(IssueOrderTarg, Condition(function HeroFilter       ))
    call TriggerAddCondition(IssueOrderCreep,Condition(function CreepFilterTarget))
    call TriggerAddCondition(IssueOrderPoint,Condition(function PointC           ))
    call TriggerAddAction   (IssueOrderTarg,           function antistart        )
    call TriggerAddAction   (IssueOrderCreep,          function antiendCREEP     )
    call TriggerAddAction   (IssueOrderPoint,          function antiend          )
endfunction

endlibrary</i>


so i thought that i might try to recreate dota's anti harass system, i thought it was first done by priorities, but i guess its not. Unless it is then this was a huge waste of time.

But anyhow this is how my idea goes, as soon as the creeps spawn for top, mid and bot, we store the value's of where they are going..inside the array prevX, prevY.., then when a unit attacks... and the other unit is a hero, we take all the units around the attacker and make them attack it thus, anti harass... we store all these units into a group. Then we check when the attacker stops harrasing the other hero, so then we order the units to attack the point it was going to..

though is there anyway to improve on this? and sometimes the creeps don't stop attacking even if the hero isn't harassing anymore

IsActive boolean is to check if the creeps are already attacking a harrasser
 

waaaks!

Zinctified
Reaction score
255
dota uses regions and dummy abilities
if a unit enters this region, give this ability, and in their creep agro trigger, when the units are enumerated and ordered to attack that target, after some timer, check if it has this ability, if it has this ability, then order the unit to that region

heres my version, much shorter than dota, but it causes bug when picking all units in the map, pausing them, and after some time, unpausing them (some sort of arena used by my friend) but there's no problem with this code in my map

when 1.24 was released, last order updated, and last order uses UIU, most people uses autoindex (like me), so we changed UIU with autoindex in the required library for last order, now it SOMETIMES causes bug (if u used lastorder with a required library autoindex)

if you want to use this library in your map, download lastorder and don't change the required field in it, and put this code into your map

no need to configure the codes, just configure the global variables
JASS:
library CreepAgro initializer init needs LastOrder, AutoIndex
//by: waaaks!
globals
    private constant real RADIUS = 450.0
    private constant real RETURN_TIME = 3.0

    private boolean array run
    private boolean array ordered
    private string array order
    private real array ox
    private real array oy
    private widget array ot
    private integer array otype
endglobals

private struct data
    group e
endstruct

private function tick takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local data d = GetTimerData(t)
    local unit u
    loop
        set u = FirstOfGroup(d.e)
        exitwhen u == null
        if otype[GetUnitId(u)] == ORDER_TYPE_TARGET then
            call IssueTargetOrder(u,order[GetUnitId(u)],ot[GetUnitId(u)])
        elseif otype[GetUnitId(u)] == ORDER_TYPE_POINT then
            call IssuePointOrder(u,order[GetUnitId(u)],ox[GetUnitId(u)],oy[GetUnitId(u)])
        elseif otype[GetUnitId(u)] == ORDER_TYPE_IMMEDIATE then
            call IssueImmediateOrder(u,order[GetUnitId(u)])
        endif
        set ordered[GetUnitId(u)] = false
        set run[GetUnitId(u)] = false
        call GroupRemoveUnit(d.e,u)
    endloop
    call ReleaseGroup(d.e)
    call ReleaseTimer(t)
    call d.destroy()
    set t = null
    set u = null
endfunction

private function con takes nothing returns boolean
    return IsUnitType(GetOrderTargetUnit(),UNIT_TYPE_HERO) and GetIssuedOrderId() == 851983 and IsUnitEnemy(GetOrderTargetUnit(),GetOwningPlayer(GetTriggerUnit()))
endfunction

private function filter takes nothing returns boolean
    return IsUnitAlly(GetFilterUnit(),GetOwningPlayer(GetOrderTargetUnit())) and not IsUnitType(GetFilterUnit(),UNIT_TYPE_HERO) and (GetOwningPlayer(GetFilterUnit()) == Player(0) or GetOwningPlayer(GetFilterUnit()) == Player(6))
endfunction

private function act takes nothing returns nothing
    local timer t = NewTimer()
    local data d = data.create()
    local unit trg = GetTriggerUnit()
    local group g = NewGroup()
    local unit u
    set d.e = NewGroup()
    call GroupEnumUnitsInRange(g,GetUnitX(trg),GetUnitY(trg),RADIUS,Condition(function filter))
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        if not run[GetUnitId(u)] then
            set run[GetUnitId(u)] = true
            set order[GetUnitId(u)] = GetLastOrderString(u)
            set otype[GetUnitId(u)] = GetLastOrderType(u)
            if otype[GetUnitId(u)] == ORDER_TYPE_POINT then
                set ox[GetUnitId(u)] = GetLastOrderX(u)
                set oy[GetUnitId(u)] = GetLastOrderY(u)
            elseif otype[GetUnitId(u)] == ORDER_TYPE_TARGET then
                set ot[GetUnitId(u)] = GetLastOrderTarget(u)
            endif
        endif
        if IsUnitVisible(GetTriggerUnit(),GetOwningPlayer(u)) and not ordered[GetUnitId(u)] then
            call DisableTrigger(GetTriggeringTrigger())
            call IssueTargetOrder(u,&quot;attack&quot;,trg)
            set ordered[GetUnitId(u)] = true
            call EnableTrigger(GetTriggeringTrigger())
        endif
        call GroupAddUnit(d.e,u)
        call GroupRemoveUnit(g,u)
    endloop
    call ReleaseGroup(g)
    call TimerStart(t,RETURN_TIME,false,function tick)
    call SetTimerData(t,d)
    set g = null
    set trg = null
    set t = null
    set u = null
endfunction

//===========================================================================
private function init takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
    call TriggerAddCondition(t,Condition(function con))
    call TriggerAddAction( t, function act )
endfunction

endlibrary
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
You can use LastOrder Library by Rising Dusk which you can find it in wc3c.net
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top