Advertisement
FlacoBey

Untitled

Jun 28th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 22.01 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include <sourcemod>
  5. #include <sdktools>
  6. #include <sdkhooks>
  7.  
  8. #define SOUND_PASS1         "animation/c130_flyby.wav"
  9.  
  10. #define PARTICLE_FLARE      "flare_burning"
  11. #define PARTICLE_FUSE       "weapon_pipebomb_fuse"
  12. #define SOUND_CRACKLE       "ambient/fire/fire_small_loop2.wav"
  13. #define MODEL_FLARE         "models/props_lighting/light_flares.mdl"
  14.  
  15. #define MAXLIST 26
  16.  
  17. char sMap[56];
  18. int gIndexCrate[2048+1], g_iFlares[2048+1][5];
  19. ConVar cTankChance, cDropType, cCountItems, cCountAirdrops, cTimeOpen, cUseString, cColorFlare, cFlare, cFlareLenght, cFlareAplha, cWeaponList, cGlowRange, cVocalize;
  20. bool IsLeft4Dead2;
  21.  
  22. public Plugin myinfo =
  23. {
  24.     name = "[L4D2] Airdrop",
  25.     author = "BHaType",
  26.     description = "Admin can call airdrop.",
  27.     version = "0.4",
  28.     url = "https://www.sourcemod.net/plugins.php?cat=0&mod=-1&title=&author=BHaType&description=&search=1"
  29. }
  30.  
  31. static const char gModeList[4][] =
  32. {
  33.     "models/props_vehicles/c130.mdl",
  34.     "models/props_crates/supply_crate02.mdl",
  35.     "models/props_crates/supply_crate02_gib1.mdl",
  36.     "models/props_junk/wood_crate001a.mdl"
  37. };
  38.  
  39. static const char gItemsListL4D1[MAXLIST - 18][] =
  40. {
  41.     "weapon_autoshotgun",
  42.     "weapon_first_aid_kit",
  43.     "weapon_pipe_bomb",
  44.     "weapon_molotov",
  45.     "weapon_rifle",
  46.     "weapon_hunting_rifle",
  47.     "weapon_pain_pills",
  48.     "weapon_pistol"
  49. };
  50.  
  51. static const char gItemsList[MAXLIST][] =
  52. {
  53.     "weapon_autoshotgun",       //0
  54.     "weapon_first_aid_kit",     //1
  55.     "weapon_pipe_bomb",         //2
  56.     "weapon_molotov",           //3
  57.     "weapon_rifle",             //4
  58.     "weapon_hunting_rifle",     //5
  59.     "weapon_pain_pills",        //6
  60.     "weapon_pistol",            //7
  61.     "weapon_adrenaline",        //8
  62.     "weapon_smg_mp5",           //9
  63.     "weapon_smg",               //10
  64.     "weapon_smg_silenced",      //11
  65.     "weapon_pumpshotgun",       //12
  66.     "weapon_shotgun_chrome",    //13
  67.     "weapon_rifle_m60",         //14
  68.     "weapon_shotgun_spas",      //15
  69.     "weapon_sniper_military",   //16
  70.     "weapon_rifle_ak47",        //17
  71.     "weapon_rifle_desert",      //18
  72.     "weapon_sniper_awp",        //19
  73.     "weapon_rifle_sg552",       //20
  74.     "weapon_sniper_scout",      //21
  75.     "weapon_grenade_launcher"//22
  76.     "weapon_pistol_magnum",     //23
  77.     "weapon_vomitjar",          //24
  78.     "weapon_defibrillator"      //25
  79. };
  80.  
  81. static const char gExplodeList[MAXLIST][] =
  82. {
  83.     "autoshotgun",      //0
  84.     "first_aid_kit",    //1
  85.     "pipe_bomb",        //2
  86.     "molotov",          //3
  87.     "rifle",            //4
  88.     "hunting_rifle",    //5
  89.     "pain_pills",       //6
  90.     "pistol",           //7
  91.     "adrenaline",       //8
  92.     "smg_mp5",          //9
  93.     "smg",              //10
  94.     "smg_silenced",     //11
  95.     "pumpshotgun",      //12
  96.     "shotgun_chrome",   //13
  97.     "rifle_m60",        //14
  98.     "shotgun_spas",     //15
  99.     "sniper_military"//16
  100.     "rifle_ak47",       //17
  101.     "rifle_desert",     //18
  102.     "sniper_awp",       //19
  103.     "rifle_sg552",      //20
  104.     "sniper_scout",     //21
  105.     "grenade_launcher", //22
  106.     "pistol_magnum",    //23
  107.     "vomitjar",         //24
  108.     "defibrillator"     //25
  109. };
  110.  
  111. static const char gModelsItemsList[MAXLIST][] =
  112. {
  113.     "models/w_models/weapons/w_autoshot_m4super.mdl",   //0
  114.     "models/w_models/weapons/w_eq_Medkit.mdl",          //1
  115.     "models/w_models/weapons/w_eq_pipebomb.mdl",        //2
  116.     "models/w_models/weapons/w_eq_molotov.mdl",         //3
  117.     "models/w_models/weapons/w_rifle_m16a2.mdl",        //4
  118.     "models/w_models/weapons/w_sniper_mini14.mdl",      //5
  119.     "models/w_models/weapons/w_eq_painpills.mdl",       //6
  120.     "models/w_models/weapons/w_pistol_a.mdl",           //7
  121.     "models/w_models/weapons/w_eq_adrenaline.mdl",      //8
  122.     "models/w_models/weapons/w_smg_mp5.mdl",            //9
  123.     "models/w_models/weapons/w_smg_uzi.mdl",            //10
  124.     "models/w_models/weapons/w_smg_a.mdl",              //11
  125.     "models/w_models/weapons/w_shotgun.mdl",            //12
  126.     "models/w_models/weapons/w_pumpshotgun_a.mdl",      //13
  127.     "models/w_models/weapons/w_m60.mdl",                //14
  128.     "models/w_models/weapons/w_shotgun_spas.mdl",       //15
  129.     "models/w_models/weapons/w_sniper_military.mdl",    //16
  130.     "models/w_models/weapons/w_rifle_ak47.mdl",         //17
  131.     "models/w_models/weapons/w_desert_rifle.mdl",       //18
  132.     "models/w_models/weapons/w_sniper_awp.mdl",         //19
  133.     "models/w_models/weapons/w_rifle_sg552.mdl",        //20
  134.     "models/w_models/weapons/w_sniper_scout.mdl",       //21
  135.     "models/w_models/weapons/w_grenade_launcher.mdl",   //22
  136.     "models/w_models/weapons/w_desert_eagle.mdl",       //23
  137.     "models/w_models/weapons/w_eq_bile_flask.mdl",      //24
  138.     "models/w_models/weapons/w_eq_defibrillator.mdl"    //25
  139. };
  140.  
  141. static int gAmmoList[MAXLIST] =
  142. {
  143.     90,
  144.     -1,
  145.     -1,
  146.     -1,
  147.     360,
  148.     150,
  149.     -1,
  150.     -1,
  151.     -1,
  152.     650,
  153.     650,
  154.     650,
  155.     56,
  156.     56,
  157.     -1,
  158.     90,
  159.     180,
  160.     360,
  161.     360,
  162.     180,
  163.     360,
  164.     180,
  165.     30,
  166.     -1,
  167.     -1,
  168.     -1
  169. };
  170.  
  171. public void OnPluginStart()
  172. {
  173.     char sEngine[24];
  174.     GetGameFolderName(sEngine, sizeof(sEngine));
  175.     if (StrEqual(sEngine, "left4dead2", false))
  176.         IsLeft4Dead2 = true;
  177.    
  178.     RegAdminCmd("sm_ac130", CallAirdrop, ADMFLAG_ROOT);
  179.     //HookEvent("tank_spawn", EventTank);
  180.     HookEvent("tank_killed", EventTank);
  181.  
  182.     cWeaponList     =       CreateConVar("airdrop_weapons_list"     ,   "rifle;autoshotgun;hunting_rifle;smg;pumpshotgun;pistol;molotov;pipe_bomb;first_aid_kit;pain_pills;shotgun_chrome;rifle_desert;grenade_launcher;rifle_m60;rifle_ak47;rifle_sg552;shotgun_spas;smg_silenced;smg_mp5;sniper_awp;sniper_military;sniper_scout;chainsaw;pistol_magnum;vomitjar;defibrillator;upgradepack_explosive;upgradepack_incendiary;adrenaline", "Which weapon should be in airdrop", FCVAR_NONE);
  183.     cFlare          =       CreateConVar("airdrop_flare"            ,   "1"         , "Flaer on? //Fix", FCVAR_NONE);
  184.     cColorFlare     =       CreateConVar("airdrop_flare_color"      ,   "25 25 255" , "Color flare //Fix", FCVAR_NONE);
  185.     cFlareLenght    =       CreateConVar("airdrop_flare_lenght"     ,   "75"        , "Lenght of smoker for flare //Fix", FCVAR_NONE);
  186.     cFlareAplha     =       CreateConVar("airdrop_flare_aplha"      ,   "255"       , "Transparency of smoke //Fix", FCVAR_NONE);
  187.     cUseString      =       CreateConVar("airdrop_open_string"      ,   "Hehe boi"  , "Open string //Fix", FCVAR_NONE);
  188.     cTimeOpen       =       CreateConVar("airdrop_open_time"        ,   "2.5"       , "Open time //Fix", FCVAR_NONE);
  189.     cCountAirdrops  =       CreateConVar("airdrop_count_airdrops"   ,   "3"         , "Count of airdrops //Fix", FCVAR_NONE);
  190.     cCountItems     =       CreateConVar("airdrop_count_items"      ,   "6"         , "Count of items from airdrops //Fix", FCVAR_NONE);
  191.     cDropType       =       CreateConVar("airdrop_type_drop"        ,   "1"         , "Type of drop //Fix", FCVAR_NONE);
  192.     cTankChance     =       CreateConVar("airdrop_tank_chance"      ,   "50"        , "Chache airdrop of tank die //Fix", FCVAR_NONE);
  193.     cVocalize       =       CreateConVar("airdrop_vocalize_chance"  ,   "40"        , "Chance of vocalize (L4D2 only) //Fix", FCVAR_NONE);
  194.     cGlowRange      =       CreateConVar("airdrop_glow_range"       ,   "500"       , "Glow range of airdrops (L4D2 only) //Fix", FCVAR_NONE);
  195.     AutoExecConfig(true, "Airdrop");
  196. }
  197.  
  198. public Action EventTank(Event event, const char[] name, bool dontbroadcast)
  199. {
  200.     if(GetRandomInt(0, 100) <= GetConVarInt(cTankChance))
  201.     {
  202.         int client = GetClientOfUserId(event.GetInt("userid"));
  203.         AirPlane(client);
  204.     }
  205. }
  206.  
  207. public void OnMapStart()
  208. {
  209.     GetCurrentMap(sMap, sizeof sMap);
  210.     PrecacheModel(MODEL_FLARE, true);
  211.     PrecacheSound(SOUND_CRACKLE, true);
  212.  
  213.     PrecacheParticle(PARTICLE_FLARE);
  214.     PrecacheParticle(PARTICLE_FUSE);
  215.    
  216.     PrecacheSound(SOUND_PASS1, true);
  217.     for (int i = 0; i < 3; i++)
  218.         PrecacheModel(gModeList[i], true);
  219.     for (int i = 0; i < MAXLIST - 1; i++)
  220.         PrecacheModel(gModelsItemsList[i], true);
  221. }
  222.  
  223. public Action CallAirdrop(int client, int args)
  224. {
  225.     AirPlane(client);
  226.     PrintToChatAll("\x04[Air] \x03%N \x04called airdrop", client);
  227. }
  228.  
  229. stock void AirPlane(int client)
  230. {
  231.     float vPos[3], vAng[3], direction;
  232.     GetEntPropVector(client, Prop_Send, "m_vecOrigin", vPos);
  233.     vPos[2] += 64;
  234.     GetEntPropVector(client, Prop_Send, "m_angRotation", vAng);
  235.     direction = vAng[1];
  236.            
  237.     float vSkybox[3];
  238.     vAng[0] = 0.0;
  239.     vAng[1] = direction;
  240.     vAng[2] = 0.0;
  241.    
  242.     GetEntPropVector(0, Prop_Data, "m_WorldMaxs", vSkybox);
  243.  
  244.     int entity = CreateEntityByName("prop_dynamic_override");
  245.     DispatchKeyValue(entity, "targetname", "ac130");
  246.     DispatchKeyValue(entity, "disableshadows", "1");
  247.     DispatchKeyValue(entity, "model", gModeList[0]);
  248.     DispatchSpawn(entity);
  249.     float height = vPos[2] + 1150.0;
  250.     if( height > vSkybox[2] - 200 )
  251.         vPos[2] = vSkybox[2] - 200;
  252.     else
  253.         vPos[2] = height;
  254.  
  255.     TeleportEntity(entity, vPos, vAng, NULL_VECTOR);
  256.     EmitSoundToAll(SOUND_PASS1, entity, SNDCHAN_AUTO, SNDLEVEL_HELICOPTER);
  257.     SetVariantString("airport_intro_flyby");
  258.     AcceptEntityInput(entity, "SetAnimation");
  259.     AcceptEntityInput(entity, "Enable");
  260.  
  261.     SetVariantString("OnUser1 !self:Kill::20.19:1");
  262.     AcceptEntityInput(entity, "AddOutput");
  263.     AcceptEntityInput(entity, "FireUser1");
  264.     CreateTimer(6.6, TimerDropAirDrop, EntIndexToEntRef(entity));
  265. }
  266.  
  267. public Action TimerDropAirDrop(Handle timer, any entity)
  268. {
  269.     entity = EntRefToEntIndex(entity);
  270.     if(entity != INVALID_ENT_REFERENCE)
  271.     {
  272.         float vPos[3];
  273.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
  274.         CreateCrates(vPos);
  275.     }
  276. }
  277.  
  278. void CreateCrates(float vPos[3])
  279. {
  280.     char sUseString[16], sTimeOpen[16];
  281.     int entity, iTrigger;
  282.     Handle hTrace;
  283.    
  284.     float vAng[3], vEndPos[3], vDistance, fTime;
  285.     vAng[0] = 89.0; vAng[1] = 0.0; vAng[2] = 0.0;
  286.    
  287.     GetConVarString(cUseString, sUseString, sizeof sUseString);
  288.     GetConVarString(cTimeOpen, sTimeOpen, sizeof sTimeOpen);
  289.    
  290.     if(strcmp(sMap, "c5m1_waterfront") == 0)
  291.         vPos[2] -= 475.0;
  292.        
  293.     for(int i = 0; i < GetConVarInt(cCountAirdrops); i++)
  294.     {
  295.         vPos[1] += GetRandomInt(-150, 150);
  296.         vPos[0] += GetRandomInt(-150, 150);
  297.         entity = CreateEntityByName("prop_physics_override");
  298.         DispatchKeyValue(entity, "targetname", "SupplyDrop");
  299.         DispatchKeyValueVector(entity, "origin", vPos);
  300.         if(IsLeft4Dead2)
  301.             SetEntityModel(entity, gModeList[1]);
  302.         else
  303.         {
  304.             DispatchKeyValue(entity, "StartGlowing", "1");
  305.             DispatchKeyValue(entity, "model", gModeList[3]);
  306.         }
  307.         DispatchSpawn(entity);
  308.        
  309.         if(GetConVarInt(cFlare))
  310.         {
  311.             vPos[2] -= 50;
  312.             hTrace = TR_TraceRayFilterEx(vPos, vAng, MASK_SHOT, RayType_Infinite, TraceDontHitSelf, entity);
  313.             GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
  314.             if(TR_DidHit(hTrace))
  315.             {
  316.                 TR_GetEndPosition(vEndPos, hTrace);
  317.                 vDistance = GetVectorDistance(vPos, vEndPos);
  318.                 fTime = vDistance / 315.0;
  319.                 CreateTimer(fTime, tToDelete, EntIndexToEntRef(entity));
  320.             }
  321.             else
  322.                 LogError("Trace did not hit anything! WTF");
  323.         }
  324.         if(IsLeft4Dead2)
  325.         {
  326.             iTrigger = CreateEntityByName("func_button_timed");
  327.             DispatchKeyValueVector(iTrigger, "origin", vPos);
  328.             DispatchKeyValue(iTrigger, "use_string", sUseString);
  329.             DispatchKeyValue(iTrigger, "use_time", sTimeOpen);
  330.             DispatchKeyValue(iTrigger, "auto_disable", "1");
  331.             DispatchSpawn(iTrigger);
  332.             ActivateEntity(iTrigger);
  333.            
  334.             SetEntPropVector(iTrigger, Prop_Send, "m_vecMins", view_as<float>({-225.0, -225.0, -225.0}));
  335.             SetEntPropVector(iTrigger, Prop_Send, "m_vecMaxs", view_as<float>({225.0, 225.0, 225.0}));
  336.             HookSingleEntityOutput(iTrigger, "OnTimeUp", OnTimeUp);
  337.             SetEntityModel(iTrigger, gModeList[2]);
  338.             SetEntityRenderMode(iTrigger, RENDER_NONE);
  339.             TeleportEntity(iTrigger, vPos, NULL_VECTOR, NULL_VECTOR);
  340.             SetVariantString("!activator");
  341.             AcceptEntityInput(iTrigger, "SetParent", entity);
  342.             char sColor[16];
  343.             Format(sColor, sizeof sColor, "255 255 255");
  344.             SetEntProp(entity, Prop_Send, "m_nGlowRange", GetConVarInt(cGlowRange));
  345.             SetEntProp(entity, Prop_Send, "m_iGlowType", 3);
  346.             SetEntProp(entity, Prop_Send, "m_glowColorOverride", GetColor(sColor));
  347.             SetEntProp(iTrigger, Prop_Data, "m_takedamage", 0, 1);
  348.             SetEntProp(entity, Prop_Data, "m_takedamage", 0, 1);
  349.             gIndexCrate[iTrigger] = EntIndexToEntRef(entity);
  350.         }
  351.         else SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage);
  352.     }
  353.     //SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage);
  354.     PrintToChatAll("\x04[Air] \x03Airdrop \x04fell in the approximate coordinates \x05%.2f %.2f %.2f", vPos[0], vPos[1], vPos[2]);
  355. }
  356.  
  357. public Action tToDelete(Handle timer, any entity)
  358. {
  359.     entity = EntRefToEntIndex(entity);
  360.     if(entity != INVALID_ENT_REFERENCE)
  361.     {
  362.         float vPos[3], vAng[3];
  363.         char sColor[12];
  364.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
  365.         GetConVarString(cColorFlare, sColor, sizeof sColor);
  366.         vPos[0] += 20.0;
  367.         vPos[2] -= 6.0;
  368.         MakeFlare(entity, vAng, vPos, sColor, sColor);
  369.     }
  370. }
  371.  
  372. public bool TraceDontHitSelf(int entity, int mask, any data)
  373. {
  374.     if(entity == data)
  375.     {
  376.         return false;
  377.     }
  378.     return true;
  379. }
  380.  
  381. public void OnTimeUp(const char[] output, int caller, int activator, float delay)
  382. {
  383.     if (activator > 0 && activator <= MaxClients && IsClientInGame(activator))
  384.     {
  385.         char sWeaponList[360], sWeaponAllowed[36][32];
  386.         GetConVarString(cWeaponList, sWeaponList, sizeof sWeaponList);
  387.         ExplodeString(sWeaponList, ";", sWeaponAllowed, sizeof(sWeaponAllowed), sizeof(sWeaponAllowed[]));
  388.         int entity = gIndexCrate[caller];
  389.         if((entity = EntRefToEntIndex(entity)) != INVALID_ENT_REFERENCE)
  390.         {
  391.             int SupplyItem;
  392.             float vPos[3], vAng[3];
  393.             AcceptEntityInput(caller, "kill");
  394.             GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
  395.             GetEntPropVector(entity, Prop_Send, "m_angRotation", vAng);
  396.             int OpenedCrate = CreateEntityByName("prop_physics_override");
  397.             DispatchKeyValueVector(OpenedCrate, "origin", vPos);
  398.             DispatchKeyValueVector(OpenedCrate, "angles", vAng);
  399.             SetEntityModel(OpenedCrate, gModeList[2]);
  400.             DispatchSpawn(OpenedCrate);
  401.             int RandomIntType = GetRandomInt(0, 24);
  402.             AcceptEntityInput(entity, "kill");
  403.             for(int i = 0; i <= GetConVarInt(cCountItems); i++)
  404.             {
  405.                 if(GetConVarInt(cDropType) != 1) SupplyItem = CreateEntityByName(gItemsList[RandomIntType]);
  406.                 else
  407.                 {
  408.                     RandomIntType = GetRandomInt(0, 25);
  409.                     SupplyItem = CreateEntityByName(gItemsList[RandomIntType]);
  410.                 }
  411.                 if(IsValidEntity(SupplyItem))
  412.                 {
  413.                     for(int v = 0; v < 26; v++)
  414.                     {
  415.                         if(strcmp(gExplodeList[RandomIntType], sWeaponAllowed[v]) == 0)
  416.                         {
  417.                             DispatchSpawn(SupplyItem);
  418.                             SetEntityModel(SupplyItem, gModelsItemsList[RandomIntType]);
  419.                             vPos[2] += 2.5;
  420.                             vAng[0] = 0.0;
  421.                             vAng[1] = 90.0;
  422.                             vAng[2] = 0.0;
  423.                             TeleportEntity(SupplyItem, vPos, vAng, NULL_VECTOR);
  424.                             if(gAmmoList[RandomIntType] != -1)
  425.                                 SetEntProp(SupplyItem, Prop_Send, "m_iExtraPrimaryAmmo", gAmmoList[RandomIntType], 4);
  426.                         }
  427.                     }
  428.                 }
  429.             }
  430.             for(int i = 0; i <= 4; i++)
  431.                 AcceptEntityInput(g_iFlares[entity][i], "kill");
  432.             for(int i = 1; i <= MaxClients; i++)
  433.                 if(IsClientInGame(i)) PrintToChat(i, "\x04[Air] \x03%N \x04open airdrop", activator);
  434.             Vocalize(activator);
  435.         }
  436.     }
  437. }
  438.  
  439. public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)  
  440. {
  441.     if(IsValidEntity(victim) && attacker > 0 && GetClientTeam(attacker) == 2)
  442.     {
  443.         float vPos[3];
  444.         char sModel[126], sWeaponList[360], sWeaponAllowed[36][32];
  445.         int SupplyItem;
  446.         GetEntPropString(victim, Prop_Data, "m_ModelName", sModel, sizeof(sModel));
  447.         GetConVarString(cWeaponList, sWeaponList, sizeof sWeaponList);
  448.         ExplodeString(sWeaponList, ";", sWeaponAllowed, sizeof(sWeaponAllowed), sizeof(sWeaponAllowed[]));
  449.         if(strcmp(sModel, gModeList[3]) == 0)
  450.         {  
  451.             AcceptEntityInput(victim, "break");
  452.            
  453.             GetEntPropVector(victim, Prop_Send, "m_vecOrigin", vPos);
  454.             for(int v = 0; v < GetConVarInt(cCountItems); v++)
  455.             {
  456.                 int iInt = GetRandomInt(0, 7);
  457.                 if(GetConVarInt(cDropType) == 1) SupplyItem = CreateEntityByName(gItemsListL4D1[GetRandomInt(0, 7)]);
  458.                 else SupplyItem = CreateEntityByName(gItemsListL4D1[iInt]);
  459.                 for(int i = 0; i < 26; i++)
  460.                 {
  461.                     if(strcmp(gItemsListL4D1[iInt], sWeaponAllowed[v]) == 0)
  462.                     {
  463.                         DispatchSpawn(SupplyItem);
  464.                         vPos[2] += 5.0;
  465.                         TeleportEntity(SupplyItem, vPos, NULL_VECTOR, NULL_VECTOR);
  466.                     }
  467.                 }
  468.             }
  469.         }
  470.     }
  471. }
  472.  
  473. int GetColor(char[] sTemp)
  474. {
  475.     if( StrEqual(sTemp, "") )
  476.         return 0;
  477.  
  478.     char sColors[3][4];
  479.     int color = ExplodeString(sTemp, " ", sColors, 3, 4);
  480.  
  481.     if( color != 3 )
  482.         return 0;
  483.  
  484.     color = StringToInt(sColors[0]);
  485.     color += 256 * StringToInt(sColors[1]);
  486.     color += 65536 * StringToInt(sColors[2]);
  487.  
  488.     return color;
  489. }
  490.  
  491. //Thanks to Silvers...
  492. int MakeFlare(int client, float vAngles[3], float vOrigin[3], const char[] sColorL, const char[] sColorS)
  493. {
  494.     int entity;
  495.    
  496.     entity = CreateEntityByName("prop_dynamic");
  497.  
  498.     SetEntityModel(entity, MODEL_FLARE);
  499.     DispatchSpawn(entity);
  500.     TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
  501.    
  502.     g_iFlares[client][0] = entity;
  503.     vOrigin[2] += 15.0;
  504.     entity = MakeLightDynamic(vOrigin, view_as<float>({ 90.0, 0.0, 0.0 }), sColorL, 255);
  505.     vOrigin[2] -= 15.0;
  506.    
  507.     g_iFlares[client][1] = entity;
  508.     // Position particles / smoke
  509.     entity = 0;
  510.     vAngles[1] = GetRandomFloat(1.0, 360.0);
  511.     vAngles[0] = -80.0;
  512.     vOrigin[0] += (1.0 * (Cosine(DegToRad(vAngles[1]))));
  513.     vOrigin[1] += (1.5 * (Sine(DegToRad(vAngles[1]))));
  514.     vOrigin[2] += 1.0;
  515.  
  516.     // Flare particles
  517.     entity = DisplayParticle(PARTICLE_FLARE, vOrigin, vAngles);
  518.     g_iFlares[client][2] = entity;
  519.    
  520.     // Fuse particles
  521.     entity = DisplayParticle(PARTICLE_FUSE, vOrigin, vAngles);
  522.     g_iFlares[client][3] = entity;
  523.  
  524.     // Smoke
  525.     vAngles[0] = -85.0;
  526.     entity = MakeEnvSteam(vOrigin, vAngles, sColorS, GetConVarInt(cFlareAplha), GetConVarInt(cFlareLenght));
  527.     g_iFlares[client][4] = entity;
  528.  
  529.     PlaySound(g_iFlares[entity][0]);
  530. }
  531.  
  532. //Thanks to Silvers...
  533. int DisplayParticle(const char[] sParticle, const float vPos[3], const float vAng[3])
  534. {
  535.     int entity = CreateEntityByName("info_particle_system");
  536.     if( entity != -1 )
  537.     {
  538.         DispatchKeyValue(entity, "effect_name", sParticle);
  539.         DispatchSpawn(entity);
  540.         ActivateEntity(entity);
  541.         AcceptEntityInput(entity, "start");
  542.         TeleportEntity(entity, vPos, vAng, NULL_VECTOR);
  543.         return entity;
  544.     }
  545.     return 0;
  546. }
  547.  
  548. //Thanks to Silvers...
  549. int MakeEnvSteam(const float vOrigin[3], const float vAngles[3], const char[] sColor, int iAlpha, int iLength)
  550. {
  551.     int entity = CreateEntityByName("env_steam");
  552.     char sTemp[5];
  553.     DispatchKeyValue(entity, "SpawnFlags", "1");
  554.     DispatchKeyValue(entity, "rendercolor", sColor);
  555.     DispatchKeyValue(entity, "SpreadSpeed", "1");
  556.     DispatchKeyValue(entity, "Speed", "15");
  557.     DispatchKeyValue(entity, "StartSize", "1");
  558.     DispatchKeyValue(entity, "EndSize", "3");
  559.     DispatchKeyValue(entity, "Rate", "10");
  560.     IntToString(iLength, sTemp, sizeof(sTemp));
  561.     DispatchKeyValue(entity, "JetLength", sTemp);
  562.     IntToString(iAlpha, sTemp, sizeof(sTemp));
  563.     DispatchKeyValue(entity, "renderamt", sTemp);
  564.     DispatchKeyValue(entity, "InitialState", "1");
  565.     DispatchSpawn(entity);
  566.     AcceptEntityInput(entity, "TurnOn");
  567.     TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
  568.     return entity;
  569. }
  570.  
  571. void PlaySound(int entity)
  572. {
  573.     EmitSoundToAll(SOUND_CRACKLE, entity, SNDCHAN_AUTO, SNDLEVEL_DISHWASHER, SND_SHOULDPAUSE, SNDVOL_NORMAL, SNDPITCH_HIGH, -1, NULL_VECTOR, NULL_VECTOR);
  574. }
  575.  
  576. int MakeLightDynamic(const float vOrigin[3], const float vAngles[3], const char[] sColor, int iDist)
  577. {
  578.     int entity = CreateEntityByName("light_dynamic");
  579.     char sTemp[16];
  580.     Format(sTemp, sizeof(sTemp), "6");
  581.     DispatchKeyValue(entity, "style", sTemp);
  582.     Format(sTemp, sizeof(sTemp), "%s 255", sColor);
  583.     DispatchKeyValue(entity, "_light", sTemp);
  584.     DispatchKeyValue(entity, "brightness", "1");
  585.     DispatchKeyValueFloat(entity, "spotlight_radius", 32.0);
  586.     DispatchKeyValueFloat(entity, "distance", float(iDist));
  587.     DispatchSpawn(entity);
  588.     AcceptEntityInput(entity, "TurnOn");
  589.     TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
  590.     return entity;
  591. }
  592.  
  593. void PrecacheParticle(const char[] ParticleName)
  594. {
  595.     int entity = CreateEntityByName("info_particle_system");
  596.     DispatchKeyValue(entity, "effect_name", ParticleName);
  597.     DispatchSpawn(entity);
  598.     ActivateEntity(entity);
  599.     AcceptEntityInput(entity, "start");
  600.     SetVariantString("OnUser1 !self:Kill::0.1:-1");
  601.     AcceptEntityInput(entity, "AddOutput");
  602.     AcceptEntityInput(entity, "FireUser1");
  603. }
  604. /*
  605.     "left4dead2_dlc1/scenes/Coach/dlc1_c6m1_alarmdoor01.vcd",
  606.     "left4dead2_dlc1/scenes/Coach/dlc1_golfclub07.vcd",
  607.     "scenes/Coach/thanks02.vcd",
  608.     "scenes/Coach/reactionnegative02.vcd",
  609.     "scenes/Coach/no02.vcd",
  610.     "left4dead2_dlc1/scenes/Gambler/dlc1_c6m1_alarmdoor02.vcd",
  611.     "left4dead2_dlc1/scenes/Gambler/dlc1_c6m1_alarmdoor01.vcd",
  612.     "left4dead2_dlc1/scenes/Gambler/dlc1_c6m2_phase2jumpinwater02.vcd",
  613.     "left4dead2_dlc1/scenes/Mechanic/dlc1_c6m3_finalebridgerun02.vcd",
  614. */ // Dont use it!
  615.  
  616. //Thanks to Silvers
  617. static const char g_sVocalize[][] =
  618. {
  619.     "scenes/Coach/dlc1_c6m1_alarmdoor01.vcd",
  620.     "scenes/Coach/dlc1_golfclub07.vcd",
  621.     "scenes/Coach/thanks02.vcd",
  622.     "scenes/Coach/reactionnegative02.vcd",
  623.     "scenes/Coach/no02.vcd",
  624.     "scenes/Gambler/dlc1_c6m1_alarmdoor02.vcd",
  625.     "scenes/Gambler/dlc1_c6m1_alarmdoor01.vcd",
  626.     "scenes/Gambler/dlc1_c6m2_phase2jumpinwater02.vcd",
  627.     "scenes/Mechanic/dlc1_c6m3_finalebridgerun02.vcd",
  628.     "scenes/Mechanic/dlc1_m6007.vcd",
  629.     "scenes/Producer/heardspecialc104.vcd",
  630.     "scenes/Producer/hurrah01.vcd",
  631.     /*
  632.     "left4dead2_dlc1/scenes/teengirl/laughter01.vcd",
  633.     "left4dead2_dlc1/scenes/teengirl/nicejob05.vcd",
  634.     "left4dead2_dlc1/scenes/teengirl/playersuggesthealthspecific04.vcd.vcd",
  635.     "left4dead2_dlc2/scenes/biker/dlc2birdhate01.vcd",
  636.     "left4dead2_dlc3/scenes/biker/c6dlc3otherboats09.vcd",
  637.     "scenes/biker/namebill02.vcd", 
  638.     "left4dead2_dlc1/scenes/biker/dlc1_killfinaltank01.vcd",
  639.     "left4dead2_dlc2/manager/dlc2forlease01.vcd"
  640.     */
  641. };
  642.  
  643. //Thanks to Silvers
  644. void Vocalize(int client)
  645. {
  646.     if(GetRandomInt(1, 100) > GetConVarInt(cVocalize))
  647.         return;
  648.  
  649.     char sTemp[64];
  650.     GetEntPropString(client, Prop_Data, "m_ModelName", sTemp, 64);
  651.  
  652.     int random;
  653.     if( sTemp[26] == 'c' )                          // c = Coach
  654.         random = GetRandomInt(0, 4);
  655.     else if( sTemp[26] == 'g' )                     // g = Gambler
  656.         random = GetRandomInt(5, 7);
  657.     else if( sTemp[26] == 'm' && sTemp[27] == 'e' ) // me = Mechanic
  658.         random = GetRandomInt(8, 9);
  659.     else if( sTemp[26] == 'p' )                     // p = Producer
  660.         random = GetRandomInt(10, 11);
  661.     else if(StrContains(sTemp, "teengirl") > 0)
  662.         random = GetRandomInt(12, 14);
  663.     else if(StrContains(sTemp, "biker") > 0)
  664.         random = GetRandomInt(15, 18);
  665.     else if(StrContains(sTemp, "manager") > 0)
  666.         random = 19;
  667.     else
  668.         return;
  669.  
  670.     int entity = CreateEntityByName("instanced_scripted_scene");
  671.     DispatchKeyValue(entity, "SceneFile", g_sVocalize[random]);
  672.     DispatchSpawn(entity);
  673.     SetEntPropEnt(entity, Prop_Data, "m_hOwner", client);
  674.     ActivateEntity(entity);
  675.     AcceptEntityInput(entity, "Start", client, client);
  676. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement