• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Can someone tell me what is going on here (solved)

Status
Not open for further replies.
Level 17
Joined
Jun 2, 2009
Messages
1,136
Hello everyone. I don't know about Jass and this trigger made by my friend.
When you attack enemy hero and if there are any creeps (friendly units) around them, attack the attacker
Example: Red Archmage attacks Purple Archmage, allied units around attacked unit (Red Archmage attacks Purple Archmage) should attack the Attacker (Red Archmage)
This trigger works until here but the problem starts in here.
I have shared 2 pictures for the details.



JASS:
library CreepSystem initializer Init
 
globals
    private constant real CREEP_ATTACK_FOG_REVEAL_TIME = 1.00
  
    private constant integer CREEP_ABILITY_ID = 'A0E6'
 

    public integer HeroIndex = 0
  
  
    private boolean OBS = false
    private constant integer ORDER_ID_MOVE = 851986
    //private constant integer STOP_ORDER_ID =
    private constant integer ORDER_ID_SMART = 851971
    private constant integer ORDER_ID_ATTACK = 851983
    private unit array HeroAttacker
endglobals
 
public function IsClanUnit takes unit u returns boolean
    return GetOwningPlayer(u) == udg_ClanDevilPlayer or GetOwningPlayer(u) == udg_ClanReaperPlayer
endfunction
 
public function IsRealHero takes unit u returns boolean
    return IsUnitType(u, UNIT_TYPE_HERO) == true and IsUnitIllusion(u) == false // and types
endfunction
 
public function CreepContinueSingle takes unit creep returns nothing
    if GetOwningPlayer(creep) == udg_ClanDevilPlayer then
        call IssuePointOrderLoc(creep, "attack", udg_DevilNextHedef[GetUnitAbilityLevel(creep, CREEP_ABILITY_ID)])
    elseif GetOwningPlayer(creep) == udg_ClanReaperPlayer then
        call IssuePointOrderLoc(creep, "attack", udg_ReaperNextHedef[GetUnitAbilityLevel(creep, CREEP_ABILITY_ID)])
    endif
endfunction
 
///////////////////////////////////////////////////////////////
 
private function RemoveCreepAttackReveal takes nothing returns nothing // function T2I
    local timer t = GetExpiredTimer()
    local fogmodifier f = LoadFogModifierHandle(udg_hash, GetHandleId(t), 0)
    call FogModifierStop(f)
    call DestroyFogModifier(f)
    call FlushChildHashtable(udg_hash, GetHandleId(t))
    call PauseTimer(t)
    call DestroyTimer(t)
    set t = null
    set f = null
endfunction
 
private function CreepAttackReveal takes player p, real time returns nothing // function T3I
    local timer t = CreateTimer()
    local fogmodifier f = CreateFogModifierRadius(p, FOG_OF_WAR_VISIBLE, GetUnitX(GetAttacker()), GetUnitY(GetAttacker()), 128.00, true, false)
    call FogModifierStart(f)
    call SaveFogModifierHandle(udg_hash, GetHandleId(t), 0, f)
    call TimerStart(t, time, false, function RemoveCreepAttackReveal)
    set t = null
    set f = null
endfunction
 
 
function CreepAttackVision takes nothing returns boolean // function NVO
    if GetOwningPlayer(GetTriggerUnit()) == udg_ClanDevilPlayer then
        if IsUnitFogged(GetAttacker(), udg_DevilPlayersArray[1]) or IsUnitFogged(GetAttacker(), udg_ReaperPlayersArray[1]) then
            call CreepAttackReveal(udg_DevilPlayersArray[1], CREEP_ATTACK_FOG_REVEAL_TIME)
        endif
    elseif GetOwningPlayer(GetTriggerUnit()) == udg_ClanReaperPlayer then
        if IsUnitFogged(GetAttacker(), udg_DevilPlayersArray[1]) or IsUnitFogged(GetAttacker(), udg_ReaperPlayersArray[1]) then
            call CreepAttackReveal(udg_ReaperPlayersArray[1],CREEP_ATTACK_FOG_REVEAL_TIME)
        endif
    endif
    return false
endfunction
 
private function RegisterClanUnits takes nothing returns nothing // function NEO
    local unit centerUnit = GetTriggerUnit()
    local unit attacker = HeroAttacker[GetUnitUserData(centerUnit)]
    call SetUnitPosition(centerUnit, GetUnitX(centerUnit), GetUnitY(centerUnit))
    if attacker != null and GetWidgetLife(attacker) > 0 and IsUnitVisible(attacker, GetOwningPlayer(attacker)) then
        call IssueTargetOrder(centerUnit, "attack", attacker)
    else
        call DisableTrigger(GetTriggeringTrigger())
        call CreepContinueSingle(centerUnit)
        //call IssuePointOrderLoc(centerUnit, "attack", udg_CreepHedefler[GetUnitAbilityLevel(centerUnit, CREEP_ABILITY_ID)])
        call EnableTrigger(GetTriggeringTrigger())
    endif
    set centerUnit = null
    set attacker = null
endfunction
 
private function CheckClanUnits takes nothing returns boolean // function NGO
    if IsClanUnit(GetTriggerUnit()) then
        call RegisterClanUnits()
    endif
    return false
endfunction
 
private function CreepHeroAttack takes nothing returns nothing // function NHO
    local unit mover = GetTriggerUnit()
    local unit heroAttacker = HeroAttacker[GetUnitUserData(mover)]
    call SetUnitPosition(mover, GetUnitX(mover), GetUnitY(mover))
    //call BJDebugMsg("B")
    if heroAttacker != null and GetWidgetLife(heroAttacker) > 0 and IsUnitVisible(heroAttacker, GetOwningPlayer(heroAttacker)) then
        call IssueTargetOrder(mover, "attack", heroAttacker)
    else
        call DisableTrigger(GetTriggeringTrigger())
        call CreepContinueSingle(mover)
        //call IssuePointOrderLoc(mover, "attack", udg_[GetUnitAbilityLevel(mover, CREEP_ABILITY_ID)])
        call EnableTrigger(GetTriggeringTrigger())
    endif
    set mover = null
    set heroAttacker = null
endfunction
 
private function CheckOrder takes nothing returns boolean // function NZO
    if GetIssuedOrderId() == ORDER_ID_MOVE then
        //call BJDebugMsg("C")
        call CreepHeroAttack()
    endif
    return false
endfunction
 
function Alliance takes nothing returns nothing
    local integer x = 0
    local integer y = 0
 
    call SetAllyColorFilterState(0)
  
    loop
        exitwhen x>5
        call SetPlayerAlliance(Player(0),udg_DevilPlayersArray[x],ALLIANCE_PASSIVE,true)
        call SetPlayerAlliance(Player(0),udg_DevilPlayersArray[x],ALLIANCE_SHARED_SPELLS,true)
        call SetPlayerAlliance(Player(0),udg_ReaperPlayersArray[x],ALLIANCE_PASSIVE,false)
        call SetPlayerAlliance(Player(0),udg_ReaperPlayersArray[x],ALLIANCE_SHARED_SPELLS,false)
        set x=x+1
    endloop
  
  
    set x=0
    set y=0
    loop
        exitwhen x>5
        loop
            exitwhen y>5
            if(x!=y)then
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_PASSIVE,true)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_HELP_REQUEST,true)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_HELP_RESPONSE,true)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_SHARED_XP,true)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_SHARED_SPELLS,true)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_SHARED_VISION,true)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_SHARED_CONTROL,false)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_SHARED_ADVANCED_CONTROL,false)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_PASSIVE,true)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_HELP_REQUEST,true)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_HELP_RESPONSE,true)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_SHARED_XP,true)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_SHARED_SPELLS,true)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_SHARED_VISION,true)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_SHARED_CONTROL,false)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_SHARED_ADVANCED_CONTROL,false)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_PASSIVE,false)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_HELP_REQUEST,false)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_HELP_RESPONSE,false)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_SHARED_XP,false)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_SHARED_SPELLS,false)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_SHARED_VISION,false)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_SHARED_CONTROL,false)
                call SetPlayerAlliance(udg_DevilPlayersArray[x],udg_ReaperPlayersArray[y],ALLIANCE_SHARED_ADVANCED_CONTROL,false)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_PASSIVE,false)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_HELP_REQUEST,false)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_HELP_RESPONSE,false)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_SHARED_XP,false)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_SHARED_SPELLS,false)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_SHARED_VISION,false)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_SHARED_CONTROL,false)
                call SetPlayerAlliance(udg_ReaperPlayersArray[x],udg_DevilPlayersArray[y],ALLIANCE_SHARED_ADVANCED_CONTROL,false)
            endif
            set y=y+1
        endloop
        set y=0
        set x=x+1
    endloop
endfunction
 
private function CreepsContinueWay takes nothing returns nothing //function MTO
    // set custom value to 0?
    call SetUnitUserData(GetEnumUnit(), 0)
    call CreepContinueSingle(GetEnumUnit())
    //call IssuePointOrderLoc(GetEnumUnit(), "attack", udg_CreepHedefler[GetUnitAbilityLevel(GetEnumUnit(), CREEP_ABILITY_ID)])
endfunction
 
private function CreepAttackTimerCallback takes nothing returns nothing // function MUO
    local integer id = GetHandleId(LoadUnitHandle(udg_hash, GetHandleId(GetExpiredTimer()), 2))
    local integer heroIndex = LoadInteger(udg_hash, id, 143)
    local group g = LoadGroupHandle(udg_hash, id, 144)
    set HeroAttacker[heroIndex] = null
    call ForGroup(g, function CreepsContinueWay)
    call GroupClear(g)
    set g = null
endfunction
 
private function FilterCreepAttack takes nothing returns boolean // function MPO
    local integer id = GetUnitTypeId(GetFilterUnit())
    if id == 0 then // other ids here
        return false
    endif
    if IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_TempUnit)) and IsClanUnit(GetFilterUnit()) and GetUnitUserData(GetFilterUnit()) == 0 then // and custom value equal to 0
        return true
    endif
    return false
endfunction
 
private function CallbackCreepAttack takes nothing returns nothing //function MRO upper function's callback
    call IssueTargetOrder(GetEnumUnit(), "attack", udg_TempUnit)
    call GroupAddUnit(udg_TempGroup, GetEnumUnit())
    call SetUnitUserData(GetEnumUnit(), udg_TempInteger)
    // set custom value of picked unit to targetIndex
endfunction
 
private function CreepsContinueWay2 takes nothing returns nothing // function MQO
    if GetUnitCurrentOrder(GetEnumUnit()) == 0 and IsUnitInRange(GetEnumUnit(), udg_TempUnit, GetUnitAcquireRange(GetEnumUnit())) == false then
        call GroupRemoveUnit(udg_TempGroup, GetEnumUnit())
        // set custom value to 0?
        call SetUnitUserData(GetEnumUnit(), 0)
        call CreepContinueSingle(GetEnumUnit())
        //call IssuePointOrderLoc(GetEnumUnit(), "attack", udg_CreepHedefler[GetUnitAbilityLevel(GetEnumUnit(), CREEP_ABILITY_ID)])
    endif
endfunction
 
private function SetHeroAttacker takes unit target, unit starter returns nothing//function N1O
    local integer id = GetHandleId(target)
    local group g = LoadGroupHandle(udg_hash, id, 144)
    local integer targetIndex = LoadInteger(udg_hash, id, 143)
    local unit heroAttacker = HeroAttacker[targetIndex]
    local group g2 = CreateGroup()
  
    if heroAttacker != null and heroAttacker != starter then
        call ForGroup(g, function CreepsContinueWay)
        call GroupClear(g)
    endif
  
    set HeroAttacker[targetIndex] = starter
    set udg_TempGroup = g
    set udg_TempUnit = starter
    set udg_TempInteger = targetIndex
    call ForGroup(g, function CreepsContinueWay2)
    call GroupEnumUnitsInRange(g2, GetUnitX(target), GetUnitY(target), 500.00, Condition(function FilterCreepAttack))
    call ForGroup(g2, function CallbackCreepAttack)
    call TimerStart(LoadTimerHandle(udg_hash, GetHandleId(target), 141), 2.00, false, function CreepAttackTimerCallback)
  
    call DestroyGroup(g2)
    set g2 = null
    set g = null
    set heroAttacker = null
endfunction
 
function HeroOrderingTarget takes nothing returns boolean // function N2O
    local unit orderer = GetTriggerUnit()
    local unit orderTarget = GetOrderTargetUnit()
    local integer orderId = GetIssuedOrderId()
    local integer orderTargetIndex
    if IsRealHero(orderTarget) and (orderId != ORDER_ID_MOVE or orderId != ORDER_ID_SMART) and IsUnitEnemy(orderer, GetOwningPlayer(orderTarget)) and IsUnitVisible(orderer, GetOwningPlayer(orderTarget)) then
        set orderTargetIndex = LoadInteger(udg_hash, GetHandleId(orderTarget), 143)
        if HeroAttacker[orderTargetIndex] == null or HeroAttacker[orderTargetIndex] == orderTarget or GetWidgetLife(HeroAttacker[orderTargetIndex]) <= 0 then
            if orderTargetIndex != 0 then
                call SetHeroAttacker(orderTarget, orderer)
            endif
        endif
    endif
    return false
endfunction
 
function HeroGettingAttacked takes nothing returns boolean // function N4O
    local unit attacker = GetAttacker()
    local unit attackedHero = GetTriggerUnit()
    local integer attackedIndex
    if IsClanUnit(attacker) == false then
        set attackedIndex = LoadInteger(udg_hash, GetHandleId(attackedHero), 143)
        if HeroAttacker[attackedIndex] == null or HeroAttacker[attackedIndex] == attackedHero or GetWidgetLife(HeroAttacker[attackedIndex]) <= 0 then
            if attackedIndex != 0 then
                call SetHeroAttacker(attackedHero, attacker)
            endif
        endif
    endif
    set attacker = null
    set attackedHero = null
    return false
endfunction
 
private function HeroEnteredGame takes unit hero returns nothing // function N5O
    local group g
    local trigger tr
    local timer t
    local integer id = GetHandleId(hero)
    set HeroIndex = HeroIndex + 1
    call SaveBoolean(udg_hash, id, 142, true)
    call SaveInteger(udg_hash, id, 143, HeroIndex)
    call SaveGroupHandle(udg_hash, id, 144, CreateGroup())
  
    set tr = CreateTrigger()
    call TriggerRegisterUnitEvent(tr, hero, EVENT_UNIT_ISSUED_TARGET_ORDER)
    call TriggerAddCondition(tr, Condition(function HeroOrderingTarget))
  
    set tr = CreateTrigger()
    call TriggerRegisterUnitEvent(tr, hero, EVENT_UNIT_ATTACKED)
    call TriggerAddCondition(tr, Condition(function HeroGettingAttacked))
  
    set t = CreateTimer()
    call SaveTimerHandle(udg_hash, id, 141, t)
    call SaveUnitHandle(udg_hash, GetHandleId(t), 2, hero)
  
    set g = null
    set t = null
    set tr = null
endfunction
 
private function HeroEntersGame takes nothing returns boolean // function N6O
    if IsRealHero(GetTriggerUnit()) and LoadBoolean(udg_hash, GetHandleId(GetTriggerUnit()), 142) == false then
        call HeroEnteredGame(GetTriggerUnit())
    endif
    return false
endfunction
 
private function RemoveCreepGuardPos takes nothing returns boolean
    if IsClanUnit(GetTriggerUnit()) and GetUnitAbilityLevel(GetTriggerUnit(), CREEP_ABILITY_ID) > 0 then
        if GetOwningPlayer(GetTriggerUnit()) == udg_ClanDevilPlayer then
           // call BJDebugMsg("A")
            call SetUnitOwner(GetTriggerUnit(), Player(1), false)
            call SetUnitCreepGuard(GetTriggerUnit(), false)
            call RemoveGuardPosition(GetTriggerUnit())
            call SetUnitOwner(GetTriggerUnit(), udg_ClanDevilPlayer, false)
        else
            call SetUnitOwner(GetTriggerUnit(), Player(7), false)
            call SetUnitCreepGuard(GetTriggerUnit(), false)
            call RemoveGuardPosition(GetTriggerUnit())
            call SetUnitOwner(GetTriggerUnit(), udg_ClanReaperPlayer, false)
        endif
    endif
  
    return false
endfunction
 
private function Register takes nothing returns boolean // function NWO and BO1
    local trigger t
    local group g
    local unit u
    local region re
    set OBS = GetPlayerController(Player(0)) == MAP_CONTROL_USER or GetPlayerController(Player(6)) == MAP_CONTROL_USER
    if OBS then
        call SetAllyColorFilterState(0)
        call Alliance()
  
        set t = CreateTrigger()
        call TriggerRegisterPlayerUnitEvent(t, udg_ClanDevilPlayer, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null)
        call TriggerRegisterPlayerUnitEvent(t, udg_ClanReaperPlayer, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null)
        call TriggerAddCondition(t, Condition(function CheckOrder))
        //call BJDebugMsg("D")
      
        set t = CreateTrigger()
        set g = CreateGroup()
        call GroupEnumUnitsOfPlayer(g, udg_ClanDevilPlayer, null)
        loop
            set u = FirstOfGroup(g)
            exitwhen u == null
            call GroupRemoveUnit(g, u)
            if GetUnitAcquireRange(u) != 0 then
                call TriggerRegisterUnitInRange(t, u, 600.00, null)
            endif
        endloop
        call GroupClear(g)
      
        call GroupEnumUnitsOfPlayer(g, udg_ClanReaperPlayer, null)
        loop
            set u = FirstOfGroup(g)
            exitwhen u == null
            call GroupRemoveUnit(g, u)
            // WHY THIS IF STATEMENT HAS STRUCTURE PART???
            if GetUnitAcquireRange(u) != 0 and IsUnitType(u, UNIT_TYPE_STRUCTURE) then
                call TriggerRegisterUnitInRange(t, u, 600.00, null)
            endif
        endloop
        call GroupClear(g)
        call DestroyGroup(g)
        call TriggerAddCondition(t, Condition(function CheckClanUnits))
      
        set t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED)
        call TriggerAddCondition(t, Condition(function CreepAttackVision))
      
      
      
    endif
  
    set t = CreateTrigger()
    set re = CreateRegion()
    call RegionAddRect(re, GetWorldBounds())
    call TriggerRegisterEnterRegion(t, re, null)
    call TriggerAddCondition(t, Condition(function HeroEntersGame))
  
    //set t = CreateTrigger()
    //set re = CreateRegion()
    //call RegionAddRect(re, GetWorldBounds())
    //call TriggerRegisterEnterRegion(t, re, null)
    //call TriggerAddCondition(t, Condition(function RemoveCreepGuardPos))
   
    set udg_ClanDevilPlayers = GetPlayersAllies(udg_ClanDevilPlayer)
    call ForceRemovePlayer(udg_ClanDevilPlayers, udg_ClanDevilPlayer)
    set udg_ClanDevilPlayerCount = CountPlayersInForceBJ(udg_ClanDevilPlayers)
   
    set udg_ClanReaperPlayers = GetPlayersAllies(udg_ClanReaperPlayer)
    call ForceRemovePlayer(udg_ClanReaperPlayers, udg_ClanReaperPlayer)
    set udg_ClanReaperPlayerCount = CountPlayersInForceBJ(udg_ClanReaperPlayers)
  
    call DisableTrigger(GetTriggeringTrigger())
  
    set t = null
    set g = null
    set u = null
    set re = null
  
    return false
endfunction
 
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEvent(t, 0.50, false)
    call TriggerAddCondition(t, Condition(function Register))
endfunction
 
endlibrary
 

Attachments

  • example 1.png
    example 1.png
    1.1 MB · Views: 36
  • example2.png
    example2.png
    1.4 MB · Views: 35
Level 17
Joined
Jun 2, 2009
Messages
1,136
Uhm Actually still i need with this one. And i am not 100% percent sure about this trigger because i cannot read.
Nowadays i am trying to create my own aggro system and delete this one.
But before deletion, i have to know what does this jass do?
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
I tried to dissect the script :D

While the script leaves a lot to be desired from my point of view (i.e. no comments, magic numbers instead of named constants, somewhat useless conditions/actions, strange function names), as far as I can see it should work as expected.

But one thing to note - the script you posted is not a generic system, on the contrary it seems to be closely tied to your map and I have a suspicion that you also have either some other script somewhere in your map or a GUI trigger for setting the system up (for example the script references DevilNextHedef and ClanDevilPlayer variables which are not set anywhere in the script you posted).
Since I don't know your map, I may be off about some points.

From what I could understand just based on the script alone, your map consists of two factions, each side has X user players who control heroes and one computer player, where the computer player sends non-hero units on lines to attack some pre-defined targets (I imagine similar setup as 'lines' in DoTA for example)
The script you posted causes the computer player's units to help a nearby hero who is engaged in combat with an opponent's hero.

Basically the script can be divided into following sections:
  1. When a computer player's unit is ordered to move somewhere...
    1. ... and there is no nearby allied hero engaged in combat, then override the command and order the unit to attack its next line target instead
    2. ... and there is a nearby allied hero engaged in combat, then order the unit to attack the hero's opponent hero
  2. Similar setup as above is also used whenever any unit comes close enough to the computer player's units
  3. When a player's hero is ordered to engage in combat with enemy hero, pick nearby computer player's unit allied to the targeted enemy hero and order them to help the targeted hero by attacking the attacker
  4. When a player's hero is attacked by enemy player's hero, pick nearby computer player's units allied to the attacked hero and order them to help the attacked hero by attacking the attacker

So I think this works as intended:
  • Red and purple archmagi are user-controller heroes
  • Blue and teal sorceresses are computer-controller units
  • Red and blue are allied and are enemies to purple and teal and vice-versa
  • Red attacks purple (triggering point #3 mentioned above), causing teal sorceresses to attack red
  • Because purple was attacked, the generic unit AI makes the attacked unit retaliate
  • So purple attacks red (triggering point #4 mentioned above), causing blue sorceresses to attack purple
  • ???
  • profit
 
Level 17
Joined
Jun 2, 2009
Messages
1,136
You've had this script in your map for over 4 years and you don't know what it does...?
More than 4 years. Yes i don't know because as i said i have 0 knowledge about Jass. I was created simple aggro system (when you attack enemy hero, attacked unit's allies attacking you for the protect attacked unit) and my friend told me it was not good trigger and gave me to this. But people told me there are more triggers into it. They said "he put another extra triggers by his own"

@Nichilus You are "Amazing" by the way dear @Uncle fixed the creep aggro issue for me in here


This Jass should only be for aggro system but it seems my friend added extra triggers for my map.

DevilNextHedef etc etc was set in other triggers don't worry.

By the way yes, you understand correctly. Uncle found and fixed the issue because of the UnitIndexer was conflicted and now it works perfectly.

If this code only about creep aggro system, no problem. I just wanted to remove unused, unnecessary, unknown parts.

Thank you for your interest again dear @Nichilus
 
Status
Not open for further replies.
Top