Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- bool IsSpawned
- bool IsAbility
- Handle sdkCallPushPlayer = INVALID_HANDLE;
- Handle GameConf = INVALID_HANDLE;
- ConVar vPower, vDamage;
- public OnPluginStart()
- {
- GameConf = LoadGameConfigFile("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();
- vPower = CreateConVar("PowerRock", "80", "Сила откидывания камня", FCVAR_NONE);
- vDamage = CreateConVar("DamageRock", "80", "Урон от взрыва", FCVAR_NONE);
- HookEvent("tank_spawn", hTankSpawn, EventHookMode_PostNoCopy);
- HookEvent("tank_killed", hTankKill, EventHookMode_PostNoCopy);
- HookEvent("ability_use", AbilityUsed);
- AutoExecConfig(true, "TankRock");
- }
- public OnMapStart()
- {
- PrecacheParticle("gas_explosion_pump");
- PrecacheModel("models/props_junk/propanecanister001a.mdl", true);
- IsSpawned = false;
- IsAbility = false;
- }
- public Action hTankSpawn(Handle:event, const String:name[], bool:dontBroadcast)
- {
- IsSpawned = true;
- }
- public Action hTankKill(Handle:event, const String:name[], bool:dontBroadcast)
- {
- IsSpawned = false;
- IsAbility = false;
- }
- public Action:AbilityUsed(Handle:event, const String:name[], bool:dontBroadcast)
- {
- char sAbili[32];
- GetEventString(event, "ability", sAbili, sizeof(sAbili));
- if(StrEqual(sAbili, "ability_throw"))
- {
- IsAbility = true;
- }
- }
- public OnEntityCreated(entity, const String:classname[])
- {
- if(!IsAbility && !IsSpawned) return;
- if(StrEqual(classname, "tank_rock"))
- {
- CreateTimer(0.1, OnHeSpawned, EntIndexToEntRef(entity), TIMER_FLAG_NO_MAPCHANGE);
- }
- }
- public OnEntityDestroyed(entity)
- {
- if(!IsSpawned && !IsValidEntity(entity) && !IsAbility) return;
- decl String:g_classname[20];
- GetEdictClassname(entity, g_classname, 20);
- if(StrEqual(g_classname, "tank_rock"))
- {
- IsAbility = false;
- for (new i = 1; i <= MaxClients; i++)
- {
- if(bIsSurvivor(i))
- {
- float vPos[3], vEntityPos[3];
- GetEntPropVector(i, Prop_Data, "m_vecOrigin", vPos);
- GetEntPropVector(entity, Prop_Data, "m_vecOrigin", vEntityPos);
- int vStreght = RoundToCeil(GetConVarInt(vPower) - GetVectorDistance(vPos, vEntityPos));
- if(vStreght < 1) return;
- float vTraceVec[3], vResult[3];
- MakeVectorFromPoints(vEntityPos, vPos, vTraceVec);
- GetVectorAngles(vTraceVec, vResult);
- vResult[0] = Cosine(DegToRad(vResult[1])) * vStreght;
- vResult[1] = Sine(DegToRad(vResult[1])) * vStreght;
- vResult[2] = vStreght + (vStreght * 0.5);
- LittleFlower(vEntityPos)
- SDKCall(sdkCallPushPlayer, i, vResult, 76, i, 2.0);
- ShowParticle(vEntityPos, "gas_explosion_pump", 3.0);
- int samage = RoundToCeil(GetConVarInt(vDamage) - GetVectorDistance(vPos, vEntityPos));
- if(samage < 0) return;
- ForceDamageEntity(entity, samage, i)
- }
- }
- }
- }
- public Action OnHeSpawned(Handle timer, any ent)
- {
- decl client;
- if ((ent = EntRefToEntIndex(ent)) > 0 && (client = GetEntPropEnt(ent, Prop_Data, "m_hThrower")) > 0 && IsClientInGame(client))
- {
- IsAbility = false;
- if(IsValidEntity(ent) && IsValidEdict(ent))
- {
- if(IsValidInfected(client))
- {
- if(IsClientInGame(client) && IsPlayerAlive(client))
- {
- if(GetEntityFlags(client) & FL_ONFIRE)
- {
- IgniteEntity(ent, 100.0);
- }
- }
- }
- }
- }
- }
- public ShowParticle(Float:pos[3], String:particlename[], Float:time)
- {
- new particle = CreateEntityByName("info_particle_system");
- if (IsValidEdict(particle))
- {
- TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR);
- DispatchKeyValue(particle, "effect_name", particlename);
- DispatchKeyValue(particle, "targetname", "particle");
- DispatchSpawn(particle);
- ActivateEntity(particle);
- AcceptEntityInput(particle, "start");
- CreateTimer(time, DeleteParticles, particle);
- }
- }
- public PrecacheParticle(String:particlename[])
- {
- new particle = CreateEntityByName("info_particle_system");
- if (IsValidEdict(particle))
- {
- DispatchKeyValue(particle, "effect_name", particlename);
- DispatchKeyValue(particle, "targetname", "particle");
- DispatchSpawn(particle);
- ActivateEntity(particle);
- AcceptEntityInput(particle, "start");
- CreateTimer(0.01, DeleteParticles, particle);
- }
- }
- public Action:DeleteParticles(Handle:timer, any:particle)
- {
- if(IsValidEntity(particle))
- {
- decl String:classname[64];
- GetEdictClassname(particle, classname, sizeof(classname));
- if (StrEqual(classname, "info_particle_system", false))
- {
- AcceptEntityInput(particle, "stop");
- AcceptEntityInput(particle, "kill");
- RemoveEdict(particle);
- }
- }
- }
- stock LittleFlower(Float:pos[3])
- {
- new entity = CreateEntityByName("prop_physics");
- if (IsValidEntity(entity))
- {
- pos[2] += 1.0;
- DispatchKeyValue(entity, "model", "models/props_junk/propanecanister001a.mdl");
- DispatchSpawn(entity);
- SetEntData(entity, GetEntSendPropOffs(entity, "m_CollisionGroup"), 1, 1, true);
- SetEntityRenderMode(entity, RENDER_TRANSCOLOR);
- SetEntityRenderColor(entity, 255, 255, 255, 0);
- TeleportEntity(entity, pos, NULL_VECTOR, NULL_VECTOR);
- AcceptEntityInput(entity, "break");
- }
- }
- stock ForceDamageEntity(causer, damage, 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");
- }
- stock bool bIsSurvivor(int client)
- {
- return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
- }
- stock bool:IsValidInfected( client )
- {
- if ( client < 1 || client > MaxClients ) return false;
- if ( !IsClientConnected( client )) return false;
- if ( !IsClientInGame( client )) return false;
- if ( GetClientTeam( client ) != 3 ) return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment