Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include sdktools
- #include sdkhooks
- #define TEAM_SURVIVORS 2
- #define TEAM_INFECTED 3
- #define ZC_BOOMER 2
- Handle distance_flint;
- new Handle:sdkCallPushPlayer = INVALID_HANDLE;
- new Handle:GameConf = INVALID_HANDLE;
- public OnPluginStart()
- {
- distance_flint = CreateConVar("sv_distance_flint", "400.0", "", 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);
- HookEvent("player_death", death);
- }
- public Action death(Event event, const char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "userid"));
- int damager = GetClientOfUserId(GetEventInt(event, "attacker"));
- if(IsValidBoomer(client))
- {
- float fDamagerPos[3], fDangerPos[3];
- GetEntPropVector(damager, Prop_Send, "m_vecOrigin", fDamagerPos);
- GetEntPropVector(client, Prop_Send, "m_vecOrigin", fDangerPos);
- Fly(client, damager, GetConVarFloat(distance_flint))
- }
- }
- public Fly(explosion, target, Float:power)
- {
- if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target)) // check if the taget is a valid entity
- return;
- decl Float:targetPos[3], Float:explosionPos[3], Float:traceVec[3], Float:resultingFling[3];
- /* getting the target and explosion position */
- GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);
- GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);
- power = power - GetVectorDistance(targetPos,explosionPos); // an easy way to define the explosion power, is the "base power" minus the distance between the target and the explosion
- if(power < 1) // if the power is irrelevant, doesn't worth to continue
- return;
- /* getting the resulting */
- 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);
- /* for L4D 2 */
- if (GetClientTeam(target) == TEAM_SURVIVORS)
- {
- SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);// throwing survivor with animation 76 (charge animation)
- }
- else
- if (GetClientTeam(target) == TEAM_INFECTED)
- {
- SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);// throwing infected with animation 2 (jump animation)
- }
- }
- public IsValidBoomer(client)
- {
- if (IsValidClient(client) && GetClientTeam(client) == TEAM_INFECTED)
- {
- new class = GetEntProp(client, Prop_Send, "m_zombieClass");
- if (class == ZC_BOOMER)
- return true;
- return false;
- }
- return false;
- }
- public IsValidClient(client)
- {
- if (client <= 0)
- return false;
- if (client > MaxClients)
- return false;
- if (!IsClientInGame(client))
- return false;
- return true;
- }
- 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
Advertisement