![]() |
#1 | |
master of fugue
Join Date: Jun 2007
Posts: 2,453
![]() ![]() ![]() ![]() ![]() |
![]() ![]() //============================================================================== // TEXT TAG - Floating text system by Cohadar - v5.0 //============================================================================== // // PURPOUSE: // * Displaying floating text - the easy way // * Has a set of useful and commonly needed texttag functions // // CREDITS: // * DioD - for extracting proper color, fadepoint and lifespan parameters // for default warcraft texttags (from miscdata.txt) // // HOW TO IMPORT: // * Just create a trigger named TextTag // convert it to text and replace the whole trigger text with this one //============================================================================== library TextTag globals // for custom centered texttags private constant real MEAN_CHAR_WIDTH = 5.5 private constant real MAX_TEXT_SHIFT = 200.0 private constant real DEFAULT_HEIGHT = 16.0 // for default texttags private constant real SIGN_SHIFT = 16.0 private constant real FONT_SIZE = 0.024 private constant string MISS = "miss" endglobals //=========================================================================== // Custom centered texttag on (x,y) position // color is in default wc3 format, for example "|cFFFFCC00" //=========================================================================== public function XY takes real x, real y, string text, string color returns nothing local texttag tt = CreateTextTag() local real shift = RMinBJ(StringLength(text)*MEAN_CHAR_WIDTH, MAX_TEXT_SHIFT) call SetTextTagText(tt, color+text, FONT_SIZE) call SetTextTagPos(tt, x-shift, y, DEFAULT_HEIGHT) call SetTextTagVelocity(tt, 0.0, 0.04) call SetTextTagVisibility(tt, true) call SetTextTagFadepoint(tt, 2.5) call SetTextTagLifespan(tt, 4.0) call SetTextTagPermanent(tt, false) set tt = null endfunction //=========================================================================== // Custom centered texttag above unit //=========================================================================== public function Unit takes unit whichUnit, string text, string color returns nothing local texttag tt = CreateTextTag() local real shift = RMinBJ(StringLength(text)*MEAN_CHAR_WIDTH, MAX_TEXT_SHIFT) call SetTextTagText(tt, color+text, FONT_SIZE) call SetTextTagPos(tt, GetUnitX(whichUnit)-shift, GetUnitY(whichUnit), DEFAULT_HEIGHT) call SetTextTagVelocity(tt, 0.0, 0.04) call SetTextTagVisibility(tt, true) call SetTextTagFadepoint(tt, 2.5) call SetTextTagLifespan(tt, 4.0) call SetTextTagPermanent(tt, false) set tt = null endfunction //=========================================================================== // Standard wc3 gold bounty texttag, displayed only to killing player //=========================================================================== public function GoldBounty takes unit whichUnit, integer bounty, player killer returns nothing local texttag tt = CreateTextTag() local string text = "+" + I2S(bounty) call SetTextTagText(tt, text, FONT_SIZE) call SetTextTagPos(tt, GetUnitX(whichUnit)-SIGN_SHIFT, GetUnitY(whichUnit), 0.0) call SetTextTagColor(tt, 255, 220, 0, 255) call SetTextTagVelocity(tt, 0.0, 0.03) call SetTextTagVisibility(tt, GetLocalPlayer()==killer) call SetTextTagFadepoint(tt, 2.0) call SetTextTagLifespan(tt, 3.0) call SetTextTagPermanent(tt, false) set text = null set tt = null endfunction //============================================================================== public function LumberBounty takes unit whichUnit, integer bounty, player killer returns nothing local texttag tt = CreateTextTag() local string text = "+" + I2S(bounty) call SetTextTagText(tt, text, FONT_SIZE) call SetTextTagPos(tt, GetUnitX(whichUnit)-SIGN_SHIFT, GetUnitY(whichUnit), 0.0) call SetTextTagColor(tt, 0, 200, 80, 255) call SetTextTagVelocity(tt, 0.0, 0.03) call SetTextTagVisibility(tt, GetLocalPlayer()==killer) call SetTextTagFadepoint(tt, 2.0) call SetTextTagLifespan(tt, 3.0) call SetTextTagPermanent(tt, false) set text = null set tt = null endfunction //=========================================================================== public function ManaBurn takes unit whichUnit, integer dmg returns nothing local texttag tt = CreateTextTag() local string text = "-" + I2S(dmg) call SetTextTagText(tt, text, FONT_SIZE) call SetTextTagPos(tt, GetUnitX(whichUnit)-SIGN_SHIFT, GetUnitY(whichUnit), 0.0) call SetTextTagColor(tt, 82, 82 ,255 ,255) call SetTextTagVelocity(tt, 0.0, 0.04) call SetTextTagVisibility(tt, true) call SetTextTagFadepoint(tt, 2.0) call SetTextTagLifespan(tt, 5.0) call SetTextTagPermanent(tt, false) set text = null set tt = null endfunction //=========================================================================== public function Miss takes unit whichUnit returns nothing local texttag tt = CreateTextTag() call SetTextTagText(tt, MISS, FONT_SIZE) call SetTextTagPos(tt, GetUnitX(whichUnit), GetUnitY(whichUnit), 0.0) call SetTextTagColor(tt, 255, 0, 0, 255) call SetTextTagVelocity(tt, 0.0, 0.03) call SetTextTagVisibility(tt, true) call SetTextTagFadepoint(tt, 1.0) call SetTextTagLifespan(tt, 3.0) call SetTextTagPermanent(tt, false) set tt = null endfunction //=========================================================================== public function CriticalStrike takes unit whichUnit, integer dmg returns nothing local texttag tt = CreateTextTag() local string text = I2S(dmg) + "!" call SetTextTagText(tt, text, FONT_SIZE) call SetTextTagPos(tt, GetUnitX(whichUnit), GetUnitY(whichUnit), 0.0) call SetTextTagColor(tt, 255, 0, 0, 255) call SetTextTagVelocity(tt, 0.0, 0.04) call SetTextTagVisibility(tt, true) call SetTextTagFadepoint(tt, 2.0) call SetTextTagLifespan(tt, 5.0) call SetTextTagPermanent(tt, false) set text = null set tt = null endfunction //=========================================================================== public function ShadowStrike takes unit whichUnit, integer dmg, boolean initialDamage returns nothing local texttag tt = CreateTextTag() local string text = I2S(dmg) if initialDamage then set text = text + "!" endif call SetTextTagText(tt, text, FONT_SIZE) call SetTextTagPos(tt, GetUnitX(whichUnit), GetUnitY(whichUnit), 0.0) call SetTextTagColor(tt, 160, 255, 0, 255) call SetTextTagVelocity(tt, 0.0, 0.04) call SetTextTagVisibility(tt, true) call SetTextTagFadepoint(tt, 2.0) call SetTextTagLifespan(tt, 5.0) call SetTextTagPermanent(tt, false) set text = null set tt = null endfunction endlibrary
|
|
![]() |
![]() |
Sponsored Links - Login to hide this ad! |
|
![]() |
#2 |
Lackadaisically Absent.
Respected User
|
![]() I think you're missing some configurations there... I would do this:
__________________![]() globals // for custom centered texttags private constant real MEAN_CHAR_WIDTH = 5.5 private constant real MAX_TEXT_SHIFT = 200.0 private constant real DEFAULT_HEIGHT = 16.0 // for default texttags private constant real SIGN_SHIFT = 16.0 private constant real FONT_SIZE = 0.024 private constant string MISS = "miss" private constant real LIFESPAN = 4.00 private constant real FADEPOINT = 2.5 private constant real VELOCITY =0.04 private constant real VELOCITY_ANGLE = 0.0 endglobals public function XY takes real x, real y, string text, string color returns nothing local texttag tt = CreateTextTag() local real shift = RMinBJ(StringLength(text)*MEAN_CHAR_WIDTH, MAX_TEXT_SHIFT) call SetTextTagText(tt, color+text, FONT_SIZE) call SetTextTagPos(tt, x-shift, y, DEFAULT_HEIGHT) call SetTextTagVelocity(tt, VELOCITY_ANGLE, VELOCITY) call SetTextTagVisibility(tt, true) call SetTextTagFadepoint(tt, FADEPOINT) call SetTextTagLifespan(tt, LIFESPAN) call SetTextTagPermanent(tt, false) set tt = null endfunction public function XYCustom takes real x, real y, string text, string color, real size, real height, real velocityangle, real velocity, real lifespan, real fadepoint returns nothing local texttag tt = CreateTextTag() local real shift = RMinBJ(StringLength(text)*MEAN_CHAR_WIDTH, MAX_TEXT_SHIFT) call SetTextTagText(tt, color+text, size) call SetTextTagPos(tt, x-shift, y, height) call SetTextTagVelocity(tt, velocityangle, angle) call SetTextTagVisibility(tt, true) call SetTextTagFadepoint(tt, fadepoint) call SetTextTagLifespan(tt, lifespan) call SetTextTagPermanent(tt, false) set tt = null endfunction //The same for Unit texttags Last edited by Pyrogasm : 08-11-2008 at 04:39 AM. |
![]() |
![]() |
![]() |
#3 |
Alpha Male of Wc3c
Official Map Reviewer
|
![]() Jeez, first it was timers, now it's texttags...
__________________1: What if I want to make 2 different texttags 2 different sizes? Your code doesn't immediately allow that, so this < Dusk's. 2: Colors are so much easier to set with 255 RGB values. 3 more params, but a lot easier. EDIT: Nvm, I see what you're doing. Both work fine. 3: Your globals are overly complicated. Seriously. What the heck is "SIGN_SHIFT" and "MEAN_CHAR_WIDTH"? (You didn't even comment them) Plus, like Pyro said, you're lacking a lot of globals. Why not just use... "SIZE". Amazing, a single integer that does exactly what it says. You might have to use a single BJ (Not sure), but at least your code will be easier to, idk, make sense of? EDIT: I see "FONT SIZE", but you don't make it configurable between functions, nor do you explain why it's a random tiny real value and not something like "10". You also do not explain how to get said real value if you want to use a size of, say, "12". Last edited by darkwulfv : 08-11-2008 at 06:47 AM. |
![]() |
![]() |
![]() |
#4 |
master of fugue
Join Date: Jun 2007
Posts: 2,453
![]() ![]() ![]() ![]() ![]() |
![]() The globals that are missing (like FADEPOINT and LIFESPAN) are missing because they cannot be global constants.
__________________And they cannot be constants because they are different from function to function. The reason there exists multiple functions is to avoid multiple parameters. The purpouse of TextTag is not being able to display everything. It is about doing the right job with minimal effort. (like it clearly says in the PURPOUSE section) For example when you want to display critical strike you don't need color or fadepoint or lifespan as parameters because they have default values, all you need is a unit above which to display texttag and amount of damage to display. If you need some custom texttag not specified in the library just create a function and add it (it should be obvious how by looking at other functions SIGN_SHIFT is a default texttag shift to the left wc3 uses when - or + sign are added to the text. (as you can clearly see from the code of functions that use it) MEAN_CHAR_WIDTH is exactly that, mean width of 0.024 size characters (because not all characters are of same width "i", "W") it is used to calculate shift to the left when centering text Last edited by cohadar : 08-11-2008 at 09:06 AM. |
![]() |
![]() |
![]() |
#5 |
100% Genuine Retard!
|
![]() It does what it's supposed to do and it's really easy to use. This is both simple and useful, exactly how a script should be.
__________________ |
![]() |
![]() |
![]() |
#6 |
Overdoses result in death
Join Date: Jan 2007
Posts: 2,365
![]() ![]() ![]() |
![]() So like, what can this do that GUI can't?
__________________ |
![]() |
![]() |
![]() |
#7 | |
Free Software Terrorist
Technical Director
|
![]() Quote:
|
|
![]() |
![]() |
![]() |
#8 |
Procrastination Incarnate
Development Director
|
![]() The library doesn't really allow any kind of textag customization, but then again that's not its purpose; the purpose is the easy creation of texttags that simulate game-made ones. The problem is this purpose isn't clearly stated in the first post, hence the confusion. "Displaying floating text - the easy way" is just way too vague, and the library name very generic, is should be something more like "War3TextTag" or "PresetTextTag" or whatever. Once a clearer statement of purpose is included I see no reason why this shouldn't be approved.
__________________ |
![]() |
![]() |
![]() |
#9 |
master of fugue
Join Date: Jun 2007
Posts: 2,453
![]() ![]() ![]() ![]() ![]() |
![]() The beauty of using a public keyword is that you can change the name of a library and all functions will change names accordingly.
__________________So if you feel it should have less generic name please feel free to customize it. |
![]() |
![]() |
![]() |
#10 | |
Lackadaisically Absent.
Respected User
|
![]() Quote:
I'm saying they should be there only for the functions "XY" and "Unit" so that if someone decides that the default texttags are fading too soon it will be easier to modify the fadepoint without going through the code of the actual system. Last edited by Pyrogasm : 08-11-2008 at 09:14 PM. |
|
![]() |
![]() |
![]() |
#11 | |
Free Software Terrorist
Technical Director
|
![]() Quote:
|
|
![]() |
![]() |
![]() |
#12 |
master of fugue
Join Date: Jun 2007
Posts: 2,453
![]() ![]() ![]() ![]() ![]() |
![]() Well I officially use TextTag name in pyramidal defence because in addition to standard wc3 function I put all other custom texttag function in it.
__________________The whole point when it comes to texttags is that everyone will need something custom for their map and there is no way anyone can make general enough texttag library. So you are expected to add your own functions to it, standard wc3 ones are just there as a good basis and example code. And if you are going to add your custom functions to it and make all your texttags with it then only good name for it is TextTag. |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
|