Advertisement
FlacoBey

Untitled

Jul 3rd, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 23.95 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. #define CONFIG_CHANCE       "data/weapon_chances.cfg"
  10.  
  11. #define PARTICLE_FLARE      "flare_burning"
  12. #define PARTICLE_FUSE       "weapon_pipebomb_fuse"
  13. #define SOUND_CRACKLE       "ambient/fire/fire_small_loop2.wav"
  14. #define MODEL_FLARE         "models/props_lighting/light_flares.mdl"
  15.  
  16. #define MAXLIST 26
  17. #define MAXENTITIES 128
  18.  
  19. int gIndexCrate[2048+1], g_iFlares[2048+1][5], g_iParachute[2048+1];
  20. ConVar  cTankChance, cCountAirdrops, cTimeOpen, cUseString, cColorFlare, cFlare,
  21.         cFlareLenght, cFlareAplha, cWeaponList, cGlowRange, cVocalize, cCustomModel, cParachuteSpeed,
  22.         cMessages;
  23. bool IsLeft4Dead2, gFlares[2048+1];
  24. Handle hTimer[2048];
  25.  
  26. public Plugin myinfo =
  27. {
  28.     name = "[L4D2] Airdrop",
  29.     author = "BHaType",
  30.     description = "Admin can call airdrop.",
  31.     version = "0.9",
  32.     url = "https://www.sourcemod.net/plugins.php?cat=0&mod=-1&title=&author=BHaType&description=&search=1"
  33. }
  34.  
  35. static const char gModeList[4][] =
  36. {
  37.     "models/props_vehicles/c130.mdl",
  38.     "models/props_crates/supply_crate02.mdl",
  39.     "models/props_crates/supply_crate02_gib1.mdl",
  40.     "models/props_junk/wood_crate001a.mdl"
  41. };
  42.  
  43. static const char gItemsListL4D1[MAXLIST - 18][] =
  44. {
  45.     "weapon_autoshotgun",
  46.     "weapon_first_aid_kit",
  47.     "weapon_pipe_bomb",
  48.     "weapon_molotov",
  49.     "weapon_rifle",
  50.     "weapon_hunting_rifle",
  51.     "weapon_pain_pills",
  52.     "weapon_pistol"
  53. };
  54.  
  55. static const char gItemsList[MAXLIST][] =
  56. {
  57.     "weapon_autoshotgun",       //0
  58.     "weapon_first_aid_kit",     //1
  59.     "weapon_pipe_bomb",         //2
  60.     "weapon_molotov",           //3
  61.     "weapon_rifle",             //4
  62.     "weapon_hunting_rifle",     //5
  63.     "weapon_pain_pills",        //6
  64.     "weapon_pistol",            //7
  65.     "weapon_adrenaline",        //8
  66.     "weapon_smg_mp5",           //9
  67.     "weapon_smg",               //10
  68.     "weapon_smg_silenced",      //11
  69.     "weapon_pumpshotgun",       //12
  70.     "weapon_shotgun_chrome",    //13
  71.     "weapon_rifle_m60",         //14
  72.     "weapon_shotgun_spas",      //15
  73.     "weapon_sniper_military",   //16
  74.     "weapon_rifle_ak47",        //17
  75.     "weapon_rifle_desert",      //18
  76.     "weapon_sniper_awp",        //19
  77.     "weapon_rifle_sg552",       //20
  78.     "weapon_sniper_scout",      //21
  79.     "weapon_grenade_launcher"//22
  80.     "weapon_pistol_magnum",     //23
  81.     "weapon_vomitjar",          //24
  82.     "weapon_defibrillator"      //25
  83. };
  84.  
  85. static int gItemsChances[MAXLIST] =
  86. {
  87.     100,
  88.     100,
  89.     100,
  90.     100,
  91.     100,
  92.     100,
  93.     100,
  94.     100,
  95.     100,
  96.     100,
  97.     100,
  98.     100,
  99.     100,
  100.     100,
  101.     100,
  102.     100,
  103.     100,
  104.     100,
  105.     100,
  106.     100,
  107.     100,
  108.     100,
  109.     100,
  110.     100,
  111.     100,
  112.     100
  113. };
  114.  
  115. /*
  116. static int gItemsCounts[MAXLIST] =
  117. {
  118.     100,
  119.     100,
  120.     100,
  121.     100,
  122.     100,
  123.     100,
  124.     100,
  125.     100,
  126.     100,
  127.     100,
  128.     100,
  129.     100,
  130.     100,
  131.     100,
  132.     100,
  133.     100,
  134.     100,
  135.     100,
  136.     100,
  137.     100,
  138.     100,
  139.     100,
  140.     100,
  141.     100,
  142.     100,
  143.     100
  144. };
  145. */
  146. static const char gModelsItemsList[MAXLIST][] =
  147. {
  148.     "models/w_models/weapons/w_autoshot_m4super.mdl",   //0
  149.     "models/w_models/weapons/w_eq_Medkit.mdl",          //1
  150.     "models/w_models/weapons/w_eq_pipebomb.mdl",        //2
  151.     "models/w_models/weapons/w_eq_molotov.mdl",         //3
  152.     "models/w_models/weapons/w_rifle_m16a2.mdl",        //4
  153.     "models/w_models/weapons/w_sniper_mini14.mdl",      //5
  154.     "models/w_models/weapons/w_eq_painpills.mdl",       //6
  155.     "models/w_models/weapons/w_pistol_a.mdl",           //7
  156.     "models/w_models/weapons/w_eq_adrenaline.mdl",      //8
  157.     "models/w_models/weapons/w_smg_mp5.mdl",            //9
  158.     "models/w_models/weapons/w_smg_uzi.mdl",            //10
  159.     "models/w_models/weapons/w_smg_a.mdl",              //11
  160.     "models/w_models/weapons/w_shotgun.mdl",            //12
  161.     "models/w_models/weapons/w_pumpshotgun_a.mdl",      //13
  162.     "models/w_models/weapons/w_m60.mdl",                //14
  163.     "models/w_models/weapons/w_shotgun_spas.mdl",       //15
  164.     "models/w_models/weapons/w_sniper_military.mdl",    //16
  165.     "models/w_models/weapons/w_rifle_ak47.mdl",         //17
  166.     "models/w_models/weapons/w_desert_rifle.mdl",       //18
  167.     "models/w_models/weapons/w_sniper_awp.mdl",         //19
  168.     "models/w_models/weapons/w_rifle_sg552.mdl",        //20
  169.     "models/w_models/weapons/w_sniper_scout.mdl",       //21
  170.     "models/w_models/weapons/w_grenade_launcher.mdl",   //22
  171.     "models/w_models/weapons/w_desert_eagle.mdl",       //23
  172.     "models/w_models/weapons/w_eq_bile_flask.mdl",      //24
  173.     "models/w_models/weapons/w_eq_defibrillator.mdl"    //25
  174. };
  175.  
  176. static int gAmmoList[MAXLIST] =
  177. {
  178.     90,
  179.     -1,
  180.     -1,
  181.     -1,
  182.     360,
  183.     150,
  184.     -1,
  185.     -1,
  186.     -1,
  187.     650,
  188.     650,
  189.     650,
  190.     56,
  191.     56,
  192.     -1,
  193.     90,
  194.     180,
  195.     360,
  196.     360,
  197.     180,
  198.     360,
  199.     180,
  200.     30,
  201.     -1,
  202.     -1,
  203.     -1
  204. };
  205.  
  206. static char gStringTable[2][] =
  207. {
  208.     "flare_burning",
  209.     "weapon_pipebomb_fuse"
  210. };
  211.  
  212. public int CallAirdrop_NAT(Handle plugin, int numParams)
  213. {
  214.     float vPos[3];
  215.     vPos[0] = GetNativeCell(2);
  216.     vPos[1] = GetNativeCell(3);
  217.     vPos[2] = GetNativeCell(4);
  218.     AirPlane(GetNativeCell(1), vPos);
  219. }
  220.  
  221. public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
  222. {
  223.     EngineVersion test = GetEngineVersion();
  224.     if( test == Engine_Left4Dead2 )
  225.         IsLeft4Dead2 = true;
  226.        
  227.     CreateNative("Airdrop", CallAirdrop_NAT);
  228.     return APLRes_Success;
  229. }
  230.  
  231. public void OnPluginStart()
  232. {
  233.     RegAdminCmd("sm_ac130", CallAirdrop, ADMFLAG_ROOT);
  234.     //HookEvent("tank_spawn", EventTank);
  235.     HookEvent("tank_killed", EventTank);
  236.     cFlare              =       CreateConVar("airdrop_flare"            ,   "1"         , "Flare on? //Fix"                                 , FCVAR_NONE);
  237.     cColorFlare         =       CreateConVar("airdrop_flare_color"      ,   "25 25 255" , "Color flare //Fix"                               , FCVAR_NONE);
  238.     cFlareLenght        =       CreateConVar("airdrop_flare_length"     ,   "75"        , "Length of smoker for flare //Fix"                , FCVAR_NONE);
  239.     cFlareAplha         =       CreateConVar("airdrop_flare_alpha"      ,   "255"       , "Transparency of smoke //Fix"                     , FCVAR_NONE);
  240.     cUseString          =       CreateConVar("airdrop_open_string"      ,   "Hehe boi"  , "Open string //Fix"                               , FCVAR_NONE);
  241.     cTimeOpen           =       CreateConVar("airdrop_open_time"        ,   "2.5"       , "Open time //Fix"                                 , FCVAR_NONE);
  242.     cCountAirdrops      =       CreateConVar("airdrop_count_airdrops"   ,   "3"         , "Count of airdrops //Fix"                         , FCVAR_NONE);
  243.     cTankChance         =       CreateConVar("airdrop_tank_chance"      ,   "50"        , "Chace airdrop of tank //Fix"                     , FCVAR_NONE);
  244.     cVocalize           =       CreateConVar("airdrop_vocalize_chance"  ,   "40"        , "Chance of vocalize (L4D2 only) //Fix"            , FCVAR_NONE);
  245.     cGlowRange          =       CreateConVar("airdrop_glow_range"       ,   "500"       , "Glow range of airdrops (L4D2 only) //Fix"        , FCVAR_NONE);
  246.     cCustomModel        =       CreateConVar("airdrop_use_custom_model" ,   "0"         , "Use customs model or not(parachute)"             , FCVAR_NONE);
  247.     cParachuteSpeed     =       CreateConVar("airdrop_parachute_speed"  ,   "60.0"      , "Speed of crate (Need parachute)"                 , FCVAR_NONE);
  248.     cMessages           =       CreateConVar("airdrop_enable_message"   ,   "1"         , "Enable message or no"                            , FCVAR_NONE);
  249.  
  250.     AutoExecConfig(true, "Airdrop");
  251.     LoadPercents();
  252. }
  253.  
  254. void LoadPercents()
  255. {  
  256.     char sPath[PLATFORM_MAX_PATH];
  257.     BuildPath(Path_SM, sPath, sizeof(sPath), CONFIG_CHANCE);
  258.     KeyValues hFile = new KeyValues("drop_weapons");
  259.     if(!FileExists(sPath))
  260.     {
  261.         File hCfg = OpenFile(sPath, "w");
  262.         hCfg.WriteLine("");
  263.         delete hCfg;
  264.        
  265.         if(KvJumpToKey(hFile, "weapons", true))
  266.         {
  267.             for( int i = 0; i < MAXLIST; i++ )
  268.                 hFile.SetNum(gItemsList[i], 0);
  269.             hFile.Rewind();
  270.             hFile.ExportToFile(sPath);
  271.         }
  272.         //hFile.Rewind();
  273.         //if(KvJumpToKey(hFile, "counts", true))
  274.         //{
  275.         //  for( int i = 0; i < MAXLIST; i++ )
  276.         //      hFile.SetNum(gItemsList[i], 3);
  277.         //  hFile.Rewind();
  278.         //  hFile.ExportToFile(sPath);
  279.         //}
  280.     }
  281.     else
  282.     {
  283.         if(hFile.ImportFromFile(sPath))
  284.         {
  285.             if(KvJumpToKey(hFile, "weapons", true))
  286.                 for( int i = 0; i < MAXLIST; i++ )
  287.                     gItemsChances[i] = hFile.GetNum(gItemsList[i]);
  288.         }
  289.     }
  290.     delete hFile;
  291. }
  292.  
  293. void PrecacheParticle(const char[] sEffectName)
  294. {
  295.     static int table = INVALID_STRING_TABLE;
  296.  
  297.     if( table == INVALID_STRING_TABLE )
  298.     {
  299.         table = FindStringTable("ParticleEffectNames");
  300.     }
  301.  
  302.     if( FindStringIndex(table, sEffectName) == INVALID_STRING_INDEX )
  303.     {
  304.         bool save = LockStringTables(false);
  305.         AddToStringTable(table, sEffectName);
  306.         LockStringTables(save);
  307.     }
  308. }
  309.  
  310. public Action EventTank(Event event, const char[] name, bool dontbroadcast)
  311. {
  312.     if(GetRandomInt(1, 100) <= GetConVarInt(cTankChance)) // AK978
  313.     {
  314.         float vPos[3];
  315.         int client = GetClientOfUserId(event.GetInt("userid"));
  316.         AirPlane(client, vPos);
  317.     }
  318. }
  319.  
  320. public void OnMapStart()
  321. {
  322.     for (int i = 0; i < 3; i++)
  323.         PrecacheModel(gModeList[i], true);
  324.     for (int i = 0; i < MAXLIST - 1; i++)
  325.         PrecacheModel(gModelsItemsList[i], true);
  326.     PrecacheSound(SOUND_CRACKLE);
  327.     PrecacheModel(MODEL_FLARE);
  328.     if(GetConVarInt(cCustomModel))
  329.     {
  330.         PrecacheModel("models/props_crates/supply_crate02_custom.mdl");
  331.     }
  332.     for(int i = 0; i < 2; i++)
  333.         PrecacheParticle(gStringTable[i]);
  334.     PrecacheModel("models/props_crates/supply_crate02_custom.mdl");
  335. }
  336.  
  337. public Action CallAirdrop(int client, int args)
  338. {
  339.     float vPos[3];
  340.     AirPlane(client, vPos);
  341.     if(GetConVarInt(cMessages)) PrintToChatAll("\x04[Air] \x03%N \x04called airdrop", client);
  342. }
  343.  
  344. stock void AirPlane(int client, float vPos[3])
  345. {
  346.     float vAng[3], vEndPos[3], direction[3];
  347.     vAng[0] = -89.00;
  348.     Handle hTrace;
  349.     if(vPos[0] == 0.0 && vPos[1] == 0.0 && vPos[2] == 0.0)
  350.     {
  351.         GetEntPropVector(client, Prop_Send, "m_vecOrigin", vPos);
  352.         vPos[2] += 90;
  353.     }
  354.    
  355.     hTrace = TR_TraceRayFilterEx(vPos, vAng, CONTENTS_SOLID, RayType_Infinite, TraceDontHitSelf, client);
  356.     if(TR_DidHit(hTrace))
  357.     {
  358.         TR_GetEndPosition(vEndPos, hTrace);
  359.         int entity = CreateEntityByName("prop_dynamic_override");
  360.         DispatchKeyValue(entity, "targetname", "ac130");
  361.         DispatchKeyValue(entity, "disableshadows", "1");
  362.         DispatchKeyValue(entity, "model", gModeList[0]);
  363.         DispatchSpawn(entity);
  364.         vPos[2] = vEndPos[2] - 15.0;
  365.        
  366.         GetClientAbsAngles(client, vAng);
  367.         GetAngleVectors(vAng, direction, NULL_VECTOR, NULL_VECTOR);
  368.         TeleportEntity(entity, vPos, direction, NULL_VECTOR);
  369.         EmitSoundToAll(SOUND_PASS1, entity, SNDCHAN_AUTO, SNDLEVEL_HELICOPTER);
  370.         SetVariantString("airport_intro_flyby");
  371.         AcceptEntityInput(entity, "SetAnimation");
  372.         AcceptEntityInput(entity, "Enable");
  373.  
  374.         SetVariantString("OnUser1 !self:Kill::20.19:1");
  375.         AcceptEntityInput(entity, "AddOutput");
  376.         AcceptEntityInput(entity, "FireUser1");
  377.         CreateTimer(6.4, TimerDropAirDrop, EntIndexToEntRef(entity));
  378.         delete hTrace;
  379.     }
  380. }
  381.  
  382. public Action TimerDropAirDrop(Handle timer, any entity)
  383. {
  384.     entity = EntRefToEntIndex(entity);
  385.     if(entity != INVALID_ENT_REFERENCE)
  386.     {
  387.         float vPos[3];
  388.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
  389.         CreateCrates(vPos);
  390.     }
  391. }
  392.  
  393. void CreateCrates(float vPos[3])
  394. {
  395.     char sUseString[56], sTimeOpen[16];
  396.     int entity, iTrigger, iGravity, count;
  397.     float vAng[3];
  398.     vAng[0] = 89.0; vAng[1] = 0.0; vAng[2] = 0.0;
  399.    
  400.     GetConVarString(cUseString, sUseString, sizeof sUseString);
  401.     GetConVarString(cTimeOpen, sTimeOpen, sizeof sTimeOpen);
  402.        
  403.     count = GetConVarInt(cCountAirdrops);
  404.     for(int i; i < count; i++)
  405.     {
  406.         vPos[1] += GetRandomInt(-150, 150);
  407.         vPos[0] += GetRandomInt(-150, 150);
  408.         entity = CreateEntityByName("prop_physics_override");
  409.         DispatchKeyValue(entity, "targetname", "SupplyDrop");
  410.         DispatchKeyValueVector(entity, "origin", vPos);
  411.         if(IsLeft4Dead2)
  412.             SetEntityModel(entity, gModeList[1]);
  413.         else
  414.         {
  415.             DispatchKeyValue(entity, "StartGlowing", "1");
  416.             DispatchKeyValue(entity, "model", gModeList[3]);
  417.         }
  418.         DispatchSpawn(entity);
  419.         if(GetConVarInt(cCustomModel))
  420.         {  
  421.             iGravity = CreateEntityByName("prop_dynamic_override");
  422.             SetEntityModel(iGravity, "models/props_crates/supply_crate02_custom.mdl");
  423.             DispatchSpawn(iGravity);
  424.             TeleportEntity(iGravity, vPos, NULL_VECTOR, NULL_VECTOR);
  425.             SetVariantString("!activator");
  426.             AcceptEntityInput(iGravity, "SetParent", entity);
  427.             g_iParachute[entity] = EntIndexToEntRef(iGravity);
  428.         }
  429.         if(GetConVarInt(cFlare) || GetConVarInt(cCustomModel))
  430.         {
  431.             for(int v = MaxClients; v < 2049; v++)
  432.             {
  433.                 if(hTimer[v] == null)
  434.                 {
  435.                     hTimer[v] = CreateTimer(0.1, tSetGravity, EntIndexToEntRef(entity), TIMER_REPEAT);
  436.                     break;
  437.                 }
  438.             }
  439.         }
  440.         if(IsLeft4Dead2)
  441.         {
  442.             iTrigger = CreateEntityByName("func_button_timed");
  443.             DispatchKeyValueVector(iTrigger, "origin", vPos);
  444.             DispatchKeyValue(iTrigger, "use_string", sUseString);
  445.             DispatchKeyValue(iTrigger, "use_time", sTimeOpen);
  446.             DispatchKeyValue(iTrigger, "auto_disable", "1");
  447.             DispatchSpawn(iTrigger);
  448.             ActivateEntity(iTrigger);
  449.            
  450.             SetEntPropVector(iTrigger, Prop_Send, "m_vecMins", view_as<float>({-225.0, -225.0, -225.0}));
  451.             SetEntPropVector(iTrigger, Prop_Send, "m_vecMaxs", view_as<float>({225.0, 225.0, 225.0}));
  452.             HookSingleEntityOutput(iTrigger, "OnTimeUp", OnTimeUp);
  453.             SetEntityModel(iTrigger, gModeList[2]);
  454.             SetEntityRenderMode(iTrigger, RENDER_NONE);
  455.             TeleportEntity(iTrigger, vPos, NULL_VECTOR, NULL_VECTOR);
  456.             SetVariantString("!activator");
  457.             AcceptEntityInput(iTrigger, "SetParent", entity);
  458.             char sColor[16];
  459.             Format(sColor, sizeof sColor, "255 255 255");
  460.             SetEntProp(entity, Prop_Send, "m_nGlowRange", GetConVarInt(cGlowRange));
  461.             SetEntProp(entity, Prop_Send, "m_iGlowType", 3);
  462.             SetEntProp(entity, Prop_Send, "m_glowColorOverride", GetColor(sColor));
  463.             SetEntProp(iTrigger, Prop_Data, "m_takedamage", 0, 1);
  464.             SetEntProp(entity, Prop_Data, "m_takedamage", 0, 1);
  465.             gIndexCrate[iTrigger] = EntIndexToEntRef(entity);
  466.         }
  467.         else SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage);
  468.     }
  469.     //SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage);
  470.     if(GetConVarInt(cMessages)) PrintToChatAll("\x04[Air] \x03Airdrop \x04fell in the approximate coordinates \x05%.2f %.2f %.2f", vPos[0], vPos[1], vPos[2]);
  471. }
  472.  
  473. public Action tSetGravity(Handle timer, any entity)
  474. {
  475.     entity = EntRefToEntIndex(entity);
  476.     if(entity != INVALID_ENT_REFERENCE)
  477.     {
  478.         float vSpeed[3], vPos[3], vAng[3], vEndPos[3];
  479.         int iGravity;
  480.         char sColor[12];
  481.         vAng[0] = 89.0;
  482.         Handle hTrace;
  483.         vSpeed[2] = float(GetConVarInt(cParachuteSpeed)) * -1;
  484.         if(GetConVarInt(cCustomModel))
  485.             TeleportEntity(entity, NULL_VECTOR, NULL_VECTOR, vSpeed);
  486.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
  487.         hTrace = TR_TraceRayFilterEx(vPos, vAng, CONTENTS_SOLID, RayType_Infinite, TraceDontHitSelf, entity);
  488.         if(TR_DidHit(hTrace))
  489.         {
  490.             TR_GetEndPosition(vEndPos, hTrace);
  491.             float vDistance = GetVectorDistance(vPos, vEndPos);
  492.             if(vDistance < 15)
  493.             {
  494.                 if(GetConVarInt(cFlare))
  495.                 {
  496.                     GetConVarString(cColorFlare, sColor, sizeof sColor);
  497.                     vAng[0] = 0.0;
  498.                     vPos[0] += 25.0;
  499.                     vPos[2] -= 12.0;
  500.                     MakeFlare(entity, vAng, vPos, sColor, sColor);
  501.                     gFlares[entity] = true;
  502.                 }
  503.                 if(GetConVarInt(cCustomModel))
  504.                 {
  505.                     iGravity = EntRefToEntIndex(g_iParachute[entity]); 
  506.                     if(iGravity != INVALID_ENT_REFERENCE)
  507.                         AcceptEntityInput(iGravity, "kill");
  508.                 }
  509.                 hTimer[entity] = null;
  510.                 return Plugin_Stop;
  511.             }
  512.         }
  513.         delete hTrace;
  514.     }
  515.     return Plugin_Continue;
  516. }
  517.  
  518. public bool TraceFilter(int entity, int contentsMask)
  519. {
  520.     return entity > MaxClients;
  521. }
  522.  
  523. public bool TraceDontHitSelf(int entity, int mask, any data)
  524. {
  525.     if(entity == data || IsValidEntity(entity))
  526.     {
  527.         return false;
  528.     }
  529.     return true;
  530. }
  531.  
  532. public void OnTimeUp(const char[] output, int caller, int activator, float delay)
  533. {
  534.     if (activator > 0 && activator <= MaxClients && IsClientInGame(activator))
  535.     {
  536.         int entity, iGravity, iChancesWeapons;
  537.         entity = gIndexCrate[caller];
  538.         if((entity = EntRefToEntIndex(entity)) != INVALID_ENT_REFERENCE)
  539.         {
  540.             if(hTimer[entity] != null)
  541.             {
  542.                 delete hTimer[entity];
  543.             }
  544.             if(GetConVarInt(cCustomModel))
  545.             {
  546.                 iGravity = EntRefToEntIndex(g_iParachute[entity]);
  547.                 if(iGravity != INVALID_ENT_REFERENCE)
  548.                 {
  549.                     AcceptEntityInput(iGravity, "kill");
  550.                 }
  551.             }
  552.             int SupplyItem, OpenedCrate;
  553.             float vPos[3], vAng[3];
  554.             AcceptEntityInput(caller, "kill");
  555.             GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
  556.             GetEntPropVector(entity, Prop_Send, "m_angRotation", vAng);
  557.             OpenedCrate = CreateEntityByName("prop_physics_override");
  558.             DispatchKeyValueVector(OpenedCrate, "origin", vPos);
  559.             DispatchKeyValueVector(OpenedCrate, "angles", vAng);
  560.             SetEntityModel(OpenedCrate, gModeList[2]);
  561.             DispatchSpawn(OpenedCrate);
  562.             AcceptEntityInput(entity, "kill");
  563.             int weapons = MAXLIST;
  564.             while (weapons-- > 0)
  565.             {
  566.                 iChancesWeapons = GetRandomInt(1, 100);
  567.                 if(iChancesWeapons <= gItemsChances[weapons])
  568.                 {
  569.                     SupplyItem = CreateEntityByName(gItemsList[weapons]);
  570.                     DispatchSpawn(SupplyItem);
  571.                     SetEntityModel(SupplyItem, gModelsItemsList[weapons]);
  572.                     vPos[2] += 2.5;
  573.                     vAng[0] = 0.0; vAng[1] = 90.0; vAng[2] = 0.0;
  574.                     TeleportEntity(SupplyItem, vPos, vAng, NULL_VECTOR);
  575.                     if(gAmmoList[weapons] != -1)
  576.                         SetEntProp(SupplyItem, Prop_Send, "m_iExtraPrimaryAmmo", gAmmoList[weapons], 4);
  577.                 }
  578.             }
  579.             for(int i = 0; i <= 4; i++)
  580.             {
  581.                 if(gFlares[entity])
  582.                 {
  583.                     int iFlare = EntRefToEntIndex(g_iFlares[entity][i]);
  584.                     if(iFlare != INVALID_ENT_REFERENCE)
  585.                         AcceptEntityInput(iFlare, "kill");
  586.                 }
  587.             }
  588.             for(int i = 1; i <= MaxClients; i++)
  589.                 if(IsClientInGame(i)) PrintToChat(i, "\x04[Air] \x03%N \x04open airdrop", activator);
  590.             Vocalize(activator);
  591.         }
  592.     }
  593. }
  594.  
  595. public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)  
  596. {
  597.     if(IsValidEntity(victim) && attacker > 0 && GetClientTeam(attacker) == 2)
  598.     {
  599.         float vPos[3];
  600.         char sModel[126], sWeaponList[360], sWeaponAllowed[36][32];
  601.         int SupplyItem;
  602.         GetEntPropString(victim, Prop_Data, "m_ModelName", sModel, sizeof(sModel));
  603.         GetConVarString(cWeaponList, sWeaponList, sizeof sWeaponList);
  604.         ExplodeString(sWeaponList, ";", sWeaponAllowed, sizeof(sWeaponAllowed), sizeof(sWeaponAllowed[]));
  605.         if(strcmp(sModel, gModeList[3]) == 0)
  606.         {  
  607.             AcceptEntityInput(victim, "break");
  608.            
  609.             GetEntPropVector(victim, Prop_Send, "m_vecOrigin", vPos);
  610.             for(int v; v < GetConVarInt(cCountItems); v++)
  611.             {
  612.                 int iInt = GetRandomInt(0, 7);
  613.                 SupplyItem = CreateEntityByName(gItemsListL4D1[GetRandomInt(0, 7)]);
  614.                 for(int i; i < 8; i++)
  615.                 {
  616.                     if(strcmp(gItemsListL4D1[iInt], sWeaponAllowed[i]) == 0)
  617.                     {
  618.                         DispatchSpawn(SupplyItem);
  619.                         vPos[2] += 7.0;
  620.                         TeleportEntity(SupplyItem, vPos, NULL_VECTOR, NULL_VECTOR);
  621.                     }
  622.                 }
  623.             }
  624.         }
  625.     }
  626. }
  627.  
  628. int GetColor(char[] sTemp)
  629. {
  630.     if( StrEqual(sTemp, "") )
  631.         return 0;
  632.  
  633.     char sColors[3][4];
  634.     int color = ExplodeString(sTemp, " ", sColors, 3, 4);
  635.  
  636.     if( color != 3 )
  637.         return 0;
  638.  
  639.     color = StringToInt(sColors[0]);
  640.     color += 256 * StringToInt(sColors[1]);
  641.     color += 65536 * StringToInt(sColors[2]);
  642.  
  643.     return color;
  644. }
  645.  
  646. //Thanks to Silvers...
  647. int MakeFlare(int client, float vAngles[3], float vOrigin[3], const char[] sColorL, const char[] sColorS)
  648. {
  649.     int entity;
  650.    
  651.     entity = CreateEntityByName("prop_dynamic");
  652.  
  653.     SetEntityModel(entity, MODEL_FLARE);
  654.     DispatchSpawn(entity);
  655.     TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
  656.    
  657.     g_iFlares[client][0] = EntIndexToEntRef(entity);
  658.     vOrigin[2] += 15.0;
  659.     entity = MakeLightDynamic(vOrigin, view_as<float>({ 90.0, 0.0, 0.0 }), sColorL, 255);
  660.     vOrigin[2] -= 15.0;
  661.    
  662.     g_iFlares[client][1] = EntIndexToEntRef(entity);
  663.     // Position particles / smoke
  664.     entity = 0;
  665.     vAngles[1] = GetRandomFloat(1.0, 360.0);
  666.     vAngles[0] = -80.0;
  667.     vOrigin[0] += (1.0 * (Cosine(DegToRad(vAngles[1]))));
  668.     vOrigin[1] += (1.5 * (Sine(DegToRad(vAngles[1]))));
  669.     vOrigin[2] += 1.0;
  670.  
  671.     // Flare particles
  672.     entity = DisplayParticle(PARTICLE_FLARE, vOrigin, vAngles);
  673.     g_iFlares[client][2] = EntIndexToEntRef(entity);
  674.    
  675.     // Fuse particles
  676.     entity = DisplayParticle(PARTICLE_FUSE, vOrigin, vAngles);
  677.     g_iFlares[client][3] = EntIndexToEntRef(entity);
  678.  
  679.     // Smoke
  680.     vAngles[0] = -85.0;
  681.     entity = MakeEnvSteam(vOrigin, vAngles, sColorS, GetConVarInt(cFlareAplha), GetConVarInt(cFlareLenght));
  682.     g_iFlares[client][4] = EntIndexToEntRef(entity);
  683.  
  684.     PlaySound(g_iFlares[entity][0]);
  685. }
  686.  
  687. //Thanks to Silvers...
  688. int DisplayParticle(const char[] sParticle, const float vPos[3], const float vAng[3])
  689. {
  690.     int entity = CreateEntityByName("info_particle_system");
  691.     if( entity != -1 )
  692.     {
  693.         DispatchKeyValue(entity, "effect_name", sParticle);
  694.         DispatchSpawn(entity);
  695.         ActivateEntity(entity);
  696.         AcceptEntityInput(entity, "start");
  697.         TeleportEntity(entity, vPos, vAng, NULL_VECTOR);
  698.         return entity;
  699.     }
  700.     return 0;
  701. }
  702.  
  703. //Thanks to Silvers...
  704. int MakeEnvSteam(const float vOrigin[3], const float vAngles[3], const char[] sColor, int iAlpha, int iLength)
  705. {
  706.     int entity = CreateEntityByName("env_steam");
  707.     char sTemp[5];
  708.     DispatchKeyValue(entity, "SpawnFlags", "1");
  709.     DispatchKeyValue(entity, "rendercolor", sColor);
  710.     DispatchKeyValue(entity, "SpreadSpeed", "1");
  711.     DispatchKeyValue(entity, "Speed", "15");
  712.     DispatchKeyValue(entity, "StartSize", "1");
  713.     DispatchKeyValue(entity, "EndSize", "3");
  714.     DispatchKeyValue(entity, "Rate", "10");
  715.     IntToString(iLength, sTemp, sizeof(sTemp));
  716.     DispatchKeyValue(entity, "JetLength", sTemp);
  717.     IntToString(iAlpha, sTemp, sizeof(sTemp));
  718.     DispatchKeyValue(entity, "renderamt", sTemp);
  719.     DispatchKeyValue(entity, "InitialState", "1");
  720.     DispatchKeyValueVector(entity, "origin", vOrigin);
  721.     DispatchKeyValueVector(entity, "angles", vAngles);
  722.     //TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
  723.     DispatchSpawn(entity);
  724.     AcceptEntityInput(entity, "TurnOn");
  725.     return entity;
  726. }
  727.  
  728. void PlaySound(int entity)
  729. {
  730.     EmitSoundToAll(SOUND_CRACKLE, entity, SNDCHAN_AUTO, SNDLEVEL_DISHWASHER, SND_SHOULDPAUSE, SNDVOL_NORMAL, SNDPITCH_HIGH, -1, NULL_VECTOR, NULL_VECTOR);
  731. }
  732.  
  733. int MakeLightDynamic(const float vOrigin[3], const float vAngles[3], const char[] sColor, int iDist)
  734. {
  735.     int entity = CreateEntityByName("light_dynamic");
  736.     char sTemp[16];
  737.     Format(sTemp, sizeof(sTemp), "6");
  738.     DispatchKeyValue(entity, "style", sTemp);
  739.     Format(sTemp, sizeof(sTemp), "%s 255", sColor);
  740.     DispatchKeyValue(entity, "_light", sTemp);
  741.     DispatchKeyValue(entity, "brightness", "1");
  742.     DispatchKeyValueFloat(entity, "spotlight_radius", 32.0);
  743.     DispatchKeyValueFloat(entity, "distance", float(iDist));
  744.     DispatchSpawn(entity);
  745.     AcceptEntityInput(entity, "TurnOn");
  746.     TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
  747.     return entity;
  748. }
  749.  
  750. //Thanks to Silvers
  751. static const char g_sVocalize[][] =
  752. {
  753.     "scenes/Coach/dlc1_c6m1_alarmdoor01.vcd",
  754.     "scenes/Coach/dlc1_golfclub07.vcd",
  755.     "scenes/Coach/thanks02.vcd",
  756.     "scenes/Coach/reactionnegative02.vcd",
  757.     "scenes/Coach/no02.vcd",
  758.     "scenes/Gambler/dlc1_c6m1_alarmdoor02.vcd",
  759.     "scenes/Gambler/dlc1_c6m1_alarmdoor01.vcd",
  760.     "scenes/Gambler/dlc1_c6m2_phase2jumpinwater02.vcd",
  761.     "scenes/Mechanic/dlc1_c6m3_finalebridgerun02.vcd",
  762.     "scenes/Mechanic/dlc1_m6007.vcd",
  763.     "scenes/Producer/heardspecialc104.vcd",
  764.     "scenes/Producer/hurrah01.vcd",
  765.     /*
  766.     "left4dead2_dlc1/scenes/teengirl/laughter01.vcd",
  767.     "left4dead2_dlc1/scenes/teengirl/nicejob05.vcd",
  768.     "left4dead2_dlc1/scenes/teengirl/playersuggesthealthspecific04.vcd.vcd",
  769.     "left4dead2_dlc2/scenes/biker/dlc2birdhate01.vcd",
  770.     "left4dead2_dlc3/scenes/biker/c6dlc3otherboats09.vcd",
  771.     "scenes/biker/namebill02.vcd", 
  772.     "left4dead2_dlc1/scenes/biker/dlc1_killfinaltank01.vcd",
  773.     "left4dead2_dlc2/manager/dlc2forlease01.vcd"
  774.     */
  775. };
  776.  
  777. //Thanks to Silvers
  778. void Vocalize(int client)
  779. {
  780.     if(GetRandomInt(1, 100) > GetConVarInt(cVocalize))
  781.         return;
  782.  
  783.     char sTemp[64];
  784.     GetEntPropString(client, Prop_Data, "m_ModelName", sTemp, 64);
  785.  
  786.     int random;
  787.     if( sTemp[26] == 'c' )                          // c = Coach
  788.         random = GetRandomInt(0, 4);
  789.     else if( sTemp[26] == 'g' )                     // g = Gambler
  790.         random = GetRandomInt(5, 7);
  791.     else if( sTemp[26] == 'm' && sTemp[27] == 'e' ) // me = Mechanic
  792.         random = GetRandomInt(8, 9);
  793.     else if( sTemp[26] == 'p' )                     // p = Producer
  794.         random = GetRandomInt(10, 11);
  795.     else
  796.         return;
  797.        
  798.     /*
  799.     else if(StrContains(sTemp, "teengirl") > 0)
  800.         random = GetRandomInt(12, 14);
  801.     else if(StrContains(sTemp, "biker") > 0)
  802.         random = GetRandomInt(15, 18);
  803.     else if(StrContains(sTemp, "manager") > 0)
  804.         random = 19;
  805.     else
  806.         return;
  807.     */
  808.     int entity = CreateEntityByName("instanced_scripted_scene");
  809.     DispatchKeyValue(entity, "SceneFile", g_sVocalize[random]);
  810.     DispatchSpawn(entity);
  811.     SetEntPropEnt(entity, Prop_Data, "m_hOwner", client);
  812.     ActivateEntity(entity);
  813.     AcceptEntityInput(entity, "Start", client, client);
  814. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement