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 MAXPROJECTILES 64
- ConVar cDamage, cRange, cDistance, cSpeed, cCount, cColor, cDistanceLight;
- float g_iDamage, g_iRange, g_iDistance, g_iSpeed;
- Handle g_hSpitVelocity;
- int g_iVelocity, g_iCount, g_iEntities[MAXPLAYERS + 1][MAXPROJECTILES], g_iOwner[2048 + 1];
- public Plugin myinfo =
- {
- name = "[L4D2] Spitter",
- author = "BHaType",
- description = "spitter",
- version = "0.0.1",
- url = "N/A"
- }
- public void OnPluginStart()
- {
- cDamage = CreateConVar("magic_spitter_damage" , "5.0" , "Number of damage" , FCVAR_NONE);
- cRange = CreateConVar("magic_spitter_range" , "60.0" , "Range of hit" , FCVAR_NONE);
- cDistance = CreateConVar("magic_spitter_distance" , "950.0" , "Distance of detect" , FCVAR_NONE);
- cSpeed = CreateConVar("magic_spitter_speed" , "5.5" , "Speed of magic items" , FCVAR_NONE);
- cCount = CreateConVar("magic_spitter_count" , "12" , "Count of magic items" , FCVAR_NONE);
- cColor = CreateConVar("magic_spitter_color" , "25 255 25" , "Color of magic items" , FCVAR_NONE);
- cDistanceLight = CreateConVar("magic_spitter_color" , "250" , "Distance of light magic items" , FCVAR_NONE);
- g_iDamage = cDamage.FloatValue;
- g_iRange = cRange.FloatValue;
- g_iDistance = cDistance.FloatValue;
- g_iSpeed = cSpeed.FloatValue;
- g_iCount = cCount.IntValue;
- cDamage.AddChangeHook(IntsCvar);
- cRange.AddChangeHook(IntsCvar);
- cDistance.AddChangeHook(IntsCvar);
- cSpeed.AddChangeHook(IntsCvar);
- cCount.AddChangeHook(IntsCvar);
- g_iVelocity = FindSendPropInfo("CBasePlayer", "m_vecVelocity[0]");
- HookEvent("player_death", eDeath);
- HookEvent("ability_use", eAbility);
- g_hSpitVelocity = FindConVar("z_spit_velocity");
- AutoExecConfig(true, "spitter_aimbot");
- }
- public void IntsCvar(ConVar convar, const char[] oldValue, const char[] newValue)
- {
- g_iDamage = cDamage.FloatValue;
- g_iRange = cRange.FloatValue;
- g_iDistance = cDistance.FloatValue;
- g_iSpeed = cSpeed.FloatValue;
- g_iCount = cCount.IntValue;
- }
- public void eAbility(Event event, const char[] name, bool dontBroadcast)
- {
- int client;
- client = GetClientOfUserId(event.GetInt("userid"));
- if (!client || !IsClientInGame(client)) return;
- if(GetEntProp(client, Prop_Send, "m_zombieClass") == 4)
- {
- float vPos[3], vAng[3];
- char sColor[16];
- GetClientEyeAngles(client, vAng);
- GetClientEyePosition(client, vPos);
- GetAngleVectors(vAng, vAng, NULL_VECTOR, NULL_VECTOR);
- NormalizeVector(vAng, vAng);
- ScaleVector(vAng, GetConVarFloat(g_hSpitVelocity) * 0.45);
- cColor.GetString(sColor, sizeof sColor);
- for(int l; l < g_iCount; l++)
- {
- int weapon = CreateEntityByName("spitter_projectile");
- if(IsValidEntity(weapon))
- {
- vAng[0] += GetRandomFloat(-60.0, 60.0);
- vAng[1] += GetRandomFloat(-60.0, 60.0);
- vAng[2] += GetRandomFloat(-60.0, 60.0);
- vPos[0] += GetRandomFloat(-20.0, 20.0);
- vPos[1] += GetRandomFloat(-20.0, 20.0);
- vPos[2] += GetRandomFloat(-20.0, 20.0);
- DispatchSpawn(weapon);
- SetEntityGravity(weapon, 0.01);
- MakeLightDynamic(vPos, vAng, sColor, GetConVarInt(cDistanceLight), weapon);
- SetEntProp(weapon, Prop_Send, "m_nSolidType", 0);
- g_iOwner[weapon] = client;
- for(int i; i < MAXPROJECTILES; i++)
- {
- if(EntRefToEntIndex(g_iEntities[client][i]) == INVALID_ENT_REFERENCE || EntRefToEntIndex(g_iEntities[client][i]) == 0)
- {
- g_iEntities[client][i] = EntIndexToEntRef(weapon);
- break;
- }
- }
- CreateTimer(0.1, PreThink, EntIndexToEntRef(weapon), TIMER_REPEAT);
- TeleportEntity(weapon, vPos, NULL_VECTOR, vAng);
- }
- else
- AcceptEntityInput(weapon, "kill");
- }
- }
- }
- public void eDeath (Event event, const char[] name, bool dontbroadcast)
- {
- int client = GetClientOfUserId(event.GetInt("userid"));
- if(client > 0 && client <= MaxClients)
- {
- if(GetEntProp(client, Prop_Send, "m_zombieClass") == 4)
- {
- int entity;
- for(int i; i < MAXPROJECTILES; i++)
- {
- if((entity = EntRefToEntIndex(g_iEntities[client][i])) != INVALID_ENT_REFERENCE && IsValidEntity(entity) && entity > MaxClients)
- AcceptEntityInput(entity, "kill");
- }
- }
- }
- }
- public Action PreThink (Handle timer, int index)
- {
- index = EntRefToEntIndex(index);
- if(index != INVALID_ENT_REFERENCE && IsValidEntity(index))
- Tracering(index, g_iOwner[index]);
- else
- return Plugin_Stop;
- return Plugin_Continue;
- }
- void Tracering(int iEnt, int index)
- {
- float vPos[3], vVel[3], flDistance;
- GetEntPropVector(iEnt, Prop_Send, "m_vecOrigin", vPos);
- GetEntDataVector(iEnt, g_iVelocity, vVel);
- float vLenght = GetVectorLength(vVel);
- NormalizeVector(vVel, vVel);
- int client = lucker(iEnt);
- if(client == -1)
- client = index;
- if(client > 0 && IsValidEntity(client))
- {
- float vEnemy[3], vVelEnemy[3], vDir[3], doubleVel[3];
- GetClientEyePosition(client, vEnemy);
- GetEntDataVector(client, g_iVelocity, vVelEnemy);
- flDistance = GetVectorDistance(vPos, vEnemy);
- if(flDistance <= g_iRange && client != index)
- {
- SDKHooks_TakeDamage(client, iEnt, iEnt, g_iDamage, 1);
- AcceptEntityInput(iEnt, "kill");
- }
- SubtractVectors(vEnemy, vPos, vDir);
- NormalizeVector(vDir, vDir);
- ScaleVector(vDir, 0.5);
- AddVectors(vVel, vDir, doubleVel);
- NormalizeVector(doubleVel, doubleVel);
- ScaleVector(doubleVel, vLenght + g_iSpeed);
- TeleportEntity(iEnt, NULL_VECTOR, NULL_VECTOR, doubleVel);
- }
- }
- int MakeLightDynamic(const float vOrigin[3], const float vAngles[3], const char[] sColor, int iDist, int parent)
- {
- 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));
- TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
- DispatchSpawn(entity);
- AcceptEntityInput(entity, "TurnOn");
- SetVariantString("!activator");
- AcceptEntityInput(entity, "SetParent", parent);
- TeleportEntity(entity, view_as<float>({0, 0, 0}), NULL_VECTOR, NULL_VECTOR);
- return entity;
- }
- int lucker(int index)
- {
- float vPos[3], vPosEntity[3], vDistance = 100000.0, flDistance;
- int count = -1;
- GetEntPropVector(index, Prop_Send, "m_vecOrigin", vPos);
- for(int i = 1; i <= MaxClients; i++)
- {
- if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i) && IsVisibleTo(i, index))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPosEntity);
- flDistance = GetVectorDistance(vPosEntity, vPos);
- if(flDistance < vDistance && flDistance <= g_iDistance)
- {
- vDistance = flDistance;
- count = i;
- }
- }
- }
- return count;
- }
- static bool IsVisibleTo(int client, int entity)
- {
- float vAngles[3], vOrigin[3], vEnt[3], vLookAt[3];
- GetClientEyePosition(client, vOrigin);
- GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vEnt);
- vEnt[2] += 64.0;
- MakeVectorFromPoints(vOrigin, vEnt, vLookAt);
- GetVectorAngles(vLookAt, vAngles);
- Handle trace = TR_TraceRayFilterEx(vOrigin, vAngles, MASK_SHOT, RayType_Infinite, TraceFilter, entity);
- bool isVisible = false;
- if (TR_DidHit(trace))
- {
- float vStart[3];
- TR_GetEndPosition(vStart, trace);
- if ((GetVectorDistance(vOrigin, vStart, false) + 25.0) >= GetVectorDistance(vOrigin, vEnt))
- {
- isVisible = true;
- }
- }
- delete trace;
- return isVisible;
- }
- public bool TraceFilter(int entity, int mask, any data)
- {
- if(entity == data)
- return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement