daily pastebin goal
32%
SHARE
TWEET

Untitled

a guest Sep 17th, 2017 21 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <engine>
  4.  
  5. #include <ipci/Ascend>
  6. #include <ipci/Core>
  7. new bool:IsPressingButton[32];  
  8.  
  9. new const Class[] = { "finalflash",  "finishingbuster", "kamehameha", "masenko", "gallitgun" }
  10.  
  11. public client_PreThink(Client)
  12. {
  13.     if(!getClientATKSHOOT(Client) || getClientBEAMJUMP(Client))
  14.         return PLUGIN_HANDLED;
  15.    
  16.     static Control, Weapon[32]; Control = get_user_button(Client);
  17.     getClientWEAPONNAME(Client, Weapon);
  18.    
  19.     if(Control == IN_ATTACK2 && IsPressingButton[Client] == false)
  20.     {
  21.         IsPressingButton[Client] = true;
  22.        
  23.         for(new All = 0; All < sizeof Class; All++) // Restart server and see the logs.
  24.         {
  25.             if(equal(Weapon, Class[All]) && getClientKI(Client) > 200.0)
  26.             {
  27.                
  28.                 setClientKI(Client, .Ki = getClientKI(Client) - 200.0);
  29.                 setClientMELEEPUSHBACK(Client, 1);
  30.             }
  31.         }
  32.     }
  33.    
  34.     else if(Control != IN_ATTACK2 || IsPressingButton[Client] == true)
  35.     {
  36.         setClientMELEEPUSHBACK(Client, 0);
  37.         IsPressingButton[Client] = false;
  38.     }
  39.    
  40.     return PLUGIN_CONTINUE;
  41. }
  42.  
  43. public @FollowEnemy(Client)
  44. {
  45.     if(getClientATKSHOOT(Client) || getClientBEAMJUMP(Client))
  46.         return PLUGIN_HANDLED;
  47.    
  48.     new Float:MinimumDistance = 2000.0, NearestPlayer = 0, Entity = -1;
  49.    
  50.     for(new All = 0; All < sizeof Class; All++)
  51.     {
  52.         while((Entity = find_ent_by_class(Entity, Class[All])))
  53.         {
  54.             if(!is_valid_ent(Entity))
  55.             {
  56.                 remove_task(Client);
  57.                 return PLUGIN_HANDLED;
  58.             }
  59.            
  60.             new Owner = entity_get_edict(Entity, EV_ENT_owner);
  61.            
  62.             new Player[32], Players, Num;
  63.             get_players(Player, Players, "a");
  64.            
  65.             for(Num = 0; Num < Players; Num++)
  66.             {
  67.                 if(is_user_alive(Player[Num]) && Owner != Player[Num])
  68.                 {
  69.                     new Float:Distance = entity_range(Entity, Player[Num]);
  70.                    
  71.                     if(Distance <= MinimumDistance)
  72.                     {
  73.                         MinimumDistance = Distance;
  74.                         NearestPlayer = Player[Num];
  75.                     }
  76.                 }
  77.                
  78.                 if(NearestPlayer > 0)
  79.                 {
  80.                     entity_set_follow(Entity, NearestPlayer, 600.0)
  81.                 }
  82.             }
  83.         }
  84.     }
  85.    
  86.     return PLUGIN_CONTINUE;
  87. }
  88. stock entity_set_follow(entity, target, Float:speed) // Good vector work, but not the best.
  89. {
  90.     if(!is_valid_ent(entity) || !is_valid_ent(target))
  91.         return 0
  92.  
  93.     new Float:entity_origin[3], Float:target_origin[3]
  94.     pev(entity, pev_origin, entity_origin)
  95.     pev(target, pev_origin, target_origin)
  96.  
  97.     new Float:diff[3]
  98.     diff[0] = target_origin[0] - entity_origin[0]
  99.     diff[1] = target_origin[1] - entity_origin[1]
  100.     diff[2] = target_origin[2] - entity_origin[2]
  101.  
  102.     new Float:length = floatsqroot(floatpower(diff[0], 2.0) + floatpower(diff[1], 2.0) + floatpower(diff[2], 2.0))
  103.  
  104.         new Float:velocity[3]
  105.     velocity[0] = diff[0] * (speed / length)
  106.     velocity[1] = diff[1] * (speed / length)
  107.     velocity[2] = diff[2] * (speed / length)
  108.  
  109.     set_pev(entity, pev_velocity, velocity)
  110.  
  111.     return 1
  112. }
RAW Paste Data
Top