Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include sdkhooks
- #pragma tabsize 0
- float iPropaneSurvivors = 50000.0
- float iPropaneTank = 30000.0
- float iPropaneCharger = 60000.0
- float iPropaneInfected = 5000.0
- float iRadiusSurvivors = 400.0
- float iRadiusTank = 200.0
- float iRadiusCharger = 500.0
- float iRadiusInfected = 500.0
- float iRadiusSurvivorsflint = 400.0
- float iRadiusTankflint = 200.0
- float iRadiusChargerflint = 500.0
- float iRadiusInfectedflint = 500.0
- Handle sdkCallPushPlayer = null;
- public OnPluginStart()
- {
- Handle GameConf = LoadGameConfigFile("StaggerInfected");
- StartPrepSDKCall(SDKCall_Player);
- PrepSDKCall_SetFromConf(GameConf, SDKConf_Signature, "CTerrorPlayer_OnStaggered");
- PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer);
- PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
- sdkCallPushPlayer = EndPrepSDKCall();
- }
- public void OnEntityDestroyed(int entity)
- {
- if (IsValidEntity(entity) && IsValidEdict(entity))
- {
- char classname[128];
- GetEdictClassname(entity, classname, 128);
- PrintToChatAll("%s", classname)
- if (StrEqual(classname, "weapon_propanetank", false))
- {
- float bPos[3]
- GetEntPropVector(entity, Prop_Send, "m_vecOrigin", bPos);
- for (new i = 1; i <= MaxClients; i++)
- {
- if(IsValid(i, 3) && GetEntProp(i, Prop_Send, "m_zombieClass") == 6)
- {
- float vPos[3]
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
- if (!IsVisibleTo(bPos, vPos)) continue;
- float fTargetDistance = GetVectorDistance(bPos, vPos);
- if(fTargetDistance < iRadiusCharger)
- {
- float vTransit = iRadiusCharger - fTargetDistance
- float vForward = iRadiusCharger / vTransit
- int iTotal = RoundToCeil(iPropaneCharger / (vForward * vForward * vForward));
- ForceDamageEntity(i, iTotal, i)
- }
- if(fTargetDistance < iRadiusChargerflint)
- {
- SDKCall(sdkCallPushPlayer, i, entity, bPos);
- }
- }
- else if(IsValid(i, 3) && GetEntProp(i, Prop_Send, "m_zombieClass") == 8)
- {
- float vPos[3]
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
- if (!IsVisibleTo(bPos, vPos)) continue;
- float fTargetDistance = GetVectorDistance(bPos, vPos);
- if(fTargetDistance < iRadiusTank)
- {
- float vTransit = iRadiusTank - fTargetDistance
- float vForward = iRadiusTank / vTransit
- int iTotal = RoundToCeil(iPropaneTank / (vForward * vForward * vForward));
- ForceDamageEntity(i, iTotal, i)
- }
- if(fTargetDistance < iRadiusTankflint)
- {
- SDKCall(sdkCallPushPlayer, i, entity, bPos);
- }
- }
- else if(IsValid(i, 3) && GetEntProp(i, Prop_Send, "m_zombieClass") < 6)
- {
- float vPos[3]
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
- if (!IsVisibleTo(bPos, vPos)) continue;
- float fTargetDistance = GetVectorDistance(bPos, vPos);
- if(fTargetDistance < iRadiusInfected)
- {
- float vTransit = iRadiusInfected - fTargetDistance
- float vForward = iRadiusInfected / vTransit
- int iTotal = RoundToCeil(iPropaneInfected / (vForward * vForward * vForward));
- ForceDamageEntity(i, iTotal, i)
- }
- if(fTargetDistance < iRadiusInfectedflint)
- {
- SDKCall(sdkCallPushPlayer, i, entity, bPos);
- }
- }
- else if(IsValid(i, 2) && GetEntProp(i, Prop_Send, "m_zombieClass") == 9)
- {
- float vPos[3]
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", vPos);
- if (!IsVisibleTo(bPos, vPos)) continue;
- float fTargetDistance = GetVectorDistance(bPos, vPos);
- if(fTargetDistance < iRadiusSurvivors)
- {
- float vTransit = iRadiusSurvivors - fTargetDistance
- float vForward = iRadiusSurvivors / vTransit
- int iTotal = RoundToCeil(iPropaneSurvivors / (vForward * vForward * vForward));
- ForceDamageEntity(i, iTotal, i)
- }
- if(fTargetDistance < iRadiusSurvivorsflint)
- {
- SDKCall(sdkCallPushPlayer, i, entity, bPos);
- }
- }
- }
- }
- }
- }
- stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
- {
- float victim_origin[3];
- char rupture[32];
- char damage_victim[32];
- IntToString(damage, rupture, sizeof(rupture));
- Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
- GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
- int entity = CreateEntityByName("point_hurt");
- DispatchKeyValue(victim, "targetname", damage_victim);
- DispatchKeyValue(entity, "DamageTarget", damage_victim);
- DispatchKeyValue(entity, "Damage", rupture);
- DispatchSpawn(entity);
- TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
- AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
- DispatchKeyValue(entity, "classname", "point_hurt");
- DispatchKeyValue(victim, "targetname", "null");
- AcceptEntityInput(entity, "Kill");
- }
- static bool IsVisibleTo(float position[3], float targetposition[3])
- {
- float vAngles[3], vLookAt[3];
- MakeVectorFromPoints(position, targetposition, vLookAt); // compute vector from start to target
- GetVectorAngles(vLookAt, vAngles); // get angles from vector for trace
- // execute Trace
- 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); // retrieve our trace endpoint
- if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))
- {
- isVisible = true; // if trace ray length plus tolerance equal or bigger absolute distance, you hit the target
- }
- }
- return isVisible;
- }
- public bool _TraceFilter(int entity, int contentsMask)
- {
- if (!entity || entity <= MaxClients || !IsValidEntity(entity)) // dont let WORLD, or invalid entities be hit
- {
- return false;
- }
- return true;
- }
- stock bool:IsValid(int client, int team)
- {
- if ( client < 1 || client > MaxClients ) return false;
- if ( !IsClientConnected( client )) return false;
- if ( !IsClientInGame( client )) return false;
- if ( GetClientTeam( client ) != team ) return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement