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
256
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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top