Advertisement
FlacoBey

Untitled

Jun 28th, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 18.90 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;
  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 gModelsItemsList[MAXLIST][] =
  82. {
  83.     "models/w_models/weapons/w_autoshot_m4super.mdl", //0
  84.     "models/w_models/weapons/w_eq_Medkit.mdl", //1
  85.     "models/w_models/weapons/w_eq_pipebomb.mdl", //2
  86.     "models/w_models/weapons/w_eq_molotov.mdl", //3
  87.     "models/w_models/weapons/w_rifle_m16a2.mdl", //4
  88.     "models/w_models/weapons/w_sniper_mini14.mdl", //5
  89.     "models/w_models/weapons/w_eq_painpills.mdl", //6
  90.     "models/w_models/weapons/w_pistol_a.mdl", //7
  91.     "models/w_models/weapons/w_eq_adrenaline.mdl", //8
  92.     "models/w_models/weapons/w_smg_mp5.mdl", //9
  93.     "models/w_models/weapons/w_smg_uzi.mdl", //10
  94.     "models/w_models/weapons/w_smg_a.mdl", //11
  95.     "models/w_models/weapons/w_shotgun.mdl", //12
  96.     "models/w_models/weapons/w_pumpshotgun_a.mdl", //13
  97.     "models/w_models/weapons/w_m60.mdl", //14
  98.     "models/w_models/weapons/w_shotgun_spas.mdl", //15
  99.     "models/w_models/weapons/w_sniper_military.mdl", //16
  100.     "models/w_models/weapons/w_rifle_ak47.mdl", //17
  101.     "models/w_models/weapons/w_desert_rifle.mdl", //18
  102.     "models/w_models/weapons/w_sniper_awp.mdl", //19
  103.     "models/w_models/weapons/w_rifle_sg552.mdl", //20
  104.     "models/w_models/weapons/w_sniper_scout.mdl", //21
  105.     "models/w_models/weapons/w_grenade_launcher.mdl", //22
  106.     "models/w_models/weapons/w_desert_eagle.mdl", //23
  107.     "models/w_models/weapons/w_eq_bile_flask.mdl", //24
  108.     "models/w_models/weapons/w_eq_defibrillator.mdl" //25
  109. };
  110.  
  111. static int gAmmoList[MAXLIST] =
  112. {
  113.     90,
  114.     -1,
  115.     -1,
  116.     -1,
  117.     360,
  118.     150,
  119.     -1,
  120.     -1,
  121.     -1,
  122.     650,
  123.     650,
  124.     650,
  125.     56,
  126.     56,
  127.     -1,
  128.     90,
  129.     180,
  130.     360,
  131.     360,
  132.     180,
  133.     360,
  134.     180,
  135.     30,
  136.     -1,
  137.     -1,
  138.     -1
  139. };
  140.  
  141. public void OnPluginStart()
  142. {
  143.     char sEngine[24];
  144.     GetGameFolderName(sEngine, sizeof(sEngine));
  145.     if (StrEqual(sEngine, "left4dead2", false))
  146.         IsLeft4Dead2 = true;
  147.    
  148.     RegAdminCmd("sm_ac130", CallAirdrop, ADMFLAG_ROOT);
  149.     //HookEvent("tank_spawn", EventTank);
  150.     HookEvent("tank_killed", EventTank);
  151.    
  152.     cWeaponList     =       CreateConVar("airdrop_weapons_list",    "weapon_rifle;weapon_autoshotgun;weapon_hunting_rifle;weapon_smg;weapon_pumpshotgun;weapon_pistol;weapon_molotov;weapon_pipe_bomb;weapon_first_aid_kit;weapon_pain_pills;weapon_shotgun_chrome;weapon_rifle_desert;weapon_grenade_launcher;weapon_rifle_m60;weapon_rifle_ak47;weapon_rifle_sg552;weapon_shotgun_spas;weapon_smg_silenced;weapon_smg_mp5;weapon_sniper_awp;weapon_sniper_military;weapon_sniper_scout;weapon_chainsaw;weapon_pistol_magnum;weapon_vomitjar;weapon_defibrillator;weapon_upgradepack_explosive;weapon_upgradepack_incendiary;weapon_adrenaline", "Будет ли рядом флаер с коробкой", FCVAR_NONE);
  153.     cFlare          =       CreateConVar("airdrop_flare",   "1", "Будет ли рядом флаер с коробкой", FCVAR_NONE);
  154.     cColorFlare     =       CreateConVar("airdrop_flare_color",     "25 25 255", "Цвет флаера", FCVAR_NONE);
  155.     cFlareLenght    =       CreateConVar("airdrop_flare_lenght",    "275", "Длина дыма флаера", FCVAR_NONE);
  156.     cFlareAplha     =       CreateConVar("airdrop_flare_aplha",     "255", "Прозрачность дыма", FCVAR_NONE);
  157.     cUseString      =       CreateConVar("airdrop_open_string",     "Hehe boi", "Что будет написано при открытии ящика", FCVAR_NONE);
  158.     cTimeOpen       =       CreateConVar("airdrop_open_time",       "2.5", "Время открытия", FCVAR_NONE);
  159.     cCountAirdrops  =       CreateConVar("airdrop_count_airdrops",  "3", "Кол-во ящиков", FCVAR_NONE);
  160.     cCountItems     =       CreateConVar("airdrop_count_items",     "6", "Кол-во предметов из ящиков", FCVAR_NONE);
  161.     cDropType       =       CreateConVar("airdrop_type_drop",       "1", "Разные предметы будут выпадать либо нет(Ставить 1, только если квар \"airdrop count items\" > 1)", FCVAR_NONE);
  162.     cTankChance     =       CreateConVar("airdrop_tank_chance",     "50", "Шанс аирдропа при смерти танка", FCVAR_NONE);
  163.     AutoExecConfig(true, "Airdrop");
  164. }
  165.  
  166. public Action EventTank(Event event, const char[] name, bool dontbroadcast)
  167. {
  168.     if(GetRandomInt(0, 100) <= GetConVarInt(cTankChance))
  169.     {
  170.         int client = GetClientOfUserId(event.GetInt("userid"));
  171.         AirPlane(client);
  172.     }
  173. }
  174.  
  175. public void OnMapStart()
  176. {
  177.     GetCurrentMap(sMap, sizeof sMap);
  178.     PrecacheModel(MODEL_FLARE, true);
  179.     PrecacheSound(SOUND_CRACKLE, true);
  180.  
  181.     PrecacheParticle(PARTICLE_FLARE);
  182.     PrecacheParticle(PARTICLE_FUSE);
  183.    
  184.     PrecacheSound(SOUND_PASS1, true);
  185.     for (int i = 0; i < 3; i++)
  186.         PrecacheModel(gModeList[i], true);
  187.     for (int i = 0; i < MAXLIST - 1; i++)
  188.         PrecacheModel(gModelsItemsList[i], true);
  189. }
  190.  
  191. public Action CallAirdrop(int client, int args)
  192. {
  193.     AirPlane(client);
  194.     PrintToChatAll("\x04[Air] \x03%N \x04вызвал аирдроп", client);
  195. }
  196.  
  197. stock void AirPlane(int client)
  198. {
  199.     float vPos[3], vAng[3], direction;
  200.     GetEntPropVector(client, Prop_Send, "m_vecOrigin", vPos);
  201.     vPos[2] += 64;
  202.     GetEntPropVector(client, Prop_Send, "m_angRotation", vAng);
  203.     direction = vAng[1];
  204.            
  205.     float vSkybox[3];
  206.     vAng[0] = 0.0;
  207.     vAng[1] = direction;
  208.     vAng[2] = 0.0;
  209.    
  210.     GetEntPropVector(0, Prop_Data, "m_WorldMaxs", vSkybox);
  211.  
  212.     int entity = CreateEntityByName("prop_dynamic_override");
  213.     DispatchKeyValue(entity, "targetname", "ac130");
  214.     DispatchKeyValue(entity, "disableshadows", "1");
  215.     DispatchKeyValue(entity, "model", gModeList[0]);
  216.     DispatchSpawn(entity);
  217.     float height = vPos[2] + 1150.0;
  218.     if( height > vSkybox[2] - 200 )
  219.         vPos[2] = vSkybox[2] - 200;
  220.     else
  221.         vPos[2] = height;
  222.  
  223.     TeleportEntity(entity, vPos, vAng, NULL_VECTOR);
  224.     EmitSoundToAll(SOUND_PASS1, entity, SNDCHAN_AUTO, SNDLEVEL_HELICOPTER);
  225.     SetVariantString("airport_intro_flyby");
  226.     AcceptEntityInput(entity, "SetAnimation");
  227.     AcceptEntityInput(entity, "Enable");
  228.  
  229.     SetVariantString("OnUser1 !self:Kill::20.19:1");
  230.     AcceptEntityInput(entity, "AddOutput");
  231.     AcceptEntityInput(entity, "FireUser1");
  232.     CreateTimer(6.3, TimerDropAirDrop, EntIndexToEntRef(entity));
  233. }
  234.  
  235. public Action TimerDropAirDrop(Handle timer, any entity)
  236. {
  237.     entity = EntRefToEntIndex(entity);
  238.     if(entity != INVALID_ENT_REFERENCE)
  239.     {
  240.         float vPos[3];
  241.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
  242.         CreateCrates(vPos);
  243.     }
  244. }
  245.  
  246. void CreateCrates(float vPos[3])
  247. {
  248.     char sUseString[16], sTimeOpen[16];
  249.     int entity, iTrigger;
  250.     Handle hTrace;
  251.    
  252.     float vAng[3], vEndPos[3], vDistance, fTime;
  253.     vAng[0] = 89.0; vAng[1] = 0.0; vAng[2] = 0.0;
  254.    
  255.     GetConVarString(cUseString, sUseString, sizeof sUseString);
  256.     GetConVarString(cTimeOpen, sTimeOpen, sizeof sTimeOpen);
  257.    
  258.     if(strcmp(sMap, "c5m1_waterfront") == 0)
  259.         vPos[2] -= 475.0;
  260.        
  261.     for(int i = 0; i < GetConVarInt(cCountAirdrops); i++)
  262.     {
  263.         vPos[1] += GetRandomInt(-150, 150);
  264.         vPos[0] += GetRandomInt(-150, 150);
  265.         entity = CreateEntityByName("prop_physics_override");
  266.         DispatchKeyValue(entity, "targetname", "SupplyDrop");
  267.         DispatchKeyValueVector(entity, "origin", vPos);
  268.         if(IsLeft4Dead2)
  269.             SetEntityModel(entity, gModeList[1]);
  270.         else
  271.         {
  272.             DispatchKeyValue(entity, "StartGlowing", "1");
  273.             DispatchKeyValue(entity, "model", gModeList[3]);
  274.         }
  275.         DispatchSpawn(entity);
  276.        
  277.         if(GetConVarInt(cFlare))
  278.         {
  279.             vPos[2] -= 50;
  280.             hTrace = TR_TraceRayFilterEx(vPos, vAng, MASK_SHOT, RayType_Infinite, TraceDontHitSelf, entity);
  281.             GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
  282.             if(TR_DidHit(hTrace))
  283.             {
  284.                 TR_GetEndPosition(vEndPos, hTrace);
  285.                 vDistance = GetVectorDistance(vPos, vEndPos);
  286.                 fTime = vDistance / 315.0;
  287.                 CreateTimer(fTime, tToDelete, EntIndexToEntRef(entity));
  288.             }
  289.             else
  290.                 LogError("Trace did not hit anything! WTF");
  291.         }
  292.         if(IsLeft4Dead2)
  293.         {
  294.             iTrigger = CreateEntityByName("func_button_timed");
  295.             DispatchKeyValueVector(iTrigger, "origin", vPos);
  296.             DispatchKeyValue(iTrigger, "use_string", sUseString);
  297.             DispatchKeyValue(iTrigger, "use_time", sTimeOpen);
  298.             DispatchKeyValue(iTrigger, "auto_disable", "1");
  299.             DispatchSpawn(iTrigger);
  300.             ActivateEntity(iTrigger);
  301.            
  302.             SetEntPropVector(iTrigger, Prop_Send, "m_vecMins", view_as<float>({-225.0, -225.0, -225.0}));
  303.             SetEntPropVector(iTrigger, Prop_Send, "m_vecMaxs", view_as<float>({225.0, 225.0, 225.0}));
  304.             HookSingleEntityOutput(iTrigger, "OnTimeUp", OnTimeUp);
  305.             SetEntityModel(iTrigger, gModeList[2]);
  306.             SetEntityRenderMode(iTrigger, RENDER_NONE);
  307.             vPos[2] += 25;
  308.             TeleportEntity(iTrigger, vPos, NULL_VECTOR, NULL_VECTOR);
  309.             SetVariantString("!activator");
  310.             AcceptEntityInput(iTrigger, "SetParent", entity);
  311.             char sColor[16];
  312.             Format(sColor, sizeof sColor, "255 255 255");
  313.             SetEntProp(entity, Prop_Send, "m_nGlowRange", 500);
  314.             SetEntProp(entity, Prop_Send, "m_iGlowType", 3);
  315.             SetEntProp(entity, Prop_Send, "m_glowColorOverride", GetColor(sColor));
  316.             SetEntProp(iTrigger, Prop_Data, "m_takedamage", 0, 1);
  317.             SetEntProp(entity, Prop_Data, "m_takedamage", 0, 1);
  318.             gIndexCrate[iTrigger] = EntIndexToEntRef(entity);
  319.         }
  320.         else SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage);
  321.     }
  322.     //SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage);
  323.     PrintToChatAll("\x04[Air] \x03Аирдроп(ы) \x04упал(и) в примерных координатах \x05%.2f %.2f %.2f", vPos[0], vPos[1], vPos[2]);
  324. }
  325.  
  326. public Action tToDelete(Handle timer, any entity)
  327. {
  328.     entity = EntRefToEntIndex(entity);
  329.     if(entity != INVALID_ENT_REFERENCE)
  330.     {
  331.         float vPos[3], vAng[3];
  332.         char sColor[12];
  333.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
  334.         GetConVarString(cColorFlare, sColor, sizeof sColor);
  335.         vPos[0] += 20.0;
  336.         vPos[2] -= 6.0;
  337.         MakeFlare(entity, vAng, vPos, sColor, sColor);
  338.     }
  339. }
  340.  
  341. public bool TraceDontHitSelf(int entity, int mask, any data)
  342. {
  343.     if(entity == data)
  344.     {
  345.         return false;
  346.     }
  347.     return true;
  348. }
  349.  
  350. public void OnTimeUp(const char[] output, int caller, int activator, float delay)
  351. {
  352.     if (activator > 0 && activator <= MaxClients && IsClientInGame(activator))
  353.     {
  354.         char sWeaponList[90], sWeaponAllowed[36][36];
  355.         GetConVarString(cWeaponList, sWeaponList, sizeof sWeaponList);
  356.         ExplodeString(sWeaponList, ";", sWeaponAllowed, sizeof(sWeaponAllowed), sizeof(sWeaponAllowed[]));
  357.         PrintToChatAll("%s", sWeaponAllowed[1][sizeof(sWeaponAllowed[]) - 1]);
  358.         int entity = gIndexCrate[caller];
  359.         if((entity = EntRefToEntIndex(entity)) != INVALID_ENT_REFERENCE)
  360.         {
  361.             int SupplyItem;
  362.             float vPos[3], vAng[3];
  363.             AcceptEntityInput(caller, "kill");
  364.             GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
  365.             GetEntPropVector(entity, Prop_Send, "m_angRotation", vAng);
  366.             int OpenedCrate = CreateEntityByName("prop_physics_override");
  367.             DispatchKeyValueVector(OpenedCrate, "origin", vPos);
  368.             DispatchKeyValueVector(OpenedCrate, "angles", vAng);
  369.             SetEntityModel(OpenedCrate, gModeList[2]);
  370.             DispatchSpawn(OpenedCrate);
  371.             int RandomIntType = GetRandomInt(0, 24);
  372.             AcceptEntityInput(entity, "kill");
  373.             for(int i = 0; i <= GetConVarInt(cCountItems); i++)
  374.             {
  375.                 if(GetConVarInt(cDropType) != 1) SupplyItem = CreateEntityByName(gItemsList[RandomIntType]);
  376.                 else
  377.                 {
  378.                     if(IsLeft4Dead2) RandomIntType = GetRandomInt(0, 24);
  379.                     else RandomIntType = GetRandomInt(0, 8);
  380.                     SupplyItem = CreateEntityByName(gItemsList[RandomIntType]);
  381.                 }
  382.                 if(IsValidEntity(SupplyItem))
  383.                 {
  384.                     for(int v = 0; v < 36; v++)
  385.                     {
  386.                         PrintToChatAll("%s", sWeaponAllowed[v][sizeof(sWeaponAllowed[]) - 1]);
  387.                         if(strcmp(gItemsList[i], sWeaponAllowed[v][sizeof(sWeaponAllowed[]) - 1]) == 0)
  388.                         {
  389.                            
  390.                             DispatchSpawn(SupplyItem);
  391.                             SetEntityModel(SupplyItem, gModelsItemsList[RandomIntType]);
  392.                             vPos[2] += 2.5;
  393.                             vAng[0] = 0.0;
  394.                             vAng[1] = 90.0;
  395.                             vAng[2] = 0.0;
  396.                             TeleportEntity(SupplyItem, vPos, vAng, NULL_VECTOR);
  397.                             if(gAmmoList[RandomIntType] != -1)
  398.                                 SetEntProp(SupplyItem, Prop_Send, "m_iExtraPrimaryAmmo", gAmmoList[RandomIntType], 4);
  399.                         }
  400.                     }
  401.                 }
  402.             }
  403.             for(int i = 0; i <= 4; i++)
  404.                 AcceptEntityInput(g_iFlares[entity][i], "kill");
  405.             PrintToChatAll("\x04[Air] \x03%N \x04открыл аирдроп", activator);
  406.         }
  407.     }
  408. }
  409.  
  410. public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)  
  411. {
  412.     if(IsValidEntity(victim) && attacker > 0 && GetClientTeam(attacker) == 2)
  413.     {
  414.         float vPos[3];
  415.         char sModel[126];
  416.         int SupplyItem;
  417.         GetEntPropString(victim, Prop_Data, "m_ModelName", sModel, sizeof(sModel));
  418.         if(strcmp(sModel, gModeList[3]) == 0)
  419.         {  
  420.             AcceptEntityInput(victim, "break");
  421.            
  422.             GetEntPropVector(victim, Prop_Send, "m_vecOrigin", vPos);
  423.             for(int v = 0; v < GetConVarInt(cCountItems); v++)
  424.             {
  425.                 int iInt = GetRandomInt(0, 7);
  426.                 if(GetConVarInt(cDropType) == 1) SupplyItem = CreateEntityByName(gItemsListL4D1[GetRandomInt(0, 7)]);
  427.                 else CreateEntityByName(gItemsListL4D1[iInt]);
  428.                 DispatchSpawn(SupplyItem);
  429.                 vPos[2] += 5.0;
  430.                 TeleportEntity(SupplyItem, vPos, NULL_VECTOR, NULL_VECTOR);
  431.             }
  432.             PrintToChatAll("\x04[Air] \x03%N \x04вскрыл аирдроп", attacker);
  433.         }
  434.     }
  435. }
  436.  
  437. int GetColor(char[] sTemp)
  438. {
  439.     if( StrEqual(sTemp, "") )
  440.         return 0;
  441.  
  442.     char sColors[3][4];
  443.     int color = ExplodeString(sTemp, " ", sColors, 3, 4);
  444.  
  445.     if( color != 3 )
  446.         return 0;
  447.  
  448.     color = StringToInt(sColors[0]);
  449.     color += 256 * StringToInt(sColors[1]);
  450.     color += 65536 * StringToInt(sColors[2]);
  451.  
  452.     return color;
  453. }
  454.  
  455. //Thanks to Silvers...
  456. int MakeFlare(int client, float vAngles[3], float vOrigin[3], const char[] sColorL, const char[] sColorS)
  457. {
  458.     int entity;
  459.    
  460.     entity = CreateEntityByName("prop_dynamic");
  461.  
  462.     SetEntityModel(entity, MODEL_FLARE);
  463.     DispatchSpawn(entity);
  464.     TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
  465.    
  466.     g_iFlares[client][0] = entity;
  467.     vOrigin[2] += 15.0;
  468.     entity = MakeLightDynamic(vOrigin, view_as<float>({ 90.0, 0.0, 0.0 }), sColorL, 255);
  469.     vOrigin[2] -= 15.0;
  470.    
  471.     g_iFlares[client][1] = entity;
  472.     // Position particles / smoke
  473.     entity = 0;
  474.     vAngles[1] = GetRandomFloat(1.0, 360.0);
  475.     vAngles[0] = -80.0;
  476.     vOrigin[0] += (1.0 * (Cosine(DegToRad(vAngles[1]))));
  477.     vOrigin[1] += (1.5 * (Sine(DegToRad(vAngles[1]))));
  478.     vOrigin[2] += 1.0;
  479.  
  480.     // Flare particles
  481.     entity = DisplayParticle(PARTICLE_FLARE, vOrigin, vAngles);
  482.     g_iFlares[client][2] = entity;
  483.    
  484.     // Fuse particles
  485.     entity = DisplayParticle(PARTICLE_FUSE, vOrigin, vAngles);
  486.     g_iFlares[client][3] = entity;
  487.  
  488.     // Smoke
  489.     vAngles[0] = -85.0;
  490.     entity = MakeEnvSteam(vOrigin, vAngles, sColorS, GetConVarInt(cFlareAplha), GetConVarInt(cFlareLenght));
  491.     g_iFlares[client][4] = entity;
  492.  
  493.     PlaySound(g_iFlares[entity][0]);
  494. }
  495.  
  496. //Thanks to Silvers...
  497. int DisplayParticle(const char[] sParticle, const float vPos[3], const float vAng[3])
  498. {
  499.     int entity = CreateEntityByName("info_particle_system");
  500.     if( entity != -1 )
  501.     {
  502.         DispatchKeyValue(entity, "effect_name", sParticle);
  503.         DispatchSpawn(entity);
  504.         ActivateEntity(entity);
  505.         AcceptEntityInput(entity, "start");
  506.         TeleportEntity(entity, vPos, vAng, NULL_VECTOR);
  507.         return entity;
  508.     }
  509.     return 0;
  510. }
  511.  
  512. //Thanks to Silvers...
  513. int MakeEnvSteam(const float vOrigin[3], const float vAngles[3], const char[] sColor, int iAlpha, int iLength)
  514. {
  515.     int entity = CreateEntityByName("env_steam");
  516.     char sTemp[5];
  517.     DispatchKeyValue(entity, "SpawnFlags", "1");
  518.     DispatchKeyValue(entity, "rendercolor", sColor);
  519.     DispatchKeyValue(entity, "SpreadSpeed", "1");
  520.     DispatchKeyValue(entity, "Speed", "15");
  521.     DispatchKeyValue(entity, "StartSize", "1");
  522.     DispatchKeyValue(entity, "EndSize", "3");
  523.     DispatchKeyValue(entity, "Rate", "10");
  524.     IntToString(iLength, sTemp, sizeof(sTemp));
  525.     DispatchKeyValue(entity, "JetLength", sTemp);
  526.     IntToString(iAlpha, sTemp, sizeof(sTemp));
  527.     DispatchKeyValue(entity, "renderamt", sTemp);
  528.     DispatchKeyValue(entity, "InitialState", "1");
  529.     DispatchSpawn(entity);
  530.     AcceptEntityInput(entity, "TurnOn");
  531.     TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
  532.     return entity;
  533. }
  534.  
  535. void PlaySound(int entity)
  536. {
  537.     EmitSoundToAll(SOUND_CRACKLE, entity, SNDCHAN_AUTO, SNDLEVEL_DISHWASHER, SND_SHOULDPAUSE, SNDVOL_NORMAL, SNDPITCH_HIGH, -1, NULL_VECTOR, NULL_VECTOR);
  538. }
  539.  
  540. int MakeLightDynamic(const float vOrigin[3], const float vAngles[3], const char[] sColor, int iDist)
  541. {
  542.     int entity = CreateEntityByName("light_dynamic");
  543.     char sTemp[16];
  544.     Format(sTemp, sizeof(sTemp), "6");
  545.     DispatchKeyValue(entity, "style", sTemp);
  546.     Format(sTemp, sizeof(sTemp), "%s 255", sColor);
  547.     DispatchKeyValue(entity, "_light", sTemp);
  548.     DispatchKeyValue(entity, "brightness", "1");
  549.     DispatchKeyValueFloat(entity, "spotlight_radius", 32.0);
  550.     DispatchKeyValueFloat(entity, "distance", float(iDist));
  551.     DispatchSpawn(entity);
  552.     AcceptEntityInput(entity, "TurnOn");
  553.     TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
  554.     return entity;
  555. }
  556.  
  557. void PrecacheParticle(const char[] ParticleName)
  558. {
  559.     int entity = CreateEntityByName("info_particle_system");
  560.     DispatchKeyValue(entity, "effect_name", ParticleName);
  561.     DispatchSpawn(entity);
  562.     ActivateEntity(entity);
  563.     AcceptEntityInput(entity, "start");
  564.     SetVariantString("OnUser1 !self:Kill::0.1:-1");
  565.     AcceptEntityInput(entity, "AddOutput");
  566.     AcceptEntityInput(entity, "FireUser1");
  567. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement