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!
How do i do this:
When a player enters a chat string like -reload then it will set the number of charges remaining on an item the player's unit has to 20.How do i do that?
You are setting Unit = (Triggering Unit). There is no triggering unit in this trigger. Also mind that setting charges to 0 will mean unlimited charges.
The following is not meant rude but it seems to me you don't know too much about triggers ?
The easiest way to achieve what you want should be
-if you create the item by triggers:
create an item variable by pressing "Ctrl + B" in the trigger editor and then when you create the item by trigger assign the variable to it and in your Reload Railgun trigger select "(Item being manipulated)" and choose your variable in the window.
-if you placed the item in the editor by hand:
click on "(Item being manipulated)" in the last trigger you posted and then in the new window click on "Select an Item" and select it directly in the editor.
It will increase the memory size if you don't remove leaks.
In general, yes leaks are bad. That's why it's always good practice to code in a clean way and always to remove them.
Seeing it practical, only if you leak very much, you will notice it in game after a while. So it's very important to keep periodic triggers leakfree, which are fired very often.
In contrast to that, triggers that are not fired too often (and don't have 10000 leaks in it^^) are not really a problem.
But anyway it's still always good practicse to keep your code clean, and for example also a requirement for spells/systems on hive.
Wc3 objects (i.e. handles) use memory and only will deallocate it when being destroyed by the map maker. Look at Things That Leak for a very good overview.
Only a limited amount of memory is available and performance will suffer with an increasing amount. Mind though that only thousands of leaks will really affect performance.
Having a leak means having memory allocated which
a) should no longer be allocated because it will not be used again
b) can't be deallocated because there is no reference to it left
Lets look at an easy example:
Unit - Move (Triggering unit) instantly to (Point(0.00, 0.00))
The function Location(real x, real y) will return a location, which is a handle occupying memory. It will still be in memory, unaccessible, after the execution of the trigger and therefore be a leak. On the next execution a new location will be created and again sit in memory.
Now imagine this trigger executed once every 0.01 seconds. Thats 100 more leaks per second. After some minutes, you would certainly notice a difference in a frames per second drop resulting in stuttering.
To not let the leak happen, a solution in GUI would be to assign the location to a variable, use it, and then remove it with the correct custom script JASS function, like this:
Set myLocation = (Point(0.00, 0.00))
Unit - Move (Triggering unit) instantly to myLocation
We could solve this problem with creating a tmpPlayerForce each time, show our text to this Force, and then destroy the Force afterwerds.
But I would prefer another way here, as you might see already, the tmpForce will always be the exactly same for one player. So I would create a global force variable and never destroy them:
Init - trigger:
Set Force[1] = PlayerGroup - Player 1
Set Force[2] = PlayerGroup - Player 2
Set Force[3] = PlayerGroup - Player 3
...
Set Force[12] = PlayerGroup - Player 12
Force[array] is a player group variabled with array ticked.
In this trigger you only initialisize the variables.
Usage - Example:
Events
Player - Player 1 (Red) types a chat message containing reloadpgm1 as An exact match
Player - Player 2 (Blue) types a chat message containing reloadpgm1 as An exact match
Player - Player 3 (Teal) types a chat message containing reloadpgm1 as An exact match
...
Player - Player 10 (Light Blue) types a chat message containing reloadpgm1 as An exact match
Conditions
Actions
Game - Display to Force[PlayerNumberOfTriggeringPlayer] the text: PG Mark I reloaded....
So you can see here, with just use the "Player Number Of Triggering Player" as index to show the text to the correct Force. No need to create/destroy tmp player forces anymore.
And no leak as you can use these forces over and over again in any trigger.
But i have another question though,how to do this:
When a player presses the "A" button in there keyboard then it will make there unit walk left.How do i do that?
The unit would have an ability with hotkey A. Then you can use the CAST EVENT.
Using arrow keys would also be an option maybe, but do not respond veryquick in wc3.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.