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. PLZ HELP ME
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.
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:
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
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?
cpuguyim 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").
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...