Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. #pragma semicolon 1
  2.  
  3. #include <sourcemod>
  4. #include <sdkhooks>
  5.  
  6. enum ButtonState
  7. {
  8. Pressed,
  9. Released,
  10. };
  11.  
  12. new Handle:g_ConVar_Penalty_Hndl = INVALID_HANDLE;
  13. new Handle:g_ConVar_NapalmOnly_Hndl = INVALID_HANDLE;
  14. new Float:g_Penalty = 0.0;
  15. new bool:g_NapalmOnly = true;
  16.  
  17. new g_StaminaOffset = -1;
  18. new ButtonState:g_JumpButtonState[MAXPLAYERS + 1] = {Released, ...};
  19.  
  20. public Plugin:myinfo =
  21. {
  22. name = "Burn Speed Penalty",
  23. author = "Lickaroo Johnson McPhaley",
  24. description = "Applies a stamina-based speed penalty when burned so ignited players get a slowdown like in older Source titles.",
  25. version = "1.33333333333333",
  26. url = "http://www.wigs4sale.net/"
  27. };
  28.  
  29. public OnPluginStart()
  30. {
  31. g_StaminaOffset = FindSendPropInfo("CCSPlayer", "m_flStamina");
  32. if (g_StaminaOffset == -1)
  33. {
  34. LogError("\"CCSPlayer::m_flStamina\" could not be found.");
  35. SetFailState("\"CCSPlayer::m_flStamina\" could not be found.");
  36. }
  37.  
  38. g_ConVar_Penalty_Hndl = CreateConVar("sm_stamina_burncost", "25.0", "Stamina penalty applied when burned", 0, true, 0.0, true, 100.0);
  39. g_Penalty = GetConVarFloat(g_ConVar_Penalty_Hndl);
  40. HookConVarChange(g_ConVar_Penalty_Hndl, OnPenaltyChanged);
  41.  
  42. g_ConVar_NapalmOnly_Hndl = CreateConVar("sm_napalmonly", "1", "Stamina penalty will only be applied to napalm grenades", 0, true, 0.0, true, 1.0);
  43. g_NapalmOnly = GetConVarBool(g_ConVar_Penalty_Hndl);
  44. HookConVarChange(g_ConVar_NapalmOnly_Hndl, OnNapalmOnlyChanged);
  45.  
  46. // Late load
  47. for (new i = 1; i <= MaxClients; i++)
  48. {
  49. if (IsClientInGame(i))
  50. {
  51. OnClientPutInServer(i);
  52. }
  53. }
  54. }
  55.  
  56. public OnClientPutInServer(client)
  57. {
  58. SDKHook(client, SDKHook_OnTakeDamagePost, OnTakeDamagePost);
  59. }
  60.  
  61. public OnPenaltyChanged(Handle:cvar, const String:oldVal[], const String:newVal[])
  62. {
  63. g_Penalty = StringToFloat(newVal);
  64. }
  65.  
  66. public OnNapalmOnlyChanged(Handle:cvar, const String:oldVal[], const String:newVal[])
  67. {
  68. g_NapalmOnly = bool:StringToInt(newVal);
  69. }
  70.  
  71.  
  72. public OnTakeDamagePost(client, attacker, inflictor, Float:damage, damagetype)
  73. {
  74. if (!(damagetype & DMG_BURN))
  75. {
  76. return;
  77. }
  78.  
  79. if (attacker >= 1 && attacker <= MaxClients)
  80. {
  81. if (g_NapalmOnly == true)
  82. {
  83. return;
  84. }
  85. }
  86.  
  87. if (!IsClientOnObject(client))
  88. {
  89. return;
  90. }
  91.  
  92.  
  93. SetEntDataFloat(client, g_StaminaOffset, g_Penalty, true);
  94. return;
  95. }
  96.  
  97. public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
  98. {
  99. if (!IsClientOnObject(client))
  100. {
  101. return Plugin_Continue;
  102. }
  103.  
  104. if (!(buttons & IN_JUMP))
  105. {
  106. // Player is not holding down space bar (+jump)
  107. g_JumpButtonState[client] = Released;
  108.  
  109. return Plugin_Continue;
  110. }
  111.  
  112. // Player is holding down the space bar (+jump)
  113.  
  114. if (g_JumpButtonState[client] == Pressed)
  115. {
  116. // Client is holding down +jump before we land
  117. return Plugin_Continue;
  118. }
  119.  
  120. g_JumpButtonState[client] = Pressed;
  121. SetEntDataFloat(client, g_StaminaOffset, 0.0, true);
  122.  
  123. return Plugin_Continue;
  124. }
  125.  
  126. /**
  127. * Return whether a client is standing on an object
  128. *
  129. * @param Client index
  130. * @return True if client is standing on an object. False otherwise.
  131. */
  132. bool:IsClientOnObject(client)
  133. {
  134. return GetEntPropEnt(client, Prop_Send, "m_hGroundEntity") > -1 ? true : false;
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement