Advertisement
Guest User

Untitled

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