• 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] Help with this function: CreateTextTagUnit

Status
Not open for further replies.
Level 21
Joined
Aug 9, 2006
Messages
2,384
Well, i made a own function which includes all the things for the texttags, so i could call it out of the header, but the texttag does not show.

Thats the function:

JASS:
function CreateTextTagUnit takes string s, unit whichUnit, real zOffset, real size, integer red, integer green, integer blue, integer transparency, integer velocityA, integer velocityB, real lifespan, boolean perma, boolean visible returns texttag
    local texttag LastTextTag = CreateTextTag()
    call SetTextTagText(LastTextTag, s, size * 0.023 / 10)
    call SetTextTagPosUnit(LastTextTag, whichUnit, zOffset)
    call SetTextTagColor(LastTextTag, red, green, blue, transparency)
    call SetTextTagVelocity( LastTextTag, velocityA, velocityB )
    call SetTextTagLifespan( LastTextTag, lifespan )
    call SetTextTagPermanent( LastTextTag, perma )
    call SetTextTagVisibility( LastTextTag, visible )
    return LastTextTag
endfunction

thats how i call it:

JASS:
function Trig_Viper_Agility_Conditions takes nothing returns boolean
    if ( not ( UnitHasItemOfTypeBJ(GetAttacker(), 'I00P') == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Viper_Agility_Actions takes nothing returns nothing
    local unit ViperUnit = GetAttacker()
    local texttag ViperTxt
    if GetRandomInt(1, 100) <= 50 then
        set ViperTxt = CreateTextTagUnit("Viper Agility!", ViperUnit, 0.00, 10.00, 100, 100, 100, 100, 64, 90, 3.00, false, true)
        call UnitAddAbility( ViperUnit, 'A00N' )
        call PolledWait(3.00)
        call UnitRemoveAbility( ViperUnit, 'A00N' )
        set ViperTxt = null
    endif
    set ViperUnit = null
endfunction

//===========================================================================
function InitTrig_Viper_Agility takes nothing returns nothing
    set gg_trg_Viper_Agility = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Viper_Agility, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Viper_Agility, Condition( function Trig_Viper_Agility_Conditions ) )
    call TriggerAddAction( gg_trg_Viper_Agility, function Trig_Viper_Agility_Actions )
endfunction



I really don't know why it won't work.
 
Last edited:
Level 2
Joined
Feb 24, 2007
Messages
37
Try using 0 as transperancy so instead of this:

JASS:
set ViperTxt = CreateTextTagUnit("Viper Agility!", ViperUnit, 0.00, 10.00, 100, 100, 100, 100, 64, 90, 3.00, false, true)
//

use this:
JASS:
set ViperTxt = CreateTextTagUnit("Viper Agility!", ViperUnit, 0.00, 10.00, 100, 100, 100, 0, 64, 90, 3.00, false, true)
//

Ignore the "//"
 
Level 2
Joined
Feb 24, 2007
Messages
37
Ive made some changes and tested it,
it seems the problem is with the velocity.

JASS:
function CreateTextTagUnit takes string s, unit whichUnit, real zOffset, real size, integer red, integer green, integer blue, integer transparency, real velocityA, real velocityB, real lifespan, boolean perma, boolean visible returns texttag
    local texttag LastTextTag = CreateTextTag()
    call SetTextTagText(LastTextTag, s, size * 0.023 / 10)
    call SetTextTagPosUnit(LastTextTag, whichUnit, zOffset)
    call SetTextTagColor(LastTextTag, red, green, blue, transparency)
    call SetTextTagVelocity( LastTextTag, velocityA, velocityB )
    call SetTextTagLifespan( LastTextTag, lifespan )
    call SetTextTagPermanent( LastTextTag, perma )
    call SetTextTagVisibility( LastTextTag, visible )
    return LastTextTag
endfunction

I've changed the
JASS:
integer velocityA, integer velocityB
to
JASS:
real velocityA, real velocityB
since
JASS:
native SetTextTagVelocity takes texttag t, real xvel, real yvel returns nothing
also takes reals instead of integers.

And then i changed the two values of the velocity here to a lower number
JASS:
set ViperTxt = CreateTextTagUnit("Viper Agility!", ViperUnit, 0.00, 10.00, 100, 100, 100, 100, 0, 0.03, 3.00, false, true)
//
 
Status
Not open for further replies.
Top