Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2014
597
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 13.67 KB | None | 0 0
  1. /*
  2.     Plugin generated by AMXX-Studio
  3.    
  4.     Plugin: [KF Like] JackZombie special to NewYear Zombie-Mod.ru //SlowPocke.jpg
  5.     Creator: Chrescoe1
  6.     Version: 0.0 //i con't test it on ZP - if you found Bugs - write me please Skype: Xailer24
  7.    
  8.     01.01.2014 19:27 - Code make started
  9.     01.01.2014 20:14 - First Test
  10.     01.01.2014 20:27 - 20:35 Drink Coffe - AFK
  11.     01.01.2014 22:48 - Test Ending - Version 0.0 Released - Upload to Zombie-Mod.ru
  12.    
  13.     01.04.2014 00:00 - Fixed little bug with rendering
  14.  
  15. */
  16.  
  17. #include <amxmodx>
  18. #include <hamsandwich>
  19. #include <fakemeta_util>
  20.  
  21. #define PLUGIN "[IceFire] JackFrost"
  22. #define VERSION "0.1"
  23. #define AUTHOR "Chrescoe1"
  24.  
  25. //#define TestingTime   //I test this plugin on public server
  26.  
  27. #if !defined TestingTime
  28.     //Zombie Settings
  29.     #include <zombieplague>
  30.     new Jack
  31.     const Health = 500
  32.     const Speed = 220
  33.     const Float:Gravity = 0.8
  34.     const Float:KickBack = 1.1
  35.    
  36. #endif
  37.  
  38. #define FireShpere_Classname "ZP_Jack_FireShpere"
  39. #define FrostSphere_Classname "ZP_Jack_FrostSphere"
  40.  
  41. #define CDHudChannel 4
  42.  
  43. #define Model "jack_frost"
  44. #define Claw "v_jackfrost.mdl"
  45. #define Shpere "models/w_flashbang.mdl"
  46. #define Trail "sprites/xenobeam.spr"
  47. #define Burn "sprites/xflare2.spr"
  48. #define ThrowFireShpereSound "FireBallMissileLaunch3.wav"
  49.  
  50.  
  51. const Float:FireShpereExplodeRadius = 140.0
  52. const Float:FireShpereExplodeDamage = 15.0
  53. const Float:FireShpere_CD=30.0
  54.  
  55. const Float:FireShpere_BurnTime = 6.0
  56. const Float:BurnDamage = 3.0
  57. const Float:BurnUpdate = 0.5    //Damage == FireShpere_BurnTime/BurnUpdate*BurnDamage
  58.  
  59.  
  60. const Float:FrostSphereExplodeRadius = 170.0
  61. const Float:FrostSphereExplodeDamage = 35.0
  62. const Float:FrostSphere_CD=20.0
  63. const Float:FrostSphere_FreezeTime = 8.0
  64.  
  65.  
  66. new bool:Can_Use_Ability[32],Selected_Ability[32],Float:Ability_CD[32],Float:UpdateHud[32]
  67. new bool:in_frost[32],Float:FrostTime[32]
  68. new bool:in_burn[32],Float:BurnTime[32],BurnOwner[32],Float:BurnUpdateDamage[32]
  69.  
  70. new MaxPlayers,Msg_ScreenShake,Msg_ScreenFade,TrailSpriteIndex,BurnSprite
  71.  
  72. public plugin_precache()
  73. {
  74.     precache_model(Shpere)
  75.     TrailSpriteIndex=precache_model(Trail)
  76.     BurnSprite=precache_model(Burn)
  77.     precache_sound(ThrowFireShpereSound)
  78. }
  79. public plugin_init()
  80. {
  81.     register_plugin(PLUGIN, VERSION, AUTHOR)
  82.     Msg_ScreenShake = get_user_msgid("ScreenShake")
  83.     Msg_ScreenFade = get_user_msgid("ScreenFade")
  84.     MaxPlayers = get_maxplayers()
  85.    
  86.     //Register Class
  87.     #if !defined TestingTime
  88.         Jack=zp_register_zombie_class("Jack Frost","Throw FireShpere and FrostSphere",Model,Claw,Health,Speed,Gravity,KickBack)
  89.     #endif
  90.    
  91.     //Ham
  92.     RegisterHam(Ham_Touch, "info_target", "Ham_Touch_Pre")
  93.    
  94.     //CMD
  95.     register_clcmd("drop","use_ability")    //Becouse ZP block impulse 100 =|
  96.     // Add your code here...
  97. }
  98. //Cmd Drop
  99. public use_ability(id)
  100. {
  101.     if(!is_user_connected(id))return
  102.     if(!is_user_alive(id))return
  103.     #if !defined TestingTime
  104.     if(!zp_get_user_zombie(id))return
  105.     if(zp_get_user_nemesis(id))return
  106.     if(zp_get_user_zombie_class(id)!=Jack)return
  107.     #endif
  108.     if(!Can_Use_Ability[id-1])return
  109.     new Float: gametime = get_gametime()
  110.     switch(Selected_Ability[id-1])
  111.     {
  112.         case 0:throw_Shpere(id,1),Ability_CD[id-1]=gametime+FireShpere_CD,Can_Use_Ability[id-1]=false
  113.         case 1:throw_Shpere(id,2),Ability_CD[id-1]=gametime+FrostSphere_CD,Can_Use_Ability[id-1]=false
  114.     }  
  115. }
  116. //Ham
  117. public Ham_Touch_Pre(ent,world)
  118. {
  119.     if(!pev_valid(ent))return HAM_IGNORED
  120.    
  121.     new Classname[32]
  122.     pev(ent, pev_classname, Classname, sizeof(Classname))
  123.     if(!equal(Classname, FireShpere_Classname)&&!equal(Classname, FrostSphere_Classname))return HAM_IGNORED
  124.    
  125.     new Float:Origin[3],id = pev(ent,pev_owner)
  126.                
  127.     pev(ent,pev_origin,Origin)
  128.     new victim =-1,Float:Damage_Radius,Float:Damage,attacker
  129.     switch(pev(ent,pev_iuser1))
  130.     {
  131.         case 1:Damage_Radius=FireShpereExplodeRadius,Damage=FireShpereExplodeDamage,Light(Origin,30,255,105,0,4),DrawRings(Origin,255,105,0)
  132.         case 2:Damage_Radius=FrostSphereExplodeRadius,Damage=FrostSphereExplodeDamage,Light(Origin,30,0,105,255,4),DrawRings(Origin,0,105,255)
  133.     }
  134.    
  135.    
  136.     while((victim = engfunc(EngFunc_FindEntityInSphere, victim, Origin, Damage_Radius)) != 0)
  137.     {
  138.         if(pev_valid(victim)&&pev(victim, pev_takedamage)!=DAMAGE_NO&&pev(victim, pev_solid)!=SOLID_NOT)
  139.         {
  140.             if(is_user_connected(victim))
  141.             {
  142.                 #if defined TestingTime
  143.                 if(get_user_team(victim)!=get_user_team(id))
  144.                 #else
  145.                 if(!zp_get_user_zombie(victim))
  146.                 #endif
  147.                 {
  148.                     if(pev(victim,pev_armorvalue)<=0.0&&pev(victim,pev_health)<Damage)attacker=id;else attacker=0
  149.                     switch(pev(ent,pev_iuser1))
  150.                     {
  151.                         case 1: ExecuteHamB(Ham_TakeDamage,victim, ent,attacker, Damage, DMG_BURN),ScreenFade(victim,6,1,{255,125,0},125,1),fm_set_rendering(victim),
  152.                             BurnTime[victim-1]=get_gametime()+FireShpere_BurnTime,in_burn[victim-1]=true,in_frost[victim-1]=false,BurnOwner[victim-1]=id
  153.                         case 2: ExecuteHamB(Ham_TakeDamage,victim, ent,attacker, Damage, DMG_FREEZE),ScreenFade(victim,6,1,{0,0,255},125,1),
  154.                             FrostTime[victim-1]=get_gametime()+FrostSphere_FreezeTime,in_frost[victim-1]=true,in_burn[victim-1]=false,
  155.                             fm_set_rendering(victim, kRenderFxGlowShell, 0,105,255, kRenderNormal,15)
  156.                     }
  157.                     ScreenShake(victim, ((1<<12) * 3), ((2<<12) * 3))
  158.                 }
  159.             }
  160.             else ExecuteHamB(Ham_TakeDamage,victim, ent,id, Damage, DMG_BLAST)  //take damage entity
  161.         }
  162.     }
  163.     if(pev_valid(ent))engfunc(EngFunc_RemoveEntity, ent)    //Remove sphere after blast!
  164.     return HAM_HANDLED
  165. }
  166.            
  167. //ZP
  168. #if !defined TestingTime
  169. public zp_user_infected_post(id,infector,nemesis)if(zp_get_user_zombie_class(id)!=Jack)if(!zp_get_user_nemesis(id))Can_Use_Ability[id-1]=true
  170. public zp_user_humanized_post(id)Can_Use_Ability[id-1]=false
  171. public zp_round_ended(WINTEAM)for(new i=1;i<MaxPlayers;i++)if(is_user_connected(i))if(in_frost[i-1]||in_burn[i-1])in_frost[i-1]=false,in_burn[i-1]=false,fm_set_rendering(i)
  172. #endif
  173. //Standart Forwards
  174. public client_connect(id)Can_Use_Ability[id-1]=false,Selected_Ability[id-1]=0
  175. public client_PreThink(id)
  176. {
  177.     new Float:gametime = get_gametime()
  178.     if(in_frost[id-1])
  179.         #if defined TestingTime
  180.         if(FrostTime[id-1]<gametime||!is_user_alive(id))
  181.         #else
  182.         if(FrostTime[id-1]<gametime||!is_user_alive(id)||zp_get_user_zombie(id))
  183.         #endif
  184.             fm_set_rendering(id),
  185.             in_frost[id-1]=false
  186.         else
  187.             {set_pev(id,pev_velocity,{0.0,0.0,0.0});new Float:Origin[3];pev(id,pev_origin,Origin);Light(Origin,15,0,105,255,4);}
  188.     if(in_burn[id-1])
  189.         #if defined TestingTime
  190.         if(BurnTime[id-1]<gametime||!is_user_alive(id))
  191.         #else
  192.         if(BurnTime[id-1]<gametime||!is_user_alive(id)||zp_get_user_zombie(id))
  193.         #endif
  194.             in_burn[id-1]=false
  195.         else
  196.             if(BurnUpdateDamage[id-1]<gametime)
  197.             {
  198.                 if(pev(id,pev_armorvalue)<=0.0&&pev(id,pev_health)<BurnDamage)ExecuteHamB(Ham_TakeDamage,id, 0,BurnOwner[id-1], BurnDamage, DMG_BURN)
  199.                 else ExecuteHamB(Ham_TakeDamage,id, 0,0, BurnDamage, DMG_BURN)
  200.                
  201.                 BurnUpdateDamage[id-1]=gametime+BurnUpdate
  202.                
  203.                 new Float:Origin[3]
  204.                 pev(id,pev_origin,Origin)
  205.                 engfunc(EngFunc_MessageBegin, MSG_BROADCAST, SVC_TEMPENTITY, Origin, 0)
  206.                 write_byte(TE_SPRITE) // TE id
  207.                 engfunc(EngFunc_WriteCoord, Origin[0]+random_float(-5.0, 5.0)) // x
  208.                 engfunc(EngFunc_WriteCoord, Origin[1]+random_float(-5.0, 5.0)) // y
  209.                 engfunc(EngFunc_WriteCoord, Origin[2]+random_float(-10.0, 10.0)) // z
  210.                 write_short(BurnSprite) // sprite
  211.                 write_byte(random_num(5, 10)) // scale
  212.                 write_byte(200) // brightness
  213.                 message_end()
  214.                 Light(Origin,15,255,105,0,7)   
  215.             }
  216.     if(!is_user_alive(id))return
  217.     #if !defined TestingTime
  218.     if(!zp_get_user_zombie(id))return
  219.     if(zp_get_user_nemesis(id))return
  220.     if(zp_get_user_zombie_class(id)!=Jack)return
  221.     #endif
  222.     if(UpdateHud[id-1]<gametime)
  223.     {
  224.         new Text0[100], Text1[56],Text2[56]
  225.         formatex(Text0, 99, "Press [E] (IN_USE) to change ability^nPress [F] (Impulse 100) or [G] (Drop) to use ability^n^n")
  226.         switch(Selected_Ability[id-1])
  227.         {
  228.             case 0:formatex(Text1, 55, "Selected Ability: Throw Fire Shpere^n")
  229.             case 1:formatex(Text1, 55, "Selected Ability: Throw Frost Sphere^n")
  230.         }
  231.         if(!Can_Use_Ability[id-1])
  232.         {
  233.             if(Ability_CD[id-1]-gametime>0.0)formatex(Text2, 55, "Recharge Ability: %..1f^n",Ability_CD[id-1]-gametime)
  234.             else formatex(Text2, 55, "Recharge Ability: Ready to use^n"),Can_Use_Ability[id-1]=true
  235.         }
  236.         set_hudmessage(255,255,255,0.02,0.2,0,0.1,1.0,0.0,0.0,CDHudChannel)
  237.         show_hudmessage(id,"%s%s%s",Text0,Text1,Text2)
  238.         UpdateHud[id-1]=gametime+0.1
  239.     }
  240.     //Select Ability
  241.     if((pev(id,pev_button)&IN_USE)&&!(pev(id,pev_oldbuttons)&IN_USE))
  242.     {
  243.         switch(Selected_Ability[id-1])
  244.         {
  245.             case 0:Selected_Ability[id-1]=1
  246.             case 1:Selected_Ability[id-1]=0
  247.         }
  248.     }
  249.     //Use ability
  250.     if(Can_Use_Ability[id-1])
  251.     if (pev(id,pev_impulse)==100)
  252.     {
  253.         switch(Selected_Ability[id-1])
  254.         {
  255.             case 0:throw_Shpere(id,1),Ability_CD[id-1]=gametime+FireShpere_CD,Can_Use_Ability[id-1]=false
  256.             case 1:throw_Shpere(id,2),Ability_CD[id-1]=gametime+FrostSphere_CD,Can_Use_Ability[id-1]=false
  257.         }
  258.        
  259.     }
  260. }
  261. //Public func
  262. public throw_Shpere(id,type)
  263. {
  264.     emit_sound(id, CHAN_VOICE, ThrowFireShpereSound, 1.0, ATTN_NORM, 0, PITCH_NORM) //Play sound
  265.     set_pdata_float(id, 83, 0.7, 5) //Block attack
  266.     UTIL_PlayWeaponAnimation(id,5)  //And play Anim
  267.    
  268.     new Float:StartOrigin[3],Float:EndOrigin[3]
  269.     get_position(id,30.0,0.0,5.0,StartOrigin)
  270.     fm_get_aim_origin(id,EndOrigin)
  271.    
  272.     new ient = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  273.     engfunc(EngFunc_SetModel,ient, Shpere)
  274.     engfunc(EngFunc_SetSize, ient, {-3.0,-3.0,-3.0}, {3.0,3.0,3.0})
  275.     switch(type)
  276.     {
  277.         case 1: set_pev(ient, pev_classname, FireShpere_Classname),
  278.             fm_set_rendering(ient, kRenderFxGlowShell, 255,105,0, kRenderTransAlpha,55)
  279.         case 2: set_pev(ient, pev_classname, FrostSphere_Classname),
  280.             fm_set_rendering(ient, kRenderFxGlowShell, 0,105,255, kRenderTransAlpha,55)
  281.     }
  282.     set_pev(ient, pev_movetype, MOVETYPE_FLY)
  283.     set_pev(ient,pev_solid,SOLID_TRIGGER)
  284.     set_pev(ient,pev_origin,StartOrigin)
  285.     set_pev(ient,pev_owner,id)
  286.     set_pev(ient, pev_nextthink, get_gametime() +0.01)     
  287.     set_pev(ient,pev_iuser1,type)
  288.    
  289.     //Sphere Trail
  290.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  291.     write_byte(TE_BEAMFOLLOW)
  292.     write_short(ient)
  293.     write_short(TrailSpriteIndex)
  294.     write_byte(15)
  295.     write_byte(15)
  296.     switch(type)    //Select colors
  297.     {
  298.         case 1:
  299.         {
  300.             write_byte(255)
  301.             write_byte(105)
  302.             write_byte(0)
  303.         }
  304.         case 2:
  305.         {
  306.             write_byte(0)
  307.             write_byte(105)
  308.             write_byte(255)
  309.         }
  310.     }
  311.     write_byte(155)
  312.     message_end()
  313.    
  314.     new Float:VECTOR[3],Float:VELOCITY[3]
  315.     xs_vec_sub(EndOrigin, StartOrigin, VECTOR)
  316.     xs_vec_normalize(VECTOR, VECTOR)
  317.     xs_vec_mul_scalar(VECTOR, 1300.0, VELOCITY) //1300.0 - Sphere speed! (Max 2000.0!!!)
  318.     set_pev(ient, pev_velocity, VELOCITY)
  319. }
  320. //Stocks
  321. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
  322. {
  323.     new Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  324.     pev(id, pev_v_angle, vAngle);pev(id, pev_origin, vOrigin);pev(id, pev_view_ofs,vUp)
  325.     xs_vec_add(vOrigin,vUp,vOrigin)
  326.     angle_vector(vAngle,ANGLEVECTOR_FORWARD,vForward)
  327.     angle_vector(vAngle,ANGLEVECTOR_RIGHT,vRight)
  328.     angle_vector(vAngle,ANGLEVECTOR_UP,vUp)
  329.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  330.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  331.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  332. }
  333. stock DrawRings(Float:Origin[3],R,G,B)
  334. {
  335.     for(new i=0;i<4;i++)
  336.     {
  337.         message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  338.         write_byte( TE_BEAMTORUS );
  339.         engfunc(EngFunc_WriteCoord, Origin[0])
  340.         engfunc(EngFunc_WriteCoord, Origin[1])
  341.         engfunc(EngFunc_WriteCoord, Origin[2]+3.0*i)
  342.         engfunc(EngFunc_WriteCoord, Origin[0])
  343.         engfunc(EngFunc_WriteCoord, Origin[1])
  344.         engfunc(EngFunc_WriteCoord, Origin[2]+100.0+10.0*i)
  345.         write_short( TrailSpriteIndex ); // sprite
  346.         write_byte( 0 ); // Starting frame
  347.         write_byte( 0  ); // framerate * 0.1
  348.         write_byte( 8-1*i ); // life * 0.1
  349.         write_byte( 14 ); // width
  350.         write_byte( 0 ); // noise
  351.         write_byte( R ); // color r,g,b
  352.         write_byte( G ); // color r,g,b
  353.         write_byte( B); // color r,g,b
  354.         write_byte( 255 ); // brightness
  355.         write_byte( 0 ); // scroll speed
  356.         message_end();  
  357.     }  
  358. }
  359. stock Light(Float:Origin[3],RAD,R,G,B,Life)
  360. {
  361.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  362.     write_byte(TE_DLIGHT)
  363.     engfunc(EngFunc_WriteCoord, Origin[0])
  364.     engfunc(EngFunc_WriteCoord, Origin[1])
  365.     engfunc(EngFunc_WriteCoord, Origin[2])
  366.     write_byte(RAD) //Radius
  367.     write_byte(R)   // r
  368.     write_byte(G)   // g
  369.     write_byte(B)   // b
  370.     write_byte(Life)    //Life
  371.     write_byte(10)
  372.     message_end()
  373. }
  374. stock ScreenFade(id, Timer, FadeTime, Colors[3], Alpha, type)
  375. {
  376.     if(id) if(!is_user_connected(id)) return
  377.  
  378.     if (Timer > 0xFFFF) Timer = 0xFFFF
  379.     if (FadeTime <= 0) FadeTime = 4
  380.    
  381.     message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST,Msg_ScreenFade, _, id);
  382.     write_short(Timer * 1 << 12)
  383.     write_short(FadeTime * 1 << 12)
  384.     switch (type)
  385.     {
  386.         case 1: write_short(0x0000)     // IN ( FFADE_IN )
  387.         case 2: write_short(0x0001)     // OUT ( FFADE_OUT )
  388.         case 3: write_short(0x0002)     // MODULATE ( FFADE_MODULATE )
  389.         case 4: write_short(0x0004)     // STAYOUT ( FFADE_STAYOUT )
  390.         default: write_short(0x0001)
  391.     }
  392.     write_byte(Colors[0])
  393.     write_byte(Colors[1])
  394.     write_byte(Colors[2])
  395.     write_byte(Alpha)
  396.     message_end()
  397. }
  398. stock ScreenShake(id, duration, frequency)
  399. {  
  400.     message_begin(id ? MSG_ONE_UNRELIABLE : MSG_ALL, Msg_ScreenShake, _, id ? id : 0);
  401.     write_short(1<<14)
  402.     write_short(duration)
  403.     write_short(frequency)
  404.     message_end();
  405. }
  406. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
  407. {
  408.     set_pev(Player, pev_weaponanim, Sequence)
  409.    
  410.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  411.     write_byte(Sequence)
  412.     write_byte(pev(Player, pev_body))
  413.     message_end()
  414. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement