storing unit locations

Jooster

New Member
Reaction score
7
alright so i have pre-placed units on the map. determined upon a terrain selection. there are sever rects laid out throughout the map. each unit pre-placed in these regions, if are killed, i would like them to re spawn. i got one alright trigger that gives the unit a integer value and im using

Code:
set udg_Creep_X[udg_TriggerName] = GetUnitX(GetEnumUnit())
set udg_Creep_Y[udg_TriggerName] = GetUnitY(GetEnumUnit())

but when its time to respawn the unit back in its allocating spot it will respawn on the exact opposite side of the map or smack in the center of the map.

is there a easier way of going about this? *edit* forgot to mention this. Is it possible to use a custom script that sets the units rect instead of X,Y co-ordinates?
 

Exide

I am amazingly focused right now!
Reaction score
448
X and Y coordinates are quicker, but more troublesome to use.
I'd suggest you simply use Points.
(I have no idea what your udg_TriggerName is, but I trust you do. :p)

Code:
Setup
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        Set tempgroup = (Units in (Playable map area) owned by Neutral Hostile)
        Unit Group - Pick every unit in tempgroup and do (Actions)
            Loop - Actions
                Unit - Set the custom value of (Picked unit) to loopinteger
                Set creepspawn[loopinteger] = (Position of (Picked unit))
                Set loopinteger = (loopinteger + 1)
        Custom script:   call DestroyGroup(udg_tempgroup)

Code:
Respawn
    Events
        Unit - A unit Dies
    Conditions
        (Owner of (Triggering unit)) Equal to Neutral Hostile
    Actions
        Wait 30.00 game-time seconds
        Hero - Instantly revive (Triggering unit) at creepspawn[(Custom value of (Triggering unit))], Hide revival graphics

Variables:
creepspawn = Point - array variable
loopinteger = integer variable
tempgroup = unit group variable


With X and Y:

Code:
Setup
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        Set tempgroup = (Units in (Playable map area) owned by Neutral Hostile)
        Unit Group - Pick every unit in tempgroup and do (Actions)
            Loop - Actions
                Unit - Set the custom value of (Picked unit) to loopinteger
                Set creepspawnX[loopinteger] = (X of (Position of (Picked unit)))
                Set creepspawnY[loopinteger] = (Y of (Position of (Picked unit)))
                Set loopinteger = (loopinteger + 1)
        Custom script:   call DestroyGroup(udg_tempgroup)

Code:
Respawn
    Events
        Unit - A unit Dies
    Conditions
        (Owner of (Triggering unit)) Equal to Neutral Hostile
    Actions
        Wait 30.00 game-time seconds
        Hero - Instantly revive (Triggering unit) at (Point(creepspawnX[(Custom value of (Triggering unit))], creepspawnY[(Custom value of (Triggering unit))])), Hide revival graphics

Same variables as before, but with two new:

creepspawnX = real - array variable
creepspawnY = real - array variable



with custom scripts:

Code:
Custom script:   set udg_creepspawnX[loopinteger] = GetUnitX(GetEnumUnit())
Custom script:   set udg_creepspawnY[loopinteger] = GetUnitY(GetEnumUnit())


with JASS:

JASS:

function Trig_Setup_Group_Actions_Func takes nothing returns nothing
    local integer loopinteger = 1

    call SetUnitUserData( GetEnumUnit(), loopinteger )
    set udg_creepspawnX[loopinteger] = GetUnitX(GetEnumUnit())
    set udg_creepspawnY[loopinteger] = GetUnitY(GetEnumUnit())
    set loopinteger = ( loopinteger + 1 )
endfunction

function Trig_Setup_Actions takes nothing returns nothing
    local group tempgroup = GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(PLAYER_NEUTRAL_AGGRESSIVE))

    call ForGroup( tempgroup, function Trig_Setup_Group_Actions_Func )

    call DestroyGroup(tempgroup)
    set tempgroup = null
endfunction

//===========================================================================
function InitTrig_Setup takes nothing returns nothing
    local trigger Setup = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( Setup, 1.00 )
    call TriggerAddAction( Setup, function Trig_Setup_Actions )
endfunction


