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
- int tank;
- Handle distance, Fling, FlingDamage, FireDamage;
- new Handle:sdkCallPushPlayer = INVALID_HANDLE;
- new Handle:GameConf = INVALID_HANDLE;
- public 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", "20.0", "", FCVAR_NONE);
- FireDamage = CreateConVar("sv_rock_damage_fire", "5", "", 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("ability_use", ability_use);
- }
- public Action ability_use(Event event, const char[] name, bool dontBroadcast)
- {
- decl String:s[32];
- GetEventString(event, "ability", s, 32);
- if(StrEqual(s, "ability_throw", true))
- {
- tank = GetClientOfUserId(GetEventInt(event, "userid"));
- }
- }
- public OnEntityCreated(entity, const String:classname[])
- {
- if(StrEqual(classname, "tank_rock", true) && GetEntProp(entity, Prop_Send, "m_iTeamNum")>=0)
- {
- if(IsValidEntity(entity) && IsValidEdict(entity))
- {
- if(GetEntityFlags(tank) & FL_ONFIRE)
- {
- IgniteEntity(entity, 25.0);
- }
- }
- }
- }
- public OnEntityDestroyed(entity)
- {
- if(IsValidEntity(entity) && IsValidEdict(entity))
- {
- decl String: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;
- Fly(entity, i, GetConVarFloat(Fling))
- if(GetEntityFlags(tank) & FL_ONFIRE)
- {
- DamageEffect(i, GetConVarInt(FireDamage))
- IgniteEntity(i, 5.0);
- }
- }
- }
- }
- }
- }
- 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)
- {
- DamageEffect(target, RoundToNearest(GetConVarFloat(FlingDamage))); // apply damage to the survivor
- SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);// throwing survivor with animation 76 (charge animation)
- }
- else
- if (GetClientTeam(target) == TEAM_INFECTED)
- {
- DamageEffect(target, RoundToNearest(GetConVarFloat(FlingDamage))); // apply damage to the infected
- SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);// throwing infected with animation 2 (jump animation)
- }
- }
- public DamageEffect(target, damage)
- {
- decl String:sDamage[12];
- IntToString(damage, sDamage, sizeof(sDamage)); // converting the damage from int to string
- new pointHurt = CreateEntityByName("point_hurt"); // Create point_hurt
- DispatchKeyValue(target, "targetname", "hurtme"); // mark target
- DispatchKeyValue(pointHurt, "Damage", sDamage); // Set damage
- DispatchKeyValue(pointHurt, "DamageTarget", "hurtme"); // Target Assignmen
- DispatchKeyValue(pointHurt, "DamageType", "65536");
- DispatchSpawn(pointHurt); // Spawn descriped point_hurt
- AcceptEntityInput(pointHurt, "Hurt"); // Trigger point_hurt execute
- AcceptEntityInput(pointHurt, "Kill"); // Remove point_hurt
- DispatchKeyValue(target, "targetname", "cake"); // Clear target's mark
- }
- 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