Moderator
M
Moderator
Casting Text & Casting Percentage System v1.3 | Reviewed by Maker | 11th Oct 2013 | ||||
APPROVED | ||||
|
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
// C A S T I N G T E X T S Y S T E M
// B Y:
// E L P H I S
// V E R S I O N:
// 1.3
// C O D E A P I:
//! novjass
struct Casting..... /*
//===========================ALL ABOUT HELPING METHOD===========================
//This method help you to get current x of texttag
*/ method operator getX takes nothing returns real /*
//This method help you to get current y of texttag
*/ method operator getY takes nothing returns real /*
//This method help you to get current z of texttag
*/ method operator getZ takes nothing returns real /*
//This method help you to get current size of texttag
*/ method operator getS takes nothing returns real /*
//This method help you to set texttag position
*/ method setXYZ takes real x,real y,real z,real size returns nothing /*
//This method help you to hide text for player
*/ method hideTextForPlayer takes player p/* Which player you want to hide
*/ boolean hide /* Boolean hide text
*/ returns nothing /*
//This method help you to hide the texttag for player
*/ method hideText takes /*
*/ boolean hidetext /* Only you can see this text
*/ boolean hidetextenemies /* Only you and your allies can see this text
*/ return nothing/*
//This method help you to destroy the texttag instantly and also destroy data inside of this texttag
*/ method destroyInstantly takes nothing returns nothing /*
//This method help you to add text to method percentage when it run :)
*/ method addText takes string text returns nothing /*
*/
//
//
//==============================================================================
static method textPoint takes /*
*/ string text /* Which text you want to display
*/ string color /* Which color you want to combine when texttag reaching
*/ real x /* x of texttag
*/ real y /* y of texttag
*/ real z /* z of texttag
*/ real size /* Size of texttag
*/ real time /* Time out
*/ boolean style /* Style of Texttag (if true, STYLE: Override font color, if false, STYLE: Increase the letter)
*/ integer savenumber /* This number very important, it's a number save with table and you can load this texttag with number :)
*/ returns nothing
//Now for Example:
call Casting.textPoint("KABOOMKABOOM","|cffFFFF00",GetRectCenterX(gg_rct_P),GetRectCenterY(gg_rct_P),5.,15.,5.,false,15)
//
//
static method textNumber takes /*
*/ string color /* Which color you want to combine when texttag reaching
*/ real x /* x of texttag
*/ real y /* y of texttag
*/ real z /* z of texttag
*/ real size /* Size of texttag
*/ real time /* Time out
*/ integer savenumber /* This number very important, it's a number save with table and you can load this texttag with number :)
*/ returns nothing
//Now for Example:
call Casting.textNumber("|cffFFFF00",GetRectCenterX(gg_rct_P),GetRectCenterY(gg_rct_P),5.,15.,5.,10)
//
//
static method TextRun takes /*
*/ unit ct /* Which unit you want to add this texttag
*/ string text /* Which text you want to display
*/ string color /* Which color you want to combine when texttag reaching
*/ real size /* Size of texttag
*/ real time /* Time out
*/ boolean hidetext /* Only you can see this text
*/ boolean hidetextenemies /* Only you and your allies can see this text
*/ boolean style /* Style of Texttag (if true, STYLE: Override font color, if false, STYLE: Increase the letter)
*/ integer savenumber /* This number very important, it's a number save with table and you can load this texttag with number :)
*/ returns nothing
//Now for Example:
call Casting.TextRunning(Player(0),"CastingSystem","|cff00CC66",5.,13.,3.,true,false,true)
//
//
static method TextChannel takes /*
*/ unit ct /* Which unit you want to add this texttag and check order
*/ string text /* Which text you want to display
*/ string color /* Which color you want to combine when texttag reaching
*/ string order /* Order of ability unit using, if order != Current order, this system will deny it and also destroy it, this texttag will be cancel
*/ real size /* Size of texttag
*/ real time /* Time out
*/ boolean hidetext /* Only you can see this text
*/ boolean hidetextenemies /* Only you and your allies can see this text
*/ boolean style /* Style of Texttag (if true, STYLE: Override font color, if false, STYLE: Increase the letter)
*/ returns nothing
//Now for Example:
call Casting.TextChanneling(GetTriggerUnit(),"CastingSystem","carrionswarm","|cff00CC66",GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit()),5.,13.,3.,true,false,true)
//
//
static method NumberRun takes /*
*/ unit ct /* Which unit you want to add this texttag
*/ string color /* Which color you want to combine with number
*/ real size /* Size of texttag
*/ real time /* Time out
*/ boolean hidetext /* Only you can see this text
*/ boolean hidetextenemies /* Only you and your allies can see this text
*/ integer savenumber /* This number very important, it's a number save with table and you can load this texttag with number :)
//Hint: Different with Text, this method display percent of time 1 -> 100% :)
*/ returns nothing
//Now for Example:
call Casting.NumberRunning(Player(0),"|cff00CC66",5.,13.,3.,true,false,true)
//
//
static method NumberChannel takes /*
*/ unit ct /* Which unit you want to add this texttag and check order
*/ string color /* Which color you want to combine with number
*/ string order /* Order of ability unit using, if order != Current order, this system will deny it and also destroy it, this texttag will be cancel
*/ real size /* Size of texttag
*/ real time /* Time out
*/ boolean hidetext /* Only you can see this text
*/ boolean hidetextenemies /* Only you and your allies can see this text
*/ boolean style /* Style of Texttag (if true, STYLE: Override font color, if false, STYLE: Increase the letter)
//Hint: Different with Text, this method display percent of time 1 -> 100% :)
*/ returns nothing
//Now for Example:
call Casting.NumberChanneling(GetTriggerUnit(),"CastingSystem","carrionswarm","|cff00CC66",GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit()),5.,13.,3.,true,false,true)
//! endnovjass
//*************************************************************************************************
// - Installation:
// - Import/copy the required libraries and Casting Text code to your map
// - Read system API
// - You may play with the configurables below
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
// C A S T I N G T E X T S Y S T E M
// B Y:
// E L P H I S
// V E R S I O N:
// 1.3
// C O D E A P I:
//! novjass
struct Casting..... /*
//===========================ALL ABOUT HELPING METHOD===========================
//This method help you to get current x of texttag
*/ method operator getX takes nothing returns real /*
//This method help you to get current y of texttag
*/ method operator getY takes nothing returns real /*
//This method help you to get current z of texttag
*/ method operator getZ takes nothing returns real /*
//This method help you to get current size of texttag
*/ method operator getS takes nothing returns real /*
//This method help you to set texttag position
*/ method setXYZ takes real x,real y,real z,real size returns nothing /*
//This method help you to hide text for player
*/ method hideTextForPlayer takes player p/* Which player you want to hide
*/ boolean hide /* Boolean hide text
*/ returns nothing /*
//This method help you to hide the texttag for player
*/ method hideText takes /*
*/ boolean hidetext /* Only you can see this text
*/ boolean hidetextenemies /* Only you and your allies can see this text
*/ return nothing/*
//This method help you to destroy the texttag instantly and also destroy data inside of this texttag
*/ method destroyInstantly takes nothing returns nothing /*
//This method help you to add text to method percentage when it run :)
*/ method addText takes string text returns nothing /*
*/
//
//
//==============================================================================
static method textPoint takes /*
*/ string text /* Which text you want to display
*/ string color /* Which color you want to combine when texttag reaching
*/ real x /* x of texttag
*/ real y /* y of texttag
*/ real z /* z of texttag
*/ real size /* Size of texttag
*/ real time /* Time out
*/ boolean style /* Style of Texttag (if true, STYLE: Override font color, if false, STYLE: Increase the letter)
*/ integer savenumber /* This number very important, it's a number save with table and you can load this texttag with number :)
*/ returns nothing
//Now for Example:
call Casting.textPoint("KABOOMKABOOM","|cffFFFF00",GetRectCenterX(gg_rct_P),GetRectCenterY(gg_rct_P),5.,15.,5.,false,15)
//
//
static method textNumber takes /*
*/ string color /* Which color you want to combine when texttag reaching
*/ real x /* x of texttag
*/ real y /* y of texttag
*/ real z /* z of texttag
*/ real size /* Size of texttag
*/ real time /* Time out
*/ integer savenumber /* This number very important, it's a number save with table and you can load this texttag with number :)
*/ returns nothing
//Now for Example:
call Casting.textNumber("|cffFFFF00",GetRectCenterX(gg_rct_P),GetRectCenterY(gg_rct_P),5.,15.,5.,10)
//
//
static method TextRun takes /*
*/ unit ct /* Which unit you want to add this texttag
*/ string text /* Which text you want to display
*/ string color /* Which color you want to combine when texttag reaching
*/ real size /* Size of texttag
*/ real time /* Time out
*/ boolean hidetext /* Only you can see this text
*/ boolean hidetextenemies /* Only you and your allies can see this text
*/ boolean style /* Style of Texttag (if true, STYLE: Override font color, if false, STYLE: Increase the letter)
*/ integer savenumber /* This number very important, it's a number save with table and you can load this texttag with number :)
*/ returns nothing
//Now for Example:
call Casting.TextRunning(Player(0),"CastingSystem","|cff00CC66",5.,13.,3.,true,false,true)
//
//
static method TextChannel takes /*
*/ unit ct /* Which unit you want to add this texttag and check order
*/ string text /* Which text you want to display
*/ string color /* Which color you want to combine when texttag reaching
*/ string order /* Order of ability unit using, if order != Current order, this system will deny it and also destroy it, this texttag will be cancel
*/ real size /* Size of texttag
*/ real time /* Time out
*/ boolean hidetext /* Only you can see this text
*/ boolean hidetextenemies /* Only you and your allies can see this text
*/ boolean style /* Style of Texttag (if true, STYLE: Override font color, if false, STYLE: Increase the letter)
*/ returns nothing
//Now for Example:
call Casting.TextChanneling(GetTriggerUnit(),"CastingSystem","carrionswarm","|cff00CC66",GetWidgetX(GetTriggerUnit()),GetWidgetY(GetTriggerUnit()),5.,13.,3.,true,false,true)
//
//
static method NumberRun takes /*
*/ unit ct /* Which unit you want to add this texttag
*/ string color /* Which color you want to combine with number
*/ real size /* Size of texttag
*/ real time /* Time out
*/ boolean hidetext /* Only you can see this text
*/ boolean hidetextenemies /* Only you and your allies can see this text
*/ integer savenumber /* This number very important, it's a number save with table and you can load this texttag with number :)
//Hint: Different with Text, this method display percent of time 1 -> 100% :)
*/ returns nothing
//Now for Example:
call Casting.NumberRunning(Player(0),"|cff00CC66",5.,13.,3.,true,false,true)
//
//
static method NumberChannel takes /*
*/ unit ct /* Which unit you want to add this texttag and check order
*/ string color /* Which color you want to combine with number
*/ string order /* Order of ability unit using, if order != Current order, this system will deny it and also destroy it, this texttag will be cancel
*/ real size /* Size of texttag
*/ real time /* Time out
*/ boolean hidetext /* Only you can see this text
*/ boolean hidetextenemies /* Only you and your allies can see this text
*/ boolean style /* Style of Texttag (if true, STYLE: Override font color, if false, STYLE: Increase the letter)
//Hint: Different with Text, this method display percent of time 1 -> 100% :)
*/ returns nothing
//Now for Example:
call Casting.NumberChanneling(GetTriggerUnit(),"CastingSystem","carrionswarm","|cff00CC66",GetWidgetX(GetTriggerUnit()),GetWidgetY(GetTriggerUnit()),5.,13.,3.,true,false,true)
//! endnovjass
//*************************************************************************************************
// - Installation:
// - Import/copy the required libraries and Casting Text code to your map
// - Read system API
// - You may play with the configurables below
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
library /*
*/ CastingText /*
*/ uses/*
*/ TimerUtils /*
*/ TextTag /*
*/ Table /*
*/ Alloc /*
*/
//*************************************************************************************************
//*************************************************************************************************
//
globals
//==================================SYSTEM SETTINGS==================================
//Delay before destroy texttag, this is useful value, don't change this unless you know what you doing !!
private constant real DELAY = 0.1
//Life span of texttag
private constant real LIFE_SPAN = 1.
//Fade point of texttag
private constant real FADE_POINT = 0.7
//Age of texttag
private constant real AGE = 0.5
//Periodic for this system
private constant real PERIODIC = 0.031250000
// TABLE INSTALL
Table C_TAB
//=========================================================================================
endglobals
//
//=========================================================================================
// Do not change things below
//=========================================================================================
struct Casting extends array
//
implement Alloc
//integer
private integer SN
//unit
private unit caster
//texttag
private texttag t
//string
private string source
private string c
private string o
private string tex
//real
private real timeout
private real intevar
private real s
private real delay
private real logic
private real mt
private real xx
private real yy
private real zz
//integer
private integer l
//boolean
private boolean style
private boolean numbercast
private boolean release
//
method setXYZ takes real x,real y,real z,real size returns nothing
set xx = x
set yy = y
set zz = z
set s = size
endmethod
//
method operator getS takes nothing returns real
return s
endmethod
//
method operator getX takes nothing returns real
return xx
endmethod
//
method operator getY takes nothing returns real
return yy
endmethod
//
method operator getZ takes nothing returns real
return zz
endmethod
//
private method hideText takes boolean hidetext,boolean hidetextenemies returns nothing
//
local integer i
local player p
//
if caster == null then
set p = null
return
endif
//
set i = 0
set p = GetOwningPlayer(caster)
//
if hidetext then
loop
exitwhen i == bj_MAX_PLAYERS
if Player(i) != p then
if GetLocalPlayer() == Player(i) then
call SetTextTagVisibility(t,false)
endif
endif
set i = i + 1
endloop
elseif hidetextenemies then
loop
exitwhen i == bj_MAX_PLAYERS
if Player(i) != p and IsPlayerEnemy(p,Player(i)) then
if GetLocalPlayer() == Player(i) then
call SetTextTagVisibility(t,false)
endif
endif
set i = i + 1
endloop
endif
endmethod
//
method setTextHideForPlayer takes player p,boolean hidetext returns nothing
if caster == null then
return
endif
//
if GetLocalPlayer() == p then
call SetTextTagVisibility(t,false)
endif
endmethod
//
method addText takes string text returns nothing
set tex = text
endmethod
//
method destroyInstantly takes nothing returns nothing
set release = true
endmethod
//
private method removeText takes nothing returns nothing
call C_TAB.remove(SN)
call TextTagAge(t,LIFE_SPAN,FADE_POINT,AGE)
set t = null
set o = null
set tex = null
set source = null
set c = null
set caster = null
call this.deallocate()
endmethod
// This method is periodic
private static method onPeriodic takes nothing returns nothing
local timer ti = GetExpiredTimer()
local thistype this = GetTimerData(ti)
local real a
local string st
//Check time
if timeout > 0 then
//This boolean check this method called is a numbercast method
//
if caster != null then
//Set Texttag Position
set xx = GetWidgetX(caster)
set yy = GetWidgetY(caster)
set zz = GetUnitFlyHeight(caster)
endif
//
if not numbercast then
set intevar = intevar+PERIODIC
//Logical
set a = (intevar/mt)*l
if style then
set st = c + SubString(source,0,R2I(a)) + "|r" + SubString(source,R2I(a),l)
else
set st = c + SubString(source,0,R2I(a))
endif
//
if intevar > l or GetUnitCurrentOrder(caster) != OrderId(o) and o != "" then
set release = true
endif
else
set intevar = intevar + logic
//
set st = c + tex +I2S(R2I(intevar)) + "%"
//
if intevar >= 100. or GetUnitCurrentOrder(caster) != OrderId(o) and o != "" then
set release = true
endif
endif
//
call ChangeTextTag(t,st,s)
//
call SetTextTagPos(t,xx,yy,zz)
//
//Decrease time
set timeout = timeout - PERIODIC
//
else
if not release then
set release = true
endif
endif
//
if release then
//Run delay
if delay < DELAY then
set delay = delay + PERIODIC
else
//Clean data
call ReleaseTimer(ti)
call removeText()
endif
endif
//
set st = null
set ti = null
endmethod
//
//
static method textNumber takes string color,real x,real y,real z,real size,real time,integer savenumber returns nothing
local thistype this = allocate()
local integer i = 0
//
set release = false
set numbercast = true
//
set delay = 0.
set intevar = 0.
//Save with Table
set C_TAB[savenumber] = this
set SN = savenumber
//
set xx = x
set yy = y
set zz = z
//
set tex = ""
set o = ""
set caster = null
set timeout = time
set logic = PERIODIC/timeout*100.
set c = color
set s = size
//
set t = CreateTextTagLoc("",xx,yy,zz,s)
//Calling Periodic
call TimerStart(NewTimerEx(this),PERIODIC,true,function thistype.onPeriodic)
endmethod
//
//
static method textPoint takes string text,string color,real x,real y,real z,real size,real time,boolean style,integer savenumber returns nothing
local thistype this = allocate()
local integer i = 0
//
set release = false
set numbercast = false
//
set delay = 0.
set intevar = 0.
//Save with Table
set C_TAB[savenumber] = this
set SN = savenumber
//
set xx = x
set yy = y
set zz = z
//
set caster = null
set o = ""
set timeout = time
set mt = timeout
set c = color
set s = size
set style = style
//
set source = text
set l = StringLength(source)
//
if style then
set t = CreateTextTagLoc(source,xx,yy,zz,s)
else
set t = CreateTextTagLoc(SubString(source,0,0),GetWidgetX(caster),GetWidgetY(caster),GetUnitFlyHeight(caster),s)
endif
//Calling Periodic
call TimerStart(NewTimerEx(this),PERIODIC,true,function thistype.onPeriodic)
endmethod
//
//
static method textRun takes unit ct,string text,string color,real size,real time,boolean hidetext,boolean hidetextenemies,boolean style,integer savenumber returns nothing
local thistype this = allocate()
local integer i = 0
//
set release = false
set numbercast = false
//
set delay = 0.
set intevar = 0.
//Save with Table
set C_TAB[savenumber] = this
set SN = savenumber
//
set tex = ""
set o = ""
set caster = ct
set timeout = time
set mt = timeout
set c = color
set s = size
set style = style
//
set source = text
set l = StringLength(source)
//
if style then
set t = CreateTextTagLoc(source,GetWidgetX(caster),GetWidgetY(caster),GetUnitFlyHeight(caster),s)
else
set t = CreateTextTagLoc(SubString(source,0,0),GetWidgetX(caster),GetWidgetY(caster),GetUnitFlyHeight(caster),s)
endif
//Check 2 boolean
call hideText(hidetext,hidetextenemies)
//
//Calling Periodic
call TimerStart(NewTimerEx(this),PERIODIC,true,function thistype.onPeriodic)
endmethod
//
//
static method textChannel takes unit ct,string text,string order,string color,real size,real time,boolean hidetext,boolean hidetextenemies,boolean style returns nothing
local thistype this = allocate()
local integer i = 0
//
set release = false
set numbercast = false
//
set delay = 0.
set intevar = 0.
//
set o = order
set caster = ct
set timeout = time
set mt = timeout
set c = color
set s = size
set style = style
set o = order
//
set source = text
set l = StringLength(source)
//
if style then
set t = CreateTextTagLoc(source,GetWidgetX(caster),GetWidgetY(caster),GetUnitFlyHeight(caster),s)
else
set t = CreateTextTagLoc(SubString(source,0,0),GetWidgetX(caster),GetWidgetY(caster),GetUnitFlyHeight(caster),s)
endif
//Check 2 boolean
call hideText(hidetext,hidetextenemies)
//
//Calling Periodic
call TimerStart(NewTimerEx(this),PERIODIC,true,function thistype.onPeriodic)
endmethod
//
//
static method numberRun takes unit ct, string color,real size,real time,boolean hidetext,boolean hidetextenemies,integer savenumber returns nothing
local thistype this = allocate()
local integer i = 0
//
set release = false
set numbercast = true
//
set delay = 0.
set intevar = 1.
//Save with Table
set C_TAB[savenumber] = this
set SN = savenumber
//
set tex = ""
set o = ""
set caster = ct
set timeout = time
set logic = PERIODIC/timeout*100.
set c = color
set s = size
//
set t = CreateTextTagLoc("",GetWidgetX(caster),GetWidgetY(caster),GetUnitFlyHeight(caster),s)
//Check 2 boolean
call hideText(hidetext,hidetextenemies)
//Calling Periodic
call TimerStart(NewTimerEx(this),PERIODIC,true,function thistype.onPeriodic)
endmethod
//
//
//
static method numberChannel takes unit ct,string order,string color,real size,real time,boolean hidetext,boolean hidetextenemies returns nothing
local thistype this = allocate()
local integer i = 0
//
set release = false
set numbercast = true
//
set delay = 0.
set intevar = 0.
//
set o = order
set caster = ct
set timeout = time
set o = order
set logic = PERIODIC/timeout*100.
set c = color
set s = size
set t = CreateTextTagLoc("",GetWidgetX(caster),GetWidgetY(caster),GetUnitFlyHeight(caster),s)
//
call hideText(hidetext,hidetextenemies)
//Calling Periodic
call TimerStart(NewTimerEx(this),PERIODIC,true,function thistype.onPeriodic)
endmethod
//
private static method onInit takes nothing returns nothing
set C_TAB = Table.create()
endmethod
endstruct
endlibrary[/HIDDEN]