(With JASS you're using two local variables (loopinteger and tempgroup) so udg_loopinteger and udg_tempgroup aren't needed.)

JASS:

function Trig_Respawn_Conditions takes nothing returns boolean
    return ( GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) )
endfunction

function Trig_Respawn_Actions takes nothing returns nothing
    local integer cvalue = GetUnitUserData(GetTriggerUnit())

    call PolledWait( 30.00 )
    call ReviveHero( GetTriggerUnit(), udg_creepspawnX[cvalue], udg_creepspawnY[cvalue], false )
endfunction

//===========================================================================
function InitTrig_Respawn takes nothing returns nothing
    local trigger Respawn = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( Respawn, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( Respawn, Condition( function Trig_Respawn_Conditions ) )
    call TriggerAddAction( Respawn, function Trig_Respawn_Actions )
endfunction
 

Vassilev

New Member
Reaction score
39
Hmmm...

You don't have a periodic timer that constantly updates the position of the heros?

Also..

Code:
Respawn
    Events
        Unit - A unit Dies
    Conditions
        (Owner of (Triggering unit)) Equal to Neutral Hostile
    Actions
        Wait 30.00 game-time seconds
        Hero - Instantly revive (Triggering unit) at creepspawn[(Custom value of (Triggering unit))], Hide revival graphics

I think the "triggering unit" might have phased out of existance from the game by the time 30 seconds have passed :p (decayed and removed from game, thus undetectable, had this problem before -.-")
 

vypur85

Hibernate
Reaction score
803
Heroes won't decay till inexistence. They will still be there unless you remove them. But creeps will. If I'm not mistaken, creeps decay time is about 1 minute. Anyway, I don't think this will work on normal units:

Code:
Hero - Instantly revive (Triggering unit) at creepspawn[(Custom value of (Triggering unit))], Hide revival graphics

It's used for heroes. For units, you need to create an entirely new unit.

Also, showing the entire trigger may help.
 

Vassilev

New Member
Reaction score
39
Heroes won't decay till inexistence. They will still be there unless you remove them. But creeps will. If I'm not mistaken, creeps decay time is about 1 minute. Anyway, I don't think this will work on normal units:

ah.. my bad :p

the problem with my trigger was that i grouppicked after 30 seconds and it didn't detect the dead heroes... or maybe it was just my boolean..
 

Jooster

New Member
Reaction score
7
exide, my spawn system is almost EXACTLY like what u sugguested. i just have multiple levels of units to spawn. I.E lvl 1/2/3 types of spawning groups. if that makes any sense. thats all working great. my only problem is what i suggested before. the group of units are being spawned at the center of the map. not where they were. its prtty frustrating.

ok so this is what i got.

Code:
ashenvale creeps
    Events
        Time - Elapsed game time is 40.00 seconds
    Conditions
    Actions
        Unit - Create 2 Timber Wolf for Neutral Hostile at (Center of creeps 1 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 1 Giant Wolf for Neutral Hostile at (Center of creeps 1 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 3 Dark Troll for Neutral Hostile at (Center of creeps 2 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 1 Dark Troll Shadow Priest for Neutral Hostile at (Center of creeps 2 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 2 Dark Troll Shadow Priest for Neutral Hostile at (Center of creeps 3 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 2 Giant Spider for Neutral Hostile at (Center of creeps 3 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 1 Dire Wolf for Neutral Hostile at (Center of creeps 3 north <gen>) facing Default building facing (270.0) degrees
        Trigger - Run creep values Changing <gen> (checking conditions)
        Sound - Play creeps_entering <gen>
        Game - Display to (All players) the text: |cffffcc00-Level 1-...
        Trigger - Turn on ashenvale creeps L2 <gen>


Code:
ashenvale creeps L2
    Events
        Time - Elapsed game time is 300.00 seconds
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Triggering unit) is A Hero) Not equal to True
                    Then - Actions
                        Unit - Remove (Picked unit) from the game
                    Else - Actions
        Unit Group - Destroy unit group (Last created unit group)
        Unit - Create 2 Giant Wolf for Neutral Hostile at (Center of creeps 1 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 1 Dire Wolf for Neutral Hostile at (Center of creeps 1 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 3 Dark Troll Berserker for Neutral Hostile at (Center of creeps 2 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 1 Dark Troll High Priest for Neutral Hostile at (Center of creeps 2 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 2 Dark Troll High Priest for Neutral Hostile at (Center of creeps 3 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 2 Brood Mother for Neutral Hostile at (Center of creeps 3 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 3 Dire Wolf for Neutral Hostile at (Center of creeps 3 north <gen>) facing Default building facing (270.0) degrees
        Trigger - Run creep values Changing <gen> (checking conditions)
        Sound - Play creeps_entering <gen>
        Game - Display to (All players) the text: |cffffcc00-Level 2-...
        Trigger - Turn on ashenvale creeps L3 <gen>

Code:
ashenvale creeps L3
    Events
        Time - Elapsed game time is 600.00 seconds
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Triggering unit) is A Hero) Not equal to True
                    Then - Actions
                        Unit - Remove (Picked unit) from the game
                    Else - Actions
        Unit Group - Destroy unit group (Last created unit group)
        Unit - Create 2 Dire Wolf for Neutral Hostile at (Center of creeps 1 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 1 Dark Troll Warlord for Neutral Hostile at (Center of creeps 1 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 4 Dark Troll Berserker for Neutral Hostile at (Center of creeps 1 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 3 Dark Troll Warlord for Neutral Hostile at (Center of creeps 2 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 2 Dark Troll High Priest for Neutral Hostile at (Center of creeps 2 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 2 Dark Troll High Priest for Neutral Hostile at (Center of creeps 3 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 2 Brood Mother for Neutral Hostile at (Center of creeps 3 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 3 Dire Wolf for Neutral Hostile at (Center of creeps 3 north <gen>) facing Default building facing (270.0) degrees
        Unit - Create 1 Satyr Hellcaller for Neutral Hostile at (Center of creeps 3 north <gen>) facing Default building facing (270.0) degrees
        Trigger - Run creep values Changing <gen> (checking conditions)
        Sound - Play creeps_entering <gen>
        Game - Display to (All players) the text: |cffffcc00-Level 3-...


Then..... these are the spawn/custom value triggers

Code:
creep values initialization
    Events
    Conditions
    Actions
        Set unit_group = (Units in (Playable map area) owned by Neutral Hostile)
        Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
            Loop - Actions
                Set Creep_Value = (Creep_Value + 1)
                Unit - Set the custom value of (Picked unit) to Creep_Value
                Custom script: set udg_Creep_X[udg_Creep_Value] = GetUnitX(GetEnumUnit())
                Custom script: set udg_Creep_Y[udg_Creep_Value] = GetUnitY(GetEnumUnit())
        Custom script: call DestroyGroup (udg_unit_group)

Notice the trigger above and the trigger below are the same in a sense. just one dumps the value of the LVL1 and 2 creeps to reset the custom value for the next creeps entering the map when told to run.

Code:
creep values Changing
    Events
    Conditions
    Actions
        Set Creep_Value = 0
        Set unit_group = (Units in (Playable map area) owned by Neutral Hostile)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Triggering unit) is A Hero) Not equal to True
            Then - Actions
                Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
                    Loop - Actions
                        Set Creep_Value = (Creep_Value + 1)
                        Unit - Set the custom value of (Picked unit) to Creep_Value
                        Set Creep_Spawnpoint[Creep_Value] = (Position of (Picked unit))
            Else - Actions
        Custom script: call DestroyGroup (udg_unit_group)

AND finally the respawn code

Code:
creep respawn
    Events
        Unit - A unit Dies
    Conditions
        ((Owner of (Triggering unit)) Equal to Neutral Hostile) and (((Triggering unit) is Summoned) Not equal to True)
    Actions
        Wait 60.00 seconds
        Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at Creep_Spawnpoint[(Custom value of (Triggering unit))] facing Default building facing (270.0) degrees
        Unit - Set the custom value of (Triggering unit) to (Custom value of (Triggering unit))
        Custom script: call RemoveLocation (udg_Creep_Spawnpoint)
*edit* forgot to ask, when i run these. it seems like after about 3 cycles through a section of creeps they just quit respawning all together.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top