Creep Revival System (System that supports more than 60secs)

Kingdom

New Member
Reaction score
0
Sup guys, i really need some help with this. I am just going crazy.

First off i know crap about JASS, but i've found this particular system some time ago. I already gave up one map development because i couldn't get the system to handle more than 60 secs revival time.

So, here's the deal. I got this system and changed the wait time for more than 60 secs and it just doesn't works. My guess is that it just doesn't support more than that, OK, np, i then tried to adjust the system to handle more than 60secs using a Countdown Timer. The code is below:

Code:
Creep Revival System Initialization
    Events
        Map Initialization
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
            Loop - Actions
                Set Integer = (Integer + 1)
                Unit - Set the custom value of (Picked unit) to Integer
                Custom script:   set udg_Creep_X[udg_Integer] = GetUnitX(GetEnumUnit())
                Custom script:   set udg_Creep_Y[udg_Integer] = GetUnitY(GetEnumUnit())
                Set Unit[Integer] = (Picked unit)


Code:
Timer RUN
    Events
        Time - RS_Revive_Timer expires
    Conditions
    Actions
        Countdown Timer - Start RS_Revive_Timer as a One-shot timer that will expire in 40.00 seconds
        Countdown Timer - Create a timer window for (Last started timer) with title TIMER
        Trigger - Run Revive <gen> (checking conditions)


Code:
Revive
    Events
    Conditions
    Actions
        For each (Integer A) from 0 to Integer, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Unit[(Integer A)] is dead) Equal to True
                    Then - Actions
                        Set tempPoint[1] = (Center of (Entire map))
                        Set tempPoint[2] = (tempPoint[1] offset by (Creep_X[(Custom value of Unit[(Integer A)])], Creep_Y[(Custom value of Unit[(Integer A)])]))
                        Unit - Create 1 (Unit-type of Unit[(Integer A)]) for Neutral Hostile at ((Center of (Entire map)) offset by (Creep_X[(Custom value of Unit[(Integer A)])], Creep_Y[(Custom value of Unit[(Integer A)])])) facing Default building facing degrees
                        Unit - Set the custom value of (Last created unit) to (Custom value of Unit[(Integer A)])
                        Set Unit[(Integer A)] = (Last created unit)
                        Custom script:   call RemoveLocation(udg_tempPoint[1])
                        Custom script:   call RemoveLocation(udg_tempPoint[2])
                    Else - Actions
                        Do nothing


OK, now the explaining. As you can see, i made it so that the code depends on the countdown timer, this way i can set whatever time i want.
The code is partially working, it revives correctly if u kill about 15-, but if you go crazy and kill 30+, it starts bugging everything. Some creeps won't revive, others are revived when they shouldn't...

So, if ne1 is experencied enough help me plz. I'll send a PM with the map's download link if you want to.

Thanks in advance.
 

gref

New Member
Reaction score
33
Urgh. Well I guess it's a system that should work.

Sure pm me and I'll wade through it :)
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
http://www.thehelper.net/forums/showthread.php?t=57742 should do it. The reason why your system(s) doesn't work after 60 seconds is that a unit is completely removed from the game 60 seconds after it dies so there is no way to know what unit type it was. You can change the decay time in the Advanced settings but that's not a very good solution. It's better to save the unit type of each unit in it's own array or save it in a local variable at death time, the first option is way easier for a gui user.
 

Kingdom

New Member
Reaction score
0
Gref did some cleaning and now it's working better but not fully. Some Pandarem weren't reviving, now they are. But the undead ones still aren't reviving.

Phyre, i did try to use Ace's ones, but they won't work. I tried method 5 and 6 (the ones that suits the map). Method 6 would just revive Trolls for some reason, even if u killed Pandarem or other mobs, and Method 5 would revive them on the wrong spot.
I am using cheat codes to kill the mobs, so i can simulate a lot of them being killed at the same time.

Here's the code now partially working but noy reviving some undead creeps:

Code:
Creep Revival System Initialization
    Events
        Map initialization
    Conditions
    Actions
        Countdown Timer - Start RS_Revive_Timer as a One-shot timer that will expire in 120.00 seconds
        Countdown Timer - Create a timer window for (Last started timer) with title TIMER
        Set Integer = 0
        Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
            Loop - Actions
                Set Integer = (Integer + 1)
                Unit - Set the custom value of (Picked unit) to Integer
                Custom script:   set udg_Creep_X[udg_Integer] = GetUnitX(GetEnumUnit())
                Custom script:   set udg_Creep_Y[udg_Integer] = GetUnitY(GetEnumUnit())
                Set Unit[Integer] = (Picked unit)

Code:
Revive
    Events
        Time - RS_Revive_Timer expires
    Conditions
    Actions
        For each (Integer A) from 1 to Integer, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Unit[(Integer A)] is dead) Equal to True
                    Then - Actions
                        Set tempPoint[1] = (Point(Creep_X[(Integer A)], Creep_Y[(Integer A)]))
                        Unit - Create 1 (Unit-type of Unit[(Integer A)]) for Neutral Hostile at tempPoint[1] facing Default building facing degrees
                        Unit - Set the custom value of (Last created unit) to (Integer A)
                        Set Unit[(Integer A)] = (Last created unit)
                        Custom script:   call RemoveLocation(udg_tempPoint[1])
                    Else - Actions
                        Do nothing

Any other ideas?

Map download: http://gamerslust.com/KK.w3x

BTW, thanks a lot for the help, :).

Thanks in advance.

EDIT: Is there a limit to the array size?

EDIT2: I did some reading on the code of the Method 6 from Ace's revival map, well, for what i can see it doesn't revives the mobs u killed, but revives the same lv creeps from that titleset, and in my case, there's only trolls. So the 6 won't work as supposed or that's the way Ace programmed.

EDIT3: I think i have a solution but i can't produce myself, for i don't know how to program on Jass. Check the code from Ace:

Code:
function Trig_Respawn5_Func_Test takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), Player(PLAYER_NEUTRAL_AGGRESSIVE)) )
endfunction

function Trig_Respawn5_Actions takes nothing returns nothing
    local location tmpPoint = GetUnitLoc(GetDyingUnit())
    local integer tmpUnit = GetUnitTypeId(GetDyingUnit())
    loop
        call PolledWait( GetRandomReal(25.00, 55.00) )
        exitwhen ( IsUnitGroupEmptyBJ(GetUnitsInRangeOfLocMatching(1536.00, tmpPoint, Condition(function Trig_Respawn5_Func_Test))) )
    endloop
    call CreateNUnitsAtLoc( 1, tmpUnit, Player(PLAYER_NEUTRAL_AGGRESSIVE), tmpPoint, bj_UNIT_FACING )
endfunction

//===========================================================================
function InitTrig_Respawn5 takes nothing returns nothing
    set gg_trg_Respawn5 = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Respawn5, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Respawn5, function Trig_Respawn5_Actions )
endfunction

As you can see, the code grabs the unit location using Point, what if it were to use:

Code:
Custom script:   set udg_Creep_X[udg_Integer] = GetUnitX(GetEnumUnit())
Custom script:   set udg_Creep_Y[udg_Integer] = GetUnitY(GetEnumUnit())

I remember using Point on my other map to revive, but had the same problem, the creeps would respawn on the wrong location. Can some1 please make the change on the code so that it uses the Creep_X and Creep_Y instead of GetUnitLoc(GetDyingUnit()), as on my original code on the top of the topic?

Thanks!
 

gref

New Member
Reaction score
33
Alright...If you want Jass, this is the system I use in my map.

If you don't have a vJass preprocessor download WEHelper, WEU, or Jass Newgen.

Create regions around the units you want to respawn.
Set the number after max_creep_groups to the number of regions.
Where it sets the creep_regions at the bottom, replace the current regions with the names of the regions on your map, replacing spaces with underscores and starting each with gg_rct_

