• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Floating Text Doesn't Appear

Status
Not open for further replies.
Level 6
Joined
Jul 2, 2008
Messages
156
Here's my desired effect:

Unit cast spell on another unit
Unit becomes zombie
Floating text appears over the changed unit reading "Villager Zombified!"
Zombie moves to rally point of casting unit.

In GUI this was easy to accomplish with no problems whatsoever, but when I redid the trigger in JASS, the floating text has refused to appear.

My Code:
JASS:
function Trig_Conversion_Actions takes nothing returns nothing
    local unit u= GetSpellTargetUnit()
    local player p= GetOwningPlayer(GetSpellAbilityUnit())
    local unit t= udg_TowerOfSouls[GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))]
    call IssueImmediateOrder( u, "stop" )
    call UnitAddAbility( t, 'A002' )
    call TriggerSleepAction( 1.00 )
    call IssueTargetOrder( t, "darkconversion", u )
    call TriggerSleepAction( 1.00 )
    call AddHeroXPSwapped( 5, GetSpellAbilityUnit(), true )
    call UnitRemoveAbility( t, 'A002' )
    call SetUnitOwner( u, p, true )
    call ReplaceUnitBJ( u, 'n000', bj_UNIT_STATE_METHOD_RELATIVE )
    set u= GetLastReplacedUnitBJ()
    call SetUnitPathing( u, true )
    call TriggerSleepAction( 0.50 )
    call CreateTextTagUnitBJ( "|cffff0000Villager Zombified!|r", u, 0, 8.00, 100, 100, 100, 0 )
    call SetTextTagVelocity( GetLastCreatedTextTag(), 64, 90 )
    call SetTextTagPermanent( GetLastCreatedTextTag(), false )
    call SetTextTagLifespan( GetLastCreatedTextTag(), 2.00 )
    call TriggerSleepAction( 1.00 )
    if ((GetRallyX(t) != 0) or (GetRallyY(t) != 0)) then
    call IssuePointOrder( u, "move", GetRallyX(t), GetRallyY(t) )
    else
    endif
endfunction

At first I suspected that the trigger was going too fast, so I added a
JASS:
TriggerSleepAction( 0.50 )
after the variable u changes, but it didn't solve anything.

I'm sure the problem is real obvious and I'm just being a ditz, but I appreciate the help all the same. :bored:
 
Level 6
Joined
Mar 20, 2008
Messages
208
You need to set the text tag size in decimal, anything under 1.
I find .023 works out ok.
JASS:
function CreateTextTagUnitBJ takes string s, unit whichUnit, real zOffset, real size, real red, real green, real blue, real transparency returns texttag
    set bj_lastCreatedTextTag = CreateTextTag()
    call SetTextTagTextBJ(bj_lastCreatedTextTag, s, size)
    call SetTextTagPosUnitBJ(bj_lastCreatedTextTag, whichUnit, zOffset)
    call SetTextTagColorBJ(bj_lastCreatedTextTag, red, green, blue, transparency)

    return bj_lastCreatedTextTag
endfunction
 
Level 4
Joined
Apr 16, 2009
Messages
85
You need to set the text tag size in decimal, anything under 1.
I find .023 works out ok.

i think size is fine as he uses the BJ function and it sets it to a lower value correctly but he uses the native SetTextTagVelocity function and 64/90 are much to high values (64*0.071/128=0.0355 would be normal)

heres a (i hope leakless) version that should work (didn't test it though):

JASS:
function Trig_Conversion_Actions takes nothing returns nothing
    local unit u = GetSpellTargetUnit()
    local unit c = GetSpellAbilityUnit()
    local player p = GetOwningPlayer(c)
    local unit t = udg_TowerOfSouls[GetPlayerId(p) + 1]
    local integer index
    local item indexItem
    local boolean wasHidden
    local texttag tt
    call IssueImmediateOrder( u, "stop" )
    call UnitAddAbility( t, 'A002' )
    call TriggerSleepAction( 1.00 )
    call IssueTargetOrder( t, "darkconversion", u )
    call TriggerSleepAction( 1.00 )
    call AddHeroXP( c, 5,  true )
    call UnitRemoveAbility( t, 'A002' )
    call SetUnitOwner( u, p, true )
    
    set wasHidden = IsUnitHidden(u)
    call ShowUnit(u, false)
    set c = CreateUnit(GetOwningPlayer(u), 'n000', GetUnitX(u), GetUnitY(u), GetUnitFacing(u))
    if (GetUnitState(u, UNIT_STATE_MAX_LIFE) > 0) then
            call SetUnitState(c, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_LIFE) / GetUnitState(u, UNIT_STATE_MAX_LIFE) * GetUnitState(c, UNIT_STATE_MAX_LIFE))
        endif
        if (GetUnitState(u, UNIT_STATE_MAX_MANA) > 0) and (GetUnitState(c, UNIT_STATE_MAX_MANA) > 0) then
            call SetUnitState(c, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MANA) / GetUnitState(u, UNIT_STATE_MAX_MANA) * GetUnitState(c, UNIT_STATE_MAX_MANA))
        endif
    
    call SetResourceAmount(c, GetResourceAmount(u))

    if (IsUnitType(u, UNIT_TYPE_HERO) and IsUnitType(c, UNIT_TYPE_HERO)) then
        call SetHeroXP(c, GetHeroXP(u), false)
        set index = 0
        loop
            set indexItem = UnitItemInSlot(u, index)
            if (indexItem != null) then
                call UnitRemoveItem(u, indexItem)
                call UnitAddItem(c, indexItem)
            endif
            set index = index + 1
            exitwhen index >= bj_MAX_INVENTORY
        endloop
    endif

    if wasHidden then
        call KillUnit(u)
        call RemoveUnit(u)
    else
        call RemoveUnit(u)
    endif

    call SetUnitPathing( c, true )
    call TriggerSleepAction( 0.50 )
    set tt = CreateTextTag()
    call SetTextTagText(tt, "|cffff0000Villager Zombified!|r", 0.0184)
    call SetTextTagPosUnit(tt, c, 0)
    call SetTextTagColor(tt, 255.0, 255.0, 255.0, 255.0)
    call SetTextTagVelocity(tt, 0, 0.0355)
    call SetTextTagLifespan( tt, 2.00 )
    call SetTextTagPermanent( tt, false )
    
    call TriggerSleepAction( 1.00 )
    if ((GetRallyX(t) != 0) or (GetRallyY(t) != 0)) then
        call IssuePointOrder( c, "move", GetRallyX(t), GetRallyY(t) )
    endif
    
    set c = null
    set t = null
    set u = null
    set tt = null
    set indexItem = null
endfunction
 
Last edited:
Level 6
Joined
Jul 2, 2008
Messages
156
Wow okay that is a lot more than I wanted, lol.
That entire middle chunk that you added would be useless for my code.

I am gonna use more local variables though.
And I'm gonna try out the texttag you suggested.

EDIT:
My attempt of taking what I needed from your code ended in failure, so I just tried plugging yours in, and for the most part it worked.

Thanks a ton for the help, but FYI color codes can't have decimals.
 
Last edited:
Status
Not open for further replies.
Top