• 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.

[Solved] How to delete old unit name and get new unit name when evolving (chat line)

Status
Not open for further replies.
Level 5
Joined
May 8, 2020
Messages
87
1682135062718.png

One
Events
Map initialization
Conditions
Actions
Player - Set name of Player 1 (Red) to ((Name of (Triggering player)) + (Name of (Triggering unit)))

Two
Events
Unit - A unit Gains a level
Conditions
(Level of (Leveling Hero)) Equal to 2
Actions
Unit - Remove (Leveling Hero) from the game
Unit - Create 1 Mountain King for Player 1 (Red) at (Position of (Leveling Hero)) facing Default building facing degrees
Player - Set name of Player 1 (Red) to ((Name of (Triggering player)) + (Name of (Triggering unit)))

How when I am a Blood Mage with the name when chatting (that) then evolve, how do I delete the old name and get the new one (Mountain King) ?
If there are more than 100 generals, what should I do
 
Last edited:
Level 24
Joined
Feb 27, 2019
Messages
833
Rather than to delete characters from the new string its easier to store the old unedited string.

Use two string array variables to store the name of the players and the name of the units in separate strings. The player number can be used as an index for the arrays.
  • Player - Set name of Player 1 (Red) to (udg_PlayerName[1] + udg_UnitName[1])
Edit: You can do with one variable that stores the player name. The important part is to not overwrite that variable. Use that variable instead of ((Name of (Triggering player)) when setting the player name.
 
Last edited:
Level 5
Joined
May 8, 2020
Messages
87
I want to ask how to determine the unit name without having to set ? because if it's 100 heroes, shouldn't I have to set them one by one
 
Level 24
Joined
Feb 27, 2019
Messages
833
Each players name has to be stored in a string variable array. Each heroes name does not have to be stored.
  • Init Player Name
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set VariableSet PlayerName[(Player number of (Picked player))] = (Name of (Picked player))
  • Set Player Name
    • Events
    • Conditions
    • Actions
      • Player - Set name of (Triggering player) to (PlayerName[(Player number of (Triggering player))] + (Name of (Triggering unit)))
 
Status
Not open for further replies.
Top