Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #pragma newdecls required
- #include <sdktools>
- #include <sdkhooks>
- Handle sdkSetAttack;
- float vRadius[18];
- int iChance = 2;
- public void OnPluginStart()
- {
- Handle hGameConf = LoadGameConfigFile("SetAttackSurvivorCommons");
- StartPrepSDKCall(SDKCall_Entity);
- if( PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "SetAttackToSurvivors") == false )
- SetFailState("Could not load the \"SetAttackToSurvivors\" gamedata offset.");
- sdkSetAttack = EndPrepSDKCall();
- SetFuse();
- HookEvent("bullet_impact", Bullet);
- }
- public void SetFuse()
- {
- vRadius[0] = 1650.0;
- vRadius[1] = 660.0;
- vRadius[2] = 880.0;
- vRadius[3] = 1980.0;
- vRadius[4] = 1650.0;
- vRadius[5] = 1100.0;
- vRadius[6] = 1100.0;
- vRadius[7] = 1100.0;
- vRadius[8] = 1320.0;
- vRadius[9] = 1100.0;
- vRadius[10] = 1540.0;
- vRadius[11] = 1540.0;
- vRadius[12] = 880.0;
- vRadius[13] = 880.0;
- vRadius[14] = 880.0;
- vRadius[15] = 1870.0;
- vRadius[16] = 1320.0;
- vRadius[17] = 1320.0;
- }
- public Action Bullet(Handle event, const char[] name, bool dontbroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "userid"));
- int weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
- if(IsValidEntity(weapon))
- {
- char weaponname[36];
- GetEntityClassname(weapon, weaponname, sizeof(weaponname));
- if(bIsSurvivor(client))
- {
- for(int i = 33; i < 2049; i++)
- {
- float vPos[3], vTargetPos[3];
- GetClientEyePosition(client, vPos);
- if(strcmp(weaponname, "weapon_autoshotgun") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[0])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[0])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_hunting_rifle") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[1])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[1])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_pistol") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[2])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[2])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_pistol_magnum") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[3])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[3])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_pumpshotgun") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[4])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[4])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_rifle") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[5])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[5])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_rifle_ak47") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[6])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[6])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_rifle_desert") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[7])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[7])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_rifle_m60") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[8])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[8])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_rifle_sg552") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[8])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[8])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_shotgun_chrome") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[9])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[9])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_shotgun_spas") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[9])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[9])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_smg") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[10])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[10])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_smg_mp5") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[11])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[11])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_smg_silenced") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[12])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[12])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_sniper_awp") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[13])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[13])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_sniper_military") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[14])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[14])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- else if(strcmp(weaponname, "weapon_sniper_scout") == 0)
- {
- if(IsCommonInfected(i))
- {
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
- float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
- if(IsVisibleTo(vPos, vTargetPos))
- {
- if(fTargetDistance < vRadius[15])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- else
- {
- if(GetRandomInt(0, 100) <= iChance)
- {
- if(fTargetDistance < vRadius[15])
- {
- SDKCall(sdkSetAttack, i);
- }
- }
- }
- }
- }
- }
- }
- }
- return Plugin_Continue;
- }
- static bool IsVisibleTo(float position[3], float targetposition[3])
- {
- float vAngles[3], vLookAt[3];
- MakeVectorFromPoints(position, targetposition, vLookAt);
- GetVectorAngles(vLookAt, vAngles);
- Handle trace = TR_TraceRayFilterEx(position, vAngles, MASK_SHOT, RayType_Infinite, _TraceFilter);
- bool isVisible = false;
- if (TR_DidHit(trace))
- {
- float vStart[3];
- TR_GetEndPosition(vStart, trace);
- if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))
- {
- isVisible = true;
- }
- }
- return isVisible;
- }
- public bool _TraceFilter(int entity, int contentsMask)
- {
- if (IsValidEntity(entity))
- {
- return false;
- }
- return true;
- }
- stock bool bIsSurvivor(int client)
- {
- return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
- }
- stock bool IsCommonInfected(int entity)
- {
- if (entity > 33 && IsValidEntity(entity) && IsValidEdict(entity))
- {
- char entType[64];
- GetEdictClassname(entity, entType, sizeof(entType));
- return StrEqual(entType, "infected");
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement