FlacoBey

Untitled

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