• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Preserving Proper Names Between "Unit - Replace "

Status
Not open for further replies.
Level 2
Joined
Dec 8, 2018
Messages
6
Anyone know of a quick and dirty way to preserve a Hero's proper name between replacement?

For example, I have an instance where a Hero is replaced with an identical Hero with different abilities. In this case, "Build Advanced Structures". However, once the Hero is replaced, a new Proper Name will be randomly generated. Is it possible to keep the old Proper Name?

I imagine I would need to get the unit's proper name, convert is to a string, stick it in a table then call it up somehow?
 
Level 7
Joined
Apr 17, 2017
Messages
316
Yes it is, There are possible ways to achieve that. But In my opinion the best and efficient is hashtables if you have multiple units and and you need to keep keep track of every hero
  • Map Init
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set hash = (Last created hashtable)
  • Your Trigger
    • Events
      • Your Event
    • Conditions
    • Actions
      • Set heroName = (Proper name of Your Hero)
      • Unit - Replace Your Hero with a Paladin using The old unit's relative life and mana
      • Hashtable - Save heroName as 0 of (Key (Last replaced unit)) in hash
      • Hero - Set Name of (Last replaced unit) to (Load 0 of (Key (Last replaced unit)) from hash)
Note: you don't even have to use hashtables if you don't plan on using these string variables later on. If that's the case you can simply do this:
  • Your Trigger
    • Events
      • Your Event
    • Conditions
    • Actions
      • Set heroName = (Proper name of Your Hero)
      • Unit - Replace Your Hero with a Paladin using The old unit's relative life and mana
      • Hero - Set Name of (Last replaced unit) to heroName
 
Status
Not open for further replies.
Top