Advertisement
MasamuneDate

CoD Perk : Airstrike

May 23rd, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.60 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5. #include <cstrike>
  6. #include <codmod>
  7. #include <engine>
  8. #include <fakemeta_util>
  9. #include <hamsandwich>
  10.  
  11. new bool:ma_perk[33];
  12.  
  13. new sprite_blast;
  14.  
  15. new ilosc[33];
  16.  
  17. new PobraneOrigin[3], ZmienKilla[2];
  18.  
  19. public plugin_init()
  20. {
  21.     cod_register_perk("Airstrike", "You can call in an air raid on a round of time!");
  22.    
  23.     register_touch("bomb", "*", "touchedrocket");
  24.    
  25.     RegisterHam(Ham_Spawn, "player", "Spawn", 1);  
  26. }
  27.  
  28. public plugin_precache()
  29. {
  30.     sprite_blast = precache_model("sprites/dexplo.spr");
  31.     precache_model("models/p_hegrenade.mdl");
  32.     precache_model("models/cod_plane.mdl");
  33.     precache_sound("mw/jet_fly1.wav");
  34.     precache_sound("mw/air_friend.wav");
  35.     precache_sound("mw/air_enemy.wav");
  36.     precache_sound("mw/air_give.wav");
  37. }
  38.  
  39. public cod_perk_enabled(id)
  40. {
  41.     if(cod_get_user_level(id) > 100)
  42.     return COD_STOP;
  43.  
  44.     ma_perk[id] = true;
  45.     ilosc[id] = 1;
  46.     return COD_CONTINUE;
  47. }
  48.    
  49. public cod_perk_disabled(id)
  50. {
  51.     ma_perk[id] = false;
  52.     ilosc[id] = 0;
  53. }
  54.  
  55. public client_disconnect(id)
  56. {
  57.     ma_perk[id] = false;
  58.     ilosc[id] = 0;
  59. }
  60.    
  61. public cod_perk_used(id)
  62. {
  63.     if(!ilosc[id])
  64.     {
  65.                 client_print(id, print_center, "You can no longer use the perk!");
  66.                 return PLUGIN_CONTINUE;
  67.          }
  68.     else
  69.     {
  70.         if (is_user_alive(id))
  71.         {
  72.      
  73.             ilosc[id]--;
  74.        
  75.             CreateNalot(id);
  76.         }
  77.     }
  78.     return PLUGIN_CONTINUE;
  79. }
  80.  
  81. public CreateNalot(id)
  82. {
  83.     new num, players[32];
  84.     get_players(players, num, "gh");
  85.     for(new a = 0; a < num; a++)
  86.     {
  87.         new i = players[a];
  88.         if(get_user_team(id) != get_user_team(i))
  89.             client_cmd(i, "spk sound/mw/air_enemy.wav");
  90.         else
  91.             client_cmd(i, "spk sound/mw/air_friend.wav");
  92.     }
  93.     set_task(1.0, "CreateBombs", id+997, _, _, "a", 3);
  94.     CreatePlane(id);
  95. }
  96.  
  97. public CreateBombs(taskid)
  98. {  
  99.     new id = (taskid-997);
  100.    
  101.     new radlocation[3];
  102.     PobraneOrigin[0] += random_num(-300,300);
  103.     PobraneOrigin[1] += random_num(-300,300);
  104.     PobraneOrigin[2] += 50;
  105.    
  106.     for(new i=0; i<15; i++)
  107.     {
  108.         radlocation[0] = PobraneOrigin[0]+1*random_num(-150,150);
  109.         radlocation[1] = PobraneOrigin[1]+1*random_num(-150,150);
  110.         radlocation[2] = PobraneOrigin[2];
  111.        
  112.         new Float:LocVec[3];
  113.         IVecFVec(radlocation, LocVec);
  114.         create_ent(id, "bomb", "models/p_hegrenade.mdl", 2, 10, LocVec);
  115.     }
  116. }  
  117.  
  118. public CreatePlane(id)
  119. {
  120.     new Float:Origin[3], Float:Angle[3], Float:Velocity[3], ent;
  121.    
  122.     get_user_origin(id, PobraneOrigin, 3);
  123.    
  124.     velocity_by_aim(id, 1000, Velocity);
  125.     entity_get_vector(id, EV_VEC_origin, Origin);
  126.     entity_get_vector(id, EV_VEC_v_angle, Angle);
  127.    
  128.     Angle[0] = Velocity[2] = 0.0;
  129.     Origin[2] += 200.0;
  130.    
  131.     create_ent(id, "samolot", "models/cod_plane.mdl", 2, 8, Origin, ent);
  132.    
  133.     entity_set_vector(ent, EV_VEC_velocity, Velocity);
  134.     entity_set_vector(ent, EV_VEC_angles, Angle);
  135.    
  136.     emit_sound(ent, CHAN_ITEM, "mw/jet_fly1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
  137.     set_task(4.5, "del_plane", ent+5731);
  138. }
  139.  
  140. public del_plane(taskid)
  141.     remove_entity(taskid-5731);
  142.  
  143. public touchedrocket(ent, id)
  144. {
  145.     if(!is_valid_ent(ent))
  146.         return PLUGIN_CONTINUE;
  147.    
  148.     bombs_explode(ent, 100.0, 150.0);
  149.     return PLUGIN_CONTINUE;
  150. }
  151.  
  152. stock create_ent(id, szName[], szModel[], iSolid, iMovetype, Float:fOrigin[3], &ent=-1)
  153. {
  154.     new ent1 = create_entity("info_target");
  155.     entity_set_string(ent1, EV_SZ_classname, szName);
  156.     entity_set_model(ent1, szModel);
  157.     entity_set_int(ent1, EV_INT_solid, iSolid);
  158.     entity_set_int(ent1, EV_INT_movetype, iMovetype);
  159.     entity_set_edict(ent1, EV_ENT_owner, id);
  160.     entity_set_origin(ent1, fOrigin);
  161.    
  162.     if(ent != -1)
  163.         ent = ent1;
  164. }
  165.  
  166. bombs_explode(ent, Float:zadaje, Float:promien)
  167. {
  168.     if(!is_valid_ent(ent))
  169.         return;
  170.    
  171.     new attacker = entity_get_edict(ent, EV_ENT_owner);
  172.    
  173.     new Float:entOrigin[3], Float:fDamage, Float:Origin[3];
  174.     entity_get_vector(ent, EV_VEC_origin, entOrigin);
  175.     entOrigin[2] += 1.0;
  176.    
  177.     new entlist[33];
  178.     new numfound = find_sphere_class(ent, "player", promien, entlist, 32)
  179.     for(new i=0; i < numfound; i++)
  180.     {      
  181.         new victim = entlist[i];       
  182.         if(!is_user_alive(victim) || get_user_team(attacker) == get_user_team(victim))
  183.             continue;
  184.            
  185.         entity_get_vector(victim, EV_VEC_origin, Origin);
  186.         fDamage = zadaje - floatmul(zadaje, floatdiv(get_distance_f(Origin, entOrigin), promien));
  187.         fDamage *= estimate_take_hurt(entOrigin, victim, 0);
  188.         if(fDamage>0.0)
  189.             UTIL_Kill(attacker, victim, fDamage, DMG_BULLET);
  190.     }
  191.     Sprite_Blast(entOrigin);
  192.     remove_entity(ent);
  193. }
  194.  
  195. stock Float:estimate_take_hurt(Float:fPoint[3], ent, ignored)
  196. {
  197.     new Float:fFraction, Float:fOrigin[3], tr;
  198.     entity_get_vector(ent, EV_VEC_origin, fOrigin);
  199.     engfunc(EngFunc_TraceLine, fPoint, fOrigin, DONT_IGNORE_MONSTERS, ignored, tr);
  200.     get_tr2(tr, TR_flFraction, fFraction);
  201.     if(fFraction == 1.0 || get_tr2(tr, TR_pHit) == ent)
  202.         return 1.0;
  203.     return 0.6;
  204. }
  205.  
  206. stock UTIL_Kill(atakujacy, obrywajacy, Float:damage, damagebits, ile=0)
  207. {
  208.     ZmienKilla[ile] |= (1<<atakujacy);
  209.     ExecuteHam(Ham_TakeDamage, obrywajacy, atakujacy, atakujacy, damage, damagebits);
  210.     ZmienKilla[ile] &= ~(1<<atakujacy);
  211. }
  212.  
  213. stock Sprite_Blast(Float:iOrigin[3])
  214. {
  215.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  216.     write_byte(TE_EXPLOSION);
  217.     write_coord(floatround(iOrigin[0]));
  218.     write_coord(floatround(iOrigin[1]));
  219.     write_coord(floatround(iOrigin[2]));
  220.     write_short(sprite_blast);
  221.     write_byte(32);
  222.     write_byte(20);
  223.     write_byte(0);
  224.     message_end();
  225. }
  226.  
  227. public Spawn(id)
  228. {
  229.         if(!is_user_alive(id) || !is_user_connected(id))
  230.                 return PLUGIN_CONTINUE;
  231.        
  232.         if(ma_perk[id])
  233.                 ilosc[id] = 1;
  234.        
  235.         return PLUGIN_CONTINUE;
  236. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement