• 🏆 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!

[Trigger] Simple trigger doesn't work!

Status
Not open for further replies.
Level 8
Joined
Dec 1, 2010
Messages
316
I really didn't know how to describe this with a fitting title.

Anyway, I want the mana cost of an ability to be equal to the players current mana. I want it to update periodically aswell.
I came to the solution below. However this is the first time i use unit groups, and the "set mana cost of ability" action. The trigger doesn't seem to be working and i can't wrap my head around why.

Does anyone have any idea what i'm doing wrong?

  • Untitled Trigger 014
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units owned by Player 1 (Red) of type Magroth the Defender) and do (Actions)
        • Loop - Actions
          • Unit - For Unit (Picked unit), Set mana cost of ability War Stomp, Level: (Level of War Stomp for (Picked unit)) to (Integer((Mana of (Picked unit))))

EDIT:
Okay it seems like the value does change, but only when i level up the ability. I was expecing it to update based on the function not the leveling up. any suggestions for alternative methods of achieving this?
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,024
  • I think it would be easier to just give the spell no mana cost and then just set total mana to 0 upon casting it. However, if you don't want to do that:

  • "Units owned by..." leaks a group (refer to my post in your other thread for how to clean leaks)
  • It would be best to create a group specifically for this spell and add units to the group when they learn the spell. Then pick units in that group periodically. Doing it this way does not leak the group since you constantly re-use it.
  • 1.00 is a slow refresh rate for something like this. You can safely get away with 0.25 or even less without having an impact on game execution in any way.
 
Level 8
Joined
Dec 1, 2010
Messages
316
  • I think it would be easier to just give the spell no mana cost and then just set total mana to 0 upon casting it. However, if you don't want to do that:
While i have considered that and it would be easier, i like the fact that the mana cost updates and is visible when you look at the spell. It adds a sense of immersion imo.

  • "Units owned by..." leaks a group (refer to my post in your other thread for how to clean leaks)
  • It would be best to create a group specifically for this spell and add units to the group when they learn the spell. Then pick units in that group periodically. Doing it this way does not leak the group since you constantly re-use it.
i'm still having some troubles wrapping my head around what a leak is exactly, Can i see it in a way as the group geting re created every time the timer runs, eventually causing it to overload the memory with unused groups?

What exactly is the impact leaks have on the game or the functioning of a trigger in very simple terms?

1.00 is a slow refresh rate for something like this. You can safely get away with 0.25 or even less without having an impact on game execution in any way.
Yeah, i just put it on something random while i tested stuff out.


The problem is the 0-indexing. Level 0 on the trigger is actually level 1 on the ability in the game. So it should be ((Level of War Stomp for (Picked unit)) - 1).

This seems to have fixed the problems i had with the function not running as intended. the mana is updating apropiately now.
 
Level 9
Joined
Jul 30, 2018
Messages
445
What exactly is the impact leaks have on the game or the functioning of a trigger in very simple terms?

Leak is a lost piece of information that keeps taking up the CPU's memory, but cannot be used or accessed in any way. The result is lag and in most severe cases it can cause crashes.

Imagine it this way: you tell the game to create a unit to a location. A "point object" is then created at that location. Then the unit is created to the position of this point object. Now, if you created another unit again at some location, the first unit's spawn location would be lost. The point object that was created is still there, but now you have no way to access that, because you declared another point location, thus creating another point object. And because all those point objects still exist there, the computer has to keep them in its memory, even though you have no use for them, because you can't access them.

Here are some good threads about how to clear these leaks:
- Things That Leak
- Memory Leaks
 
Level 8
Joined
Dec 1, 2010
Messages
316
Leak is a lost piece of information that keeps taking up the CPU's memory, but cannot be used or accessed in any way. The result is lag and in most severe cases it can cause crashes.

Imagine it this way: you tell the game to create a unit to a location. A "point object" is then created at that location. Then the unit is created to the position of this point object. Now, if you created another unit again at some location, the first unit's spawn location would be lost. The point object that was created is still there, but now you have no way to access that, because you declared another point location, thus creating another point object. And because all those point objects still exist there, the computer has to keep them in its memory, even though you have no use for them, because you can't access them.

Here are some good threads about how to clear these leaks:
- Things That Leak
- Memory Leaks



Oh, I have seen the things that leak page before (thanks to pyrogasm!)

But i think i understand now why it's important to avoid them!
The concept was still pretty new to me since i've first head about them yesterday xD
Right now it seems pretty clear though.

thanks
 
Status
Not open for further replies.
Top