• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

odd

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 41
Joined
Jun 9, 2011
Messages
13,247
hey got a little problem with a simple trigger here, this is not finished at all but it bugs allready -.-

the trigger is supposed to show name above the unit and change the colour depending on lvl. But somehow when I lvl up the text become red not green idk why :/


  • Show names
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Current camera bounds)) and do (Actions)
        • Loop - Actions
          • Set u = (Picked unit)
          • Set level = (Level of hero)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of (Picked unit)) Less than or equal to (level - 5)
            • Then - Actions
              • Set name = (|CFF20C000 + ((Name of u) + |R))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of (Picked unit)) Less than or equal to (level + 5)
            • Then - Actions
              • Set name = ( |CFFFF0303 + ((Name of u) + |R))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of (Picked unit)) Greater than or equal to (level - 2)
              • (Level of (Picked unit)) Less than or equal to (level + 2)
            • Then - Actions
              • Set name = ( |CFFFFFF01 + ((Name of u) + |R))
            • Else - Actions
          • Set loc = (Position of u)
          • Set loc2 = (loc offset by 100.00 towards 135.00 degrees)
          • Set text = (Load 1 of (Key (Picked unit)) in index_tableIf the label is not found, this function returns NULL.)
          • Floating Text - Destroy text
          • Floating Text - Create floating text that reads name at loc2 with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Set text = (Last created floating text)
          • Hashtable - Save Handle Oftext as 1 of (Key (Picked unit)) in index_table
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Put the if/then/elses inside each other.


  • Show names
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Current camera bounds)) and do (Actions)
        • Loop - Actions
          • Set u = (Picked unit)
          • Set level = (Level of hero)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of (Picked unit)) Less than or equal to (level - 5)
            • Then - Actions
              • Set name = (|CFF20C000 + ((Name of u) + |R))
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of (Picked unit)) Less than or equal to (level + 5)
                • Then - Actions
                  • Set name = ( |CFFFF0303 + ((Name of u) + |R))
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of (Picked unit)) Greater than or equal to (level - 2)
                      • (Level of (Picked unit)) Less than or equal to (level + 2)
                    • Then - Actions
                      • Set name = ( |CFFFFFF01 + ((Name of u) + |R))
                    • Else - Actions
          • Set loc = (Position of u)
          • Set loc2 = (loc offset by 100.00 towards 135.00 degrees)
          • Set text = (Load 1 of (Key (Picked unit)) in index_tableIf the label is not found, this function returns NULL.)
          • Floating Text - Destroy text
          • Floating Text - Create floating text that reads name at loc2 with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Set text = (Last created floating text)
          • Hashtable - Save Handle Oftext as 1 of (Key (Picked unit)) in index_table


You could make it loop every 0.05 seconds. Actually couldn't you just run it when your hero levels up?
And fix the leaks: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
Instead of destroing the ft, you could just change the text.
 
yup I know it leaks but I don't like to have the removers ther before the trigger is working.
And I assume I can't convince you to clean leaks as soon as they're created? :p

Anyway, I just created this system myself (to search for any logical flaws), but it's working fine for me.
As Maker suggested, I decreased the periodic timer (0.05 wasn't smooth enough, so I suggest something between 0.02 and 0.03). I also pick units within range (not camera bounds) and set the hero level in a different trigger (on level-up).

So I have no idea why your trigger isn't working. You use the name of the picked unit so that should be correct, but apparently it isn't.


  • Periodic
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • -------- Remove Old Text --------
      • Unit Group - Pick every unit in TextGroup and do (Actions)
        • Loop - Actions
          • Unit Group - Remove (Picked unit) from TextGroup
          • Floating Text - Destroy TextUnitText[(Custom value of (Picked unit))]
      • -------- Create New Text --------
      • Set TempLoc1 = (Position of Hero)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 1000.00 of TempLoc1 matching ((Matching unit) Not equal to Hero)) and do (Actions)
        • Loop - Actions
          • Set TempInt = (Level of (Picked unit))
          • Set TempLoc2 = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HeroLevel Greater than (TempInt + 3)
            • Then - Actions
              • Set TempString = ((|c0080ff56 + (Name of (Picked unit))) + |r)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HeroLevel Greater than (TempInt + 1)
                • Then - Actions
                  • Set TempString = ((|c00bbff00 + (Name of (Picked unit))) + |r)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • HeroLevel Greater than (TempInt - 1)
                    • Then - Actions
                      • Set TempString = ((|c00ffcc00 + (Name of (Picked unit))) + |r)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • HeroLevel Greater than (TempInt - 3)
                        • Then - Actions
                          • Set TempString = ((|c00ff9900 + (Name of (Picked unit))) + |r)
                        • Else - Actions
                          • Set TempString = ((|c00bb0000 + (Name of (Picked unit))) + |r)
          • Floating Text - Create floating text that reads TempString at TempLoc2 with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Set TextUnitText[(Custom value of (Picked unit))] = (Last created floating text)
          • Unit Group - Add (Picked unit) to TextGroup
          • Custom script: call RemoveLocation( udg_TempLoc2 )
      • Custom script: call RemoveLocation( udg_TempLoc1 )
 

Chaosy

Tutorial Reviewer
Level 41
Joined
Jun 9, 2011
Messages
13,247
since I dont like indexers I try to stick with hashtables if I can.
anyway I did actually fix the things before but that made the error since it worked before.

  • Show names
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Current camera bounds)) and do (Actions)
        • Loop - Actions
          • Set u = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of (Picked unit)) Less than or equal to (level - 5)
            • Then - Actions
              • Set name = (|CFF20C000 + ((Name of u) + |R))
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of (Picked unit)) Greater than or equal to (level + 5)
                • Then - Actions
                  • Set name = ( |CFFFF0303 + ((Name of u) + |R))
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of (Picked unit)) Greater than or equal to (level - 2)
                      • (Level of (Picked unit)) Less than or equal to (level + 2)
                    • Then - Actions
                      • Set name = ( |CFFFFFF01 + ((Name of u) + |R))
                    • Else - Actions
          • Set loc = (Position of u)
          • Set loc2 = (loc offset by 100.00 towards 135.00 degrees)
          • Set text = (Load 1 of (Key (Picked unit)) in index_tableIf the label is not found, this function returns NULL.)
          • Floating Text - Destroy text
          • Floating Text - Create floating text that reads name at loc2 with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Set text = (Last created floating text)
          • Hashtable - Save Handle Oftext as 1 of (Key (Picked unit)) in index_table
          • Custom script: call RemoveLocation(udg_loc)
          • Custom script: call RemoveLocation(udg_loc2)


will upload a pic soon


2qm226p.png



23w19uu.png

 
Status
Not open for further replies.
Top