daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <fakemeta_util>
  4. #include <hamsandwich>
  5. #include <cstrike>
  6. #include <zombieplague>
  7.  
  8. #define PLUGIN "Balrog-III"
  9. #define VERSION "1.0"
  10. #define AUTHOR "Dias"
  11.  
  12. #define V_MODEL "models/v_balrog3.mdl"
  13. #define P_MODEL "models/p_balrog3.mdl"
  14. #define W_MODEL "models/w_balrog3.mdl"
  15.  
  16. #define DAMAGE 48
  17. #define BPAMMO 240
  18. #define ACTIVE_CLIP 15
  19.  
  20. #define CSW_BALROG3 CSW_MP5NAVY
  21. #define weapon_balrog3 "weapon_mp5navy"
  22.  
  23. #define WEAPON_SECRETCODE 4962
  24. #define WEAPON_EVENT "events/mp5n.sc"
  25. #define OLD_W_MODEL "models/w_mp5.mdl"
  26.  
  27. new const Balrog3_Sounds[6][] =
  28. {
  29.     "weapons/balrig3-1.wav",
  30.     "weapons/balrig3-2.wav",
  31.     "weapons/balrig3_boltpull.wav",
  32.     "weapons/balrig3_clipin.wav",
  33.     "weapons/balrig3_clipout.wav",
  34.     "weapons/balrig3_draw.wav"
  35. }
  36.  
  37. #define EXPLOSE_SPR "sprites/balrog5stack.spr"
  38.  
  39. enum
  40. {
  41.     ANIM_IDLE = 0,
  42.     ANIM_DRAW,
  43.     ANIM_RELOAD,
  44.     ANIM_SHOOT_A,
  45.     ANIM_SHOOT_B
  46. }
  47.  
  48. new g_Balrog3
  49. new g_Had_Balrog3[33], g_Shoot_Special[33], g_Holding_Attack[33], g_Shoot_Count[33], g_Old_Weapon[33], g_Current_Weapon[33]
  50. new g_Exp_SprId, g_balrog3_event, g_ShellId, g_SmokePuff_SprId
  51.  
  52. public plugin_init()
  53. {
  54.     register_plugin(PLUGIN, VERSION, AUTHOR)
  55.    
  56.     register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
  57.    
  58.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)   
  59.     register_forward(FM_PlaybackEvent, "fw_PlaybackEvent") 
  60.     register_forward(FM_SetModel, "fw_SetModel")
  61.     register_forward(FM_CmdStart, "fw_CmdStart")       
  62.    
  63.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack")
  64.     RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")   
  65.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_balrog3, "fw_Weapon_PrimaryAttack")
  66.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_balrog3, "fw_Weapon_PrimaryAttack_Post", 1)
  67.     RegisterHam(Ham_Item_AddToPlayer, weapon_balrog3, "fw_Item_AddToPlayer_Post", 1)
  68.    
  69.     register_clcmd("admin_get_balrog3", "Get_Balrog3", ADMIN_BAN)
  70. }
  71.  
  72. public plugin_precache()
  73. {
  74.     engfunc(EngFunc_PrecacheModel, V_MODEL)
  75.     engfunc(EngFunc_PrecacheModel, P_MODEL)
  76.     engfunc(EngFunc_PrecacheModel, W_MODEL)
  77.    
  78.     for(new i = 0; i < sizeof(Balrog3_Sounds); i++)
  79.         engfunc(EngFunc_PrecacheSound, Balrog3_Sounds[i])
  80.        
  81.     g_Exp_SprId = engfunc(EngFunc_PrecacheModel, EXPLOSE_SPR)
  82.     g_SmokePuff_SprId = engfunc(EngFunc_PrecacheModel, "sprites/wall_puff1.spr")
  83.     g_ShellId = engfunc(EngFunc_PrecacheModel, "models/pshell.mdl")
  84.    
  85.     register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
  86.     g_Balrog3 = zp_register_extra_item("Balrog-III", 25, ZP_TEAM_HUMAN)
  87. }
  88.  
  89. public fw_PrecacheEvent_Post(type, const name[])
  90. {
  91.     if(equal(WEAPON_EVENT, name))
  92.         g_balrog3_event = get_orig_retval()    
  93. }
  94.  
  95. public zp_extra_item_selected(id, itemid)
  96. {
  97.     if(itemid == g_Balrog3) Get_Balrog3(id)
  98. }
  99.  
  100. public zp_user_infected_post(id) Remove_Balrog3(id)
  101. public zp_user_humanized_post(id) Remove_Balrog3(id)
  102.  
  103. public Get_Balrog3(id)
  104. {
  105.     if(!is_user_alive(id))
  106.         return
  107.        
  108.     g_Had_Balrog3[id] = 1
  109.     g_Shoot_Special[id] = 0
  110.     g_Holding_Attack[id] = 0
  111.     g_Shoot_Count[id] = 0
  112.    
  113.     fm_give_item(id, weapon_balrog3)
  114.    
  115.     cs_set_user_bpammo(id, CSW_BALROG3, BPAMMO)
  116. }
  117.  
  118. public Remove_Balrog3(id)
  119. {
  120.     if(!is_user_connected(id))
  121.         return
  122.        
  123.     g_Had_Balrog3[id] = 0
  124.     g_Shoot_Special[id] = 0
  125. }
  126.  
  127. public Event_CurWeapon(id)
  128. {
  129.     if(!is_user_alive(id))
  130.         return
  131.    
  132.     if(get_user_weapon(id) != g_Current_Weapon[id]) g_Current_Weapon[id] = get_user_weapon(id)
  133.    
  134.     if(get_user_weapon(id) == CSW_BALROG3 && g_Had_Balrog3[id])
  135.     {
  136.         if(g_Old_Weapon[id] != CSW_BALROG3)
  137.         {
  138.             set_pev(id, pev_viewmodel2, V_MODEL)
  139.             set_pev(id, pev_weaponmodel2, P_MODEL)
  140.         }
  141.     }
  142.    
  143.     g_Old_Weapon[id] = get_user_weapon(id)
  144. }
  145.  
  146. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  147. {
  148.     if(!is_user_alive(id) || !is_user_connected(id))
  149.         return FMRES_IGNORED   
  150.     if(get_user_weapon(id) == CSW_BALROG3 && g_Had_Balrog3[id])
  151.         set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  152.    
  153.     return FMRES_HANDLED
  154. }
  155.  
  156. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  157. {
  158.     if (!is_user_connected(invoker))
  159.         return FMRES_IGNORED   
  160.     if(get_user_weapon(invoker) != CSW_BALROG3 || !g_Had_Balrog3[invoker])
  161.         return FMRES_IGNORED
  162.     if(eventid != g_balrog3_event)
  163.         return FMRES_IGNORED
  164.    
  165.     engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  166.    
  167.     if(!g_Shoot_Special[invoker] && cs_get_user_bpammo(invoker, CSW_BALROG3) > 0)
  168.     {
  169.         g_Shoot_Count[invoker]++
  170.         if(g_Shoot_Count[invoker] >= ACTIVE_CLIP)
  171.         {
  172.             g_Shoot_Special[invoker] = 1
  173.            
  174.             static Ent; Ent = fm_get_user_weapon_entity(invoker, CSW_BALROG3)
  175.             if(pev_valid(Ent)) g_Shoot_Count[invoker] = cs_get_weapon_ammo(Ent)
  176.         }
  177.     } else if(g_Shoot_Special[invoker]) {
  178.         cs_set_user_bpammo(invoker, CSW_BALROG3, cs_get_user_bpammo(invoker, CSW_BALROG3) - 1)
  179.        
  180.         if(cs_get_user_bpammo(invoker, CSW_BALROG3) <= 0)
  181.         {
  182.             g_Shoot_Special[invoker] = 0
  183.             g_Shoot_Count[invoker] = 0
  184.         }
  185.     }
  186.    
  187.     set_weapon_anim(invoker, g_Shoot_Special[invoker] == 1 ? ANIM_SHOOT_B : ANIM_SHOOT_A)
  188.     emit_sound(invoker, CHAN_WEAPON, g_Shoot_Special[invoker] == 1 ? Balrog3_Sounds[1] : Balrog3_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  189.    
  190.     Eject_Shell(invoker, g_ShellId, 0.0)
  191.        
  192.     return FMRES_SUPERCEDE
  193. }
  194.  
  195. public fw_SetModel(entity, model[])
  196. {
  197.     if(!pev_valid(entity))
  198.         return FMRES_IGNORED
  199.    
  200.     static Classname[32]
  201.     pev(entity, pev_classname, Classname, sizeof(Classname))
  202.    
  203.     if(!equal(Classname, "weaponbox"))
  204.         return FMRES_IGNORED
  205.    
  206.     static iOwner
  207.     iOwner = pev(entity, pev_owner)
  208.    
  209.     if(equal(model, OLD_W_MODEL))
  210.     {
  211.         static weapon; weapon = fm_find_ent_by_owner(-1, weapon_balrog3, entity)
  212.        
  213.         if(!pev_valid(weapon))
  214.             return FMRES_IGNORED;
  215.        
  216.         if(g_Had_Balrog3[iOwner])
  217.         {
  218.             Remove_Balrog3(iOwner)
  219.            
  220.             set_pev(weapon, pev_impulse, WEAPON_SECRETCODE)
  221.             engfunc(EngFunc_SetModel, entity, W_MODEL)
  222.            
  223.             return FMRES_SUPERCEDE
  224.         }
  225.     }
  226.  
  227.     return FMRES_IGNORED;
  228. }
  229.  
  230. public fw_CmdStart(id, uc_handle, seed)
  231. {
  232.     if(!is_user_alive(id))
  233.         return
  234.     if(g_Current_Weapon[id] != CSW_BALROG3 || !g_Had_Balrog3[id])
  235.         return
  236.        
  237.     static NewButton; NewButton = get_uc(uc_handle, UC_Buttons)
  238.     static OldButton; OldButton = pev(id, pev_oldbuttons)
  239.    
  240.     if(NewButton & IN_ATTACK)
  241.     {
  242.         if(!g_Holding_Attack[id]) g_Holding_Attack[id] = 1
  243.     } else if((NewButton & IN_ATTACK2) && !(OldButton & IN_ATTACK2)) {
  244.         if(cs_get_user_zoom(id) == 1) cs_set_user_zoom(id, CS_SET_AUGSG552_ZOOM, 1)
  245.         else cs_set_user_zoom(id, CS_SET_NO_ZOOM, 1)
  246.     } else {
  247.         if(OldButton & IN_ATTACK)
  248.         {
  249.             if(g_Holding_Attack[id])
  250.             {
  251.                 g_Holding_Attack[id] = 0
  252.                 g_Shoot_Count[id] = 0
  253.                 g_Shoot_Special[id] = 0
  254.             }
  255.         }
  256.     }
  257. }
  258.  
  259. public fw_TraceAttack(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
  260. {
  261.     if(!is_user_alive(Attacker))
  262.         return HAM_IGNORED 
  263.     if(get_user_weapon(Attacker) != CSW_BALROG3 || !g_Had_Balrog3[Attacker])
  264.         return HAM_IGNORED
  265.        
  266.     static Float:flEnd[3], Float:vecPlane[3]
  267.    
  268.     get_tr2(Ptr, TR_vecEndPos, flEnd)
  269.     get_tr2(Ptr, TR_vecPlaneNormal, vecPlane)      
  270.        
  271.     if(!is_user_alive(Victim))
  272.     {
  273.         Make_BulletHole(Attacker, flEnd, Damage)
  274.         Make_BulletSmoke(Attacker, Ptr)
  275.     }
  276.    
  277.     if(g_Shoot_Special[Attacker])
  278.     {
  279.         Make_BalrogEffect(Attacker, Ptr)
  280.         radius_damage(Attacker, flEnd, float(DAMAGE), 96.0)
  281.     }
  282.    
  283.     SetHamParamFloat(3, float(DAMAGE))
  284.    
  285.     return HAM_IGNORED
  286. }
  287.  
  288. public fw_Weapon_PrimaryAttack(Ent)
  289. {
  290.     if(!pev_valid(Ent))
  291.         return
  292.     static Id; Id = pev(Ent, pev_owner)
  293.     if(!g_Had_Balrog3[Id])
  294.         return
  295.    
  296.     if(g_Shoot_Special[Id]) set_pdata_float(Ent, 62, 0.4, 4)
  297.     else set_pdata_float(Ent, 62, 0.2, 4)
  298. }
  299.  
  300. public fw_Weapon_PrimaryAttack_Post(Ent)
  301. {
  302.     if(!pev_valid(Ent))
  303.         return
  304.     static Id; Id = pev(Ent, pev_owner)
  305.     if(!g_Had_Balrog3[Id])
  306.         return
  307.    
  308.     if(g_Shoot_Special[Id] && cs_get_weapon_ammo(Ent) > 0)
  309.     {
  310.         cs_set_weapon_ammo(Ent, g_Shoot_Count[Id])
  311.         set_pdata_float(Ent, 46, get_pdata_float(Ent, 46, 4) * 0.75, 4)
  312.     }
  313. }
  314.  
  315. public fw_Item_AddToPlayer_Post(ent, id)
  316. {
  317.     if(!pev_valid(ent))
  318.         return HAM_IGNORED
  319.        
  320.     if(pev(ent, pev_impulse) == WEAPON_SECRETCODE)
  321.     {
  322.         g_Had_Balrog3[id] = 1
  323.         set_pev(ent, pev_impulse, 0)
  324.     }      
  325.  
  326.     return HAM_HANDLED 
  327. }
  328.  
  329. stock Make_BulletHole(id, Float:Origin[3], Float:Damage)
  330. {
  331.     // Find target
  332.     static Decal; Decal = random_num(41, 45)
  333.     static LoopTime;
  334.    
  335.     if(Damage > 100.0) LoopTime = 2
  336.     else LoopTime = 1
  337.    
  338.     for(new i = 0; i < LoopTime; i++)
  339.     {
  340.         // Put decal on "world" (a wall)
  341.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  342.         write_byte(TE_WORLDDECAL)
  343.         engfunc(EngFunc_WriteCoord, Origin[0])
  344.         engfunc(EngFunc_WriteCoord, Origin[1])
  345.         engfunc(EngFunc_WriteCoord, Origin[2])
  346.         write_byte(Decal)
  347.         message_end()
  348.        
  349.         // Show sparcles
  350.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  351.         write_byte(TE_GUNSHOTDECAL)
  352.         engfunc(EngFunc_WriteCoord, Origin[0])
  353.         engfunc(EngFunc_WriteCoord, Origin[1])
  354.         engfunc(EngFunc_WriteCoord, Origin[2])
  355.         write_short(id)
  356.         write_byte(Decal)
  357.         message_end()
  358.     }
  359. }
  360.  
  361. public Make_BulletSmoke(id, TrResult)
  362. {
  363.     static Float:vecSrc[3], Float:vecEnd[3], TE_FLAG
  364.    
  365.     get_weapon_attachment(id, vecSrc)
  366.     global_get(glb_v_forward, vecEnd)
  367.    
  368.     xs_vec_mul_scalar(vecEnd, 8192.0, vecEnd)
  369.     xs_vec_add(vecSrc, vecEnd, vecEnd)
  370.  
  371.     get_tr2(TrResult, TR_vecEndPos, vecSrc)
  372.     get_tr2(TrResult, TR_vecPlaneNormal, vecEnd)
  373.    
  374.     xs_vec_mul_scalar(vecEnd, 2.5, vecEnd)
  375.     xs_vec_add(vecSrc, vecEnd, vecEnd)
  376.    
  377.     TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  378.     TE_FLAG |= TE_EXPLFLAG_NOSOUND
  379.     TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  380.    
  381.     engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0)
  382.     write_byte(TE_EXPLOSION)
  383.     engfunc(EngFunc_WriteCoord, vecEnd[0])
  384.     engfunc(EngFunc_WriteCoord, vecEnd[1])
  385.     engfunc(EngFunc_WriteCoord, vecEnd[2] - 10.0)
  386.     write_short(g_SmokePuff_SprId)
  387.     write_byte(2)
  388.     write_byte(50)
  389.     write_byte(TE_FLAG)
  390.     message_end()
  391. }
  392.  
  393. public Make_BalrogEffect(id, TrResult)
  394. {
  395.     static Float:vecSrc[3], Float:vecEnd[3], TE_FLAG
  396.    
  397.     get_weapon_attachment(id, vecSrc)
  398.     global_get(glb_v_forward, vecEnd)
  399.    
  400.     xs_vec_mul_scalar(vecEnd, 8192.0, vecEnd)
  401.     xs_vec_add(vecSrc, vecEnd, vecEnd)
  402.  
  403.     get_tr2(TrResult, TR_vecEndPos, vecSrc)
  404.     get_tr2(TrResult, TR_vecPlaneNormal, vecEnd)
  405.    
  406.     xs_vec_mul_scalar(vecEnd, 5.0, vecEnd)
  407.     xs_vec_add(vecSrc, vecEnd, vecEnd)
  408.    
  409.     TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  410.     TE_FLAG |= TE_EXPLFLAG_NOSOUND
  411.     TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  412.    
  413.     engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0)
  414.     write_byte(TE_EXPLOSION)
  415.     engfunc(EngFunc_WriteCoord, vecEnd[0])
  416.     engfunc(EngFunc_WriteCoord, vecEnd[1])
  417.     engfunc(EngFunc_WriteCoord, vecEnd[2])
  418.     write_short(g_Exp_SprId)
  419.     write_byte(5)
  420.     write_byte(30)
  421.     write_byte(TE_FLAG)
  422.     message_end()
  423. }
  424.  
  425. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
  426. {
  427.     new Float:vfEnd[3], viEnd[3]
  428.     get_user_origin(id, viEnd, 3)  
  429.     IVecFVec(viEnd, vfEnd)
  430.    
  431.     new Float:fOrigin[3], Float:fAngle[3]
  432.    
  433.     pev(id, pev_origin, fOrigin)
  434.     pev(id, pev_view_ofs, fAngle)
  435.    
  436.     xs_vec_add(fOrigin, fAngle, fOrigin)
  437.    
  438.     new Float:fAttack[3]
  439.    
  440.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  441.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  442.    
  443.     new Float:fRate
  444.    
  445.     fRate = fDis / vector_length(fAttack)
  446.     xs_vec_mul_scalar(fAttack, fRate, fAttack)
  447.    
  448.     xs_vec_add(fOrigin, fAttack, output)
  449. }
  450.  
  451. stock radius_damage(id, Float:Origin[3], Float:Damage, Float:Radius)
  452. {
  453.     static Victim; Victim = -1
  454.  
  455.     while((Victim = engfunc(EngFunc_FindEntityInSphere, Victim, Origin, Radius)) != 0)
  456.     {
  457.         if(!is_user_alive(Victim) || id == Victim)
  458.             continue
  459.         if(!zp_get_user_zombie(Victim))
  460.             continue
  461.  
  462.         ExecuteHamB(Ham_TakeDamage, Victim, fm_get_user_weapon_entity(id, get_user_weapon(id)), id, Damage, DMG_BULLET)
  463.     }
  464. }
  465.  
  466. stock Eject_Shell(id, Shell_ModelIndex, Float:Time) // By Dias
  467. {
  468.     static Ent; Ent = get_pdata_cbase(id, 373, 5)
  469.     if(!pev_valid(Ent))
  470.         return
  471.  
  472.         set_pdata_int(Ent, 57, Shell_ModelIndex, 4)
  473.         set_pdata_float(id, 111, get_gametime() + Time)
  474. }
  475.  
  476. stock set_weapon_anim(id, anim)
  477. {
  478.     if(!is_user_alive(id))
  479.         return
  480.    
  481.     set_pev(id, pev_weaponanim, anim)
  482.    
  483.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
  484.     write_byte(anim)
  485.     write_byte(pev(id, pev_body))
  486.     message_end()
  487. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top