Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 28.79 KB | None | 0 0
  1. /*==================================================================================================
  2. LIBRARIES.
  3. ==================================================================================================*/
  4.  
  5. #include <amxmodx>
  6. #include <engine>
  7. #include <hamsandwich>
  8. #include <xs>
  9.  
  10. #include <ipci/Ascend>
  11. #include <ipci/Core>
  12. #include <ipci/FXLib>
  13.  
  14. #include <xtension/Special>
  15.  
  16.  
  17. #include <amxmisc>
  18. #include <fun>
  19. #include <fakemeta>
  20.  
  21. #include <ipci/ascend>
  22. #include <ipci/dragonball>
  23. #include <xs>
  24.  
  25.  
  26.  
  27.  
  28. /*==================================================================================================
  29. ADDITIONAL MATERIAL.
  30. ==================================================================================================*/
  31.  
  32. #define SPECIAL_VALREQSTATE 1
  33. #define SPECIAL_NULREQSTATE 0
  34.  
  35. stock SpecialXtension:__sx_Mafuba;
  36.  
  37. // Sequence
  38. static __int_Sequence[2], __int_Capsule;
  39.  
  40. // Effects
  41. static __int_Gibs[3], __int_Trail, __int_Lightning;
  42.  
  43. // Conditions
  44.  
  45. /*==================================================================================================
  46. START OF THE SPECIAL.
  47. ==================================================================================================*/
  48.  
  49. public plugin_init()
  50. {
  51.     register_forward(FM_AddToFullPack, "@FM_AddToFullPack", ._post = true);
  52.    
  53.     RegisterHam(Ham_Use, "func_button", "@Ham_Use");
  54.     RegisterHam(Ham_TakeDamage, "info_target", "@Ham_TakeDamage");
  55.    
  56.     register_clcmd("say c", "@CreateMafubaBeamEntity");
  57.    
  58.     register_think("capsule_jar", "@Think_Jar");
  59.    
  60.     register_touch("worldspawn", "capsule_jar", "@Touch_Jar");
  61.    
  62.     register_forward( FM_Touch, "@EntityTouch" );  
  63.    
  64.     register_message(get_user_msgid("Explosion"), "ExplosionDetected");
  65.    
  66.     register_clcmd("say weg", "removeEntity");
  67. }
  68.  
  69. public plugin_precache()
  70. {
  71.     precache_model("models/capsule.mdl");
  72.     precache_model("models/ricecooker.mdl");
  73.    
  74.     precache_model("sprites/mafuba.spr");
  75.    
  76.     __int_Trail = precache_model("sprites/auratrail.spr");
  77.    
  78.     __int_Lightning = precache_model("sprites/lgtning.spr");
  79.    
  80.     __int_Gibs[0] = precache_model("models/teil1.mdl");
  81.     __int_Gibs[1] = precache_model("models/teil2.mdl");
  82.     __int_Gibs[2] = precache_model("models/teil3.mdl");
  83.    
  84.     precache_sound("weapons/mafuba/capsule_click.wav");
  85.     precache_sound("weapons/mafuba/capsule_bounce.wav");
  86.     precache_sound("weapons/mafuba/capsule_decompression.wav");
  87.    
  88.     precache_sound("weapons/mafuba/jar_use.wav");
  89.     precache_sound("weapons/mafuba/jar_break.wav");
  90.    
  91.     precache_sound("weapons/powerup.wav");
  92.     precache_sound("weapons/mafuba/player_scream.wav");
  93.    
  94.     precache_model( "sprites/mafubatrail2.spr" );
  95.     precache_model( "sprites/sv_ff_t.spr" );
  96.    
  97.     precache_sound("common/wpn_select.wav");
  98. }
  99.  
  100. public @EntityTouch(ptr,ptd)   //toucher+touched
  101. {
  102.     new classname[32]
  103.    
  104.     pev(ptr,pev_classname,classname,31)
  105.    
  106.    
  107.     if ( equal(classname, "mafuba") )
  108.     {
  109.         //client_print(0,print_chat,"damn touched");
  110.         // and other stuff
  111.         phase2(ptd)
  112.        
  113.        
  114.     }  
  115.  
  116.     return FMRES_HANDLED
  117. }
  118.  
  119. phase2(ball)
  120. {
  121.    
  122.     new Float:orig[3]
  123.     pev(ball, pev_origin, orig)
  124.    
  125.    
  126.     //client_print(ball,print_chat,"jo");
  127.     //set_task(2.0, "removeEntity", ball);
  128. }
  129.  
  130. public removeEntity(iEnt)
  131. {
  132.     remove_entity(iEnt);
  133. }
  134.  
  135.  
  136.  
  137.  
  138. public @CreateMafubaBeamEntityphase2(__int_Entity, const __int_Owner, const Float:__float_Scale, const __int_Velocity)
  139. {
  140.     __int_Entity = create_entity("env_sprite");
  141.    
  142.     entity_set_model(__int_Entity, "sprites/mafuba.spr");
  143.    
  144.     entity_set_int(__int_Entity, EV_INT_spawnflags, SF_SPRITE_STARTON);
  145.    
  146.     DispatchSpawn(__int_Entity);
  147.    
  148.     entity_set_int(__int_Entity, EV_INT_renderfx, kRenderFxGlowShell);
  149.     entity_set_int(__int_Entity, EV_INT_rendermode, kRenderTransAdd);
  150.  
  151.     entity_set_float(__int_Entity, EV_FL_animtime, get_gametime());
  152.     entity_set_float(__int_Entity, EV_FL_framerate, float(10));
  153.    
  154.     entity_set_string(__int_Entity, EV_SZ_classname, "mafubaphase2");
  155.    
  156.     entity_set_float(__int_Entity, EV_FL_renderamt, float(254));
  157.    
  158.     entity_set_float(__int_Entity, EV_FL_scale, __float_Scale);
  159.    
  160.     entity_set_int(__int_Entity, EV_INT_movetype, MOVETYPE_FLY);
  161.    
  162.     entity_set_size(__int_Entity, Float:{-8.000_000, -8.000_000, -8.000_000}, Float:{8.000_000, 8.000_000, 8.000_000});
  163.    
  164.     entity_set_int(__int_Entity, EV_INT_solid, SOLID_TRIGGER);
  165.    
  166.     //entity_set_edict(__int_Entity, EV_ENT_owner, __int_Owner);
  167.     set_pev(__int_Entity,pev_owner, __int_Owner)
  168.     entity_set_edict(__int_Entity, EV_ENT_pContainingEntity, __int_Entity);
  169.    
  170.     static Float:__float_Origin[3];
  171.     entity_get_vector(__int_Owner, EV_VEC_origin, __float_Origin);
  172.    
  173.     entity_set_origin(__int_Entity, __float_Origin);
  174.    
  175.     static Float:__float_Velocity[3];
  176.     velocity_by_aim(__int_Owner, __int_Velocity, __float_Velocity);
  177.    
  178.     entity_set_vector(__int_Entity, EV_VEC_velocity, __float_Velocity);
  179.    
  180.    
  181.     message_begin( MSG_BROADCAST,SVC_TEMPENTITY )
  182.     write_byte( TE_BEAMFOLLOW )
  183.     write_short( __int_Entity )
  184.     write_short( engfunc( EngFunc_ModelIndex,"sprites/sv_ff_t.spr" ) )
  185.     write_byte( 30 )// 持续时间[] life in 0.1's
  186.     write_byte( 10 )// 宽度[] line width in 0.1's
  187.     write_byte( 255 )// Red
  188.     write_byte( 255 )// Green
  189.     write_byte( 255 )// Blue
  190.     write_byte( 255 )// Brightness
  191.     message_end( )
  192. }
  193.  
  194.  
  195. public @CreateMafubaBeamEntity(__int_Entity, const __int_Owner, const Float:__float_Scale, const __int_Velocity)
  196. {
  197.     __int_Entity = create_entity("env_sprite");
  198.    
  199.     entity_set_model(__int_Entity, "sprites/mafuba.spr");
  200.    
  201.     entity_set_int(__int_Entity, EV_INT_spawnflags, SF_SPRITE_STARTON);
  202.    
  203.     DispatchSpawn(__int_Entity);
  204.    
  205.     entity_set_int(__int_Entity, EV_INT_renderfx, kRenderFxGlowShell);
  206.     entity_set_int(__int_Entity, EV_INT_rendermode, kRenderTransAdd);
  207.  
  208.     entity_set_float(__int_Entity, EV_FL_animtime, get_gametime());
  209.     entity_set_float(__int_Entity, EV_FL_framerate, float(10));
  210.    
  211.     entity_set_string(__int_Entity, EV_SZ_classname, "mafuba");
  212.    
  213.     entity_set_float(__int_Entity, EV_FL_renderamt, float(254));
  214.    
  215.     entity_set_float(__int_Entity, EV_FL_scale, __float_Scale);
  216.    
  217.     entity_set_int(__int_Entity, EV_INT_movetype, MOVETYPE_FLY);
  218.    
  219.     entity_set_size(__int_Entity, Float:{-8.000_000, -8.000_000, -8.000_000}, Float:{8.000_000, 8.000_000, 8.000_000});
  220.    
  221.     entity_set_int(__int_Entity, EV_INT_solid, SOLID_TRIGGER);
  222.    
  223.     //entity_set_edict(__int_Entity, EV_ENT_owner, __int_Owner);
  224.     set_pev(__int_Entity,pev_owner, __int_Owner)
  225.     entity_set_edict(__int_Entity, EV_ENT_pContainingEntity, __int_Entity);
  226.    
  227.     static Float:__float_Origin[3];
  228.     entity_get_vector(__int_Owner, EV_VEC_origin, __float_Origin);
  229.    
  230.     entity_set_origin(__int_Entity, __float_Origin);
  231.    
  232.     static Float:__float_Velocity[3];
  233.     velocity_by_aim(__int_Owner, __int_Velocity, __float_Velocity);
  234.    
  235.     entity_set_vector(__int_Entity, EV_VEC_velocity, __float_Velocity);
  236.     set_task(0.1, "follow_enemy", __int_Entity,_,_,"b")
  237.    
  238.    
  239.     message_begin( MSG_BROADCAST,SVC_TEMPENTITY )
  240.     write_byte( TE_BEAMFOLLOW )
  241.     write_short( __int_Entity )
  242.     write_short( engfunc( EngFunc_ModelIndex,"sprites/mafubatrail2.spr" ) )
  243.     write_byte( 10 )// 持续时间[] life in 0.1's
  244.     write_byte( 30 )// 宽度[] line width in 0.1's
  245.     write_byte( 255 )// Red
  246.     write_byte( 255 )// Green
  247.     write_byte( 255 )// Blue
  248.     write_byte( 255 )// Brightness
  249.     message_end( )
  250. }
  251.  
  252. public follow_enemy(ball)
  253. {
  254.     static tid, id, closest[2]
  255.     closest[0] = 0
  256.     closest[1]= 6000
  257.     id = pev(ball, pev_owner)
  258.     tid = pev(ball, pev_iuser1)
  259.    
  260.     if(tid == 0)
  261.     {
  262.         new user_team = get_user_team(id)
  263.         new pl[32], num, Float:flAngles[3], Float:flForward[3],
  264.         Float:vector[3], Float:fired_particle_start_origin[3], Float:flVecSrc2[3],
  265.         Float:maxdist, Float:flVecDest[3]
  266.         get_players(pl,num,"a")
  267.        
  268.         pev(id, pev_v_angle, flAngles)
  269.         angle_vector(flAngles, ANGLEVECTOR_FORWARD, flForward)
  270.        
  271.         pev(id, pev_origin, fired_particle_start_origin)
  272.         pev(id, pev_view_ofs, vector)
  273.    
  274.         // get the fired particle start origin
  275.         xs_vec_add(fired_particle_start_origin, vector, fired_particle_start_origin)
  276.        
  277.         for(new i = 0; i<num;i++)
  278.         {
  279.             tid = pl[i]
  280.             if(tid == id && get_user_team(tid) == user_team) continue
  281.            
  282.             pev(tid, pev_origin, flVecSrc2)
  283.            
  284.             maxdist = get_distance_f(fired_particle_start_origin, flVecSrc2)
  285.            
  286.             flVecDest[0] = fired_particle_start_origin[0] + (flForward[0] * maxdist);
  287.             flVecDest[1] = fired_particle_start_origin[1] + (flForward[1] * maxdist);
  288.             flVecDest[2] = fired_particle_start_origin[2] + (flForward[2] * maxdist);
  289.            
  290.             if(get_distance_f(flVecDest, flVecSrc2) < closest[1]*1.0)
  291.             {
  292.                 closest[0] = tid
  293.             } else closest[1] = floatround(get_distance_f(flVecDest, flVecSrc2))
  294.         }
  295.     } else if(!is_user_alive(tid))
  296.     {
  297.         new Float:orig[3], Float:Torig[3]
  298.        
  299.         pev(ball, pev_origin, orig)
  300.        
  301.         new pl[32], num
  302.        
  303.         get_players(pl,num,"a")
  304.         for(new i;i<num;i++)
  305.         {
  306.             tid = pl[i]
  307.            
  308.             pev(tid, pev_origin, Torig)
  309.            
  310.             if(get_distance_f(orig, Torig) < closest[1]*1.0)
  311.                 closest[0] = tid
  312.             else
  313.                 closest[1] = floatround(get_distance_f(orig, Torig))
  314.         }
  315.     }
  316.     if(closest[0] != 0) tid = closest[0]
  317.    
  318.     if(!is_user_alive(tid))
  319.     {
  320.         remove_task(ball)
  321.         engfunc(EngFunc_RemoveEntity, ball)
  322.         return
  323.     }
  324.     new Float:origin[3], Float:AimVec[3], Float:speed = 800.0
  325.    
  326.     pev(tid, pev_origin, AimVec)
  327.  
  328.     entity_get_vector(ball, EV_VEC_origin, origin)
  329.  
  330.     new Float:iNewVelocity[3]
  331.  
  332.     new Float:velocityVec[3], Float:length
  333.  
  334.     velocityVec[0] = AimVec[0]-origin[0]
  335.     velocityVec[1] = AimVec[1]-origin[1]
  336.     velocityVec[2] = AimVec[2]-origin[2]
  337.  
  338.     length = floatsqroot(velocityVec[0]*velocityVec[0] + velocityVec[1]*velocityVec[1] + velocityVec[2]*velocityVec[2])
  339.     // Stupid Check but lets make sure you don't devide by 0
  340.     if ( length < 1.0 ) length = 1.0
  341.  
  342.     velocityVec[0] = velocityVec[0]*speed/length
  343.     velocityVec[1] = velocityVec[1]*speed/length
  344.     velocityVec[2] = velocityVec[2]*speed/length
  345.  
  346.     new Float:args[3]
  347.     pev(ball, pev_velocity, args)
  348.     iNewVelocity[0] = (velocityVec[0] + (args[0] * 2.0)) / 3.0
  349.     iNewVelocity[1] = (velocityVec[1] + (args[1] * 2.0)) / 3.0
  350.     iNewVelocity[2] = (velocityVec[2] + (args[2] * 2.0)) / 3.0
  351.  
  352.     set_pev(ball, pev_velocity, iNewVelocity)
  353. }
  354.  
  355. public client_connect(__int_Index)
  356. {
  357.     @RemoveData(__int_Index);
  358. }
  359.  
  360. public client_disconnect(__int_Index)
  361. {
  362.     @RemoveData(__int_Index);
  363. }
  364.  
  365. public @ClientReSpawned(__int_Index)
  366. {
  367.     if(is_user_alive(__int_Index))
  368.     {
  369.         __int_Capsule |= (1 << __int_Index);
  370.     }
  371. }
  372.  
  373. public @SpecialCreation()
  374. {
  375.     beginSpecialCreation("Mafuba", "", "@CallBackMafuba", "special_mafuba");
  376.    
  377.     addSpecialCharge(   .ControlSequence = IN_ATTACK,
  378.                 .SecsForFullCharge = float(8),
  379.                 .KiPerStep = float(6),
  380.                 .CanMove = false);
  381.    
  382.     addSpecialCharge(   .ControlSequence = IN_ATTACK2,
  383.                 .SecsForFullCharge = float(1),
  384.                 .KiPerStep = float(0),
  385.                 .CanMove = true);
  386.    
  387.     __sx_Mafuba = endSpecialCreation();
  388. }
  389.  
  390. public @CallBackMafuba(__int_Index, CSpecialState:__Status, __int_Control, Float:__float_Charge)
  391. {
  392.     switch(__Status)
  393.     {
  394.         case ssCharge:
  395.         {
  396.             if(__int_Control == IN_ATTACK2)
  397.             {
  398.                 if(@IsPlayerBusy(__int_Index)
  399.                 || getClientINFREEFALL(__int_Index)
  400.                 || @ReturnAnimation(__int_Index, 1))
  401.                 {
  402.                     return SPECIAL_NULREQSTATE;
  403.                 }
  404.                
  405.                 if(__float_Charge == float(-1))
  406.                 {
  407.                     set_pdata_int(__int_Index, 200, false);
  408.                    
  409.                     @StopAnimation(__int_Index, 2);
  410.                 }
  411.                
  412.                 if(__float_Charge == float(0))
  413.                 {
  414.                     set_pdata_int(__int_Index, 200, true);
  415.                    
  416.                     @StartAnimation(__int_Index, 0);
  417.                 }
  418.                
  419.                 if(__float_Charge == 0.300_000 && __int_Capsule & (1 << __int_Index))
  420.                 {
  421.                     emit_sound(__int_Index, CHAN_WEAPON, "weapons/mafuba/capsule_click.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  422.                 }
  423.             }
  424.            
  425.             else
  426.             {
  427.                 if(getClientPOWERUP(__int_Index) && getClientXFROZEN(__int_Index))
  428.                 {
  429.                     setClientFLY(__int_Index, false);
  430.                 }
  431.                
  432.                 if(@IsPlayerBusy(__int_Index)
  433.                 || getClientFLY(__int_Index)
  434.                 || getClientTURBO(__int_Index)
  435.                 || ~entity_get_int(__int_Index, EV_INT_flags) & FL_ONGROUND)
  436.                 {
  437.                     return SPECIAL_NULREQSTATE;
  438.                 }
  439.                
  440.                 if(__float_Charge == 0.050_000)
  441.                 {
  442.                     set_task(0.5, "@fxWorldLight", __int_Index, _, _, "b");
  443.                    
  444.                     message_begin(MSG_ALL, get_user_msgid("Powerup"));
  445.                     {
  446.                         write_byte(__int_Index);
  447.                        
  448.                         write_byte(0);
  449.                         write_byte(0);
  450.                         write_byte(0);
  451.                     }
  452.                     message_end();
  453.                    
  454.                     emit_sound(__int_Index, CHAN_WEAPON, "common/null.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  455.                    
  456.                     emit_sound(__int_Index, CHAN_ITEM, "weapons/powerup.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  457.                 }
  458.                
  459.                 if(__float_Charge == 0.700_000)
  460.                 {
  461.                     set_rendering(__int_Index, kRenderFxGlowShell, 0, _, 0, _, 10);
  462.                 }
  463.                
  464.                 else if(__float_Charge == 0.325_000 || __float_Charge == 0.987_500)
  465.                 {
  466.                     AddFx(__int_Index, "fxBlow");
  467.                     AddFx(__int_Index, "fxScreenShake", float(5), float(1), float(5));
  468.                 }
  469.             }
  470.            
  471.             entity_set_float(__int_Index, EV_FL_fuser2, __float_Charge);
  472.            
  473.             return SPECIAL_VALREQSTATE;
  474.         }
  475.        
  476.         case ssChargeReleased:
  477.         {
  478.             if(__int_Control == IN_ATTACK2)
  479.             {
  480.                 if(__float_Charge >= 0.325_000)
  481.                 {
  482.                     @StartAnimation(__int_Index, 1);
  483.                    
  484.                     if(__int_Capsule & (1 << __int_Index))
  485.                     {
  486.                         @ThrowCapsule(__int_Index, (120 * floatround(__float_Charge * float(10))));
  487.                     }
  488.                    
  489.                     else
  490.                     {
  491.                         client_print(__int_Index, print_center, "You don't have more capsules.");
  492.                     }
  493.                 }
  494.                
  495.                 else
  496.                 {
  497.                     set_pdata_int(__int_Index, 200, false);
  498.                    
  499.                     @StopAnimation(__int_Index, 2);
  500.                 }
  501.             }
  502.            
  503.             else
  504.             {
  505.                 if(__float_Charge >= 0.900_000)
  506.                 {  
  507.                     @CreateMafubaBeamEntity(100, __int_Index, 1.0, 800);
  508.                     emit_sound(__int_Index, CHAN_AUTO, "weapons/mafuba/player_scream.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  509.                 }
  510.                
  511.                 emit_sound(__int_Index, CHAN_ITEM, "common/null.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  512.                
  513.                 @RemoveChargeReferences(__int_Index);
  514.             }
  515.         }
  516.        
  517.         case ssChargeAborted:
  518.         {
  519.             if(__int_Control == IN_ATTACK2)
  520.             {
  521.                 set_pdata_int(__int_Index, 200, false);
  522.                
  523.                 @StopAnimation(__int_Index, 2);
  524.             }
  525.            
  526.             else
  527.             {
  528.                 emit_sound(__int_Index, CHAN_ITEM, "common/null.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  529.                
  530.                 @RemoveChargeReferences(__int_Index);
  531.             }
  532.            
  533.             return SPECIAL_NULREQSTATE;
  534.         }
  535.        
  536.         case ssForceAbort:
  537.         {
  538.             if(__int_Control == IN_ATTACK2)
  539.             {
  540.                 set_pdata_int(__int_Index, 200, false);
  541.                
  542.                 @StopAnimation(__int_Index, 2);
  543.             }
  544.            
  545.             else
  546.             {
  547.                 emit_sound(__int_Index, CHAN_ITEM, "common/null.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  548.                
  549.                 @RemoveChargeReferences(__int_Index);
  550.             }
  551.         }
  552.     }
  553.    
  554.     return SPECIAL_VALREQSTATE;
  555. }
  556.  
  557. public @ThrowCapsule(const __int_Index, const __int_Strengh)
  558. {
  559.     static __int_Entity;
  560.     __int_Entity = create_entity("info_target");
  561.    
  562.     entity_set_string(__int_Entity, EV_SZ_classname, "capsule_jar");
  563.    
  564.     entity_set_model(__int_Entity, "models/capsule.mdl");
  565.    
  566.     DispatchKeyValue(__int_Entity, "health", "10");
  567.    
  568.     entity_set_int(__int_Entity, EV_INT_spawnflags, entity_get_int(__int_Entity, EV_INT_spawnflags) & SF_NORESPAWN);
  569.    
  570.     DispatchSpawn(__int_Entity);
  571.    
  572.     entity_set_float(__int_Entity, EV_FL_nextthink, (get_gametime() + 0.01));
  573.    
  574.     entity_set_float(__int_Entity, EV_FL_scale, 0.6);
  575.    
  576.     entity_set_int(__int_Entity, EV_INT_solid, SOLID_TRIGGER);
  577.    
  578.     entity_set_int(__int_Entity, EV_INT_movetype, MOVETYPE_BOUNCE);
  579.    
  580.     entity_set_size(__int_Entity, Float:{-0.500_000, -0.500_000, -0.500_000}, Float:{0.500_000, 0.500_000, 0.500_000});
  581.    
  582.     static Float:__float_Origin[3], Float:__float_Velocity[3];
  583.     entity_get_vector(__int_Index, EV_VEC_origin, __float_Origin);
  584.     entity_set_origin(__int_Entity, __float_Origin);
  585.    
  586.     velocity_by_aim(__int_Index, __int_Strengh, __float_Velocity);
  587.    
  588.     __float_Velocity[2] += float(100);
  589.    
  590.     entity_set_vector(__int_Entity, EV_VEC_avelocity, Float:{200.0, 400.0, 600.0});
  591.     entity_set_vector(__int_Entity, EV_VEC_velocity, __float_Velocity);
  592.    
  593.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  594.     {
  595.         write_byte(TE_BEAMFOLLOW);
  596.        
  597.         write_short(__int_Entity);
  598.         write_short(__int_Trail);
  599.        
  600.         write_byte(5);
  601.         write_byte(1);
  602.        
  603.         write_byte(255);
  604.         write_byte(255);
  605.         write_byte(255);
  606.        
  607.         write_byte(100);
  608.     }
  609.     message_end();
  610.    
  611.     __int_Capsule &= ~(1 << __int_Index);
  612. }
  613.  
  614. public @SpawnJar(__int_Entity)
  615. {
  616.     if(is_valid_ent(__int_Entity))
  617.     {
  618.         entity_set_model(__int_Entity, "models/ricecooker.mdl");
  619.        
  620.         entity_set_int(__int_Entity, EV_INT_solid, SOLID_BBOX);
  621.        
  622.         entity_set_int(__int_Entity, EV_INT_movetype, MOVETYPE_TOSS);
  623.        
  624.         entity_set_size(__int_Entity, Float:{-0.500_000, -0.500_000, -0.500_000}, Float:{0.500_000, 0.500_000, 0.500_000});
  625.        
  626.         entity_set_float(__int_Entity, EV_FL_scale, float(1));
  627.        
  628.         entity_set_float(__int_Entity, EV_FL_animtime, get_gametime());
  629.         entity_set_float(__int_Entity, EV_FL_framerate, 1.0);
  630.        
  631.         entity_set_int(__int_Entity, EV_INT_effects, EF_MUZZLEFLASH);
  632.        
  633.         entity_set_float(__int_Entity, EV_FL_takedamage, float(1));
  634.        
  635.         static Float:__float_Origin[3], __int_Origin[3];
  636.         entity_get_vector(__int_Entity, EV_VEC_origin, __float_Origin);
  637.         FVecIVec(__float_Origin, __int_Origin);
  638.        
  639.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  640.         {
  641.             write_byte(TE_DLIGHT);
  642.            
  643.             write_coord(__int_Origin[0]);
  644.             write_coord(__int_Origin[1]);
  645.             write_coord(__int_Origin[2]);
  646.            
  647.             write_byte(10);
  648.             write_byte(255);
  649.             write_byte(255);
  650.             write_byte(255);
  651.             write_byte(30);
  652.             write_byte(1);
  653.         }
  654.         message_end();
  655.        
  656.         message_begin(MSG_ALL, 98);
  657.         {
  658.             write_byte(2);
  659.             write_short(__int_Entity);
  660.            
  661.             write_coord(__int_Origin[0]);
  662.             write_coord(__int_Origin[1]);
  663.             write_coord(__int_Origin[2]);
  664.            
  665.             write_short(200);
  666.         }
  667.         message_end();
  668.        
  669.         message_begin(MSG_ALL, 115, __int_Origin);
  670.         {
  671.             write_byte(3);
  672.             write_byte(__int_Entity);
  673.         }
  674.         message_end();
  675.        
  676.         message_begin(MSG_ALL, 106, __int_Origin);
  677.         {
  678.             write_short(__int_Entity);
  679.             write_byte(10);
  680.         }
  681.         message_end();
  682.        
  683.         entity_set_int(__int_Entity, EV_INT_sequence, 1);
  684.        
  685.         emit_sound(__int_Entity, CHAN_WEAPON, "weapons/mafuba/capsule_decompression.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  686.        
  687.         static __int_Use;
  688.         __int_Use = create_entity("func_button");
  689.        
  690.         entity_set_int(__int_Use, EV_INT_movetype, MOVETYPE_FOLLOW);
  691.         entity_set_edict(__int_Use, EV_ENT_aiment, __int_Entity);
  692.        
  693.         entity_set_edict(__int_Use, EV_ENT_euser1, __int_Entity);
  694.        
  695.         entity_set_string(__int_Use, EV_SZ_classname, "mafuba_use");
  696.        
  697.         entity_set_edict(__int_Entity, EV_ENT_euser3, __int_Use);
  698.     }
  699. }
  700.  
  701. public @FM_AddToFullPack(__int_Handle, __int_Edict, __int_Entity, __int_Host, __int_Flags, __int_Player, __int_Set)
  702. {
  703.     if(__int_Player
  704.     && __int_Entity == __int_Host
  705.     && (is_user_alive(__int_Host) && !is_user_bot(__int_Host)))
  706.     {
  707.         if(__int_Sequence[0] & (1 << __int_Entity))
  708.         {
  709.             entity_set_float(__int_Entity, EV_FL_animtime, get_gametime());
  710.             set_es(__int_Handle, ES_Sequence, 90);
  711.             entity_set_float(__int_Entity, EV_FL_framerate, 0.380_000);
  712.            
  713.             if(entity_get_float(__int_Entity, EV_FL_fuser2) == float(1))
  714.             {
  715.                 entity_set_float(__int_Entity, EV_FL_framerate, float(0));
  716.             }
  717.         }
  718.        
  719.         if(__int_Sequence[1] & (1 << __int_Entity))
  720.         {
  721.             entity_set_float(__int_Entity, EV_FL_framerate, float(2));
  722.            
  723.             static Float:__int_Frame[2];
  724.            
  725.             __int_Frame[0] = __int_Frame[1];
  726.             __int_Frame[1] = entity_get_float(__int_Entity, EV_FL_frame);
  727.            
  728.             if(__int_Frame[0] > __int_Frame[1])
  729.             {
  730.                 set_pdata_int(__int_Entity, 200, false);
  731.                
  732.                 @StopAnimation(__int_Entity, 2);
  733.             }
  734.         }
  735.     }
  736.    
  737.     return FMRES_IGNORED;
  738. }
  739.  
  740. public @Think_Jar(__int_Entity)
  741. {
  742.     if(is_valid_ent(__int_Entity))
  743.     {
  744.         if(task_exists(__int_Entity))
  745.         {
  746.             remove_task(__int_Entity);
  747.         }
  748.        
  749.         static Float:__float_Start[3], Float:__float_End[3];
  750.         entity_get_vector(__int_Entity, EV_VEC_origin, __float_Start);
  751.        
  752.         __float_End[0] = __float_Start[0];
  753.         __float_End[1] = __float_Start[1];
  754.         __float_End[2] = (__float_Start[2] - float(9999));
  755.        
  756.         static __int_Trace;
  757.         engfunc(EngFunc_TraceLine, __float_Start, __float_End, IGNORE_MONSTERS, 0, __int_Trace);
  758.        
  759.         static Float:__float_Angles[3];
  760.         get_tr2(__int_Trace, TR_vecPlaneNormal, __float_Angles);
  761.        
  762.         vector_to_angle(__float_Angles, __float_Angles);
  763.        
  764.         __float_Angles[0] -= float(90);
  765.        
  766.         entity_set_vector(__int_Entity, EV_VEC_angles, __float_Angles);
  767.        
  768.         set_task(2.500_000, "@fxLight", __int_Entity);
  769.         set_task(float(3), "@SpawnJar", __int_Entity);
  770.     }
  771. }
  772.  
  773. public @Touch_Jar(__int_Touched, __int_Toucher)
  774. {
  775.     if(is_valid_ent(__int_Toucher))
  776.     {
  777.         static Float:__float_Velocity[3];
  778.         entity_get_vector(__int_Toucher, EV_VEC_velocity, __float_Velocity);
  779.        
  780.         __float_Velocity[0] /= 2.500_000;
  781.         __float_Velocity[1] /= 2.500_000;
  782.         __float_Velocity[2] /= 2.500_000;
  783.        
  784.         entity_set_vector(__int_Toucher, EV_VEC_velocity, __float_Velocity);
  785.        
  786.         entity_set_float(__int_Toucher, EV_FL_nextthink, (get_gametime() + 0.01));
  787.        
  788.         emit_sound(__int_Toucher, random_num(0, 7), "weapons/mafuba/capsule_bounce.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  789.     }
  790. }
  791.  
  792. public @Ham_Use(__int_Entity, __int_Index)
  793. {
  794.     if(entity_get_int(entity_get_edict(__int_Entity, EV_ENT_euser1), EV_INT_iuser3) != 1)
  795.     {
  796.         static __int_Classname[32];
  797.         entity_get_string(__int_Entity, EV_SZ_classname, __int_Classname, sizeof(__int_Classname)-1);
  798.        
  799.         if(equal(__int_Classname, "mafuba_use"))
  800.         {
  801.             emit_sound(__int_Index, CHAN_ITEM, "weapons/mafuba/jar_use.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  802.            
  803.             entity_set_int(entity_get_edict(__int_Entity, EV_ENT_euser1), EV_INT_sequence, entity_get_int(entity_get_edict(__int_Entity, EV_ENT_euser1), EV_INT_sequence) == 0 ? 1 : 0);
  804.         }
  805.     }
  806. }
  807.  
  808. public @Ham_TakeDamage(__int_Victim, __int_Inflictor, __int_Attacker, Float:__float_Damage, __int_Bits)
  809. {
  810.     static __int_Classname[32];
  811.     entity_get_string(__int_Victim, EV_SZ_classname, __int_Classname, sizeof(__int_Classname)-1);
  812.    
  813.     if(equal(__int_Classname, "capsule_jar"))
  814.     {
  815.         if((entity_get_float(__int_Victim, EV_FL_health) - __float_Damage) < float(0))
  816.         {
  817.             SetHamParamFloat(4, float(0));
  818.            
  819.             if(!task_exists(__int_Victim))
  820.             {
  821.                 entity_set_int(__int_Victim, EV_INT_iuser3, 1);
  822.                
  823.                 static __int_Data[2];
  824.                 __int_Data[0] = __int_Victim;
  825.                 __int_Data[1] = __int_Attacker;
  826.                
  827.                 set_rendering(__int_Victim, kRenderFxGlowShell, _, _, _, _, 20);
  828.                
  829.                 set_task(0.5, "@fxLightning", __int_Victim, _, _, "a", 8);
  830.                 set_task(float(5), "@fxKillJar", __int_Victim, __int_Data, 2);
  831.                
  832.                 emit_sound(__int_Victim, CHAN_ITEM, "weapons/mafuba/jar_break.wav", VOL_NORM, ATTN_NORM, 0 ,PITCH_NORM);
  833.             }
  834.         }
  835.     }
  836. }
  837.  
  838. /*==================================================================================================
  839. EFFECTS.
  840. ==================================================================================================*/
  841.  
  842. public @fxKillJar(__int_Data[])
  843. {
  844.     if(is_valid_ent(__int_Data[0]))
  845.     {
  846.         static Float:__float_Origin[3];
  847.         entity_get_vector(__int_Data[0], EV_VEC_origin, __float_Origin);
  848.        
  849.         for(new __int_Models = 0; __int_Models < 3; __int_Models++)
  850.         {
  851.             message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  852.             {
  853.                 write_byte(TE_MODEL);
  854.                 write_coord(floatround(__float_Origin[0]));
  855.                 write_coord(floatround(__float_Origin[1]));
  856.                 write_coord(floatround(__float_Origin[2]));
  857.                
  858.                 write_coord(random_num(random_num(-200, -300), random_num(200, 300)));
  859.                 write_coord(random_num(random_num(-200, -300), random_num(200, 300)));
  860.                 write_coord(random_num(250, 300));
  861.                
  862.                 write_angle(random_num(0, 360));
  863.                
  864.                 write_short(__int_Gibs[__int_Models]);
  865.                 write_byte(0);
  866.                 write_byte(200);
  867.             }
  868.             message_end();
  869.         }
  870.        
  871.         message_begin(MSG_ALL, 98);
  872.         {
  873.             write_byte(2);
  874.             write_short(__int_Data[0]);
  875.            
  876.             write_coord(floatround(__float_Origin[0]));
  877.             write_coord(floatround(__float_Origin[1]));
  878.             write_coord(floatround(__float_Origin[2]));
  879.            
  880.             write_short(60);
  881.         }
  882.         message_end();
  883.        
  884.         if(is_valid_ent(entity_get_edict(__int_Data[0], EV_ENT_euser3)))
  885.         {
  886.             remove_entity(entity_get_edict(__int_Data[0], EV_ENT_euser3));
  887.         }
  888.        
  889.         ExecuteHam(Ham_Killed, __int_Data[0], __int_Data[1], 0);
  890.     }
  891. }
  892.  
  893. public @fxLightning(__int_Entity)
  894. {
  895.     if(is_valid_ent(__int_Entity))
  896.     {
  897.         static Float:__float_Origin[3];
  898.         entity_get_vector(__int_Entity, EV_VEC_origin, __float_Origin);
  899.        
  900.         message_begin(MSG_ALL, SVC_TEMPENTITY);
  901.         {
  902.             write_byte(TE_BEAMPOINTS);
  903.             write_coord(floatround(__float_Origin[0]));
  904.             write_coord(floatround(__float_Origin[1]));
  905.             write_coord(floatround(__float_Origin[2]));
  906.            
  907.             write_coord(floatround(__float_Origin[0] + random_float(-11.0, 11.0)));
  908.             write_coord(floatround(__float_Origin[1] + random_float(-11.0, 11.0)));
  909.             write_coord(floatround(__float_Origin[2] + random_float(0.0, 11.0)));
  910.            
  911.             write_short(__int_Lightning);
  912.            
  913.             write_byte(1);
  914.             write_byte(10);
  915.             write_byte(10);
  916.             write_byte(5);
  917.             write_byte(125);
  918.             write_byte(255);
  919.            
  920.             write_byte(255);
  921.             write_byte(255);
  922.             write_byte(255);
  923.            
  924.             write_byte(150);
  925.         }
  926.         message_end();
  927.     }
  928. }
  929.  
  930. public @fxLight(__int_Entity)
  931. {
  932.     if(is_valid_ent(__int_Entity))
  933.     {
  934.         static Float:__float_Origin[3];
  935.         entity_get_vector(__int_Entity, EV_VEC_origin, __float_Origin);
  936.        
  937.         static __int_Players;
  938.         __int_Players = -1;
  939.        
  940.         while((__int_Players = find_ent_in_sphere(__int_Players, __float_Origin, float(15))))
  941.         {
  942.             if(is_user_alive(__int_Players) && is_user_connected(__int_Players))
  943.             {
  944.                 static Float:__float_Origin[3];
  945.                 entity_get_vector(__int_Players, EV_VEC_origin, __float_Origin);
  946.                
  947.                 __float_Origin[2] += float(100);
  948.                
  949.                 entity_set_origin(__int_Players, __float_Origin);
  950.             }
  951.         }
  952.        
  953.         entity_set_int(__int_Entity, EV_INT_effects, EF_LIGHT);
  954.     }
  955. }
  956.  
  957. public @fxWorldLight(__int_Index)
  958. {
  959.     if(is_user_alive(__int_Index))
  960.     {
  961.         static __int_Origin[3];
  962.         get_user_origin(__int_Index, __int_Origin);
  963.        
  964.         message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, __int_Index);
  965.         {
  966.             write_byte(TE_DLIGHT);
  967.            
  968.             write_coord(__int_Origin[0]);
  969.             write_coord(__int_Origin[1]);
  970.             write_coord(__int_Origin[2]);
  971.            
  972.             write_byte(12);
  973.            
  974.             write_byte(entity_get_float(__int_Index, EV_FL_fuser2) < 0.699_999 ? 255 : 0);
  975.             write_byte(255);
  976.             write_byte(entity_get_float(__int_Index, EV_FL_fuser2) < 0.699_999 ? 255 : 0);
  977.            
  978.             write_byte(255);
  979.             write_byte(floatround(2.500_000));
  980.         }
  981.         message_end();
  982.        
  983.         static Float:__float_Charge;
  984.         __float_Charge = entity_get_float(__int_Index, EV_FL_fuser2);
  985.        
  986.         if(__float_Charge >= 0.325_000)
  987.         {
  988.             set_rendering(.index = __int_Index,
  989.                 .fx = kRenderFxGlowShell,
  990.                 .r = (__float_Charge < 0.700_000 ? 255 : 0),
  991.                 .g = _,
  992.                 .b = (__float_Charge < 0.700_000 ? 255 : 0),
  993.                 .render = kRenderNormal,
  994.                 .amount = (__float_Charge < 0.700_000 ? 6 : 8));
  995.         }
  996.     }
  997. }
  998.  
  999. /*==================================================================================================
  1000. POST-USE.
  1001. ==================================================================================================*/
  1002.  
  1003. public @RemoveData(const __int_Index)
  1004. {
  1005.     @StopAnimation(__int_Index, 2);
  1006.    
  1007.     __int_Capsule &= ~(1 << __int_Index);
  1008.    
  1009.     if(is_valid_ent(entity_get_edict(__int_Index, EV_ENT_euser1)))
  1010.     {
  1011.         remove_entity(entity_get_edict(__int_Index, EV_ENT_euser1));
  1012.     }
  1013. }
  1014.  
  1015. public @IsPlayerBusy(const __int_Index)
  1016. {
  1017.     if(getClientPOWERUP(__int_Index) && !getClientXFROZEN(__int_Index)
  1018.     || getClientSWOOPING(__int_Index)
  1019.     || getClientBLOCK(__int_Index)
  1020.     || getClientATKSHOOT(__int_Index)
  1021.     || getClientMELEE(__int_Index)
  1022.     || getClientMELEEPUSHBACK(__int_Index)
  1023.     || getClientTHROWAWAY(__int_Index)
  1024.     || getClientTHROW(__int_Index)
  1025.     || getClientWALLGND(__int_Index))
  1026.     {
  1027.         return 1;
  1028.     }
  1029.    
  1030.     return 0;
  1031. }
  1032.  
  1033. public @RemoveChargeReferences(const __int_Index)
  1034. {
  1035.     if(task_exists(__int_Index))
  1036.     {
  1037.         remove_task(__int_Index);
  1038.     }
  1039.    
  1040.     message_begin(MSG_ALL, get_user_msgid("StopPowerup"));
  1041.     {
  1042.         write_byte(__int_Index);
  1043.     }
  1044.     message_end();
  1045.    
  1046.     set_rendering(__int_Index, kRenderFxNone, _, _, _, kRenderNormal);
  1047. }
  1048.  
  1049. public @ReturnAnimation(const __int_Index, const __int_Wich)
  1050. {
  1051.     return (__int_Sequence[__int_Wich] & (1 << __int_Index)); // Handle.
  1052. }
  1053.  
  1054. public @StartAnimation(const __int_Index, const __int_Wich)
  1055. {
  1056.     if(__int_Wich == 0) // Hold.
  1057.     {
  1058.         __int_Sequence[0] |= (1 << __int_Index);
  1059.     }
  1060.    
  1061.     else // Throw.
  1062.     {
  1063.         __int_Sequence[1] |= (1 << __int_Index);
  1064.     }
  1065. }
  1066.  
  1067. public @StopAnimation(const __int_Index, const __int_Wich)
  1068. {
  1069.     if(__int_Wich == 0) // Hold.
  1070.     {
  1071.         __int_Sequence[0] &= ~(1 << __int_Index);
  1072.     }
  1073.    
  1074.     else if(__int_Wich == 1) // Throw.
  1075.     {
  1076.         __int_Sequence[1] &= ~(1 << __int_Index);
  1077.     }
  1078.    
  1079.     else // Both.
  1080.     {
  1081.         __int_Sequence[0] &= ~(1 << __int_Index);
  1082.         __int_Sequence[1] &= ~(1 << __int_Index);
  1083.     }
  1084. }
  1085.  
  1086. /*==================================================================================================
  1087. END OF THE SPECIAL.
  1088. ==================================================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement