Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include sdktools
- #include sdkhooks
- #pragma semicolon 1
- #pragma newdecls required
- #define TEAM_SURVIVORS 2
- #define TEAM_INFECTED 3
- Handle distance, Fling, FlingDamage;
- Handle sdkCallPushPlayer = INVALID_HANDLE;
- Handle GameConf = INVALID_HANDLE;
- public void OnPluginStart()
- {
- distance = CreateConVar("sv_rang_rock_stun", "400.0", "", FCVAR_NONE);
- Fling = CreateConVar("sv_power_rock_of_fling", "450.0", "", FCVAR_NONE);
- FlingDamage = CreateConVar("sv_rock_damage_fling", "1", "", FCVAR_NONE);
- GameConf = LoadGameConfigFile("l4d2_detonationforce");
- StartPrepSDKCall(SDKCall_Player);
- PrepSDKCall_SetFromConf(GameConf, SDKConf_Signature, "CTerrorPlayer_Fling");
- PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
- PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
- PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
- PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
- sdkCallPushPlayer = EndPrepSDKCall();
- CloseHandle(GameConf);
- }
- public void OnEntityDestroyed(int entity)
- {
- if(IsValidEntity(entity) && IsValidEdict(entity))
- {
- char g_classname[20];
- GetEdictClassname(entity, g_classname, 20);
- if(StrEqual(g_classname, "tank_rock", true) && GetEntProp(entity, Prop_Send, "m_iTeamNum") >= 0)
- {
- for(int i = 1; i <= MaxClients; ++i)
- {
- if(bIsSurvivor(i))
- {
- float fDamagerPos[3], fDangerPos[3];
- GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fDamagerPos);
- GetEntPropVector(i, Prop_Send, "m_vecOrigin", fDangerPos);
- float fTargetDistance = GetVectorDistance(fDamagerPos, fDangerPos);
- if (fTargetDistance > GetConVarFloat(distance)) continue;
- int iCurrentWeapon = GetEntPropEnt(i, Prop_Send, "m_hActiveWeapon");
- if(IsValidEntity(iCurrentWeapon)) SDKCallWeaponDrop(i, iCurrentWeapon);
- Fly(entity, i, GetConVarFloat(Fling));
- DamageEffect(i, GetConVarInt(FlingDamage));
- }
- }
- }
- }
- }
- public int Fly(int explosion, int target, float power)
- {
- if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))
- return;
- float targetPos[3], explosionPos[3], traceVec[3], resultingFling[3];
- GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);
- GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
- float fDistance = GetVectorDistance(targetPos,explosionPos);
- float iOne = GetConVarInt(distance) - fDistance;
- float vForward = GetConVarInt(distance) / iOne;
- power = GetConVarInt(Fling) / (vForward * vForward * vForward);
- if(power < 1) return;
- MakeVectorFromPoints(explosionPos, targetPos, traceVec);
- GetVectorAngles(traceVec, resultingFling);
- resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;
- resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;
- resultingFling[2] = power + (power * 0.5);
- if (GetClientTeam(target) == TEAM_SURVIVORS)
- {
- SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);
- }
- }
- public void DamageEffect(int target, int damage)
- {
- char sDamage[12];
- IntToString(damage, sDamage, sizeof(sDamage));
- int pointHurt = CreateEntityByName("point_hurt");
- DispatchKeyValue(target, "targetname", "hurtme");
- DispatchKeyValue(pointHurt, "Damage", sDamage);
- DispatchKeyValue(pointHurt, "DamageTarget", "hurtme");
- DispatchKeyValue(pointHurt, "DamageType", "65536");
- DispatchSpawn(pointHurt);
- AcceptEntityInput(pointHurt, "Hurt");
- AcceptEntityInput(pointHurt, "Kill");
- DispatchKeyValue(target, "targetname", "cake");
- }
- stock void SDKCallWeaponDrop(int client, int weapon)
- {
- float vecAngles[3], vecVelocity[3];
- GetClientEyeAngles(client, vecAngles);
- GetAngleVectors(vecAngles, vecVelocity, NULL_VECTOR, NULL_VECTOR);
- vecVelocity[0] = vecAngles[0] * GetRandomInt(2, 4);
- vecVelocity[1] = vecAngles[1] * GetRandomInt(2, 4);
- vecVelocity[2] = vecAngles[2] * GetRandomInt(2, 4);
- SDKHooks_DropWeapon(client, weapon, NULL_VECTOR, NULL_VECTOR);
- TeleportEntity(weapon, NULL_VECTOR, NULL_VECTOR, vecVelocity);
- }
- stock bool bIsSurvivor(int client)
- {
- return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
- }
Advertisement
Add Comment
Please, Sign In to add comment