• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Check Hero's personal name

Level 17
Joined
Apr 5, 2011
Messages
331
Hi all,
I think it's impossible, but I wanna ask to make sure.

Is there any way to check the hero's personal name in WorldEditor? E.g. playing as Undead, I train a DK: if his personal name is "Lord Nightsorrow" he gets +1 Strength via triggers, and if it's "Lord Soulrender" he gets +1 Agility.

There is a walkaround with replacing the trained DK with a different but identical DK-unit with just a single proper name, but I don't want to go that route.

Thank you all!
 
Level 21
Joined
Feb 27, 2019
Messages
633
  • (Proper name of (Triggering unit)) Equal to Lord Soulrender
  • Hero - Set Name of (Triggering unit) to Lord Soulrender
Maybe you want to check only the first letters because if there are multiple heroes with the same name I believe they will be called Lord Soulrender II, Lord Soulrender III and so on.
  • (Substring((Proper name of (Triggering unit)), 1, 15)) Equal to Lord Soulrender
 
Last edited:

Uncle

Warcraft Moderator
Level 66
Joined
Aug 10, 2018
Messages
6,745
Cheers!

I'm blind and somehow missed that the string can be extracted:vw_wtf:

Although setting name only works in Reforged and not in 1.26 in which I mod.
I don't think it's a Reforged only function. I remember using it in 1.31 and before. Lots of goodies were added in 1.31 prior to Reforged release.
 
Level 20
Joined
Jan 3, 2022
Messages
328
(Substring((Proper name of (Triggering unit)), 1, 15)) Equal to Lord Soulrender
This can desync between players if you compare a localized name vs "Lord Soulrender". Example:
English players: Lord Soulrender
Russian players: Лорд Душегуб (not accurate)

Now you have got English players with one version of events and everybody else playing their language with another version of events. People will desync. This is true for all localized names and strings.
Can you do anything? First I would suggest to NOT RELY on names. However if you used custom names in WorldEdit then everybody would get the English name you entered (pink field) unless your map had a multilanguage translation embedded - then every player would have a localized name again.
Find another way to derive the hero stats. Maybe use an intermediate dummy unit for spawning/training which when trained is instantly replaced by the correct hero variation (it can be the one unit but with a name set through BlzSetHeroProperName).

Do you really, really want to rely on ProperName? Then I guess BlzSetUnitStringField is worth exploring, if this is the correct native to get access to each separate unit name. Then you'd need to find which one of the many names it is (find its index) and then decide the stats based on the index, not the string name. Example:
Index 0 = Lord Soulrender
Index 1 = Lord Nightsorrow
Here you compare the current name with indexed name, then you know which index number it is. Since each player loaded the correct locale for their own checks, this will not desync. But I don't know if it's the correct native at all, because no other native exists.
 
Level 17
Joined
Apr 5, 2011
Messages
331
This can desync between players if you compare a localized name vs "Lord Soulrender". Example:
English players: Lord Soulrender
Russian players: Лорд Душегуб (not accurate)

Now you have got English players with one version of events and everybody else playing their language with another version of events. People will desync. This is true for all localized names and strings.
Can you do anything? First I would suggest to NOT RELY on names. However if you used custom names in WorldEdit then everybody would get the English name you entered (pink field) unless your map had a multilanguage translation embedded - then every player would have a localized name again.
Find another way to derive the hero stats. Maybe use an intermediate dummy unit for spawning/training which when trained is instantly replaced by the correct hero variation (it can be the one unit but with a name set through BlzSetHeroProperName).

Do you really, really want to rely on ProperName? Then I guess BlzSetUnitStringField is worth exploring, if this is the correct native to get access to each separate unit name. Then you'd need to find which one of the many names it is (find its index) and then decide the stats based on the index, not the string name. Example:
Index 0 = Lord Soulrender
Index 1 = Lord Nightsorrow
Here you compare the current name with indexed name, then you know which index number it is. Since each player loaded the correct locale for their own checks, this will not desync. But I don't know if it's the correct native at all, because no other native exists.
Thanks for the headsup, but I'm using custom names in english, so no such problem should arise (yes, "pink fields"). I used vanilla DK as an example only.
 
Top