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

[JASS] Changing a hero proper name.....

Status
Not open for further replies.
Level 2
Joined
Apr 30, 2005
Messages
3
I jumped into JASS as soon as i found out i couldn't change hero proper names in the game....the trig editor has no actions that do this....i.e. if i had a paladin hero summoned, his name would be like "arthur the pure", i need a JASS pro who can make it so that if someone types -heroname "name" then his hero's name will change to whatever he typed in..like -heroname "dork" and his hero would be named dork instead of arthur blah blah. :roll: PLZ HELP ME
 
Level 4
Joined
Aug 30, 2004
Messages
58
The reason every one keeps asking is becouse its such a pointless item (the name) that it should be simple to change with triggers. You can change every thing about a hero from size, color, stats, damage, speed, owner, abilitys, ect. All BUT the stupid name that holds no barring on the unit it self. GRRRR!! Its getting me angry just thinking about it.
 
Level 7
Joined
May 6, 2005
Messages
390
-=Emergenzy=- said:
This question has been asked so many times! you can't change the heroes name with GUI or JASS :!:

Yes it has been asked many times and are answered wrong nearly every time.

You ARE able to change a Hero's proper name just only in a dumb way, and only to a name you encoded i OE.

I made a code some time ago can post it if you want.
 
Level 11
Joined
Aug 15, 2004
Messages
710
Blade.dk2 said:
-=Emergenzy=- said:
This question has been asked so many times! you can't change the heroes name with GUI or JASS :!:

Yes it has been asked many times and are answered wrong nearly every time.

You ARE able to change a Hero's proper name just only in a dumb way, and only to a name you encoded i OE.

I made a code some time ago can post it if you want.
POST IT THEN :p
 
Level 7
Joined
May 6, 2005
Messages
390
Ok here it is. It took me some time to look in all my test maps to find it :) ..

As said it's primitive (based on replacement). It needs the Handle Vars since loops bugged it out (and no, it wasn't the loop itself that was wron, it just ran a max of 573 times for some weird reason). Refer to the unit as LastCreatedGoldMine.

Note that it may add suffixes to heroes names like if it should be "Harald" it may be "Harald IV" or something like that. Anyways, here is the functions:

JASS:
function SetHeroProperName_Child takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = GetHandleUnit(t, "Hero")
    local unit n = ReplaceUnitBJ(u, GetUnitTypeId(u), bj_UNIT_STATE_METHOD_RELATIVE)
    call SetHandleHandle(t, "Hero", n)
    if (GetHandleString(t, "Name") == SubStringBJ(GetHeroProperName(n), 1, StringLength(GetHandleString(t, "Name")))) then
        set bj_lastHauntedGoldMine = n
        call FlushHandleLocals(t)
        call DestroyTimer(t)
    endif
    set t = null
    set u = null
    set n = null
endfunction

function SetHeroProperName takes unit whichHero, string newName returns nothing
    local timer t = CreateTimer()
    call SetHandleHandle(t, "Hero", whichHero)
    call SetHandleString(t, "Name", newName)
    call TimerStart(t, 0.00, true, function SetHeroProperName_Child)
    set whichHero = null
    set t = null
endfunction
 
Level 2
Joined
Aug 21, 2004
Messages
9
im sorry i am absolutoly no good at Jass, and probably never will be, is there any possible way i can use triggers to change a heroes proper name, without needing to replace the unit?

Help would be much abliged.
 
Level 3
Joined
Mar 2, 2006
Messages
40
cpuguy said:
im sorry i am absolutoly no good at Jass, and probably never will be, is there any possible way i can use triggers to change a heroes proper name, without needing to replace the unit?

Help would be much abliged.
JASS isn't as complicated as you think. And to call a JASS function is really easy. Here's an example how to change the hero's name :

First, copy the handle vars(http://www.wc3jass.com/viewtopic.php?p=2327) in the Custom Script section of your map (Click on the name of the map above the triggers to see it ). Then copy blade.dk's code there. And to change the proper name of a hero in some trigger, New Action - Custom Script - and write : call SetHeroProperName(someunit, "somename").
 
Level 6
Joined
Feb 18, 2005
Messages
263
sry the function seems somewhat complex, but i will try to explain it.

it takes the unit-object, including all it's specific attributes like 'name'.
then the function sets a new value for the attribute 'name' to be inserted into the unit.
now it comes: it replaces the unit with one with (exactly i believe) the same attributes, but with the new name.
i guess it needs to replace for that is the only way to change that attribute...
i may be wrong and i'll take a look at it meself, but that's how it looks like in that function...

- Razul
 
Level 9
Joined
Aug 27, 2004
Messages
471
...I just noticed the child function was a timer. It looks like this swaps the unit until its propor name is matching?

And correct me if I'm wrong, but the propor name has to be preset into the hero-unit right? You cant just set the name to any random thing?
 
Status
Not open for further replies.
Top