Advertisement
Guest User

Untitled

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