SHARE
TWEET

Untitled

a guest Dec 9th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2. #include <zombieplague>
  3. #include <engine>
  4. #include <fun>
  5. #include <fakemeta>
  6. #include <hamsandwich>
  7. #include <amx_settings_api>
  8. #include <cs_maxspeed_api>
  9. #include <cs_player_models_api>
  10. #include <cs_weap_models_api>
  11. #include <cs_ham_bots_api>
  12. #include <zp50_core>
  13. #define LIBRARY_GRENADE_FROST "zp50_grenade_frost"
  14. #include <zp50_grenade_frost>
  15. #define LIBRARY_GRENADE_FIRE "zp50_grenade_fire"
  16. #include <zp50_grenade_fire>
  17.  
  18. // Settings file
  19. new const ZP_SETTINGS_FILE[] = "zombieplague.ini"
  20.  
  21. // Default models
  22. new const models_predator_player[][] = { "predator_boss" }
  23. new const models_predator_claw[][] = { "models/zombie_plague/v_knife_zombie.mdl" }
  24.  
  25. #define PLAYERMODEL_MAX_LENGTH 32
  26. #define MODEL_MAX_LENGTH 640
  27.  
  28. // Custom models
  29. new Array:g_models_predator_player
  30. new Array:g_models_predator_claw
  31.  
  32. #define flag_get(%1,%2) (%1 & (1 << (%2 & 31)))
  33. #define flag_get_boolean(%1,%2) (flag_get(%1,%2) ? true : false)
  34. #define flag_set(%1,%2) %1 |= (1 << (%2 & 31))
  35. #define flag_unset(%1,%2) %1 &= ~(1 << (%2 & 31))
  36.  
  37. new g_MaxPlayers
  38. new g_Ispredator
  39. new g_currentweapon[33]
  40.  
  41. new cvar_predator_health, cvar_predator_base_health, cvar_predator_speed, cvar_predator_gravity
  42. new cvar_predator_kill_explode
  43. new cvar_predator_grenade_frost, cvar_predator_grenade_fire, cvar_predator_damage,  cvar_predator_damage2
  44. new cvar_predator_glow
  45.  
  46. public plugin_init()
  47. {
  48.     register_plugin("[ZP] Class: Predator", ZP_VERSION_STRING, "AntiChrist")
  49.    
  50.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  51.     RegisterHamBots(Ham_TakeDamage, "fw_TakeDamage")
  52.     RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  53.     RegisterHamBots(Ham_Killed, "fw_PlayerKilled")
  54.     register_forward(FM_ClientDisconnect, "fw_ClientDisconnect_Post", 1)
  55.     register_event("Damage", "Damage", "b", "2!=0")
  56.    
  57.     g_MaxPlayers = get_maxplayers()
  58.    
  59.     cvar_predator_health = register_cvar("zp_predator_health", "0")
  60.     cvar_predator_base_health = register_cvar("zp_predator_base_health", "2000")
  61.     cvar_predator_speed = register_cvar("zp_predator_speed", "1.2")
  62.     cvar_predator_gravity = register_cvar("zp_predator_gravity", "0.4")
  63.     cvar_predator_damage = register_cvar("zp_predator_damage", "150.0")
  64.     cvar_predator_damage2 = register_cvar("zp_predator_damage2", "50.0")
  65.     cvar_predator_kill_explode = register_cvar("zp_predator_kill_explode", "1")
  66.     cvar_predator_glow = register_cvar("zp_predator_glow", "1")
  67.     cvar_predator_grenade_frost = register_cvar("zp_predator_grenade_frost", "0")
  68.     cvar_predator_grenade_fire = register_cvar("zp_predator_grenade_fire", "1")
  69. }
  70.  
  71. public plugin_precache()
  72. {
  73.     // Initialize arrays
  74.     g_models_predator_player = ArrayCreate(PLAYERMODEL_MAX_LENGTH, 1)
  75.     g_models_predator_claw = ArrayCreate(MODEL_MAX_LENGTH, 1)
  76.    
  77.     // Load from external file
  78.     amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Player Models", "PREDATOR", g_models_predator_player)
  79.     amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Weapon Models", "V_KNIFE ASSASSIN", g_models_predator_claw)
  80.    
  81.     // If we couldn't load from file, use and save default ones
  82.     new index
  83.     if (ArraySize(g_models_predator_player) == 0)
  84.     {
  85.         for (index = 0; index < sizeof models_predator_player; index++)
  86.             ArrayPushString(g_models_predator_player, models_predator_player[index])
  87.        
  88.         // Save to external file
  89.         amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Player Models", "PREDATOR", g_models_predator_player)
  90.     }
  91.     if (ArraySize(g_models_predator_claw) == 0)
  92.     {
  93.         for (index = 0; index < sizeof models_predator_claw; index++)
  94.             ArrayPushString(g_models_predator_claw, models_predator_claw[index])
  95.        
  96.         // Save to external file
  97.         amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Weapon Models", "V_KNIFE ASSASSIN", g_models_predator_claw)
  98.     }
  99.    
  100.     // Precache models
  101.     new player_model[PLAYERMODEL_MAX_LENGTH], model[MODEL_MAX_LENGTH], model_path[128]
  102.     for (index = 0; index < ArraySize(g_models_predator_player); index++)
  103.     {
  104.         ArrayGetString(g_models_predator_player, index, player_model, charsmax(player_model))
  105.         formatex(model_path, charsmax(model_path), "models/player/%s/%s.mdl", player_model, player_model)
  106.         precache_model(model_path)
  107.         // Support modelT.mdl files
  108.         formatex(model_path, charsmax(model_path), "models/player/%s/%sT.mdl", player_model, player_model)
  109.         if (file_exists(model_path)) precache_model(model_path)
  110.     }
  111.     for (index = 0; index < ArraySize(g_models_predator_claw); index++)
  112.     {
  113.         ArrayGetString(g_models_predator_claw, index, model, charsmax(model))
  114.         precache_model(model)
  115.     }
  116. }
  117.  
  118. public plugin_natives()
  119. {
  120.     register_library("zp50_class_predator")
  121.     register_native("zp_class_predator_get", "native_class_predator_get")
  122.     register_native("zp_class_predator_set", "native_class_predator_set")
  123.     register_native("zp_class_predator_get_count", "native_class_predator_get_count")
  124.    
  125.     set_module_filter("module_filter")
  126.     set_native_filter("native_filter")
  127. }
  128. public module_filter(const module[])
  129. {
  130.     if (equal(module, LIBRARY_GRENADE_FROST) || equal(module, LIBRARY_GRENADE_FIRE))
  131.         return PLUGIN_HANDLED;
  132.    
  133.     return PLUGIN_CONTINUE;
  134. }
  135. public native_filter(const name[], index, trap)
  136. {
  137.     if (!trap)
  138.         return PLUGIN_HANDLED;
  139.        
  140.     return PLUGIN_CONTINUE;
  141. }
  142.  
  143. public fw_ClientDisconnect_Post(id)
  144. {
  145.     // Reset flags AFTER disconnect (to allow checking if the player was assassin before disconnecting)
  146.     flag_unset(g_Ispredator, id)
  147.     if (get_pcvar_num(cvar_predator_glow))
  148.             set_user_rendering(id)
  149. }
  150.  
  151. // Ham Take Damage Forward
  152. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
  153. {
  154.     g_currentweapon[attacker] = read_data(2)
  155.    
  156.     // Non-player damage or self damage
  157.     if (victim == attacker || !is_user_alive(attacker))
  158.         return HAM_IGNORED;
  159.        
  160.     // Nemesis attacking human
  161.     if (flag_get(g_Ispredator, attacker) && !zp_core_is_zombie(victim))
  162.     {
  163.         // Ignore nemesis damage override if damage comes from a 3rd party entity
  164.         // (to prevent this from affecting a sub-plugin's rockets e.g.)
  165.         if (inflictor == attacker  &&  g_currentweapon[attacker] == CSW_KNIFE  &&   get_user_button(attacker) & IN_ATTACK2)
  166.         {
  167.             // Set nemesis damage
  168.             SetHamParamFloat(4, get_pcvar_float(cvar_predator_damage))
  169.             return HAM_HANDLED;
  170.         }
  171.         else
  172.         {
  173.         SetHamParamFloat(4, get_pcvar_float(cvar_predator_damage2))
  174.             return HAM_HANDLED;
  175.         }
  176.        
  177.     }
  178. }
  179.  
  180. // Ham Player Killed Forward
  181. public fw_PlayerKilled(victim, attacker, shouldgib)
  182. {
  183.     if (flag_get(g_Ispredator, victim))
  184.     {
  185.         // assassin explodes!
  186.         if (get_pcvar_num(cvar_predator_kill_explode))
  187.             SetHamParamInteger(3, 2)
  188.     }
  189. }
  190.  
  191. public zp_fw_grenade_frost_pre(id)
  192. {
  193.     // Prevent frost for assassin
  194.     if (flag_get(g_Ispredator, id) && !get_pcvar_num(cvar_predator_grenade_frost))
  195.         return PLUGIN_HANDLED;
  196.    
  197.     return PLUGIN_CONTINUE;
  198. }
  199.  
  200. public zp_fw_grenade_fire_pre(id)
  201. {
  202.     // Prevent burning for assassin
  203.     if (flag_get(g_Ispredator, id) && !get_pcvar_num(cvar_predator_grenade_fire))
  204.         return PLUGIN_HANDLED;
  205.    
  206.     return PLUGIN_CONTINUE;
  207. }
  208.  
  209. public zp_fw_core_spawn_post(id)
  210. {
  211.     if (flag_get(g_Ispredator, id))
  212.     {
  213.         // Remove assassin flag
  214.         flag_unset(g_Ispredator, id)
  215.     }
  216.     if (get_pcvar_num(cvar_predator_glow))
  217.             set_user_rendering(id)
  218. }
  219.  
  220. public zp_fw_core_cure(id, attacker)
  221. {
  222.     if (flag_get(g_Ispredator, id))
  223.     {
  224.         // Remove assassin flag
  225.         flag_unset(g_Ispredator, id)
  226.     }
  227.     if (get_pcvar_num(cvar_predator_glow))
  228.             set_user_rendering(id)
  229. }
  230.  
  231. public zp_fw_core_infect_post(id, attacker)
  232. {
  233.     // Apply assassin attributes?
  234.     if (!flag_get(g_Ispredator, id))
  235.         return;
  236.    
  237.     // Health
  238.     if (get_pcvar_num(cvar_predator_health) == 0)
  239.         set_user_health(id, get_pcvar_num(cvar_predator_base_health) * GetAliveCount())
  240.     else
  241.         set_user_health(id, get_pcvar_num(cvar_predator_health))
  242.    
  243.     // Gravity
  244.     set_user_gravity(id, get_pcvar_float(cvar_predator_gravity))
  245.    
  246.     // Speed
  247.     cs_set_player_maxspeed_auto(id, get_pcvar_float(cvar_predator_speed))
  248.    
  249.     // Apply assassin player model
  250.     new player_model[PLAYERMODEL_MAX_LENGTH]
  251.     ArrayGetString(g_models_predator_player, random_num(0, ArraySize(g_models_predator_player) - 1), player_model, charsmax(player_model))
  252.     cs_set_player_model(id, player_model)
  253.    
  254.     // Apply assassin claw model
  255.     new model[MODEL_MAX_LENGTH]
  256.     ArrayGetString(g_models_predator_claw, random_num(0, ArraySize(g_models_predator_claw) - 1), model, charsmax(model))
  257.     cs_set_player_view_model(id, CSW_KNIFE, model) 
  258.    
  259.     // assassin glow
  260.     if (get_pcvar_num(cvar_predator_glow))
  261.         set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 5)
  262. }
  263.  
  264. public native_class_predator_get(plugin_id, num_params)
  265. {
  266.     new id = get_param(1)
  267.    
  268.     if (!is_user_connected(id))
  269.     {
  270.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  271.         return -1;
  272.     }
  273.    
  274.     return flag_get_boolean(g_Ispredator, id);
  275. }
  276.  
  277. public native_class_predator_set(plugin_id, num_params)
  278. {
  279.     new id = get_param(1)
  280.    
  281.     if (!is_user_alive(id))
  282.     {
  283.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  284.         return false;
  285.     }
  286.    
  287.     if (flag_get(g_Ispredator, id))
  288.     {
  289.         log_error(AMX_ERR_NATIVE, "[ZP] Player already a predator (%d)", id)
  290.         return false;
  291.     }
  292.    
  293.     flag_set(g_Ispredator, id)
  294.     zp_core_force_infect(id)
  295.     return true;
  296. }
  297.  
  298. public native_class_predator_get_count(plugin_id, num_params)
  299. {
  300.     return GetpredatorCount();
  301. }
  302.  
  303.  
  304. // Get Alive Count -returns alive players number-
  305. GetAliveCount()
  306. {
  307.     new iAlive, id
  308.    
  309.     for (id = 1; id <= g_MaxPlayers; id++)
  310.     {
  311.         if (is_user_alive(id))
  312.             iAlive++
  313.     }
  314.    
  315.     return iAlive;
  316. }
  317.  
  318. // Get assassin Count -returns alive assassin number-
  319. GetpredatorCount()
  320. {
  321.     new ipredator, id
  322.    
  323.     for (id = 1; id <= g_MaxPlayers; id++)
  324.     {
  325.         if (is_user_alive(id) && flag_get(g_Ispredator, id))
  326.             ipredator++
  327.     }
  328.    
  329.     return ipredator;
  330. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top