summaryrefslogtreecommitdiffstats
path: root/DTUtility.c
diff options
context:
space:
mode:
Diffstat (limited to 'DTUtility.c')
-rw-r--r--DTUtility.c76
1 files changed, 51 insertions, 25 deletions
diff --git a/DTUtility.c b/DTUtility.c
index a747d33..481ebe9 100644
--- a/DTUtility.c
+++ b/DTUtility.c
@@ -56,14 +56,14 @@ global func EscapeString(string value)
}
else if(c == 92) // \
{
- ret = Format("%s\\\\", ret);
- }
- else
- {
- ret = Format("%s%c", ret, c);
+ ret = Format("%s\\\\", ret);
+ }
+ else
+ {
+ ret = Format("%s%c", ret, c);
+ }
}
-}
-return ret;
+ return ret;
}
global func CreateEnum(string prefix, array enum)
@@ -445,7 +445,7 @@ global func ParseFloat(string float, int precision) // precision = number of dig
// out of precision
break;
}
-
+
var c = GetChar(float, i);
if(i == 0)
{
@@ -479,12 +479,12 @@ global func ParseFloat(string float, int precision) // precision = number of dig
{
decimalPoint = i - 1;
}
-
+
for(; i <= decimalPoint + precision; ++i)
{
ret *= 10;
}
-
+
return ret * (1 - (2 * neg));
}
@@ -514,7 +514,7 @@ global func Find_ProcedureCheck(string proc)
global func GetSolidMask(object obj)
{
obj = obj || this;
- return
+ return
[
GetObjectVal("SolidMask", 0, obj, 0), GetObjectVal("SolidMask", 0, obj, 1),
GetObjectVal("SolidMask", 0, obj, 2), GetObjectVal("SolidMask", 0, obj, 3),
@@ -606,7 +606,7 @@ global func GetOverlayValueByIndex(int index, int startIndex, int getValue, obje
//something went wrong already
return -3;
}
-
+
if(found)
{
if(getValue == 5)
@@ -622,23 +622,23 @@ global func GetOverlayValueByIndex(int index, int startIndex, int getValue, obje
return i + 4;
}
}
-
+
i += 10; // this is either the last row of the Transformation matrix or the Color-Modulation
val = GetObjectVal("GfxOverlay", 0, obj, i);
-
+
if(GetType(val) == C4V_String)
{
// part of the matrix, skip it
i += 3;
}
-
+
if(found && getValue == 8)
{
return GetObjectVal("GfxOverlay", 0, obj, i + 2);
}
-
+
i += 3; // and the rest
-
+
if(++foundIndex == index)
{
if(GetObjectVal("GfxOverlay", 0, obj, i) == 0)
@@ -659,7 +659,7 @@ global func GetOverlayValueByIndex(int index, int startIndex, int getValue, obje
}
}
}
-
+
++i; // skip the next overlay ID
}
}
@@ -667,7 +667,7 @@ global func GetOverlayValueByIndex(int index, int startIndex, int getValue, obje
global func GetOverlayValueOffsetByID(int overlay, object obj)
{
obj = obj || this;
-
+
if(overlay != 0)
{
var offset = 0, diffIndex = 0;
@@ -680,7 +680,7 @@ global func GetOverlayValueOffsetByID(int overlay, object obj)
diffIndex = 1;
}
}
-
+
return -1;
}
@@ -695,7 +695,7 @@ global func GetObjDrawTransform(int overlay, int overlayOffset, object obj)
return [1000, 0, 0, 0, 1000, 0];
}
var ret = [ParseFloat(first, 3), ParseFloat(GetObjectVal("DrawTransform", 0, obj, 1), 3), ParseFloat(GetObjectVal("DrawTransform", 0, obj, 2), 3), ParseFloat(GetObjectVal("DrawTransform", 0, obj, 3), 3), ParseFloat(GetObjectVal("DrawTransform", 0, obj, 4), 3), ParseFloat(GetObjectVal("DrawTransform", 0, obj, 5), 3)];
-
+
var rest = GetObjectVal("DrawTransform", 0, obj, 7); // 6 is left out intentionally, because its only FlipDir (used internally for Actions with FlipDir)
if(GetType(rest) == C4V_String) // the last 3 matrix-values are only decompiled if they are not the default of [0, 0, 1.0]
{
@@ -704,7 +704,7 @@ global func GetObjDrawTransform(int overlay, int overlayOffset, object obj)
ret[7] = ParseFloat(GetObjectVal("DrawTransform", 0, obj, 8), 3);
ret[8] = ParseFloat(GetObjectVal("DrawTransform", 0, obj, 9), 3);
}
-
+
return ret;
}
else
@@ -727,9 +727,9 @@ global func GetObjDrawTransform(int overlay, int overlayOffset, object obj)
{
return index;
}
-
+
var ret = [ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index), 3), ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index + 1), 3), ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index + 2), 3), ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index + 3), 3), ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index + 4), 3), ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index + 5), 3)];
-
+
var rest = GetObjectVal("GfxOverlay", 0, obj, index + 7); // 6 is left out intentionally, because its only FlipDir (used internally for Actions with FlipDir)
if(GetType(rest) == C4V_String) // the last 3 matrix-values are only decompiled if they are not the default of [0, 0, 1.0]
{
@@ -738,7 +738,33 @@ global func GetObjDrawTransform(int overlay, int overlayOffset, object obj)
ret[7] = ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index + 8), 3);
ret[8] = ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index + 9), 3);
}
-
+
return ret;
}
}
+
+global func GetShape(object obj)
+{
+ obj = obj || this;
+ return [GetObjectVal("Offset", 0, obj, 0), GetObjectVal("Offset", 0, obj, 1), GetObjectVal("Width", 0, obj), GetObjectVal("Height", 0, obj)];
+}
+
+global func InRect(array point, array rect)
+{
+ var x = point[0], y = point[1];
+ return rect[0] < x && x < rect[0] + rect[2] && rect[1] < y && y < rect[1] + rect[3];
+}
+
+global func GetPlayerByID(int id)
+{
+ for(var i = 0; i < GetPlayerCount(); ++i)
+ {
+ var plr = GetPlayerByIndex(i);
+ if(GetPlayerID(plr) == id)
+ {
+ return plr;
+ }
+ }
+
+ return NO_OWNER;
+}