Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. // ==========================================================
  2. // IW4M project
  3. //
  4. // Component: clientdll
  5. // Sub-component: steam_api
  6. // Purpose: Adds a T5-style string next to obituaries of
  7. // players committing suicide.
  8. //
  9. // Initial author: NTAuthority
  10. // Started: 2012-04-10
  11. // ==========================================================
  12.  
  13. #include "StdInc.h"
  14. #include <time.h>
  15.  
  16. dvar_t* iw4m_suicideMsg;
  17. #define NUM_SUICIDE_MESSAGES 13
  18.  
  19. static const char* suicideMessages[] =
  20. {
  21. "Mistakes were made.",
  22. "made a fatal mistake.",
  23. "killed himself.",
  24. "couldn't take it anymore.",
  25. "bought the farm.",
  26. "ate xetal's socks.",
  27. "gave Pigophone a pillow.",
  28. "is KIA.",
  29. "committed suicide.",
  30. "couldn't be saved.",
  31. "was too depressed.",
  32. "SUICIDED!",
  33. "bid farewell, cruel world!"
  34. };
  35.  
  36. CallHook printObituaryHook;
  37. DWORD printObituaryHookLoc = 0x401453;
  38.  
  39. void ModifyObituaryMessage(char* attackerName, char* buffer)
  40. {
  41. if (!attackerName[0] && (!iw4m_suicideMsg || iw4m_suicideMsg->current.boolean))
  42. {
  43. char suicideMessage[128] = { 0 };
  44. strcat(suicideMessage, " ");
  45. strcat(suicideMessage, suicideMessages[rand() % NUM_SUICIDE_MESSAGES]);
  46. strcat(suicideMessage, "\n");
  47.  
  48. char* end = &buffer[strlen(buffer) - 1];
  49. strcpy(end, suicideMessage);
  50. }
  51. }
  52.  
  53. void __declspec(naked) PrintObituaryHookStub()
  54. {
  55. __asm
  56. {
  57. push ecx
  58. push eax // message buffer
  59.  
  60. mov ecx, [esp + 438h] // function argument 2, 'attacker name'
  61.  
  62. push ecx
  63. call ModifyObituaryMessage
  64. add esp, 4h
  65.  
  66. pop eax
  67. pop ecx
  68. jmp printObituaryHook.pOriginal
  69. }
  70. }
  71.  
  72. void PatchMW2_SuicideMessages()
  73. {
  74. srand((unsigned int)time(NULL));
  75.  
  76. printObituaryHook.initialize(printObituaryHookLoc, PrintObituaryHookStub);
  77. printObituaryHook.installHook();
  78.  
  79. iw4m_suicideMsg = (dvar_t*)Dvar_RegisterBool("iw4m_suicideMsg", 1, DVAR_FLAG_SAVED, "Enables custom suicide messages");
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement