function GoldBountyFX takes unit u, integer gold, player p returns nothing
local integer FLYING_GOLD_UNITTYPE = 039;z000039;
local texttag t = CreateTextTag()
local real ux = GetUnitX(u)
local real uy = GetUnitY(u)
local real uz = GetUnitFlyHeight(u)
local destructable d
local unit f
if(IsUnitType(u, UNIT_TYPE_FLYING)) then
set f = CreateUnit(Player(15), FLYING_GOLD_UNITTYPE, ux, uy, 0)
call SetUnitScale(f, 1, 1, 1)
call SetUnitFlyHeight(f, uz, 0)
call UnitAddAbility(f, 039;Aloc039;)
call SetTextTagText(t, "+" + I2S(gold), 0.023)
call SetTextTagPosUnit(t, f, -13)
call KillUnit(f)
else
call SetTextTagText(t, "+" + I2S(gold), 0.024)
call SetTextTagPos(t, ux-16, uy-16, uz)
set d = CreateDestructableZ(039;OTip039;, ux-16, uy-16, uz, 0.00, 1, 0) //http://wc3jass.com/viewtopic.php?t=2472
call DestroyEffect(AddSpecialEffect("UI\\Feedback\\GoldCredit\\GoldCredit.mdl", ux-16, uy-16))
call RemoveDestructable(d)
endif
call SetTextTagColor(t, 255, 220, 0, 255)
call SetTextTagVelocity(t, 0, 0.03)
call SetTextTagVisibility(t, GetLocalPlayer() == p)
call SetTextTagFadepoint(t, 2)
call SetTextTagLifespan(t, 3)
call SetTextTagPermanent(t, false)
set t = null
set f = null
set d = null
endfunction
//==============================================================================
// 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 = 7
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 string BLOCK = "block"
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 Block takes unit whichUnit returns nothing
local texttag tt = CreateTextTag()
call SetTextTagText(tt, BLOCK, FONT_SIZE)
call SetTextTagPos(tt, GetUnitX(whichUnit)-SIGN_SHIFT, GetUnitY(whichUnit), 0.0)
call SetTextTagColor(tt, 0, 255, 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
//###########################################################################
// Custom TextTags for Pyramidal Defence
//###########################################################################
//===========================================================================
public function BonusDamage takes unit whichUnit, integer dmg returns nothing
local texttag tt = CreateTextTag()
local string text = I2S(dmg)
if dmg > 0 then
set text = "+"+text
endif
call SetTextTagText(tt, text, FONT_SIZE)
call SetTextTagPos(tt, GetUnitX(whichUnit)-SIGN_SHIFT, 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, 4.0)
call SetTextTagPermanent(tt, false)
set text = null
set tt = null
endfunction
//===========================================================================
public function Monster takes unit whichUnit, string text returns nothing
local texttag tt = CreateTextTag()
local real shift = RMinBJ(StringLength(text)*MEAN_CHAR_WIDTH, MAX_TEXT_SHIFT)
call SetTextTagText(tt, text, FONT_SIZE)
call SetTextTagPos(tt, GetUnitX(whichUnit)-shift, GetUnitY(whichUnit), DEFAULT_HEIGHT)
call SetTextTagColor(tt, 255, 0, 0, 255)
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
endlibrary
function GoldBountyFX takes unit u, integer gold, player p returns nothing
local texttag t = CreateTextTag()
local real ux = GetUnitX(u)
local real uy = GetUnitY(u)
if(IsUnitType(GetTriggerUnit(), UNIT_TYPE_FLYING)) then
// NOTE: For perfect accuracy in a later revision, this is going to need a non-tilting 0-size flying dummy unit, I think.
call SetTextTagText(t, "+" + I2S(gold), 0.023)
call SetTextTagPosUnit(t, u, -100)
call DestroyEffect(AddSpecialEffectTarget("UI\\Feedback\\GoldCredit\\GoldCredit.mdl", u, "origin"))
else
call SetTextTagText(t, "+" + I2S(gold), 0.025)
call SetTextTagPos(t, ux-16, uy-16, 0)
call DestroyEffect(AddSpecialEffect("UI\\Feedback\\GoldCredit\\GoldCredit.mdl", ux, uy))
endif
call SetTextTagColor(t, 255, 220, 0, 255)
call SetTextTagVelocity(t, 0, 0.03)
call SetTextTagVisibility(t, GetLocalPlayer() == p)
call SetTextTagFadepoint(t, 2)
call SetTextTagLifespan(t, 3)
call SetTextTagPermanent(t, false)
set t = null
endfunction
else
call SetUnitX(u, ux - 16) // This.
call SetUnitY(u, uy - 16) // And this.
call SetTextTagText(t, "+" + I2S(gold), 0.025)
call SetTextTagPos(t, ux-16, uy-16, 0)
call SetUnitX(u, ux) // These two as well.
call SetUnitY(u, uy)// <
call DestroyEffect(AddSpecialEffect("UI\\Feedback\\GoldCredit\\GoldCredit.mdl", ux, uy))
endif
Yeah, a victim of copy/paste and not enough proofreading.Because he forgot to put ' "+" + I2S(gold) ' in where it says text i presume.
Indeed, I had been using that to offset the text when it was using SetTextTagPosUnit(), but then I realized that for ground units it should just use SetTextTagPos() (the text appears from their feet, not overhead) and I forgot to take out those lines. That's what I get for editing the code madly late at night... :nuts:The SetTextTagPos already had ux-16, and uy-16 in the line anyways, so that is why the commented lines are odd.
Heh, WC3 can only display 100 texttags at a time anyway. Yeah, it's MUI.Oww thanks dude Is it MUI? I'll be having like... 100++ units that gives this bounty or something? :O So not sure if a dummy is a good idea :O
function GoldBountyFX takes unit u, integer gold, player p returns nothing
local texttag t = CreateTextTag()
local real ux = GetUnitX(u)
local real uy = GetUnitY(u)
local real uz = GetUnitFlyHeight(u)
local destructable d
if(IsUnitType(u, UNIT_TYPE_FLYING)) then
call SetTextTagText(t, "+" + I2S(gold), 0.023)
call SetTextTagPos(t, ux, uy, uz)
else
call SetTextTagText(t, "+" + I2S(gold), 0.024)
call SetTextTagPos(t, ux-16, uy-16, uz)
endif
set d = CreateDestructableZ(039;OTip039;, ux-16, uy-16, uz, 0.00, 1, 0) //http://wc3jass.com/viewtopic.php?t=2472
call DestroyEffect(AddSpecialEffect("UI\\Feedback\\GoldCredit\\GoldCredit.mdl", ux-16, uy-16))
call RemoveDestructable(d)
call SetTextTagColor(t, 255, 220, 0, 255)
call SetTextTagVelocity(t, 0, 0.03)
call SetTextTagVisibility(t, GetLocalPlayer() == p)
call SetTextTagFadepoint(t, 2)
call SetTextTagLifespan(t, 3)
call SetTextTagPermanent(t, false)
set t = null
set d = null
endfunction
Maybe?- It can display 100 per player right?
function GoldBountyStrictGroundFX takes unit u, integer gold, player p returns nothing
local texttag t = CreateTextTag()
local real ux = GetUnitX(u)
local real uy = GetUnitY(u)
call SetTextTagText(t, "+" + I2S(gold), 0.024)
call SetTextTagPos(t, ux-16, uy-16, GetUnitFlyHeight(u)) //Meh.
call DestroyEffect(AddSpecialEffect("UI\\Feedback\\GoldCredit\\GoldCredit.mdl", ux-16, uy-16))
call SetTextTagColor(t, 255, 220, 0, 255)
call SetTextTagVelocity(t, 0, 0.03)
call SetTextTagVisibility(t, GetLocalPlayer() == p)
call SetTextTagFadepoint(t, 2)
call SetTextTagLifespan(t, 3)
call SetTextTagPermanent(t, false)
set t = null
endfunction