FlacoBey

Untitled

May 5th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.46 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3.  
  4. bool IsSpawned
  5. bool IsAbility
  6.  
  7. Handle sdkCallPushPlayer = INVALID_HANDLE;
  8. Handle GameConf = INVALID_HANDLE;
  9.  
  10. ConVar vPower, vDamage;
  11.  
  12. public OnPluginStart()
  13. {
  14.     GameConf = LoadGameConfigFile("detonationforce");
  15.     StartPrepSDKCall(SDKCall_Player);
  16.     PrepSDKCall_SetFromConf(GameConf, SDKConf_Signature, "CTerrorPlayer_Fling");
  17.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  18.     PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
  19.     PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
  20.     PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
  21.     sdkCallPushPlayer = EndPrepSDKCall();
  22.    
  23.     vPower = CreateConVar("PowerRock", "80", "Сила откидывания камня", FCVAR_NONE);
  24.     vDamage = CreateConVar("DamageRock", "80", "Урон от взрыва", FCVAR_NONE);
  25.    
  26.     HookEvent("tank_spawn", hTankSpawn, EventHookMode_PostNoCopy);
  27.     HookEvent("tank_killed", hTankKill, EventHookMode_PostNoCopy);
  28.     HookEvent("ability_use", AbilityUsed);
  29.    
  30.     AutoExecConfig(true, "TankRock");
  31. }
  32.  
  33. public OnMapStart()
  34. {
  35.     IsSpawned = false;
  36.     IsAbility = false;
  37. }
  38.  
  39. public Action hTankSpawn(Handle:event, const String:name[], bool:dontBroadcast)
  40. {
  41.     IsSpawned = true;
  42. }
  43.  
  44. public Action hTankKill(Handle:event, const String:name[], bool:dontBroadcast)
  45. {
  46.     IsSpawned = false;
  47.     IsAbility = false;
  48. }
  49.  
  50. public Action:AbilityUsed(Handle:event, const String:name[], bool:dontBroadcast)
  51. {
  52.     char sAbili[32];
  53.     GetEventString(event, "ability", sAbili, sizeof(sAbili));
  54.  
  55.     if(StrEqual(sAbili, "ability_throw"))
  56.     {  
  57.         IsAbility = true;
  58.     }
  59. }
  60.  
  61. public OnEntityCreated(entity, const String:classname[])
  62. {
  63.     if(!IsAbility && !IsSpawned) return;
  64.     if(StrEqual(classname, "tank_rock"))
  65.     {
  66.         CreateTimer(0.1, OnHeSpawned, EntIndexToEntRef(entity), TIMER_FLAG_NO_MAPCHANGE);
  67.     }
  68. }
  69.  
  70. public OnEntityDestroyed(entity)
  71. {  
  72.     if(!IsSpawned && !IsValidEntity(entity) && !IsAbility) return;
  73.    
  74.     decl String:g_classname[20];
  75.     GetEdictClassname(entity, g_classname, 20);
  76.    
  77.     if(StrEqual(g_classname, "tank_rock"))
  78.     {
  79.         for (new i = 1; i <= MaxClients; i++)
  80.         {
  81.             float vPos[3], vEntityPos[3];
  82.             GetEntPropVector(i, Prop_Data, "m_vecOrigin", vPos);       
  83.             GetEntPropVector(entity, Prop_Data, "m_vecOrigin", vEntityPos);
  84.            
  85.             int vStreght = RoundToCeil(GetConVarInt(vPower) - GetVectorDistance(vPos, vEntityPos));
  86.            
  87.             if(vStreght < 1) return;
  88.            
  89.             float vTraceVec[3], vResult[3];
  90.            
  91.             MakeVectorFromPoints(vEntityPos, vPos, vTraceVec);
  92.             GetVectorAngles(vTraceVec, vResult);
  93.            
  94.             vResult[0] = Cosine(DegToRad(vResult[1])) * vStreght;
  95.             vResult[1] = Sine(DegToRad(vResult[1])) * vStreght;
  96.             vResult[2] = vStreght + (vStreght * 0.5);
  97.            
  98.             LittleFlower(vEntityPos)
  99.             SDKCall(sdkCallPushPlayer, i, vResult, 76, i, 2.0);
  100.             ShowParticle(vEntityPos, "gas_explosion_pump", 3.0);
  101.            
  102.             int samage = RoundToCeil(GetConVarInt(vDamage) - GetVectorDistance(vPos, vEntityPos));
  103.             if(samage < 0) return;
  104.            
  105.             ForceDamageEntity(entity, samage, i)
  106.         }
  107.     }
  108. }
  109.  
  110. public Action OnHeSpawned(Handle timer, any ent)
  111. {
  112.     decl client;
  113.     if ((ent = EntRefToEntIndex(ent)) > 0 && (client = GetEntPropEnt(ent, Prop_Data, "m_hThrower")) > 0 && IsClientInGame(client))
  114.     {
  115.         IsAbility = false;
  116.         if(IsValidEntity(ent) && IsValidEdict(ent))
  117.         {
  118.             if(IsValidInfected(client))
  119.             {
  120.                 if(IsClientInGame(client) && IsPlayerAlive(client))
  121.                 {
  122.                     if(GetEntityFlags(client) & FL_ONFIRE)
  123.                     {
  124.                         IgniteEntity(ent, 100.0);
  125.                     }
  126.                 }
  127.             }
  128.         }
  129.     }
  130. }
  131.  
  132.  public ShowParticle(Float:pos[3], String:particlename[], Float:time)
  133. {
  134.     new particle = CreateEntityByName("info_particle_system");
  135.     if (IsValidEdict(particle))
  136.     {
  137.         TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR);
  138.         DispatchKeyValue(particle, "effect_name", particlename);
  139.         DispatchKeyValue(particle, "targetname", "particle");
  140.         DispatchSpawn(particle);
  141.         ActivateEntity(particle);
  142.         AcceptEntityInput(particle, "start");
  143.         CreateTimer(time, DeleteParticles, particle);
  144.     }
  145. }
  146.  
  147. public PrecacheParticle(String:particlename[])
  148. {
  149.     new particle = CreateEntityByName("info_particle_system");
  150.     if (IsValidEdict(particle))
  151.     {
  152.         DispatchKeyValue(particle, "effect_name", particlename);
  153.         DispatchKeyValue(particle, "targetname", "particle");
  154.         DispatchSpawn(particle);
  155.         ActivateEntity(particle);
  156.         AcceptEntityInput(particle, "start");
  157.         CreateTimer(0.01, DeleteParticles, particle);
  158.     }
  159. }
  160.  
  161. public Action:DeleteParticles(Handle:timer, any:particle)
  162. {
  163.     if(IsValidEntity(particle))
  164.     {
  165.         decl String:classname[64];
  166.         GetEdictClassname(particle, classname, sizeof(classname));
  167.         if (StrEqual(classname, "info_particle_system", false))
  168.         {
  169.             AcceptEntityInput(particle, "stop");
  170.             AcceptEntityInput(particle, "kill");
  171.             RemoveEdict(particle);
  172.         }
  173.      }
  174. }
  175.  
  176. stock LittleFlower(Float:pos[3])
  177. {
  178.     new entity = CreateEntityByName("prop_physics");
  179.     if (IsValidEntity(entity))
  180.     {
  181.         pos[2] += 1.0;
  182.         DispatchKeyValue(entity, "model", "models/props_junk/propanecanister001a.mdl");
  183.         DispatchSpawn(entity);
  184.         SetEntData(entity, GetEntSendPropOffs(entity, "m_CollisionGroup"), 1, 1, true);
  185.         SetEntityRenderMode(entity, RENDER_TRANSCOLOR);
  186.         SetEntityRenderColor(entity, 255, 255, 255, 0);
  187.         TeleportEntity(entity, pos, NULL_VECTOR, NULL_VECTOR);
  188.         AcceptEntityInput(entity, "break");
  189.     }
  190. }
  191.  
  192. stock ForceDamageEntity(causer, damage, victim) // thanks to 达斯*维达
  193. {
  194.     float victim_origin[3];
  195.     char rupture[32];
  196.     char damage_victim[32];
  197.     IntToString(damage, rupture, sizeof(rupture));
  198.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  199.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  200.     int entity = CreateEntityByName("point_hurt");
  201.     DispatchKeyValue(victim, "targetname", damage_victim);
  202.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  203.     DispatchKeyValue(entity, "Damage", rupture);
  204.     DispatchSpawn(entity);
  205.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  206.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  207.     DispatchKeyValue(entity, "classname", "point_hurt");
  208.     DispatchKeyValue(victim, "targetname", "null");
  209.     AcceptEntityInput(entity, "Kill");
  210. }
  211.  
  212. stock bool:IsValidInfected( client )
  213. {
  214.     if ( client < 1 || client > MaxClients ) return false;
  215.     if ( !IsClientConnected( client )) return false;
  216.     if ( !IsClientInGame( client )) return false;
  217.     if ( GetClientTeam( client ) != 3 ) return false;
  218.     return true;
  219. }
Advertisement
Add Comment
Please, Sign In to add comment