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

[Trigger] How to add (unit) name infront of player name?

Status
Not open for further replies.

Intro

alright so im FF7 project-G and im usualy in chat(alot) or helping people in request/WE helper forum whenever i can. I am currently making a map the involves heroes fighting each other like DOTA(i hate to make that referance but i used dota's layout for my map so i guess i have to), but i have remade ALL the items, hero's, and spell's. Sorry i cant provide screenshots atm because my crew is working on the map and an updated version is not currently in my possession.

Request

Alright so this would probably be a JASS trigger but im not sure, because i have looked around and i saw a similar thread to this but that only let people change their name using a substring -xxxxx trigger. I would preffer this in GUI but i can handle JASS also.

What it should be like

alright so what it should be like is basicly if a player chooses (x) hero(this is going to use an array im thinking) and they get their hero's name put infront of their's. EX: (Slayer)FF7 project-G
something around the lines like that. There will be 12players total including red and green but i dont think we need to add them seeing as they are AI and cant type.

Credits+Rep will be given of course
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Well basically what you do is: make a unit-type array and a string array.

At map initialization, you set the unit-type array to the types of all heroes, for instance:
set HeroType[0] = Paladin
set HeroType[1] = Mountain King
...

set HeroName[0] = "Paladin"
set HeroName[1] = "Mountain King"

In the hero selection trigger, whenever a player chooses a hero, you loop through the hero array and return the index of the hero, for instance if you chose a Mountain king, you check the whole array and you'll notice mountain king is at position 1. You remember number 1.
When this is done, finally you change the player name and change it into
HeroName[the index you found] + Current playername

If you selected MK this becomes: Mountain King Eleandor
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Global variables:
Hero array of size (maximum heroes)
String array of size (maximum heroes)
integer called "index"

  • Events: don't know, when you're selecting a hero (depends on how you select heroes)
  • Conditions: none
  • Actions
    • For each integer A from 0 to (maximum heroes) do
    • If (Unit type of chosen hero) equal to HeroTypes[Integer A] Then
      • Set index = Integer A
    • Else
      • Do nothing
    • Set the name of (player owning the chosen hero) to Concatenation(StringTypes[index] + Player name of (player owning the chosen hero))
In the case of random heroes, set index = Random Integer between 0 and maximum heroes
 
this would be for unit going into region selection.

  • Actions
    • For each (Integer A) from 0 to MaxHeroNumber, do (Actions)
      • Loop - Actions
        • Custom script: set bj_wantDestroyGroup = true
        • Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Triggering unit))) and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Unit-type of (Picked unit)) Equal to HeroName[(Integer A)]
              • Then - Actions
                • Player - Set name of (Owner of (Triggering unit)) to ((String(HeroName[(Integer A)])) + (Name of (Owner of (Triggering unit))))
              • Else - Actions
 
ok i am a trigger noob i just know the basics of what do what and such, so you guys could explain it more(just_spectating) not sure what you mean, and i would appreciate if you guys could put this into a simple map or post them ehre and give EXACT details about out because i dont know how to do random numbers from x-x and such and im kinda busy modeling atm so it will be appreciated much much more if you guys could
EDIT-im selecting heroes from a tavern and yes there is a random hero choosing event using -random
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
In fact, it's much easier I see now. I forgot about a function "Unit Name"...

The map I attached I've done VERY quickly, didn't even test it but it should work. Currently it doesn't work for multiple players, but you're 1 click away from making it work for multiple players.
 

Attachments

  • tmp.w3x
    17 KB · Views: 19
Status
Not open for further replies.
Top