• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Map gets crazy after getting overloaded with variables

Status
Not open for further replies.
Level 10
Joined
May 24, 2016
Messages
339
During testing with players I've met a bag that makes my map acts like crazy: damage becomes a healing (via scripts), some timers fuctions may stop working. Game cant even count a right variable value via simple functions.
About leaks I can only say - I am vanilla JASS user and know every basic leak rules.
So I started testing map by killing about 100-300 units with one spell and turning them into another units, and everytime I do that, I see some functions stop working right. I dont know what to say more.
 
Last edited:
During testing with players I've met a bag that makes my map acts like crazy: damage becomes a healing (via scripts), some timers fuctions may stop working. Game cant even count a right variable value via simple functions.
About leaks I can only say - I am vanilla JASS user and know every basic leak rules.
So I started testing map by killing about 100-300 units with one spell and turning them into another units, and everytime I do that, I see some functions stop working right. I dont know what to say more.

Okay I found out something. Сoncretely that is a Hashtable. It may not save variables.

You will need to be a bit more specific, since this sort of problem can be caused by a myriad of issues. What are you using the Hashtable for, did you use InitHashtable() to create it? How many Hashtables do you have in your map?
 
Level 10
Joined
May 24, 2016
Messages
339
You will need to be a bit more specific, since this sort of problem can be caused by a myriad of issues. What are you using the Hashtable for, did you use InitHashtable() to create it? How many Hashtables do you have in your map?
Hastable is used for much scripts related with timerstart. Though I use both local timer and global variables timer for hash, so I can save their handle.
Only one hashtable is used, yes by InitHashtable()
 
Hastable is used for much scripts related with timerstart. Though I use both local timer and global variables timer for hash, so I can save their handle.
Only one hashtable is used, yes by InitHashtable()
I see, are you pausing your timers before destroying them? Are you making sure to use FlushChildHashtable on the handle id of the timer, when you are done using them?
 
Level 10
Joined
May 24, 2016
Messages
339
I see, are you pausing your timers before destroying them? Are you making sure to use FlushChildHashtable on the handle id of the timer, when you are done using them?
Never thought it makes some sort of sence, but yeah I pause timers that are set to true value.
I always tried to clean hashtable by removeaavedhandle/flushchildhashtable
The only thing I'm not sure of I often use expiredtimer to go again as a new function

Example
Function humble takes...
Set T = GetExpiredTimer
... Some actions
TimerStart(T, function humble2)
Endfunction
 
Level 10
Joined
May 24, 2016
Messages
339
Using the same timer twice shouldn't be an issue. At this point you seem to be doing everything correctly, so I don't think anyone can help much further without seeing the code that is causing issues.
Omg it seems I fixed it. I almost never checked for dymmy types in trigger even "unit dies". Anyway thx u for help. So glad it ended so easily to fix.
 
Level 10
Joined
May 24, 2016
Messages
339
Well it still happens, but not completely, for a short periods of time, my map gives me some epic errors like "cant calculate is unit enemy or not" or hash doesnt work correctly. So, this happens because of being overlorded with memory or what?
 
Level 10
Joined
May 24, 2016
Messages
339
Okay I'm gonna clarify some things. Maybe somebody could give me advices, and I will be very fucting grateful.
1) For much timers and groups recylcling I always use a global timer EveryTenthSecondOfAGame. It helps me not to create much handles.
2) Using vanilla UNIT_COMES_IN_RANGE events
3) I have a lot of dummy types and feel sorry for that
4) Sometimes I use BJ functions but probably it doesnt affect the game
5) I use a lot of array global variables. Sometimes I check them with that way
Code:
 set i = 0
loop
exitwhen i > 12
if d == UnitVision[i] then
...
i++
endloop
6) I use from russian xgm.ru library that makes dinamically floating text
Simple spoiler
Maybe someone will like that
Code:
library FloatingText
 
 
    globals
        private constant real period = 1.00 / 40.00
        private constant real rate = 0.001265
        private constant real max = 0.034155
        private constant real min = 0.02277
        private constant real lifetime = 2.80
    endglobals
 
    struct FT
        static FT array data
        static integer count=0
        static timer timer=CreateTimer()
 
        static method tim takes nothing returns nothing
            local FT this
            local integer i=0
     
            loop
                exitwhen i>=.count
                set this=.data[i]
         
                if .b then
                    set .fg=.fg+rate
                    if .fg>max then
                        set .b=false
                    else
                        call SetTextTagText(.tt, .s, .fg)
                    endif
                else
                    set .fg=.fg-rate
                    if .fg<min then
                        call SetTextTagPermanent(.tt, false)
                        call SetTextTagLifespan( .tt, lifetime )
                        call SetTextTagFadepoint( .tt, lifetime-0.1 )
                 
                        call .destroy()
                        set .count=.count-1
                        set .data[i]=.data[.count]
                        set i=i-1
                 
                        if .count==0 then
                            call PauseTimer(.timer)
                        endif
                    else
                        call SetTextTagText(.tt, .s, .fg)
                    endif
                endif
         
                set i=i+1
            endloop
        endmethod
 
        static method add takes texttag tt, string s returns nothing
            set .data[.count]=FT.create()
            set .data[.count].tt=tt
            set .data[.count].fg=min
            set .data[.count].b=true
            set .data[.count].s=s
     
            if .count==0 then
                call TimerStart(.timer,period,true,function FT.tim)
            endif
     
            set .count=.count+1
        endmethod
 
        texttag tt
        real fg
        boolean b
        string s
    endstruct
 
endlibrary
7) Using UnitIndexer by Bribe, Missile GUI system by BPower, GetClosestWidget v3.0.1.3 by Bannar aka Spinnaker, vjass Damage system by looking_for_help, checkwalkabilitysystem by PurgeAndFire, escort system by Escort v1.0
8) I use polledwait sometimes and triggersleepaction
9) Dont really think it matters, but sometimes by some error my map can try to RemoveUnitFromGroup that already removed, making quest failed when it's failed already, and etc.
10) I dont always ClearGroup before destroying it
11) I always recycly groups by this trick
Code:
        call GroupClear(P) 
set bj_groupAddGroupDest = P
call ForGroup(Zeal_Casters,function GroupAddGroupEnumJ)
loop
set F = FirstOfGroup(P)
... actions
call GroupRemoveUnit(P)
endloop
 
Last edited:
The only thing that could cause some sort of issue is PolledWait and SleepAction.
9) Dont really think it matters, but sometimes by some error my map can try to RemoveUnitFromGroup that already removed, making quest failed when it's failed already, and etc.

Try fixing this first, maybe it's related to the problem? Though it doesn't seem likely, from what you described.

Apart from that, nothing you said really helps when trying to diagnose the problem. All of those things you mentioned generally work fine, so no one can arbitrarily guess what the problem is. You either need to log the functions that are being executed when the problem is occuring, using BJDebugMessage, to try and pinpoint where exactly the error occurs. Then you can either fix it yourself or post the code here and see if someone knows how to fix it.

Or you can find someone that is willing to go through your map's code and do this debugging processes for you, but that might take a while.

Either way, with what you posted, it's pretty much impossible to solve the problem, since no one can debug something that they can't see (and doesn't have any obvious issues).
 
Level 10
Joined
May 24, 2016
Messages
339
The only thing that could cause some sort of issue is PolledWait and SleepAction.


Try fixing this first, maybe it's related to the problem? Though it doesn't seem likely, from what you described.

Apart from that, nothing you said really helps when trying to diagnose the problem. All of those things you mentioned generally work fine, so no one can arbitrarily guess what the problem is. You either need to log the functions that are being executed when the problem is occuring, using BJDebugMessage, to try and pinpoint where exactly the error occurs. Then you can either fix it yourself or post the code here and see if someone knows how to fix it.

Or you can find someone that is willing to go through your map's code and do this debugging processes for you, but that might take a while.

Either way, with what you posted, it's pretty much impossible to solve the problem, since no one can debug something that they can't see (and doesn't have any obvious issues).
You mean BJDebugMessage? Yes I often use that but my bags are mostly occuring in multiplayer
Code:
function echo takes string s returns nothing
call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,10.,s)
endfunction
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Guhun is just suggesting that you print something to debug functions, not that there's any issue with using BJDebugMsg.

Post
The
Code

Try disabling triggers and code blocks en masse until you get to a point where these issues no longer occur. Then the issue is likely within the most recently disabled block.
 
Level 10
Joined
May 24, 2016
Messages
339
Guhun is just suggesting that you print something to debug functions, not that there's any issue with using BJDebugMsg.

Post
The
Code

Try disabling triggers and code blocks en masse until you get to a point where these issues no longer occur. Then the issue is likely within the most recently disabled block.
This would be great yeah, but I dont have any testers to play this map for 10+ mins when most of the blocks will be turned off to check for bugs. Only if I do it myself, and yeah I'll try doing that.

Post
The
Code
I'm sorry for lack of English enough, but you mean, posting my code here, and somebody would really check it out?
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
I'm sorry for lack of English enough, but you mean, posting my code here, and somebody would really check it out?
It's not a foregone conclusion that someone would, but it's possible. As Guhun said, though:
Either way, with what you posted, it's pretty much impossible to solve the problem, since no one can debug something that they can't see (and doesn't have any obvious issues).
 
Level 10
Joined
May 24, 2016
Messages
339
That's the most huge trigger with a global timer checking for most events.
Code:
scope HuntSystem initializer HS



function RaidGetSpawned takes nothing returns nothing
local boolexpr b = Condition(function HeroAroundOrQuest)
local boolexpr b2
set udg_CP_Point = Location(0.,0.)
loop
set X = GetRandomReal(GetRectMinX(bj_mapInitialPlayableArea), GetRectMaxX(bj_mapInitialPlayableArea))
set Y = GetRandomReal(GetRectMinY(bj_mapInitialPlayableArea), GetRectMaxY(bj_mapInitialPlayableArea))
call MoveLocation(udg_CP_Point,X,Y)
call TriggerExecute( gg_trg_Check_Walkability )
exitwhen udg_CP_PointIsWalkable == true
endloop
//set X = -4350
//set Y = -1115
//call echo("point walk")
if not IsVisibleToPlayer(X,Y,Player(0)) and not IsVisibleToPlayer(X,Y,Player(6)) and not IsPointBlighted(X,Y) and not RectContainsCoordsJ(gg_rct_LivingRegion1,X,Y) and not RectContainsCoordsJ(gg_rct_LivingRegion2,X,Y)/*
*/ and not RectContainsCoordsJ(gg_rct_LivingRegion3,X,Y) and not RectContainsCoordsJ(gg_rct_LivingRegion4,X,Y) and not RectContainsCoordsJ(gg_rct_LivingRegion5,X,Y) /*
*/ and not RectContainsCoordsJ(gg_rct_LivingRegion6,X,Y) and not RectContainsCoordsJ(gg_rct_LivingRegion7,X,Y) and not RectContainsCoordsJ(gg_rct_LivingRegion8,X,Y) /*
*/ and not RectContainsCoordsJ(gg_rct_LivingRegion9,X,Y) and not RectContainsCoordsJ(gg_rct_LivingRegion10,X,Y) and not RectContainsCoordsJ(gg_rct_LivingRegion11,X,Y) and not RectContainsCoordsJ(gg_rct_LivingRegion12,X,Y) /*
*/ and not RectContainsCoordsJ(gg_rct_RestrictedAreaForRaid,X,Y) then
//call echo("no vision")
if  QuestCompleted[1] != true or QuestCompleted[2] != true or QuestCompleted[3] != true or QuestCompleted[4] != true or QuestCompleted[5] != true
//call echo("yeah through")
 call GroupClear(P)
call GroupEnumUnitsInRange(P,GetUnitX(F),GetUnitY(F),2500,b)
set F = FirstOfGroup(P)
if F != null then
//call echo("oh they are around boy")
else
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
//call echo("oh yeah go boy")
loop
set QuestNumber = GetRandomInt(1,5)
exitwhen QuestCompleted[QuestNumber] != true
endloop
//call echo("quest is active")
set b2 = Condition(function RaidAttackFilter)
set T = CreateTimer()
set ID = GetHandleId(T)
 if QuestNumber == 1 then
//set I = 'nfrl'
set I2 = 1
//call echo("furb")
RaidCurrentMax++
set RaidActive[RaidCurrentMax] = true
set RaidGroup[RaidCurrentMax] = CreateGroup()
loop

exitwhen I2 > 1 * RaidLVL
if I2 == 1 or I2 == 2 then
set I = 'nfrl'
elseif I2 == 3
set I = 'nfrs'
endif
set X = X + GetRandomReal(-70,70)
set Y = Y + GetRandomReal(-70,70)
set F = CreateUnit(Player(4),I,X,Y,GetRandomReal(0,360))
call SetUnitColor(F,PLAYER_COLOR_LIGHT_GRAY)
call SaveInteger(Hash,GetHandleId(F),StringHash("RaidInteger"),RaidCurrentMax)
call GroupAddUnit(RaidGroup[RaidCurrentMax],F)
//call echo("create")
set I2 = I2 + 1
endloop


call GroupClear(P)
call GroupEnumUnitsInRange(P,GetUnitX(F),GetUnitY(F),1000,b2) // kda is love
set F = FirstOfGroup(P)
if F != null then
//call echo("start attack nearby unit")
call GroupClear(P2)
set bj_groupAddGroupDest = P2
call ForGroup(RaidGroup[RaidCurrentMax],function GroupAddGroupEnumJ)
loop
set F2 = FirstOfGroup(P2)
exitwhen F2 == null
call IssuePointOrder(F2,"attack",GetUnitX(F),GetUnitY(F))
call GroupRemoveUnit(P2,F2)
endloop

else // they choose to just walk somewhere
//call echo("start they move")
set F2 = FirstOfGroup(RaidGroup[RaidCurrentMax])
loop
set X = GetUnitX(F2) + GetRandomReal(-2500,2500)
set Y = GetUnitY(F2) + GetRandomReal(-2500,2500)
call MoveLocation(udg_CP_Point,X,Y)
call TriggerExecute( gg_trg_Check_Walkability )
exitwhen udg_CP_PointIsWalkable == true
endloop
call GroupClear(P2)
set bj_groupAddGroupDest = P2
call ForGroup(RaidGroup[RaidCurrentMax],function GroupAddGroupEnumJ)
loop
set F2 = FirstOfGroup(P2)
exitwhen F2 == null
call IssuePointOrder(F2,"move",X,Y)
call GroupRemoveUnit(P2,F2)
endloop

endif

elseif QuestNumber == 2
set I2 = 1
//call echo("trent")
RaidCurrentMax++
set RaidActive[RaidCurrentMax] = true
set RaidGroup[RaidCurrentMax] = CreateGroup()
set RaidActive[RaidCurrentMax] = true
loop

exitwhen I2 > 1 * RaidLVL
if I2 == 1 or I2 == 2 then
set I = 'nenc'
elseif I2 == 3
set I = 'nepl'
endif
set X = X + GetRandomReal(-70,70)
set Y = Y + GetRandomReal(-70,70)
set F = CreateUnit(Player(4),I,X,Y,GetRandomReal(0,360))
call SetUnitColor(F,PLAYER_COLOR_LIGHT_GRAY)
call SaveInteger(Hash,GetHandleId(F),StringHash("RaidInteger"),RaidCurrentMax)
call GroupAddUnit(RaidGroup[RaidCurrentMax],F)
//call echo("tregeate")
set I2 = I2 + 1
endloop


call GroupClear(P)
call GroupEnumUnitsInRange(P,GetUnitX(F),GetUnitY(F),1000,b2) // kda is love
set F = FirstOfGroup(P)
if F != null then
//call echo("start attack nearby unit")
call GroupClear(P2)
set bj_groupAddGroupDest = P2
call ForGroup(RaidGroup[RaidCurrentMax],function GroupAddGroupEnumJ)
loop
set F2 = FirstOfGroup(P2)
exitwhen F2 == null
call IssuePointOrder(F2,"attack",GetUnitX(F),GetUnitY(F))
call GroupRemoveUnit(P2,F2)
endloop

else // they choose to just walk somewhere
//call echo("start move")
set F2 = FirstOfGroup(RaidGroup[RaidCurrentMax])
loop
set X = GetUnitX(F2) + GetRandomReal(-2500,2500)
set Y = GetUnitY(F2) + GetRandomReal(-2500,2500)
call MoveLocation(udg_CP_Point,X,Y)
call TriggerExecute( gg_trg_Check_Walkability )
exitwhen udg_CP_PointIsWalkable == true
endloop
call GroupClear(P2)
set bj_groupAddGroupDest = P2
call ForGroup(RaidGroup[RaidCurrentMax],function GroupAddGroupEnumJ)
loop
set F2 = FirstOfGroup(P2)
exitwhen F2 == null
call IssuePointOrder(F2,"attack",X,Y)
call GroupRemoveUnit(P2,F2)
endloop

endif

elseif QuestNumber == 3
set I2 = 1
//call echo("thugs")
RaidCurrentMax++
set RaidActive[RaidCurrentMax] = true
set RaidGroup[RaidCurrentMax] = CreateGroup()
set RaidActive[RaidCurrentMax] = true
loop

exitwhen I2 > 1 * RaidLVL + 1
if I2 == 1 or I2 == 2 then
set I = 'nban'
elseif I2 == 3
set I = 'nbrg'
elseif I2 == 4
 set I = 'nrog'
endif
set X = X + GetRandomReal(-70,70)
set Y = Y + GetRandomReal(-70,70)
set F = CreateUnit(Player(4),I,X,Y,GetRandomReal(0,360))
call SetUnitColor(F,PLAYER_COLOR_LIGHT_GRAY)
call SaveInteger(Hash,GetHandleId(F),StringHash("RaidInteger"),RaidCurrentMax)
call GroupAddUnit(RaidGroup[RaidCurrentMax],F)
//call echo("thugscreate")
set I2 = I2 + 1
endloop


call GroupClear(P)
call GroupEnumUnitsInRange(P,GetUnitX(F),GetUnitY(F),1000,b2) // kda is love
set F = FirstOfGroup(P)
if F != null then
//call echo("start attack nearby unit")
call GroupClear(P2)
set bj_groupAddGroupDest = P2
call ForGroup(RaidGroup[RaidCurrentMax],function GroupAddGroupEnumJ)
loop
set F2 = FirstOfGroup(P2)
exitwhen F2 == null
call IssuePointOrder(F2,"attack",GetUnitX(F),GetUnitY(F))
call GroupRemoveUnit(P2,F2)
endloop

else // they choose to just walk somewhere
//call echo("start move")
set F2 = FirstOfGroup(RaidGroup[RaidCurrentMax])
loop
set X = GetUnitX(F2) + GetRandomReal(-2500,2500)
set Y = GetUnitY(F2) + GetRandomReal(-2500,2500)
call MoveLocation(udg_CP_Point,X,Y)
call TriggerExecute( gg_trg_Check_Walkability )
exitwhen udg_CP_PointIsWalkable == true
endloop
call GroupClear(P2)
set bj_groupAddGroupDest = P2
call ForGroup(RaidGroup[RaidCurrentMax],function GroupAddGroupEnumJ)
loop
set F2 = FirstOfGroup(P2)
exitwhen F2 == null
call IssuePointOrder(F2,"attack",X,Y)
call GroupRemoveUnit(P2,F2)
endloop

endif

elseif QuestNumber == 4
set I2 = 1
//call echo("crypt")
RaidCurrentMax++
set RaidActive[RaidCurrentMax] = true
set RaidGroup[RaidCurrentMax] = CreateGroup()
set RaidActive[RaidCurrentMax] = true
loop

exitwhen I2 > 1 * RaidLVL + 1
if I2 == 1 or I2 == 2 or I2 == 3 or I2 == 4 then
set I = 'ucry'
endif
set X = X + GetRandomReal(-70,70)
set Y = Y + GetRandomReal(-70,70)
set F = CreateUnit(Player(4),I,X,Y,GetRandomReal(0,360))
call SetUnitColor(F,PLAYER_COLOR_LIGHT_GRAY)
call SaveInteger(Hash,GetHandleId(F),StringHash("RaidInteger"),RaidCurrentMax)
call GroupAddUnit(RaidGroup[RaidCurrentMax],F)
//call echo("create")
set I2 = I2 + 1
endloop


call GroupClear(P)
call GroupEnumUnitsInRange(P,GetUnitX(F),GetUnitY(F),1000,b2) // kda is love
set F = FirstOfGroup(P)
if F != null then
//call echo("start attack nearby unit")
call GroupClear(P2)
set bj_groupAddGroupDest = P2
call ForGroup(RaidGroup[RaidCurrentMax],function GroupAddGroupEnumJ)
loop
set F2 = FirstOfGroup(P2)
exitwhen F2 == null
call IssuePointOrder(F2,"attack",GetUnitX(F),GetUnitY(F))
call GroupRemoveUnit(P2,F2)
endloop

else // they choose to just walk somewhere
//call echo("start move")
set F2 = FirstOfGroup(RaidGroup[RaidCurrentMax])
loop
set X = GetUnitX(F2) + GetRandomReal(-2500,2500)
set Y = GetUnitY(F2) + GetRandomReal(-2500,2500)
call MoveLocation(udg_CP_Point,X,Y)
call TriggerExecute( gg_trg_Check_Walkability )
exitwhen udg_CP_PointIsWalkable == true
endloop
call GroupClear(P2)
set bj_groupAddGroupDest = P2
call ForGroup(RaidGroup[RaidCurrentMax],function GroupAddGroupEnumJ)
loop
set F2 = FirstOfGroup(P2)
exitwhen F2 == null
call IssuePointOrder(F2,"attack",X,Y)
call GroupRemoveUnit(P2,F2)
endloop

endif

elseif QuestNumber == 5
set I2 = 1
//call echo("rebel")
RaidCurrentMax++
set RaidActive[RaidCurrentMax] = true
set RaidGroup[RaidCurrentMax] = CreateGroup()
set RaidActive[RaidCurrentMax] = true
loop

exitwhen I2 > 1 * RaidLVL + 1
if I2 == 1 or I2 == 2  then
set I = 'h009'
elseif I2 == 3
set I = 'n002'
elseif I2 == 4 then
set I = 'h00A'
endif
set X = X + GetRandomReal(-70,70)
set Y = Y + GetRandomReal(-70,70)
set F = CreateUnit(Player(4),I,X,Y,GetRandomReal(0,360))
call SetUnitColor(F,PLAYER_COLOR_LIGHT_GRAY)
call SaveInteger(Hash,GetHandleId(F),StringHash("RaidInteger"),RaidCurrentMax)
call GroupAddUnit(RaidGroup[RaidCurrentMax],F)
//call echo("create")
set I2 = I2 + 1
endloop


call GroupClear(P)
call GroupEnumUnitsInRange(P,GetUnitX(F),GetUnitY(F),1000,b2) // kda is love
set F = FirstOfGroup(P)
if F != null then
//call echo("start attack nearby unit")
call GroupClear(P2)
set bj_groupAddGroupDest = P2
call ForGroup(RaidGroup[RaidCurrentMax],function GroupAddGroupEnumJ)
loop
set F2 = FirstOfGroup(P2)
exitwhen F2 == null
call IssuePointOrder(F2,"attack",GetUnitX(F),GetUnitY(F))
call GroupRemoveUnit(P2,F2)
endloop

else // they choose to just walk somewhere
//call echo("start move")
set F2 = FirstOfGroup(RaidGroup[RaidCurrentMax])
loop
set X = GetUnitX(F2) + GetRandomReal(-2500,2500)
set Y = GetUnitY(F2) + GetRandomReal(-2500,2500)
call MoveLocation(udg_CP_Point,X,Y)
call TriggerExecute( gg_trg_Check_Walkability )
exitwhen udg_CP_PointIsWalkable == true
endloop
call GroupClear(P2)
set bj_groupAddGroupDest = P2
call ForGroup(RaidGroup[RaidCurrentMax],function GroupAddGroupEnumJ)
loop
set F2 = FirstOfGroup(P2)
exitwhen F2 == null
call IssuePointOrder(F2,"attack",X,Y)
call GroupRemoveUnit(P2,F2)
endloop

endif

endif
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
//set F = CreateUnit(Player(13),I,X,Y,GetRandomReal(0,360))
//call PingMinimapForForceExJ(HumanForce, X, Y, 3, bj_MINIMAPPINGSTYLE_SIMPLE, 60, 80, 40)
endif

else
//call echo("quest no oh no boy")
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
endif
else
//call echo("no vision oh no boy")
//call PauseTimer(GetExpiredTimer())
//call DestroyTimer(GetExpiredTimer())
endif
call RemoveLocation(udg_CP_Point)
call GroupRemoveUnit(P,F)
 call DestroyBoolExpr(b)
 call DestroyBoolExpr(b2)
 set b2 = null
 set b = null
endfunction





    function EveryTenthCSecondInGame takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local integer idT = GetHandleId(t)
        local integer i
        local boolean FirstUnitDS
        local real r
        local unit f
        local unit d
//local group randomg
//local unit randomu
        local integer i2
        local group g
        local camerasetup cs
        local boolexpr b2
//=====
if not GameOver

set RaidActionCommandInterval = RaidActionCommandInterval - 0.1
if RaidActionCommandInterval <= 0. then // second time
set udg_CP_Point = Location(0.,0.)
set RaidActionCommandInterval = 15.
set I2 = 1
set b2 = Condition(function RaidAttackFilter)
//call echo("we act")
loop
exitwhen I2 > RaidCurrentMax
if RaidActive[I2] != false and RaidCommandIsActive[I2] != true then
//call echo(I2S(I2) + " we do")
set RaidCommandIsActive[I2] = true
set F = FirstOfGroup(RaidGroup[I2])
call GroupClear(P)
call GroupEnumUnitsInRange(P,GetUnitX(F),GetUnitY(F),1000,b2) // kda is love
set F = FirstOfGroup(P)
if F != null then
//call echo(GetUnitName(F))
set RaidTargetUnit[I2] = F
set RaidXPoint[I2] = GetUnitX(F)
set RaidYPoint[I2] = GetUnitY(F)
set RaidCommandType[I2] = 1
//call echo("They attack 2 time")

call GroupClear(P2)
set bj_groupAddGroupDest = P2
call ForGroup(RaidGroup[I2],function GroupAddGroupEnumJ)

loop
set F2 = FirstOfGroup(P2)
exitwhen F2 == null
call IssuePointOrder(F2,"attack",GetUnitX(F),GetUnitY(F))
call GroupRemoveUnit(P2,F2)
endloop

else // they choose to just walk somewhere



set F2 = FirstOfGroup(RaidGroup[I2])
loop
set X = GetUnitX(F2) + GetRandomReal(-2500,2500)
set Y = GetUnitY(F2) + GetRandomReal(-2500,2500)
call MoveLocation(udg_CP_Point,X,Y)
call TriggerExecute( gg_trg_Check_Walkability )
exitwhen udg_CP_PointIsWalkable == true and not RectContainsCoordsJ(gg_rct_RestrictedAreaForRaid,X,Y)
endloop
//call echo("they move 2 time")
//call echo(I2S(I2))
set RaidCommandType[I2] = 2
set RaidXPoint[I2] = X
set RaidYPoint[I2] = Y
call GroupClear(P2)
set bj_groupAddGroupDest = P2
call ForGroup(RaidGroup[I2],function GroupAddGroupEnumJ)
loop
set F2 = FirstOfGroup(P2)
exitwhen F2 == null
call IssuePointOrder(F2,"attack",X,Y)
call GroupRemoveUnit(P2,F2)
endloop

endif

endif

I2++
endloop
//call echo ("end acting")
call RemoveLocation(udg_CP_Point)
call DestroyBoolExpr(b2)
endif

if  QuestCompleted[1] != true or QuestCompleted[2] != true or QuestCompleted[3] != true or QuestCompleted[4] != true or QuestCompleted[5] != true
if RaidSpawn > 0. then
    set RaidSpawn = RaidSpawn - 0.1
    elseif RaidSpawn <= 0. then
    //call echo("true")
    set RaidBoolean = true
    endif
  
    if RaidBoolean == true then
    if RaidInterval > 0. then
    set RaidInterval = RaidInterval - 0.1
    //call echo(R2S(RaidInterval))
    elseif RaidInterval <= 0. then
    //set RaidBoolean = false
    set RaidInterval = 65. //45
    call TimerStart(CreateTimer(),RaidIntReal,true,function RaidGetSpawned)
    //call echo("go spawn")
    endif
    endif
endif


//call echo(R2S(timeperm))
        set time = time + 0.1
        set timeperm = timeperm + 0.1
        if PalSurvive == true then
        set PalSurviveReal = PalSurviveReal - 0.1
        endif
        if PalSurviveReal <= 0. then
        //call echo("&&&&&&")
        call TriggerExecute(gg_trg_PalSurvive)
        endif
        if timeperm == TESTautoUPGRADEtime and TEST == true then
        call SetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD,5000)
        call IssueImmediateOrderById( gg_unit_halt_0059, 'Al01' )
        call echo("1 upg")
      
        elseif timeperm == TESTautoUPGRADEtime + 40. and TEST == true then
        call IssueImmediateOrderById( gg_unit_halt_0059, 'Al02' )
        call echo("1 upg")
        elseif timeperm == TESTautoUPGRADEtime + 80. and TEST == true then
        call IssueImmediateOrderById( gg_unit_halt_0059, 'Al03' )
        call echo("1 upg")
        elseif timeperm == TESTautoUPGRADEtime + 120. and TEST == true then
        call IssueImmediateOrderById( gg_unit_halt_0059, 'Al04' )
        call echo("1 upg")
        elseif timeperm == TESTautoUPGRADEtime + 160. and TEST == true then
        call IssueImmediateOrderById( gg_unit_halt_0059, 'Al05' )
        call echo("1 upg")
        elseif timeperm == TESTautoUPGRADEtime + 200. and TEST == true then
        call IssueImmediateOrderById( gg_unit_halt_0059, 'Al06' )
        call echo("1 upg")
        endif

        if R2I(timeperm) == 120 and LVL2Raid != true then //300
        set LVL2Raid = true
        //call echo("raid lvl 2")
        set RaidLVL = 2
        elseif R2I(timeperm) == 240 and LVL3Raid != true //900
        set LVL3Raid = true
        //call echo("raid lvl 3")
        set RaidLVL = 3
        endif
      
       if BladeUnit != null
       if BladeCd <= 0.
      
       if GetUnitAbilityLevel(BladeUnit,'ANca') == 0
       call UnitAddAbility(BladeUnit,'ANca')
       endif
      
       else
       set BladeCd = BladeCd - 0.1
       endif
       endif
if SoulPickedUp

if IsUnitInvisible(SoulUnit, Player(PLAYER_NEUTRAL_AGGRESSIVE)) == true

if GetInventoryIndexOfItemTypeJ(SoulUnit, 'gsou') > 0

set bj_lastRemovedItem = GetItemOfTypeFromUnitJ(SoulUnit,'gsou')
call UnitRemoveItem(HERO[I2],bj_lastRemovedItem)
call RemoveItem(bj_lastRemovedItem)
set bj_lastCreatedItem = CreateItem('soul', GetUnitX(SoulUnit), GetUnitY(SoulUnit))
    call UnitAddItem(SoulUnit, bj_lastCreatedItem)
endif

else

if GetInventoryIndexOfItemTypeJ(SoulUnit, 'soul') > 0

set bj_lastRemovedItem = GetItemOfTypeFromUnitJ(SoulUnit,'soul')
call UnitRemoveItem(HERO[I2],bj_lastRemovedItem)
call RemoveItem(bj_lastRemovedItem)
set bj_lastCreatedItem = CreateItem('gsou', GetUnitX(SoulUnit), GetUnitY(SoulUnit))
    call UnitAddItem(SoulUnit, bj_lastCreatedItem)
endif

endif

endif

       if Shadows[6] != null
       call SetTextTagPosUnit(LoadTextTagHandle(Hash,GetHandleId(Shadows[6]),4), Shadows[6], 25)
       endif
       if Shadows[7] != null
       call SetTextTagPosUnit(LoadTextTagHandle(Hash,GetHandleId(Shadows[7]),4), Shadows[7], 25)
       endif
       if Shadows[8] != null
       call SetTextTagPosUnit(LoadTextTagHandle(Hash,GetHandleId(Shadows[8]),4), Shadows[8], 25)
       endif
       if Shadows[9] != null
       call SetTextTagPosUnit(LoadTextTagHandle(Hash,GetHandleId(Shadows[9]),4), Shadows[9], 25)
       endif
      
        if PalSurviveReal <= 100 and DefendingEnd == false //-600              1000 -1700( when mortars go kill everything )- 1800 actually
           if (IsPlayerInForce(GetLocalPlayer(), PlayerForce)) then
      
            call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 8., "|c00E35782 100 seconds and the game is end! |r |r")
      
           endif
        call StartSound(gg_snd_ItemReceived)
        set DefendingEnd = true
        endif
      
      
        //call echo(R2S(timeperm))
        //set timemin = timemin + 0.1
        if ThugsReal > 0. then
        set ThugsReal = ThugsReal - 0.1
        if ThugsReal == 0. then
      
        if CountUnitsInGroupJ(ThugsRaidGroup) <= 2 then
        set I = GetRandomInt(1,2)
      
        set ThugsReal = 6.5
        if I == 1 then
        set F = CreateUnit(Player(4),'nban',GetRectCenterX(gg_rct_ThugsSpawner1),GetRectCenterY(gg_rct_ThugsSpawner1),260)
        call GroupAddUnit(ThugsRaidGroup,F)
        else
        set F = CreateUnit(Player(4),'nban',GetRectCenterX(gg_rct_ThugsSpawner2),GetRectCenterY(gg_rct_ThugsSpawner2),260)
        call GroupAddUnit(ThugsRaidGroup,F)
        endif
      
        endif
      
        endif
        endif
      
      
        if FurblogsReal > 0. then
        set FurblogsReal = FurblogsReal - 0.1
endif

        if RectDeadReal > 0. then // PREVENT TOO MUCH WARNING SOUND
        //call echo("rect dead real")
        set RectDeadReal = RectDeadReal - 0.1
        endif
      
        if MedRectWarnReal > 0. then
        set MedRectWarnReal = MedRectWarnReal - 0.1
        endif
      
        if CryptSpidersReal > 0. then
        set CryptSpidersReal = CryptSpidersReal - 0.1
endif
       if RebelsReal > 0. then
       set RebelsReal = RebelsReal - 0.1
       endif
      
        if timeperm >= 240. and CaptainActivated == false then //240 120
        //call echo("CAP IS HERE")
            set CaptainActivated = TRUE
    call PingMinimapForForceExJ(HumanForce, -1160., 3300, 3, bj_MINIMAPPINGSTYLE_SIMPLE, 40,85, 50)
    set i = 0
    loop
    exitwhen i > 3
    if (GetLocalPlayer() == Player(i)) then
        call SetCameraQuickPosition(GetUnitX(F), GetUnitY(F))
    endif
    set i = i + 1
    endloop
    call MsgForce (HumanForce," |c00E35782-> Work of patrols is established.|r")
//call echo("sdsdsdsd CAPTAIN")

        elseif CaptainIsOnCd then
            set CaptainCd = CaptainCd - 0.1

            if CaptainCd <= 0. then
                set CaptainIsOnCd = FALSE
//set CaptainCd = 45.
            endif

        endif
//set g = CreateGroup()
if CountUnitsInGroupJ(QuestionMarkGroup) > 0
//call echo("ssddddS")
call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(QuestionMarkGroup,function GroupAddGroupEnumJ)
loop
            set F = FirstOfGroup(P)
            //call echo(GetUnitName(F))
            exitwhen F == null
          
           set F2 = LoadUnitHandle(Hash,GetHandleId(F),StringHash("QuestMark"))
           //call echo(GetUnitName(F2))
           call SetUnitX(F2,GetUnitX(F))
           call SetUnitY(F2,GetUnitY(F))
          
          
call GroupRemoveUnit(P, F)
endloop

endif



if CountUnitsInGroupJ(AppearingGroup) > 0 then
//call echo("sdd!!")
call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(AppearingGroup,function GroupAddGroupEnumJ)
        loop
            set F = FirstOfGroup(P)
            exitwhen F == null
          
          
          
            set R = LoadReal(Hash, GetHandleId(F), StringHash("Appearing_R"))
            if R <= 0 then
            set R = 15
            else
            set R = R + 24
            endif
                call SetUnitVertexColor(F, 255, 255, 255, R2I(R))
                if R >= 255 then
                    call GroupRemoveUnit(AppearingGroup, F)
                    call RemoveSavedHandle(Hash,GetHandleId(F),StringHash("Appearing_R"))
                    call PauseUnit(F,false)
                else
                    call SaveReal(Hash, GetHandleId(F), StringHash("Appearing_R"), R)
                endif
          


            call GroupRemoveUnit(P, F)
        endloop