Level means the sum of all the levels off your creeps, divided by 5. (It's an estimate for the difficulty of the encounter. Where it says Create_Creep(i, BLAH) lots, replace those with creeps of whatever level section its in, and when units of the same level die, it will replace them with units of a similar level. Use the id codes of units here. to find them press Ctrl + D in the unit editor and it will show you them. The numbers in the comments there are just how many times I placed each creep set in my map at initilization, and doesn't really have a bearing on you.

What it basically does, is work out the level of all creeps in each region when the map starts and stores it. Then when all the units in the group either die or are charmed, it waits X seconds and however long it takes for the region to not be visible to any players, then repawns a random set of creeps of the same level. It repeats as needed.

Place it in an empty custom script trigger called Creeps.
Ask whatever questions you need. I'm kind of tired though so I don't feel like rewriting you a system from scratch.


JASS:
scope CreepRespawning

    globals
        private rect array creep_regions
        private group array creep_groups
        private integer array creep_level
    
        private constant integer max_creep_groups = 27
    endglobals

    private function Create_Creep takes integer i, integer ctype returns nothing
        local unit u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), ctype, GetRectCenterX(creep_regions<i>), GetRectCenterY(creep_regions<i>), GetRandomReal(0, 360.0))
        call GroupAddUnit(creep_groups<i>, u)
        set u = null
    endfunction

    private function Make_Creep_Group takes integer i returns nothing
        local real random = GetRandomReal(0, 100)

        if(creep_level<i> == 1) then
            if (random &lt; 33) then     //2 Ashenvale Murlocs                   
                call Create_Creep(i, &#039;nmrl&#039;) 
                call Create_Creep(i, &#039;nmrr&#039;)
                call Create_Creep(i, &#039;nmrr&#039;)
                call Create_Creep(i, &#039;nmmm&#039;)
            elseif (random &lt; 67) then //2 Sludge               
                call Create_Creep(i, &#039;nsln&#039;)                
                call Create_Creep(i, &#039;nslf&#039;)                
                call Create_Creep(i, &#039;nslm&#039;)         
            else                      //2 Corrupted Treants                         
                call Create_Creep(i, &#039;nenp&#039;)                
                call Create_Creep(i, &#039;nenc&#039;)                
                call Create_Creep(i, &#039;nepl&#039;)        
            endif    
        elseif (creep_level<i> == 2) then 
            if (random &lt; 33) then     //2 Felwood Murlocs         
                call Create_Creep(i, &#039;nmpg&#039;)                
                call Create_Creep(i, &#039;nmfs&#039;)                
                call Create_Creep(i, &#039;nmmu&#039;)                
                call Create_Creep(i, &#039;nmrl&#039;)           
            elseif (random &lt; 67) then //2 Dark Trolls   
                call Create_Creep(i, &#039;ndth&#039;)    
                call Create_Creep(i, &#039;ndtb&#039;)    
                call Create_Creep(i, &#039;ndtt&#039;)        
            else                      //2 Skeletal Orcs + Stormreavers
                call Create_Creep(i, &#039;nsog&#039;)    
                call Create_Creep(i, &#039;nsko&#039;)    
                call Create_Creep(i, &#039;nsra&#039;)    
                call Create_Creep(i, &#039;nsrh&#039;)        
            endif 
    
        elseif (creep_level<i> == 3) then   
            if (random &lt; 25) then     //1 Fel Beasts             
                call Create_Creep(i, &#039;npfl&#039;)                
                call Create_Creep(i, &#039;nfel&#039;)                
                call Create_Creep(i, &#039;npfm&#039;)        
            elseif (random &lt; 50) then //2 Stormreavers     
                call Create_Creep(i, &#039;nsra&#039;)    
                call Create_Creep(i, &#039;nsrh&#039;)    
                call Create_Creep(i, &#039;nsrn&#039;)    
                call Create_Creep(i, &#039;nsrw&#039;)        
            elseif (random &lt; 75) then //2 Satyrs    
                call Create_Creep(i, &#039;nsty&#039;)    
                call Create_Creep(i, &#039;nsat&#039;)    
                call Create_Creep(i, &#039;nstl&#039;)    
                call Create_Creep(i, &#039;nsts&#039;)    
                call Create_Creep(i, &#039;nsth&#039;)           
            else                     //2 Ogres
                call Create_Creep(i, &#039;nogl&#039;)  
                call Create_Creep(i, &#039;nogm&#039;)  
                call Create_Creep(i, &#039;nomg&#039;)
        
            endif 
    
        elseif (creep_level<i> == 4) then  
            if (random &lt; 25) then     //1 Spiders
                call Create_Creep(i, &#039;nspr&#039;)
                call Create_Creep(i, &#039;nssp&#039;) 
                call Create_Creep(i, &#039;nssp&#039;)
                call Create_Creep(i, &#039;nsgt&#039;)
                call Create_Creep(i, &#039;nsgt&#039;)
                call Create_Creep(i, &#039;nsbm&#039;)
            elseif (random &lt; 50) then //1 Thunder Lizards 
                call Create_Creep(i, &#039;nltl&#039;)
                call Create_Creep(i, &#039;nthl&#039;) 
                call Create_Creep(i, &#039;nthl&#039;)
                call Create_Creep(i, &#039;nstw&#039;) 
            elseif (random &lt; 75) then //1 Dark Trolls   
                call Create_Creep(i, &#039;ndtr&#039;)
                call Create_Creep(i, &#039;ndtp&#039;)
                call Create_Creep(i, &#039;ndtt&#039;)
                call Create_Creep(i, &#039;ndtb&#039;)
                call Create_Creep(i, &#039;ndth&#039;)  
                call Create_Creep(i, &#039;ndtw&#039;)        
            else                      //2 Wolves   
                call Create_Creep(i, &#039;nwld&#039;)
                call Create_Creep(i, &#039;nwld&#039;)
                call Create_Creep(i, &#039;nwlg&#039;)
                call Create_Creep(i, &#039;nwlt&#039;)  
                call Create_Creep(i, &#039;nwlt&#039;)
        
            endif 
    
        elseif (creep_level<i> == 5) then  
            if (random &lt; 25) then    //1 Murguls
                call Create_Creep(i, &#039;nmcf&#039;)    
                call Create_Creep(i, &#039;nmbg&#039;)    
                call Create_Creep(i, &#039;nmtw&#039;)      
                call Create_Creep(i, &#039;nmtw&#039;)  
                call Create_Creep(i, &#039;nmsn&#039;)    
                call Create_Creep(i, &#039;nmrv&#039;)    
                call Create_Creep(i, &#039;nmsc&#039;)          
            elseif (random &lt; 50) then //1 Wendigos   
                call Create_Creep(i, &#039;nwen&#039;)  
                call Create_Creep(i, &#039;nwnr&#039;)  
                call Create_Creep(i, &#039;nwns&#039;)  
                call Create_Creep(i, &#039;nwna&#039;)        
            elseif (random &lt; 75) then //1 Salamanders       
                call Create_Creep(i, &#039;nslh&#039;)     
                call Create_Creep(i, &#039;nslh&#039;)  
                call Create_Creep(i, &#039;nslr&#039;)  
                call Create_Creep(i, &#039;nslv&#039;)  
                call Create_Creep(i, &#039;nsll&#039;) 
                  
            else                      //1 Tentacles + Dragons
                call Create_Creep(i, &#039;nfgo&#039;) 
                call Create_Creep(i, &#039;nadw&#039;)   
                call Create_Creep(i, &#039;nadr&#039;)         
            endif 
    
        endif    
    endfunction

    private function Check_Then_Make_Group takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local integer r = GetAttachedInt(t, &quot;repop_group&quot;)
        local integer i = 3
        local boolean visible = false
    
        loop
            exitwhen i == 12
        
            if(IsVisibleToPlayer(GetRectCenterX(creep_regions[r]), GetRectCenterY(creep_regions[r]), Player(i))==true) then
                set visible = true
                endif
            
            set i = i + 1
        endloop
    
        if (visible == false) then
            call Make_Creep_Group(r)
            call CleanAttachedVars(t)
            call DestroyTimer(t)
        else    
            call TimerStart(t, 0.5, false, function Check_Then_Make_Group)        
        endif
        
        set t = null    
    endfunction

    private function Repopulate_Group takes nothing returns nothing
        local timer t = GetExpiredTimer()

        call TimerStart(t, 0.5, false, function Check_Then_Make_Group)

        set t = null
    endfunction

//Creeps no longer in group...
    private function Creep_Changes_Owner_Actions takes nothing returns nothing
        local integer i = 0
        local timer t
    
        loop
            exitwhen i == max_creep_groups
        
            if(IsUnitInGroup(GetChangingUnit(), creep_groups<i>)==true) then
                call GroupRemoveUnit(creep_groups<i>, GetChangingUnit())
                if (FirstOfGroup(creep_groups<i>)==null) then
                    set t = CreateTimer()
                    call AttachInt(t, &quot;repop_group&quot;, i)
                    call TimerStart(t, 10.0, false, function Repopulate_Group)
                endif
            endif
        
            set i = i+1
        endloop
        set t = null
    endfunction

    private function Creep_Dies_Actions takes nothing returns nothing
        local integer i = 0
        local timer t
    
        loop
            exitwhen i == max_creep_groups
        
            if(IsUnitInGroup(GetTriggerUnit(), creep_groups<i>)==true) then
                call GroupRemoveUnit(creep_groups<i>, GetTriggerUnit())
                if (FirstOfGroup(creep_groups<i>)==null) then
                    set t = CreateTimer()
                    call AttachInt(t, &quot;repop_group&quot;, i)
                    call TimerStart(t, 10.0, false, function Repopulate_Group)
                endif
            endif
        
            set i = i+1
        endloop
        set t = null
    endfunction

    private function Get_Creep_Group_Level takes group g returns integer
        local integer count = 0
        local unit u
    
        loop
            set u = FirstOfGroup(g)
            exitwhen u == null
        
            set count = count + GetUnitLevel(u)
        
            call GroupRemoveUnit(g, u)
        endloop
    
        set g = null
        set u = null
        return count/5
    endfunction

    private function Add_Creeps_To_Groups takes nothing returns nothing 
        local integer i = 0
        local group g = CreateGroup() 
    
        loop
            exitwhen i == max_creep_groups
        
            set creep_groups<i> = CreateGroup()
        
            call GroupEnumUnitsInRect(creep_groups<i>, creep_regions<i>, null)
            call GroupEnumUnitsInRect(g, creep_regions<i>, null)
            set creep_level<i> = Get_Creep_Group_Level(g)
        
            set i = i + 1
        endloop     

        call DestroyGroup(g)
        set g = null
    endfunction

    function InitTrig_Creeps takes nothing returns nothing  
        local trigger Creep_Dies = CreateTrigger(  )    
        local trigger Creep_Changes_Owner = CreateTrigger(  )
    
    //Triggers
    
        call TriggerRegisterAnyUnitEventBJ( Creep_Dies, EVENT_PLAYER_UNIT_DEATH ) 
        call TriggerRegisterAnyUnitEventBJ( Creep_Changes_Owner, EVENT_PLAYER_UNIT_CHANGE_OWNER )
    
        call TriggerAddAction( Creep_Dies, function Creep_Dies_Actions ) 
        call TriggerAddAction( Creep_Changes_Owner, function Creep_Changes_Owner_Actions )

    //Initialize Regions

        set creep_regions[0] = gg_rct_Region_008
        set creep_regions[1] = gg_rct_Region_009
        set creep_regions[2] = gg_rct_Region_010
        set creep_regions[3] = gg_rct_Region_011
        set creep_regions[4] = gg_rct_Region_012
        set creep_regions[5] = gg_rct_Region_013
        set creep_regions[6] = gg_rct_Region_014
        set creep_regions[7] = gg_rct_Region_015
        set creep_regions[8] = gg_rct_Region_016
        set creep_regions[9] = gg_rct_Region_017
        set creep_regions[10] = gg_rct_Region_018
        set creep_regions[11] = gg_rct_Region_019
        set creep_regions[12] = gg_rct_Region_021
        set creep_regions[13] = gg_rct_Region_022
        set creep_regions[14] = gg_rct_Region_023
        set creep_regions[15] = gg_rct_Region_024
        set creep_regions[16] = gg_rct_Region_025
        set creep_regions[17] = gg_rct_Region_026
        set creep_regions[18] = gg_rct_Region_027
        set creep_regions[19] = gg_rct_Region_028
        set creep_regions[20] = gg_rct_Region_029
        set creep_regions[21] = gg_rct_Region_030
        set creep_regions[22] = gg_rct_Region_031
        set creep_regions[23] = gg_rct_Region_032
        set creep_regions[24] = gg_rct_Region_033
        set creep_regions[25] = gg_rct_Region_034
        set creep_regions[26] = gg_rct_Region_035
    
        call Add_Creeps_To_Groups()
    
        set Creep_Changes_Owner = null
        set Creep_Dies = null
    endfunction
endscope
</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Code:
Creep Revival System Initialization
    Events
        Map Initialization
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
            Loop - Actions
                Set Integer = (Integer + 1)
                Unit - Set the custom value of (Picked unit) to Integer
                Set Unit_Position = (Position Of (Picked Unit))
                Set Unit_Type = (Unit-Type of (Picked Unit))

Code:
Creep Respawn
    Events
        Unit - Unit owned By Neutral Hostile dies
    Conditions
        Custom Value of (Triggering Unit) is greater than 0
    Actions
        Custom Script: local integer udg_Integer = GetUnitUserData(GetTriggerUnit())
        Wait 500 Seconds
        Unit - Create 1 (Unit_Type[(Integer)]) for Neutral Hostile at (Unit_Position[(Integer)]) facing Default building facing degrees
        Unit - Set the custom value of (Last created unit) to (Integer)

Unit_Position is of type Position
Unit_Type is of type Unit-Type
Integer is of type Integer...

Free hand GUI so the actions may not be correctly named.
 

Kingdom

New Member
Reaction score
0
Well, thanks a lot to both of you, it's finally working. I'd throw some rep around if i knew how, but anyway, hhehehe...

There goes the code to respawn them exactly where they were:

Code:
CRS Initialization Copy
    Events
        Map initialization
    Conditions
    Actions
        Set Integer = 0
        Unit Group - Pick every unit in (Units owned by Neutral Hostile matching ((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is Summoned) Not equal to True))) and do (Actions)
            Loop - Actions
                Set Integer = (Integer + 1)
                Unit - Set the custom value of (Picked unit) to Integer
                Custom script:   set udg_Creep_X[udg_Integer] = GetUnitX(GetEnumUnit())
                Custom script:   set udg_Creep_Y[udg_Integer] = GetUnitY(GetEnumUnit())
                Set Unit_Type[Integer] = (Unit-type of (Picked unit))

Code:
CRS Creep Dies and Revive
    Events
        Unit - A unit owned by Neutral Hostile Dies
    Conditions
        (((Triggering unit) is A structure) Not equal to True) and (((Triggering unit) is Summoned) Not equal to True)
        (Custom value of (Triggering unit)) Greater than 0
    Actions
        Custom script:   local integer udg_Integer = GetUnitUserData(GetTriggerUnit())
        Wait 30.00 seconds
        Unit - Create 1 Unit_Type[Integer] for Neutral Hostile at ((Center of (Entire map)) offset by (Creep_X[Integer], Creep_Y[Integer])) facing (Random angle) degrees
        Unit - Set the custom value of (Last created unit) to Integer

Thanks again, i can now finish my 2 maps, :)))))).
Laterz!!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top