• 🏆 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!

Trigger Name help

Status
Not open for further replies.
Level 7
Joined
Jul 11, 2008
Messages
104
Say there's a mercenary shop, and in that shop you can buy either a grunt or a footman. How do I make it so that when someone buys a footman, it changes their name so it has (Footman) in front of it?

Example:

Bob (Footman): Hello
 
Something like this:
  • NameChange
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Mercenary Camp (Ashenvale)
    • Actions
      • Player - Set name of (Owner of (Sold unit)) to ((Name of (Owner of (Sold unit))) + ( ( + ((Name of (Sold unit)) + ))))
It just involves a lot of concatenating strings.
 
Level 7
Joined
Jul 11, 2008
Messages
104
Something like this:
  • NameChange
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Mercenary Camp (Ashenvale)
    • Actions
      • Player - Set name of (Owner of (Sold unit)) to ((Name of (Owner of (Sold unit))) + ( ( + ((Name of (Sold unit)) + ))))
It just involves a lot of concatenating strings.

This worked. Thanks man, one more question though...
How do I make it so that if the footman dies, it will change his name back?
 
My point, you need to use variables or something like that, try experimenting. It can be done if you don't want the original name but... you do.

Hmm.. I'm not sure what you mean. It adds to the players name " (<Name of sold unit>) " eg: " (Footman) ". So if their name was "Hippo", then it would change their name to:
"Hippo (Footman)".

This worked. Thanks man, one more question though...
How do I make it so that if the footman dies, it will change his name back?

I made some quick codes that might work:
  • OnMapInit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set MyHash = (Last created hashtable)
  • NameChange
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Mercenary Camp (Ashenvale)
    • Actions
      • Hashtable - Save (Name of (Owner of (Sold unit))) as 0 of (Player number of (Owner of (Sold unit))) in MyHash
      • Player - Set name of (Owner of (Sold unit)) to ((Name of (Owner of (Sold unit))) + ( ( + ((Name of (Sold unit)) + ))))
      • Unit Group - Add (Sold unit) to SoldGroup
  • ResetName
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in SoldGroup) Equal to True
    • Actions
      • Player - Set name of (Owner of (Triggering unit)) to (Load 0 of (Player number of (Owner of (Triggering unit))) from MyHash)
      • Unit Group - Remove (Triggering unit) from SoldGroup
 
Status
Not open for further replies.
Top