• 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.

[Solved] Floating text vJass, need help.

Status
Not open for further replies.
Level 8
Joined
May 9, 2010
Messages
266
Greetings!
I am trying to learn vJass and have made a simple spell. Just heal with floating text.
Heal is works properly, but texttag is not appear:(
Here is a code, help me please, thanks:)
JASS:
library heal

globals

private constant integer SpellID = 'A000'//Spell ID
private constant string se = "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" // Heal SE
private constant real TTt = 3. //living time of text
private constant real TTs = 15. //Floating text size
private constant real TTtf = 3.5 //Fading time of text
//*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*//
private real HPcur
private real HPs
private real HPplus
private unit u
private integer SpellLevel
private texttag TT
endglobals


function HealAmmount takes integer SpellLevel returns real
return SpellLevel * 50.
endfunction

function Heal takes unit u returns nothing //call Heal(unit)
set HPplus = HealAmmount(SpellLevel)
set HPcur = GetUnitState(u, UNIT_STATE_LIFE) //делаем переменную, равную новому хп юнита
set HPs = HPcur + HPplus

call SetUnitState(u, UNIT_STATE_LIFE, HPs) // сделать хп столько - то
local real HPswap 
set HPswap = GetUnitState(u, UNIT_STATE_LIFE) - HPcur
call DestroyEffect(AddSpecialEffectTarget(se,u,"chest")) // Эффект, без BJ

local real ux = GetUnitX(u)
local real uy = GetUnitY(u)
local real uz = GetUnitFlyHeight(u) + GetLocationZ(Location(ux,uy))
//local texttag TT
set TT = CreateTextTag() //Floating text
call SetTextTagPermanent(TT, false)
call SetTextTagLifespan(TT, TTt)
call SetTextTagFadepoint(TT, TTtf)
call SetTextTagText(TT, R2S(HPswap), TTs)
call SetTextTagPos(TT, ux, uy, uz)
endfunction


//===========================================================================

function Conds takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == SpellID ) ) then //Conditions
        return false
    endif
    return true
endfunction

function actions takes nothing returns nothing
    set u = GetSpellTargetUnit()
    set SpellLevel = GetUnitAbilityLevel(GetTriggerUnit(), SpellID)
    call Heal(u)//ours HealFunction
endfunction

function InitTrig_Heal_vJass takes nothing returns nothing
    local trigger t
    set t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )     //Event
    call TriggerAddCondition( t, Condition( function Conds ) )
    call TriggerAddAction( t, function actions )
endfunction

endlibrary
 
Level 8
Joined
May 9, 2010
Messages
266
The size is too big, use 0.015.

After changing TTs(size) variable to 0.015, floating text is still not appear:(
Here is new code.
JASS:
library heal

globals

private constant integer SpellID = 'A000'//Spell ID
private constant string se = "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" // Heal SE
private constant real TTt = 3. //living time of text
private constant real TTs = 0.015 //Floating text size
private constant real TTtf = 3.5 //Fading time of text
//*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*//
private real HPcur
private real HPs
private real HPplus
private unit u
private integer SpellLevel
private texttag TT
endglobals


function HealAmmount takes integer SpellLevel returns real
return SpellLevel * 50.
endfunction

function Heal takes unit u returns nothing //call Heal(unit)
set HPplus = HealAmmount(SpellLevel)
set HPcur = GetUnitState(u, UNIT_STATE_LIFE) //делаем переменную, равную новому хп юнита
set HPs = HPcur + HPplus

call SetUnitState(u, UNIT_STATE_LIFE, HPs) // сделать хп столько - то
local real HPswap 
set HPswap = GetUnitState(u, UNIT_STATE_LIFE) - HPcur
call DestroyEffect(AddSpecialEffectTarget(se,u,"chest")) // Эффект, без BJ

local real ux = GetUnitX(u)
local real uy = GetUnitY(u)
local real uz = GetUnitFlyHeight(u) + GetLocationZ(Location(ux,uy))
//local texttag TT
set TT = CreateTextTag() //Floating text
call SetTextTagPermanent(TT, false)
call SetTextTagLifespan(TT, TTt)
call SetTextTagFadepoint(TT, TTtf)
call SetTextTagText(TT, R2S(HPswap), TTs)
call SetTextTagPos(TT, ux, uy, uz)
call SetTextTagColor(TT, 255,255,255,1)
endfunction


//===========================================================================

function Conds takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == SpellID ) ) then //Conditions
        return false
    endif
    return true
endfunction

function actions takes nothing returns nothing
    set u = GetSpellTargetUnit()
    set SpellLevel = GetUnitAbilityLevel(GetTriggerUnit(), SpellID)
    call Heal(u)//ours HealFunction
endfunction

function InitTrig_Heal_vJass takes nothing returns nothing
    local trigger t
    set t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )     //Event
    call TriggerAddCondition( t, Condition( function Conds ) )
    call TriggerAddAction( t, function actions )
endfunction

endlibrary

Edit: I`ve understood my problem, thanks for help guys!
(P.S. problem really was in my private variables, such as size and fading time
P.P.S how can i solve this thread?:D)
 
Status
Not open for further replies.
Top