In need of a few clarifications

XeRo13g

New Member
Reaction score
3
Maybe someone experienced enough can clarify a few things?

1. Lets assume that we want to spawn units from a specific point, facing a specific point throughout a long period of the game. Can we set a unique variable to those points and keep using them over and over again without any leak? Can we do that with unit\player groups also? (I've seen it before I think)

Initialization
Code:
Set Perm_Point1 = (Point(1537.00, -352.00))
Set Perm_Point2 = (Point(2311.00, -1352.00))
Set Perm_Group = (Units in (X_Region))

Trigger-1
Code:
Unit - Create 1 footman for Player 1 at Perm_Point facing Perm_Point2
Add (last created unit) to Perm_Group

Trigger-2
Code:
Unit Group - Pick every unit in Perm_Group and do (Unit Group - Remove (Picked unit) from Perm_Group)
Unit - Create 1 archer for Player 1 at Perm_Point facing Perm_Point2
Add (last created unit) to Perm_Group

If we use trigger-1 and trigger-2, 400 times before we destroy the points and group, will it leak?

Current answer:

2.Is there any way to simulate "right-click" with a trigger?
When you right click on a friendly unit, you will follow that unit but you will also attack if the unit you are following isn't moving. Using a trigger to order a "right-click" will just follow and never attack.

Current answer:
call IssueTargetOrder(GetSummonedUnit(), "smart", GetSummoningUnit())

3.Is there any way for an ally to upgrade a research that you own?

Current answer:
Probably not

4.I've read somewhere, long time ago that using Player 1 is not good(true/false?). If you set those globals to a variable, would it be better/faster?

Current answer:
Makes no difference


5.If you use different variables for everything you do and finally end up with 1000 variables the game has to remember, isn't it the same with having 1000 leaks?

Current answer:
Many variables will not slow down the performance significantly


6.Recently I'm trying my luck with hashtables, there is a tutorial that states that you shouldn't have more than 10 hashtables in your map. Is it because hashtables can be reused and you don't need more, or is there another restriction? (eg. bugs, slower performance etc)

Current answer:
False, there is no 10 hashtables limit


7.At "scenario-Player properties", opponents are set to computer and when the game begins, it shows "computer(normal)", giving no choice to players for easy or insane. Atm I cannot change that, no matter what I try.
Is there a way to change one of the computers to easy and others to insane?
Is there any way to give the choice to players?

Current answer:

8.When I create a local game, any player who clicks on my game lags for several seconds before he is able to join. Then, when he attempts to join the game, he lags again for even more time before he finally joins. Is this due to the minimap preview image? The loading image? Does the game loads any part of the game (or variables) beforehand?
How can this be avoided or minimized?

Current answer:

9.While playing, the first time you open the "quest" panel, you freeze for a few seconds. (The map has 6-7 quests or so).
Is there any way to prevent\preload that?

Current answer:
The abilities cause this. The reason or circumstances - unknown

10.How much "heavier" is using auras for adding bonuses to a hero(range 25000) than using an ability on that hero? (eg. Aura for armor vs armor bonus ability)

Current answer:
It's the same

I've spent quite some time looking these up and either I found nothing or the answers were foggy/contradicting.
Thank you for taking the time to read this long post and thank you in advance for helping out.-

EDIT: I've updated the questions with the answers provided so far. I'll try to keep them updated, for others who seek answers to similar questions and to keep track what is answered or not.
 

ultimate11

Active Member
Reaction score
25
This is a long storry baby:
1)Once you saved a point you can use it over and over and will not leak if u wont overwrite it.
ex:
Trigger:
  • Event Map initialization
    • Condtions:
    • Actions
      • Set Temp_point equal centre of region X = not leak

Trigger:
  • Event Every 0.1 seconds of game
    • Condtions:
      • Actions
        • Set Temp_point equal centre of region X = leak whitout clearing it

2)
Trigger:
  • Untitled Trigger 003
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Issued order) Equal to (Order(smart))
      • Or - Any (Conditions) are true
      • (Current order of (Target unit of issued order)) Equal to (Order(move))
      • (Current order of (Target unit of issued order)) Equal to (Order(smart))
    • Actions
      • Unit - Order (Triggering unit) to Attack (Target unit of issued order)
 

ultimate11

Active Member
Reaction score
25
3) dont know
4)false
5)at least you are clearing them is false.You can use up to 8000 variable is u clear them and use well
6)hashtable are slower but more efficiently for MUI skills and others
7)you can do via trigger i think,but players can choose difficluty of a computer just befro game start
8)it`s happens to me sometimes before game end ,dont know why and don`t disturb me
9)depend on how you create your quest..check them again isn`t noramly to freez when press F9
10)i dont understood what kind of bonusses 9agil,str) or attack rate movement speed?

OMG sry for the double post....big mistake
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
1. Lets assume that we want to spawn units from a specific point, facing a specific point throughout a long period of the game. Can we set a unique variable to those points and keep using them over and over again without any leak? Can we do that with unit\player groups also? (I've seen it before I think)
[...]
If we use trigger-1 and trigger-2, 400 times before we destroy the points and group, will it leak?
Will not leak


2.Is there any way to simulate "right-click" with a trigger?
When you right click on a friendly unit, you will follow that unit but you will also attack if the unit you are following isn't moving. Using a trigger to order a "right-click" will just follow and never attack.
If i remember correctly you can issue an order to a unit which is "rightclick".


3.Is there any way for an ally to upgrade a research that you own?
I dont know if the "shared shop" ability works for upgrades, but at the very least you can make one player research an upgrade and set the upgrade level for another player via triggers.


4.I've read somewhere, long time ago that using Player 1 is not good(true/false?). If you set those globals to a variable, would it be better/faster?
I dont understand what you mean, how could using "player 1" be bad? Could you give some kind of context?


5.If you use different variables for everything you do and finally end up with 1000 variables the game has to remember, isn't it the same with having 1000 leaks?
Do you understand what a leak is? Of course, if you leak 1000 points it takes as much ram as if you set 1000 variables without destroying them, because its actually the same.
But if you have a repeated memory leak you can easily get beyond 1000 leaks in a longer lasting game.


6.Recently I'm trying my luck with hashtables, there is a tutorial that states that you shouldn't have more than 10 hashtables in your map. Is it because hashtables can be reused and you don't need more, or is there another restriction? (eg. bugs, slower performance etc)
There is one restriction that disallows you to use more then 256 hashtables at once (if i remember correctly). Other then that there is no restriction.
But its still true that you can use 1 Hashtable to store unlimited amounts of information and so you dont need any more hashtables but 1. But you can use more if you really wish for. Just remember, everything you create takes RAM.

7.At "scenario-Player properties", opponents are set to computer and when the game begins, it shows "computer(normal)", giving no choice to players for easy or insane. Atm I cannot change that, no matter what I try.
Is there a way to change one of the computers to easy and others to insane?
Is there any way to give the choice to players?
Wow, this really is one thing i never thought about in all my years with the editor. i dont know, lol.

8.When I create a local game, any player who clicks on my game lags for several seconds before he is able to join. Then, when he attempts to join the game, he lags again for even more time before he finally joins. Is this due to the minimap preview image? The loading image? Does the game loads any part of the game (or variables) beforehand?
How can this be avoided or minimized?
There are some information about the game which are downloaded before the game starts, such as the preview image and loading screen, thats correct.



9.While playing, the first time you open the "quest" panel, you freeze for a few seconds. (The map has 6-7 quests or so).
Is there any way to prevent\preload that?
Never heard of such behaviour.


10.How much "heavier" is using auras for adding bonuses to a hero(range 25000) than using an ability on that hero? (eg. Aura for armor vs armor bonus ability)
Not at all? Its still an ability, the differences should be minimal.
 

XeRo13g

New Member
Reaction score
3
7)you can do via trigger i think,but players can choose difficluty of a computer just befro game start

-With a trigger, I don't think it's possible? This is before the game starts
-I've tried to allow them to choose, no luck.

9)depend on how you create your quest..check them again isn`t noramly to freez when press F9

Quest - Create a Required quest titled "title" with the description "Desc", using icon path "path"
Set Quests[1] = (Last created quest)
Quest - Mark Quests[1] as Undiscovered
Quest - Create a quest requirement for Quests[1] with the description "blabla"
Set Quest_Requirement[1] = (Last created quest requirement)

