• 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.

Create or train random unit

Status
Not open for further replies.
Level 14
Joined
Mar 4, 2009
Messages
1,156
in 55 second of the game i need to order unit (portal of hell) to train random
unit or create random unit on his position.(If i order the unit to train unit1,unit2,unit3,unit4......he will always first train unit2)
 
Level 14
Joined
Mar 4, 2009
Messages
1,156
I'm curious



setname of variable UNITS
veriable type = unit-type


Set Vampires
Events
Map initialization
Conditions
Actions
Set UNITS[1] = Nosferatu (Evil) (PRAVI)
Set UNITS[2] = Benshee (Evil) (PRAVI)
Set UNITS[3] = Nosferatu (Evil) (PRAVI)
Set UNITS[4] = Nosferatu (Evil) (PRAVI)
Set UNITS[5] = Werewolf (Evil) (PRAVI)
Set UNITS6] = Nosferatu (Evil)



Spawn Hero for Player 11
Events
Time - Elapsed game time is 54.50 seconds
Conditions
(Player 11 (Dark Green) slot status) Equal to Is playing
((Random unit from (Units owned by Player 11 (Dark Green) matching (((Matching unit) is A Hero) Equal to True))) is alive) Not equal to True
Actions
Unit - Create 1 units[(Random integer number between 1 and 6)] for Player 11 (Dark Green) at (Center of VAMPIRES <gen>) facing Default building facing degrees

You may have the same combination of spawning units but just in WE, you will not have it in multiplayer for shure.
 

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,550
(Center of VAMPIRES <gen>)
This location does not exist by default, so the game will first have to create it, but unfortunately, it won't delete that location. The game will create the location again and again, and those locations are little pieces of memory that slowly begin to pile up, causing your map to lag.
So you should create a point variable, set it to "(Center of VAMPIRES <gen>)" and then call this custom script:
  • Custom script: call RemoveLocation(udg_NameOfYourPointVariable)
  • Set MyPointVariable = (Center of VAMPIRES <gen>)
  • Unit - Create 1 units[(Random integer number between 1 and 6)] for Player 11 (Dark Green) at (Center of VAMPIRES <gen>) facing Default building facing degrees
  • Custom script: call RemoveLocation(udg_MyPointVariable)
 
Level 14
Joined
Mar 4, 2009
Messages
1,156
This location does not exist by default, so the game will first have to create it, but unfortunately, it won't delete that location. The game will create the location again and again, and those locations are little pieces of memory that slowly begin to pile up, causing your map to lag.
So you should create a point variable, set it to "(Center of VAMPIRES <gen>)"

I dont understand i mean that VAMPIRE<gen> is just a region why should it make lags?Anyway i think it will not make lags becouse i turned off the triggers after 55 seconds.
 

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,550
I dont understand i mean that VAMPIRE<gen> is just a region why should it make lags?Anyway i think it will not make lags becouse i turned off the triggers after 55 seconds.
It's not the region I'm talking about. Have you heard of memory leaks? It's exactly as I said: they're pieces of unused memory.
By referring to the center of a region, you are referring to a location. To refer to it, the game first has to create that location, and only then run the action that is using it. See it as an invisible object. That object will remain there, because the system does not delete it, but another one is still created each time the trigger refers to it. In that case, you have to delete it yourself.

If you're turning the trigger off after 55 seconds, I guess it won't generate a lot of memory leaks, but still, it's preferable to be as clean as possible, and remove that unused memory (which also affects the loading time following your map's end).
 
Level 10
Joined
Jun 1, 2008
Messages
485
ye, every time you refer to location directly(not using variable), and not destroyed afterward, it will cause a 'memory leak' (it still on memory, but you can't refer to it, and will be there until the game end or restarted). well, 1 or 2 leak is not so lag, but imagine if there is a 10.000 leak, it will crash the warcraft.

And, you can use a variable to save it at map initialization. And, you refer to that variable every time you use it. it's not leaking
 
Status
Not open for further replies.
Top