endif
//call GroupAddUnit(F2,RainFire)
//call SaveReal(Hash,GetHandleId(F2),StringHash("Rain_Detonation"),1.2)
call GroupClear(P) // R A D I A N C E RADIANCE
set bj_groupAddGroupDest = P
call ForGroup(Radiance,function GroupAddGroupEnumJ)
       // set g = CopyGroup(Paladins)
    loop
    set f = FirstOfGroup(P)
    exitwhen f == null
    if IsUnitInGroup(f,Paladins) then
  
  
      set R = LoadReal(Hash,GetHandleId(f),StringHash("Radiance_R"))
            if R <= 0 then
            call UnitRemoveAbility(f,'A01F')
            call UnitRemoveAbility(f,'B00D')
            //call echo("end")
            call DestroyEffect(LoadEffectHandle(Hash,GetHandleId(f),StringHash("Radiance_eff")))
            call RemoveSavedHandle(Hash,GetHandleId(f),StringHash("Radiance_eff"))
                call RemoveSavedReal(Hash,GetHandleId(f),StringHash("Radiance_R"))
                call GroupRemoveUnit(Radiance,f)
    else
            set R = R-0.1
            //call echo("-R")
            call SaveReal(Hash,GetHandleId(f),StringHash("Radiance_R"),R)
            set B = Condition(function Radiance_Filter)
                call GroupClear(P2)
                call GroupEnumUnitsInRange(P2, GetUnitX(f), GetUnitY(f), 400, B)
                loop
                set F2 = FirstOfGroup(P2)
                exitwhen F2 == null
                call UnitDamageTarget(f,F2,5.,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
                call AddEffectTimeToUnit("Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage.mdl",F2,"chest",0.1)
                //call echo(R2S(r))"Ember Shield I FX 5.mdx"
                call GroupRemoveUnit(P2,F2)
                endloop
                call DestroyBoolExpr(B)
          
            endif
      
        elseif GetUnitTypeId(f) == 'hhes' then
      
        set B = Condition(function Radiance_Filter)
                call GroupClear(P2)
                call GroupEnumUnitsInRange(P2, GetUnitX(f), GetUnitY(f), 1000, B)
                set F2 = GetClosestUnitInGroup(GetUnitX(f), GetUnitY(f), P2)
                /*
                if GetUnitTypeId(ar) == 'hhes' and not IssueTargetOrder(ar,"creepthunderbolt",at)  then
        //call echo("yes")
        call IssueTargetOrder(ar,"creepthunderbolt",at)
        endif */
        if not IssueTargetOrder(f,"creepthunderbolt",F2) then
        //call echo("yes")
        call IssueTargetOrder(f,"creepthunderbolt",F2)
        endif
                call DestroyBoolExpr(B)
      
        endif
     call GroupRemoveUnit(P, f)
     endloop
    
call GroupClear(P) // R A I N RAIN FIRE
set bj_groupAddGroupDest = P
call ForGroup(RainFire,function GroupAddGroupEnumJ)
       // set g = CopyGroup(Paladins)
    loop
    set f = FirstOfGroup(P)
    exitwhen f == null
            set R = LoadReal(Hash,GetHandleId(f),StringHash("Rain_Detonation"))
            if R <= 0 then
            //call echo("DOES END")
            set F = LoadUnitHandle(Hash,GetHandleId(f),StringHash("Rain_caster"))
            set r = LoadReal(Hash,GetHandleId(f),StringHash("Rain_damage"))
            set R2 = LoadReal(Hash,GetHandleId(f),StringHash("Rain_radius"))
            call PlaySoundAtPoint("Abilities\\Spells\\Undead\\Curse\\CurseTarget1.wav", GetUnitX(f), GetUnitY(f) )
                set B = Condition(function Rain_Filter)
                call GroupClear(P2)
                call GroupEnumUnitsInRange(P2, GetUnitX(f), GetUnitY(f), R2, B)
                loop
                set F2 = FirstOfGroup(P2)
                exitwhen F2 == null
                call UnitDamageTarget(F,F2,r,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
                //call echo(R2S(r))
                call GroupRemoveUnit(P2,F2)
                endloop
                call DestroyBoolExpr(B)
                call GroupRemoveUnit(RainFire,f)
            call FlushChildHashtable(Hash,GetHandleId(f))
            call KillUnit(f)
          
            else
            set R = R-0.1
            call SaveReal(Hash,GetHandleId(f),StringHash("Rain_Detonation"),R)
            endif
     call GroupRemoveUnit(P, f)
     endloop
      

      
call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(Paladins,function GroupAddGroupEnumJ)
       // set g = CopyGroup(Paladins)
        loop
            set f = FirstOfGroup(P)
            exitwhen f == null
            //Paladins VISIOn
            //call echo(GetUnitName(f))
            set F2 = LoadUnitHandle(Hash,GetHandleId(f),StringHash("P_Vision"))
          
            if SpyVision[GetPlayerId(GetOwningPlayer(f))] == true and GetInventoryIndexOfItemTypeJ(f, 'tels') <= 0 then
call UnitRemoveAbility(F2,'ALsi')
            endif
            set X = GetUnitX(f)
            set Y = GetUnitY(f)
            //call echo(GetUnitName(F2))
            call SetUnitX(F2,X)
            call SetUnitY(F2,Y)
            //call echo(R2S(GetUnitX(f)))
            if GetInventoryIndexOfItemTypeJ(f, 'schl') > 0
call SetUnitLife(f,GetUnitLife(f) + 0.15)
call SetUnitState(f,UNIT_STATE_MANA,GetUnitState(f,UNIT_STATE_MANA) + 0.1)
            endif
            call GroupClear(P2)
            call GroupEnumUnitsInRange(P2, GetUnitX(f), GetUnitY(f), 1300, null)


            loop
                set F = FirstOfGroup(P2)
                exitwhen F == null

                if UnitTypeNotDummy(F) and IsUnitType(F, UNIT_TYPE_STRUCTURE) and IsPlayerInForce(GetOwningPlayer(F),HumanForce)  then //

                    if LoadReal(Hash, GetHandleId(F), StringHash("STR_r")) <= 0. then
                        call SaveUnitHandle(Hash, GetHandleId(F), StringHash("STR_u"), CreateUnit(GetOwningPlayer(f), 'e00I', GetUnitX(F), GetUnitY(F), 0))
                    endif
                    if GuardTip[GetPlayerId(GetOwningPlayer(f))] != true and timeperm > 140. then
                    set GuardTip[GetPlayerId(GetOwningPlayer(f))] = true
                    call MsgP(GetPlayerId(GetOwningPlayer(f)),"|c00EDBDA7Structures nearby your hero gives your additicnal vision and true sight (that can track DreadLords). Note that true sight works on less distance(900 = around 18 metres) than base vision|r", 12.)
                    endif
                    call SaveReal(Hash, GetHandleId(F), StringHash("STR_r"), 3.)
                    
                    if not IsUnitInGroup(F, BuildVision) then
                        call GroupAddUnit(BuildVision, F)
                    endif

                endif

                call GroupRemoveUnit(P2, F)
            endloop

            call GroupRemoveUnit(P, f)
        endloop

        call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(DreadLords,function GroupAddGroupEnumJ)
       // set g = CopyGroup(Paladins)
        loop
            set f = FirstOfGroup(P)
            exitwhen f == null
            //Dreadlords VISION
            set F2 = LoadUnitHandle(Hash,GetHandleId(f),StringHash("DL_Vision"))
            call SetUnitX(F2,GetUnitX(f))
            call SetUnitY(F2,GetUnitY(f))
          
          
            if GetInventoryIndexOfItemTypeJ(f, 'stwa') > 0
call SetUnitState(f,UNIT_STATE_MANA,GetUnitState(f,UNIT_STATE_MANA) + 0.1)

endif

        if GetInventoryIndexOfItemTypeJ(f, 'sprn') > 0
call SetUnitLife(f,GetUnitLife(f) + 0.1)
call SetUnitState(f,UNIT_STATE_MANA,GetUnitState(f,UNIT_STATE_MANA) + 0.1)
            endif
call GroupRemoveUnit(P, f)
        endloop
      
      
call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(BuildVision,function GroupAddGroupEnumJ)
       // set g = CopyGroup()
        loop
            set f = FirstOfGroup(P)
            exitwhen f == null

            set i2 = GetHandleId(f)
            set r = LoadReal(Hash, i2, StringHash("STR_r")) - 0.1

            if r <= 0. then

                call RemoveUnit(LoadUnitHandle(Hash, i2, StringHash("STR_u")))
                call GroupRemoveUnit(BuildVision, f)
                call RemoveSavedHandle(Hash, i2, StringHash("STR_u"))
                call RemoveSavedReal(Hash, i2, StringHash("STR_r"))


            else
                call SaveReal(Hash, i2, StringHash("STR_r"), r)
            endif

            call GroupRemoveUnit(P, f)
        endloop
        //call DestroyGroup(g)


call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(ReplicsGroup,function GroupAddGroupEnumJ)
        loop
            set f = FirstOfGroup(P)
            exitwhen f == null
            set r = LoadReal(Hash, GetHandleId(f), StringHash("ReplicReal")) - 0.1
            if r <= 0. then
                call RemoveSavedBoolean(Hash, GetHandleId(f), StringHash("ReplicBoolean"))
                call RemoveSavedReal(Hash, GetHandleId(f), StringHash("ReplicReal"))
                call GroupRemoveUnit(ReplicsGroup, f)
            else

                call SaveReal(Hash, GetHandleId(f), StringHash("ReplicReal"), r)
            endif
            call GroupRemoveUnit(P, f)
        endloop
      
      
      
      
      
        //call DestroyGroup(g)

call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(ShareVisionGroup,function GroupAddGroupEnumJ)
      //  set g = CopyGroup(ShareVisionGroup)
        loop
            set f = FirstOfGroup(P)
            exitwhen f == null
            set r = LoadReal(Hash, GetHandleId(f), StringHash("SV_r")) - 0.1
            set d = LoadUnitHandle(Hash, GetHandleId(f), StringHash("SV_d"))
            if r <= 0. then
                call DestroyEffect(LoadEffectHandle(Hash, GetHandleId(f), StringHash("SV_e")))
                call RemoveSavedHandle(Hash, GetHandleId(f), StringHash("SV_e"))
                call RemoveSavedHandle(Hash, GetHandleId(f), StringHash("SV_d"))
                call RemoveSavedInteger(Hash,GetHandleId(f),StringHash("SV_i"))
                call RemoveSavedReal(Hash, GetHandleId(f), StringHash("SV_r"))
                call GroupRemoveUnit(ShareVisionGroup, f)
                call RemoveUnit(d)
            else
                call SaveReal(Hash, GetHandleId(f), StringHash("SV_r"), r)
                call SetUnitX(d, GetUnitX(f))
                call SetUnitY(d, GetUnitY(f))
            endif
            call GroupRemoveUnit(P, f)
        endloop
        //call DestroyGroup(g)
call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(FocusedUnitVision,function GroupAddGroupEnumJ)
        //set g = CopyGroup(FocusedUnitVision)
        loop
            set f = FirstOfGroup(P)
            exitwhen f == null
          
            set I = LoadInteger(Hash,GetHandleId(f),StringHash("FocusedUnit[i]_i"))
            set d = HuntTargetUnitDummy[I]
            if not IsUnitDead(d) then
                call SetUnitX(d, GetUnitX(f))
                call SetUnitY(d, GetUnitY(f))
            endif
          
          
            call GroupRemoveUnit(P, f)
        endloop
       // call DestroyGroup(g)
      
        call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(Zeal_Casters,function GroupAddGroupEnumJ)
       // set g = CopyGroup(Zeal_Casters) // ZEAL zeal group casters
        loop
            set f = FirstOfGroup(P)
            exitwhen f == null
            set r = LoadReal(Hash, GetHandleId(f), StringHash("Zeal_time")) - 0.1
            if r <= 0. then

                call GroupRemoveUnit(Zeal_Casters, f)
                call UnitRemoveAbility(f, 'A00J')
                call UnitRemoveAbility(f, 'A00K')
                call UnitRemoveAbility(f, 'B007')
                call DestroyEffect(LoadEffectHandle(Hash, GetHandleId(f), StringHash("Zeal_e")))
                call RemoveSavedHandle(Hash, GetHandleId(f), StringHash("Zeal_e"))
                call RemoveSavedReal(Hash, GetHandleId(f), StringHash("Zeal_time"))
                call GroupRemoveUnit(ReplicsGroup, f)

            else
                if r == 5. then
                    call SetUnitAbilityLevel(f, 'A00J', GetUnitAbilityLevel(f, 'A00J') + 1)
//call echo(I2S(GetUnitAbilityLevel(f,'A00J')+1))
                endif
                call SaveReal(Hash, GetHandleId(f), StringHash("Zeal_time"), r)
            endif


            call GroupRemoveUnit(P, f)
        endloop
        //call DestroyGroup(g)

        call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(Sorcerers,function GroupAddGroupEnumJ)
        //set g = CopyGroup()
        loop
            set f = FirstOfGroup(P)
            exitwhen f == null

            set r = LoadReal(Hash, GetHandleId(f), StringHash("POL_r")) - 0.1
            if r <= 0. then


                call RemoveSavedReal(Hash, GetHandleId(f), StringHash("POL_r"))
                call GroupRemoveUnit(Sorcerers, f)


            else
                call SaveReal(Hash, GetHandleId(f), StringHash("POL_r"), r)
            endif

            call GroupRemoveUnit(P, f)
        endloop
       // call DestroyGroup(g)
        call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(PowerDashHaste,function GroupAddGroupEnumJ)
        //set g = CopyGroup()
        loop
            set f = FirstOfGroup(P)
            exitwhen f == null

            set r = LoadReal(Hash, GetHandleId(f), StringHash("CPT_HASTE")) - 0.1
            if r <= 0. then

                call UnitRemoveAbility(f, 'ACua')
                call RemoveSavedReal(Hash, GetHandleId(f), StringHash("CPT_HASTE"))
                call GroupRemoveUnit(PowerDashHaste, f)


            else
                call SaveReal(Hash, GetHandleId(f), StringHash("CPT_HASTE"), r)
            endif

            call GroupRemoveUnit(P, f)
        endloop
        //call DestroyGroup(g)

        call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(DSgroup,function GroupAddGroupEnumJ)
      //  set g = CopyGroup(DSgroup)
        loop
            set f = FirstOfGroup(P)
            exitwhen f == null
            if GetUnitAbilityLevel(f, 'B005') <= 0 and GetUnitAbilityLevel(f, 'B00C') <= 0 then
                set r = LoadReal(Hash, GetHandleId(f), StringHash("DS_trsp")) - 4
                call SetUnitVertexColor(f, 200, 200, 200, R2I(r))
                if r <= 75 then
                    call GroupRemoveUnit(DSgroup, f)
                    call FlushChildHashtable(Hash, GetHandleId(f))
                  
                    call RemoveUnit(f)
                  
                else
                    call SaveReal(Hash, GetHandleId(f), StringHash("DS_trsp"), r)
                endif
            else
            call SetUnitVertexColor(f, 255, 255, 255, 255)
                call SaveReal(Hash, GetHandleId(f), StringHash("DS_trsp"), 255)
            endif


            call GroupRemoveUnit(P, f)
        endloop
       // call DestroyGroup(g)

               call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(DSgroupDread,function GroupAddGroupEnumJ)
//set g = CopyGroup(DSgroupDread)
        loop
            set f = FirstOfGroup(P)
            exitwhen f == null
            //if GetUnitAbilityLevel(f, 'B005') <= 0 then
                set r = LoadReal(Hash, GetHandleId(f), StringHash("DSD_trsp")) - 6
                call SetUnitVertexColor(f, 200, 200, 200, R2I(r))
                if r <= -70 then
                    call GroupRemoveUnit(DSgroupDread, f)
                    call RemoveSavedHandle(Hash, GetHandleId(f), StringHash("DSD_trsp"))
                  
                    call ShowUnit(f,false)
                  
                else
                if r == 183 then
                call AddEffectTimeToPoint("Abilities\\Spells\\Demon\\DarkConversion\\ZombifyTarget.mdl",GetUnitX(f),GetUnitY(f),6.)
                endif
                    call SaveReal(Hash, GetHandleId(f), StringHash("DSD_trsp"), r)
                endif
            //else
               // call SetUnitVertexColor(f, 255, 255, 255, 255)
               // call SaveReal(Hash, GetHandleId(f), StringHash("DSD_trsp"), 255)
            //endif


            call GroupRemoveUnit(P, f)
        endloop
      //  call DestroyGroup(g)

    set timesec = timesec+0.1
    //=========================//=========================//=========================
//========================= EVERY SECONS BY TIMESEC ==================================
//=========================//=========================//=========================
    if timesec == 1. then // EVERY SEC КАЖДУЮ СЕКУНДУ
    RaidInt++
    set timesec=0.
    set timemin = timemin + 1
  
    I2 = 1
  
    set b2 = Condition(function RaidAttackFilter)
    //call echo("does work")
loop // third time
exitwhen I2 > RaidCurrentMax //repeate raid command 3 time
if RaidCommandIsActive[I2] == true and RaidActive[I2] == true then
//set RaidCommandIsActive[I2] = false
//call echo(I2S(I2))
//call echo("work?")
set F = FirstOfGroup(RaidGroup[I2])
//call echo("raid commant tye == " + I2S(RaidCommandType[I2]))
if RaidCommandType[I2] == 1 then
//call echo("command type 1")

call GroupClear(P)
call GroupEnumUnitsInRange(P,GetUnitX(F),GetUnitY(F),700,b2)
//set F2 = FirstOfGroup(P)
call GroupClear(P2)
set bj_groupAddGroupDest = P2
call ForGroup(RaidGroup[I2],function GroupAddGroupEnumJ)
if DistanceXY(GetUnitX(F),GetUnitY(F),RaidXPoint[I2],RaidYPoint[I2]) <= 1200 and DistanceXY(GetUnitX(F),GetUnitY(F),RaidXPoint[I2],RaidYPoint[I2]) > 300 then

loop
set F2= FirstOfGroup(P2)
exitwhen F2 == null
if RaidInt == 2 then
call IssuePointOrder(F2,"attack",RaidXPoint[I2],RaidYPoint[I2])
endif
call GroupRemoveUnit(P2,F2)
endloop

elseif DistanceXY(GetUnitX(F),GetUnitY(F),RaidXPoint[I2],RaidYPoint[I2]) < 300 //-->
//call echo("REACHED ATTACK POINT")
set RaidCommandIsActive[I2] = false

loop //-->
set F2= FirstOfGroup(P2)
exitwhen F2 == null
call IssueImmediateOrder(F2,"stop")
call GroupRemoveUnit(P2,F2)
endloop //<--

else
//call echo("Anyway fuck u")
set RaidCommandIsActive[I2] = false
                                                                      endif //<--


elseif RaidCommandType[I2] == 2 then
//call echo("command type 2")
call GroupClear(P2)
set bj_groupAddGroupDest = P2
call ForGroup(RaidGroup[I2],function GroupAddGroupEnumJ)
if DistanceXY(GetUnitX(F),GetUnitY(F),RaidXPoint[I2],RaidYPoint[I2]) <= 300
//call echo("reached")
set RaidCommandIsActive[I2] = false
loop
set F2= FirstOfGroup(P2)
exitwhen F2 == null
call IssueImmediateOrder(F2,"stop")
call GroupRemoveUnit(P2,F2)
endloop
set RaidCommandIsActive[I2] = false
else //-->
//call echo("still go group " + I2S(I2))
loop //-->
set F2= FirstOfGroup(P2)
exitwhen F2 == null
if RaidInt == 2 then
//call echo("etteck")
call IssuePointOrder(F2,"attack",RaidXPoint[I2],RaidYPoint[I2])
endif
call GroupRemoveUnit(P2,F2)
endloop //<--

endif //<--

endif
endif
I2++
endloop
//call echo("end")
call DestroyBoolExpr(b2)
  if RaidInt == 3 then
    set RaidInt = 0
    //call echo("saddd")
    endif
                   call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(AttackingGroup,function GroupAddGroupEnumJ)
  //  set g= CopyGroup()
    loop
            set f = FirstOfGroup(P)
            exitwhen f == null
            set R = LoadReal(Hash,GetHandleId(f),StringHash("Attacking")) - 1.
            if  R <=0. then
            call UnitRemoveAbility(f,'Aasl')
            call RemoveSavedReal(Hash,GetHandleId(f),StringHash("Attacking"))
            call GroupRemoveUnit(AttackingGroup,f)
            else
            call SaveReal(Hash,GetHandleId(f),StringHash("Attacking"),R)
            endif
          
            call GroupRemoveUnit(P, f)
        endloop
       // call DestroyGroup(g)
  
    if timemin == 60 then
        set timemin = 0
        set i = 0
        loop
            exitwhen i == 10
            call AdjustPlayerStateJ( 1, Player(i), PLAYER_STATE_RESOURCE_FOOD_CAP)
            set i = i + 1
        endloop
    endif
  
    set i = 0
                       call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(RageOfTheDamned,function GroupAddGroupEnumJ)
    //set g = CopyGroup(RageOfTheDamned)
        loop
            set f = FirstOfGroup(P)
            exitwhen f == null

            if GetUnitAbilityLevel(f, 'Buhf') > 0 then
                call SetWidgetLife(f, GetWidgetLife(f) + 4)
            else
                call GroupRemoveUnit(RageOfTheDamned, f)
            endif

            call GroupRemoveUnit(P, f)
        endloop
       // call DestroyGroup(g)

        loop
            exitwhen i == 10 // there are all bots next
            if PlayerInGame[i] and CinematicEnd[i] then
                if i == 0 or i == 1 or i == 2 or i == 3 then
                    set cs = gg_cam_GameCam1
                else
                    set cs = gg_cam_GameCam1
                endif

                if GetLocalPlayer() == Player(i) then
                    call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, distance[i], 1.00 )
    //call (R2S(CameraSetupGetField(cs,CAMERA_FIELD_TARGET_DISTANCE)),0.5)
                    call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, CameraSetupGetField(cs, CAMERA_FIELD_ANGLE_OF_ATTACK), 1.00 )
                    call SetCameraField(CAMERA_FIELD_ROLL, CameraSetupGetField( cs, CAMERA_FIELD_ROLL), 1.00 )
                    call SetCameraField(CAMERA_FIELD_ROTATION, CameraSetupGetField(cs, CAMERA_FIELD_ROTATION), 1.00 )
                endif

            endif
            set i = i + 1
        endloop



        set i = 1
        loop
            exitwhen i > PatrolMax
            if not IsUnitDead(PatrolUnit[i]) then
                set r = LoadReal(Hash, GetHandleId(PatrolUnit[i]), StringHash("PTtime")) - 1.
                if r <= 0. then
                    call SaveReal(Hash, GetHandleId(PatrolUnit[i]), StringHash("PTtime"), LoadReal(Hash, GetHandleId(PatrolUnit[i]), StringHash("PTtimeSaved")))
                    set i2 = i * 2
                    if RectContainsCoordsJ(PatrolRect[i2 - 1], GetUnitX(PatrolUnit[i]), GetUnitY(PatrolUnit[i])) then
                        call IssuePointOrder(PatrolUnit[i], "attack", GetRectCenterX(PatrolRect[i2]), GetRectCenterY(PatrolRect[i2]))
                    elseif RectContainsCoordsJ(PatrolRect[i2], GetUnitX(PatrolUnit[i]), GetUnitY(PatrolUnit[i])) then
                        call IssuePointOrder(PatrolUnit[i], "attack", GetRectCenterX(PatrolRect[i2 - 1]), GetRectCenterY(PatrolRect[i2 - 1]))
                    else
                        call IssuePointOrder(PatrolUnit[i], "attack", GetRectCenterX(PatrolRect[i2 - 1]), GetRectCenterY(PatrolRect[i2 - 1]))
                    endif
                else
                    call SaveReal(Hash, GetHandleId(PatrolUnit[i]), StringHash("PTtime"), r)
                endif
            endif
            set i = i + 1
        endloop
  
     // DEFENDOFF
                            call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(DefendOff,function GroupAddGroupEnumJ)
   // set g = CopyGroup()
        loop
            set f = FirstOfGroup(P)
            exitwhen f == null

            set r = LoadReal(Hash, GetHandleId(f), StringHash("Defend_R")) - 1.
            if r <= 0. then
                //call echo("end")
                call IssueImmediateOrder(f,"undefend")
                call RemoveSavedReal(Hash, GetHandleId(f), StringHash("Defend_R"))
                call GroupRemoveUnit(DefendOff, f)


            else
                call SaveReal(Hash, GetHandleId(f), StringHash("Defend_R"), r)
            endif

            call GroupRemoveUnit(P, f)
        endloop
        //call DestroyGroup(g)
  
    // GREAT SOURCES AURA
set B = Condition(function GreatSourcesDealAuraEnemyFilter)
call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(GreatSourcesDealAura,function GroupAddGroupEnumJ)
loop
set F = FirstOfGroup(P)
exitwhen F == null
            if F!= null and not IsUnitDead(F) then
call GroupClear(P2)
call GroupEnumUnitsInRange(P2,GetUnitX(F),GetUnitY(F),1800,B)
            loop
            set F2 = FirstOfGroup(P2)
            exitwhen F2 == null
            if not IsUnitInGroup(F2,Corruption) and not IsUnitDead(F2) then
            call UnitAddAbility(F2,'A00I')
            call GroupAddUnit(Corruption,F2)
            call UnitDamageTarget(F,F2,30.,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayTarget.mdl",F2,"chest"))
            call SaveUnitHandle(Hash,GetHandleId(F2),StringHash("Corruption_origin"),F)
            endif
            call GroupRemoveUnit(P2, F2)
            endloop
            endif
call GroupRemoveUnit(P, F)
endloop
call DestroyBoolExpr(B)  
  
    call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(Corruption,function GroupAddGroupEnumJ)
loop
set F = FirstOfGroup(P)
exitwhen F == null
set F2 = LoadUnitHandle(Hash,GetHandleId(F),StringHash("Corruption_origin"))
if F != null then
if DistanceXY(GetUnitX(F),GetUnitY(F),GetUnitX(F2),GetUnitY(F2)) <= 1800 and not IsUnitDead(F) then
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayDamage.mdl",F,"head"))
call UnitDamageTarget(F2,F,15.,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
else
//call echo("OUT")
call UnitRemoveAbility(F,'A00I')
call UnitRemoveAbility(F,'BUdd')
call GroupRemoveUnit(Corruption,F)
call RemoveSavedHandle(Hash,GetHandleId(F),StringHash("Corruption_origin"))
endif
endif
call GroupRemoveUnit(P, F)
endloop
  
    call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(ReplicsGroupIsOnPoint,function GroupAddGroupEnumJ)
        loop
            set f = FirstOfGroup(P)
            exitwhen f == null
            set ID = GetHandleId(f)
            set X =LoadReal(Hash,ID,StringHash("RG_OnPoint_X"))
            set Y = LoadReal(Hash,ID,StringHash("RG_OnPoint_Y"))
        if DistanceXY(X,Y,GetUnitX(f),GetUnitY(f)) < 300 then
        call IssueImmediateOrder(f,"stop")
        call RemoveSavedReal(Hash,ID,StringHash("RG_OnPoint_X"))
        call RemoveSavedReal(Hash,ID,StringHash("RG_OnPoint_Y"))
        call GroupRemoveUnit(ReplicsGroupIsOnPoint,f)
        elseif GetUnitCurrentOrder(f) != String2OrderId("move")  then //not IssuePointOrder(f, "move", X,Y)
        call IssuePointOrder(f, "move", X, Y)
        endif
      
            call GroupRemoveUnit(P, f)
        endloop
  
        set time = 0.

        set i = 0

      
      
         /* set r = LoadReal(Hash, idT, 0)
        call SaveReal(Hash, idT, 0, r + 1.) */

set TimeToFixAttack = TimeToFixAttack + 1.
        set i = 1
        if UDUNITS > 0 then
            loop
                exitwhen i > UGM
if UndeadGroupIsOn[i] == true then
                if IsUnitFocused[i] == false and UndeadGroupEliminated[i] != true then
                I++

                set F = GroupPickRandomUnitEx(Undead[i]) //grouppickrandomunit
                set FocusedUnit[i] = GetClosestUnitInGroup(GetUnitX(F), GetUnitY(F), CilivianzGroup)
              

if not IsUnitInGroup(FocusedUnit[i],FocusedUnitVision) then
call GroupAddUnit(FocusedUnitVision,FocusedUnit[i])
set HuntTargetUnitDummy[i] = CreateUnit(Player(6),'e001',GetUnitX(FocusedUnit[i]),GetUnitY(FocusedUnit[i]),0)

set S = ""
if IsPlayerInForce(GetLocalPlayer(),UndeadForce) then
set S = "Abilities\\Spells\\NightElf\\shadowstrike\\shadowstrike.mdl" //"HuntersMarkTarget.mdx"
endif

set HuntTargetEffect[i] = AddSpecialEffectTarget(S,FocusedUnit[i],"overhead")
call SaveInteger(Hash,GetHandleId(FocusedUnit[i]),StringHash("FocusedUnit[i]_i"),i)
endif
set UndeadFocusX[i] = GetUnitX(FocusedUnit[i])
set UndeadFocusY[i] = GetUnitY(FocusedUnit[i])
                call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(Undead[i],function GroupAddGroupEnumJ)
                loop
                    set F = FirstOfGroup(P)
                    exitwhen F == null
                
                    call IssuePointOrder(F, "attack", UndeadFocusX[i], UndeadFocusY[i])
                   // endif
                    call GroupRemoveUnit(P, F)
//set i = i + 1
                endloop
//call GroupClear(g)
                //call DestroyGroup(g)
//call GroupClear(P)
                set IsUnitFocused[i] = true
//call DestroyGroup(P)

            elseif IsUnitFocused[i] == true and FocusedUnit[i] != null and UndeadGroupEliminated[i] != true then
I++
set bl = false
//set FirstUnitDS = false
call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(Undead[i],function GroupAddGroupEnumJ)
               // set g = CopyGroup(Undead[i])
                loop
                    set F = FirstOfGroup(P)
                    exitwhen F == null
                    if FocusedUnit[i] != null and DistanceXY(GetUnitX(F),GetUnitY(F), UndeadFocusX[i], UndeadFocusY[i]) < 250  then // 851983 then//String2OrderId("attack") then
                        //call IssueImmediateOrder(F,"stop")
                        set UndeadFocusX[i] = GetUnitX(FocusedUnit[i])
                        set UndeadFocusY[i] = GetUnitY(FocusedUnit[i])
                        set bl = true
                      
                    elseif TimeToFixAttack == 5. and FocusedUnit[i] != null then
                    call IssuePointOrder(F, "attack", UndeadFocusX[i] , UndeadFocusY[i])
                     //call echo("GO bitch")
                        //elseif vse ravno attack stoit pidor
                        //call attack
                        //call IssuePointOrder(F, "attack", UndeadFocusX[i], UndeadFocusY[i]))
                        //call SaveBoolean(Hash,GetHandleId(F),StringHash("Undead_reached"),true)
                        //call IssuePointOrder(F, "attack", GetUnitX(FocusedUnit[i]), GetUnitY(FocusedUnit[i]))
//call echo("??? ????????")
                    endif
                    call GroupRemoveUnit(P, F)
//set i = i + 1
                endloop
              
                if bl == true then
                call GroupClear(P)
set bj_groupAddGroupDest = P
call ForGroup(Undead[i],function GroupAddGroupEnumJ)
                       loop
                    set F = FirstOfGroup(P)
                    exitwhen F == null
                    if FocusedUnit[i] != null then // 851983 then//String2OrderId("attack") then
                        call IssueImmediateOrder(F,"stop")
                        call IssuePointOrder(F, "attack", UndeadFocusX[i] , UndeadFocusY[i])
                        //call SaveBoolean(Hash,GetHandleId(F),StringHash("Undead_reached"),true)
                        //call IssuePointOrder(F, "attack", GetUnitX(FocusedUnit[i]), GetUnitY(FocusedUnit[i]))
//call echo("??? ????????")
                    endif
                    call GroupRemoveUnit(P, F)
//set i = i + 1
                endloop
                endif
              //  call DestroyGroup(g)
//call GroupClear(P)

          
           // elseif FocusedUnit[i] == null
           // call echo("хуево")
            endif
            endif
            set i = i + 1

        endloop


endif

if TimeToFixAttack >= 5. then
set TimeToFixAttack = 0.
endif  


    //=========================//=========================//=========================
//========================= EVERY SECONS BY TIMESEC -- END ACTIONS ==================================
//=========================//=========================//=========================

endif




endif // game over
//====
set t = null
set g = null
set f = null
set d = null
set cs = null
set b2 = null
//set randomg = null
//set randomu =null
endfunction





function HS_A takes nothing returns nothing
endfunction


//===========================================================================
function HS takes nothing returns nothing
//it's important thing
local integer i
local boolexpr b = Condition(function Cilivians_Expr)
//call echo("0.1")



set distance[0] = 2100 //2300
set distance[1] = 2100
set distance[2] = 2100
set distance[3] = 2100
set distance[6] = 2100
set distance[7] = 2100
set distance[8] = 2100
set distance[9] = 2100

// ======
set i = 1
loop
    exitwhen i > UGMmax
    set IsUnitFocused[i] = false
    set UndeadGroupShouldBeEliminated[i] = false
    set UndeadGroupEliminated[i] = false
    set UndeadGroupIsOn[i] = false
    set i = i + 1
endloop
set Undead[1] = CreateGroup() // ?? ????? ????????? ??? ???????????? = )
set UDUNITS = 0
 /* set LIVINGRECTS[1] = gg_rct_WestLowRegion
set LIVINGRECTS[2] = gg_rct_MiddleLowRegion
set LIVINGRECTS[3] = gg_rct_UpperRightPart
set LIVINGRECTS[4] = gg_rct_UpperRightPart2
set LIVINGRECTS[5] = gg_rct_MiddleRightPart
set LIVINGRECTS[6] = gg_rct_LowerRightPart2
set LIVINGRECTS[7] = gg_rct_MiddleRightPart2
set LIVINGRECTS[8] = gg_rct_MiddleUpperRight */

set ISRECTALIVE[1] = true
set ISRECTALIVE[2] = true
set ISRECTALIVE[3] = true
set ISRECTALIVE[4] = true
set ISRECTALIVE[5] = true
set ISRECTALIVE[6] = true
set ISRECTALIVE[7] = true
set ISRECTALIVE[8] = true
set QuestCompleted[1] = false
set QuestCompleted[2] = false

set QuestCompleted[3] = false

set QuestCompleted[4] = false

set QuestCompleted[5] = false

 /* set Cilivians[1] = CreateGroup()
set Cilivians[2] = CreateGroup()
set Cilivians[3] = CreateGroup()
set Cilivians[4] = CreateGroup()

call GroupEnumUnitsInRect(Cilivians[1], LIVINGRECTS[1], b)//UnitsInRectOfPlayer(gg_rct_WestLowRegion, Player(5))
call GroupEnumUnitsInRect(Cilivians[2], LIVINGRECTS[2], b)
call GroupEnumUnitsInRect(Cilivians[3], LIVINGRECTS[3], b)
call GroupEnumUnitsInRect(Cilivians[4], LIVINGRECTS[4], b) */
 /* здесь нет проверки на охрану, т.е они не будет являться приоритетом фокуса. Время покажет */

 /* set P = CopyGroup(Cilivians[1])
loop
    set F = FirstOfGroup(P)
    exitwhen F == null
    set CGM = CGM + 1
    call GroupRemoveUnit(P, F)
endloop
call GroupClear(P)
set P = CopyGroup(Cilivians[2])
loop
    set F = FirstOfGroup(P)
    exitwhen F == null
    set CGM = CGM + 1
    call GroupRemoveUnit(P, F)
endloop
call GroupClear(P)
set P = CopyGroup(Cilivians[3])
loop
    set F = FirstOfGroup(P)
    exitwhen F == null
    set CGM = CGM + 1
    call GroupRemoveUnit(P, F)
endloop
call GroupClear(P)
set P = CopyGroup(Cilivians[4])
loop
    set F = FirstOfGroup(P)
    exitwhen F == null
    set CGM = CGM + 1
    call GroupRemoveUnit(P, F)
endloop
 */
 /* call GroupAddUnit(Undead[UGM], gg_unit_nzom_0029)
call GroupAddUnit(Undead[UGM], gg_unit_nzom_0028) */
if TEST == true then
call GroupAddUnit(Undead[UGM], gg_unit_Udea_0589)

//call GroupAddUnit(Undead[UGM], gg_unit_Nmag_0725)

//call GroupAddUnit(Undead[UGM], gg_unit_Ulic_0724)

//call GroupAddUnit(Undead[UGM], gg_unit_Ucrl_0723)
set UDUNITS = 1 // because we added 3 zombies to group right now
else
//call GroupAddUnit(Undead[UGM], gg_unit_Udea_0589)
//set UDUNITS = 1
endif

call GroupAddUnit(Paladins, gg_unit_Hpal_0503)
set HERO[0] = gg_unit_Hpal_0503
call GroupAddUnit(Paladins, gg_unit_H001_0245)
set HERO[1] = gg_unit_H001_0245
call GroupAddUnit(Paladins, gg_unit_H002_0715)
set HERO[2] = gg_unit_H002_0715
call GroupAddUnit(Paladins, gg_unit_H003_0717)
set HERO[3] = gg_unit_H003_0717
//call GroupAddUnit(DreadLords, gg_unit_Udre_0043)
set HERO[6] = gg_unit_Udre_0043
//call GroupAddUnit(DreadLords, gg_unit_U000_0551)
set HERO[7] = gg_unit_U000_0551
//call GroupAddUnit(DreadLords, gg_unit_U001_0718)
set HERO[8] = gg_unit_U001_0718
//call GroupAddUnit(DreadLords, gg_unit_U002_0716)
set HERO[9] = gg_unit_U002_0716
if TEST == true then
call GroupAddUnit(DreadLords, gg_unit_Udre_0043)
call ForceAddPlayer(UndeadForce,Player(7))
//call GroupAddUnit(DreadLords, gg_unit_U000_0551)
//call GroupAddUnit(DreadLords, gg_unit_U001_0718)
//call GroupAddUnit(DreadLords, gg_unit_U002_0716)
endif

set i = 0
loop

    call SetPlayerAbilityAvailable( Player(i), 'A003', false )
    set i = i + 1
    exitwhen i == bj_MAX_PLAYER_SLOTS
endloop

call TimerStart(CreateTimer(), 0.1, true, function EveryTenthCSecondInGame)
//=====
call DestroyBoolExpr(b)
set b = null
endfunction

endscope


//Code indented using The_Witcher's Script language Aligner
//Download the newest version and report bugs at www.hiveworkshop.com
 
Status
Not open for further replies.
Top