//==============================================================================
// TEXT TAG - Floating text system by Cohadar - v4.0
//==============================================================================
//
// PURPOUSE:
// * Displaying floating text - the easy way
// * Text is automatically centered depending on it's length
//
// FUNCTION LIST:
// * TextTag_XY(x, y, text, color)
// * TextTag_Unit(unit, text, color)
// * TextTag_GoldBounty(unit, text, killer)
// * TextTag_LumberBounty(unit, text, killer)
//
// color is a color string, example: "|c00FFCC00"
// killer is a killing player, usually: GetOwningPlayer(GetKillingUnit())
// (bounty text is visible only to killer)
//
// 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
private constant integer MEAN_CHAR_WIDTH = 8
private constant integer MAX_TEXT_SHIFT = 32
private constant real FONT_SIZE = 0.025
private constant real VELOCITY_X = 0
private constant real VELOCITY_Y = .04
private constant real LIFESPAN = 4
private constant real HEIGHT = 16
private constant real FADE_POINT = 2.5
endglobals
//===========================================================================
public function XY takes real x, real y, string text, string color returns nothing
local texttag t = CreateTextTag()
local integer shift = IMinBJ(StringLength(text), MAX_TEXT_SHIFT) * MEAN_CHAR_WIDTH
call SetTextTagText(t, color+text, FONT_SIZE)
call SetTextTagPos(t, x-shift, y, HEIGHT)
call SetTextTagVelocity(t, VELOCITY_X, VELOCITY_Y)
call SetTextTagVisibility(t, true)
call SetTextTagFadepoint(t, FADE_POINT)
call SetTextTagLifespan(t, LIFESPAN)
call SetTextTagPermanent(t, false)
set t = null
endfunction
//===========================================================================
public function Unit takes unit whichUnit, string text, string color returns nothing
local texttag t = CreateTextTag()
local integer shift = IMinBJ(StringLength(text), MAX_TEXT_SHIFT) * MEAN_CHAR_WIDTH
call SetTextTagText(t, color+text, FONT_SIZE)
call SetTextTagPos(t, GetUnitX(whichUnit)-shift, GetUnitY(whichUnit), HEIGHT)
call SetTextTagVelocity(t, VELOCITY_X, VELOCITY_Y)
call SetTextTagVisibility(t, true)
call SetTextTagFadepoint(t, FADE_POINT)
call SetTextTagLifespan(t, LIFESPAN)
call SetTextTagPermanent(t, false)
set t = null
endfunction
//===========================================================================
public function GoldBounty takes unit whichUnit, string text, player killer returns nothing
local texttag t = CreateTextTag()
local integer shift = IMinBJ(StringLength(text), MAX_TEXT_SHIFT) * MEAN_CHAR_WIDTH
call SetTextTagText(t, text, FONT_SIZE)
call SetTextTagPos(t, GetUnitX(whichUnit)-shift, GetUnitY(whichUnit), HEIGHT)
call SetTextTagColor(t, 255, 220, 0, 255)
call SetTextTagVelocity(t, VELOCITY_X, VELOCITY_Y)
call SetTextTagVisibility(t, GetLocalPlayer()==killer)
call SetTextTagFadepoint(t, FADE_POINT)
call SetTextTagLifespan(t, LIFESPAN)
call SetTextTagPermanent(t, false)
set t = null
endfunction
//==============================================================================
public function LumberBounty takes unit whichUnit, string text, player killer returns nothing
local texttag t = CreateTextTag()
local integer shift = IMinBJ(StringLength(text), MAX_TEXT_SHIFT) * MEAN_CHAR_WIDTH
call SetTextTagText(t, text, FONT_SIZE)
call SetTextTagPos(t, GetUnitX(whichUnit)-shift, GetUnitY(whichUnit), HEIGHT)
call SetTextTagColor(t, 0, 196, 0, 255)
call SetTextTagVelocity(t, VELOCITY_X, VELOCITY_Y)
call SetTextTagVisibility(t, GetLocalPlayer()==killer)
call SetTextTagFadepoint(t, FADE_POINT)
call SetTextTagLifespan(t, LIFESPAN)
call SetTextTagPermanent(t, false)
set t = null
endfunction
endlibrary