• 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] How do I change the selection scale of a unit with a different skin Id

Level 6
Joined
Mar 9, 2023
Messages
75
Hello again! With two functions I am manipulating the unit skin and associated sizes to sell that it's a different unit. However, the selection scale doesn't wanna play fair.

Warlock uses ability > transforms into a large demon. The selection scale is visually small, but when mouse dragging to select it's large for a brief moment. Then, when the Demon (warlock) uses the ability to revert the transformation, the selection scale is larger than the Warlock's original selections scale. Currently in the code I don't have a selection scale change after the skin changes, and that's because it just didn't do anything.

And yes, the code isn't optimized.
JASS:
globals
     real warlockUnitScale
    real warlockUnitSelection
    integer warlockSkinId
endglobals

function Demon_To_Warlock takes nothing returns nothing
    if udg_warlockIsDemon == true then
    set udg_WarlockMana = 0
    call DisableTrigger( gg_trg_WarlockDrain )
    call SetUnitAnimation( udg_WarlockHero, "spell channel" )
    call PauseUnitBJ( true, udg_WarlockHero )
    call AddSpecialEffectTargetUnitBJ( "origin", udg_WarlockHero, "Desecrate_JFI.mdx" )

    call DestroyEffectBJ( udg_WarlockHand1 )
    call DestroyEffectBJ( udg_WarlockHand2 )
    call DestroyEffectBJ( udg_WarlockHand3 )

    call BlzSetUnitDiceNumber( udg_WarlockHero, 1, 0 )
    call BlzSetUnitDiceSides( udg_WarlockHero, 1, 0 )
    call UnitRemoveAbilityBJ( 'A0C4', udg_WarlockHero )
    call UnitRemoveAbilityBJ( 'A0C5', udg_WarlockHero )

    if GetUnitTypeId(udg_WarlockHero) == 'N056' then
        call SetUnitMoveSpeed( udg_WarlockHero, 270.00 )
    else
        call SetUnitMoveSpeed( udg_WarlockHero, 290.00 )
    endif
    call SetUnitInvulnerable( udg_WarlockHero, true )
    call PolledWait( 1.90 )
    call BlzStartUnitAbilityCooldown( udg_WarlockHero, 'A0C3', 240.00 )
    call SetUnitInvulnerable( udg_WarlockHero, false )
    call PauseUnitBJ( false, udg_WarlockHero )
    call SetUnitScale(udg_WarlockHero, warlockUnitScale, warlockUnitScale, warlockUnitScale)
    call SetUnitAnimation( udg_WarlockHero, "spell slam" )
    call BlzSetUnitSkin( udg_WarlockHero, warlockSkinId )

    call SetUnitVertexColorBJ( udg_WarlockHero, 100.0, 100.00, 100.00, 0 )

    set udg_WarlockHero = null
    set udg_warlockIsDemon = false
endif
endfunction

function Warlock_To_Demon takes nothing returns nothing
        set udg_warlockIsDemon = true
        set warlockSkinId = GetUnitTypeId(udg_WarlockHero)
        set warlockUnitScale = BlzGetUnitRealField(udg_WarlockHero, UNIT_RF_SCALING_VALUE)
        set warlockUnitSelection = BlzGetUnitRealField(udg_WarlockHero, UNIT_RF_SELECTION_SCALE)

        call SetUnitInvulnerable( udg_WarlockHero, true )
        call AddSpecialEffectTargetUnitBJ( "origin", udg_WarlockHero, "Desecrate_JFI.mdx" )
        call PauseUnitBJ( true, udg_WarlockHero )
        call SetUnitAnimation( udg_WarlockHero, "spell channel" )
        call PolledWait( 1.85 )
        call SetUnitInvulnerable( udg_WarlockHero, false )
        call PauseUnitBJ( false, udg_WarlockHero )
        call SetUnitScale(udg_WarlockHero, 2.0, 2.0, 2.5)
        call BlzSetUnitSkin( udg_WarlockHero, 'N04O' )
        call SetUnitVertexColorBJ( udg_WarlockHero, 100.0, 40.00, 40.00, 0 )

        set udg_WarlockMana = 0
        call EnableTrigger( gg_trg_WarlockDrain )
        call KillSoundWhenDoneBJ( GetLastPlayedSound() )
        call PlaySoundFromOffsetBJ( udg_Sound[GetRandomInt(885, 888)], 100, 0 )

        call AddSpecialEffectTargetUnitBJ( "right hand", udg_WarlockHero, "Affliction040.mdx" )
        set udg_WarlockHand1 = GetLastCreatedEffectBJ()
        call AddSpecialEffectTargetUnitBJ( "left hand", udg_WarlockHero, "Affliction040.mdx" )
        set udg_WarlockHand2 = GetLastCreatedEffectBJ()
        call AddSpecialEffectTargetUnitBJ( "origin", udg_WarlockHero, "CursedSTR097.mdx" )
        set udg_WarlockHand3 = GetLastCreatedEffectBJ()
        call SetUnitAnimation(udg_WarlockHero,"birth")

        call BlzSetUnitDiceNumber( udg_WarlockHero, 6, 0 )
        call BlzSetUnitDiceSides( udg_WarlockHero, 6, 0 )
        call UnitAddAbilityBJ( 'A0C4', udg_WarlockHero )
        call UnitAddAbilityBJ( 'A0C5', udg_WarlockHero )
        call SetUnitMoveSpeed( udg_WarlockHero, 200.00 )
endfunction

I have tried solutions such as
JASS:
call BlzSetUnitRealField(udg_WarlockHero, UNIT_RF_SELECTION_SCALE, warlockUnitSelection)

And having debugged the real values, I have noticed that the fields do change. Just not the visual indicator. Any ideas on what to try next?
 
It seems like updating UNIT_RF_SELECTION_SCALE only updates the health/mana bar scale and a few other indicators (e.g. target indicator)--but doesn't seem to affect the actual selection circle.

I think your best bet is to use morphing. You can either use bear form/metamorphosis for your ability directly, or if you need to update this passively (i.e. you want to trigger it without the user taking any action), you can follow this tutorial: Hero passive transformation
 
Top