Advertisement
Guest User

Untitled

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