Calling tmpPoint in GUI ?

killbuzz

Member
Reaction score
9
I'm currently working on a creep respawn system that will respawn the dead creep in its original location and only if there are no enemy players nearby. here is what I have so far:
Code:
Respawn Init
    Events
        Map initialization
    Conditions
    Actions
        Set Respawn_Time = 25.00
        Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
            Loop - Actions
                Set Temp_Integer = (Temp_Integer + 1)
                Unit - Set the custom value of (Picked unit) to Temp_Integer
                Set Creep_Point[Temp_Integer] = (Position of (Picked unit))
                Set Creep_Angle[Temp_Integer] = (Facing of (Picked unit))

Code:
Respawn
    Events
        Unit - A unit owned by Neutral Hostile Dies
    Conditions
        And - All (Conditions) are true
            Conditions
                (Unit-type of (Triggering unit)) Not equal to Sapphiron (undead)
                (Unit-type of (Triggering unit)) Not equal to Lich King (Evil)
                (Unit-type of (Triggering unit)) Not equal to Ghost
                (Unit-type of (Triggering unit)) Not equal to Horn of Cenarius Pedestal
                (Unit-type of (Triggering unit)) Not equal to Unique Artifact
                ((Triggering unit) is A Hero) Equal to False
                ((Triggering unit) is Summoned) Equal to False
                (Custom value of (Triggering unit)) Greater than 0
                ((Triggering unit) is A flying unit) Equal to False
    Actions
        Custom script:  local integer i = GetUnitTypeId(GetTriggerUnit())
        Custom script:  local integer ii = GetUnitUserData(GetTriggerUnit())
        Custom script:  local location tmpPoint = GetUnitLoc(GetTriggerUnit())
        Wait until (((Units within 800.00 of tmpPoint matching (((Matching unit) belongs to an enemy of Neutral Hostile) Equal to True)) is empty) Equal to True), checking every Respawn_Time seconds
        Custom script:  call SetUnitUserData(CreateUnit(Player(12),i,GetLocationX(udg_Creep_Point[ii]),GetLocationY(udg_Creep_Point[ii]),udg_Creep_Angle[ii]),ii)
        Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
        Custom script:  call RemoveLocation (udg_tmpPoint)
I'm having problems with the local location 'tmpPoint' I would like to call it in the wait until function and I'm wondering if its possible/how to do it. I have tried converting to custom text and editing the variables from there but I always get an error.
 
Code:
Wait until (((Units within 800.00 of tmpPoint matching (((Matching unit) belongs to an enemy of Neutral Hostile) Equal to True)) is empty) Equal to True), checking every Respawn_Time seconds
This tmpPoint is actually a global variable.

When you set this variable,
Code:
Custom script:  local location tmpPoint = GetUnitLoc(GetTriggerUnit())
it's a local variable.

So you have 2 different variables here, tmpPoint and udg_tmpPoint. They are separate entity, which is why your trigger didn't work.

Also, local variables are known to not work in GUI condition block.

My suggestion is to use periodic trigger. When a unit dies, add the unit into a unit group. Then periodically check for presence of units around the said unit. If no units around, create your creep and set their custom value accordingly. Then, remove the dead unit from the unit group.
 
That could potentially work, but the problem with that is when the corpse decays/is raised it will be removed from the unit group, and then revived at the next condition check. I tried to solve this in my original trigger by hiding the dying unit, suspending corpse decay on that unit, then creating a corpse of that unit type so there was still something to be raised:
Code:
Respawn
    Events
        Unit - A unit owned by Neutral Hostile Dies
    Conditions
        And - All (Conditions) are true
            Conditions
                (Unit-type of (Triggering unit)) Not equal to Sapphiron (undead)
                (Unit-type of (Triggering unit)) Not equal to Lich King (Evil)
                (Unit-type of (Triggering unit)) Not equal to Ghost
                (Unit-type of (Triggering unit)) Not equal to Horn of Cenarius Pedestal
                (Unit-type of (Triggering unit)) Not equal to Unique Artifact
                ((Triggering unit) is A Hero) Equal to False
                ((Triggering unit) is Summoned) Equal to False
                (Custom value of (Triggering unit)) Greater than 0
                ((Triggering unit) is A flying unit) Equal to False
    Actions
        Custom script:  local integer i = GetUnitTypeId(GetTriggerUnit())
        Custom script:  local integer ii = GetUnitUserData(GetTriggerUnit())
        Unit - Hide (Triggering unit)
        Unit - Suspend corpse decay for (Triggering unit)
        Unit - Create a (Unit-type of (Triggering unit)) corpse for Neutral Hostile at (Position of (Triggering unit))
        Wait until (((Units within 800.00 of Creep_Point[(Custom value of (Triggering unit))] matching (((Matching unit) belongs to an enemy of Neutral Hostile) Equal to True)) is empty) Equal to True), checking every Respawn_Time seconds
        Custom script:  call SetUnitUserData(CreateUnit(Player(12),i,GetLocationX(udg_Creep_Point[ii]),GetLocationY(udg_Creep_Point[ii]),udg_Creep_Angle[ii]),ii)
        Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
This didn't work as creatures like revenants don't have corpses so it would just create their base models and I think it would screw up the custom value of the unit as well. (Had mobs respawning when players were nearby) I also tried to put the location of the triggering unit into another point array, in hopes that it would bypass the corpse decay problem:
Code:
Respawn
    Events
        Unit - A unit owned by Neutral Hostile Dies
    Conditions
        And - All (Conditions) are true
            Conditions
                (Unit-type of (Triggering unit)) Not equal to Sapphiron (undead)
                (Unit-type of (Triggering unit)) Not equal to Lich King (Evil)
                (Unit-type of (Triggering unit)) Not equal to Ghost
                (Unit-type of (Triggering unit)) Not equal to Horn of Cenarius Pedestal
                (Unit-type of (Triggering unit)) Not equal to Unique Artifact
                ((Triggering unit) is A Hero) Equal to False
                ((Triggering unit) is Summoned) Equal to False
                (Custom value of (Triggering unit)) Greater than 0
                ((Triggering unit) is A flying unit) Equal to False
    Actions
        Custom script:  local integer i = GetUnitTypeId(GetTriggerUnit())
        Custom script:  local integer ii = GetUnitUserData(GetTriggerUnit())
        Set tmpPointArray[(Custom value of (Triggering unit))] = Creep_Point[(Custom value of (Triggering unit))]
        Wait until (((Units within 800.00 of tmpPointArray[(Custom value of (Triggering unit))] matching (((Matching unit) belongs to an enemy of Neutral Hostile) Equal to True)) is empty) Equal to True), checking every Respawn_Time seconds
        Custom script:  call SetUnitUserData(CreateUnit(Player(12),i,GetLocationX(udg_Creep_Point[ii]),GetLocationY(udg_Creep_Point[ii]),udg_Creep_Angle[ii]),ii)
        Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
That didn't work either, as it seemed to set the most recently killed unit as the position for all of the currently dead creeps.
I thought I had read somewhere that if you called a local variable in a GUI condition with the same name it would work properly, but I guess I read wrong or else blizz changed it. So if it isn't possible my next question is how do I go about solving the creeps that have no corpses problem?
Thank you for your reply btw :)

EDIT: Seems like adding every dead unit to a single group wouldn't work, because either all of the creep locations would have to have a player nearby or else all the creeps would respawn, or the opposite would happen and none of the creeps would respawn if even 1 location had a player nearby. Maybe i'm missing something?
 
> I thought I had read somewhere that if you called a local variable in a GUI condition with the same name it would work properly, but I guess I read wrong or else blizz changed it

Don't think this is possible. I believe what you read was globalising the local variable. Ie, you create a local variable, then you set the local variable as a global variable. Then you use this global within a condition block. This way, you can 'mask' the local variable usage within GUI conditions. But I guess this way won't do it for your case here.


> Seems like adding every dead unit to a single group wouldn't work

I can imagine it to work though. Just add them into single group. Within that group, you create another group again for each picked unit:

Code:
Pick... in SomeUnitGroup and do...
   Loop - Actions
     Set TempGroup - Units within 300 range of Position of Picked unit
     If number of unit in TempGroup is 0, then....
         - Remove Picked unit grom SomeUnitGroup
         - Create your new creep at Somewhere[Custom value of Picked unit]

Some thing along the line, perhaps? Of course, by doing this, you'd need to make sure the decay time for units is set to a large value, about 88 seconds seem fine to me.


> solving the creeps that have no corpses problem?

Make the unit drop corpse upon death. This can be set in the Object Editor for that specific unit.


Ps: Not sure how familiar are you with WE. But from the triggers you posted above, you seemed rather experienced. So I just generally describe my ideas here.
 
Ok I think I see what you are getting at and how it could be made to work, just wondering what exactly 'make unit drop corpse on death' does? Will it make the trigger behave differently? I'll set something up for this, thank you for the help :). (Also i'm just coming back to WE after a 2 year break, starting to use custom script and wish I had started a long time ago lol)

EDIT: Alright here are all the triggers I have:
Code:
Respawn Setup
    Events
        Map initialization
    Conditions
    Actions
        Set Respawn_Time = 25.00
        Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
            Loop - Actions
                Set Temp_Integer = (Temp_Integer + 1)
                Unit - Set the custom value of (Picked unit) to Temp_Integer
                Set Creep_Point[Temp_Integer] = (Position of (Picked unit))
                Set Creep_Angle[Temp_Integer] = (Facing of (Picked unit))

Code:
Respawn Init
    Events
        Unit - A unit owned by Neutral Hostile Dies
    Conditions
        And - All (Conditions) are true
            Conditions
                (Unit-type of (Triggering unit)) Not equal to Sapphiron (undead)
                (Unit-type of (Triggering unit)) Not equal to Lich King (Evil)
                (Unit-type of (Triggering unit)) Not equal to Ghost
                (Unit-type of (Triggering unit)) Not equal to Horn of Cenarius Pedestal
                (Unit-type of (Triggering unit)) Not equal to Unique Artifact
                ((Triggering unit) is A Hero) Equal to False
                ((Triggering unit) is Summoned) Equal to False
                (Custom value of (Triggering unit)) Greater than 0
                ((Triggering unit) is A flying unit) Equal to False
    Actions
        Unit Group - Add (Triggering unit) to DeadCreeps

Code:
Respawn
    Events
        Time - Every 25.00 seconds of game time
    Conditions
        (Number of units in (Units within 800.00 of (Position of (Picked unit)) matching ((Owner of (Matching unit)) Not equal to Neutral Hostile))) Equal to 0
    Actions
        Unit Group - Pick every unit in DeadCreeps and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Number of units in (Units within 800.00 of (Position of (Picked unit)) matching ((Owner of (Matching unit)) Not equal to Neutral Hostile))) Equal to 0
                    Then - Actions
                        Unit - Create 1 (Unit-type of (Picked unit)) for Neutral Hostile at Creep_Point[(Custom value of (Picked unit))] facing Creep_Angle[(Custom value of (Picked unit))] degrees  <--- Turns out I wasn't able to put custom script here for some reason
                        Unit - Set the custom value of (Last created unit) to (Custom value of (Picked unit))
                        Unit Group - Remove (Picked unit) from DeadCreeps
                    Else - Actions
                        Do nothing

So assuming that "Make Unit Drop Corpse on Death" solves the decaying problem then I should be all set unless there are some leaks I forgot to clean up, kinda tired atm.
EDIT 2: Checked the object editor and i'm not seeing the option to make unit drop corpse on death, do you happen to know what it would be under? (art/combat/stats/etc.)
 
I've recently made a respawn system that meets your requirements, here's the link.

I actually came across your trigger when I was first trying to set this whole thing up, but I really don't know how stuff like 'for each integer A do actions' works. Also, does this work even after a dying units corpse has decayed? Because that is the only problem I am having with my current triggers. Thanks for your reply :)
 
Yes, the variables are stored at the map initialization and right after unit is respawned, so they work independly of the state of an unit. Units will respawn in their original location, despite being killed in another. Also, things like 'Remove Unit' won't affect the trigger since the condition 'Unit is Alive' will return false if the unit no longer exists, is dead and also, from what I noticed and tested, reanimated.
 
Alright, awesome :D I looked it over again and I don't think it will be to difficult to figure out, thank you both for your replies and i'm glad this is finally dealt with. :) (Seems like TheHelper has changed since I was last here, I guess I cant give out +rep anymore?)
 
You're welcome. If you'll find any bugs or issues with the system let me know, since I'm using it myself and will work out the fixes. I'm not familiar with +rep options since I never actually used it so I can't address your question.
 
If you'll find any bugs or issues with the system let me know, since I'm using it myself and will work out the fixes
Alright no problem. Not going to start on it tonight though, I know I'd make to many mistakes, sometime tomorrow I think.
 
> Make Unit Drop Corpse on Death

I believe it is the Death Type - Can't raise, can decay.... Or something along the line. Just test and see if it works or not. Good that everything worked out for you.
 
> Make Unit Drop Corpse on Death

I believe it is the Death Type - Can't raise, can decay.... Or something along the line. Just test and see if it works or not. Good that everything worked out for you.

Ahh I see, and no that didnt work :| oh well going to start on the new system now :)

EDIT: finished the new trigger, and everything seems to be working fine now, thanks again and if I have any problems with it I will let you know.
Code:
Respawn Setup
    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 Temp_Integer = (Temp_Integer + 1)
                Unit - Set the custom value of (Picked unit) to Temp_Integer
                Set Creep[Temp_Integer] = (Picked unit)
                Set CreepUnitType[Temp_Integer] = (Unit-type of (Picked unit))
                Set Creep_Point[Temp_Integer] = (Position of (Picked unit))
                Set Creep_Angle[Temp_Integer] = (Facing of (Picked unit))
                Set CreepTimer[Temp_Integer] = 76

Code:
Respawn
    Events
        Time - Every 2.00 seconds of game time
    Conditions
    Actions
        For each (Integer A) from 1 to Temp_Integer, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Creep[(Integer A)] is alive) Equal to False
                    Then - Actions
                        Set Temp_Boolean = False
                        Set TempGroup = (Units within 800.00 of Creep_Point[(Integer A)])
                        Unit Group - Pick every unit in TempGroup and do (Actions)
                            Loop - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        ((Picked unit) belongs to an enemy of Neutral Hostile) Equal to True
                                    Then - Actions
                                        Set Temp_Boolean = True
                                    Else - Actions
                        Custom script:  call DestroyGroup(udg_TempGroup)
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Temp_Boolean Equal to False
                            Then - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        CreepTimer[(Integer A)] Greater than 0
                                    Then - Actions
                                        Set CreepTimer[(Integer A)] = (CreepTimer[(Integer A)] - 2)
                                    Else - Actions
                                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            If - Conditions
                                                CreepTimer[(Integer A)] Equal to 0
                                            Then - Actions
                                                Unit - Create 1 CreepUnitType[(Integer A)] for Neutral Hostile at Creep_Point[(Integer A)] facing Creep_Angle[(Integer A)] degrees
                                                Set Creep[(Integer A)] = (Last created unit)
                                                Set CreepTimer[(Integer A)] = 76
                                            Else - Actions
                            Else - Actions
                    Else - Actions
 
This will work as long as your 'Temp_Integer' isn't used elsewhere, whereas its name suggests otherwise.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    It is weird seeing a way more realistic users online number
  • The Helper The Helper:
    Happy Tuesday Night!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top