Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include sdkhooks
- #pragma tabsize 0
- float GrenadeDamage = 100.0
- float PipeBombDamage = 100.0
- float BarrelDamage = 100.0
- float GrenadeRadius = 500.0
- float PipeRadius = 500.0
- float BarrelRadius = 500.0
- float GrenadeFling = 200.0
- float PipeFling = 200.0
- float BarrelFling = 200.0
- float RadiusFlingGrenade = 500.0
- float RadiusFlingPipe = 500.0
- float RadiusFlingBarrel = 500.0
- Handle sdkCallPushPlayer;
- public OnPluginStart()
- {
- Handle GameConf = LoadGameConfigFile("gamedata_stager");
- if(GameConf == INVALID_HANDLE)
- {
- SetFailState("Couldn't find the offsets and signatures file. Please, check that it is installed correctly.");
- }
- 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();
- }
- bool IsAllow = false;
- public OnMapStart()
- {
- IsAllow = false;
- CreateTimer(3.0, allow)
- }
- public Action allow(Handle timer)
- {
- IsAllow = true;
- }
- public void OnEntityDestroyed(int entity)
- {
- if(!IsAllow) return;
- if (IsValidEntity(entity) && IsValidEdict(entity))
- {
- char classname[128];
- GetEdictClassname(entity, classname, 128);
- if (StrEqual(classname, "grenade_launcher_projectile", false))
- {
- GrenadeTouch(entity);
- }
- if (StrEqual(classname, "pipe_bomb_projectile", false))
- {
- BombTouch(entity);
- }
- if (StrEqual(classname, "prop_fuel_barrel", false))
- {
- BarrelTouch(entity);
- }
- }
- }
- public int GrenadeTouch(int entity)
- {
- float pos[3];
- GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
- GranadeExplode(pos);
- }
- public int BombTouch(int entity)
- {
- float pos[3];
- GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
- BombExplode(pos)
- }
- public int BarrelTouch(int entity)
- {
- float pos[3];
- GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
- BarrelExplode(pos);
- }
- int GranadeExplode(float pos[3])
- {
- float fDistance = 0.0;
- float pos2[3];
- for( int i = 0; i < 32; i++ )
- {
- if(IsValidClient(i) && GetClientTeam(i) == 2)
- {
- int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
- if(vClass == 9)
- {
- GetClientAbsOrigin(i, pos2);
- fDistance = GetVectorDistance(pos, pos2);
- if(fDistance < RadiusFlingGrenade)
- {
- Fly(i, i, GrenadeFling)
- }
- if(fDistance < GrenadeRadius)
- {
- float iOne = GrenadeRadius - fDistance
- float vForward = GrenadeRadius / iOne
- int iDamage = RoundToCeil(GrenadeDamage / (vForward * vForward))
- ForceDamageEntity(i, iDamage, i)
- }
- }
- }
- }
- }
- int BombExplode(float pos[3])
- {
- float fDistance = 0.0;
- float pos2[3];
- for( int i = 0; i < 32; i++ )
- {
- if(IsValidClient(i) && GetClientTeam(i) == 2)
- {
- int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
- if(vClass == 9)
- {
- GetClientAbsOrigin(i, pos2);
- fDistance = GetVectorDistance(pos, pos2);
- if(fDistance < RadiusFlingPipe)
- {
- Fly(i, i, PipeFling)
- }
- if(fDistance < PipeRadius)
- {
- float iOne = PipeRadius - fDistance
- float vForward = PipeRadius / iOne
- int iDamage = RoundToCeil(PipeBombDamage / (vForward * vForward))
- ForceDamageEntity(i, iDamage, i)
- }
- }
- }
- }
- }
- int BarrelExplode(float pos[3])
- {
- float fDistance = 0.0;
- float pos2[3];
- for( int i = 0; i < 32; i++ )
- {
- if(IsValidClient(i) && GetClientTeam(i) == 2)
- {
- int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
- if(vClass == 9)
- {
- GetClientAbsOrigin(i, pos2);
- fDistance = GetVectorDistance(pos, pos2);
- if(fDistance < RadiusFlingBarrel)
- {
- Fly(i, i, BarrelFling)
- }
- if(fDistance < BarrelRadius)
- {
- float iOne = BarrelRadius - fDistance
- float vForward = BarrelRadius / iOne
- int iDamage = RoundToCeil(BarrelDamage / (vForward * vForward))
- ForceDamageEntity(i, iDamage, i)
- }
- }
- }
- }
- }
- public Fly(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);
- 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) == 2)
- {
- SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);
- }
- else
- {
- SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);
- }
- }
- 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");
- }
- void StaggerClient(int iUserID, const float fPos[3])
- {
- static int iScriptLogic = INVALID_ENT_REFERENCE;
- if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
- {
- iScriptLogic = EntIndexToEntRef(CreateEntityByName("logic_script"));
- if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
- LogError("Could not create 'logic_script");
- DispatchSpawn(iScriptLogic);
- }
- char sBuffer[96];
- Format(sBuffer, sizeof(sBuffer), "GetPlayerFromUserID(%d).Stagger(Vector(%d,%d,%d))", iUserID, RoundFloat(fPos[0]), RoundFloat(fPos[1]), RoundFloat(fPos[2]));
- SetVariantString(sBuffer);
- AcceptEntityInput(iScriptLogic, "RunScriptCode");
- AcceptEntityInput(iScriptLogic, "Kill");
- }
- stock bool IsValidClient(int client)
- {
- if ( client < 1 || client > MaxClients ) return false;
- if( !IsClientInGame(client)) return false;
- if ( !IsPlayerAlive( client )) return false;
- return true;
- }
- public void ScreenShake(int target, float power)
- {
- Handle msg;
- msg = StartMessageOne("Shake", target);
- BfWriteByte(msg, 0);
- BfWriteFloat(msg, power);
- BfWriteFloat(msg, 10.0);
- BfWriteFloat(msg, 3.0);
- EndMessage();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement