• 🏆 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!

[General] This beautiful system broke my core system...

Status
Not open for further replies.
Level 17
Joined
Jun 2, 2009
Messages
1,137
Hello everyone. Sadly, i have to share 2 triggers (GUI and JASS) and i have no idea about Jass coding. I don't know how to read it and it seems this system broke my system.

This is issue with Jass and Gui combined. Let me share both triggers with you.

First Jass (alternatively i was created topic about it because i don't know how to read it) Can someone tell me what is going on here

Second is DDS system by Bribe.

  • Unit Indexer
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call ExecuteFunc("InitializeUnitIndexer")
      • Custom script: endfunction
      • Custom script:
      • Custom script: function ClearUnitIndex takes nothing returns nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Custom value of UDexUnits[UDex]) Equal to 0
        • Then - Actions
          • Set UnitIndexLock[UDex] = (UnitIndexLock[UDex] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UnitIndexLock[UDex] Equal to 0
            • Then - Actions
              • Set UDexNext[UDexPrev[UDex]] = UDexNext[UDex]
              • Set UDexPrev[UDexNext[UDex]] = UDexPrev[UDex]
              • Set UDexPrev[UDex] = 0
              • Set UnitIndexEvent = 0.00
              • Set UnitIndexEvent = 2.00
              • Set UnitIndexEvent = 0.00
              • Set UDexUnits[UDex] = No unit
              • Set UDexNext[UDex] = UDexRecycle
              • Set UDexRecycle = UDex
            • Else - Actions
        • Else - Actions
      • Custom script: endfunction
      • Custom script:
      • Custom script: function IndexUnit takes nothing returns boolean
      • Custom script: local integer pdex = udg_UDex
      • Custom script: local integer ndex
      • -------- - --------
      • -------- You can customize the following block - if conditions are false the (Matching unit) won't be indexed. --------
      • -------- - --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UnitIndexerEnabled Equal to True
          • (Custom value of (Matching unit)) Equal to 0
        • Then - Actions
          • Set UDexWasted = (UDexWasted + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UDexWasted Equal to 32
            • Then - Actions
              • Set UDexWasted = 0
              • Set UDex = UDexNext[0]
              • Custom script: loop
              • Custom script: exitwhen udg_UDex == 0
              • Custom script: set ndex = udg_UDexNext[udg_UDex]
              • Custom script: call ClearUnitIndex()
              • Custom script: set udg_UDex = ndex
              • Custom script: endloop
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UDexRecycle Equal to 0
            • Then - Actions
              • Set UDex = (UDexGen + 1)
              • Set UDexGen = UDex
            • Else - Actions
              • Set UDex = UDexRecycle
              • Set UDexRecycle = UDexNext[UDex]
          • Set UDexUnits[UDex] = (Matching unit)
          • Unit - Set the custom value of UDexUnits[UDex] to UDex
          • Set UDexPrev[UDexNext[0]] = UDex
          • Set UDexNext[UDex] = UDexNext[0]
          • Set UDexNext[0] = UDex
          • Set UnitIndexLock[UDex] = 1
          • Set UnitIndexEvent = 0.00
          • Set UnitIndexEvent = 1.00
          • Set UnitIndexEvent = 0.00
          • Custom script: set udg_UDex = pdex
        • Else - Actions
      • Custom script: return false
      • Custom script: endfunction
      • Custom script:
      • Custom script: function InitializeUnitIndexer takes nothing returns nothing
      • Custom script: local integer i = bj_MAX_PLAYER_SLOTS
      • Custom script: local boolexpr b = Filter(function IndexUnit)
      • Custom script: local region re = CreateRegion()
      • Custom script: local trigger t = GetTriggeringTrigger()
      • Custom script: local rect r = GetWorldBounds()
      • Custom script: call RegionAddRect(re, r)
      • Custom script: call TriggerRegisterEnterRegion(t, re, b)
      • Custom script: call TriggerClearActions(t)
      • Custom script: call TriggerAddAction(t, function ClearUnitIndex)
      • Set UnitIndexerEnabled = True
      • Custom script: loop
      • Custom script: set i = i - 1
      • Custom script: call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, Player(i), b)
      • Custom script: exitwhen i == 0
      • Custom script: endloop
      • Custom script: call RemoveRect(r)
      • Custom script: set re = null
      • Custom script: set r = null
      • Custom script: set t = null
      • Custom script: set b = null
      • Set UnitIndexEvent = 3.00
      • Set UnitIndexEvent = 0.00
Before go further let us correct this.
This 2 systems conflicts?
 
Level 17
Joined
Jun 2, 2009
Messages
1,137
The linked jass code sets unit "cutom"-value, and the indexer sets it too.
I the jass-code needs to be updated to use an array instead of using custom-value for its data-storage. It should be fairly simple imo.
Thank you but i don't have an idea "how" to do that.
My knowledge with the Jass = 0
It could be better if there any gui version. Or if someone can help me about that
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Hopefully I didn't break anything as I can't really test it myself but this should fix your issue:
vJASS:
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
    private integer array CustomValue
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
    local unit u = GetEnumUnit()
    // set custom value to 0?
    set CustomValue[GetUnitUserData(u)] = 0
    //call SetUnitUserData(u, 0)
    call CreepContinueSingle(u)
    //call IssuePointOrderLoc(u, "attack", udg_CreepHedefler[GetUnitAbilityLevel(u, CREEP_ABILITY_ID)])
    set u = null
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 unit u = GetFilterUnit()
    local integer id = GetUnitTypeId(u)
    if id == 0 then // other ids here
        set u = null
        return false
    endif
    if IsUnitEnemy(u, GetOwningPlayer(udg_TempUnit)) and IsClanUnit(u) and CustomValue[GetUnitUserData(u)] == 0 then // and custom value equal to 0
        set u = null
        return true
    endif
    set u = null
    return false
endfunction
 
private function CallbackCreepAttack takes nothing returns nothing //function MRO upper function's callback
    local unit u = GetEnumUnit()
    call IssueTargetOrder(u, "attack", udg_TempUnit)
    call GroupAddUnit(udg_TempGroup, u)
    call SetUnitUserData(u, udg_TempInteger)
    // set custom value of picked unit to targetIndex
    set u = null
endfunction
 
private function CreepsContinueWay2 takes nothing returns nothing // function MQO
    local unit u = GetEnumUnit()
    if GetUnitCurrentOrder(u) == 0 and IsUnitInRange(u, udg_TempUnit, GetUnitAcquireRange(u)) == false then
        call GroupRemoveUnit(udg_TempGroup, u)
        // set custom value to 0?
        call SetUnitUserData(u, 0)
        call CreepContinueSingle(u)
        //call IssuePointOrderLoc(u, "attack", udg_CreepHedefler[GetUnitAbilityLevel(u, CREEP_ABILITY_ID)])
    endif
    set u = null
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
    set orderer = null
    set orderTarget = null
    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 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 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
    local unit u = GetTriggerUnit()
    if IsClanUnit(u) and GetUnitAbilityLevel(u, CREEP_ABILITY_ID) > 0 then
        if GetOwningPlayer(u) == udg_ClanDevilPlayer then
           // call BJDebugMsg("A")
            call SetUnitOwner(u, Player(1), false)
            call SetUnitCreepGuard(u, false)
            call RemoveGuardPosition(u)
            call SetUnitOwner(u, udg_ClanDevilPlayer, false)
        else
            call SetUnitOwner(u, Player(7), false)
            call SetUnitCreepGuard(u, false)
            call RemoveGuardPosition(u)
            call SetUnitOwner(u, udg_ClanReaperPlayer, false)
        endif
    endif
    set u = null
    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

I added a new Integer array variable called CustomValue and replaced all instances of SetUnitUserData() and GetUnitUserData() with it. SetUnitUserData() is the Blizzard function that changes a unit's custom value. GetUnitUserData() is the Blizzard function that gets you a unit's custom value. I also added more local variables because the code was pretty unoptimized.

A unit can only have one Custom Value at a time which can be pretty limiting and cause lots of problems if you have multiple systems trying to use and change it. But that's where a Unit Indexer system comes into play, it's designed to be the ONLY system in your map that uses Custom Value, and then everything else should instead use Variable Arrays that use a unit's Custom Value as their [index].
 
Last edited:
Level 17
Joined
Jun 2, 2009
Messages
1,137
@Uncle I wanted to test and this happens
By the way people says "there are other different things in this jass" and it is another problem to me. Is this Jass doing something different instead of aggro system? I want to learn what it does and i have to delete them.

OR it could be better to create my own. Currently trying to create my own but as i can see picking units after wait not works. It seems i have to add them to TempGroup and delete them after 2 seconds.

  • Untitled Trigger 005
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units within 750.00 of (Position of DamageEventTarget)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (DamageEventTarget is A Hero) Equal to True
              • (DamageEventSource is A Hero) Equal to True
              • ((Picked unit) belongs to an ally of (Owner of DamageEventTarget)) Equal to True
              • ((Picked unit) is A Hero) Equal to False
            • Then - Actions
              • Unit - Order (Picked unit) to Attack DamageEventSource
            • Else - Actions
      • Wait 2.00 seconds
      • Unit - Order (Picked unit) to Stop
I will use NextTarget and CurrentTarget system at Actions when i am done. If it is easier than you expected, i think best way to create our own but first i have to learn what does this Jass (except of aggro) and delete it.
 

Attachments

  • error.png
    error.png
    60.4 KB · Views: 6

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
I updated the code in my last post, try it again.

Also, this is not safe:
  • Wait 2.00 seconds
  • Unit - Order (Picked unit) to Stop
(Picked unit) acts like a global variable that can only have one value at a time. There's no guaranteeing that this will be same (Picked unit) from earlier.

Also, those Actions aren't even inside of the Pick Every Unit action.

And these Conditions are out of place:
  • (DamageEventTarget is A Hero) Equal to True
  • (DamageEventSource is A Hero) Equal to True
You should be checking these in the main Conditions block instead of inside of the Pick Every Unit action. You should only run the Actions if these two Conditions are true.

Lastly, you want to fix those memory leaks as well. Creating a Unit Group and a Point every single time a unit is damaged is going to ruin your map performance.
 
Last edited:
Level 17
Joined
Jun 2, 2009
Messages
1,137
@Uncle This is the new error.

Understood. This is why i was planning to do it like this. By the way i am sorry i hope i am not confusing you.


  • Untitled Trigger 00
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units within 750.00 of (Position of DamageEventTarget)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (DamageEventTarget is A Hero) Equal to True
              • (DamageEventSource is A Hero) Equal to True
              • ((Picked unit) belongs to an ally of (Owner of DamageEventTarget)) Equal to True
              • ((Picked unit) is A Hero) Equal to False
            • Then - Actions
              • Unit Group - Add (Picked unit) to TempGroup
              • Unit Group - Pick every unit in TempGroup and do (Actions)
                • Loop - Actions
                  • Unit - Order (Picked unit) to Attack DamageEventSource
            • Else - Actions
      • Wait 2.00 seconds
      • Unit Group - Order TempGroup to Stop
Now i am creating TempGroup but the question is this trigger will gonna work many times. It will detect all new units added to group and hmmm no i don't think so. When i destroy the group, everything will be lost.
 

Attachments

  • error.png
    error.png
    29.6 KB · Views: 5

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
I updated the code again. I don't want to post too much so if there's another error just know I'll try to update the code again in a little bit.

This is how the trigger should look IF Waits worked, but unfortunately this won't work because of the Wait:
  • The working damage trigger
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventTarget is A Hero) Equal to True
      • (DamageEventSource is A Hero) Equal to True
    • Actions
      • Set Variable DamagePoint = (Position of DamageEventTarget)
      • Set Variable DamageGroup = (Units within 750.00 of DamagePoint and do (Actions)
      • Custom script: call RemoveLocation(udg_DamagePoint)
      • Unit Group - Pick every unit in DamageGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an ally of (Owner of DamageEventTarget)) Equal to True
              • ((Picked unit) is A Hero) Equal to False
              • ((Picked unit) is Alive) Equal to True
            • Then - Actions
              • Unit - Order (Picked unit) to Attack DamageEventSource
              • Wait 2.00 seconds
              • Unit - Order (Picked unit) to Stop
            • Else - Actions
      • Custom script: call DestroyGroup(udg_DamageGroup)
There's multiple solutions but the easiest is to create another trigger that tracks the (Picked unit) using a local variable and orders them to Stop. It's okay to put a Wait in this other trigger because it won't mess with the Loop - Actions (it just works):
  • Untitled Trigger 005
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventTarget is A Hero) Equal to True
      • (DamageEventSource is A Hero) Equal to True
    • Actions
      • Set Variable DamagePoint = (Position of DamageEventTarget)
      • Set Variable DamageGroup = (Units within 750.00 of DamagePoint and do (Actions)
      • Custom script: call RemoveLocation(udg_DamagePoint)
      • Unit Group - Pick every unit in DamageGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an ally of (Owner of DamageEventTarget)) Equal to True
              • ((Picked unit) is A Hero) Equal to False
              • ((Picked unit) is Alive) Equal to True
            • Then - Actions
              • Unit - Order (Picked unit) to Attack DamageEventSource
              • Trigger - Run DamageStopAfterWait (ignoring conditions)
            • Else - Actions
      • Custom script: call DestroyGroup(udg_DamageGroup)
  • DamageStopAfterWait
    • Events
    • Conditions
    • Actions
      • Custom script: local unit udg_DamageUnit = GetEnumUnit()
      • Wait 2.00 seconds
      • Unit - Order DamageUnit to Stop
      • Custom script: set udg_DamageUnit = null
You need to create these variables yourself.
DamagePoint = Point
DamageGroup = Unit Group
DamageUnit = Unit
 
Last edited:
Level 17
Joined
Jun 2, 2009
Messages
1,137
Hello again dear @Uncle sadly few of my players reported this.

"When you get hit by spells of the enemy hero, enemy creatures are changing aggro to targeted hero"

You are standing between creeps and only killing creeps. Then enemy hero casts spell to your hero but enemy creeps starts to attack you.

And here is the video.
Enemy hero casts spell on Pandaren. But allies of the caster decides to attack attacked unit.
Extra details about heroes in video.
Warlock - Archimonde simply casts Firebolt. No dummy units creates.
Pandaren Earth attack range is melee. There is no way to attack enemy hero from that distance.
Can you put Debug message to your Jass Code? Hero[2] attacks Hero[3] and Player1Creeps attacks Hero[x] something like this? So we can test it today.

And this is the Jass you reconfigured. Maybe you wanted to check again.
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
    private integer array CustomValue
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
    local unit u = GetEnumUnit()
    // set custom value to 0?
    set CustomValue[GetUnitUserData(u)] = 0
    //call SetUnitUserData(u, 0)
    call CreepContinueSingle(u)
    //call IssuePointOrderLoc(u, "attack", udg_CreepHedefler[GetUnitAbilityLevel(u, CREEP_ABILITY_ID)])
    set u = null
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 unit u = GetFilterUnit()
    local integer id = GetUnitTypeId(u)
    if id == 0 then // other ids here
        set u = null
        return false
    endif
    if IsUnitEnemy(u, GetOwningPlayer(udg_TempUnit)) and IsClanUnit(u) and CustomValue[GetUnitUserData(u)] == 0 then // and custom value equal to 0
        set u = null
        return true
    endif
    set u = null
    return false
endfunction
 
private function CallbackCreepAttack takes nothing returns nothing //function MRO upper function's callback
    local unit u = GetEnumUnit()
    call IssueTargetOrder(u, "attack", udg_TempUnit)
    call GroupAddUnit(udg_TempGroup, u)
    call SetUnitUserData(u, udg_TempInteger)
    // set custom value of picked unit to targetIndex
    set u = null
endfunction
 
private function CreepsContinueWay2 takes nothing returns nothing // function MQO
    local unit u = GetEnumUnit()
    if GetUnitCurrentOrder(u) == 0 and IsUnitInRange(u, udg_TempUnit, GetUnitAcquireRange(u)) == false then
        call GroupRemoveUnit(udg_TempGroup, u)
        // set custom value to 0?
        call SetUnitUserData(u, 0)
        call CreepContinueSingle(u)
        //call IssuePointOrderLoc(u, "attack", udg_CreepHedefler[GetUnitAbilityLevel(u, CREEP_ABILITY_ID)])
    endif
    set u = null
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
    set orderer = null
    set orderTarget = null
    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 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 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
    local unit u = GetTriggerUnit()
    if IsClanUnit(u) and GetUnitAbilityLevel(u, CREEP_ABILITY_ID) > 0 then
        if GetOwningPlayer(u) == udg_ClanDevilPlayer then
           // call BJDebugMsg("A")
            call SetUnitOwner(u, Player(1), false)
            call SetUnitCreepGuard(u, false)
            call RemoveGuardPosition(u)
            call SetUnitOwner(u, udg_ClanDevilPlayer, false)
        else
            call SetUnitOwner(u, Player(7), false)
            call SetUnitCreepGuard(u, false)
            call RemoveGuardPosition(u)
            call SetUnitOwner(u, udg_ClanReaperPlayer, false)
        endif
    endif
    set u = null
    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

  • Unit Indexer
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call ExecuteFunc("InitializeUnitIndexer")
      • Custom script: endfunction
      • Custom script:
      • Custom script: function ClearUnitIndex takes nothing returns nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Custom value of UDexUnits[UDex]) Equal to 0
        • Then - Actions
          • Set UnitIndexLock[UDex] = (UnitIndexLock[UDex] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UnitIndexLock[UDex] Equal to 0
            • Then - Actions
              • Set UDexNext[UDexPrev[UDex]] = UDexNext[UDex]
              • Set UDexPrev[UDexNext[UDex]] = UDexPrev[UDex]
              • Set UDexPrev[UDex] = 0
              • Set UnitIndexEvent = 0.00
              • Set UnitIndexEvent = 2.00
              • Set UnitIndexEvent = 0.00
              • Set UDexUnits[UDex] = No unit
              • Set UDexNext[UDex] = UDexRecycle
              • Set UDexRecycle = UDex
            • Else - Actions
        • Else - Actions
      • Custom script: endfunction
      • Custom script:
      • Custom script: function IndexUnit takes nothing returns boolean
      • Custom script: local integer pdex = udg_UDex
      • Custom script: local integer ndex
      • -------- - --------
      • -------- You can customize the following block - if conditions are false the (Matching unit) won't be indexed. --------
      • -------- - --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UnitIndexerEnabled Equal to True
          • (Custom value of (Matching unit)) Equal to 0
        • Then - Actions
          • Set UDexWasted = (UDexWasted + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UDexWasted Equal to 32
            • Then - Actions
              • Set UDexWasted = 0
              • Set UDex = UDexNext[0]
              • Custom script: loop
              • Custom script: exitwhen udg_UDex == 0
              • Custom script: set ndex = udg_UDexNext[udg_UDex]
              • Custom script: call ClearUnitIndex()
              • Custom script: set udg_UDex = ndex
              • Custom script: endloop
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UDexRecycle Equal to 0
            • Then - Actions
              • Set UDex = (UDexGen + 1)
              • Set UDexGen = UDex
            • Else - Actions
              • Set UDex = UDexRecycle
              • Set UDexRecycle = UDexNext[UDex]
          • Set UDexUnits[UDex] = (Matching unit)
          • Unit - Set the custom value of UDexUnits[UDex] to UDex
          • Set UDexPrev[UDexNext[0]] = UDex
          • Set UDexNext[UDex] = UDexNext[0]
          • Set UDexNext[0] = UDex
          • Set UnitIndexLock[UDex] = 1
          • Set UnitIndexEvent = 0.00
          • Set UnitIndexEvent = 1.00
          • Set UnitIndexEvent = 0.00
          • Custom script: set udg_UDex = pdex
        • Else - Actions
      • Custom script: return false
      • Custom script: endfunction
      • Custom script:
      • Custom script: function InitializeUnitIndexer takes nothing returns nothing
      • Custom script: local integer i = bj_MAX_PLAYER_SLOTS
      • Custom script: local boolexpr b = Filter(function IndexUnit)
      • Custom script: local region re = CreateRegion()
      • Custom script: local trigger t = GetTriggeringTrigger()
      • Custom script: local rect r = GetWorldBounds()
      • Custom script: call RegionAddRect(re, r)
      • Custom script: call TriggerRegisterEnterRegion(t, re, b)
      • Custom script: call TriggerClearActions(t)
      • Custom script: call TriggerAddAction(t, function ClearUnitIndex)
      • Set UnitIndexerEnabled = True
      • Custom script: loop
      • Custom script: set i = i - 1
      • Custom script: call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, Player(i), b)
      • Custom script: exitwhen i == 0
      • Custom script: endloop
      • Custom script: call RemoveRect(r)
      • Custom script: set re = null
      • Custom script: set r = null
      • Custom script: set t = null
      • Custom script: set b = null
      • Set UnitIndexEvent = 3.00
      • Set UnitIndexEvent = 0.00

I can even send my map to you Uncle. I can provide any information you need.
 
Last edited:
Level 17
Joined
Jun 2, 2009
Messages
1,137
By the way if you can say "delete my jass code and use this trigger" i will use it. No need to bother you with extra jass trigger if you have a solution like this.
Alternatively i will create this trigger and test it with my players

There's multiple solutions but the easiest is to create another trigger that tracks the (Picked unit) using a local variable and orders them to Stop. It's okay to put a Wait in this other trigger because it won't mess with the Loop - Actions (it just works):
  • Untitled Trigger 005
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventTarget is A Hero) Equal to True
      • (DamageEventSource is A Hero) Equal to True
    • Actions
      • Set Variable DamagePoint = (Position of DamageEventTarget)
      • Set Variable DamageGroup = (Units within 750.00 of DamagePoint and do (Actions)
      • Custom script: call RemoveLocation(udg_DamagePoint)
      • Unit Group - Pick every unit in DamageGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an ally of (Owner of DamageEventTarget)) Equal to True
              • ((Picked unit) is A Hero) Equal to False
              • ((Picked unit) is Alive) Equal to True
            • Then - Actions
              • Unit - Order (Picked unit) to Attack DamageEventSource
              • Trigger - Run DamageStopAfterWait (ignoring conditions)
            • Else - Actions
      • Custom script: call DestroyGroup(udg_DamageGroup)
  • DamageStopAfterWait
    • Events
    • Conditions
    • Actions
      • Custom script: local unit udg_DamageUnit = GetEnumUnit()
      • Wait 2.00 seconds
      • Unit - Order DamageUnit to Stop
      • Custom script: set udg_DamageUnit = null
You need to create these variables yourself.
DamagePoint = Point
DamageGroup = Unit Group
DamageUnit = Unit
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
I'm not going to pretend like I actually read all of the code but I did find more cases of custom value being used incorrectly. I fixed those cases so maybe it will work now, but I have no idea.

This code should NOT interfere with your Unit Indexer now:
vJASS:
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
    private integer array CustomValue
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
    local unit u = GetEnumUnit()
    // set custom value to 0?
    set CustomValue[GetUnitUserData(u)] = 0
    //call SetUnitUserData(u, 0)
    call CreepContinueSingle(u)
    //call IssuePointOrderLoc(u, "attack", udg_CreepHedefler[GetUnitAbilityLevel(u, CREEP_ABILITY_ID)])
    set u = null
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 unit u = GetFilterUnit()
    local integer id = GetUnitTypeId(u)
    if id == 0 then // other ids here
        set u = null
        return false
    endif
    if IsUnitEnemy(u, GetOwningPlayer(udg_TempUnit)) and IsClanUnit(u) and CustomValue[GetUnitUserData(u)] == 0 then // and custom value equal to 0
        set u = null
        return true
    endif
    set u = null
    return false
endfunction
 
private function CallbackCreepAttack takes nothing returns nothing //function MRO upper function's callback
    local unit u = GetEnumUnit()
    call IssueTargetOrder(u, "attack", udg_TempUnit)
    call GroupAddUnit(udg_TempGroup, u)
    set CustomValue[GetUnitUserData(u)] = udg_TempInteger
    // set custom value of picked unit to targetIndex
    set u = null
endfunction
 
private function CreepsContinueWay2 takes nothing returns nothing // function MQO
    local unit u = GetEnumUnit()
    if GetUnitCurrentOrder(u) == 0 and IsUnitInRange(u, udg_TempUnit, GetUnitAcquireRange(u)) == false then
        call GroupRemoveUnit(udg_TempGroup, u)
        // set custom value to 0?
        set CustomValue[GetUnitUserData(u)] = 0
        //call SetUnitUserData(u, 0)
        call CreepContinueSingle(u)
        //call IssuePointOrderLoc(u, "attack", udg_CreepHedefler[GetUnitAbilityLevel(u, CREEP_ABILITY_ID)])
    endif
    set u = null
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
    set orderer = null
    set orderTarget = null
    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 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 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
    local unit u = GetTriggerUnit()
    if IsClanUnit(u) and GetUnitAbilityLevel(u, CREEP_ABILITY_ID) > 0 then
        if GetOwningPlayer(u) == udg_ClanDevilPlayer then
           // call BJDebugMsg("A")
            call SetUnitOwner(u, Player(1), false)
            call SetUnitCreepGuard(u, false)
            call RemoveGuardPosition(u)
            call SetUnitOwner(u, udg_ClanDevilPlayer, false)
        else
            call SetUnitOwner(u, Player(7), false)
            call SetUnitCreepGuard(u, false)
            call RemoveGuardPosition(u)
            call SetUnitOwner(u, udg_ClanReaperPlayer, false)
        endif
    endif
    set u = null
    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
Whether or not that's actually related to your problem is beyond me.

Here's how you can display a text message in Jass:
vJASS:
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "HI THERE, THIS IS A MESSAGE")
Put that line in any of the functions, just make sure it happens AFTER the local variables are created.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Looking at the CreepSystem code you'll see this line at the top of it:
vJASS:
library CreepSystem initializer Init
What this does is tell the system to run it's function named Init at the start of the game. If you scroll through the code, particularly at the very bottom I believe, you can find this Init function which is being used to setup everything for the system to work.

So that error is telling you that your Aggro system library is trying to initialize InitTrig_Aggro but apparently it doesn't exist.

You need to either:

1) Delete the initializer from the code.
vJASS:
library Aggro
2) Add that function to the code.
vJASS:
function InitTrig_Aggro takes nothing returns nothing
endfunction
3) Rename that function if you changed the name (be careful when changing the names of things).

At least, I assume this is the problem, you never know with Warcraft 3.
 
Level 17
Joined
Jun 2, 2009
Messages
1,137
Uhm hello again. It seems it is not solved. I was tagged it as solved but when we started to second match, we realized aggro is not works properly. Sometimes creeps follows heroes forever.
Is there a GUI version of this system? If there was a GUI version i was able to check and think about it.

Or what can cause this issue? What kind of system conflicts with this one? I have a no idea because it is Jass and i don't know how to read and i have a no idea what is happening within this jass code This is why i have to ask.

It would be amazing if GUI version of this system.
System: When enemy heroes cast spells on you or attacks you, your friendly units around you starts to attack the enemy who attacks or cast spells on you for few seconds. After few seconds they will order to attack and move to their next targets (next target, current target and previous target already set)
Here is the additional triggers that shows the way to the creeps

  • Creep Yollari
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- S P A W N P O I N T S --------
      • Set DevilSpawnNoktasi[1] = (Center of DevilSpawn1 <gen>)
      • Set DevilSpawnNoktasi[2] = (Center of DevilSpawn2 <gen>)
      • Set DevilSpawnNoktasi[3] = (Center of DevilSpawn3 <gen>)
      • Set ReaperSpawnNoktasi[1] = (Center of ReaperSpawn1 <gen>)
      • Set ReaperSpawnNoktasi[2] = (Center of ReaperSpawn2 <gen>)
      • Set ReaperSpawnNoktasi[3] = (Center of ReaperSpawn3 <gen>)
      • -------- ___________________________ --------
      • Set CreepHedeflerRegion[1] = DevilSpawn1 <gen>
      • Set CreepHedeflerRegion[2] = DevilSol <gen>
      • Set CreepHedeflerRegion[3] = AltMid <gen>
      • Set CreepHedeflerRegion[4] = Reapersol <gen>
      • Set CreepHedeflerRegion[5] = ReaperSpawn1 <gen>
      • Set CreepHedeflerRegion[6] = DevilSpawn2 <gen>
      • Set CreepHedeflerRegion[7] = ReaperSpawn2 <gen>
      • Set CreepHedeflerRegion[8] = DevilSpawn3 <gen>
      • Set CreepHedeflerRegion[9] = DevilSag <gen>
      • Set CreepHedeflerRegion[10] = UstMid <gen>
      • Set CreepHedeflerRegion[11] = ReaperSag <gen>
      • Set CreepHedeflerRegion[12] = ReaperSpawn3 <gen>
      • Set CreepHedefSayisi = 12
      • For each (Integer A) from 1 to CreepHedefSayisi, do (Actions)
        • Loop - Actions
          • Set CreepHedefler[(Integer A)] = (Center of CreepHedeflerRegion[(Integer A)])
          • Trigger - Add to Creep Yonlendirme <gen> the event (Unit - A unit enters CreepHedeflerRegion[(Integer A)])
      • Set DevilNextHedef[1] = (Center of DevilSol <gen>)
      • Set DevilNextHedef[2] = (Center of AltMid <gen>)
      • Set DevilNextHedef[3] = (Center of Reapersol <gen>)
      • Set DevilNextHedef[4] = (Center of ReaperSpawn1 <gen>)
      • Set DevilNextHedef[5] = (Center of ValueReaper <gen>)
      • Set DevilNextHedef[6] = (Center of ReaperSpawn2 <gen>)
      • Set DevilNextHedef[7] = (Center of ValueReaper <gen>)
      • Set DevilNextHedef[8] = (Center of DevilSag <gen>)
      • Set DevilNextHedef[9] = (Center of UstMid <gen>)
      • Set DevilNextHedef[10] = (Center of ReaperSag <gen>)
      • Set DevilNextHedef[11] = (Center of ReaperSpawn3 <gen>)
      • Set DevilNextHedef[12] = (Center of ValueReaper <gen>)
      • Set ReaperNextHedef[1] = (Center of DevilSlayer <gen>)
      • Set ReaperNextHedef[2] = (Center of DevilSpawn1 <gen>)
      • Set ReaperNextHedef[3] = (Center of DevilSol <gen>)
      • Set ReaperNextHedef[4] = (Center of AltMid <gen>)
      • Set ReaperNextHedef[5] = (Center of Reapersol <gen>)
      • Set ReaperNextHedef[6] = (Center of DevilSlayer <gen>)
      • Set ReaperNextHedef[7] = (Center of DevilSpawn2 <gen>)
      • Set ReaperNextHedef[8] = (Center of DevilSlayer <gen>)
      • Set ReaperNextHedef[9] = (Center of DevilSpawn3 <gen>)
      • Set ReaperNextHedef[10] = (Center of DevilSag <gen>)
      • Set ReaperNextHedef[11] = (Center of UstMid <gen>)
      • Set ReaperNextHedef[12] = (Center of ReaperSag <gen>)
      • -------- ___________________________ --------
      • Set DevilSpawnHedef[1] = (Center of DevilSol <gen>)
      • Set DevilSpawnHedef[2] = (Center of ReaperSpawn2 <gen>)
      • Set DevilSpawnHedef[3] = (Center of DevilSag <gen>)
      • Set ReaperSpawnHedef[1] = (Center of Reapersol <gen>)
      • Set ReaperSpawnHedef[2] = (Center of DevilSpawn2 <gen>)
      • Set ReaperSpawnHedef[3] = (Center of ReaperSag <gen>)
      • Set DevilSpawnCreepAbilityLevel[1] = 1
      • Set DevilSpawnCreepAbilityLevel[2] = 6
      • Set DevilSpawnCreepAbilityLevel[3] = 8
      • Set ReaperSpawnCreepAbilityLevel[1] = 5
      • Set ReaperSpawnCreepAbilityLevel[2] = 7
      • Set ReaperSpawnCreepAbilityLevel[3] = 12
  • Creep Yonlendirme
    • Events
    • Conditions
      • ((Owner of (Triggering unit)) Equal to ClanDevilPlayer) or ((Owner of (Triggering unit)) Equal to ClanReaperPlayer)
    • Actions
      • Wait 0.01 seconds
      • For each (Integer A) from 1 to CreepHedefSayisi, do (Actions)
        • Loop - Actions
          • Custom script: if IsLocationInRegion(GetTriggeringRegion(), udg_CreepHedefler[bj_forLoopAIndex]) then
          • -------- Integer A girilen region --------
          • Unit - Set level of BEN CREEBIM for (Triggering unit) to (Integer A)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to ClanDevilPlayer
            • Then - Actions
              • Unit - Order (Triggering unit) to Attack-Move To DevilNextHedef[(Integer A)]
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Triggering unit)) Equal to ClanReaperPlayer
                • Then - Actions
                  • Unit - Order (Triggering unit) to Attack-Move To ReaperNextHedef[(Integer A)]
                • Else - Actions
          • Custom script: endif
 
Last edited:
Level 17
Joined
Jun 2, 2009
Messages
1,137
This is indicative that you should start to learn JASS, step by step. With small things first. You won't be able to understand this trigger in a week or a month, you just have to learn so you're not extremely dependent on others.
This is the only Jass in my map. And i am a person with low IQ. I know i cannot learn it. I just need help with 1 Jass trigger.
I already asked is there a way to convert it to GUI Is there a way to convert this into GUI? Because it has problems and i cannot read Jass.
 
Status
Not open for further replies.
Top