• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[JASS] Hero Propername

Status
Not open for further replies.
Level 7
Joined
Dec 30, 2008
Messages
72
Hi, well I am in the middle of finishing up an ability (that is already on the site - here) but have run into an extremely unpleasant bug

the hero's propername is incorrect as it is randomised, my question is
Is there a way to change the hero's propername, because you can "get" propername... how do you "set" propername?

Also on the side, is there an easy way to get rid of the hero portrait in script without going through editor or making the hero neutral hostile and changing the colour...

JASS:
// Warp Jump
// 
// By Ross Dubery
// 
// Teleports the Warper a long distance, allowing him to move rapidly about the map. 
// Whilst warping the Warper is vulnerable to attacks. 
// Warp time depends on distance travelled. 
// Deals damage on arrival in an area based on distance travelled.
//
// There are two things that require changing
// 1 - The ability code, highlighted below (A001)
// 2 - The ability code variable (A001)

//
// Checks for ability, change 'A001' to your spell ID
//
function warp_jump_conditions takes nothing returns boolean
    return  ( GetSpellAbilityId() == 'A001' )
endfunction

//
// Main Ability
//
function warp_jump_actions takes nothing returns nothing

//
//Initialise
//
    //Local Variables
    local unit LastUnit
    local unit NewUnit
    local real Distance
    local real Scale
    local real Area
    local real Damage
    local real Phase
    local real SleepLen
    local real Index
    local real IndexInc
    local real TransTicks
    local boolean FixedDamage
    local boolean FixedArea
    local boolean FixedPhase
    local boolean Transparency
    local integer Ability
    local integer LastTrans
    local integer NewTrans
    local integer MinTrans
    local integer TickAmount
    local integer NumTicks
    local effect StompEffect
    local effect LastEffect
    local effect NewEffect
    local location TargetPos
    local location UnitPos 
    
    //Define the scale of distance
    set Scale = 800.0 // Recomended scale
    
    //Choose whether damage, phase time and area are fixed or not
    set FixedDamage = false // Scale damage
    set FixedArea = false // Scale area
    set FixedPhase = false // Scale phase
    
    //Choose if you want the unit to fade in and out or not
    set Transparency = true // Scale transparency
    
    //If you said true for any of the above, modify these values
    set Damage = 100.00 // The damage dealt on arrival || If damage is negative it will heal units
    set Area = 200.00 // The area the damage is dealt in
    set Phase = 1.00 // Phase is not decreased at all
    set MinTrans = 55 // The most transparent a unit can go
    // If phase is > 1.00 it will decrease phase time
    // If phase is < 1.00 it will increase phase time
    // The lowest phase can go is 0.01
    // 0 < MinTrans < 255 
    
    //Define the ability code, replace 'A001' with your abiltiy code
    set Ability = 'A001' // Ability code
    
    //Leave these alone
    set LastUnit = GetSpellAbilityUnit()
    set UnitPos = GetUnitLoc(LastUnit)
    set TargetPos = GetSpellTargetLoc()
    set Distance = (DistanceBetweenPoints(TargetPos, UnitPos)/Scale)
    set IndexInc = 0.05
    
    //If damage, phase time and area are not fixed use the following formulae
    if ( not FixedDamage) then
        set Damage = ( 10 * Distance * I2R(GetUnitAbilityLevel(LastUnit,Ability)) )
    endif
    if (not FixedArea) then
        set Area = ( I2R(GetUnitAbilityLevel(LastUnit,Ability)) * 100.00 )
    endif
    if (not FixedPhase) then
        set Phase = GetUnitAbilityLevel(LastUnit,Ability)
    endif
    
    //Ensure phase and area are greater then 0
    // and TransTicks is greater then 6 and less then 120
    if (Phase < 0.01) then
        set Phase = 0.01
    endif
    if (Area < 0.01) then
        set Area = 0.01
    endif
        if (MinTrans < 0) then
        set MinTrans = 0
    else
        if (MinTrans > 255) then
            set MinTrans = 255
        endif
    endif    
    
    //Calculate Sleep Length and Tick Amount
    if (Transparency) then
        set SleepLen = 0.27
        set TransTicks = SleepLen*(Distance/Phase)
        
        //Calculate Sleep Length and Tick Amount  
        set TickAmount = (R2I((255-MinTrans)/(TransTicks/IndexInc)))   
    else
        set SleepLen = (Distance/Phase)
        if(SleepLen < 0.27) then
            set SleepLen = 0.27
        endif
    endif
      
    //Preload resources
    call Preload("Abilities\\Spells\\Orc\\Voodoo\\VoodooAuraTarget.mdl")
    call Preload("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl")
    

//
// Body of Ability
//

    // Damage the target location with magical damage
    call UnitDamagePoint( LastUnit, 0, Area,  GetLocationX(TargetPos),  GetLocationY(TargetPos), Damage, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS )
    set StompEffect = AddSpecialEffectLoc( "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", TargetPos )
    call DestroyEffect( StompEffect )
    
    // Move casting unit to the target location
    call SetUnitPosition( LastUnit, GetLocationX(TargetPos), GetLocationY(TargetPos))
    
    // Remove positive and negative magical buffs and aura buffs
    call UnitRemoveBuffsEx(LastUnit, true, true, true, false, false, true, true)
    
    // Create "partial" unit from casting unit stats
    set NewUnit = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), GetUnitTypeId(LastUnit), GetLocationX(UnitPos), GetLocationY(UnitPos), GetUnitFacing(LastUnit) )
    call SetUnitColor( NewUnit, GetPlayerColor(GetOwningPlayer(LastUnit)) ) 
    call SetUnitUseFood(NewUnit, false) 
    
    // Check if casting unit is a hero || Will not copy items
    if (IsHeroUnitId(GetUnitTypeId(LastUnit))) then
        call SetHeroLevel(NewUnit, GetHeroLevel(LastUnit), false)
        call ModifyHeroSkillPoints(NewUnit, bj_MODIFYMETHOD_SET, GetHeroSkillPoints(LastUnit))        
    endif
    
    // Set Life and Mana 
    call SetUnitState(NewUnit, UNIT_STATE_MANA, GetUnitState(NewUnit, UNIT_STATE_MAX_MANA) * RMaxBJ(0,GetUnitStatePercent(LastUnit, UNIT_STATE_MANA, UNIT_STATE_MAX_MANA)) * 0.01)   
    call SetUnitState(NewUnit, UNIT_STATE_LIFE, GetUnitState(NewUnit, UNIT_STATE_MAX_LIFE) * RMaxBJ(0,GetUnitStatePercent(LastUnit, UNIT_STATE_LIFE, UNIT_STATE_MAX_LIFE)) * 0.01)
    
    // Add the warp effects
    set NewEffect = AddSpecialEffectTarget( "Abilities\\Spells\\Orc\\Voodoo\\VoodooAuraTarget.mdl", NewUnit, "overhead" )
    set LastEffect = AddSpecialEffectTarget( "Abilities\\Spells\\Orc\\Voodoo\\VoodooAuraTarget.mdl", LastUnit, "overhead"  )
    
    // Pauses the units and animation indefinitely and make them partially transparant
    call PauseUnit( LastUnit, true )
    call PauseUnit( NewUnit, true )
    call SetUnitTimeScale( LastUnit, 0.00 )
    call SetUnitTimeScale( NewUnit, 0.00 )
    
    // Sleep for a while, depending on the level of the ability and distance travelled
    // Ensure that the sleep goes for 0.27 seconds
    
    //Loop through transticks if transparency is enabled
    if (not Transparency) then
        call TriggerSleepAction(SleepLen)
    else
        set Index = 0.00
        set LastTrans = MinTrans
        set NewTrans = 255
        loop
            exitwhen (Index > TransTicks)
            call SetUnitVertexColor(LastUnit, 255, 255, 255, LastTrans)
            call SetUnitVertexColor(NewUnit, 255, 255, 255, NewTrans)
            set LastTrans = LastTrans + TickAmount
            set NewTrans = NewTrans - TickAmount
            call TriggerSleepAction(SleepLen)
            set Index = Index + IndexInc
        endloop
        call SetUnitVertexColor(LastUnit, 255, 255, 255, LastTrans)
        call SetUnitVertexColor(NewUnit, 255, 255, 255, NewTrans)
    endif
    
    // Unpause the casting unit
    call SetUnitTimeScalePercent( LastUnit, 100.00 )
    call PauseUnit( LastUnit, false )
    call SetUnitVertexColor(LastUnit, 255, 255, 255, 255)
    
    // Remove warp effects
    call DestroyEffect( LastEffect )
    call DestroyEffect( NewEffect )
    
    // Check if unit died in transit
    if ( not(GetUnitState(NewUnit, UNIT_STATE_LIFE) <= 0) ) then
        if ( not(GetUnitState(LastUnit, UNIT_STATE_LIFE) <= 0) ) then
            call SetUnitState(LastUnit, UNIT_STATE_LIFE, GetUnitState(LastUnit, UNIT_STATE_MAX_LIFE) * RMaxBJ(0,RMinBJ(GetUnitStatePercent(LastUnit, UNIT_STATE_LIFE, UNIT_STATE_MAX_LIFE), GetUnitStatePercent(NewUnit, UNIT_STATE_LIFE, UNIT_STATE_MAX_LIFE))) * 0.01)
            call RemoveUnit( NewUnit )
        endif
    else
        call SetUnitExploded(LastUnit, true)
        call KillUnit(LastUnit)
    endif
    
    // Clean up
    call RemoveUnit( NewUnit )
    call RemoveLocation(TargetPos)
    call RemoveLocation(UnitPos)
    set LastUnit = null
    set NewUnit = null
    set StompEffect = null
    set NewEffect = null
    set LastEffect = null
    set TargetPos = null
    set UnitPos = null
endfunction

//
// Anti Leak Filter used to recover trigger leaks
//
function AntiLeakFilter takes nothing returns boolean
    return true
endfunction

//===========================================================================
function InitTrig_Warp_Jump takes nothing returns nothing
    local trigger WarpJump
    local filterfunc filter
    local integer index
    set WarpJump = CreateTrigger(  )
    set filter = Filter(function AntiLeakFilter)
    set index = 0
    loop
        call TriggerRegisterPlayerUnitEvent(WarpJump, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, filter)
        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddCondition( WarpJump, Condition( function warp_jump_conditions ) )
    call TriggerAddAction( WarpJump, function warp_jump_actions )
    call DestroyFilter(filter)
    set WarpJump = null
    set filter = null
endfunction
 
Level 9
Joined
Nov 28, 2008
Messages
704
The only way possible that I can think of is to keep creating the hero and checking it's name until you get the one you want, then remove the rest.

Very silly of blizzard to leave out such a simple and useful function to change a unit's name. It's not like it would be hard (I think :p).

What do you mean by Hero Script? If you mean the portrait in the top left, I believe - dont quote me - that there might be a file in the MPQ you could overwrite. Unsure on that though.
 
Level 7
Joined
Dec 30, 2008
Messages
72
see, the ability is creating a unit from the casting unit, so i can't edit the object (you don't need to go into the MPQ for that...>_>) I attmepted this, however it is not comparing the strings... there is a similar problem in C so i figure you have to use a StrCmp function to compare them, however I can't seem to find such a function... T_T
JASS:
if (IsHeroUnitId(GetUnitTypeId(LastUnit))) then    
        loop
            exitwhen (GetHeroProperName(NewUnit) == GetHeroProperName(LastUnit))
            call RemoveUnit(NewUnit)
            set NewUnit = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), GetUnitTypeId(LastUnit), GetLocationX(UnitPos), GetLocationY(UnitPos), GetUnitFacing(LastUnit) )
        endloop
 
Level 7
Joined
Dec 30, 2008
Messages
72
How would not removing them help??
//
Propername == Propername
remove Propername
set Propername = Othername
//

that is the logic...

However, wc3 automatically places roman numerals after duplicate names... so it is impossible and i hearby announce that i give up =P

Actually this brings further problems... as everytime he uses the ability a new name is given.... T_T
ooo i wonder if it will roll over eventually XD
 
Last edited:
Level 9
Joined
Nov 28, 2008
Messages
704
If you are trying to create a hero with the same name as one already in existence, you will fail. If you want one with roman numerals, use the SubString() function.

And C++ == problems are not the same in WC3 because WC3 uses the C++ string class (or something close to!), which DOES allow you to do == instead of weird functions with the char* type.
 
Status
Not open for further replies.
Top