Advertisement
Guest User

8bdm Scoreboard script

a guest
Jun 25th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. //=======|Begin Scoreboard Script===========
  2. /*
  3. Line ID's for scoreboard textures
  4. Blue = 1-3
  5. Red = 4-6
  6. Green = 7-9
  7. Yellow = 10-12
  8.  
  9. Make sure the digits are properly orientated from the player's view
  10. */
  11. Script "ScoreBoard" Open
  12. {
  13. Int BlueScoreCache;
  14. Int RedScoreCache;
  15. Int GreenScoreCache;
  16. Int YellowScoreCache;
  17.  
  18. int Digit_1;
  19. int Digit_2;
  20. int Digit_3;
  21. While(True)
  22. {
  23.  
  24. //First, check if any score has been updated.
  25. if
  26. (
  27. BlueScoreCache == GetTeamProperty(0,TPROP_PointCount)
  28. && RedScoreCache == GetTeamProperty(1,TPROP_PointCount)
  29. && GreenScoreCache == GetTeamProperty(2,TPROP_PointCount)
  30. && YellowScoreCache == GetTeamProperty(3,TPROP_PointCount)
  31. ){delay(1); Continue;}
  32.  
  33. //one of the scores have been updated, update the textures in response
  34. for(int T = 0;T < 4; T++)
  35. {
  36. if(GetTeamProperty(T,TPROP_PointCount) > 999)
  37. {
  38. Digit_1 = getNthDigit(GetTeamProperty(T,TPROP_PointCount),10,1);
  39. Digit_2 = getNthDigit(GetTeamProperty(T,TPROP_PointCount),10,2);
  40. Digit_3 = getNthDigit(GetTeamProperty(T,TPROP_PointCount),10,3);
  41. }
  42. Else
  43. { //Scoreboards max out at 999 and will go no higher
  44. Digit_1 = 9;
  45. Digit_2 = 9;
  46. Digit_3 = 9;
  47. }
  48. SetLineTexture(1+(3*T),SIDE_FRONT,TEXTURE_MIDDLE,Strparam(s:TeamTex(T),i:Digit_1));
  49. SetLineTexture(2+(3*T),SIDE_FRONT,TEXTURE_MIDDLE,Strparam(s:TeamTex(T),i:Digit_2));
  50. SetLineTexture(3+(3*T),SIDE_FRONT,TEXTURE_MIDDLE,Strparam(s:TeamTex(T),i:Digit_3));
  51. }
  52. // Update the cache values and resume from the top
  53. BlueScoreCache = GetTeamProperty(0,TPROP_PointCount);
  54. RedScoreCache = GetTeamProperty(1,TPROP_PointCount);
  55. GreenScoreCache = GetTeamProperty(2,TPROP_PointCount);
  56. YellowScoreCache = GetTeamProperty(3,TPROP_PointCount);
  57. delay(1);
  58. }
  59.  
  60. }
  61.  
  62. Function Str TeamTex (int team)
  63. {
  64. Str output;
  65. Switch(team)
  66. {
  67. Case 0: output = "BLUESC"; Break;
  68. Case 1: output = "REDSC"; Break;
  69. Case 2: output = "GREESC"; Break;
  70. Case 3: output = "YELLSC"; Break;
  71. }
  72. return output;
  73. }
  74.  
  75. // Carefule, there be maths down here, scary stuff
  76.  
  77. function int getNthDigit (int number, int base, int n)
  78. {
  79. int result = ((number / pow(base, n - 1)) % base);
  80. return result;
  81. }
  82.  
  83. function int GetTotalDigits (int number)
  84. {
  85. int result;
  86. if (number >= 100) {result = 3;}
  87. else if (number >= 10) {result = 2;}
  88. else {result = 1;}
  89. return result;
  90. }
  91.  
  92. function int pow (int x, int n)
  93. {
  94. int y = 1;
  95. while (n-- > 0) y *= x;
  96. return y;
  97. }
  98.  
  99. #define MATH_E 178145
  100. function int logN (int x, int base)
  101. {
  102. if (!base) base = MATH_E;
  103. int integer = 0;
  104.  
  105. if (x < 1.0 && base < 1.0) return 0;
  106.  
  107. while (x < 1)
  108. {
  109. integer -= 1;
  110. x = FixedMul (x, base);
  111. }
  112. while (x >= base)
  113. {
  114. integer += 1;
  115. x = FixedDiv (x, base);
  116. }
  117. int partial = 0.5;
  118. x = FixedMul (x, x);
  119. int decimal = 0;
  120. while (partial > 1) // Actually 0.0000152587890625
  121. {
  122. if (x >= base)
  123. {
  124. decimal += partial;
  125. x = FixedDiv (x, base);
  126. }
  127. partial = FixedMul (partial, 0.5);
  128. x = FixedMul (x, x);
  129. }
  130. return ((integer << 16) + decimal);
  131. }
  132. //=======|End Scoreboard Script===========
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement