FlacoBey

Untitled

May 6th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.67 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.     PrecacheParticle("gas_explosion_pump");
  36.     PrecacheModel("models/props_junk/propanecanister001a.mdl", true);
  37.    
  38.     IsSpawned = false;
  39.     IsAbility = false;
  40. }
  41.  
  42. public Action hTankSpawn(Handle:event, const String:name[], bool:dontBroadcast)
  43. {
  44.     IsSpawned = true;
  45. }
  46.  
  47. public Action hTankKill(Handle:event, const String:name[], bool:dontBroadcast)
  48. {
  49.     IsSpawned = false;
  50.     IsAbility = false;
  51. }
  52.  
  53. public Action:AbilityUsed(Handle:event, const String:name[], bool:dontBroadcast)
  54. {
  55.     char sAbili[32];
  56.     GetEventString(event, "ability", sAbili, sizeof(sAbili));
  57.  
  58.     if(StrEqual(sAbili, "ability_throw"))
  59.     {  
  60.         IsAbility = true;
  61.     }
  62. }
  63.  
  64. public OnEntityCreated(entity, const String:classname[])
  65. {
  66.     if(!IsAbility && !IsSpawned) return;
  67.     if(StrEqual(classname, "tank_rock"))
  68.     {
  69.         CreateTimer(0.1, OnHeSpawned, EntIndexToEntRef(entity), TIMER_FLAG_NO_MAPCHANGE);
  70.     }
  71. }
  72.  
  73. public OnEntityDestroyed(entity)
  74. {  
  75.     if(!IsSpawned && !IsValidEntity(entity) && !IsAbility && !IsValidEdict(entity)) return;
  76.    
  77.     decl String:g_classname[20];
  78.     GetEntityClassname(entity, g_classname, 20);
  79.    
  80.     if(StrEqual(g_classname, "tank_rock"))
  81.     {
  82.         IsAbility = false;
  83.         for (new i = 1; i <= MaxClients; i++)
  84.         {
  85.             if(bIsSurvivor(i))
  86.             {
  87.                 float vPos[3], vEntityPos[3];
  88.                 GetEntPropVector(i, Prop_Data, "m_vecOrigin", vPos);      
  89.                 GetEntPropVector(entity, Prop_Data, "m_vecOrigin", vEntityPos);
  90.                
  91.                 int vStreght = RoundToCeil(GetConVarInt(vPower) - GetVectorDistance(vPos, vEntityPos));
  92.                
  93.                 if(vStreght < 1) return;
  94.                
  95.                 float vTraceVec[3], vResult[3];
  96.                
  97.                 MakeVectorFromPoints(vEntityPos, vPos, vTraceVec);
  98.                 GetVectorAngles(vTraceVec, vResult);
  99.                
  100.                 vResult[0] = Cosine(DegToRad(vResult[1])) * vStreght;
  101.                 vResult[1] = Sine(DegToRad(vResult[1])) * vStreght;
  102.                 vResult[2] = vStreght + (vStreght * 0.5);
  103.                
  104.                 LittleFlower(vEntityPos)
  105.                 SDKCall(sdkCallPushPlayer, i, vResult, 76, i, 2.0);
  106.                 ShowParticle(vEntityPos, "gas_explosion_pump", 3.0);
  107.                
  108.                 int samage = RoundToCeil(GetConVarInt(vDamage) - GetVectorDistance(vPos, vEntityPos));
  109.                 if(samage < 0) return;
  110.                
  111.                 ForceDamageEntity(entity, samage, i)
  112.                
  113.             }
  114.         }
  115.     }
  116. }
  117.  
  118. public Action OnHeSpawned(Handle timer, any ent)
  119. {
  120.     decl client;
  121.     if ((ent = EntRefToEntIndex(ent)) > 0 && (client = GetEntPropEnt(ent, Prop_Data, "m_hThrower")) > 0 && IsClientInGame(client))
  122.     {
  123.         IsAbility = false;
  124.         if(IsValidEntity(ent) && IsValidEdict(ent))
  125.         {
  126.             if(IsValidInfected(client))
  127.             {
  128.                 if(IsClientInGame(client) && IsPlayerAlive(client))
  129.                 {
  130.                     if(GetEntityFlags(client) & FL_ONFIRE)
  131.                     {
  132.                         IgniteEntity(ent, 100.0);
  133.                     }
  134.                 }
  135.             }
  136.         }
  137.     }
  138. }
  139.  
  140.  public ShowParticle(Float:pos[3], String:particlename[], Float:time)
  141. {
  142.     new particle = CreateEntityByName("info_particle_system");
  143.     if (IsValidEdict(particle))
  144.     {
  145.         TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR);
  146.         DispatchKeyValue(particle, "effect_name", particlename);
  147.         DispatchKeyValue(particle, "targetname", "particle");
  148.         DispatchSpawn(particle);
  149.         ActivateEntity(particle);
  150.         AcceptEntityInput(particle, "start");
  151.         CreateTimer(time, DeleteParticles, particle);
  152.     }
  153. }
  154.  
  155. public PrecacheParticle(String:particlename[])
  156. {
  157.     new particle = CreateEntityByName("info_particle_system");
  158.     if (IsValidEdict(particle))
  159.     {
  160.         DispatchKeyValue(particle, "effect_name", particlename);
  161.         DispatchKeyValue(particle, "targetname", "particle");
  162.         DispatchSpawn(particle);
  163.         ActivateEntity(particle);
  164.         AcceptEntityInput(particle, "start");
  165.         CreateTimer(0.01, DeleteParticles, particle);
  166.     }
  167. }
  168.  
  169. public Action:DeleteParticles(Handle:timer, any:particle)
  170. {
  171.     if(IsValidEntity(particle))
  172.     {
  173.         decl String:classname[64];
  174.         GetEdictClassname(particle, classname, sizeof(classname));
  175.         if (StrEqual(classname, "info_particle_system", false))
  176.         {
  177.             AcceptEntityInput(particle, "stop");
  178.             AcceptEntityInput(particle, "kill");
  179.             RemoveEdict(particle);
  180.         }
  181.      }
  182. }
  183.  
  184. stock LittleFlower(Float:pos[3])
  185. {
  186.     new entity = CreateEntityByName("prop_physics");
  187.     if (IsValidEntity(entity))
  188.     {
  189.         pos[2] += 1.0;
  190.         DispatchKeyValue(entity, "model", "models/props_junk/propanecanister001a.mdl");
  191.         DispatchSpawn(entity);
  192.         SetEntData(entity, GetEntSendPropOffs(entity, "m_CollisionGroup"), 1, 1, true);
  193.         SetEntityRenderMode(entity, RENDER_TRANSCOLOR);
  194.         SetEntityRenderColor(entity, 255, 255, 255, 0);
  195.         TeleportEntity(entity, pos, NULL_VECTOR, NULL_VECTOR);
  196.         AcceptEntityInput(entity, "break");
  197.     }
  198. }
  199.  
  200. stock ForceDamageEntity(causer, damage, victim) // thanks to 达斯*维达
  201. {
  202.     float victim_origin[3];
  203.     char rupture[32];
  204.     char damage_victim[32];
  205.     IntToString(damage, rupture, sizeof(rupture));
  206.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  207.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  208.     int entity = CreateEntityByName("point_hurt");
  209.     DispatchKeyValue(victim, "targetname", damage_victim);
  210.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  211.     DispatchKeyValue(entity, "Damage", rupture);
  212.     DispatchSpawn(entity);
  213.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  214.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  215.     DispatchKeyValue(entity, "classname", "point_hurt");
  216.     DispatchKeyValue(victim, "targetname", "null");
  217.     AcceptEntityInput(entity, "Kill");
  218. }
  219.  
  220. stock bool bIsSurvivor(int client)
  221. {
  222.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  223. }
  224.  
  225. stock bool:IsValidInfected( client )
  226. {
  227.     if ( client < 1 || client > MaxClients ) return false;
  228.     if ( !IsClientConnected( client )) return false;
  229.     if ( !IsClientInGame( client )) return false;
  230.     if ( GetClientTeam( client ) != 3 ) return false;
  231.     return true;
  232. }
Advertisement
Add Comment
Please, Sign In to add comment