• 🏆 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] Text being left behind issue

Status
Not open for further replies.
Level 12
Joined
Dec 2, 2016
Messages
733
So this trigger, when the ability is casted. It teleports the unit to the center of the map. But the text that is created above their unit showing "Recall 5..4..3..2..1" sometimes bugs and stays there and doesn't remove itself. Is there anything you guys can see that would cause that issue?

Also Triggers run locally right? Because it's possible two players would use this ability at the same time.

  • Vampire Recall
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Vampiric Recall
    • Actions
      • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Human\MassTeleport\MassTeleportCaster.mdl
      • Set TempEffect = (Last created special effect)
      • Floating Text - Create floating text that reads Vampire Recall: at (Position of (Triggering unit)) with Z offset 5.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Floating Text - Show TempText for (All players)
      • Set TempText = (Last created floating text)
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Unit - Pause (Triggering unit)
          • Floating Text - Change text of TempText to (Vampire Recall: + (String((Integer A)))) using font size 10.00
          • Floating Text - Change the position of TempText to (Triggering unit) with Z offset 10.00
          • Wait 1.00 seconds
      • Unit - Move (Triggering unit) instantly to (Center of spawnVampires <gen>)
      • Unit - Unpause (Triggering unit)
      • Floating Text - Destroy TempText
      • Special Effect - Destroy TempEffect
 
Level 9
Joined
Jul 30, 2018
Messages
445
My guess is it's the wait in the loop, that gets messed up. It's usually not a good practice to use waits in loops.

There are a couple of problems here:
1. No, triggers aren't ran locally, so there would be problems if two player, or even two different units, would cast that spell at the same time.

2. The Integer A loop is not ideal. It's usually better to use a custom variable for all loops, because the Integer A (and B) are global variables, so they will get messed up if any other loop is running at the same time with the same loop variable.

3. You're leaking a lot. Take a look here: Memory Leaks

4. That TempText is not MUI, so if two players use the ability, the lastly cast ability would create a new floating text (and replace the stored information in the variable) so the first one would never be destroyed. You can just use the GUI function "Floating Text - Disable permanence" and the text will destroy itself once the lifespan is set.



I would do such spell using hashtables. They require a bit getting used to, but are then pretty handy once you get the hang of them. There's a pretty good guide to get some idea how they work: Hashtables and MUI

I have to go to work now, but if you are still having some trouble, I can make example triggers in the afternoon.
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
I agree with all of what Sabe said above, however, based on your trigger, I think you might have an easier time learning indexing for your MUI needs rather than Hashtables.

This is a great tutorial on how to make spells that can be used simultaneously by multiple or even the same unit.

Visualize: Dynamic Indexing
 
Level 9
Joined
Jul 30, 2018
Messages
445
I agree with all of what Sabe said above, however, based on your trigger, I think you might have an easier time learning indexing for your MUI needs rather than Hashtables.

This is a great tutorial on how to make spells that can be used simultaneously by multiple or even the same unit.

Visualize: Dynamic Indexing

Yeah, sure. It really comes down to preferences. Personally, I just like hashtables more and to me they are a lot easier to use.
 
Status
Not open for further replies.
Top