Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

231 lines
9.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Implementation of the Weapon Awards
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //------------------------------------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #include "WeaponAwards.h"
  14. //------------------------------------------------------------------------------------------------------
  15. // Function: CWeaponAward::getWinner
  16. // Purpose: all weapon awards use this to generate their winners
  17. //------------------------------------------------------------------------------------------------------
  18. void CWeaponAward::getWinner()
  19. {
  20. CEventListIterator it;
  21. for (it=g_pMatchInfo->eventList()->begin(); it != g_pMatchInfo->eventList()->end(); ++it)
  22. {
  23. if ((*it)->getType()==CLogEvent::FRAG)
  24. {
  25. if (strcmp((*it)->getArgument(2)->getStringValue(),killtype)==0)
  26. {
  27. PID pid=(*it)->getArgument(0)->asPlayerGetPID();
  28. accum[pid]++;
  29. winnerID=pid;
  30. fNoWinner=false;
  31. }
  32. }
  33. }
  34. map<PID,int>::iterator acc_it;
  35. for (acc_it=accum.begin();acc_it!=accum.end();++acc_it)
  36. {
  37. int currID=(*acc_it).first;
  38. if (accum[currID]>accum[winnerID])
  39. winnerID=currID;
  40. }
  41. }
  42. //------------------------------------------------------------------------------------------------------
  43. // Function: CAssaultCannonAward::noWinner
  44. // Purpose: writes out html indicating that no one won this award
  45. // Input: html - the html file to output to
  46. //------------------------------------------------------------------------------------------------------
  47. void CAssaultCannonAward::noWinner(CHTMLFile& html)
  48. {
  49. html.write("No one was killed with the Assault Cannon during this match.");
  50. }
  51. //------------------------------------------------------------------------------------------------------
  52. // Function: CAssaultCannonAward::extendedinfo
  53. // Purpose: writes out html displaying extra information about the winning of this award
  54. // Input: html - the html file to output to
  55. //------------------------------------------------------------------------------------------------------
  56. void CAssaultCannonAward::extendedinfo(CHTMLFile& html)
  57. {
  58. if (accum[winnerID]==1)
  59. html.write("%s got 1 kill with the Assault Cannon!",winnerName.c_str());
  60. else
  61. html.write("%s got %li kills with the Assault Cannon!",winnerName.c_str(),accum[winnerID]);
  62. }
  63. //------------------------------------------------------------------------------------------------------
  64. // Function: CFlamethrowerAward::noWinner
  65. // Purpose: writes out html indicating that no one won this award
  66. // Input: html - the html file to output to
  67. //------------------------------------------------------------------------------------------------------
  68. void CFlamethrowerAward::noWinner(CHTMLFile& html)
  69. {
  70. html.write("No one got torched during this match.");
  71. }
  72. //------------------------------------------------------------------------------------------------------
  73. // Function: CFlamethrowerAward::extendedinfo
  74. // Purpose: writes out html displaying extra information about the winning of this award
  75. // Input: html - the html file to output to
  76. //------------------------------------------------------------------------------------------------------
  77. void CFlamethrowerAward::extendedinfo(CHTMLFile& html)
  78. {
  79. if (accum[winnerID]==1)
  80. html.write("%s torched 1 person!",winnerName.c_str());
  81. else
  82. html.write("%s torched %li people!",winnerName.c_str(),accum[winnerID]);
  83. }
  84. //------------------------------------------------------------------------------------------------------
  85. // Function: CKnifeAward::noWinner
  86. // Purpose: writes out html indicating that no one won this award
  87. // Input: html - the html file to output to
  88. //------------------------------------------------------------------------------------------------------
  89. void CKnifeAward::noWinner(CHTMLFile& html)
  90. {
  91. html.write("No one got knifed during this match.");
  92. }
  93. //------------------------------------------------------------------------------------------------------
  94. // Function: CKnifeAward::extendedinfo
  95. // Purpose: writes out html displaying extra information about the winning of this award
  96. // Input: html - the html file to output to
  97. //------------------------------------------------------------------------------------------------------
  98. void CKnifeAward::extendedinfo(CHTMLFile& html)
  99. {
  100. if (accum[winnerID]==1)
  101. html.write("%s backstabbed 1 person!",winnerName.c_str());
  102. else
  103. html.write("%s backstabbed %li people!",winnerName.c_str(),accum[winnerID]);
  104. }
  105. //------------------------------------------------------------------------------------------------------
  106. // Function: CRocketryAward::noWinner
  107. // Purpose: writes out html indicating that no one won this award
  108. // Input: html - the html file to output to
  109. //------------------------------------------------------------------------------------------------------
  110. void CRocketryAward::noWinner(CHTMLFile& html)
  111. {
  112. html.write("No one was killed by a rocket during this match.");
  113. }
  114. //------------------------------------------------------------------------------------------------------
  115. // Function: CRocketryAward::extendedinfo
  116. // Purpose:
  117. // Input: html - the html file to output to
  118. //------------------------------------------------------------------------------------------------------
  119. void CRocketryAward::extendedinfo(CHTMLFile& html)
  120. {
  121. if (accum[winnerID]==1)
  122. html.write("%s rocketed 1 person to oblivion!",winnerName.c_str());
  123. else
  124. html.write("%s rocketed %li people to oblivion!",winnerName.c_str(),accum[winnerID]);
  125. }
  126. //------------------------------------------------------------------------------------------------------
  127. // Function: CGrenadierAward::noWinner
  128. // Purpose: writes out html indicating that no one won this award
  129. // Input: html - the html file to output to
  130. //------------------------------------------------------------------------------------------------------
  131. void CGrenadierAward::noWinner(CHTMLFile& html)
  132. {
  133. html.write("No one was killed by a grenade during this match.");
  134. }
  135. //------------------------------------------------------------------------------------------------------
  136. // Function: CGrenadierAward::extendedinfo
  137. // Purpose: writes out html displaying extra information about the winning of this award
  138. // Input: html - the html file to output to
  139. //------------------------------------------------------------------------------------------------------
  140. void CGrenadierAward::extendedinfo(CHTMLFile& html)
  141. {
  142. if (accum[winnerID]==1)
  143. html.write("%s killed 1 person with a grenade!",winnerName.c_str());
  144. else
  145. html.write("%s got %li people with grenades!",winnerName.c_str(),accum[winnerID]);
  146. }
  147. //------------------------------------------------------------------------------------------------------
  148. // Function: CDemolitionsAward::noWinner
  149. // Purpose: writes out html indicating that no one won this award
  150. // Input: html - the html file to output to
  151. //------------------------------------------------------------------------------------------------------
  152. void CDemolitionsAward::noWinner(CHTMLFile& html)
  153. {
  154. html.write("No one fell victim to a Detpack this match.");
  155. }
  156. //------------------------------------------------------------------------------------------------------
  157. // Function: CDemolitionsAward::extendedinfo
  158. // Purpose: writes out html displaying extra information about the winning of this award
  159. // Input: html - the html file to output to
  160. //------------------------------------------------------------------------------------------------------
  161. void CDemolitionsAward::extendedinfo(CHTMLFile& html)
  162. {
  163. if (accum[winnerID]==1)
  164. html.write("%s smeared 1 person with a detpack!",winnerName.c_str());
  165. else
  166. html.write("%s smeared %li people with detpacks!",winnerName.c_str(),accum[winnerID]);
  167. }
  168. //------------------------------------------------------------------------------------------------------
  169. // Function: CBiologicalWarfareAward::noWinner
  170. // Purpose: writes out html indicating that no one won this award
  171. // Input: html - the html file to output to
  172. //------------------------------------------------------------------------------------------------------
  173. void CBiologicalWarfareAward::noWinner(CHTMLFile& html)
  174. {
  175. html.write("No one died of infection this match.");
  176. }
  177. //------------------------------------------------------------------------------------------------------
  178. // Function: CBiologicalWarfareAward::extendedinfo
  179. // Purpose: writes out html displaying extra information about the winning of this award
  180. // Input: html - the html file to output to
  181. //------------------------------------------------------------------------------------------------------
  182. void CBiologicalWarfareAward::extendedinfo(CHTMLFile& html)
  183. {
  184. if (accum[winnerID]==1)
  185. html.write("%s infected 1 person.",winnerName.c_str());
  186. else
  187. html.write("%li people succumbed to %s's disease.",accum[winnerID],winnerName.c_str());
  188. }
  189. //------------------------------------------------------------------------------------------------------
  190. // Function: CBestSentryAward::noWinner
  191. // Purpose: writes out html indicating that no one won this award
  192. // Input: html - the html file to output to
  193. //------------------------------------------------------------------------------------------------------
  194. void CBestSentryAward::noWinner(CHTMLFile& html)
  195. {
  196. html.write("No sentries killed anyone this match.");
  197. }
  198. //------------------------------------------------------------------------------------------------------
  199. // Function: CBestSentryAward::extendedinfo
  200. // Purpose: writes out html displaying extra information about the winning of this award
  201. // Input: html - the html file to output to
  202. //------------------------------------------------------------------------------------------------------
  203. void CBestSentryAward::extendedinfo(CHTMLFile& html)
  204. {
  205. if (accum[winnerID]==1)
  206. html.write("%s got 1 person with a sentry gun!",winnerName.c_str());
  207. else
  208. html.write("%li people were killed by %s's well placed sentries.",accum[winnerID],winnerName.c_str());
  209. }