Guest User

Untitled

a guest
Jun 13th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.49 KB | None | 0 0
  1. Index: Main.qc
  2. ===================================================================
  3. --- Main.qc (revision 6523)
  4. +++ Main.qc (working copy)
  5. @@ -86,6 +86,12 @@
  6. registercmd("+button4");
  7. registercmd("-button4");
  8.  
  9. + registercmd("+showhitscanstats");
  10. + registercmd("-showhitscanstats");
  11. + registercmd("+showsplashstats");
  12. + registercmd("-showsplashstats");
  13. +
  14. +
  15. #ifndef CAMERATEST
  16. if(isdemo())
  17. {
  18. @@ -326,6 +332,18 @@
  19. } else if(strCmd == "-showscores") {
  20. sb_showscores = false;
  21. return true;
  22. + } else if(strCmd == "+showhitscanstats") {
  23. + sb_showhitscanstats = true;
  24. + return true;
  25. + } else if(strCmd == "-showhitscanstats") {
  26. + sb_showhitscanstats = false;
  27. + return true;
  28. + } else if(strCmd == "+showsplashstats") {
  29. + sb_showsplashstats = true;
  30. + return true;
  31. + } else if(strCmd == "-showsplashstats") {
  32. + sb_showsplashstats = false;
  33. + return true;
  34. }
  35.  
  36. if(camera_active)
  37. Index: sbar.qc
  38. ===================================================================
  39. --- sbar.qc (revision 6523)
  40. +++ sbar.qc (working copy)
  41. @@ -1,3 +1,9 @@
  42. +void drawstringright(vector, string, vector, vector, float, float);
  43. +void drawstringcentre(vector, string, vector, vector, float, float);
  44. +void Sbar_DrawStats(float);
  45. +float weapon_hits[WEP_COUNT];
  46. +float weapon_fired[WEP_COUNT];
  47. +void Sbar_DrawStats_Description(float, vector);
  48.  
  49. float last_weapon;
  50. float weapontime;
  51. @@ -6,6 +12,7 @@
  52.  
  53. vector sbar;
  54. float sbar_alpha_fg;
  55. +float sbar_alpha_bg;
  56. float sbar_hudselector;
  57.  
  58. float ps_primary, ps_secondary;
  59. @@ -20,7 +27,7 @@
  60. pos_x = (vid_conwidth - 1)/2;
  61. pos_y = 16;
  62. pos_z = 0;*/
  63. -
  64. +
  65. //drawpic(pos, "gfx/finale", '0 0 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  66.  
  67. //drawstring(pos, "END", sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
  68. @@ -835,7 +842,7 @@
  69. ymin = 45;
  70.  
  71. xmax = vid_conwidth - xmin;
  72. - ymax = vid_conheight - 0.2*vid_conheight;
  73. + ymax = vid_conheight - 0.2*vid_conheight;
  74.  
  75. center_x = xmin + 0.5*sbwidth;
  76.  
  77. @@ -1773,15 +1780,27 @@
  78. }
  79. }
  80.  
  81. +float weapon_hits[WEP_COUNT];
  82. +float weapon_fired[WEP_COUNT];
  83. +
  84. void Sbar_Draw (void)
  85. {
  86. float i;
  87. float x, fade;
  88. float stat_items, stat_weapons;
  89. + float weapon_number, weapon_stats;
  90. vector o; o = '1 0 0' * vid_conwidth;
  91. vector v;
  92. string s;
  93.  
  94. + weapon_stats = getstati(STAT_DMGDONE_HITS);
  95. + weapon_number = weapon_stats & 63;
  96. + weapon_hits[weapon_number] = rint(weapon_stats / 64);
  97. +
  98. + weapon_stats = getstati(STAT_MAXDMG_FIRED);
  99. + weapon_number = weapon_stats & 63;
  100. + weapon_fired[weapon_number] = rint(weapon_stats / 64);
  101. +
  102. sbar_fontsize = Sbar_GetFontsize("sbar_fontsize");
  103.  
  104. if(spectatee_status && !intermission)
  105. @@ -1933,11 +1952,23 @@
  106. Sbar_DrawScoreboard();
  107. Sbar_DrawCenterPrint();
  108. }
  109. + else if(sb_showsplashstats == 1)
  110. + {
  111. + Sbar_DrawStats(0);
  112. + }
  113. + else if(sb_showhitscanstats == 1)
  114. + {
  115. + Sbar_DrawStats(1);
  116. + }
  117. else if (intermission == 1)
  118. {
  119. Sbar_DrawScoreboard();
  120. Sbar_DrawCenterPrint();
  121. return;
  122. +// Sbar_DrawStats(0);
  123. +// return;
  124. +// Sbar_DrawStats(1);
  125. +// return;
  126. }
  127. else if (intermission == 2)
  128. {
  129. @@ -2190,3 +2221,130 @@
  130. drawpic(pos, "gfx/sb_flag_blue_shielded", '128 64 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
  131. }
  132. }
  133. +
  134. +void Sbar_DrawStats(float type)
  135. +{
  136. + float i, count, row; // count is the number of 'colums'
  137. + float weapon_number, weapon_stats, weapon_hit, weapon_damage;
  138. + float col_margin; // the pixel distance between the columns
  139. + float left_border; // position where the weapons start, the description is in the border
  140. + float top_border; // position where the first row starts
  141. + float row_margin; // the pixel distance between the rows
  142. + vector fill_colour, fill_size;
  143. + vector pos;
  144. +
  145. + col_margin = 20; // pixels between the columns
  146. + row_margin = 20; // pixels between the rows
  147. + top_border = 120; // pixels down the screen
  148. +
  149. + fill_size_x = 5 * sbar_fontsize_x; // width of the background
  150. + fill_size_y = 10 * sbar_fontsize_y; // height of the background
  151. +
  152. +
  153. + if (type == 1)
  154. + { // hitscan stats
  155. + // 45 pixels is the same as the 'Scoreboard' heading
  156. + drawstringcentre('0 45 0', "Hitscan Accuracy", 2 * sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  157. +
  158. + left_border = col_margin + 9 * sbar_fontsize_x;
  159. + }
  160. + else
  161. + {
  162. + drawstringcentre('0 45 0', "Splish, Splosh, Splash Accuracy", 2 * sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  163. +
  164. + left_border = col_margin + 11 * sbar_fontsize_x;
  165. + }
  166. +
  167. + Sbar_DrawStats_Description(type, '1 0 0' * col_margin + '0 1 0' * top_border);
  168. +
  169. +
  170. + for(i = WEP_FIRST; i < WEP_LAST; ++i)
  171. + {
  172. + weapon_hit = weapon_hits[i];
  173. + weapon_damage = weapon_fired[i];
  174. +
  175. + weapon_number = cvar(strcat("weapon_type", ftos(i)));
  176. + if ((weapon_number != 42)) // print them all :)
  177. +// if ((weapon_number == type) && (weapon_damage))
  178. + {
  179. + weapon_stats = rint(100 * weapon_hit / weapon_damage);
  180. +
  181. + fill_colour_x = 1 - 0.015 * weapon_stats;
  182. + fill_colour_y = 1 - 0.015 * (100 - weapon_stats);
  183. +
  184. +// how the background colour is calculated
  185. +// % red green red_2 green_2
  186. +// 0 1 0 1 - % * 0.015 1 - (100 - %) * 0.015
  187. +// 10 0.85 0 1 - % * 0.015 1 - (100 - %) * 0.015
  188. +// 20 0.70 0 1 - % * 0.015 1 - (100 - %) * 0.015
  189. +// 30 0.55 0 1 - % * 0.015 1 - (100 - %) * 0.015
  190. +// 40 0.40 0.10 1 - % * 0.015 1 - (100 - %) * 0.015
  191. +// 50 0.25 0.25 1 - % * 0.015 1 - (100 - %) * 0.015
  192. +// 60 0.10 0.40 1 - % * 0.015 1 - (100 - %) * 0.015
  193. +// 70 0 0.55 1 - % * 0.015 1 - (100 - %) * 0.015
  194. +// 80 0 0.70 1 - % * 0.015 1 - (100 - %) * 0.015
  195. +// 90 0 0.85 1 - % * 0.015 1 - (100 - %) * 0.015
  196. +// 100 0 1 1 - % * 0.015 1 - (100 - %) * 0.015
  197. +
  198. + if ((left_border + count * (fill_size_x + col_margin) + fill_size_x + cvar("stats_right_margin")) >= vid_conwidth)
  199. + {
  200. + count = 0;
  201. + ++row;
  202. + Sbar_DrawStats_Description(type, '1 0 0' * col_margin + '0 1 0' * (top_border + row * (fill_size_y + row_margin)));
  203. + }
  204. +
  205. + pos_x = left_border + count * (fill_size_x + col_margin);
  206. + pos_y = top_border + row * (fill_size_y + row_margin);
  207. +
  208. +// background
  209. + drawfill(pos, fill_size , fill_colour, 0.4 * sbar_alpha_bg, DRAWFLAG_NORMAL);
  210. +
  211. +// the weapon
  212. + drawpic(pos, strcat("gfx/inv_weapon", ftos(i-1)), '1 0.5 0' * fill_size_x , '1 1 1', sbar_alpha_bg, DRAWFLAG_NORMAL);
  213. +
  214. +// the amount of shots fired or max damage
  215. + drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 3 0' * sbar_fontsize_y, ftos(weapon_damage), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  216. +
  217. +// the amount of hits or actual damage
  218. + drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 5 0' * sbar_fontsize_y, ftos(weapon_hit), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  219. +
  220. +// the accuracy
  221. + drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 7 0' * sbar_fontsize_y, strcat(ftos(weapon_stats),"%"), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  222. +
  223. +// the amount of shots missed or damage wasted
  224. + drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 9 0' * sbar_fontsize_y, ftos(weapon_damage - weapon_hit), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  225. +
  226. + ++count;
  227. + }
  228. + }
  229. +}
  230. +
  231. +void Sbar_DrawStats_Description(float type, vector position)
  232. +{
  233. + if (type == 1)
  234. + { // hitscan stats
  235. + drawstring(position + '0 3 0' * sbar_fontsize_y, "Shots fired:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  236. + drawstring(position + '0 5 0' * sbar_fontsize_y, "Shots hit:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  237. + drawstring(position + '0 7 0' * sbar_fontsize_y, "Accuracy:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  238. + drawstring(position + '0 9 0' * sbar_fontsize_y, "Shots missed:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  239. + }
  240. + else
  241. + {
  242. + drawstring(position + '0 3 0' * sbar_fontsize_y, "Maximum damage:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  243. + drawstring(position + '0 5 0' * sbar_fontsize_y, "Actual damage:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  244. + drawstring(position + '0 7 0' * sbar_fontsize_y, "Accuracy:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  245. + drawstring(position + '0 9 0' * sbar_fontsize_y, "Damage wasted:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
  246. + }
  247. +}
  248. +
  249. +void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
  250. +{
  251. + position_x -= 2 / 3 * strlen(text) * scale_x;
  252. + drawstring(position, text, scale, rgb, alpha, flag);
  253. +}
  254. +
  255. +void drawstringcentre(vector position, string text, vector scale, vector rgb, float alpha, float flag)
  256. +{
  257. + position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
  258. + drawstring(position, text, scale, rgb, alpha, flag);
  259. +}
  260. Index: Defs.qc
  261. ===================================================================
  262. --- Defs.qc (revision 6523)
  263. +++ Defs.qc (working copy)
  264. @@ -150,6 +150,8 @@
  265. // Additional OPTIONAL Fields and Globals
  266. float intermission;
  267. float sb_showscores;
  268. +float sb_showhitscanstats;
  269. +float sb_showsplashstats;
  270. .string message;
  271. .float renderflags;
  272. // float coop;
  273. Index: View.qc
  274. ===================================================================
  275. --- View.qc (revision 6523)
  276. +++ View.qc (working copy)
  277. @@ -289,6 +289,7 @@
  278. }
  279.  
  280. sbar_alpha_fg = cvar("sbar_alpha_fg" );
  281. + sbar_alpha_bg = cvar("sbar_alpha_bg" );
  282. sbar_hudselector = cvar("sbar_hudselector");
  283. ColorTranslateMode = cvar("cl_stripcolorcodes");
  284. activeweapon = getstati(STAT_SWITCHWEAPON);
Add Comment
Please, Sign In to add comment