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

[GUI] Simple Name Prefixes

Status
Not open for further replies.
Level 12
Joined
May 20, 2009
Messages
822
Very simple GUI triggers that makes use of the new functions to set unit names so you can have prefixes in the Object Editor. Just something that I thought would be nice to do and figured I'd share it in case it would save anyone some time making it themselves.

Notes:
1. All units have to have the same length for their prefixes.

2. Use "Prefix_Identifier" to set a certain substring to check for. If a unit has this in their name at the very beginning, then they are considered to have a Prefix. If not, they are ignored entirely. This makes units without a prefix not have their names "Cropped"

The length of this Prefix_Identifier is also considered for the length of the string, so adjust SubStart accordingly.

3. You can adjust how long the prefixes can be by setting the "Prefix_SubStart" variable.

I'm not really sure how else I can go about recognizing a given part of a string so that it can cut out those parts instead of having a fixed length for all prefixes.

Suggestions and ideas to improve it are welcome. :D

Hopefully something like this won't be needed for long and we'll get real editor prefixes akin to SC2, though.

Here is an example of how I am setting prefixes right now with use of this:

unknown.png


EDIT:

Pretty easy to set up something new to make it so units without Prefixes are ignored. Map updated.

EDIT 2: Here's the triggers.

  • Init Vars
    • Events
    • Conditions
    • Actions
      • Set PrefixInt[99] = 0
      • Set RemovedPrefix[99] = Peasant
      • Set Prefix_SubStart = 0
      • Set Prefix_Identifier = P!
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Entire map)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Substring((Name of (Picked unit)), 1, (Length of Prefix_Identifier))) Equal to Prefix_Identifier
            • Then - Actions
              • Unit - Set Name of (Picked unit) to (Substring((Name of (Picked unit)), (Prefix_SubStart + (Length of Prefix_Identifier)), (Length of (Name of (Picked unit)))))
              • Unit - Set Name of (Picked unit) to (Substring((Name of (Picked unit)), (Prefix_SubStart + (Length of Prefix_Identifier)), (Length of (Name of (Picked unit)))))
              • Set PrefixInt[0] = (PrefixInt[0] + 1)
              • Set RemovedPrefix[PrefixInt[0]] = (Unit-type of (Picked unit))
            • Else - Actions
      • For each (Integer PrefixInt[10]) from 1 to PrefixInt[0], do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units of type RemovedPrefix[PrefixInt[10]]) and do (Actions)
            • Loop - Actions
              • Unit - Set Name of (Picked unit) to (Name of (Picked unit))
  • On Unit Create
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
    • Actions
      • For each (Integer PrefixInt[1]) from 1 to PrefixInt[0], do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to RemovedPrefix[PrefixInt[1]]
            • Then - Actions
              • Set PrefixInt[2] = 1
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PrefixInt[2] Equal to 0
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Substring((Name of (Triggering unit)), 1, (Length of Prefix_Identifier))) Equal to Prefix_Identifier
            • Then - Actions
              • Unit - Set Name of (Triggering unit) to (Substring((Name of (Triggering unit)), (Prefix_SubStart + (Length of Prefix_Identifier)), (Length of (Name of (Triggering unit)))))
              • Unit - Set Name of (Triggering unit) to (Substring((Name of (Triggering unit)), (Prefix_SubStart + (Length of Prefix_Identifier)), (Length of (Name of (Triggering unit)))))
              • Set PrefixInt[0] = (PrefixInt[0] + 1)
              • Set RemovedPrefix[PrefixInt[0]] = (Unit-type of (Triggering unit))
            • Else - Actions
        • Else - Actions
          • Set PrefixInt[2] = 0

Note: The top one of those "Set Name of Unit" actions is "Set Name" and the other is "Set Name (All)"

You do need both of them because "Set Name (All)" doesn't appear to set the name of the Triggering Unit, just all units that will spawn in beyond the time it is set of the same unit-type.

EDIT 3: Fixed bug where only one of each unit-type being preplaced on the map would be renamed.
 

Attachments

  • SimpleNamePrefixes.w3x
    18.3 KB · Views: 74
Last edited:
Status
Not open for further replies.
Top