• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Floating Text? That can follow unit? {displaying names, being unable to select}

Status
Not open for further replies.
Level 4
Joined
May 2, 2009
Messages
69
Got another question! :thumbs_up:
I'm making an rpg that would screw up if I allow people to select other units, so I made it so you cannot select anyone. So I want to make it so you can see unit names... But floating text cannot follow units, right? And if not, what else can I do? I saw in a map called Starcraft RPG, there were unit ranks above each unit, and I'm not sure if he made his own models for that or not... I tried to make pictures, but it only takes warcraft model files (mdl.) and I'm not skilled in the model editor... Any help?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
  • Floating Text
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero[(Integer A)] is alive) Equal to True
              • Hero[(Integer A)] Not equal to No unit
            • Then - Actions
              • Floating Text - Destroy FloatingText[(Integer A)]
              • Floating Text - Create floating text that reads (Name of Hero[(Integer A)]) above Hero[(Integer A)] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Set FloatingText[(Integer A)] = (Last created floating text)
            • Else - Actions
              • Floating Text - Destroy FloatingText[(Integer A)]
That should do it ;) (I've tested it, it follows the hero smoothly)

If the hero is dead, or doesn't exist, it will just not display the floating text anymore.

Variables:
"Hero" - Unit variable, array = player numbers (you've probably got this already if you're making an RPG).
"FloatingText": Floating Text variable, array = player numbers
 
Level 4
Joined
May 2, 2009
Messages
69
Ok thanks, that helps with the player's heroes, but I also meant for the enemy units, and I can't use that for every unit, right?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Ok thanks, that helps with the player's heroes, but I also meant for the enemy units, and I can't use that for every unit, right?

Hmm... I think you can :wink:
Well, the problem is actually that you need to keep your max units on the map as low as possible, so I suggest setting a limit or something...
Allright, these are the triggers:


  • Trigger 1
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Unit Group - Add (Picked unit) to TextGroup)
  • Trigger 2
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Unit Group - Add (Triggering unit) to TextGroup
  • Trigger 3
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Unit Group - Remove (Triggering unit) from TextGroup
  • Trigger 4 (actual system)
  • FT
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Integer = 0
      • For each (Integer A) from 1 to (Number of units in TextGroup), do (Actions)
        • Loop - Actions
          • Floating Text - Destroy FloatingText[(Integer A)]
      • Unit Group - Pick every unit in TextGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
            • Then - Actions
              • Set Integer = (Integer + 1)
              • Set TempLoc = (Position of (Picked unit))
              • Floating Text - Create floating text that reads (Name of (Picked unit)) at TempLoc with Z offset 120.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Custom script: call RemoveLocation(udg_TempLoc)
              • Set FloatingText[Integer] = (Last created floating text)
            • Else - Actions
I've tested this with exactly 100 units, put together in a 32x32 map and it was fine :)

If your map contains massed units, I wouldn't do it, though... but you can create a system that spawns units only if there are heroes in the area, otherwise they won't spawn, so the unit limit will be pretty low.

note that I've used "Creating floating text on point", since I don't know for sure if the "above unit" location will leak (I've tested that too and didn't notice any changes, but it was a 32x32 map with only the triggers I've said before, it's hard to notice lag on that...).
 
Level 9
Joined
Jul 3, 2008
Messages
495
This is also just because I know how to use 3dsmax. But I would make a model for each name, and use its as an attachment.

But thats just me. But since I use Windows 7 now, 3dsmax 5 dosent work, and thats the reason why I stopped modding in wc3.
 
Level 17
Joined
Mar 17, 2009
Messages
1,350
Let me just propose something... Your destroying the floating text at the beginning of the periodic timer, and that makes sense. But what if a unit dies, and then due to that the number of units would have decreased and so the loop won't loop to the highest number and won't destroy the 'last' floating text.

I might have said it in a complicated way, but you'll understand it I think...
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I might have said it in a complicated way, but you'll understand it I think...

After reading it 3 times, I think I may have a basic interpretation of what might possibly be your question, yes.

Let me just propose something... Your destroying the floating text at the beginning of the periodic timer, and that makes sense. But what if a unit dies, and then due to that the number of units would have decreased and so the loop won't loop to the highest number and won't destroy the 'last' floating text.

I see... so, let me try to exlpain yourself (this is my interpretation...).

So, if a unit dies, he will be removed from the unit group (of course), but because of that, the exitwhen amount of the loop will be lowered.

Let's say there were 50 units, but because there's 1 dead, there are only 49 left.

Now, the FloatingText[50] will not be removed, because there are only 49 units and the loop will end at 49.

A possible solution might be to add this to the trigger where the unit dies:

  • Actions
  • For each (Integer A) from 1 to (Number of units in TextGroup), do (Actions)
  • Loop - Actions
  • Floating Text - Destroy FloatingText[(Integer A)]
After that, the unit will be removed from the group.

If I'm incorrect, please try to clear things up and if my solution doesn't work, I hope you've got any ideas, because I don't ^^
 
Level 17
Joined
Mar 17, 2009
Messages
1,350
Yup that's what I was saying and thank you for making it clearer ap0calypse.

I should have used an example to demonstrate my idea as you did.

And your solution is creative but I don't know if it'll bug, because you'd be destroying an already destroyed floating text in that case once the loop runs after the unit dies.

One idea would be to basically, when unit dies to destroy the floating text whose variable's array has the highest value - whose value is Number of units in TextGroup - and then remove the unit from the group. Now in this case, it'll be destroying the floating text for some random unit and than adding the floating text of this unit in another array when the loop runs. But and however, at a 0.03s interval, I doubt anyone would sense it.

The loop itself would then take care of destroying the dead unit's floating text before it switches around the arrays.

Hope this works ;)


So to set an example in case you didn't get it:

Current array is 50, one unit dies, 50 is destroyed and the array is then decreased to 49.
The loop destroy 1 to 49, re-allocates the arrays and creates floating texts from 1 to 49.
 
Status
Not open for further replies.
Top