• 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] Floating Text?

Status
Not open for further replies.
Level 6
Joined
Aug 15, 2007
Messages
209
I am using Floating Text in JASS for the first time and I realize that GUI commands use tons of BJs. Does anyone have a function already set up that gets rid of most of that? I want to see if anyone is ahead of me before I dive into it myself. Thanks in advance.
 
Level 5
Joined
Dec 17, 2007
Messages
145
JASS:
function DamageTextTag takes string damage, unit PointUnit, real red100, real green100, real blue100 returns nothing
  local string s = damage
  local unit u = PointUnit
  local texttag t = CreateTextTagUnitBJ(s, u, 0.0, 10, red100, green100, blue100, 0)
  local real x_velocity = TextTagSpeed2Velocity(50.) * Cos(90 * (3.1415 / 180))
  local real y_velocity = TextTagSpeed2Velocity(50.) * Sin(90 * (3.1415 / 180))
    call SetTextTagVelocity(t, x_velocity, y_velocity)
    call SetTextTagLifespan(t, 2) 
    call SetTextTagFadepoint(t, 1.5) 
    call SetTextTagPermanent(t, false)
set u = null
set t = null
endfunction
Best I could make. It does use 3 BJ's, but they're too hard to avoid otherwise.

This particular floating text is the kind Critical Strike uses, so if you want floating text that stays there, then Sorry, this isn't it.
 
Level 11
Joined
Aug 25, 2006
Messages
971
The whole point of avoiding bj calls (besides the fact most/some leak) is to avoid wasting your processor power on a function call. So simply replacing the bj's with more functions, defeats the purpose!
 
Level 5
Joined
Dec 17, 2007
Messages
145
Except
A: It's easier to modify
B: Bj's can be leaky / inefficient within themselves
C: Bj's are made up of either multiple functions or wrappers. So:

GetUnitAbilityLevelSwapped(...)Is 2 function calls, whereas GetUnitAbilityLevel(...) is one function call.

Also, sometimes, some Bj's are a cram of functions that acheive one goal. Breaking them apart makes them easier to modify, implement, and can save a function call or two.
 
Level 6
Joined
Jun 30, 2006
Messages
230
The whole point of avoiding bj calls (besides the fact most/some leak) is to avoid wasting your processor power on a function call. So simply replacing the bj's with more functions, defeats the purpose!

I haven't been very active here, so I don't know how good with JASS you are, Mr. Bomber, but if you call a BJ, you only see one function called. But most likely that BJ simply calls other functions. If you call them directly yourself, it saves one function call. Plus, some BJ's do some error handling that may not be necessary, so you cut out more processing. Some BJ's aren't like this, but most are.
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
Replacing the BJ with more functions does not defeat the purpose, it IS the purpose. You inline the BJ function, and at the same time, save a function (or more) calls. Best example here might be the DistanceBetweenPoints BJ which is simple SquareRoot(dx*dx+dy*dy). By inlining that, you can even avoid the SquareRoot call sometimes.
 
Status
Not open for further replies.
Top