• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] animation keeps looping

Status
Not open for further replies.
Level 5
Joined
Jan 27, 2007
Messages
154
I understand that hashtags can clean up memory leaks so i tried a simple trigger to integrate it however I still am discovering how it works.

So here I tried to play a unit's animation once the skill is used and clear the hashtable once everything is done.

however the animation keeps from looping.

  • atkanimationchk
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Light Attack
  • Actions
    • Hashtable - Create a hashtable
    • Hashtable - Save Handle Of(Casting unit) as 0 of 0 in (Last created hashtable)
    • Hashtable - Save 1 as 1 of 0 in (Last created hashtable)
    • Unit - Pause (Load 0 of 0 in (Last created hashtable))
    • Animation - Play (Load 0 of 0 in (Last created hashtable))'s attack animation
    • Unit - Unpause (Load 0 of 0 in (Last created hashtable))
    • Hashtable - Clear all child hashtables of child 0 in (Last created hashtable)
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
It seems you are confused about what memory leak is. Memory leak occurs when an object meets the following criteria:
1) It is not accessible (you lose all reference to it - that means it's not saved in any variable/hashtable or any other thing that could refer back to it)
2) It has no more use to you (you don't need it in your game anymore)

Such object, which has no use to you and cannot be accessed, still takes your PC's memory. This is especially problematic with transparent objects (objects that do not have any graphic) like the "Point" object. Every time you call for example "(Position of (*some unit*))" you create a "Point" object that saves in itself the X and Y coordinates of (*some unit*). Yet it cannot be seen ingame, so it is easily forgotten and not removed.

It is also important to realize what can and what cannot leak. In your case, animation is part of unit - it is coded inside the unit itself. Hence it cannot leak, as it doesn't create any new object. It just uses part of an existing object - in this case the unit.

That the animation continues to loop is just something that is set in the unit itself (some animations are set to loop, other animations are set to play only once and you have to order to play the animation again yourself).

Preventing memory leaks via hashtable is possible but not really efficient. That is because the game has to search through the hashtable to find the reference to the animation you want to load. That is more time-consuming action than directly loading the reference from a variable. Not to mention that you refer to the hashtable as "(Last created hashtable)". That is also inefficient in the long run.
In your case, you also use hashtables incorrectly. Every time the unit uses Light Attack ability, you create new hashtable. That's not how hashtables are designed. They're designed in such a way that your whole map should need about 3 hashtables max, but you could also efficiently use only 1 hashtable for your entire map. Due to how they are designed, there is a maximum of about 60 hashtables or so that you can create (dunno the exact number now, but it is quite low). That means your triggers could get buggy when you run out of new hashtables to create.

For the memory leaks:
Check this thread: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/ - it contains all types of memory leaks and there's also explanation on how to get rid of them.
 
Status
Not open for further replies.
Top