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 MAXLIST 26
- char sMap[56];
- int gIndexCrate[2048+1];
- ConVar cTankChance, cDropType, cCountItems, cCountAirdrops, cTimeOpen, cUseString, cParahute;
- bool IsLeft4Dead2;
- public Plugin myinfo =
- {
- name = "[L4D2] Airdrop",
- author = "BHaType",
- description = "Admin can call airdrop.",
- version = "0.3",
- url = "https://www.sourcemod.net/plugins.php?cat=0&mod=-1&title=&author=BHaType&description=&search=1"
- }
- static const char gModeList[5][] =
- {
- "models/props_vehicles/c130.mdl",
- "models/props_crates/supply_crate02.mdl",
- "models/props_crates/supply_crate02_gib1.mdl",
- "models/props_junk/wood_crate001a.mdl",
- "models/props_swamp/parachute01.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 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
- };
- public void OnPluginStart()
- {
- GetCurrentMap(sMap, sizeof sMap);
- char sEngine[24];
- GetGameFolderName(sEngine, sizeof(sEngine));
- if (StrEqual(sEngine, "left4dead2", false))
- IsLeft4Dead2 = true;
- RegAdminCmd("sm_ac130", CallAirdrop, ADMFLAG_ROOT);
- //HookEvent("tank_spawn", EventTank);
- HookEvent("tank_killed", EventTank);
- cParahute = CreateConVar("airdrop_parachute", "1", "Будет ли парашут у ящиков", FCVAR_NONE);
- cUseString = CreateConVar("airdrop_open_string", "Hehe boi", "Что будет написано при открытии ящика", FCVAR_NONE);
- cTimeOpen = CreateConVar("airdrop_open_time", "2.5", "Время открытия", FCVAR_NONE);
- cCountAirdrops = CreateConVar("airdrop_count_airdrops", "3", "Кол-во ящиков", FCVAR_NONE);
- cCountItems = CreateConVar("airdrop_count_items", "6", "Кол-во предметов из ящиков", FCVAR_NONE);
- cDropType = CreateConVar("airdrop_type_drop", "1", "Разные предметы будут выпадать либо нет(Ставить 1, только если квар \"airdrop count items\" > 1)", FCVAR_NONE);
- cTankChance = CreateConVar("airdrop_tank_chance", "50", "Шанс аирдропа при смерти танка", FCVAR_NONE);
- AutoExecConfig(true, "Airdrop");
- }
- public Action EventTank(Event event, const char[] name, bool dontbroadcast)
- {
- if(GetRandomInt(1, 100) <= GetConVarInt(cTankChance))
- {
- int client = GetClientOfUserId(event.GetInt("userid"));
- AirPlane(client);
- }
- }
- public void OnMapStart()
- {
- PrecacheSound(SOUND_PASS1, true);
- for (int i = 0; i < 5; i++)
- PrecacheModel(gModeList[i], true);
- for (int i = 0; i < MAXLIST - 1; i++)
- PrecacheModel(gModelsItemsList[i], true);
- }
- public Action CallAirdrop(int client, int args)
- {
- AirPlane(client);
- PrintToChatAll("\x04[Air] \x03%N \x04вызвал аирдроп", client);
- }
- stock void AirPlane(int client)
- {
- float vPos[3], vAng[3], direction;
- GetEntPropVector(client, Prop_Send, "m_vecOrigin", vPos);
- vPos[2] += 64;
- GetEntPropVector(client, Prop_Send, "m_angRotation", vAng);
- direction = vAng[1];
- float vSkybox[3];
- vAng[0] = 0.0;
- vAng[1] = direction;
- vAng[2] = 0.0;
- GetEntPropVector(0, Prop_Data, "m_WorldMaxs", vSkybox);
- int entity = CreateEntityByName("prop_dynamic_override");
- DispatchKeyValue(entity, "targetname", "ac130");
- DispatchKeyValue(entity, "disableshadows", "1");
- DispatchKeyValue(entity, "model", gModeList[0]);
- DispatchSpawn(entity);
- float height = vPos[2] + 1150.0;
- if( height > vSkybox[2] - 200 )
- vPos[2] = vSkybox[2] - 200;
- else
- vPos[2] = height;
- TeleportEntity(entity, vPos, vAng, 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(7.0, TimerDropAirDrop, EntIndexToEntRef(entity));
- }
- 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[16], sTimeOpen[16];
- int entity, iTrigger, parachute, iGravity;
- float vAng[3], vEndPos[3], vDistance, fTime;
- vAng[0] = 89.0; vAng[1] = 0.0; vAng[2] = 0.0;
- DataPack dPack;
- GetConVarString(cUseString, sUseString, sizeof sUseString);
- GetConVarString(cTimeOpen, sTimeOpen, sizeof sTimeOpen);
- if(strcmp(sMap, "c5m1_waterfront") == 0)
- vPos[2] -= 475.0;
- for(int i = 0; i < GetConVarInt(cCountAirdrops); i++)
- {
- if(GetConVarInt(cParahute))
- {
- vPos[1] += GetRandomInt(-100, 100);
- vPos[0] += GetRandomInt(-100, 100);
- }
- 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(cParahute))
- {
- parachute = CreateEntityByName("prop_dynamic_override");
- DispatchKeyValue(parachute, "targetname", "SupplyDrop");
- DispatchKeyValueVector(parachute, "origin", vPos);
- SetEntityModel(parachute, gModeList[4]);
- DispatchSpawn(parachute);
- SetEntPropFloat(entity, Prop_Data, "m_flGravity", 0.1);
- SetVariantString("!activator");
- AcceptEntityInput(parachute, "SetParent", entity);
- iGravity = CreateEntityByName("tank_rock");
- DispatchSpawn(iGravity);
- ActivateEntity(iGravity);
- SetEntityRenderMode(iGravity, RENDER_NONE);
- SetEntityGravity(iGravity, 0.05);
- TeleportEntity(iGravity, vPos, NULL_VECTOR, NULL_VECTOR);
- SetVariantString("!activator");
- AcceptEntityInput(entity, "SetParent", iGravity);
- Handle hTrace = TR_TraceRayFilterEx(vPos, vAng, MASK_SHOT, RayType_Infinite, TraceDontHitSelf, entity);
- if(TR_DidHit(hTrace))
- {
- TR_GetEndPosition(vEndPos, hTrace);
- vDistance = GetVectorDistance(vPos, vEndPos);
- fTime = vDistance / 75.0;
- PrintToChatAll("EndPos %.4f", vEndPos);
- PrintToChatAll("Distance %.4f", vDistance);
- PrintToChatAll("ftime %.4f", fTime);
- CreateDataTimer(fTime, tToDelete, dPack, TIMER_DATA_HNDL_CLOSE);
- dPack.WriteCell(EntRefToEntIndex(parachute));
- dPack.WriteCell(EntRefToEntIndex(iGravity));
- dPack.WriteCell(EntRefToEntIndex(entity));
- }
- }
- 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>({-75.0, -75.0, -75.0}));
- SetEntPropVector(iTrigger, Prop_Send, "m_vecMaxs", view_as<float>({75.0, 75.0, 75.0}));
- HookSingleEntityOutput(iTrigger, "OnTimeUp", OnTimeUp);
- SetEntityModel(iTrigger, gModeList[2]);
- SetEntityRenderMode(iTrigger, RENDER_NONE);
- SetVariantString("!activator");
- AcceptEntityInput(iTrigger, "SetParent", entity);
- char sColor[16];
- Format(sColor, sizeof sColor, "255 255 255");
- SetEntProp(entity, Prop_Send, "m_nGlowRange", 500);
- 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);
- PrintToChatAll("\x04[Air] \x03Аирдроп(ы) \x04упал(и) в примерных координатах \x05%.2f %.2f %.2f", vPos[0], vPos[1], vPos[2]);
- }
- public Action tToDelete(Handle timer, DataPack dPack)
- {
- ResetPack(dPack);
- int parachute = EntRefToEntIndex(ReadPackCell(dPack));
- int iGravity = EntRefToEntIndex(ReadPackCell(dPack));
- int entity = EntRefToEntIndex(ReadPackCell(dPack));
- if(parachute != INVALID_ENT_REFERENCE)
- {
- AcceptEntityInput(parachute, "kill");
- }
- else if(entity != INVALID_ENT_REFERENCE)
- {
- SetVariantString("!activator");
- AcceptEntityInput(entity, "SetParent", 0);
- }
- else if(iGravity != INVALID_ENT_REFERENCE)
- {
- SetVariantString("!activator");
- AcceptEntityInput(iGravity, "SetParent", 0);
- AcceptEntityInput(iGravity, "kill");
- }
- }
- public bool TraceDontHitSelf(int entity, int mask, any data)
- {
- if(entity == data)
- {
- return false;
- }
- return true;
- }
- public void OnTimeUp(const char[] output, int caller, int activator, float delay)
- {
- if (activator > 0 && IsClientInGame(activator))
- {
- int entity = gIndexCrate[caller];
- if((entity = EntRefToEntIndex(entity)) != INVALID_ENT_REFERENCE)
- {
- int SupplyItem;
- float vPos[3], vAng[3];
- AcceptEntityInput(caller, "kill");
- GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vPos);
- GetEntPropVector(entity, Prop_Send, "m_angRotation", vAng);
- int OpenedCrate = CreateEntityByName("prop_physics_override");
- DispatchKeyValueVector(OpenedCrate, "origin", vPos);
- DispatchKeyValueVector(OpenedCrate, "angles", vAng);
- SetEntityModel(OpenedCrate, gModeList[2]);
- DispatchSpawn(OpenedCrate);
- int RandomIntType = GetRandomInt(0, 24);
- AcceptEntityInput(entity, "kill");
- for(int i = 0; i <= GetConVarInt(cCountItems); i++)
- {
- if(GetConVarInt(cDropType) != 1) SupplyItem = CreateEntityByName(gItemsList[RandomIntType]);
- else
- {
- if(IsLeft4Dead2) RandomIntType = GetRandomInt(0, 24);
- else RandomIntType = GetRandomInt(0, 8);
- SupplyItem = CreateEntityByName(gItemsList[RandomIntType]);
- }
- if(IsValidEntity(SupplyItem))
- {
- DispatchSpawn(SupplyItem);
- SetEntityModel(SupplyItem, gModelsItemsList[RandomIntType]);
- vPos[2] += 2.5;
- vAng[0] = 0.0;
- vAng[1] = 90.0;
- vAng[2] = 0.0;
- TeleportEntity(SupplyItem, vPos, vAng, NULL_VECTOR);
- if(gAmmoList[RandomIntType] != -1)
- SetEntProp(SupplyItem, Prop_Send, "m_iExtraPrimaryAmmo", gAmmoList[RandomIntType], 4);
- }
- }
- PrintToChatAll("\x04[Air] \x03%N \x04открыл аирдроп", 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];
- int SupplyItem;
- GetEntPropString(victim, Prop_Data, "m_ModelName", sModel, sizeof(sModel));
- if(strcmp(sModel, gModeList[3]) == 0)
- {
- AcceptEntityInput(victim, "break");
- GetEntPropVector(victim, Prop_Send, "m_vecOrigin", vPos);
- for(int v = 0; v < GetConVarInt(cCountItems); v++)
- {
- int iInt = GetRandomInt(0, 7);
- if(GetConVarInt(cDropType) == 1) SupplyItem = CreateEntityByName(gItemsListL4D1[GetRandomInt(0, 7)]);
- else CreateEntityByName(gItemsListL4D1[iInt]);
- DispatchSpawn(SupplyItem);
- vPos[2] += 5.0;
- TeleportEntity(SupplyItem, vPos, NULL_VECTOR, NULL_VECTOR);
- }
- PrintToChatAll("\x04[Air] \x03%N \x04вскрыл аирдроп", attacker);
- }
- }
- }
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement