Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.31 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #define DEBUG
  5.  
  6. #define PLUGIN_AUTHOR ""
  7. #define PLUGIN_VERSION "0.42"
  8.  
  9. #include <sourcemod>
  10. #include <sdktools>
  11. #include <tf2>
  12. #include <tf2_stocks>
  13. #include <smlib>
  14. //#include <sdkhooks>
  15.  
  16. public Plugin myinfo = {
  17.     name = "frick",
  18.     author = PLUGIN_AUTHOR,
  19.     description = "",
  20.     version = PLUGIN_VERSION,
  21.     url = ""
  22. };
  23.  
  24. public void OnPluginStart() {
  25.     RegAdminCmd("sm_test", sm_test, ADMFLAG_SLAY);
  26. }
  27.  
  28. public void OnMapStart() {
  29.     PrecacheSound("meme/stadiumrave.mp3", true);
  30.     //AddFileToDownloadsTable("sound/meme/stadiumrave.mp3");
  31. }
  32.  
  33. bool TRFiltPlayer(int entity, int contentsMask, any data) {
  34.     return (entity != data);
  35. }
  36.  
  37. stock int CreateParticle(float vPos[3], char[] system, float time=0.0) {
  38.     int particle = CreateEntityByName("info_particle_system");
  39.    
  40.     if (IsValidEdict(particle)) {
  41.         TeleportEntity(particle, vPos, NULL_VECTOR, NULL_VECTOR);
  42.         DispatchKeyValue(particle, "targetname", "_plParticle");
  43.         DispatchKeyValue(particle, "effect_name", system);
  44.         DispatchSpawn(particle);
  45.         SetVariantString("_plParticle");
  46.         ActivateEntity(particle);
  47.         AcceptEntityInput(particle, "start");
  48.         if (time != 0.0) {
  49.             CreateTimer(time, DeleteParticle, particle);
  50.         }
  51.     }
  52.    
  53.     return particle;
  54. }
  55.  
  56. public Action DeleteParticle(Handle timer, int particle) {
  57.     if (IsValidEntity(particle)) {
  58.         char class[64];
  59.         GetEdictClassname(particle, class, sizeof(class));
  60.         if (StrEqual(class, "info_particle_system", false)) {
  61.             RemoveEdict(particle);
  62.         }
  63.     }
  64. }
  65.  
  66. #define PARTICLE_CHOICES 4
  67. char particlechoices[PARTICLE_CHOICES][] = {
  68.     "eyeboss_tp_vortex",
  69.     "nucleus_core_steady",
  70.     "mvm_emergency_light_glow_yellow",
  71.     "mvm_emergencylight_glow_red"
  72. };
  73.  
  74. bool g_running = false;
  75. public Action sm_test(int client, int args) {
  76.     if (g_running) {
  77.         PrintToChat(client, "Wait for the command to finish silly");
  78.     }
  79.     g_running = true;
  80.  
  81.     float vClientPos[3];
  82.     Entity_GetAbsOrigin(client, vClientPos);
  83.     for (int i = 0; i < 50; i++) {
  84.         float angDir[3];
  85.         Math_MakeVector(-Math_GetRandomFloat(35.0, 89.0), Math_GetRandomFloat(-180.0, 180.0), 0.0, angDir);
  86.         PrintToServer("angDir: %f %f %f", angDir[0], angDir[1], angDir[2]);
  87.         TR_TraceRayFilter(vClientPos, angDir, MASK_SOLID_BRUSHONLY, RayType_Infinite, TRFiltPlayer, client);
  88.        
  89.         float vPos[3];
  90.         float vEnd[3];
  91.         TR_GetEndPosition(vEnd);
  92.        
  93.         float vNormal[3]; // bounce it off
  94.         TR_GetPlaneNormal(INVALID_HANDLE, vNormal);
  95.         ScaleVector(vNormal, Math_GetRandomFloat(64.0, GetVectorDistance(vClientPos, vEnd)));
  96.         PrintToServer("vNormal (scaled): %f %f %f", vNormal[0], vNormal[1], vNormal[2]);
  97.         AddVectors(vEnd, vNormal, vPos);
  98.         PrintToServer("vPos: %f %f %f", vPos[0], vPos[1], vPos[2]);
  99.        
  100.         CreateParticle(vPos, particlechoices[Math_GetRandomInt(0, PARTICLE_CHOICES - 1)], 30.0);
  101.     }
  102.  
  103.     EmitSoundToAll("meme/stadiumrave.mp3");
  104.     Handle handle = CreateTimer(0.1, ShakeAll, INVALID_HANDLE, TIMER_REPEAT);
  105.     CreateTimer(30.0, ResetTheThing, handle);
  106.    
  107.     return Plugin_Handled;
  108. }
  109. public Action ResetTheThing(Handle timer, Handle aaaa) {
  110.     g_running = false;
  111.     KillTimer(aaaa);
  112. }
  113.  
  114. public Action ShakeAll(Handle timer) {
  115.     for (int nClient = 1; nClient < GetMaxClients(); nClient++) {
  116.         if (IsValidEdict(nClient) && IsClientInGame(nClient)) {
  117.             Client_Shake(nClient, SHAKE_START, 25.0, 150.0, 0.5);
  118.         }
  119.     }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement