Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.45 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include sdkhooks
  4.  
  5. #pragma tabsize 0
  6.  
  7. float GrenadeDamage = 1000.0
  8. float PipeBombDamage = 1000.0
  9. float BarrelDamage = 1000.0
  10.  
  11. float GrenadeRadius = 500.0
  12. float PipeRadius = 500.0
  13. float BarrelRadius = 500.0
  14.  
  15. Handle sdkCallPushPlayer;
  16.  
  17. public OnPluginStart()
  18. {
  19. Handle GameConf = LoadGameConfigFile("gamedata_stager");
  20.  
  21. if(GameConf == INVALID_HANDLE)
  22. {
  23. SetFailState("Couldn't find the offsets and signatures file. Please, check that it is installed correctly.");
  24. }
  25.  
  26. StartPrepSDKCall(SDKCall_Player);
  27. PrepSDKCall_SetFromConf(GameConf, SDKConf_Signature, "CTerrorPlayer_Fling");
  28. PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  29. PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
  30. PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
  31. PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
  32. sdkCallPushPlayer = EndPrepSDKCall();
  33. }
  34.  
  35. bool IsAllow = false;
  36.  
  37. public OnMapStart()
  38. {
  39. CreateTimer(3.0, allow)
  40. }
  41.  
  42. public Action allow(Handle timer)
  43. {
  44. IsAllow = true;
  45. }
  46.  
  47. public void OnEntityDestroyed(int entity)
  48. {
  49. if(!IsAllow) return;
  50.  
  51. if (IsValidEntity(entity) && IsValidEdict(entity))
  52. {
  53. char classname[128];
  54. GetEdictClassname(entity, classname, 128);
  55. if (StrEqual(classname, "grenade_launcher_projectile", false))
  56. {
  57. GrenadeTouch(entity);
  58. }
  59. if (StrEqual(classname, "pipe_bomb_projectile", false))
  60. {
  61. BombTouch(entity);
  62. }
  63. if (StrEqual(classname, "prop_fuel_barrel", false))
  64. {
  65. BarrelTouch(entity);
  66. }
  67. }
  68. }
  69.  
  70. public int GrenadeTouch(int entity)
  71. {
  72. float pos[3];
  73. GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  74. GranadeExplode(pos, GrenadeRadius, GrenadeDamage);
  75. }
  76.  
  77. public int BombTouch(int entity)
  78. {
  79. float pos[3];
  80. GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  81. BombExplode(pos, PipeRadius, PipeBombDamage)
  82. }
  83.  
  84. public int BarrelTouch(int entity)
  85. {
  86. float pos[3];
  87. GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  88. BarrelExplode(pos, BarrelRadius, BarrelDamage);
  89. }
  90.  
  91. int GranadeExplode(float pos[3], float radius, float damage)
  92. {
  93. int explosion = CreateEntityByName("env_explosion", -1);
  94. DispatchKeyValue(explosion, "spawnflags", "64");
  95. DispatchKeyValueFloat(explosion, "iMagnitude", damage);
  96. DispatchKeyValueFloat(explosion, "iRadiusOverride", radius);
  97. DispatchSpawn(explosion);
  98. TeleportEntity(explosion, pos, NULL_VECTOR, NULL_VECTOR);
  99. AcceptEntityInput(explosion, "Explode", -1, -1, 0);
  100. AcceptEntityInput(explosion, "Kill", -1, -1, 0);
  101.  
  102. float fDistance = 0.0;
  103. float pos2[3];
  104. for( int i = 0; i < 32; i++ )
  105. {
  106. if(GetClientTeam(i) == 3 && IsValidClient(i))
  107. {
  108. int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  109. if(vClass == 8)
  110. {
  111. GetClientAbsOrigin(i, pos2);
  112. fDistance = GetVectorDistance(pos, pos2);
  113. if(fDistance < GrenadeRadius)
  114. {
  115. StaggerClient(i, pos)
  116. }
  117. }
  118. }
  119. }
  120. }
  121.  
  122. int BombExplode(float pos[3], float radius, float damage)
  123. {
  124. int explosion = CreateEntityByName("env_explosion", -1);
  125. DispatchKeyValue(explosion, "spawnflags", "1916");
  126. DispatchKeyValueFloat(explosion, "iMagnitude", damage);
  127. DispatchKeyValueFloat(explosion, "iRadiusOverride", radius);
  128. DispatchSpawn(explosion);
  129. TeleportEntity(explosion, pos, NULL_VECTOR, NULL_VECTOR);
  130. AcceptEntityInput(explosion, "Explode", -1, -1, 0);
  131. AcceptEntityInput(explosion, "Kill", -1, -1, 0);
  132.  
  133. float fDistance = 0.0;
  134. float pos2[3];
  135. for( int i = 0; i < 32; i++ )
  136. {
  137. if(GetClientTeam(i) == 3 && IsValidClient(i) && IsPlayerAlive(i))
  138. {
  139. int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  140. if(vClass == 8)
  141. {
  142. GetClientAbsOrigin(i, pos2);
  143. fDistance = GetVectorDistance(pos, pos2);
  144. if(fDistance < PipeRadius)
  145. {
  146. StaggerClient(i, pos)
  147. }
  148. }
  149. }
  150. }
  151. }
  152.  
  153. int BarrelExplode(float pos[3], float radius, float damage)
  154. {
  155. int explosion = CreateEntityByName("env_explosion", -1);
  156. DispatchKeyValue(explosion, "spawnflags", "1916");
  157. DispatchKeyValueFloat(explosion, "iMagnitude", damage);
  158. DispatchKeyValueFloat(explosion, "iRadiusOverride", radius);
  159. DispatchSpawn(explosion);
  160. TeleportEntity(explosion, pos, NULL_VECTOR, NULL_VECTOR);
  161. AcceptEntityInput(explosion, "Explode", -1, -1, 0);
  162. AcceptEntityInput(explosion, "Kill", -1, -1, 0);
  163.  
  164. float fDistance = 0.0;
  165. float pos2[3];
  166. for( int i = 0; i < 32; i++ )
  167. {
  168. if(GetClientTeam(i) == 3 && IsValidClient(i))
  169. {
  170. int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  171. if(vClass == 8)
  172. {
  173. GetClientAbsOrigin(i, pos2);
  174. fDistance = GetVectorDistance(pos, pos2);
  175. if(fDistance < BarrelRadius)
  176. {
  177. StaggerClient(i, pos)
  178. }
  179. }
  180. }
  181. }
  182. }
  183.  
  184. public Fly(explosion, int target, float power)
  185. {
  186. if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target)) return;
  187.  
  188. float targetPos[3], explosionPos[3], traceVec[3], resultingFling[3];
  189.  
  190. GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);
  191. GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
  192.  
  193. if(power < 1)
  194. return;
  195.  
  196. MakeVectorFromPoints(explosionPos, targetPos, traceVec);
  197. GetVectorAngles(traceVec, resultingFling);
  198.  
  199. resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
  200. resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
  201. resultingFling[2] = power + (power * 0.5);
  202. if (GetClientTeam(target) == 2)
  203. {
  204. SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);
  205. }
  206. else
  207. {
  208. SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);
  209. }
  210. }
  211.  
  212. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  213. {
  214. float victim_origin[3];
  215. char rupture[32];
  216. char damage_victim[32];
  217. IntToString(damage, rupture, sizeof(rupture));
  218. Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  219. GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  220. int entity = CreateEntityByName("point_hurt");
  221. DispatchKeyValue(victim, "targetname", damage_victim);
  222. DispatchKeyValue(entity, "DamageTarget", damage_victim);
  223. DispatchKeyValue(entity, "Damage", rupture);
  224. DispatchSpawn(entity);
  225. TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  226. AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  227. DispatchKeyValue(entity, "classname", "point_hurt");
  228. DispatchKeyValue(victim, "targetname", "null");
  229. AcceptEntityInput(entity, "Kill");
  230. }
  231.  
  232. void StaggerClient(int iUserID, const float fPos[3])
  233. {
  234. static int iScriptLogic = INVALID_ENT_REFERENCE;
  235. if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
  236. {
  237. iScriptLogic = EntIndexToEntRef(CreateEntityByName("logic_script"));
  238. if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
  239. LogError("Could not create 'logic_script");
  240.  
  241. DispatchSpawn(iScriptLogic);
  242. }
  243.  
  244. char sBuffer[96];
  245. Format(sBuffer, sizeof(sBuffer), "GetPlayerFromUserID(%d).Stagger(Vector(%d,%d,%d))", iUserID, RoundFloat(fPos[0]), RoundFloat(fPos[1]), RoundFloat(fPos[2]));
  246. SetVariantString(sBuffer);
  247. AcceptEntityInput(iScriptLogic, "RunScriptCode");
  248. AcceptEntityInput(iScriptLogic, "Kill");
  249. }
  250.  
  251. stock bool IsValidClient(int client)
  252. {
  253. if ( client < 1 || client > MaxClients ) return false;
  254. if( !IsClientInGame(client)) return false;
  255. if ( !IsPlayerAlive( client )) return false;
  256. return true;
  257. }
  258.  
  259. public void ScreenShake(int target, float power)
  260. {
  261. Handle msg;
  262. msg = StartMessageOne("Shake", target);
  263. BfWriteByte(msg, 0);
  264. BfWriteFloat(msg, power);
  265. BfWriteFloat(msg, 10.0);
  266. BfWriteFloat(msg, 3.0);
  267. EndMessage();
  268. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement