SHARE
TWEET

fix deimos zp class

a guest Sep 23rd, 2015 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <engine>
  5. #include <cstrike>
  6. #include <hamsandwich>
  7. #include <zombieplague>
  8. #include <zmvip>
  9.  
  10. #define PLUGIN "Zombie Class Deimos"
  11. #define VERSION "1.2.3"
  12. #define AUTHOR "NST Team"
  13.  
  14. new spr_skill[] = "g_tentacle"
  15. new const light_classname[] = "nst_deimos_skill"
  16.  
  17. new sprites_exp_index, sprites_trail_index
  18.  
  19. new g_wait[33], g_check[33], g_useskill[33], g_msgStatusIcon, g_zclass_deimos, g_msgScreenFade, g_msgScreenShake
  20. new g_CurWeapon[33], g_bombmodelwpn[64]
  21.  
  22. const WPN_NOT_DROP = ((1<<2)|(1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))
  23. enum (+= 100)
  24. {
  25.         TASK_WAIT = 2000,
  26.         TASK_ATTACK,
  27.         TASK_BOT_USE_SKILL,
  28.         TASK_USE_SKILL
  29. }
  30. // IDs inside tasks
  31. #define ID_WAIT (taskid - TASK_WAIT)
  32. #define ID_ATTACK (taskid - TASK_ATTACK)
  33. #define ID_BOT_USE_SKILL (taskid - TASK_BOT_USE_SKILL)
  34. #define ID_USE_SKILL (taskid - TASK_USE_SKILL)
  35.  
  36. const m_flTimeWeaponIdle = 48
  37. const m_flNextAttack = 83
  38.  
  39. new const sprites_exp[] = "sprites/deimosexp.spr"
  40. new const sprites_trail[] = "sprites/trail.spr"
  41. new const sound_skill_start[] = "zombie_plague/deimos_skill_start.wav"
  42. new const sound_skill_hit[] = "zombie_plague/deimos_skill_hit.wav"
  43. const skill_dmg = 0
  44. const skill_anim = 11
  45. const Float:skill_time_wait = 12.0
  46.  
  47. new const zclass_name[] = { "Deimos Zombie" }
  48. new const zclass_info[] = { "(Drop human weapon key G)" }
  49. new const zclass_model[] = { "zombi_deimos_new" }
  50. new const zclass_clawmodel[] = { "claws_deimos_new.mdl" }
  51. const zclass_health = 3500
  52. const zclass_speed = 240
  53. const Float:zclass_gravity = 1.0
  54. const Float:zclass_knockback = 1.0
  55.  
  56. #define OFFSET_MODELINDEX 491
  57. #define OFFSET_LINUX 5
  58.  
  59. new index, defaultindex
  60.  
  61. new const WeaponNames[][] =
  62. {
  63.                 "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
  64.                 "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
  65.                 "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  66.                 "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  67.                 "weapon_ak47", "weapon_knife", "weapon_p90"
  68. }
  69.  
  70. const FFADE_IN =                0x0000
  71.  
  72. public plugin_init()
  73. {
  74.         register_plugin(PLUGIN, VERSION, AUTHOR)
  75.        
  76.         // msg
  77.         g_msgStatusIcon = get_user_msgid("StatusIcon")
  78.         g_msgScreenFade = get_user_msgid( "ScreenFade" );
  79.         g_msgStatusIcon = get_user_msgid("StatusIcon");
  80.        
  81.         // Events
  82.         register_logevent("logevent_round_start",2, "1=Round_Start")
  83.         register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  84.         register_event("DeathMsg", "Death", "a")
  85.         register_event("CurWeapon", "Event_CurrentWeapon", "be", "1=1")
  86.  
  87.         for (new i = 1; i < sizeof WeaponNames; i++)
  88.         if (WeaponNames[i][0]) RegisterHam(Ham_Item_Deploy, WeaponNames[i], "fw_Weapon_Deploy_Post", 1)
  89.        
  90.         // FM Forwards
  91.         register_forward(FM_CmdStart, "fw_CmdStart")
  92.         register_forward(FM_Touch, "fw_Touch")
  93.  
  94.         // Cmd
  95.         register_concmd("drop", "use_skill")
  96. }
  97.  
  98. public plugin_precache()
  99. {
  100.         formatex(g_bombmodelwpn, charsmax(g_bombmodelwpn), "models/zombie_plague/v_zombibomb_gs.mdl")
  101.        
  102.         engfunc(EngFunc_PrecacheModel, g_bombmodelwpn)
  103.        
  104.         g_zclass_deimos = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
  105.        
  106.         sprites_exp_index = precache_model(sprites_exp)
  107.         sprites_trail_index = precache_model(sprites_trail)
  108.         precache_sound(sound_skill_start)
  109.         precache_sound(sound_skill_hit)
  110.        
  111.         index = precache_model("models/player/zombi_deimos_new/zombi_deimos_new.mdl")
  112.         defaultindex = precache_model("models/player.mdl")
  113. }
  114.  
  115. public zp_user_infected_pre(id) {
  116.     if(zv_get_user_flags(id) == 0) {
  117.         if(zp_get_user_next_class(id) == g_zclass_deimos) {
  118.             zp_set_user_zombie_class(id, 0)
  119.             client_print(id, print_center, "Your selected class in only for *VIP* members")
  120.             client_print(id, print_chat, "Your selected class in only for *VIP* members. Changed to default zombie class.")
  121.         }
  122.     }
  123. }
  124.  
  125. public Event_CurrentWeapon(id) g_CurWeapon[id] = read_data(2)
  126.  
  127. public event_round_start()
  128. {
  129.         for (new id=1; id<33; id++)
  130.         {
  131.                 if (!is_user_connected(id)) continue;
  132.                
  133.                 reset_value_player(id)
  134.                 StatusIcon(id, spr_skill, 0)
  135.         }
  136. }
  137.  
  138. public zp_user_infected_post(id, infector)
  139. {
  140.         set_wpnmodel(id)
  141.         fm_set_user_model_index(id, index)
  142. }
  143.  
  144. public zp_user_humanized_post(id, survivor)
  145. {
  146.         fm_set_user_model_index(id, defaultindex)
  147. }
  148.  
  149. public logevent_round_start()
  150. {
  151.         for (new id=1; id<33; id++)
  152.         {
  153.                 if (!is_user_connected(id)) continue;
  154.                 if (is_user_bot(id))
  155.                 {
  156.                         if (task_exists(id+TASK_BOT_USE_SKILL)) remove_task(id+TASK_BOT_USE_SKILL)
  157.                         set_task(float(random_num(5,15)), "bot_use_skill", id+TASK_BOT_USE_SKILL)
  158.                 }
  159.         }
  160. }
  161.  
  162. public Death()
  163. {
  164.         new victim = read_data(2)
  165.         StatusIcon(victim, spr_skill, 0)
  166.         reset_value_player(victim)
  167. }
  168.  
  169. public fw_Weapon_Deploy_Post(weapon_ent)
  170. {
  171.         static id; id = get_pdata_cbase(weapon_ent, 41, 4)
  172.  
  173.         static weaponid ; weaponid = cs_get_weapon_id(weapon_ent)
  174.  
  175.         g_CurWeapon[id] = weaponid
  176.        
  177.         replace_weapon_models(id, weaponid)
  178. }
  179.  
  180. public client_connect(id)
  181. {
  182.         reset_value_player(id)
  183. }
  184.  
  185. public client_disconnect(id)
  186. {
  187.         reset_value_player(id)
  188. }
  189.  
  190. reset_value_player(id)
  191. {
  192.         if (task_exists(id+TASK_WAIT)) remove_task(id+TASK_WAIT)
  193.         if (task_exists(id+TASK_BOT_USE_SKILL)) remove_task(id+TASK_BOT_USE_SKILL)
  194.  
  195.         g_wait[id] = 0
  196.         g_check[id] = 0
  197.         g_useskill[id] = 0
  198. }
  199.  
  200. // bot use skill
  201.  
  202. public bot_use_skill(taskid)
  203. {
  204.         new id = ID_BOT_USE_SKILL
  205.         if (!is_user_bot(id)) return;
  206.  
  207.         use_skill(id)
  208.         if (task_exists(taskid)) remove_task(taskid)
  209.         set_task(float(random_num(5,15)), "bot_use_skill", id+TASK_BOT_USE_SKILL)
  210. }
  211.  
  212. public use_skill(id)
  213. {
  214.         if (!is_user_alive(id)) return PLUGIN_CONTINUE
  215.        
  216.         new health = get_user_health(id) - skill_dmg
  217.         if ((zp_get_user_zombie_class(id) == g_zclass_deimos) && (zp_get_user_zombie(id)) && (!g_wait[id]) && (health>0) && (get_user_weapon(id)==CSW_KNIFE))
  218.         {
  219.                 g_useskill[id] = 1
  220.                
  221.                 // set health
  222.                 fm_set_user_health(id, health)
  223.                
  224.                 // set time wait
  225.                 new Float:timewait = skill_time_wait
  226.                
  227.                 g_wait[id] = 1
  228.                 if (task_exists(id+TASK_WAIT)) remove_task(id+TASK_WAIT)
  229.                 set_task(timewait, "RemoveWait", id+TASK_WAIT)
  230.                 return PLUGIN_HANDLED
  231.         }
  232.        
  233.         return PLUGIN_CONTINUE
  234. }
  235.  
  236. public task_use_skill(taskid)
  237. {
  238.         new id = ID_USE_SKILL
  239.        
  240.         // play anim & sound
  241.         play_weapon_anim(id, 8)
  242.         set_weapons_timeidle(id, skill_time_wait)
  243.         set_player_nextattack(id, 0.5)
  244.         PlayEmitSound(id, sound_skill_start)
  245.         entity_set_int(id, EV_INT_sequence, skill_anim)
  246.        
  247.         // attack
  248.         if (task_exists(id+TASK_ATTACK)) remove_task(id+TASK_ATTACK)
  249.         set_task(0.5, "launch_light", id+TASK_ATTACK)
  250. }
  251.  
  252. public launch_light(taskid)
  253. {
  254.         new id = ID_ATTACK
  255.         if (task_exists(id+TASK_ATTACK)) remove_task(id+TASK_ATTACK)
  256.        
  257.         if (!is_user_alive(id)) return;
  258.        
  259.         // check
  260.         new Float: fOrigin[3], Float:fAngle[3],Float: fVelocity[3]
  261.         pev(id, pev_origin, fOrigin)
  262.         pev(id, pev_view_ofs, fAngle)
  263.         fm_velocity_by_aim(id, 2.0, fVelocity, fAngle)
  264.         fAngle[0] *= -1.0
  265.        
  266.         // create ent
  267.         new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  268.         set_pev(ent, pev_classname, light_classname)
  269.         engfunc(EngFunc_SetModel, ent, "models/w_hegrenade.mdl")
  270.         set_pev(ent, pev_mins, Float:{-1.0, -1.0, -1.0})
  271.         set_pev(ent, pev_maxs, Float:{1.0, 1.0, 1.0})
  272.         set_pev(ent, pev_origin, fOrigin)
  273.         fOrigin[0] += fVelocity[0]
  274.         fOrigin[1] += fVelocity[1]
  275.         fOrigin[2] += fVelocity[2]
  276.         set_pev(ent, pev_movetype, MOVETYPE_BOUNCE)
  277.         set_pev(ent, pev_gravity, 0.01)
  278.         fVelocity[0] *= 1000
  279.         fVelocity[1] *= 1000
  280.         fVelocity[2] *= 1000
  281.         set_pev(ent, pev_velocity, fVelocity)
  282.         set_pev(ent, pev_owner, id)
  283.         set_pev(ent, pev_angles, fAngle)
  284.         set_pev(ent, pev_solid, SOLID_BBOX)                                             //store the enitty id
  285.        
  286.         // invisible ent
  287.         fm_set_rendering(ent, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 0)
  288.        
  289.         // show trail  
  290.         message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  291.         write_byte(TE_BEAMFOLLOW)
  292.         write_short(ent)                                //entity
  293.         write_short(sprites_trail_index)                //model
  294.         write_byte(5)           //10)//life
  295.         write_byte(3)           //5)//width
  296.         write_byte(102)                                 //r, hegrenade
  297.         write_byte(45)                                  //g, gas-grenade
  298.         write_byte(145)                                 //b
  299.         write_byte(200)         //brightness
  300.         message_end()                                   //move PHS/PVS data sending into here (SEND_ALL, SEND_PVS, SEND_PHS)
  301.        
  302.         //client_print(0, print_chat, "phong")
  303.         return;
  304. }
  305.  
  306. public fw_Touch(ent, victim)
  307. {
  308.         if (!pev_valid(ent)) return FMRES_IGNORED
  309.        
  310.         new EntClassName[32]
  311.         entity_get_string(ent, EV_SZ_classname, EntClassName, charsmax(EntClassName))
  312.        
  313.         if (equal(EntClassName, light_classname))
  314.         {
  315.                 light_exp(ent, victim)
  316.                 remove_entity(ent)
  317.                 return FMRES_IGNORED
  318.         }
  319.        
  320.         return FMRES_IGNORED
  321. }
  322.  
  323. light_exp(ent, victim)
  324. {
  325.         if (!pev_valid(ent)) return;
  326.        
  327.         // drop current wpn of victim
  328.         new attacker = pev(ent, pev_owner)
  329.         if (is_user_alive(victim) && !zp_get_user_survivor(victim) && (zp_get_user_zombie(attacker) != zp_get_user_zombie(victim)))
  330.         {
  331.                 new wpn, wpnname[32]
  332.                 wpn = get_user_weapon(victim)
  333.                 if( !(WPN_NOT_DROP & (1<<wpn)) && get_weaponname(wpn, wpnname, charsmax(wpnname)) )
  334.                 {
  335.                         engclient_cmd(victim, "drop", wpnname)
  336.                    
  337.                         screen_effects(victim)
  338.                 }
  339.         }
  340.        
  341.         // create effect
  342.         static Float:origin[3];
  343.         pev(ent, pev_origin, origin);
  344.         message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  345.         write_byte(TE_EXPLOSION); // TE_EXPLOSION
  346.         write_coord(floatround(origin[0])); // origin x
  347.         write_coord(floatround(origin[1])); // origin y
  348.         write_coord(floatround(origin[2])); // origin z
  349.         write_short(sprites_exp_index); // sprites
  350.         write_byte(40); // scale in 0.1's
  351.         write_byte(30); // framerate
  352.         write_byte(14); // flags
  353.         message_end(); // message end
  354.        
  355.         // play sound exp
  356.         PlayEmitSound(ent, sound_skill_hit)
  357. }
  358.  
  359. public RemoveWait(taskid)
  360. {
  361.         new id = ID_WAIT
  362.         g_wait[id] = 0
  363.         if (task_exists(taskid)) remove_task(taskid)
  364. }
  365.  
  366. public fw_CmdStart(id, uc_handle, seed)
  367. {
  368.         if (!is_user_alive(id)) return FMRES_IGNORED
  369.        
  370.         if (zp_get_user_zombie_class(id) == g_zclass_deimos && zp_get_user_zombie(id))
  371.         {
  372.                 // show status icon help
  373.                 if (g_wait[id] && g_check[id] != 2)
  374.                 {
  375.                         g_check[id] = 2
  376.                         StatusIcon(id, spr_skill, 2)
  377.                 }
  378.                 else if (!g_wait[id] && g_check[id] != 1)
  379.                 {
  380.                         g_check[id] = 1
  381.                         StatusIcon(id, spr_skill, 1)
  382.                 }
  383.                
  384.                 // use skill
  385.                 if (g_useskill[id])
  386.                 {
  387.                         set_uc(uc_handle, UC_Buttons, IN_ATTACK2)
  388.                         g_useskill[id] = 0
  389.                         entity_set_int(id, EV_INT_sequence, skill_anim)
  390.                        
  391.                         if (task_exists(id+TASK_USE_SKILL)) remove_task(id+TASK_USE_SKILL)
  392.                         set_task(0.0, "task_use_skill", id+TASK_USE_SKILL)
  393.                 }
  394.         }
  395.         else if (g_check[id])
  396.         {
  397.                 // hide status icon
  398.                 g_check[id] = 0
  399.                 StatusIcon(id, spr_skill, 0)
  400.         }
  401.        
  402.         //client_print(id, print_chat, "[%i]", set_animation(id))
  403.         return FMRES_IGNORED
  404. }
  405.  
  406. set_wpnmodel(id)
  407. {
  408.         if (!is_user_alive(id)) return;
  409.  
  410.         new wpn = get_user_weapon(id)
  411.  
  412.         if (wpn == CSW_HEGRENADE || wpn == CSW_FLASHBANG || wpn == CSW_SMOKEGRENADE)
  413.         {
  414.     set_pev(id, pev_viewmodel2, g_bombmodelwpn)
  415.         }
  416.        
  417. }
  418.  
  419. PlayEmitSound(id, const sound[])
  420. {
  421.         emit_sound(id, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  422. }
  423.  
  424. StatusIcon(id, sprname[], run)
  425. {      
  426.         if (!is_user_connected(id)) return;
  427.        
  428.         message_begin(MSG_ONE, g_msgStatusIcon, {0,0,0}, id);
  429.         write_byte(run); // status (0=hide, 1=show, 2=flash)
  430.         write_string(sprname); // sprite name
  431.         message_end();
  432. }
  433.  
  434. play_weapon_anim(player, anim)
  435. {
  436.         set_pev(player, pev_weaponanim, anim)
  437.         message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
  438.         write_byte(anim)
  439.         write_byte(pev(player, pev_body))
  440.         message_end()
  441. }
  442.  
  443. fm_velocity_by_aim(iIndex, Float:fDistance, Float:fVelocity[3], Float:fViewAngle[3])
  444. {
  445.         //new Float:fViewAngle[3]
  446.         pev(iIndex, pev_v_angle, fViewAngle)
  447.         fVelocity[0] = floatcos(fViewAngle[1], degrees) * fDistance
  448.         fVelocity[1] = floatsin(fViewAngle[1], degrees) * fDistance
  449.         fVelocity[2] = floatcos(fViewAngle[0]+90.0, degrees) * fDistance
  450.         return 1
  451. }
  452.  
  453. get_weapon_ent(id, weaponid)
  454. {
  455.         static wname[32], weapon_ent
  456.         get_weaponname(weaponid, wname, charsmax(wname))
  457.         weapon_ent = fm_find_ent_by_owner(-1, wname, id)
  458.         return weapon_ent
  459. }
  460. set_weapons_timeidle(id, Float:timeidle)
  461. {
  462.         new entwpn = get_weapon_ent(id, get_user_weapon(id))
  463.         if (pev_valid(entwpn)) set_pdata_float(entwpn, m_flTimeWeaponIdle, timeidle+3.0, 4)
  464. }
  465. set_player_nextattack(id, Float:nexttime)
  466. {
  467.         set_pdata_float(id, m_flNextAttack, nexttime, 4)
  468. }
  469. // Set player's health (from fakemeta_util)
  470. stock fm_set_user_health(id, health)
  471. {
  472.         (health > 0) ? set_pev(id, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, id);
  473. }
  474. // Set entity's rendering type (from fakemeta_util)
  475. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  476. {
  477.         static Float:color[3]
  478.         color[0] = float(r)
  479.         color[1] = float(g)
  480.         color[2] = float(b)
  481.        
  482.         set_pev(entity, pev_renderfx, fx)
  483.         set_pev(entity, pev_rendercolor, color)
  484.         set_pev(entity, pev_rendermode, render)
  485.         set_pev(entity, pev_renderamt, float(amount))
  486. }
  487. // Find entity by its owner (from fakemeta_util)
  488. stock fm_find_ent_by_owner(entity, const classname[], owner)
  489. {
  490.         while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) { /* keep looping */ }
  491.         return entity;
  492. }
  493.  
  494. replace_weapon_models(id, weaponid)
  495. {
  496.         if (zp_get_user_zombie_class(id) == g_zclass_deimos && zp_get_user_zombie(id))
  497.         {
  498.                 switch(weaponid)
  499.                 {
  500.                         case CSW_HEGRENADE:
  501.                         {
  502.                                 set_pev(id, pev_viewmodel2, g_bombmodelwpn)
  503.                         }
  504.                         case CSW_SMOKEGRENADE:
  505.                         {
  506.                                 set_pev(id, pev_viewmodel2, g_bombmodelwpn)
  507.                         }
  508.                         case CSW_FLASHBANG:
  509.                         {
  510.                                 set_pev(id, pev_viewmodel2, g_bombmodelwpn)
  511.                         }
  512.                 }
  513.         }
  514. }
  515.  
  516. screen_effects(victim)
  517. {
  518.         // Screen Fade
  519.         message_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade, _, victim)
  520.         write_short ( 1<<13 ) // Duration
  521.         write_short ( 1<<14 ) // Hold Time
  522.         write_short ( FFADE_IN ) // Fade type
  523.         write_byte ( random_num ( 50, 200 ) ) // Red amount
  524.         write_byte ( random_num ( 50, 200 ) ) // Green amount
  525.         write_byte ( random_num ( 50, 200 ) ) // Blue amount
  526.         write_byte ( random_num ( 50, 200 ) ) // Alpha
  527.         message_end ( )
  528.         // Screen Shake
  529.         message_begin(MSG_ONE_UNRELIABLE, g_msgScreenShake, _, victim)
  530.         write_short ( 0xFFFF ) // Amplitude
  531.         write_short ( 1<<13 ) // Duration
  532.         write_short ( 0xFFFF ) // Frequency
  533.         message_end ( )
  534. }
  535.  
  536. stock fm_set_user_model_index(id, value)
  537. {
  538.     set_pdata_int(id, OFFSET_MODELINDEX, value, OFFSET_LINUX)
  539. }
RAW Paste Data
Top