Maybe it's those 5 icons loading that take so long?!





I dont understand what you mean, how could using "player 1" be bad? Could you give some kind of context?

One is global, the other is a variable?!
(Owner of (Triggering unit)) Equal to Player 1 (Red)
vs
(Owner of (Triggering unit)) Equal to Temp_Player


Do you understand what a leak is? Of course, if you leak 1000 points it takes as much ram as if you set 1000 variables without destroying them, because its actually the same.
But if you have a repeated memory leak you can easily get beyond 1000 leaks in a longer lasting game.

I'm using hundreds of integers and units, stored in arrays. As far as I understand, if you have 1000 integers stored, it will slow the game as much as 1000 leaks. (True/False?)
Setting a unit variable to no-unit will clear the memory? Can an integer be cleared?

Not at all? Its still an ability, the differences should be minimal.
I was afraid that auras check all units in range periodically, thnx.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
No as it seems you dont understand leaks.

The problem occurs only with some variables, points, unit-groups, forces, regions, and such.
The reason is because these objects are not created by the games core engine but by the custom script in your map.

Imagine a variable as a pointer, it points to an object.

If we think about unit variables for example:
the game provides a unit, lets say a wisp.
You can now create unit variables.
These variables can point to the wisp.
You can have multiple variables pointing to the same wisp.
If you remove the wisp from the game the unit variable does still exist and work.
Its just a pointer.

Same goes for point or unit-group variables.
BUT! Points and unit-groups arent in the game like units or items or doodads.
If you use a point variable to describe "the position of >someunit<" you create a location and then make your point-variable point to the location.

If you now run this action: "the position of >someunit<" it would look like this:
1). Create a location at >someunit<.x / >someunit<.y
2). make the variable point to the last created location
3). Create a location at >someunit<.x / >someunit<.y
4). make the variable point to the last created location
5). Create a location at >someunit<.x / >someunit<.y
6). make the variable point to the last created location

what happened? We got 3 locations but only one variable pointing to the last one created.
The first and secondly created locations are out of your reach, you cannot even remove them anymore because you dont have a pointer pointing to them. They are out of control, sitting iddle and taking RAM without any use.
This is what is called a memory leak.

Besides this, different types of objects take different amounts of memory. A location might take more memory then a single Integer and thus an integer Variable takes less memory then a location-memory-leak.

And to answer your other question about "player 1 (red)": no, its the very same. Does not make any difference.
 

XeRo13g

New Member
Reaction score
3
Well, I do understand leaks but I appreciate the detailed explanation, actually is one of the best I've seen.
What I didn't know is how much the variables cost in terms of performance. I know that using Integer A all the time will cause problems and it's better to have a different variable for different loops. I keep track of every variable I use in an excel spreadsheet, so allocating some of the already used variables to other triggers (if they can be re-used that is), is viable yet time consuming.
I just wanted some kind of measurement to weight if it's worth the time to reallocate them and thus used "leaks" as a comparison. Apologies if I wasn't clear enough. I've updated the answer to question 5.


As far as question 9:
1. I've tried restoring all "game interface" setting.
2. Changing all quests to be discovered, hidden etc... any possible combination I could think of.
3. Placed a single quest with the default icon
4. Even preload units using the quest icons.
5. Deleted all relevant triggers that contain quest data (set quest discovered and so on...)


Nothing worked, yet if I do this to any other map, it doesn't lag.

PS. Maybe it wasn't a very good idea to list many questions in 1 post, I just didn't want to spam the forums. I added an answer after each question so, answers can be tracked.
 

ZakkWylde-

New Member
Reaction score
14
For number 2, can't you do a simple check? if unit is hostile, order attack -- if friendly order patrol?
That is, if all else fails... :D

EDIT: Question regarding the leak example: if you set temp_var = GetUnitX(>someUnit<)
and then, lets say... 5 seconds later, you set temp_var = GetUnitY(>someUnit<)
would this be the same type of leak? is the real (the x position) you set temp_var to SITTING IDLY TAKING UP RAM?
If so, how do you get rid of this...? Doesn't seem possible, even...

[For your example, would you RemoveLocation(variable) before setting it to the next location?]
 

vypur85

Hibernate
Reaction score
803
> ...using Integer A all the time will cause problems
Not if you use it correctly, it won't cause any problems.

> ...some kind of measurement to weight
Global variables can be used repeatedly as you already know. Don't think you can achieve 1000 variables (in Variable Editor) in your map. Even if you can, it doesn't really cause much problems. And there is no way you can hit the operation limit... at least that's how I think. Variables are initialised during loading time. The in-game performance will be fine. Four general point variables are sufficient for the whole map. Maybe 5.
 

XeRo13g

New Member
Reaction score
3
For number 2, can't you do a simple check? if unit is hostile, order attack -- if friendly order patrol?
That is, if all else fails... :D

What I want is to control the summoned units of a specific hero by restricting their move-away range to 500 from their owner. ATM I use a trigger to measure the distance for each of the summoned units and order them to "move-to a point", so they get closer. If I don't do that, the summoned units are naturally lured away by enemies and cause great inconvenience to every players in the game. I've tried patrol but as far as I understand, it doesn't serve this purpose as they keep getting lured away and return only when the targets are all dead.

With that said...
2)
Trigger:
  • Untitled Trigger 003
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Issued order) Equal to (Order(smart))
      • Or - Any (Conditions) are true
      • (Current order of (Target unit of issued order)) Equal to (Order(move))
      • (Current order of (Target unit of issued order)) Equal to (Order(smart))
    • Actions
      • Unit - Order (Triggering unit) to Attack (Target unit of issued order)

I cannot see how I could possibly use this, maybe Ultimate11 or anyone else can point out to me.



> Don't think you can achieve 1000 variables (in Variable Editor) in your map. Even if you can, it doesn't really cause much problems.

I certainly hope so, because I've hit the 1000 variables breakpoint and there is still too much work to be done. Before I keep going, I have to make sure that I'm not wasting my time by creating a slow and unstable map.
 

ultimate11

Active Member
Reaction score
25
Trigger:
  • Trigger:
    • Untitled Trigger 003
    • Events
    • Unit - A unit Is issued an order targeting a unit
    • Conditions
    • (Issued order) Equal to (Order(smart)) //or follow
    • Or - Any (Conditions) are true
    • (Current order of (Target unit of issued order)) Equal to (Order(move))
    • (Current order of (Target unit of issued order)) Equal to (Order(smart))
    • Actions
    • Unit - Order (Triggering unit) to Attack (Target unit of issued order)

event was wrong but surely u can easely modify it
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
2.Is there any way to simulate "right-click" with a trigger?
When you right click on a friendly unit, you will follow that unit but you will also attack if the unit you are following isn't moving. Using a trigger to order a "right-click" will just follow and never attack.

Current answer:

Order the unit to "smart" another unit. This is the equivalent to right-click, which will follow a friendly unit, or attack an enemy unit.

3.Is there any way for an ally to upgrade a research that you own?

Current answer:
Probably not

The only method I know of would be to trigger it, using dummy researches

5.If you use different variables for everything you do and finally end up with 1000 variables the game has to remember, isn't it the same with having 1000 leaks?

Current answer:
Many variables will slow down the performance, maybe less than actual leaks

It's identical to having 1000 leaks, with the exception being that you have access to those values, and when needed, they can be removed from the game. This is, of course, if those variables are all pointing to different values, and each value is being used. The amount of variables isn't nearly as important as the amount of 'things' you are actually using.
 

XeRo13g

New Member
Reaction score
3
event was wrong but surely u can easely modify it

How?!

Order the unit to "smart" another unit. This is the equivalent to right-click, which will follow a friendly unit, or attack an enemy unit.

I'm using smart in various triggers but always as a condition, I don't know how to order a unit to "smart". If there is a command for this, I've totally missed it.
If there is a custom script to order the "summoned unit" to "smart" the "summoning unit", it will probably solve my problem but I have no knowledge of how to script this. ...Anyone?

It's identical to having 1000 leaks, with the exception being that you have access to those values, and when needed, they can be removed from the game. This is, of course, if those variables are all pointing to different values, and each value is being used. The amount of variables isn't nearly as important as the amount of 'things' you are actually using.

That is what I was afraid of.
I guess that when you create an Integer Array variable with size [1] at initialization, the RAM doesn't save/remembers every value of the array to 0 but when you try to use any value of the array, it will return 0.
When you set the array variable[5] to a specific value, you have +1 more variable for the RAM to remember and i doubt that setting that value to 0, will eliminate it. Is there any way to remove those values without deleting the actual variable(the array variable[5] in this case)?
 

XeRo13g

New Member
Reaction score
3
9.While playing, the first time you open the "quest" panel, you freeze for a few seconds. (The map has 6-7 quests or so).
Is there any way to prevent\preload that?

It seems that the abilities cause the problem. Not sure how or why but if I delete every custom ability, the problem goes away. It is nearly impossible to double check if a specific ability causes this. I can't see how any ability has anything to do with the quest menu, if someone has any idea what might cause this problem, please share.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
I'm using smart in various triggers but always as a condition, I don't know how to order a unit to "smart". If there is a command for this, I've totally missed it.
If there is a custom script to order the "summoned unit" to "smart" the "summoning unit", it will probably solve my problem but I have no knowledge of how to script this. ...Anyone?

JASS:
call IssueTargetOrder(GetSummonedUnit(), &quot;smart&quot;, GetSummoningUnit())


Put that inside a custom script. Sorry, I thought there was a GUI function that let you specify a string, rather than one of those drop-down selection boxes.

That is what I was afraid of.
I guess that when you create an Integer Array variable with size [1] at initialization, the RAM doesn't save/remembers every value of the array to 0 but when you try to use any value of the array, it will return 0.
When you set the array variable[5] to a specific value, you have +1 more variable for the RAM to remember and i doubt that setting that value to 0, will eliminate it. Is there any way to remove those values without deleting the actual variable(the array variable[5] in this case)?

Don't worry about this. At all. I believe arrays are allocated for the full 8192 indices at initialization, and the only time you should worry about 'too much memory' is if you have memory leaks (usually periodic), or some giant memory-intensive system.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
There is a GUI function to order a unit to "smart".
I have to repeat myself, you can order a unit to "rightclick".

This:
Code:
call IssueTargetOrderBJ( GetTriggerUnit(), "smart", GetTriggerUnit() )
is the Jass translation of this:
Code:
Unit - Order (Triggering unit) to Rightclick (Triggering unit)

And to your "variable"-problem:
You can use even 10000 variables, it doesnt make a difference.
Variables do not take performance, they use RAM. You can store 100000000000 integers in 100000000000 variables and the FPS wouldnt even drop by 1.
Why? Because thats peanuts. An integer is usually never bigger then 4 bytes, whats 4 bytes for a 4GB-RAM chip of today? And setting and accessing those values is nothing big either. We live in the 21 century and not in the stupid-ages.
 

XeRo13g

New Member
Reaction score
3
There is a GUI function to order a unit to "smart".
I have to repeat myself, you can order a unit to "rightclick".

This:
Code:
call IssueTargetOrderBJ( GetTriggerUnit(), "smart", GetTriggerUnit() )
is the Jass translation of this:
Code:
Unit - Order (Triggering unit) to Rightclick (Triggering unit)

I've tested the custom script and it works exactly like the in-game right-click. The GUI right-click was the first that I've tried and even though the ordered unit follows correctly, it never attacks.



And to your "variable"-problem:
You can use even 10000 variables, it doesnt make a difference.
Variables do not take performance, they use RAM. You can store 100000000000 integers in 100000000000 variables and the FPS wouldnt even drop by 1.
Why? Because thats peanuts. An integer is usually never bigger then 4 bytes, whats 4 bytes for a 4GB-RAM chip of today? And setting and accessing those values is nothing big either. We live in the 21 century and not in the stupid-ages.

That takes a burden off my soul.
-Both answers updated-

Thanks guys for all the help so far +rep
 

XeRo13g

New Member
Reaction score
3
Updated the answers and added +rep to those I couldn't before. (the least I can do)

If anyone has any knowledge on questions 7,8 or the wild 9, please share.

Thanks again.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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