1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

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

Discussion in 'Triggers & Scripts' started by Couchdweller, Apr 30, 2005.

  1. Couchdweller

    Couchdweller

    Joined:
    Apr 30, 2005
    Messages:
    3
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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
     
  2. -=Emergenzy=-

    -=Emergenzy=-

    Joined:
    Jul 2, 2004
    Messages:
    471
    Resources:
    20
    Models:
    20
    Resources:
    20
    This question has been asked so many times! you can't change the heroes name with GUI or JASS :!:
     
  3. XelNaga

    XelNaga

    Joined:
    Aug 30, 2004
    Messages:
    58
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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.
     
  4. Blade.dk2

    Blade.dk2

    Joined:
    May 6, 2005
    Messages:
    441
    Resources:
    0
    Resources:
    0
    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.
     
  5. Taur

    Taur

    Joined:
    Aug 15, 2004
    Messages:
    719
    Resources:
    5
    Models:
    3
    Maps:
    2
    Resources:
    5
    POST IT THEN :p
     
  6. Blade.dk2

    Blade.dk2

    Joined:
    May 6, 2005
    Messages:
    441
    Resources:
    0
    Resources:
    0
    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:

    Code (vJASS):
    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
     
  7. cpuguy

    cpuguy

    Joined:
    Aug 21, 2004
    Messages:
    9
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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.
     
  8. MeanMachine

    MeanMachine

    Joined:
    Mar 2, 2006
    Messages:
    40
    Resources:
    1
    Models:
    1
    Resources:
    1
    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").
     
  9. Modeler

    Modeler

    Joined:
    Aug 27, 2004
    Messages:
    496
    Resources:
    0
    Resources:
    0
    How does that swap out the name??? I'm lost with that function blade -,-.
     
  10. Lord Raszul

    Lord Raszul

    Joined:
    Feb 18, 2005
    Messages:
    263
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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
     
  11. Modeler

    Modeler

    Joined:
    Aug 27, 2004
    Messages:
    496
    Resources:
    0
    Resources:
    0
    ...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?