[General] Efficient Floating Text

Status
Not open for further replies.
Level 12
Joined
Aug 12, 2008
Messages
349
I'm trying to make a spell when a hero kills a hero, the killer gains a permanent intelligence. As I want this spell to be much more nicer, so I decided to put a floating text above the unit after gaining that particular intelligence. In the following trigger (only floating text), I don't really think it's effective as it don't seems like it's MUI.
[trigger=FloatText]
Floating Text - Create floating text that reads Float Text above (Triggering unit) with Z offset 0.00, using font size 7.50, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
Set FloatText = (Last created floating text)
Floating Text - Change FloatText: Disable permanence
Floating Text - Set the velocity of FloatText to 64.00 towards 90.00 degrees
Floating Text - Change the lifespan of FloatText to 3.00 seconds
Floating Text - Change the fading age of FloatText to 1.50 seconds
[/trigger]


Is there any way to improve it? Or is there any system I can use?
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
To shadowvzs: I'm not sure if it's MUI. What if another floating text created before the first floating text faded and cleared?

its text, cant be mu or mpi :p

or game text for all player can be non mui?

anyway u can check how its work in gui damage engine

  • Set DamageEventTarget = *unit variable - in gui damage system the attacker, i tell thsi for will be clear what happen*
  • Set DamageEventAmount = *real variable in trigger, since i copy just the float text, u dont see where its get value but that indifferent coz just a variable*
  • Floating Text - Create floating text that reads ((String((Integer(DamageEventAmount)))) + !) above DamageEventTarget with Z offset 50.00, using font size 13.00, color (100.00%, 5.00%, 10.00%), and 0.00% transparency
  • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
  • Floating Text - Change (Last created floating text): Disable permanence
  • Floating Text - Change the lifespan of (Last created floating text) to 3.50 seconds
  • Floating Text - Change the fading age of (Last created floating text) to 1.40 seconds
try optimize this coz its work well, also indifferent if before or after this have another floating text since if again a floating text created then that is the last created floatingtext so dont have any effect to this anymore or use jass and change the bj's

about improve maybe if u use the natives
this is my try



(since idk why i must centerize this is why i check the string length and i * with half font size + 1)
JASS:
  local real tx = X coordinate
  local real ty = Y coordinate
  local real xdiff  //That amount how much i need for centerize the text above the target point
  local string s = "Blocked!" //i dont declared the stringh length since i also in my map declare the string later coz there have chance things, like if random int < x than string is critical hit and not block, or could be miss too
  local real xvel = 7.1 / 128 * Cos(3.14159 / 2) //after i checked the functions in jc
  local real yvel = 7.1 / 128 * Sin(3.14159 / 2)
  local texttag t1 = CreateTextTag()
            set xdiff = StringLength(s) * 5.5
            call SetTextTagText(t1, s, 0.90 * 0.023)
            call SetTextTagPos(t1, tx-xdiff, ty, 100.00)
            call SetTextTagColor(t1, 0, 0, 255, 200)
            call SetTextTagPermanent( t1, false )
            call SetTextTagLifespan( t1, 4.50 )
            call SetTextTagFadepoint( t1, 2.50 )
            call SetTextTagVelocity(t1, xvel, yvel)
    set t1 = null
   set s = null
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Thanks a lot, shadowvzs :D I got how it works!
Still don't understand what's with the below code 'cause I know nothing about Jass scripts. :p

what u do in gui (so normally in we with clicking) the WE convert to jass when u save it, but u can convert too manually if u want in trigger editor->edit->convert to custom text

what u get is same trigger but in jass form, if u convert it u can optimize the code a bit example:

  • Untitled Trigger 003
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Peasant
    • Actions
      • Player - Add 1 to (Owner of (Killing unit)) Current gold
when u convert look like this

JASS:
function Trig_Untitled_Trigger_003_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetDyingUnit()) == 'hpea' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Untitled_Trigger_003_Actions takes nothing returns nothing
    call AdjustPlayerStateBJ( 1, GetOwningPlayer(GetKillingUnitBJ()), PLAYER_STATE_RESOURCE_GOLD )
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_003 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_003 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_003, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Untitled_Trigger_003, Condition( function Trig_Untitled_Trigger_003_Conditions ) )
    call TriggerAddAction( gg_trg_Untitled_Trigger_003, function Trig_Untitled_Trigger_003_Actions )
endfunction

the red text is function call, what its mean its call a function (most of time a function can call another idk how many time) when u write native codes (ultimate function call what dont call a function what call another, its call only 1 function) then u reduce the function call numbers.

look this

JASS:
call AdjustPlayerStateBJ( 1, GetOwningPlayer(GetKillingUnitBJ()), PLAYER_STATE_RESOURCE_GOLD )

if u use Jass Craft program and copy AdjustPlayerStateBJ to there its tell to u this function call this

JASS:
    if (delta > 0) then
        if (whichPlayerState == PLAYER_STATE_RESOURCE_GOLD) then
            call AdjustPlayerStateSimpleBJ(whichPlayer, PLAYER_STATE_GOLD_GATHERED, delta)
        elseif (whichPlayerState == PLAYER_STATE_RESOURCE_LUMBER) then
            call AdjustPlayerStateSimpleBJ(whichPlayer, PLAYER_STATE_LUMBER_GATHERED, delta)
        endif
    endif

    call AdjustPlayerStateSimpleBJ(whichPlayer, whichPlayerState, delta)

GetKillingUnitBJ() call a function where basically u will get this GetKillingUnitBJ() = GetTriggeringUnit()

where AdjustPlayerStateSimpleBJ also call another function

JASS:
call SetPlayerState(whichPlayer, whichPlayerState, GetPlayerState(whichPlayer, whichPlayerState) + delta)

so u can see how much function call only for give 1 gold for a dead peasant to killer player, but if u optimize it (searh what is the last function call and store things to variable and with this u make it more readable) then its only
JASS:
function Trig_Untitled_Trigger_003_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetDyingUnit()) == 'hpea'
endfunction

function Trig_Untitled_Trigger_003_Actions takes nothing returns nothing
local player p = GetOwningPlayer(GetTriggerUnit())
    SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + 1)
set p = null
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_003 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_003 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_003, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Untitled_Trigger_003, Condition( function Trig_Untitled_Trigger_003_Conditions ) )
    call TriggerAddAction( gg_trg_Untitled_Trigger_003, function Trig_Untitled_Trigger_003_Actions )
endfunction

now compare this with 1st converted jass
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
I did try to learn Jass before as till now, I can do whatever I want with triggering. I gotta try learning Jass after this month. >< By the way, thanks a lot for your description about Jass. I already got a bit what's Jass all about. +rep

Tutorials

http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=28292

http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=21329

http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=25715

JassCraft (here just copy paste that function what u want check and its give u in that moment what its do, also easy to search in that)

http://www.wc3c.net/showthread.php?t=80051

Jass New Gen Pack (vjass) for later, its give more advantage in jass and most of complicated thing was done in vjass coz in few point more handy

http://www.hiveworkshop.com/forums/...456/how-download-install-confige-jngp-160547/

overall jass more flexiable if u want make something more complicated then 1+1 :D
 
Status
Not open for further replies.
Top