Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include <sdktools>
  5. #include <sdkhooks>
  6.  
  7. #define MAX_LIST 18
  8.  
  9. Handle sdkSetAttack;
  10.  
  11. static const char gWeapons[MAX_LIST][] =
  12. {
  13. "weapon_autoshotgun",
  14. "weapon_hunting_rifle",
  15. "weapon_pistol",
  16. "weapon_pistol_magnum",
  17. "weapon_pumpshotgun",
  18. "weapon_rifle",
  19. "weapon_rifle_ak47",
  20. "weapon_rifle_desert",
  21. "weapon_rifle_m60",
  22. "weapon_rifle_sg552",
  23. "weapon_shotgun_chrome",
  24. "weapon_shotgun_spas",
  25. "weapon_smg",
  26. "weapon_smg_mp5",
  27. "weapon_smg_silenced",
  28. "weapon_sniper_awp",
  29. "weapon_sniper_military",
  30. "weapon_sniper_scout"
  31. };
  32.  
  33. static const float gDistance[MAX_LIST] =
  34. {
  35. 1650.0,
  36. 1100.0,
  37. 880.0,
  38. 1980.0,
  39. 1650.0,
  40. 1100.0,
  41. 1100.0,
  42. 1100.0,
  43. 1320.0,
  44. 1100.0,
  45. 1540.0,
  46. 1540.0,
  47. 880.0,
  48. 880.0,
  49. 880.0,
  50. 1870.0,
  51. 1320.0,
  52. 1320.0
  53. };
  54.  
  55. public void OnPluginStart()
  56. {
  57. HookEvent("weapon_fire", EventFire);
  58.  
  59. Handle hGameConf = LoadGameConfigFile("added_sound-attracts-zombies");
  60. StartPrepSDKCall(SDKCall_Entity);
  61. if( PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "SetAttackToSurvivors") == false )
  62. SetFailState("Could not load the \"SetAttackToSurvivors\" gamedata signature.");
  63. sdkSetAttack = EndPrepSDKCall();
  64. delete hGameConf;
  65. }
  66.  
  67. public Action EventFire(Handle event, const char[] name, bool dontbroadcast)
  68. {
  69. int client = GetClientOfUserId(GetEventInt(event, "userid"));
  70. if(bIsSurvivor(client))
  71. {
  72. int weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  73. if(IsValidEntity(weapon))
  74. {
  75. char weaponname[36];
  76. GetEntityClassname(weapon, weaponname, sizeof(weaponname));
  77.  
  78. float vPos[3], vTargetPos[3];
  79. GetClientEyePosition(client, vPos);
  80.  
  81. for( int i = 0; i < MAX_LIST; i++ )
  82. {
  83. if(strcmp(weaponname, gWeapons[i]) == 0)
  84. {
  85. int entity = -1;
  86. while( (entity = FindEntityByClassname(entity, "infected")) != INVALID_ENT_REFERENCE )
  87. {
  88. GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vTargetPos);
  89. float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
  90.  
  91. if(IsVisibleTo(vPos, vTargetPos))
  92. {
  93. if(fTargetDistance < gDistance[i])
  94. {
  95. SDKCall(sdkSetAttack, entity);
  96. }
  97. }
  98. else
  99. {
  100. float iOne = gDistance[i] / 3;
  101. int vForward = RoundToCeil(gDistance[i] / iOne);
  102. int vTotal = 50 / (vForward * vForward * vForward);
  103. if(GetRandomInt(0, 100) <= vTotal)
  104. {
  105. if(fTargetDistance < iOne)
  106. {
  107. SDKCall(sdkSetAttack, entity);
  108. }
  109. }
  110. }
  111. }
  112. break;
  113. }
  114. }
  115. }
  116. }
  117. }
  118.  
  119. static bool IsVisibleTo(float position[3], float targetposition[3])
  120. {
  121. float vAngles[3], vLookAt[3];
  122.  
  123. MakeVectorFromPoints(position, targetposition, vLookAt);
  124. GetVectorAngles(vLookAt, vAngles);
  125.  
  126. Handle trace = TR_TraceRayFilterEx(position, vAngles, MASK_SHOT, RayType_Infinite, _TraceFilter);
  127.  
  128. bool isVisible = false;
  129. if (TR_DidHit(trace))
  130. {
  131. float vStart[3];
  132. TR_GetEndPosition(vStart, trace);
  133.  
  134. if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))
  135. {
  136. isVisible = true;
  137. }
  138. }
  139.  
  140. delete trace;
  141. return isVisible;
  142. }
  143.  
  144. public bool _TraceFilter(int entity, int contentsMask)
  145. {
  146. if (IsValidEntity(entity))
  147. {
  148. return false;
  149. }
  150. return true;
  151. }
  152.  
  153. stock bool bIsSurvivor(int client)
  154. {
  155. return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement