Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #pragma newdecls required
- #include <sourcemod>
- #include <sdktools>
- #include <sdkhooks>
- #define SOUND_PASS1 "animation/c130_flyby.wav"
- #define CONFIG_CHANCE "data/weapon_chances.cfg"
- #define PARTICLE_FLARE "flare_burning"
- #define PARTICLE_FUSE "weapon_pipebomb_fuse"
- #define SOUND_CRACKLE "ambient/fire/fire_small_loop2.wav"
- #define MODEL_FLARE "models/props_lighting/light_flares.mdl"
- #define MAXLIST 26
- #define MAXENTITIES 128
- int gIndexCrate[2048+1], g_iFlares[2048+1][5], g_iParachute[2048+1];
- ConVar cTankChance, cCountAirdrops, cTimeOpen, cUseString, cColorFlare, cFlare,
- cFlareLenght, cFlareAplha, cWeaponList, cGlowRange, cVocalize, cCustomModel, cParachuteSpeed,
- cMessages;
- bool IsLeft4Dead2, gFlares[2048+1];
- Handle hTimer[2048];
- public Plugin myinfo =
- {
- name = "[L4D2] Airdrop",
- author = "BHaType",
- description = "Admin can call airdrop.",
- version = "0.9",
- url = "https://www.sourcemod.net/plugins.php?cat=0&mod=-1&title=&author=BHaType&description=&search=1"
- }
- static const char gModeList[4][] =
- {
- "models/props_vehicles/c130.mdl",
- "models/props_crates/supply_crate02.mdl",
- "models/props_crates/supply_crate02_gib1.mdl",
- "models/props_junk/wood_crate001a.mdl"
- };
- static const char gItemsListL4D1[MAXLIST - 18][] =
- {
- "weapon_autoshotgun",
- "weapon_first_aid_kit",
- "weapon_pipe_bomb",
- "weapon_molotov",
- "weapon_rifle",
- "weapon_hunting_rifle",
- "weapon_pain_pills",
- "weapon_pistol"
- };
- static const char gItemsList[MAXLIST][] =
- {
- "weapon_autoshotgun", //0
- "weapon_first_aid_kit", //1
- "weapon_pipe_bomb", //2
- "weapon_molotov", //3
- "weapon_rifle", //4
- "weapon_hunting_rifle", //5
- "weapon_pain_pills", //6
- "weapon_pistol", //7
- "weapon_adrenaline", //8
- "weapon_smg_mp5", //9
- "weapon_smg", //10
- "weapon_smg_silenced", //11
- "weapon_pumpshotgun", //12
- "weapon_shotgun_chrome", //13
- "weapon_rifle_m60", //14
- "weapon_shotgun_spas", //15
- "weapon_sniper_military", //16
- "weapon_rifle_ak47", //17
- "weapon_rifle_desert", //18
- "weapon_sniper_awp", //19
- "weapon_rifle_sg552", //20
- "weapon_sniper_scout", //21
- "weapon_grenade_launcher", //22
- "weapon_pistol_magnum", //23
- "weapon_vomitjar", //24
- "weapon_defibrillator" //25
- };
- static int gItemsChances[MAXLIST] =
- {
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100
- };
- /*
- static int gItemsCounts[MAXLIST] =
- {
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100,
- 100
- };
- */
- static const char gModelsItemsList[MAXLIST][] =
- {
- "models/w_models/weapons/w_autoshot_m4super.mdl", //0
- "models/w_models/weapons/w_eq_Medkit.mdl", //1
- "models/w_models/weapons/w_eq_pipebomb.mdl", //2
- "models/w_models/weapons/w_eq_molotov.mdl", //3
- "models/w_models/weapons/w_rifle_m16a2.mdl", //4
- "models/w_models/weapons/w_sniper_mini14.mdl", //5
- "models/w_models/weapons/w_eq_painpills.mdl", //6
- "models/w_models/weapons/w_pistol_a.mdl", //7
- "models/w_models/weapons/w_eq_adrenaline.mdl", //8
- "models/w_models/weapons/w_smg_mp5.mdl", //9
- "models/w_models/weapons/w_smg_uzi.mdl", //10
- "models/w_models/weapons/w_smg_a.mdl", //11
- "models/w_models/weapons/w_shotgun.mdl", //12
- "models/w_models/weapons/w_pumpshotgun_a.mdl", //13
- "models/w_models/weapons/w_m60.mdl", //14
- "models/w_models/weapons/w_shotgun_spas.mdl", //15
- "models/w_models/weapons/w_sniper_military.mdl", //16
- "models/w_models/weapons/w_rifle_ak47.mdl", //17
- "models/w_models/weapons/w_desert_rifle.mdl", //18
- "models/w_models/weapons/w_sniper_awp.mdl", //19
- "models/w_models/weapons/w_rifle_sg552.mdl", //20
- "models/w_models/weapons/w_sniper_scout.mdl", //21
- "models/w_models/weapons/w_grenade_launcher.mdl", //22
- "models/w_models/weapons/w_desert_eagle.mdl", //23
- "models/w_models/weapons/w_eq_bile_flask.mdl", //24
- "models/w_models/weapons/w_eq_defibrillator.mdl" //25
- };
- static int gAmmoList[MAXLIST] =
- {
- 90,
- -1,
- -1,
- -1,
- 360,
- 150,
- -1,
- -1,
- -1,
- 650,
- 650,
- 650,
- 56,
- 56,
- -1,
- 90,
- 180,
- 360,
- 360,
- 180,
- 360,
- 180,
- 30,
- -1,
- -1,
- -1
- };
- static char gStringTable[2][] =
- {
- "flare_burning",
- "weapon_pipebomb_fuse"
- };
- public int CallAirdrop_NAT(Handle plugin, int numParams)
- {
- float vPos[3];
- vPos[0] = GetNativeCell(2);
- vPos[1] = GetNativeCell(3);
- vPos[2] = GetNativeCell(4);
- AirPlane(GetNativeCell(1), vPos);
- }
- public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
- {
- EngineVersion test = GetEngineVersion();
- if( test == Engine_Left4Dead2 )
- IsLeft4Dead2 = true;
- CreateNative("Airdrop", CallAirdrop_NAT);
- return APLRes_Success;
- }
- public void OnPluginStart()
- {
- RegAdminCmd("sm_ac130", CallAirdrop, ADMFLAG_ROOT);
- //HookEvent("tank_spawn", EventTank);
- HookEvent("tank_killed", EventTank);
- cFlare = CreateConVar("airdrop_flare" , "1" , "Flare on? //Fix" , FCVAR_NONE);
- cColorFlare = CreateConVar("airdrop_flare_color" , "25 25 255" , "Color flare //Fix" , FCVAR_NONE);
- cFlareLenght = CreateConVar("airdrop_flare_length" , "75" , "Length of smoker for flare //Fix" , FCVAR_NONE);
- cFlareAplha = CreateConVar("airdrop_flare_alpha" , "255" , "Transparency of smoke //Fix" , FCVAR_NONE);
- cUseString = CreateConVar("airdrop_open_string" , "Hehe boi" , "Open string //Fix" , FCVAR_NONE);
- cTimeOpen = CreateConVar("airdrop_open_time" , "2.5" , "Open time //Fix" , FCVAR_NONE);
- cCountAirdrops = CreateConVar("airdrop_count_airdrops" , "3" , "Count of airdrops //Fix" , FCVAR_NONE);
- cTankChance = CreateConVar("airdrop_tank_chance" , "50" , "Chace airdrop of tank //Fix" , FCVAR_NONE);
- cVocalize = CreateConVar("airdrop_vocalize_chance" , "40" , "Chance of vocalize (L4D2 only) //Fix" , FCVAR_NONE);
- cGlowRange = CreateConVar("airdrop_glow_range" , "500" , "Glow range of airdrops (L4D2 only) //Fix" , FCVAR_NONE);
- cCustomModel = CreateConVar("airdrop_use_custom_model" , "0" , "Use customs model or not(parachute)" , FCVAR_NONE);
- cParachuteSpeed = CreateConVar("airdrop_parachute_speed" , "60.0" , "Speed of crate (Need parachute)" , FCVAR_NONE);
- cMessages = CreateConVar("airdrop_enable_message" , "1" , "Enable message or no" , FCVAR_NONE);
- AutoExecConfig(true, "Airdrop");
- LoadPercents();
- }
- void LoadPercents()
- {
- char sPath[PLATFORM_MAX_PATH];
- BuildPath(Path_SM, sPath, sizeof(sPath), CONFIG_CHANCE);
- KeyValues hFile = new KeyValues("drop_weapons");
- if(!FileExists(sPath))
- {
- File hCfg = OpenFile(sPath, "w");
- hCfg.WriteLine("");
- delete hCfg;
- if(KvJumpToKey(hFile, "weapons", true))
- {
- for( int i = 0; i < MAXLIST; i++ )
- hFile.SetNum(gItemsList[i], 0);
- hFile.Rewind();
- hFile.ExportToFile(sPath);
- }
- //hFile.Rewind();
- //if(KvJumpToKey(hFile, "counts", true))
- //{
- // for( int i = 0; i < MAXLIST; i++ )
- // hFile.SetNum(gItemsList[i], 3);
- // hFile.Rewind();
- // hFile.ExportToFile(sPath);
- //}
- }
- else
- {
- if(hFile.ImportFromFile(sPath))
- {
- if(KvJumpToKey(hFile, "weapons", true))
- for( int i = 0; i < MAXLIST; i++ )
- gItemsChances[i] = hFile.GetNum(gItemsList[i]);
- }
- }
- delete hFile;
- }
- void PrecacheParticle(const char[] sEffectName)
- {
- static int table = INVALID_STRING_TABLE;
- if( table == INVALID_STRING_TABLE )
- {
- table = FindStringTable("ParticleEffectNames");
- }
- if( FindStringIndex(table, sEffectName) == INVALID_STRING_INDEX )
- {
- bool save = LockStringTables(false);
- AddToStringTable(table, sEffectName);
- LockStringTables(save);
- }
- }
- public Action EventTank(Event event, const char[] name, bool dontbroadcast)
- {
- if(GetRandomInt(1, 100) <= GetConVarInt(cTankChance)) // AK978
- {
- float vPos[3];
- int client = GetClientOfUserId(event.GetInt("userid"));
- AirPlane(client, vPos);
- }
- }
- public void OnMapStart()
- {
- for (int i = 0; i < 3; i++)
- PrecacheModel(gModeList[i], true);
- for (int i = 0; i < MAXLIST - 1; i++)
- PrecacheModel(gModelsItemsList[i], true);
- PrecacheSound(SOUND_CRACKLE);
- PrecacheModel(MODEL_FLARE);
- if(GetConVarInt(cCustomModel))
- {
- PrecacheModel("models/props_crates/supply_crate02_custom.mdl");
- }
- for(int i = 0; i < 2; i++)
- PrecacheParticle(gStringTable[i]);
- PrecacheModel("models/props_crates/supply_crate02_custom.mdl");
- }
- public Action CallAirdrop(int client, int args)
- {
- float vPos[3];
- AirPlane(client, vPos);
- if(GetConVarInt(cMessages)) PrintToChatAll("\x04[Air] \x03%N \x04called airdrop", client);
- }
- stock void AirPlane(int client, float vPos[3])
- {
- float vAng[3], vEndPos[3], direction[3];
- vAng[0] = -89.00;
- Handle hTrace;
- if(vPos[0] == 0.0 && vPos[1] == 0.0 && vPos[2] == 0.0)
- {
- GetEntPropVector(client, Prop_Send, "m_vecOrigin", vPos);
- vPos[2] += 90;
- }
- hTrace = TR_TraceRayFilterEx(vPos, vAng, CONTENTS_SOLID, RayType_Infinite, TraceDontHitSelf, client);
- if(TR_DidHit(hTrace))
- {
- TR_GetEndPosition(vEndPos, hTrace);
- int entity = CreateEntityByName("prop_dynamic_override");
- DispatchKeyValue(entity, "targetname", "ac130");
- DispatchKeyValue(entity, "disableshadows", "1");
- DispatchKeyValue(entity, "model", gModeList[0]);
- DispatchSpawn(entity);
- vPos[2] = vEndPos[2] - 15.0;
- GetClientAbsAngles(client, vAng);
- GetAngleVectors(vAng, direction, NULL_VECTOR, NULL_VECTOR);
- TeleportEntity(entity, vPos, direction, NULL_VECTOR);
- EmitSoundToAll(SOUND_PASS1, entity, SNDCHAN_AUTO, SNDLEVEL_HELICOPTER);
- SetVariantString("airport_intro_flyby");
- AcceptEntityInput(entity, "SetAnimation");
- AcceptEntityInput(entity, "Enable");
- SetVariantString("OnUser1 !self:Kill::20.19:1");
- AcceptEntityInput(entity, "AddOutput");
- AcceptEntityInput(entity, "FireUser1");
- CreateTimer(6.4, TimerDropAirDrop, EntIndexToEntRef(entity));
- delete hTrace;
- }
- }
- public Action TimerDropAirDrop(Handle timer, any entity)
- {
- entity = EntRefToEntIndex(entity);
- if(entity != INVALID_ENT_REFERENCE)
- {
- float vPos[3];
- GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
- CreateCrates(vPos);
- }
- }
- void CreateCrates(float vPos[3])
- {
- char sUseString[56], sTimeOpen[16];
- int entity, iTrigger, iGravity, count;
- float vAng[3];
- vAng[0] = 89.0; vAng[1] = 0.0; vAng[2] = 0.0;
- GetConVarString(cUseString, sUseString, sizeof sUseString);
- GetConVarString(cTimeOpen, sTimeOpen, sizeof sTimeOpen);
- count = GetConVarInt(cCountAirdrops);
- for(int i; i < count; i++)
- {
- vPos[1] += GetRandomInt(-150, 150);
- vPos[0] += GetRandomInt(-150, 150);
- entity = CreateEntityByName("prop_physics_override");
- DispatchKeyValue(entity, "targetname", "SupplyDrop");
- DispatchKeyValueVector(entity, "origin", vPos);
- if(IsLeft4Dead2)
- SetEntityModel(entity, gModeList[1]);
- else
- {
- DispatchKeyValue(entity, "StartGlowing", "1");
- DispatchKeyValue(entity, "model", gModeList[3]);
- }
- DispatchSpawn(entity);
- if(GetConVarInt(cCustomModel))
- {
- iGravity = CreateEntityByName("prop_dynamic_override");
- SetEntityModel(iGravity, "models/props_crates/supply_crate02_custom.mdl");
- DispatchSpawn(iGravity);
- TeleportEntity(iGravity, vPos, NULL_VECTOR, NULL_VECTOR);
- SetVariantString("!activator");
- AcceptEntityInput(iGravity, "SetParent", entity);
- g_iParachute[entity] = EntIndexToEntRef(iGravity);
- }
- if(GetConVarInt(cFlare) || GetConVarInt(cCustomModel))
- {
- for(int v = MaxClients; v < 2049; v++)
- {
- if(hTimer[v] == null)
- {
- hTimer[v] = CreateTimer(0.1, tSetGravity, EntIndexToEntRef(entity), TIMER_REPEAT);
- break;
- }
- }
- }
- if(IsLeft4Dead2)
- {
- iTrigger = CreateEntityByName("func_button_timed");
- DispatchKeyValueVector(iTrigger, "origin", vPos);
- DispatchKeyValue(iTrigger, "use_string", sUseString);
- DispatchKeyValue(iTrigger, "use_time", sTimeOpen);
- DispatchKeyValue(iTrigger, "auto_disable", "1");
- DispatchSpawn(iTrigger);
- ActivateEntity(iTrigger);
- SetEntPropVector(iTrigger, Prop_Send, "m_vecMins", view_as<float>({-225.0, -225.0, -225.0}));
- SetEntPropVector(iTrigger, Prop_Send, "m_vecMaxs", view_as<float>({225.0, 225.0, 225.0}));
- HookSingleEntityOutput(iTrigger, "OnTimeUp", OnTimeUp);
- SetEntityModel(iTrigger, gModeList[2]);
- SetEntityRenderMode(iTrigger, RENDER_NONE);
- TeleportEntity(iTrigger, vPos, NULL_VECTOR, NULL_VECTOR);
- SetVariantString("!activator");
- AcceptEntityInput(iTrigger, "SetParent", entity);
- char sColor[16];
- Format(sColor, sizeof sColor, "255 255 255");
- SetEntProp(entity, Prop_Send, "m_nGlowRange", GetConVarInt(cGlowRange));
- SetEntProp(entity, Prop_Send, "m_iGlowType", 3);
- SetEntProp(entity, Prop_Send, "m_glowColorOverride", GetColor(sColor));
- SetEntProp(iTrigger, Prop_Data, "m_takedamage", 0, 1);
- SetEntProp(entity, Prop_Data, "m_takedamage", 0, 1);
- gIndexCrate[iTrigger] = EntIndexToEntRef(entity);
- }
- else SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage);
- }
- //SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage);
- if(GetConVarInt(cMessages)) PrintToChatAll("\x04[Air] \x03Airdrop \x04fell in the approximate coordinates \x05%.2f %.2f %.2f", vPos[0], vPos[1], vPos[2]);
- }
- public Action tSetGravity(Handle timer, any entity)
- {
- entity = EntRefToEntIndex(entity);
- if(entity != INVALID_ENT_REFERENCE)
- {
- float vSpeed[3], vPos[3], vAng[3], vEndPos[3];
- int iGravity;
- char sColor[12];
- vAng[0] = 89.0;
- Handle hTrace;
- vSpeed[2] = float(GetConVarInt(cParachuteSpeed)) * -1;
- if(GetConVarInt(cCustomModel))
- TeleportEntity(entity, NULL_VECTOR, NULL_VECTOR, vSpeed);
- GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
- hTrace = TR_TraceRayFilterEx(vPos, vAng, CONTENTS_SOLID, RayType_Infinite, TraceDontHitSelf, entity);
- if(TR_DidHit(hTrace))
- {
- TR_GetEndPosition(vEndPos, hTrace);
- float vDistance = GetVectorDistance(vPos, vEndPos);
- if(vDistance < 15)
- {
- if(GetConVarInt(cFlare))
- {
- GetConVarString(cColorFlare, sColor, sizeof sColor);
- vAng[0] = 0.0;
- vPos[0] += 25.0;
- vPos[2] -= 12.0;
- MakeFlare(entity, vAng, vPos, sColor, sColor);
- gFlares[entity] = true;
- }
- if(GetConVarInt(cCustomModel))
- {
- iGravity = EntRefToEntIndex(g_iParachute[entity]);
- if(iGravity != INVALID_ENT_REFERENCE)
- AcceptEntityInput(iGravity, "kill");
- }
- hTimer[entity] = null;
- return Plugin_Stop;
- }
- }
- delete hTrace;
- }
- return Plugin_Continue;
- }
- public bool TraceFilter(int entity, int contentsMask)
- {
- return entity > MaxClients;
- }
- public bool TraceDontHitSelf(int entity, int mask, any data)
- {
- if(entity == data || IsValidEntity(entity))
- {
- return false;
- }
- return true;
- }
- public void OnTimeUp(const char[] output, int caller, int activator, float delay)
- {
- if (activator > 0 && activator <= MaxClients && IsClientInGame(activator))
- {
- int entity, iGravity, iChancesWeapons;
- entity = gIndexCrate[caller];
- if((entity = EntRefToEntIndex(entity)) != INVALID_ENT_REFERENCE)
- {
- if(hTimer[entity] != null)
- {
- delete hTimer[entity];
- }
- if(GetConVarInt(cCustomModel))
- {
- iGravity = EntRefToEntIndex(g_iParachute[entity]);
- if(iGravity != INVALID_ENT_REFERENCE)
- {
- AcceptEntityInput(iGravity, "kill");
- }
- }
- int SupplyItem, OpenedCrate;
- float vPos[3], vAng[3];
- AcceptEntityInput(caller, "kill");
- GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
- GetEntPropVector(entity, Prop_Send, "m_angRotation", vAng);
- OpenedCrate = CreateEntityByName("prop_physics_override");
- DispatchKeyValueVector(OpenedCrate, "origin", vPos);
- DispatchKeyValueVector(OpenedCrate, "angles", vAng);
- SetEntityModel(OpenedCrate, gModeList[2]);
- DispatchSpawn(OpenedCrate);
- AcceptEntityInput(entity, "kill");
- int weapons = MAXLIST;
- while (weapons-- > 0)
- {
- iChancesWeapons = GetRandomInt(1, 100);
- if(iChancesWeapons <= gItemsChances[weapons])
- {
- SupplyItem = CreateEntityByName(gItemsList[weapons]);
- DispatchSpawn(SupplyItem);
- SetEntityModel(SupplyItem, gModelsItemsList[weapons]);
- vPos[2] += 2.5;
- vAng[0] = 0.0; vAng[1] = 90.0; vAng[2] = 0.0;
- TeleportEntity(SupplyItem, vPos, vAng, NULL_VECTOR);
- if(gAmmoList[weapons] != -1)
- SetEntProp(SupplyItem, Prop_Send, "m_iExtraPrimaryAmmo", gAmmoList[weapons], 4);
- }
- }
- for(int i = 0; i <= 4; i++)
- {
- if(gFlares[entity])
- {
- int iFlare = EntRefToEntIndex(g_iFlares[entity][i]);
- if(iFlare != INVALID_ENT_REFERENCE)
- AcceptEntityInput(iFlare, "kill");
- }
- }
- for(int i = 1; i <= MaxClients; i++)
- if(IsClientInGame(i)) PrintToChat(i, "\x04[Air] \x03%N \x04open airdrop", activator);
- Vocalize(activator);
- }
- }
- }
- public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
- {
- if(IsValidEntity(victim) && attacker > 0 && GetClientTeam(attacker) == 2)
- {
- float vPos[3];
- char sModel[126], sWeaponList[360], sWeaponAllowed[36][32];
- int SupplyItem;
- GetEntPropString(victim, Prop_Data, "m_ModelName", sModel, sizeof(sModel));
- GetConVarString(cWeaponList, sWeaponList, sizeof sWeaponList);
- ExplodeString(sWeaponList, ";", sWeaponAllowed, sizeof(sWeaponAllowed), sizeof(sWeaponAllowed[]));
- if(strcmp(sModel, gModeList[3]) == 0)
- {
- AcceptEntityInput(victim, "break");
- GetEntPropVector(victim, Prop_Send, "m_vecOrigin", vPos);
- for(int v; v < GetConVarInt(cCountItems); v++)
- {
- int iInt = GetRandomInt(0, 7);
- SupplyItem = CreateEntityByName(gItemsListL4D1[GetRandomInt(0, 7)]);
- for(int i; i < 8; i++)
- {
- if(strcmp(gItemsListL4D1[iInt], sWeaponAllowed[i]) == 0)
- {
- DispatchSpawn(SupplyItem);
- vPos[2] += 7.0;
- TeleportEntity(SupplyItem, vPos, NULL_VECTOR, NULL_VECTOR);
- }
- }
- }
- }
- }
- }
- int GetColor(char[] sTemp)
- {
- if( StrEqual(sTemp, "") )
- return 0;
- char sColors[3][4];
- int color = ExplodeString(sTemp, " ", sColors, 3, 4);
- if( color != 3 )
- return 0;
- color = StringToInt(sColors[0]);
- color += 256 * StringToInt(sColors[1]);
- color += 65536 * StringToInt(sColors[2]);
- return color;
- }
- //Thanks to Silvers...
- int MakeFlare(int client, float vAngles[3], float vOrigin[3], const char[] sColorL, const char[] sColorS)
- {
- int entity;
- entity = CreateEntityByName("prop_dynamic");
- SetEntityModel(entity, MODEL_FLARE);
- DispatchSpawn(entity);
- TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
- g_iFlares[client][0] = EntIndexToEntRef(entity);
- vOrigin[2] += 15.0;
- entity = MakeLightDynamic(vOrigin, view_as<float>({ 90.0, 0.0, 0.0 }), sColorL, 255);
- vOrigin[2] -= 15.0;
- g_iFlares[client][1] = EntIndexToEntRef(entity);
- // Position particles / smoke
- entity = 0;
- vAngles[1] = GetRandomFloat(1.0, 360.0);
- vAngles[0] = -80.0;
- vOrigin[0] += (1.0 * (Cosine(DegToRad(vAngles[1]))));
- vOrigin[1] += (1.5 * (Sine(DegToRad(vAngles[1]))));
- vOrigin[2] += 1.0;
- // Flare particles
- entity = DisplayParticle(PARTICLE_FLARE, vOrigin, vAngles);
- g_iFlares[client][2] = EntIndexToEntRef(entity);
- // Fuse particles
- entity = DisplayParticle(PARTICLE_FUSE, vOrigin, vAngles);
- g_iFlares[client][3] = EntIndexToEntRef(entity);
- // Smoke
- vAngles[0] = -85.0;
- entity = MakeEnvSteam(vOrigin, vAngles, sColorS, GetConVarInt(cFlareAplha), GetConVarInt(cFlareLenght));
- g_iFlares[client][4] = EntIndexToEntRef(entity);
- PlaySound(g_iFlares[entity][0]);
- }
- //Thanks to Silvers...
- int DisplayParticle(const char[] sParticle, const float vPos[3], const float vAng[3])
- {
- int entity = CreateEntityByName("info_particle_system");
- if( entity != -1 )
- {
- DispatchKeyValue(entity, "effect_name", sParticle);
- DispatchSpawn(entity);
- ActivateEntity(entity);
- AcceptEntityInput(entity, "start");
- TeleportEntity(entity, vPos, vAng, NULL_VECTOR);
- return entity;
- }
- return 0;
- }
- //Thanks to Silvers...
- int MakeEnvSteam(const float vOrigin[3], const float vAngles[3], const char[] sColor, int iAlpha, int iLength)
- {
- int entity = CreateEntityByName("env_steam");
- char sTemp[5];
- DispatchKeyValue(entity, "SpawnFlags", "1");
- DispatchKeyValue(entity, "rendercolor", sColor);
- DispatchKeyValue(entity, "SpreadSpeed", "1");
- DispatchKeyValue(entity, "Speed", "15");
- DispatchKeyValue(entity, "StartSize", "1");
- DispatchKeyValue(entity, "EndSize", "3");
- DispatchKeyValue(entity, "Rate", "10");
- IntToString(iLength, sTemp, sizeof(sTemp));
- DispatchKeyValue(entity, "JetLength", sTemp);
- IntToString(iAlpha, sTemp, sizeof(sTemp));
- DispatchKeyValue(entity, "renderamt", sTemp);
- DispatchKeyValue(entity, "InitialState", "1");
- DispatchKeyValueVector(entity, "origin", vOrigin);
- DispatchKeyValueVector(entity, "angles", vAngles);
- //TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
- DispatchSpawn(entity);
- AcceptEntityInput(entity, "TurnOn");
- return entity;
- }
- void PlaySound(int entity)
- {
- EmitSoundToAll(SOUND_CRACKLE, entity, SNDCHAN_AUTO, SNDLEVEL_DISHWASHER, SND_SHOULDPAUSE, SNDVOL_NORMAL, SNDPITCH_HIGH, -1, NULL_VECTOR, NULL_VECTOR);
- }
- int MakeLightDynamic(const float vOrigin[3], const float vAngles[3], const char[] sColor, int iDist)
- {
- int entity = CreateEntityByName("light_dynamic");
- char sTemp[16];
- Format(sTemp, sizeof(sTemp), "6");
- DispatchKeyValue(entity, "style", sTemp);
- Format(sTemp, sizeof(sTemp), "%s 255", sColor);
- DispatchKeyValue(entity, "_light", sTemp);
- DispatchKeyValue(entity, "brightness", "1");
- DispatchKeyValueFloat(entity, "spotlight_radius", 32.0);
- DispatchKeyValueFloat(entity, "distance", float(iDist));
- DispatchSpawn(entity);
- AcceptEntityInput(entity, "TurnOn");
- TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
- return entity;
- }
- //Thanks to Silvers
- static const char g_sVocalize[][] =
- {
- "scenes/Coach/dlc1_c6m1_alarmdoor01.vcd",
- "scenes/Coach/dlc1_golfclub07.vcd",
- "scenes/Coach/thanks02.vcd",
- "scenes/Coach/reactionnegative02.vcd",
- "scenes/Coach/no02.vcd",
- "scenes/Gambler/dlc1_c6m1_alarmdoor02.vcd",
- "scenes/Gambler/dlc1_c6m1_alarmdoor01.vcd",
- "scenes/Gambler/dlc1_c6m2_phase2jumpinwater02.vcd",
- "scenes/Mechanic/dlc1_c6m3_finalebridgerun02.vcd",
- "scenes/Mechanic/dlc1_m6007.vcd",
- "scenes/Producer/heardspecialc104.vcd",
- "scenes/Producer/hurrah01.vcd",
- /*
- "left4dead2_dlc1/scenes/teengirl/laughter01.vcd",
- "left4dead2_dlc1/scenes/teengirl/nicejob05.vcd",
- "left4dead2_dlc1/scenes/teengirl/playersuggesthealthspecific04.vcd.vcd",
- "left4dead2_dlc2/scenes/biker/dlc2birdhate01.vcd",
- "left4dead2_dlc3/scenes/biker/c6dlc3otherboats09.vcd",
- "scenes/biker/namebill02.vcd",
- "left4dead2_dlc1/scenes/biker/dlc1_killfinaltank01.vcd",
- "left4dead2_dlc2/manager/dlc2forlease01.vcd"
- */
- };
- //Thanks to Silvers
- void Vocalize(int client)
- {
- if(GetRandomInt(1, 100) > GetConVarInt(cVocalize))
- return;
- char sTemp[64];
- GetEntPropString(client, Prop_Data, "m_ModelName", sTemp, 64);
- int random;
- if( sTemp[26] == 'c' ) // c = Coach
- random = GetRandomInt(0, 4);
- else if( sTemp[26] == 'g' ) // g = Gambler
- random = GetRandomInt(5, 7);
- else if( sTemp[26] == 'm' && sTemp[27] == 'e' ) // me = Mechanic
- random = GetRandomInt(8, 9);
- else if( sTemp[26] == 'p' ) // p = Producer
- random = GetRandomInt(10, 11);
- else
- return;
- /*
- else if(StrContains(sTemp, "teengirl") > 0)
- random = GetRandomInt(12, 14);
- else if(StrContains(sTemp, "biker") > 0)
- random = GetRandomInt(15, 18);
- else if(StrContains(sTemp, "manager") > 0)
- random = 19;
- else
- return;
- */
- int entity = CreateEntityByName("instanced_scripted_scene");
- DispatchKeyValue(entity, "SceneFile", g_sVocalize[random]);
- DispatchSpawn(entity);
- SetEntPropEnt(entity, Prop_Data, "m_hOwner", client);
- ActivateEntity(entity);
- AcceptEntityInput(entity, "Start", client, client);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement