- Joined
- Jul 12, 2010
- Messages
- 1,746
Hi everybody, I am currently making a custom ui that uses my own way of displaying the enemy's hp and icon:
Currently the way I use to change the texture of the backdrop(icon) is by storing the following data and looping though them to check which unit type it is:
This is a bit of a hassle when having to do with over 100 units in an RPG Map, so I thought of using a simple method to get the Unit Name:
Although this only works with default unit names...if a unit has a custom name it doesn't get the correct icon path.
It really is a shame that this trigger can't get a unit's icon path:
So I came here to ask if it's possible using JASS to directly get a unit's icon path OR if there is a better way to do this in general.
Currently the way I use to change the texture of the backdrop(icon) is by storing the following data and looping though them to check which unit type it is:
-
Enemy Bars Setup
-

Events
-


Time - Elapsed game time is 0.00 seconds
-
-

Conditions
-

Actions
-


Set VariableSet i = 1
-


Set VariableSet Bar_Unit_Type[i] = test 1
-


Set VariableSet Bar_Unit_Path[i] = ReplaceableTextures\CommandButtons\BTNFootman.tga
-


-------- - --------
-


Set VariableSet i = (i + 1)
-


Set VariableSet Bar_Unit_Type[i] = test 2
-


Set VariableSet Bar_Unit_Path[i] = ReplaceableTextures\CommandButtons\BTNRifleman.tga
-


-------- - --------
-


Set VariableSet i = (i + 1)
-


Set VariableSet Bar_Unit_Type[i] = test 3
-


Set VariableSet Bar_Unit_Path[i] = ReplaceableTextures\CommandButtons\BTNGrunt.tga
-


-------- - --------
-


Set VariableSet i = (i + 1)
-


Set VariableSet Bar_Unit_Type[i] = Tauren Chieftain
-


Set VariableSet Bar_Unit_Path[i] = ReplaceableTextures\CommandButtons\BTNHeroTaurenChieftain.tga
-


-------- - --------
-


Set VariableSet i = (i + 1)
-


Set VariableSet Bar_Unit_Type[i] = Blood Mage
-


Set VariableSet Bar_Unit_Path[i] = ReplaceableTextures\CommandButtons\BTNHeroBloodElfPrince.tga
-


-------- - --------
-


Set VariableSet Bar_Unit_Max = i
-


-------- - --------
-
-
-
select unit name
-

Events
-


Player - Player 1 (Red) Selects a unit
-
-

Conditions
-

Actions
-


Custom script: local framehandle char = BlzGetFrameByName("CharacterIcon" , 0)
-


-------- ------------------------- --------
-


-------- Check to see if there is "space" in unit name and remove it e.g Mountain Giant --------
-


Set VariableSet UnitName = (Name of (Triggering unit))
-


For each (Integer i) from 1 to (Length of UnitName), do (Actions)
-



Loop - Actions
-




Game - Display to (All players) for 5.00 seconds the text: (i + ((String(i)) + (: + (Substring(UnitName, i, i)))))
-




If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-





If - Conditions
-






(Substring(UnitName, i, i)) Equal to
-
-





Then - Actions
-






Set VariableSet UnitName = ((Substring(UnitName, 1, (i - 1))) + (Substring(UnitName, (i + 1), 20)))
-






Game - Display to (All players) for 5.00 seconds the text: (Found "space" in + (String(i)))
-
-





Else - Actions
-
-
-
-


Game - Display to (All players) for 5.00 seconds the text: (Final result: + UnitName)
-


-------- ------------------------- --------
-


-------- Check to see if unit is a hero. --------
-


If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-



If - Conditions
-




((Triggering unit) is A Hero) Equal to True
-
-



Then - Actions
-




Set VariableSet UnitName = (ReplaceableTextures\CommandButtons\BTNHero + (UnitName + .blp))
-
-



Else - Actions
-




Set VariableSet UnitName = (ReplaceableTextures\CommandButtons\BTN + (UnitName + .blp))
-
-
-


-------- ------------------------- --------
-


Custom script: call BlzFrameSetTexture(char, udg_UnitName ,0, true)
-
-
It really is a shame that this trigger can't get a unit's icon path:
So I came here to ask if it's possible using JASS to directly get a unit's icon path OR if there is a better way to do this in general.

