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 == 039;h005039; or unitid ==039;h008039; or unitid ==039;h00A039;) 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