function H2I takes handle h returns integer
return GetHandleId(h)
endfunction
function ReturnInteger takes integer i returns integer
return i
endfunction
function I2T takes integer i returns timer
call ReturnInteger(i)
if false then
return null
endif
endfunction
function I2Img takes integer i returns image
call ReturnInteger(i)
if false then
return null
endif
endfunction
function I2U takes integer i returns unit
call ReturnInteger(i)
if false then
return null
endif
endfunction
function I2Cnd takes integer i returns conditionfunc
call ReturnInteger(i)
if false then
return null
endif
endfunction
function I2Trg takes integer i returns trigger
call ReturnInteger(i)
if false then
return null
endif
endfunction
function ARCache takes nothing returns gamecache
if (udg_ArrayCache==null) then
call FlushGameCache(InitGameCache("ARCache.vx"))
set udg_ArrayCache=InitGameCache("ARCache.vx")
endif
return udg_ArrayCache
endfunction
function TSCache takes nothing returns gamecache
if (udg_TextSplatCache==null) then
call FlushGameCache(InitGameCache("TSCache.vx"))
set udg_TextSplatCache=InitGameCache("TSCache.vx")
endif
return udg_TextSplatCache
endfunction
function Print takes string s returns nothing
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 10, s)
endfunction
function AngleBetweenCoordinates takes real xa, real ya, real xb, real yb returns real
return bj_RADTODEG * Atan2(yb - ya, xb - xa)
endfunction
function DistanceBetweenCoordinates takes real xa, real ya, real xb, real yb returns real
return SquareRoot((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya))
endfunction
function PolarProjectionX takes real x, real dist, real angle returns real
return x + dist * Cos(angle * bj_DEGTORAD)
endfunction
function PolarProjectionY takes real y, real dist, real angle returns real
return y + dist * Sin(angle * bj_DEGTORAD)
endfunction
function Asc takes string char returns integer
local string charmap = " !\"#$%%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
local string first = SubString(char, 0, 1)
local string c = ""
local integer i = 0
if first == "" or first == null then
return 0
elseif first == "\b" then // backspace
return 8
elseif first == "\t" then // horizontal tab
return 9
elseif first == "\n" then // new line
return 10
elseif first == "\f" then // form feed
return 12
elseif first == "\r" then // carriage return
return 13
endif
loop
set c = SubString(charmap, i, i + 1)
exitwhen c == ""
if c == first then
return i + 32
endif
set i = i + 1
endloop
return 0
endfunction
function IdString2IdInteger takes string value returns integer
if StringLength(value) == 4 then
return Asc(SubString(value, 0, 1)) * 0x1000000 + Asc(SubString(value, 1, 2)) * 0x10000 + Asc(SubString(value, 2, 3)) * 0x100 + Asc(SubString(value, 3, 4))
elseif StringLength(value) == 1 then
return Asc(value)
endif
return 0
endfunction
function Chr takes integer ascii returns string
if ascii == 0 then
return null
elseif ascii >= 8 and ascii <= 10 then
return SubString("\b\t\n", ascii - 8, ascii - 7)
elseif ascii >= 12 and ascii <= 13 then
return SubString("\f\r", ascii - 12, ascii - 11)
elseif ascii >= 32 and ascii <= 127 then
return SubString(" !\"#$%%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", ascii - 32, ascii - 31)
endif
return ""
endfunction
function IdInteger2IdString takes integer value returns string
local string charmap = " !\"#$%%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
local string result = ""
local integer remainder = value
local integer charval = 0
loop
set charval = ModuloInteger(remainder, 256)
set remainder = remainder / 256
if charval >= 32 and charval <= 127 then
set result = SubString(charmap, charval - 32, charval - 31) + result
else
set result = " " + result
endif
exitwhen remainder <= 0
endloop
return result
endfunction
function ITertiaryOp takes boolean flag, integer a, integer b returns integer
if flag then
return a
else
return b
endif
endfunction
function RTertiaryOp takes boolean flag, real a, real b returns real
if flag then
return a
else
return b
endif
endfunction
function STertiaryOp takes boolean flag, string a, string b returns string
if flag then
return a
else
return b
endif
endfunction
function MatchesCharMap takes string source, string charmap returns integer
local integer i = 0
local integer j = 0
local integer slength = StringLength(source)
local integer clength = StringLength(charmap)
loop
exitwhen i == slength
set j = 0
loop
exitwhen SubString(source, i, i + 1) == SubString(charmap, j, j + 1)
if (j == clength) then
return i
endif
set j = j + 1
endloop
set i = i + 1
endloop
return i
endfunction
function IsHexadecimal takes string source returns boolean
return MatchesCharMap(source, "abcdefABCDEF1234567890") == StringLength(source)
endfunction
function IsNumeric takes string source returns boolean
return MatchesCharMap(source, "1234567890") == StringLength(source)
endfunction
function Val takes string s returns integer
if (StringLength(s) == 0) then
return 0
elseif (SubString(s, 0, 1) == "-") then
return ITertiaryOp(IsNumeric(SubString(s, 1, StringLength(s))), S2I(s), 0)
endif
return ITertiaryOp(IsNumeric(s), S2I(s), 0)
endfunction
function AreSimilar takes real r1, real r2, real delta returns boolean
return (r2 >= r1 - delta) and (r2 <= r1 + delta)
endfunction
//############################################################################################################
//##Begin of CONSTANTS##
//############################################################################################################
constant function ARR_INSTANCE takes nothing returns string
return "Array::Instance"
endfunction
constant function TS_INSTANCE takes nothing returns string
return "TextSplat::Instance"
endfunction
constant function TS_STATIC takes nothing returns string
return "TextSplat::Static"
endfunction
constant function TS_ARRAY_NAME takes nothing returns string
return "TextSplatArray"
endfunction
constant function TS_FONTSPATH takes nothing returns string
return "Fonts\\"
endfunction
constant function TS_ALIGN_LEFT takes nothing returns integer
return 0
endfunction
constant function TS_ALIGN_TOP takes nothing returns integer
return 0
endfunction
constant function TS_ALIGN_CENTER takes nothing returns integer
return 1
endfunction
constant function TS_ALIGN_RIGHT takes nothing returns integer
return 2
endfunction
constant function TS_ALIGN_BOTTOM takes nothing returns integer
return 2
endfunction
function TextSplatGetMovementTimeElapsed takes nothing returns real
return bj_meleeNearestMineDist
endfunction
function TextSplatGetMovementExecCount takes nothing returns integer
return bj_groupEnumTypeId
endfunction
function TextSplatSetMovementResult takes real value returns nothing
set bj_meleeNearestMineDist = value
endfunction
//############################################################################################################
//##Begin of General UTILITY FUNCTIONS##
//############################################################################################################
function CreateImageEx takes string path, real sizeX, real sizeY, real posX, real posY, real posZ, boolean show returns image
local image i = CreateImage(path, sizeX, sizeY, 0, posX - (sizeX / 2), posY - (sizeY / 2), posZ, 0, 0, 0, 2) // image type indicator
call SetImageRenderAlways(i, true)
call ShowImage(i, show)
return i
endfunction
function CreateColorInteger takes integer red, integer green, integer blue, integer alpha returns integer
return red + green * 0x100 + blue * 0x10000 + alpha * 0x1000000
endfunction
function ColorIntegerGetRed takes integer i returns integer
if i < 0 then
return ModuloInteger(i + 0x80000000, 0x100)
endif
return ModuloInteger(i, 0x100)
endfunction
function ColorIntegerGetGreen takes integer i returns integer
if i < 0 then
return ModuloInteger((i + 0x80000000) / 0x100, 0x100)
endif
return ModuloInteger(i / 0x100, 0x100)
endfunction
function ColorIntegerGetBlue takes integer i returns integer
if i < 0 then
return ModuloInteger((i + 0x80000000) / 0x10000, 0x100)
endif
return ModuloInteger(i / 0x10000, 0x100)
endfunction
function ColorIntegerGetAlpha takes integer i returns integer
if i < 0 then
return (i + 0x80000000) / 0x1000000 + 0x80
endif
return i / 0x1000000
endfunction
function CreateColorString takes integer red, integer green, integer blue, integer alpha returns string
local string charMap = "0123456789abcdef"
local integer c = alpha / 0x10
local string cs = SubString(charMap, c, c + 1)
set c = ModuloInteger(alpha, 0x10)
set cs = cs + SubString(charMap, c, c + 1)
set c = red / 0x10
set cs = cs + SubString(charMap, c, c + 1)
set c = ModuloInteger(red, 0x10)
set cs = cs + SubString(charMap, c, c + 1)
set c = green / 0x10
set cs = cs + SubString(charMap, c, c + 1)
set c = ModuloInteger(green, 0x10)
set cs = cs + SubString(charMap, c, c + 1)
set c = blue / 0x10
set cs = cs + SubString(charMap, c, c + 1)
set c = ModuloInteger(blue, 0x10)
return cs + SubString(charMap, c, c + 1)
endfunction
function ColorStringGetColor takes string s returns integer
local string charMapL = "0123456789abcdef"
local string charMapU = "0123456789ABCDEF"
local string c1 = SubString(s, 0, 1)
local string c2 = SubString(s, 1, 2)
local integer x = 0
local integer y = 0
loop
exitwhen x == 15 or SubString(charMapL, x, x + 1) == c1 or SubString(charMapU, x, x + 1) == c1
set x = x + 1
endloop
loop
exitwhen y == 15 or SubString(charMapL, y, y + 1) == c2 or SubString(charMapU, y, y + 1) == c2
set y = y + 1
endloop
return x * 16 + y
endfunction
function ColorStringGetRed takes string s returns integer
return ColorStringGetColor(SubString(s, 2, 4))
endfunction
function ColorStringGetGreen takes string s returns integer
return ColorStringGetColor(SubString(s, 4, 6))
endfunction
function ColorStringGetBlue takes string s returns integer
return ColorStringGetColor(SubString(s, 6, 8))
endfunction
function ColorStringGetAlpha takes string s returns integer
return ColorStringGetColor(SubString(s, 0, 2))
endfunction
function ColorString2ColorInteger takes string cs returns integer
local string charMapL = "0123456789abcdef"
local string charMapU = "0123456789ABCDEF"
local string c = ""
local integer i = 0
local integer d = 0
local integer array cia
if cs == null or cs == "" then
return 0
endif
loop
exitwhen i == 8
set c = SubString(cs, i, i + 1)
set d = 0
loop
exitwhen d == 15 or SubString(charMapL, d, d + 1) == c or SubString(charMapU, d, d + 1) == c
set d = d + 1
endloop
set cia[i] = d
set i = i + 1
endloop
return cia[0] * 0x10000000 + cia[1] * 0x1000000 + cia[2] * 0x10 + cia[3] + cia[4] * 0x1000 + cia[5] * 0x100 + cia[6] * 0x100000 + cia[7] * 0x10000
endfunction
function ColorInteger2ColorString takes integer ci returns string
local string charMap = "0123456789abcdef"
local string cs = ""
local integer c = 0
if ci < 0 then
set ci = ci + 0x80000000
set c = ci / 0x10000000 + 0x8
else
set c = ci / 0x10000000
endif
set cs = SubString(charMap, c, c + 1)
set c = ModuloInteger(ci / 0x1000000, 16)
set cs = cs + SubString(charMap, c, c + 1)
set c = ModuloInteger(ci / 0x10, 16)
set cs = cs + SubString(charMap, c, c + 1)
set c = ModuloInteger(ci, 16)
set cs = cs + SubString(charMap, c, c + 1)
set c = ModuloInteger(ci / 0x1000, 16)
set cs = cs + SubString(charMap, c, c + 1)
set c = ModuloInteger(ci / 0x100, 16)
set cs = cs + SubString(charMap, c, c + 1)
set c = ModuloInteger(ci / 0x100000, 16)
set cs = cs + SubString(charMap, c, c + 1)
set c = ModuloInteger(ci / 0x10000, 16)
return cs + SubString(charMap, c, c + 1)
endfunction
function CreateArray takes string name returns nothing
endfunction
function DestroyArray takes string name returns nothing
local integer maxF = GetStoredInteger(udg_ArrayCache, ARR_INSTANCE() + name, "MaxFreed")
local integer i = 0
loop
exitwhen i >= maxF
call FlushStoredInteger(udg_ArrayCache, ARR_INSTANCE() + name, "FreedIndex" + I2S(i))
set i = i + 1
endloop
call FlushStoredInteger(udg_ArrayCache, ARR_INSTANCE() + name, "MaxFreed")
call FlushStoredInteger(udg_ArrayCache, ARR_INSTANCE() + name, "MaxUsed")
endfunction
function GetFreeArrayIndex takes string name returns integer
local integer maxU = GetStoredInteger(udg_ArrayCache, ARR_INSTANCE() + name, "MaxUsed")
local integer maxF = GetStoredInteger(udg_ArrayCache, ARR_INSTANCE() + name, "MaxFreed")
if (maxF > 0) then
call StoreInteger(udg_ArrayCache, ARR_INSTANCE() + name, "MaxFreed", maxF - 1)
set maxU = GetStoredInteger(udg_ArrayCache, ARR_INSTANCE() + name, "FreedIndex" + I2S(maxF - 1))
call FlushStoredInteger(udg_ArrayCache, ARR_INSTANCE() + name, "FreedIndex")
return maxU
endif
call StoreInteger(udg_ArrayCache, ARR_INSTANCE() + name, "MaxUsed", maxU + 1)
return maxU + 1
endfunction
function FreeArrayIndex takes string name, integer index returns nothing
local integer maxU = GetStoredInteger(udg_ArrayCache, ARR_INSTANCE() + name, "MaxUsed")
local integer maxF = GetStoredInteger(udg_ArrayCache, ARR_INSTANCE() + name, "MaxFreed")
local integer i = 0
if (index == maxU) then
if (maxU <= 1) then
call FlushStoredInteger(udg_ArrayCache, ARR_INSTANCE() + name, "MaxUsed")
else
call StoreInteger(udg_ArrayCache, ARR_INSTANCE() + name, "MaxUsed", maxU - 1)
endif
elseif (index < maxU) then
loop
exitwhen i >= maxF
if (GetStoredInteger(udg_ArrayCache, ARR_INSTANCE() + name, "FreedIndex" + I2S(i)) == index) then
return
endif
set i = i + 1
endloop
call StoreInteger(udg_ArrayCache, ARR_INSTANCE() + name, "FreedIndex" + I2S(maxF), index)
call StoreInteger(udg_ArrayCache, ARR_INSTANCE() + name, "MaxFreed", maxF + 1)
endif
endfunction
//############################################################################################################
//##Begin of PRIVATE TextSplat FUNCTIONS##
//############################################################################################################
function ts_UpdateTextSplatPosition takes nothing returns nothing
local string ref = TS_INSTANCE() + I2S(bj_groupEnumTypeId)
local integer size = GetStoredInteger(udg_TextSplatCache, ref, "Size")
local integer valign = GetStoredInteger(udg_TextSplatCache, ref, "Valign")
local integer halign = GetStoredInteger(udg_TextSplatCache, ref, "Halign")
local integer lineCount = GetStoredInteger(udg_TextSplatCache, ref, "LineCount")
local string font = "Font::" + GetStoredString(udg_TextSplatCache, ref, "Font")
local real widthPerUnit = (size * 4.0) / 32.0
local real heightPerUnit = (size * 4.0) / 32.0
local real maxWidth = GetStoredInteger(udg_TextSplatCache, ref, "MaxWidth") * widthPerUnit
local real maxHeight = lineCount * 32 * heightPerUnit
local integer nrLetters = 0
local real lineWidth = 0
local real letterWidth = 0
local real xOffset = 0
local real yOffset = 0
local real curX = 0
local real curY = 0
local integer i = GetStoredInteger(udg_TextSplatCache, ref, "StartIndex")
local integer count = 0
local integer cur = 0
local integer j = 0
loop
exitwhen count == lineCount
set j = 0
set xOffset = 0
if (valign == 0) then
set curY = bj_meleeNearestMineDist - yOffset // otherwise +
elseif (valign == 1) then
set curY = bj_meleeNearestMineDist + ((lineCount / 2) - count) * 32 * heightPerUnit // otherwise (lineCount / 2) - (lineCount - count)
else
set curY = bj_meleeNearestMineDist + (lineCount - 1) * 32 * heightPerUnit - yOffset
endif
set cur = GetStoredInteger(udg_TextSplatCache, ref, "StartIndex" + I2S(i))
set lineWidth = GetStoredInteger(udg_TextSplatCache, ref, "LineWidth" + I2S(i)) * widthPerUnit
set nrLetters = GetStoredInteger(udg_TextSplatCache, ref, "LetterCount" + I2S(i))
loop
exitwhen j == nrLetters
set letterWidth = GetStoredInteger(udg_TextSplatCache, font, "Width" + I2S(GetStoredInteger(udg_TextSplatCache, ref, "Letter" + I2S(cur) + "Line" + I2S(i)))) * widthPerUnit
if (halign == 0) then
set curX = bj_enumDestructableRadius + xOffset
elseif (halign == 1) then
set curX = bj_enumDestructableRadius + (maxWidth / 2) - (lineWidth / 2) + xOffset
else
set curX = bj_enumDestructableRadius + maxWidth - lineWidth + xOffset
endif
call SetImagePosition(I2Img(GetStoredInteger(udg_TextSplatCache, ref, "Image" + I2S(cur) + "Line" + I2S(i))), curX, curY, 0)
set xOffset = xOffset + letterWidth
set cur = ModuloInteger(cur + 1, nrLetters)
set j = j + 1
endloop
set yOffset = yOffset + (32 * heightPerUnit)
set count = count + 1
set i = ModuloInteger(i + 1, lineCount)
endloop
endfunction
function ts_FadeCleanup takes integer id, boolean forced returns nothing
local string callback = "DoNothing"
local integer owner = GetStoredInteger(udg_TextSplatCache, "FadeTimer::" + I2S(id), "Owner")
if (id > 0) then
call PauseTimer(I2T(id))
call DestroyTimer(I2T(id))
if (not forced) then
set callback = GetStoredString(udg_TextSplatCache, "FadeTimer::" + I2S(id), "Callback")
if (callback == "" or callback == null) then
set callback = "DoNothing"
else
set bj_groupEnumTypeId = owner
endif
endif
call FlushStoredInteger(udg_TextSplatCache, TS_INSTANCE() + I2S(owner), "FadeTimer")
call FlushStoredMission(udg_TextSplatCache, "FadeTimer::" + I2S(id))
call ExecuteFunc(callback)
endif
endfunction
function ts_UpdateAlpha takes integer id, integer newAlpha returns nothing
local string ref = "FadeTimer::" + I2S(id)
local string owner = TS_INSTANCE() + I2S(GetStoredInteger(udg_TextSplatCache, ref, "Owner"))
local integer defColor = GetStoredInteger(udg_TextSplatCache, owner, "DefaultColor")
local integer lines = GetStoredInteger(udg_TextSplatCache, owner, "LineCount")
local integer kind = GetStoredInteger(udg_TextSplatCache, owner, "ColorType")
local integer curColor = 0
local integer colorTag = 0
local integer letters = 0
local integer i = 0
local integer j = 0
call StoreInteger(udg_TextSplatCache, owner, "DefaultColor", CreateColorInteger(ColorIntegerGetRed(defColor), ColorIntegerGetGreen(defColor), ColorIntegerGetBlue(defColor), newAlpha))
loop
exitwhen i == lines
set letters = GetStoredInteger(udg_TextSplatCache, owner, "LetterCount" + I2S(i))
set j = 0
loop
exitwhen j == letters
if (kind == 1) then
set curColor = GetStoredInteger(udg_TextSplatCache, owner, "Color" + I2S(j) + "Line" + I2S(i))
call StoreInteger(udg_TextSplatCache, owner, "Color" + I2S(j) + "Line" + I2S(i), CreateColorInteger(ColorIntegerGetRed(curColor), ColorIntegerGetGreen(curColor), ColorIntegerGetBlue(curColor), newAlpha))
else
set colorTag = GetStoredInteger(udg_TextSplatCache, owner, "ColorTag" + I2S(j) + "Line" + I2S(i))
if (colorTag == 1) then
set curColor = GetStoredInteger(udg_TextSplatCache, owner, "Color" + I2S(j) + "Line" + I2S(i))
call StoreInteger(udg_TextSplatCache, owner, "Color" + I2S(j) + "Line" + I2S(i), CreateColorInteger(ColorIntegerGetRed(curColor), ColorIntegerGetGreen(curColor), ColorIntegerGetBlue(curColor), newAlpha))
endif
endif
set j = j + 1
endloop
set i = i + 1
endloop
endfunction
function ts_FadeUpdate takes integer id, integer stage returns nothing
local string ref = "FadeTimer::" + I2S(id)
local string owner = TS_INSTANCE() + I2S(GetStoredInteger(udg_TextSplatCache, ref, "Owner"))
local integer newAlpha = GetStoredInteger(udg_TextSplatCache, ref, "FadeStart") + R2I(GetStoredReal(udg_TextSplatCache, ref, "FadeIncrement") * stage)
local integer lines = GetStoredInteger(udg_TextSplatCache, owner, "LineCount")
local integer defColor = GetStoredInteger(udg_TextSplatCache, owner, "DefaultColor")
local integer maxTimes = GetStoredInteger(udg_TextSplatCache, ref, "FadeTimes")
local integer curColor = defColor
local integer colorTag = 0
local integer kind = GetStoredInteger(udg_TextSplatCache, owner, "ColorType")
local integer r = ColorIntegerGetRed(defColor)
local integer g = ColorIntegerGetGreen(defColor)
local integer b = ColorIntegerGetBlue(defColor)
local integer letters = 0
local integer i = 0
local integer j = 0
call StoreInteger(udg_TextSplatCache, owner, "DefaultColor", CreateColorInteger(ColorIntegerGetRed(defColor), ColorIntegerGetGreen(defColor), ColorIntegerGetBlue(defColor), newAlpha))
loop
exitwhen i == lines
set letters = GetStoredInteger(udg_TextSplatCache, owner, "LetterCount" + I2S(i))
set j = 0
loop
exitwhen j == letters
if (kind == 1) then
set curColor = GetStoredInteger(udg_TextSplatCache, owner, "Color" + I2S(j) + "Line" + I2S(i))
call SetImageColor(I2Img(GetStoredInteger(udg_TextSplatCache, owner, "Image" + I2S(j) + "Line" + I2S(i))), ColorIntegerGetRed(curColor), ColorIntegerGetGreen(curColor), ColorIntegerGetBlue(curColor), newAlpha)
else
set colorTag = GetStoredInteger(udg_TextSplatCache, owner, "ColorTag" + I2S(j) + "Line" + I2S(i))
if (colorTag > 0) then
if (colorTag == 1) then
set curColor = GetStoredInteger(udg_TextSplatCache, owner, "Color" + I2S(j) + "Line" + I2S(i))
elseif (colorTag == 2) then
set curColor = defColor
endif
set r = ColorIntegerGetRed(curColor)
set g = ColorIntegerGetGreen(curColor)
set b = ColorIntegerGetBlue(curColor)
endif
call SetImageColor(I2Img(GetStoredInteger(udg_TextSplatCache, owner, "Image" + I2S(j) + "Line" + I2S(i))), r, g, b, newAlpha)
endif
set j = j + 1
endloop
set i = i + 1
endloop
if (stage == maxTimes) then
call ts_UpdateAlpha(id, GetStoredInteger(udg_TextSplatCache, ref, "FadeEnd"))
call ts_FadeCleanup(id, false)
endif
endfunction
function ts_FadeUpdateCallback takes nothing returns nothing
local integer id = H2I(GetExpiredTimer())
local integer count = GetStoredInteger(udg_TextSplatCache, "FadeTimer::" + I2S(id), "ExpirationCount") + 1
call StoreInteger(udg_TextSplatCache, "FadeTimer::" + I2S(id), "ExpirationCount", count)
call ts_FadeUpdate(H2I(GetExpiredTimer()), count)
endfunction
function ts_AttachmentCleanup takes integer id returns nothing
if (id > 0) then
call PauseTimer(I2T(id))
call DestroyTimer(I2T(id))
call FlushStoredInteger(udg_TextSplatCache, TS_INSTANCE() + I2S(GetStoredInteger(udg_TextSplatCache, "AttachmentTimer::" + I2S(id), "Owner")), "AttachmentTimer")
call FlushStoredMission(udg_TextSplatCache, "AttachmentTimer::" + I2S(id))
endif
endfunction
function ts_AttachmentUpdate takes integer id returns nothing
local string ref = "AttachmentTimer::" + I2S(id)
local string owner = TS_INSTANCE() + I2S(GetStoredInteger(udg_TextSplatCache, ref, "Owner"))
local real x = GetUnitX(I2U(GetStoredInteger(udg_TextSplatCache, ref, "Target")))
local real y = GetUnitY(I2U(GetStoredInteger(udg_TextSplatCache, ref, "Target")))
local trigger t = I2Trg(GetStoredInteger(udg_TextSplatCache, owner, "Dispatcher"))
call StoreReal(udg_TextSplatCache, owner, "BaseX", x)
call StoreReal(udg_TextSplatCache, owner, "BaseY", y)
set bj_enumDestructableRadius = x + GetStoredReal(udg_TextSplatCache, owner, "OffsetX")
set bj_meleeNearestMineDist = y + GetStoredReal(udg_TextSplatCache, owner, "OffsetY")
set bj_groupEnumTypeId = GetStoredInteger(udg_TextSplatCache, ref, "Owner")
call TriggerEvaluate(t)
set t = null
endfunction
function ts_AttachmentUpdateCallback takes nothing returns nothing
call ts_AttachmentUpdate(H2I(GetExpiredTimer()))
endfunction
function ts_RunCleanup takes integer prev, timer t, boolean moreV, boolean moreH returns nothing
local string ref = "RunTimer::" + I2S(H2I(t))
local integer next = GetStoredInteger(udg_TextSplatCache, ref, "NextRunTimer")
local boolean doV = GetStoredInteger(udg_TextSplatCache, ref, "VerticalStepWidth") != 0
local boolean doH = GetStoredInteger(udg_TextSplatCache, ref, "HorizontalStepWidth") != 0
local integer i = next
call PauseTimer(t)
call DestroyTimer(t)
set ref = TS_INSTANCE() + I2S(GetStoredInteger(udg_TextSplatCache, ref, "Owner"))
call FlushStoredMission(udg_TextSplatCache, "RunTimer::" + I2S(H2I(t)))
if (next > 0) then
if (not (moreV and moreH) and not (not doV and not doH)) then
loop
exitwhen (i <= 0)
set moreV = moreV or GetStoredInteger(udg_TextSplatCache, "RunTimer::" + I2S(i), "VerticalStepWidth") != 0
set moreH = moreH or GetStoredInteger(udg_TextSplatCache, "RunTimer::" + I2S(i), "HorizontalStepWidth") != 0
set i = GetStoredInteger(udg_TextSplatCache, "RunTimer::" + I2S(i), "NextRunTimer")
endloop
endif
if (prev > 0) then
call StoreInteger(udg_TextSplatCache, "RunTimer::" + I2S(prev), "NextRunTimer", next)
else
call StoreInteger(udg_TextSplatCache, ref, "RunTimer", next)
endif
else
if (prev > 0) then
call FlushStoredInteger(udg_TextSplatCache, "RunTimer::" + I2S(prev), "NextRunTimer")
else
call FlushStoredInteger(udg_TextSplatCache, ref, "RunTimer")
endif
endif
set i = GetStoredInteger(udg_TextSplatCache, ref, "RunCount") - 1
if (i <= 0) then
call FlushStoredInteger(udg_TextSplatCache, ref, "RunCount")
else
call StoreInteger(udg_TextSplatCache, ref, "RunCount", i)
endif
if (doV and not moreV) then
call FlushStoredInteger(udg_TextSplatCache, ref, "StartIndex")
endif
if (doH and not moreH) then
set i = 0
set next = GetStoredInteger(udg_TextSplatCache, ref, "LineCount")
loop
exitwhen i == next
call FlushStoredInteger(udg_TextSplatCache, ref, "StartIndex" + I2S(i))
set i = i + 1
endloop
endif
endfunction
function ts_RunUpdate takes integer id returns nothing
local integer owner = GetStoredInteger(udg_TextSplatCache, "RunTimer::" + I2S(id), "Owner")
local integer vStep = GetStoredInteger(udg_TextSplatCache, "RunTimer::" + I2S(id), "VerticalStepWidth")
local integer hStep = GetStoredInteger(udg_TextSplatCache, "RunTimer::" + I2S(id), "HorizontalStepWidth")
local string ref = TS_INSTANCE() + I2S(owner)
local integer lines = GetStoredInteger(udg_TextSplatCache, ref, "LineCount")
local integer lcount = 0
local trigger t = null
local integer i = 0
if (lines > 0) then
call StoreInteger(udg_TextSplatCache, ref, "StartIndex", ModuloInteger(GetStoredInteger(udg_TextSplatCache, ref, "StartIndex") + vStep, lines))
loop
exitwhen i == lines
set lcount = GetStoredInteger(udg_TextSplatCache, ref, "LetterCount" + I2S(i))
if (lcount > 0) then
call StoreInteger(udg_TextSplatCache, ref, "StartIndex" + I2S(i), ModuloInteger(GetStoredInteger(udg_TextSplatCache, ref, "StartIndex" + I2S(i)) + hStep, lcount))
endif
set i = i + 1
endloop
set t = I2Trg(GetStoredInteger(udg_TextSplatCache, ref, "Dispatcher"))
set bj_enumDestructableRadius = GetStoredReal(udg_TextSplatCache, ref, "BaseX") + GetStoredReal(udg_TextSplatCache, ref, "OffsetX")
set bj_meleeNearestMineDist = GetStoredReal(udg_TextSplatCache, ref, "BaseY") + GetStoredReal(udg_TextSplatCache, ref, "OffsetY")
set bj_groupEnumTypeId = owner
call TriggerEvaluate(t)
set t = null
endif
endfunction
function ts_RunUpdateCallback takes nothing returns nothing
call ts_RunUpdate(H2I(GetExpiredTimer()))
endfunction
function ts_HornerSchema takes real x, string ref, string dimension returns real
local integer i = GetStoredInteger(udg_TextSplatCache, ref, "Level(" + dimension + ")")
local real g = GetStoredInteger(udg_TextSplatCache, ref, "f(" + dimension + ")=" + I2S(i))
loop
exitwhen i == 0
set i = i - 1
set g = (g * x) + GetStoredInteger(udg_TextSplatCache, ref, "f(" + dimension + ")=" + I2S(i))
endloop
return g
endfunction
function ts_StoreFunctionCurve takes string ref, string f, string dimension returns nothing
local string cur = ";"
local string val = ""
local integer i = 0
local integer count = 0
local integer len = StringLength(f)
loop
exitwhen i == len
set cur = SubString(f, i, i + 1)
if (cur == ";") then
call StoreInteger(udg_TextSplatCache, ref, "f(" + dimension + ")=" + I2S(count), Val(val))
set count = count + 1
set val = ""
else
set val = val + cur
endif
set i = i + 1
endloop
if (val != "") then
call StoreInteger(udg_TextSplatCache, ref, "f(" + dimension + ")=" + I2S(count), Val(val))
set count = count + 1
endif
call StoreInteger(udg_TextSplatCache, ref, "Level(" + dimension + ")", count - 1)
endfunction
function ts_MovementCleanup takes integer id, boolean forced returns nothing
local string callback = "DoNothing"
local string ref = "MovementTimer::" + I2S(id)
local integer c = 0
local integer t = 0
local integer e = 0
local integer owner = GetStoredInteger(udg_TextSplatCache, ref, "Owner")
if (id > 0) then
if (not forced) then
set callback = GetStoredString(udg_TextSplatCache, ref, "Callback")
if (callback == "" or callback == null) then
set callback = "DoNothing"
else
set bj_groupEnumTypeId = owner
endif
endif
set e = GetStoredInteger(udg_TextSplatCache, ref, "Elapsed")
set c = GetStoredInteger(udg_TextSplatCache, ref, "ConditionX")
set t = GetStoredInteger(udg_TextSplatCache, ref, "TriggerX")
call PauseTimer(I2T(id))
call DestroyTimer(I2T(id))
call PauseTimer(I2T(e))
call DestroyTimer(I2T(e))
call DestroyTrigger(I2Trg(t))
call DestroyCondition(I2Cnd(c))
call FlushStoredMission(udg_TextSplatCache, "MovementTimer::" + I2S(e))
call FlushStoredInteger(udg_TextSplatCache, TS_INSTANCE() + I2S(owner), "MovementTimer")
call FlushStoredMission(udg_TextSplatCache, ref)
call ExecuteFunc(callback)
endif
endfunction
function ts_MovementUpdate takes integer id returns nothing
local string ref = "MovementTimer::" + I2S(id)
local string owner = TS_INSTANCE() + I2S(GetStoredInteger(udg_TextSplatCache, ref, "Owner"))
local real elapsed = TimerGetElapsed(I2T(GetStoredInteger(udg_TextSplatCache, ref, "Elapsed")))
local trigger tX = I2Trg(GetStoredInteger(udg_TextSplatCache, ref, "TriggerX"))
local trigger tY = I2Trg(GetStoredInteger(udg_TextSplatCache, ref, "TriggerY"))
local trigger t = I2Trg(GetStoredInteger(udg_TextSplatCache, owner, "Dispatcher"))
set bj_groupEnumTypeId = GetStoredInteger(udg_TextSplatCache, ref, "ExecCount")
call StoreInteger(udg_TextSplatCache, ref, "ExecCount", bj_groupEnumTypeId + 1)
set bj_meleeNearestMineDist = elapsed
call TriggerEvaluate(tX)
call StoreReal(udg_TextSplatCache, owner, "OffsetX", bj_meleeNearestMineDist)
set bj_enumDestructableRadius = GetStoredReal(udg_TextSplatCache, owner, "BaseX") + bj_meleeNearestMineDist
set bj_meleeNearestMineDist = elapsed
call TriggerEvaluate(tY)
call StoreReal(udg_TextSplatCache, owner, "OffsetY", bj_meleeNearestMineDist)
set bj_meleeNearestMineDist = GetStoredReal(udg_TextSplatCache, owner, "BaseY") + bj_meleeNearestMineDist
set bj_groupEnumTypeId = GetStoredInteger(udg_TextSplatCache, ref, "Owner")
call TriggerEvaluate(t)
set tX = null
set tY = null
set t = null
endfunction
function ts_MovementUpdateCallback takes nothing returns nothing
call ts_MovementUpdate(H2I(GetExpiredTimer()))
endfunction
function ts_MovementCleanupCallback takes nothing returns nothing
call ts_MovementCleanup(GetStoredInteger(udg_TextSplatCache, "MovementTimer::" + I2S(H2I(GetExpiredTimer())), "Elapsed"), false)
endfunction
function ts_CreateTextSplat takes string text, real baseX, real baseY, string font, integer size, integer valign, integer halign, integer color returns integer
local integer id = GetFreeArrayIndex(TS_ARRAY_NAME())
local string ref = TS_INSTANCE() + I2S(id)
local image img = null
local trigger t = null
local conditionfunc c = null
local integer length = StringLength(text)
local real sizePerUnit = (size * 4.0) / 32.0
local real curSize = 0
local integer maxWidth = 0
local integer curWidth = 0
local integer overall = 0
local integer lnr = 0
local integer count = 0
local integer r = ColorIntegerGetRed(color)
local integer g = ColorIntegerGetGreen(color)
local integer b = ColorIntegerGetBlue(color)
local integer a = ColorIntegerGetAlpha(color)
local integer temp = 0
local integer i = 0
local string cur = ""
local string next = SubString(text, 0, 1)
loop
set cur = next
exitwhen (cur == "" or cur == null)
set next = SubString(text, i + 1, i + 2)
if ((cur == "|" and next == "n") or cur == "\n" or cur == "\r") then
call StoreInteger(udg_TextSplatCache, ref, "LetterCount" + I2S(lnr), count)
call StoreInteger(udg_TextSplatCache, ref, "LineWidth" + I2S(lnr), curWidth)
call FlushStoredInteger(udg_TextSplatCache, ref, "StartIndex" + I2S(lnr))
if (curWidth > maxWidth) then
set maxWidth = curWidth
endif
set overall = overall + count
set count = 0
set curWidth = 0
set lnr = lnr + 1
if (cur == "|") then
set i = i + 1
set next = SubString(text, i + 1, i + 2)
endif
elseif (cur == "|" and next == "r") then
if (length > i + 1) then
call StoreInteger(udg_TextSplatCache, ref, "ColorTag" + I2S(count) + "Line" + I2S(lnr), 2)
endif
set r = ColorIntegerGetRed(color)
set g = ColorIntegerGetGreen(color)
set b = ColorIntegerGetBlue(color)
set a = ColorIntegerGetAlpha(color)
set i = i + 1
set next = SubString(text, i + 1, i + 2)
elseif (cur == "|" and next == "c" and length > i + 9 and IsHexadecimal(SubString(text, i + 2, i + 10))) then
set temp = ColorString2ColorInteger(SubString(text, i + 2, i + 10))
set r = ColorIntegerGetRed(temp)
set g = ColorIntegerGetGreen(temp)
set b = ColorIntegerGetBlue(temp)
set a = ColorIntegerGetAlpha(temp)
call StoreInteger(udg_TextSplatCache, ref, "ColorTag" + I2S(count) + "Line" + I2S(lnr), 1)
call StoreInteger(udg_TextSplatCache, ref, "Color" + I2S(count) + "Line" + I2S(lnr), temp)
set i = i + 9
set next = SubString(text, i + 1, i + 2)
else
set temp = Asc(cur)
if (temp >= 32 and temp <= 127) then
set curSize = GetStoredInteger(udg_TextSplatCache, "Font::" + font, "Width" + I2S(temp)) * sizePerUnit
set curWidth = curWidth + GetStoredInteger(udg_TextSplatCache, "Font::" + font, "Width" + I2S(temp))
if (temp != 32) then
set img = CreateImageEx(TS_FONTSPATH() + font + "\\" + I2S(temp) + ".blp", 32 * sizePerUnit, 32 * sizePerUnit, 0, 0, 0, true)
call SetImageColor(img, r, g, b, a)
call StoreInteger(udg_TextSplatCache, ref, "Image" + I2S(count) + "Line" + I2S(lnr), H2I(img))
endif
call StoreInteger(udg_TextSplatCache, ref, "Letter" + I2S(count) + "Line" + I2S(lnr), temp)
set count = count + 1
endif
endif
set i = i + 1
endloop
call StoreInteger(udg_TextSplatCache, ref, "LetterCount" + I2S(lnr), count)
call StoreInteger(udg_TextSplatCache, ref, "LineWidth" + I2S(lnr), curWidth)
call FlushStoredInteger(udg_TextSplatCache, ref, "StartIndex" + I2S(lnr))
if (curWidth > maxWidth) then
set maxWidth = curWidth
endif
set overall = overall + count
set lnr = lnr + 1
call StoreBoolean(udg_TextSplatCache, ref, "Visible", true)
call StoreString(udg_TextSplatCache, ref, "Font", font)
call StoreInteger(udg_TextSplatCache, ref, "Size", size)
call StoreInteger(udg_TextSplatCache, ref, "Valign", valign)
call StoreInteger(udg_TextSplatCache, ref, "Halign", halign)
call StoreInteger(udg_TextSplatCache, ref, "DefaultColor", color)
call StoreInteger(udg_TextSplatCache, ref, "LetterCount", overall)
call StoreInteger(udg_TextSplatCache, ref, "LineCount", lnr)
call StoreInteger(udg_TextSplatCache, ref, "MaxWidth", maxWidth)
call StoreReal(udg_TextSplatCache, ref, "BaseX", baseX)
call StoreReal(udg_TextSplatCache, ref, "BaseY", baseY)
call StoreReal(udg_TextSplatCache, ref, "OffsetX", 0)
call StoreReal(udg_TextSplatCache, ref, "OffsetY", 0)
set t = CreateTrigger()
set c = Condition(function ts_UpdateTextSplatPosition)
call TriggerAddCondition(t, c)
call StoreInteger(udg_TextSplatCache, ref, "Dispatcher", H2I(t))
call StoreInteger(udg_TextSplatCache, ref, "DispatcherCondition", H2I(c))
set bj_enumDestructableRadius = baseX
set bj_meleeNearestMineDist = baseY
set bj_groupEnumTypeId = id
call TriggerEvaluate(t)
set img = null
set t = null
set c = null
return id
endfunction
//############################################################################################################
//##Begin of PUBLIC TextSplat FUNCTIONS##
//############################################################################################################
function TextSplatInitializeCache takes nothing returns nothing
call TSCache()
call ARCache()
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width32", 16)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width33", 8)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width34", 10)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width35", 19)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width36", 16)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width37", 20)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width38", 22)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width39", 6)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width40", 11)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width41", 10)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width42", 14)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width43", 16)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width44", 9)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width45", 10)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width46", 8)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width47", 15)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width48", 18)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width49", 11)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width50", 18)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width51", 16)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width52", 19)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width53", 16)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width54", 18)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width55", 18)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width56", 18)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width57", 17)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width58", 8)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width59", 9)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width60", 15)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width61", 17)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width62", 15)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width63", 13)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width64", 24)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width65", 22)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width66", 18)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width67", 20)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width68", 19)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width69", 17)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width70", 18)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width71", 21)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width72", 20)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width73", 7)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width74", 15)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width75", 20)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width76", 17)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width77", 26)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width78", 19)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width79", 22)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width80", 18)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width81", 26)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width82", 19)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width83", 16)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width84", 21)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width85", 19)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width86", 21)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width87", 29)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width88", 20)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width89", 21)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width90", 18)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width91", 11)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width92", 14)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width93", 11)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width94", 15)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width95", 20)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width96", 9)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width97", 16)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width98", 13)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width99", 15)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width100", 14)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width101", 12)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width102", 13)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width103", 16)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width104", 14)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width105", 5)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width106", 11)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width107", 15)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width108", 13)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width109", 19)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width110", 14)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width111", 16)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width112", 14)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width113", 18)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width114", 14)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width115", 12)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width116", 16)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width117", 14)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width118", 16)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width119", 21)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width120", 15)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width121", 16)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width122", 13)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width123", 14)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width124", 6)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width125", 14)
call StoreInteger(udg_TextSplatCache, "Font::Trebuchet", "Width126", 15)
endfunction
function SetTextSplatPosition takes integer textSplat, real x, real y returns nothing
local string ref = TS_INSTANCE() + I2S(textSplat)
local trigger t = I2Trg(GetStoredInteger(udg_TextSplatCache, ref, "Dispatcher"))
call ts_AttachmentCleanup(GetStoredInteger(udg_TextSplatCache, ref, "AttachmentTimer"))
call StoreReal(udg_TextSplatCache, ref, "BaseX", x)
call StoreReal(udg_TextSplatCache, ref, "BaseY", y)
set bj_enumDestructableRadius = x + GetStoredReal(udg_TextSplatCache, ref, "OffsetX")
set bj_meleeNearestMineDist = y + GetStoredReal(udg_TextSplatCache, ref, "OffsetY")
set bj_groupEnumTypeId = textSplat
call TriggerEvaluate(t)
set t = null
endfunction
function SetTextSplatOffset takes integer textSplat, real offX, real offY returns nothing
local string ref = TS_INSTANCE() + I2S(textSplat)
local trigger t = I2Trg(GetStoredInteger(udg_TextSplatCache, ref, "Dispatcher"))
call ts_MovementCleanup(GetStoredInteger(udg_TextSplatCache, ref, "MovementTimer"), true)
call StoreReal(udg_TextSplatCache, ref, "OffsetX", offX)
call StoreReal(udg_TextSplatCache, ref, "OffsetY", offY)
set bj_enumDestructableRadius = GetStoredReal(udg_TextSplatCache, ref, "BaseX") + offX
set bj_meleeNearestMineDist = GetStoredReal(udg_TextSplatCache, ref, "BaseY") + offY
set bj_groupEnumTypeId = textSplat
call TriggerEvaluate(t)
set t = null
endfunction
function SetTextSplatVisible takes integer textSplat, boolean visible returns nothing
local string ref = TS_INSTANCE() + I2S(textSplat)
local integer lines = GetStoredInteger(udg_TextSplatCache, ref, "LineCount")
local integer letters = 0
local integer i = 0
local integer j = 0
loop
exitwhen i == lines
set letters = GetStoredInteger(udg_TextSplatCache, ref, "LetterCount" + I2S(i))
set j = 0
loop
exitwhen j == letters
call ShowImage(I2Img(GetStoredInteger(udg_TextSplatCache, ref, "Image" + I2S(j) + "Line" + I2S(i))), visible)
set j = j + 1
endloop
set i = i + 1
endloop
if (visible) then
call StoreBoolean(udg_TextSplatCache, ref, "Visible", true)
else
call FlushStoredBoolean(udg_TextSplatCache, ref, "Visible")
endif
endfunction
function SetTextSplatColorMono takes integer textSplat, integer color, boolean overrideTags returns nothing
local string ref = TS_INSTANCE() + I2S(textSplat)
local integer r = ColorIntegerGetRed(color)
local integer g = ColorIntegerGetGreen(color)
local integer b = ColorIntegerGetBlue(color)
local integer a = ColorIntegerGetAlpha(color)
local integer lines = GetStoredInteger(udg_TextSplatCache, ref, "LineCount")
local integer letters = 0
local integer defColor = color
local integer colorTag = 0
local integer i = 0
local integer j = 0
call ts_FadeCleanup(GetStoredInteger(udg_TextSplatCache, ref, "FadeTimer"), true)
loop
exitwhen i == lines
set letters = GetStoredInteger(udg_TextSplatCache, ref, "LetterCount" + I2S(i))
set j = 0
loop
exitwhen j == letters
if (not overrideTags) then
set colorTag = GetStoredInteger(udg_TextSplatCache, ref, "ColorTag" + I2S(j) + "Line" + I2S(i))
if (colorTag > 0) then
if (colorTag == 1) then
set color = GetStoredInteger(udg_TextSplatCache, ref, "Color" + I2S(j) + "Line" + I2S(i))
elseif (colorTag == 2) then
set color = defColor
endif
set r = ColorIntegerGetRed(color)
set g = ColorIntegerGetGreen(color)
set b = ColorIntegerGetBlue(color)
set a = ColorIntegerGetAlpha(color)
endif
endif
call SetImageColor(I2Img(GetStoredInteger(udg_TextSplatCache, ref, "Image" + I2S(j) + "Line" + I2S(i))), r, g, b, a)
set j = j + 1
endloop
set i = i + 1
endloop
call StoreInteger(udg_TextSplatCache, ref, "DefaultColor", defColor)
call StoreInteger(udg_TextSplatCache, ref, "ColorType", 0)
endfunction
function SetTextSplatColorGradient takes integer textSplat, integer colorFrom, integer colorTo returns nothing
local string ref = TS_INSTANCE() + I2S(textSplat)
local integer r = ColorIntegerGetRed(colorFrom)
local integer g = ColorIntegerGetGreen(colorFrom)
local integer b = ColorIntegerGetBlue(colorFrom)
local integer a = ColorIntegerGetAlpha(colorFrom)
local integer count = GetStoredInteger(udg_TextSplatCache, ref, "LetterCount")
local real dr = (ColorIntegerGetRed(colorTo) - r) / I2R(count)
local real dg = (ColorIntegerGetGreen(colorTo) - g) / I2R(count)
local real db = (ColorIntegerGetBlue(colorTo) - b) / I2R(count)
local real da = (ColorIntegerGetAlpha(colorTo) - a) / I2R(count)
local integer temp = 0
local integer lines = GetStoredInteger(udg_TextSplatCache, ref, "LineCount")
local integer letters = 0
local integer i = 0
local integer j = 0
set count = 0
call StoreInteger(udg_TextSplatCache, ref, "DefaultColor", CreateColorInteger((r + ColorIntegerGetRed(colorTo)) / 2, (g + ColorIntegerGetGreen(colorTo)) / 2, (b + ColorIntegerGetBlue(colorTo)) / 2, (a + ColorIntegerGetAlpha(colorTo)) / 2))
call ts_FadeCleanup(GetStoredInteger(udg_TextSplatCache, ref, "FadeTimer"), true)
loop
exitwhen i == lines
set letters = GetStoredInteger(udg_TextSplatCache, ref, "LetterCount" + I2S(i))
set j = 0
loop
exitwhen j == letters
call StoreInteger(udg_TextSplatCache, ref, "Color" + I2S(j) + "Line" + I2S(i), CreateColorInteger(R2I(r + dr * count + 0.5), R2I(g + dg * count + 0.5), R2I(b + db * count + 0.5), R2I(a + da * count + 0.5)))
call SetImageColor(I2Img(GetStoredInteger(udg_TextSplatCache, ref, "Image" + I2S(j) + "Line" + I2S(i))), R2I(r + dr * count + 0.5), R2I(g + dg * count + 0.5), R2I(b + db * count + 0.5), R2I(a + da * count + 0.5))
set count = count + 1
set j = j + 1
endloop
set i = i + 1
endloop
call StoreInteger(udg_TextSplatCache, ref, "ColorType", 1)
endfunction
function TextSplatFade takes integer textSplat, real time, real updateWait, integer startAlpha, integer endAlpha, string callback returns timer
local string ref = TS_INSTANCE() + I2S(textSplat)
local timer tmr = null
local integer times = 1
local real inc = 1
if (time <= 0 or updateWait <= 0) then
return I2T(GetStoredInteger(udg_TextSplatCache, ref, "FadeTimer"))
endif
set startAlpha = ModuloInteger(startAlpha, 256)
set endAlpha = ModuloInteger(endAlpha, 256)
if (startAlpha == endAlpha) then
return I2T(GetStoredInteger(udg_TextSplatCache, ref, "FadeTimer"))
endif
call ts_FadeCleanup(GetStoredInteger(udg_TextSplatCache, ref, "FadeTimer"), true)
if (updateWait > time) then
set updateWait = time
endif
set times = R2I(time / updateWait)
set inc = (endAlpha - startAlpha) / I2R(times)
if (inc < 1 and inc > 0) then
set updateWait = updateWait * (1 / inc)
set inc = 1
elseif (inc > -1 and inc < 0) then
set updateWait = updateWait * (-1 / inc)
set inc = -1
endif
set tmr = CreateTimer()
call StoreInteger(udg_TextSplatCache, ref, "FadeTimer", H2I(tmr))
set ref = "FadeTimer::" + I2S(H2I(tmr))
call StoreInteger(udg_TextSplatCache, ref, "Owner", textSplat)
call StoreString(udg_TextSplatCache, ref, "Callback", callback)
call StoreInteger(udg_TextSplatCache, ref, "FadeTimes", times)
call StoreInteger(udg_TextSplatCache, ref, "FadeStart", startAlpha)
call StoreInteger(udg_TextSplatCache, ref, "FadeEnd", endAlpha)
call StoreReal(udg_TextSplatCache, ref, "FadeIncrement", inc)
call ts_FadeUpdate(H2I(tmr), 0)
call TimerStart(tmr, updateWait, true, function ts_FadeUpdateCallback)
return tmr
endfunction
function TextSplatFadeIn takes integer textSplat, real time, real updateWait, string callback returns timer
return TextSplatFade(textSplat, time, updateWait, ColorIntegerGetAlpha(GetStoredInteger(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "DefaultColor")), 255, callback)
endfunction
function TextSplatFadeOut takes integer textSplat, real time, real updateWait, string callback returns timer
return TextSplatFade(textSplat, time, updateWait, ColorIntegerGetAlpha(GetStoredInteger(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "DefaultColor")), 0, callback)
endfunction
function TextSplatAttachToUnit takes integer textSplat, unit target, real updateWait returns timer
local string ref = TS_INSTANCE() + I2S(textSplat)
local timer tmr = null
if (updateWait <= 0 or target == null) then
return I2T(GetStoredInteger(udg_TextSplatCache, ref, "AttachmentTimer"))
endif
call ts_AttachmentCleanup(GetStoredInteger(udg_TextSplatCache, ref, "AttachmentTimer"))
set tmr = CreateTimer()
call StoreInteger(udg_TextSplatCache, ref, "AttachmentTimer", H2I(tmr))
set ref = "AttachmentTimer::" + I2S(H2I(tmr))
call StoreInteger(udg_TextSplatCache, ref, "Owner", textSplat)
call StoreInteger(udg_TextSplatCache, ref, "Target", H2I(target))
call ts_AttachmentUpdate(H2I(tmr))
call TimerStart(tmr, updateWait, true, function ts_AttachmentUpdateCallback)
return tmr
endfunction
function TextSplatDisableRunningText takes integer textSplat, timer runTimer returns nothing
local string ref = TS_INSTANCE() + I2S(textSplat)
local integer id = H2I(runTimer)
local integer prev = 0
local integer cur = 0
local boolean moreV = false
local boolean moreH = false
if (runTimer == null) then
loop
set id = GetStoredInteger(udg_TextSplatCache, ref, "RunTimer")
exitwhen (id == 0)
call ts_RunCleanup(0, I2T(id), true, true)
endloop
set id = GetStoredInteger(udg_TextSplatCache, ref, "LineCount")
set cur = 0
call FlushStoredInteger(udg_TextSplatCache, ref, "StartIndex")
loop
exitwhen cur == id
call FlushStoredInteger(udg_TextSplatCache, ref, "StartIndex" + I2S(cur))
set cur = cur + 1
endloop
else
set cur = GetStoredInteger(udg_TextSplatCache, ref, "RunTimer")
loop
exitwhen (cur == id or cur == 0)
set moreV = moreV or GetStoredInteger(udg_TextSplatCache, "RunTimer::" + I2S(cur), "VerticalStepWidth") != 0
set moreH = moreH or GetStoredInteger(udg_TextSplatCache, "RunTimer::" + I2S(cur), "HorizontalStepWidth") != 0
set prev = cur
set cur = GetStoredInteger(udg_TextSplatCache, "RunTimer::" + I2S(cur), "NextRunTimer")
endloop
if (cur == id) then
call ts_RunCleanup(prev, runTimer, moreV, moreH)
endif
endif
endfunction
function TextSplatEnableRunningText takes integer textSplat, integer vStep, integer hStep, real updateWait returns timer
local string ref = TS_INSTANCE() + I2S(textSplat)
local timer tmr = null
local integer id = 0
if (updateWait <= 0 or (vStep == 0 and hStep == 0)) then
return null
endif
set tmr = CreateTimer()
set id = GetStoredInteger(udg_TextSplatCache, ref, "RunTimer")
call StoreInteger(udg_TextSplatCache, ref, "RunCount", GetStoredInteger(udg_TextSplatCache, ref, "RunCount") + 1)
call StoreInteger(udg_TextSplatCache, ref, "RunTimer", H2I(tmr))
set ref = "RunTimer::" + I2S(H2I(tmr))
if (id > 0) then
call StoreInteger(udg_TextSplatCache, ref, "NextRunTimer", id)
endif
call StoreInteger(udg_TextSplatCache, ref, "Owner", textSplat)
call StoreInteger(udg_TextSplatCache, ref, "VerticalStepWidth", vStep)
call StoreInteger(udg_TextSplatCache, ref, "HorizontalStepWidth", hStep)
call TimerStart(tmr, updateWait, true, function ts_RunUpdateCallback)
return tmr
endfunction
function TextSplatFloat takes integer textSplat, real time, real updateWait, code fX, code fY, string callback returns timer
local string ref = TS_INSTANCE() + I2S(textSplat)
local timer tmr = null
local timer elapsed = null
local integer times = 1
local conditionfunc c = null
local trigger t = null
if (time <= 0) then
set time = 0x7FFFFFFF
endif
if (updateWait <= 0 or fX == null or fY == null) then
return I2T(GetStoredInteger(udg_TextSplatCache, ref, "MovementTimer"))
endif
call ts_MovementCleanup(GetStoredInteger(udg_TextSplatCache, ref, "MovementTimer"), true)
if (updateWait > time) then
set updateWait = time
endif
set times = R2I(time / updateWait)
set tmr = CreateTimer()
set elapsed = CreateTimer()
call StoreInteger(udg_TextSplatCache, ref, "MovementTimer", H2I(tmr))
set ref = "MovementTimer::" + I2S(H2I(tmr))
set t = CreateTrigger()
set c = Condition(fX)
call TriggerAddCondition(t, c)
call StoreInteger(udg_TextSplatCache, ref, "ConditionX", H2I(c))
call StoreInteger(udg_TextSplatCache, ref, "TriggerX", H2I(t))
set t = CreateTrigger()
set c = Condition(fY)
call TriggerAddCondition(t, c)
call StoreInteger(udg_TextSplatCache, ref, "ConditionY", H2I(c))
call StoreInteger(udg_TextSplatCache, ref, "TriggerY", H2I(t))
call StoreInteger(udg_TextSplatCache, ref, "Owner", textSplat)
call StoreInteger(udg_TextSplatCache, ref, "Elapsed", H2I(elapsed))
call StoreString(udg_TextSplatCache, ref, "Callback", callback)
call StoreInteger(udg_TextSplatCache, "MovementTimer::" + I2S(H2I(elapsed)), "Elapsed", H2I(tmr))
call ts_MovementUpdate(H2I(tmr))
call TimerStart(tmr, updateWait, true, function ts_MovementUpdateCallback)
call TimerStart(elapsed, time, false, function ts_MovementCleanupCallback)
set c = null
set t = null
return tmr
endfunction
function GetTriggeringTextSplat takes nothing returns integer
return bj_groupEnumTypeId
endfunction
function GetTextSplatAttachedUnit takes integer textSplat returns unit
return I2U(GetStoredInteger(udg_TextSplatCache, "AttachmentTimer::" + I2S(GetStoredInteger(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "AttachmentTimer")), "Target"))
endfunction
function GetTextSplatColor takes integer textSplat returns integer
return GetStoredInteger(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "DefaultColor")
endfunction
function GetTextSplatBaseX takes integer textSplat returns real
return GetStoredReal(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "BaseX")
endfunction
function GetTextSplatBaseY takes integer textSplat returns real
return GetStoredReal(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "BaseY")
endfunction
function GetTextSplatOffsetX takes integer textSplat returns real
return GetStoredReal(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "OffsetX")
endfunction
function GetTextSplatOffsetY takes integer textSplat returns real
return GetStoredReal(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "OffsetY")
endfunction
function GetTextSplatX takes integer textSplat returns real
return GetStoredReal(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "BaseX") + GetStoredReal(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "OffsetX")
endfunction
function GetTextSplatY takes integer textSplat returns real
return GetStoredReal(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "BaseY") + GetStoredReal(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "OffsetY")
endfunction
function IsTextSplatFading takes integer textSplat returns boolean
return GetStoredInteger(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "FadeTimer") > 0
endfunction
function IsTextSplatAttached takes integer textSplat returns boolean
return GetStoredInteger(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "AttachmentTimer") > 0
endfunction
function IsTextSplatRunning takes integer textSplat returns boolean
return GetStoredInteger(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "RunCount") > 0
endfunction
function IsTextSplatFloating takes integer textSplat returns boolean
return GetStoredInteger(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "MovementTimer") > 0
endfunction
function IsTextSplatVisible takes integer textSplat returns boolean
return GetStoredBoolean(udg_TextSplatCache, TS_INSTANCE() + I2S(textSplat), "Visible")
endfunction
function ts_SetTextSplatColorGradient takes nothing returns nothing
call SetTextSplatColorGradient(bj_groupEnumTypeId, bj_groupCountUnits, bj_forceCountPlayers)
endfunction
function TextSplatCreateGradient takes string text, real baseX, real baseY, string font, integer size, integer valign, integer halign, integer colorFrom, integer colorTo returns integer
local integer id = 0
local trigger t = null
local conditionfunc c = null
if (StringLength(text) <= 0xFF) then
set id = ts_CreateTextSplat(text, baseX, baseY, font, size, valign, halign, CreateColorInteger(255, 255, 255, 255))
set t = CreateTrigger()
set c = Condition(function ts_SetTextSplatColorGradient)
call TriggerAddCondition(t, c)
set bj_groupEnumTypeId = id
set bj_groupCountUnits = colorFrom
set bj_forceCountPlayers = colorTo
call TriggerEvaluate(t)
call DestroyTrigger(t)
call DestroyCondition(c)
set t = null
set c = null
endif
return id
endfunction
function TextSplatCreateMono takes string text, real baseX, real baseY, string font, integer size, integer valign, integer halign, integer color returns integer
local integer id = 0
if (StringLength(text) <= 0xFF) then
set id = ts_CreateTextSplat(text, baseX, baseY, font, size, valign, halign, color)
call FlushStoredInteger(udg_TextSplatCache, TS_INSTANCE() + I2S(id), "ColorType")
endif
return id
endfunction
function TextSplatDestroy takes integer textSplat returns nothing
local string ref = TS_INSTANCE() + I2S(textSplat)
local integer lines = GetStoredInteger(udg_TextSplatCache, ref, "LineCount")
local integer letters = 0
local integer i = 0
local integer j = 0
loop
exitwhen i == lines
set letters = GetStoredInteger(udg_TextSplatCache, ref, "LetterCount" + I2S(i))
set j = 0
loop
exitwhen j == letters
call DestroyImage(I2Img(GetStoredInteger(udg_TextSplatCache, ref, "Image" + I2S(j) + "Line" + I2S(i))))
set j = j + 1
endloop
set i = i + 1
endloop
call DestroyTrigger(I2Trg(GetStoredInteger(udg_TextSplatCache, ref, "Dispatcher")))
call DestroyCondition(I2Cnd(GetStoredInteger(udg_TextSplatCache, ref, "DispatcherCondition")))
call TextSplatDisableRunningText(textSplat, null)
call ts_FadeCleanup(GetStoredInteger(udg_TextSplatCache, ref, "FadeTimer"), true)
call ts_AttachmentCleanup(GetStoredInteger(udg_TextSplatCache, ref, "AttachmentTimer"))
call ts_MovementCleanup(GetStoredInteger(udg_TextSplatCache, ref, "MovementTimer"), true)
call FlushStoredMission(udg_TextSplatCache, ref)
call FreeArrayIndex(TS_ARRAY_NAME(), textSplat)
endfunction
Name | Type | is_array | initial_value |
ArrayCache | gamecache | No | |
EventUnits | group | No | |
GhostShip | unit | No | UnitNull |
GhostShipArrived | group | No | |
GhostShipCaster | unit | No | UnitNull |
GhostShipCasterPosition | location | Yes | |
GhostShipGroup | group | No | |
GhostShipLevel | integer | No | |
GhostShipNumbnessUnits | group | No | |
GhostShipPickedUnit | group | No | |
GhostShipPosition | location | No | |
GhostShipPosition2 | location | No | |
GhostShipPosition3 | location | No | |
Kill_Count | integer | No | |
RandomCreep | unitcode | Yes | |
RandomPoint | location | No | |
TextSplatCache | gamecache | No | |
TidebringerAoE | group | No | |
TidebringerPoint | location | Yes | |
TorrentCaster | unit | Yes | UnitNull |
TorrentEffect | string | No | |
TorrentEffectAngle | real | No | |
TorrentEffectPoint | location | No | |
TorrentGroup | group | Yes | |
TorrentInstances | integer | No | |
TorrentInstances2 | integer | No | |
TorrentLevel | integer | Yes | |
TorrentPickedUnitPosition | location | No | |
TorrentPickingUnits | group | No | |
TorrentTargetPoint | location | Yes | |
TorrentUnits | group | No | |
X | integer | No | |
XBuff | effect | Yes | |
XGroup | group | No | |
XInstances | integer | No | |
XInstances2 | integer | No | |
XTarget | unit | Yes | UnitNull |
XTargetPosition | location | Yes |