Converted Star Chaser SR

Zombies/Humans Extra-Items
Post Reply
User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

Star Chaser SR

#1

Post by Mark » 1 Year Ago

Description:
  • A new extra-item for humans, Star Chaser SR
  • I did not make this weapon only converted!
Cvars:
  • ze_scsr_dmg 2.0
  • ze_scsr_recoil 1.90
  • ze_scsr_clip 15
  • ze_scsr_spd 2.48
  • ze_scsr_ammo 120
Code:
  1. #pragma compress 1
  2.  
  3. #include <zombie_escape>
  4. #include <engine>
  5. #include <fakemeta_util>
  6. #include <cstrike>
  7. #include <fun>
  8. #include <xs>
  9.  
  10. #pragma tabsize 0
  11.  
  12. #define ENG_NULLENT         -1
  13.  
  14. #define EV_INT_WEAPONKEY    EV_INT_impulse
  15.  
  16. #define scsr_WEAPONKEY      10018
  17.  
  18. #define MAX_PLAYERS         32
  19.  
  20. #define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
  21.  
  22.  
  23.  
  24. const USE_STOPPED = 0
  25.  
  26. const OFFSET_ACTIVE_ITEM = 373
  27.  
  28. const OFFSET_WEAPONOWNER = 41
  29.  
  30. const OFFSET_LINUX = 5
  31.  
  32. const OFFSET_LINUX_WEAPONS = 4
  33.  
  34.  
  35.  
  36. #define WEAP_LINUX_XTRA_OFF     4
  37.  
  38. #define m_fKnown                    44
  39.  
  40. #define m_flNextPrimaryAttack       46
  41.  
  42. #define m_flTimeWeaponIdle          48
  43.  
  44. #define m_iClip                 51
  45.  
  46. #define m_fInReload             54
  47.  
  48. #define PLAYER_LINUX_XTRA_OFF   5
  49.  
  50. #define m_flNextAttack              83
  51.  
  52.  
  53.  
  54. #define scsr_RELOAD_TIME        4.0
  55.  
  56. #define scsr_SHOOT1             1
  57.  
  58. #define scsr_SHOOT2             2
  59.  
  60. #define scsr_RELOAD             3
  61.  
  62. #define scsr_DRAW               4
  63.  
  64.  
  65.  
  66. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
  67.  
  68.  
  69.  
  70. new const Fire_Sounds[][] = { "weapons/starchasersr-1.wav" }
  71.  
  72.  
  73.  
  74. new scsr_V_MODEL[64] = "models/v_starchasersr.mdl"
  75.  
  76. new scsr_P_MODEL[64] = "models/p_starchasersr.mdl"
  77.  
  78. new scsr_W_MODEL[64] = "models/w_starchasersr.mdl"
  79.  
  80.  
  81.  
  82. new const scsr_name[] = "weapon_starchasersr"
  83.  
  84.  
  85.  
  86. new const scsr_spr[][] =
  87.  
  88. {
  89.  
  90.     "sprites/640hud171.spr",
  91.  
  92.     "sprites/640hud18.spr"
  93.  
  94. }
  95.  
  96.  
  97.  
  98. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
  99.  
  100.  
  101.  
  102. new cvar_dmg_scsr, cvar_recoil_scsr, g_itemid_scsr, cvar_clip_scsr, cvar_spd_scsr, cvar_scsr_ammo
  103.  
  104. new g_MaxPlayers, g_orig_event_scsr, g_IsInPrimaryAttack
  105.  
  106. new Float:cl_pushangle[MAX_PLAYERS + 1][3]
  107.  
  108. new g_has_scsr[33], g_clip_ammo[33], g_scsr_TmpClip[33], oldweap[33]
  109.  
  110. new gmsgWeaponList, scsr_ball
  111.  
  112. new g_SprID
  113.  
  114. new Float:g_lastexpl[33]
  115.  
  116.  
  117.  
  118. const PRIMARY_WEAPONS_BIT_SUM =
  119.  
  120. (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<
  121.  
  122. CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
  123.  
  124. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
  125.  
  126.             "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
  127.  
  128.             "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  129.  
  130.             "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  131.  
  132.             "weapon_ak47", "weapon_knife", "weapon_p90" }
  133.  
  134.  
  135. public plugin_precache()
  136.  
  137. {
  138.  
  139.     precache_model(scsr_V_MODEL)
  140.  
  141.     precache_model(scsr_P_MODEL)
  142.  
  143.     precache_model(scsr_W_MODEL)
  144.  
  145.     for(new i = 0; i < sizeof Fire_Sounds; i++)
  146.  
  147.     precache_sound(Fire_Sounds[i])  
  148.  
  149.     precache_sound("weapons/starchasersr_clipin.wav")
  150.  
  151.     precache_sound("weapons/starchasersr_clipout.wav")
  152.  
  153.     precache_sound("weapons/starchasersr_idle.wav")
  154.  
  155.  
  156.  
  157.     g_SprID = precache_model("sprites/ef_starchasersr_explosion.spr")
  158.  
  159.     scsr_ball = precache_model("sprites/ef_starchasersr_star.spr")
  160.  
  161.  
  162.  
  163.     new sFile[64]
  164.  
  165.     formatex(sFile, charsmax(sFile), "sprites/%s.txt", scsr_name)
  166.  
  167.     precache_generic(sFile)
  168.  
  169.    
  170.  
  171.     for(new i = 0; i < sizeof(scsr_spr); i++)
  172.  
  173.     {
  174.  
  175.         precache_generic(scsr_spr[i])
  176.  
  177.     }
  178.  
  179.  
  180.  
  181.     register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
  182.  
  183. }
  184.  
  185. public plugin_init()
  186.  
  187. {
  188.  
  189.     register_plugin("Star Chaser SR", "1.0", "[YouTube]COBA/Mark")
  190.  
  191.     register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
  192.  
  193.     register_event("CurWeapon","CurrentWeapon","be","1=1")
  194.  
  195.     RegisterHam(Ham_Item_AddToPlayer, "weapon_g3sg1", "fw_scsr_AddToPlayer")
  196.  
  197.     RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
  198.  
  199.     RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
  200.  
  201.     RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
  202.  
  203.     RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
  204.  
  205.     for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
  206.  
  207.     if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
  208.  
  209.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_g3sg1", "fw_scsr_PrimaryAttack")
  210.  
  211.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_g3sg1", "fw_scsr_PrimaryAttack_Post", 1)
  212.  
  213.     RegisterHam(Ham_Item_PostFrame, "weapon_g3sg1", "scsr_ItemPostFrame")
  214.  
  215.     RegisterHam(Ham_Weapon_Reload, "weapon_g3sg1", "scsr_Reload")
  216.  
  217.     RegisterHam(Ham_Weapon_Reload, "weapon_g3sg1", "scsr_Reload_Post", 1)
  218.  
  219.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  220.  
  221.     register_forward(FM_SetModel, "fw_SetModel")
  222.  
  223.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  224.  
  225.     register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
  226.  
  227.  
  228.  
  229.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
  230.  
  231.     RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
  232.  
  233.     RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
  234.  
  235.     RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
  236.  
  237.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
  238.  
  239.     RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
  240.  
  241.     RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
  242.  
  243.  
  244.  
  245.     cvar_dmg_scsr = register_cvar("ze_scsr_dmg", "2.0")
  246.  
  247.     cvar_recoil_scsr = register_cvar("ze_scsr_recoil", "1.90")
  248.  
  249.     cvar_clip_scsr = register_cvar("ze_scsr_clip", "15")
  250.  
  251.     cvar_spd_scsr = register_cvar("ze_scsr_spd", "2.48")
  252.  
  253.     cvar_scsr_ammo = register_cvar("ze_scsr_ammo", "120")
  254.  
  255.    
  256.  
  257.     g_itemid_scsr = ze_register_item("Star Chaser SR", 80, 0)
  258.  
  259.     g_MaxPlayers = get_maxplayers()
  260.  
  261.     gmsgWeaponList = get_user_msgid("WeaponList")
  262.  
  263.     register_clcmd(scsr_name, "command_scsr")
  264.  
  265. }
  266.  
  267. public ze_user_humanized(id)
  268. {
  269.     g_has_scsr[id] = false
  270. }
  271.  
  272. public ze_user_infected(Victim)
  273. {
  274.     g_has_scsr[Victim] = false
  275. }
  276.  
  277. public client_putinserver(id)
  278. {
  279.     g_has_scsr[id] = false
  280. }
  281.  
  282. public client_disconnected(id)
  283. {
  284.     g_has_scsr[id] = false
  285. }
  286.  
  287.  
  288.  
  289. public fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType, Player, id)
  290.  
  291. {
  292.  
  293.     if(!is_user_alive(iAttacker))
  294.  
  295.         return
  296.  
  297.  
  298.  
  299.     new g_currentweapon = get_user_weapon(iAttacker)
  300.  
  301.  
  302.  
  303.     if(g_currentweapon != CSW_G3SG1) return
  304.  
  305.    
  306.  
  307.     if(!g_has_scsr[iAttacker]) return
  308.  
  309.  
  310.  
  311.     static Float:flEnd[3]
  312.  
  313.     get_tr2(ptr, TR_vecEndPos, flEnd)
  314.  
  315.  
  316.  
  317.     if(iEnt)
  318.  
  319.     {
  320.  
  321.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  322.  
  323.         write_byte(TE_DECAL)
  324.  
  325.         write_coord_f(flEnd[0])
  326.  
  327.         write_coord_f(flEnd[1])
  328.  
  329.         write_coord_f(flEnd[2])
  330.  
  331.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  332.  
  333.         write_short(iEnt)
  334.  
  335.         message_end()
  336.  
  337.     }
  338.  
  339.     else
  340.  
  341.     {
  342.  
  343.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  344.  
  345.         write_byte(TE_WORLDDECAL)
  346.  
  347.         write_coord_f(flEnd[0])
  348.  
  349.         write_coord_f(flEnd[1])
  350.  
  351.         write_coord_f(flEnd[2])
  352.  
  353.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  354.  
  355.         message_end()
  356.  
  357.     }
  358.  
  359.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  360.  
  361.     write_byte(TE_GUNSHOTDECAL)
  362.  
  363.     write_coord_f(flEnd[0])
  364.  
  365.     write_coord_f(flEnd[1])
  366.  
  367.     write_coord_f(flEnd[2])
  368.  
  369.     write_short(iAttacker)
  370.  
  371.     write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  372.  
  373.     message_end()
  374.  
  375. }
  376.  
  377.  
  378.  
  379. public command_scsr(Player)
  380.  
  381. {
  382.  
  383.     engclient_cmd(Player, "weapon_g3sg1")
  384.  
  385.     return PLUGIN_HANDLED
  386.  
  387. }
  388.  
  389.  
  390. public plugin_natives ()
  391.  
  392. {
  393.  
  394.     register_native("give_weapon_scsr", "native_give_weapon_add", 1)
  395.  
  396. }
  397.  
  398. public native_give_weapon_add(id)
  399.  
  400. {
  401.  
  402.     give_scsr(id)
  403.  
  404. }
  405.  
  406.  
  407.  
  408. public fwPrecacheEvent_Post(type, const name[])
  409.  
  410. {
  411.  
  412.     if (equal("events/g3sg1.sc", name))
  413.  
  414.     {
  415.  
  416.         g_orig_event_scsr = get_orig_retval()
  417.  
  418.         return FMRES_HANDLED
  419.  
  420.     }
  421.  
  422.     return FMRES_IGNORED
  423.  
  424. }
  425.  
  426.  
  427.  
  428.  
  429. public fw_SetModel(entity, model[])
  430.  
  431. {
  432.  
  433.     if(!is_valid_ent(entity))
  434.  
  435.         return FMRES_IGNORED
  436.  
  437.    
  438.  
  439.     static szClassName[33]
  440.  
  441.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  442.  
  443.        
  444.  
  445.     if(!equal(szClassName, "weaponbox"))
  446.  
  447.         return FMRES_IGNORED
  448.  
  449.    
  450.  
  451.     static iOwner
  452.  
  453.    
  454.  
  455.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  456.  
  457.    
  458.  
  459.     if(equal(model, "models/w_g3sg1.mdl"))
  460.  
  461.     {
  462.  
  463.         static iStoredAugID
  464.  
  465.        
  466.  
  467.         iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_g3sg1", entity)
  468.  
  469.    
  470.  
  471.         if(!is_valid_ent(iStoredAugID))
  472.  
  473.             return FMRES_IGNORED
  474.  
  475.    
  476.  
  477.         if(g_has_scsr[iOwner])
  478.  
  479.         {
  480.  
  481.             entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, scsr_WEAPONKEY)
  482.  
  483.            
  484.  
  485.             g_has_scsr[iOwner] = false
  486.  
  487.            
  488.  
  489.             entity_set_model(entity, scsr_W_MODEL)
  490.  
  491.            
  492.  
  493.             return FMRES_SUPERCEDE
  494.  
  495.         }
  496.  
  497.     }
  498.  
  499.     return FMRES_IGNORED
  500.  
  501. }
  502.  
  503.  
  504.  
  505. public give_scsr(id)
  506.  
  507. {
  508.  
  509.     drop_weapons(id, 1)
  510.  
  511.     new iWep2 = give_item(id,"weapon_g3sg1")
  512.  
  513.     if( iWep2 > 0 )
  514.  
  515.     {
  516.  
  517.         cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_scsr))
  518.  
  519.         cs_set_user_bpammo (id, CSW_G3SG1, get_pcvar_num(cvar_scsr_ammo))  
  520.  
  521.         UTIL_PlayWeaponAnimation(id, scsr_DRAW)
  522.  
  523.         set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
  524.  
  525.  
  526.  
  527.         message_begin(MSG_ONE, gmsgWeaponList, _, id)
  528.  
  529.         write_string(scsr_name)
  530.  
  531.         write_byte(2)
  532.  
  533.         write_byte(90)
  534.  
  535.         write_byte(-1)
  536.  
  537.         write_byte(-1)
  538.  
  539.         write_byte(0)
  540.  
  541.         write_byte(3)
  542.  
  543.         write_byte(CSW_G3SG1)
  544.  
  545.         message_end()
  546.  
  547.     }
  548.  
  549.     g_has_scsr[id] = true
  550.  
  551. }
  552.  
  553.  
  554.  
  555. public ze_select_item_pre(id, itemid)
  556. {  
  557.     if (itemid != g_itemid_scsr)
  558.         return ZE_ITEM_AVAILABLE
  559.    
  560.     if (ze_is_user_zombie(id))
  561.         return ZE_ITEM_DONT_SHOW
  562.        
  563.     return ZE_ITEM_AVAILABLE
  564. }
  565.  
  566. public ze_select_item_post(id, itemid)
  567. {
  568.     if (itemid != g_itemid_scsr)
  569.         return
  570.        
  571.     ze_colored_print(id, "Congrats! You have bought Star Chaser SR! :D")
  572.    
  573.     give_scsr(id)
  574. }
  575.  
  576. public fw_scsr_AddToPlayer(scsr, id)
  577.  
  578. {
  579.  
  580.     if(!is_valid_ent(scsr) || !is_user_connected(id))
  581.  
  582.         return HAM_IGNORED
  583.  
  584.    
  585.  
  586.     if(entity_get_int(scsr, EV_INT_WEAPONKEY) == scsr_WEAPONKEY)
  587.  
  588.     {
  589.  
  590.         g_has_scsr[id] = true
  591.  
  592.        
  593.  
  594.         entity_set_int(scsr, EV_INT_WEAPONKEY, 0)
  595.  
  596.  
  597.  
  598.         message_begin(MSG_ONE, gmsgWeaponList, _, id)
  599.  
  600.         write_string(scsr_name)
  601.  
  602.         write_byte(2)
  603.  
  604.         write_byte(90)
  605.  
  606.         write_byte(-1)
  607.  
  608.         write_byte(-1)
  609.  
  610.         write_byte(0)
  611.  
  612.         write_byte(3)
  613.  
  614.         write_byte(CSW_G3SG1)
  615.  
  616.         message_end()
  617.  
  618.  
  619.  
  620.         return HAM_HANDLED
  621.  
  622.     }
  623.  
  624.     else
  625.  
  626.     {
  627.  
  628.         message_begin(MSG_ONE, gmsgWeaponList, _, id)
  629.  
  630.         write_string("weapon_g3sg1")
  631.  
  632.         write_byte(2)
  633.  
  634.         write_byte(90)
  635.  
  636.         write_byte(-1)
  637.  
  638.         write_byte(-1)
  639.  
  640.         write_byte(0)
  641.  
  642.         write_byte(3)
  643.  
  644.         write_byte(CSW_G3SG1)
  645.  
  646.         message_end()
  647.  
  648.     }
  649.  
  650.     return HAM_IGNORED
  651.  
  652. }
  653.  
  654.  
  655.  
  656. public fw_UseStationary_Post(entity, caller, activator, use_type)
  657.  
  658. {
  659.  
  660.     if (use_type == USE_STOPPED && is_user_connected(caller))
  661.  
  662.         replace_weapon_models(caller, get_user_weapon(caller))
  663.  
  664. }
  665.  
  666.  
  667.  
  668. public fw_Item_Deploy_Post(weapon_ent)
  669.  
  670. {
  671.  
  672.     static owner
  673.  
  674.     owner = fm_cs_get_weapon_ent_owner(weapon_ent)
  675.  
  676.    
  677.  
  678.     static weaponid
  679.  
  680.     weaponid = cs_get_weapon_id(weapon_ent)
  681.  
  682.    
  683.  
  684.     replace_weapon_models(owner, weaponid)
  685.  
  686. }
  687.  
  688.  
  689.  
  690. public CurrentWeapon(id)
  691.  
  692. {
  693.  
  694.      replace_weapon_models(id, read_data(2))
  695.  
  696.  
  697.  
  698.      if(read_data(2) != CSW_G3SG1 || !g_has_scsr[id])
  699.  
  700.           return
  701.  
  702.      
  703.  
  704.      static Float:iSpeed
  705.  
  706.      if(g_has_scsr[id])
  707.  
  708.           iSpeed = get_pcvar_float(cvar_spd_scsr)
  709.  
  710.      
  711.  
  712.      static weapon[32],Ent
  713.  
  714.      get_weaponname(read_data(2),weapon,31)
  715.  
  716.      Ent = find_ent_by_owner(-1,weapon,id)
  717.  
  718.      if(Ent)
  719.  
  720.      {
  721.  
  722.           static Float:Delay
  723.  
  724.           Delay = get_pdata_float( Ent, 46, 4) * iSpeed
  725.  
  726.           if (Delay > 0.0)
  727.  
  728.           {
  729.  
  730.                set_pdata_float(Ent, 46, Delay, 4)
  731.  
  732.           }
  733.  
  734.      }
  735.  
  736. }
  737.  
  738.  
  739.  
  740. replace_weapon_models(id, weaponid)
  741.  
  742. {
  743.  
  744.     switch (weaponid)
  745.  
  746.     {
  747.  
  748.         case CSW_G3SG1:
  749.  
  750.         {      
  751.             if(g_has_scsr[id])
  752.  
  753.             {
  754.  
  755.                 set_pev(id, pev_viewmodel2, scsr_V_MODEL)
  756.  
  757.                 set_pev(id, pev_weaponmodel2, scsr_P_MODEL)
  758.  
  759.                 if(oldweap[id] != CSW_G3SG1)
  760.  
  761.                 {
  762.  
  763.                     UTIL_PlayWeaponAnimation(id, scsr_DRAW)
  764.  
  765.                     set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
  766.  
  767.  
  768.  
  769.                     message_begin(MSG_ONE, gmsgWeaponList, _, id)
  770.  
  771.                     write_string(scsr_name)
  772.  
  773.                     write_byte(2)
  774.  
  775.                     write_byte(90)
  776.  
  777.                     write_byte(-1)
  778.  
  779.                     write_byte(-1)
  780.  
  781.                     write_byte(0)
  782.  
  783.                     write_byte(3)
  784.  
  785.                     write_byte(CSW_G3SG1)
  786.  
  787.                     message_end()
  788.  
  789.                 }
  790.  
  791.             }
  792.  
  793.         }
  794.  
  795.     }
  796.  
  797.     oldweap[id] = weaponid
  798.  
  799. }
  800.  
  801.  
  802.  
  803. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  804.  
  805. {
  806.  
  807.     if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_G3SG1 || !g_has_scsr[Player]))
  808.  
  809.         return FMRES_IGNORED
  810.  
  811.    
  812.  
  813.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  814.  
  815.     return FMRES_HANDLED
  816.  
  817. }
  818.  
  819.  
  820.  
  821. public fw_scsr_PrimaryAttack(Weapon)
  822.  
  823. {
  824.  
  825.     new Player = get_pdata_cbase(Weapon, 41, 4)
  826.  
  827.    
  828.  
  829.     if (!g_has_scsr[Player])
  830.  
  831.         return
  832.  
  833.    
  834.  
  835.     g_IsInPrimaryAttack = 1
  836.  
  837.     pev(Player,pev_punchangle,cl_pushangle[Player])
  838.  
  839.    
  840.  
  841.     g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
  842.  
  843. }
  844.  
  845.  
  846.  
  847. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  848.  
  849. {
  850.  
  851.     if ((eventid != g_orig_event_scsr) || !g_IsInPrimaryAttack)
  852.  
  853.         return FMRES_IGNORED
  854.  
  855.     if (!(1 <= invoker <= g_MaxPlayers))
  856.  
  857.     return FMRES_IGNORED
  858.  
  859.  
  860.  
  861.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  862.  
  863.     return FMRES_SUPERCEDE
  864.  
  865. }
  866.  
  867.  
  868.  
  869. public fw_scsr_PrimaryAttack_Post(Weapon)
  870.  
  871. {
  872.  
  873.     g_IsInPrimaryAttack = 0
  874.  
  875.     new iPlayer = get_pdata_cbase(Weapon, 41, 4)
  876.  
  877.    
  878.  
  879.     new szClip, szAmmo
  880.  
  881.     get_user_weapon(iPlayer, szClip, szAmmo)
  882.  
  883.    
  884.  
  885.     if(!is_user_alive(iPlayer))
  886.  
  887.         return
  888.  
  889.  
  890.  
  891.     if(g_has_scsr[iPlayer])
  892.  
  893.     {
  894.  
  895.         if (!g_clip_ammo[iPlayer])
  896.  
  897.             return
  898.  
  899.  
  900.  
  901.         new Float:push[3]
  902.  
  903.         pev(iPlayer,pev_punchangle,push)
  904.  
  905.         xs_vec_sub(push,cl_pushangle[iPlayer],push)
  906.  
  907.        
  908.  
  909.         xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil_scsr),push)
  910.  
  911.         xs_vec_add(push,cl_pushangle[iPlayer],push)
  912.  
  913.         set_pev(iPlayer,pev_punchangle,push)
  914.  
  915.        
  916.  
  917.         emit_sound(iPlayer, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  918.  
  919.         UTIL_PlayWeaponAnimation(iPlayer, random_num(scsr_SHOOT1, scsr_SHOOT2))
  920.  
  921.  
  922.  
  923.         static Float:plrViewAngles[3], Float:VecEnd[3], Float:VecDir[3], Float:PlrOrigin[3]
  924.  
  925.         pev(iPlayer, pev_v_angle, plrViewAngles)
  926.  
  927.  
  928.  
  929.         static Float:VecSrc[3], Float:VecDst[3]
  930.  
  931.    
  932.  
  933.         //VecSrc = pev->origin + pev->view_ofs
  934.  
  935.         pev(iPlayer, pev_origin, PlrOrigin)
  936.  
  937.         pev(iPlayer, pev_view_ofs, VecSrc)
  938.  
  939.         xs_vec_add(VecSrc, PlrOrigin, VecSrc)
  940.  
  941.  
  942.  
  943.         //VecDst = VecDir * 8192.0
  944.  
  945.         angle_vector(plrViewAngles, ANGLEVECTOR_FORWARD, VecDir)
  946.  
  947.         xs_vec_mul_scalar(VecDir, 8192.0, VecDst)
  948.  
  949.         xs_vec_add(VecDst, VecSrc, VecDst)
  950.  
  951.    
  952.  
  953.         new hTrace = create_tr2()
  954.  
  955.         engfunc(EngFunc_TraceLine, VecSrc, VecDst, 0, iPlayer, hTrace)
  956.  
  957.         get_tr2(hTrace, TR_vecEndPos, VecEnd)
  958.  
  959.  
  960.  
  961.         explode(iPlayer);
  962.  
  963.         scsr_spr_ball(iPlayer, VecSrc, VecEnd);
  964.  
  965.     }
  966.  
  967. }
  968.  
  969.  
  970.  
  971. public explode(id)
  972.  
  973. {
  974.  
  975.     if(is_user_alive(id))
  976.  
  977.     {      
  978.  
  979.         new Float:originF[3]
  980.  
  981.         fm_get_aim_origin(id, originF)
  982.  
  983.         message_begin(MSG_ALL, SVC_TEMPENTITY)
  984.  
  985.         write_byte(TE_SPARKS)
  986.  
  987.         engfunc(EngFunc_WriteCoord, originF[0])
  988.  
  989.         engfunc(EngFunc_WriteCoord, originF[1])
  990.  
  991.         engfunc(EngFunc_WriteCoord, originF[2]+30.0)
  992.  
  993.         message_end()
  994.  
  995.        
  996.  
  997.         message_begin(MSG_ALL, SVC_TEMPENTITY)
  998.  
  999.         write_byte(TE_SPARKS)
  1000.  
  1001.         engfunc(EngFunc_WriteCoord, originF[0]+30.0)
  1002.  
  1003.         engfunc(EngFunc_WriteCoord, originF[1])
  1004.  
  1005.         engfunc(EngFunc_WriteCoord, originF[2]+30.0)
  1006.  
  1007.         message_end()
  1008.  
  1009.        
  1010.  
  1011.         message_begin(MSG_ALL, SVC_TEMPENTITY)
  1012.  
  1013.         write_byte(TE_SPARKS)
  1014.  
  1015.         engfunc(EngFunc_WriteCoord, originF[0])
  1016.  
  1017.         engfunc(EngFunc_WriteCoord, originF[1]+30.0)
  1018.  
  1019.         engfunc(EngFunc_WriteCoord, originF[2]+30.0)
  1020.  
  1021.         message_end()
  1022.  
  1023.        
  1024.  
  1025.         message_begin(MSG_ALL, SVC_TEMPENTITY)
  1026.  
  1027.         write_byte(TE_SPARKS)
  1028.  
  1029.         engfunc(EngFunc_WriteCoord, originF[0])
  1030.  
  1031.         engfunc(EngFunc_WriteCoord, originF[1]+40.0)
  1032.  
  1033.         engfunc(EngFunc_WriteCoord, originF[2]+40.0)
  1034.  
  1035.         message_end()
  1036.  
  1037.        
  1038.  
  1039.         message_begin(MSG_ALL, SVC_TEMPENTITY)
  1040.  
  1041.         write_byte(TE_SPARKS)
  1042.  
  1043.         engfunc(EngFunc_WriteCoord, originF[0])
  1044.  
  1045.         engfunc(EngFunc_WriteCoord, originF[1]+40.0)
  1046.  
  1047.         engfunc(EngFunc_WriteCoord, originF[2]+30.0)
  1048.  
  1049.         message_end()
  1050.  
  1051.        
  1052.  
  1053.         message_begin(MSG_ALL, SVC_TEMPENTITY)
  1054.  
  1055.         write_byte(TE_SPARKS)
  1056.  
  1057.         engfunc(EngFunc_WriteCoord, originF[0])
  1058.  
  1059.         engfunc(EngFunc_WriteCoord, originF[1]+30.0)
  1060.  
  1061.         engfunc(EngFunc_WriteCoord, originF[2]+40.0)
  1062.  
  1063.         message_end()
  1064.  
  1065.        
  1066.  
  1067.         // Draw explosion
  1068.  
  1069.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  1070.  
  1071.         write_byte(TE_SPRITE) // Temporary entity ID
  1072.  
  1073.         engfunc(EngFunc_WriteCoord, originF[0]) // engfunc because float
  1074.  
  1075.         engfunc(EngFunc_WriteCoord, originF[1])
  1076.  
  1077.         engfunc(EngFunc_WriteCoord, originF[2]+40.0)
  1078.  
  1079.         write_short(g_SprID) // Sprite index
  1080.  
  1081.         write_byte(8) // Scale
  1082.  
  1083.         write_byte(255) // Framerate
  1084.  
  1085.         message_end()
  1086.  
  1087.  
  1088.  
  1089.         new a = FM_NULLENT
  1090.  
  1091.         while((a = find_ent_in_sphere(a, originF, 60.0)) != 0)
  1092.  
  1093.         {
  1094.  
  1095.             if (id == a)
  1096.  
  1097.                 continue
  1098.  
  1099.                
  1100.  
  1101.             if(pev(a, pev_takedamage) != DAMAGE_NO)
  1102.  
  1103.             {
  1104.  
  1105.                 ExecuteHamB(Ham_TakeDamage, a, id, id, 50.0, DMG_BULLET)
  1106.  
  1107.             }
  1108.  
  1109.         }
  1110.  
  1111.         return PLUGIN_HANDLED
  1112.  
  1113.     }
  1114.  
  1115.     return PLUGIN_HANDLED
  1116.  
  1117. }
  1118.  
  1119.  
  1120.  
  1121. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, ent)
  1122.  
  1123. {
  1124.  
  1125.     if (victim != attacker && is_user_connected(attacker))
  1126.  
  1127.     {
  1128.  
  1129.         if(get_user_weapon(attacker) == CSW_G3SG1)
  1130.  
  1131.         {
  1132.  
  1133.             if(g_has_scsr[attacker])
  1134.  
  1135.                 SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_scsr))
  1136.  
  1137.         }
  1138.  
  1139.     }
  1140.  
  1141. }
  1142.  
  1143.  
  1144.  
  1145. public message_DeathMsg(msg_id, msg_dest, id)
  1146.  
  1147. {
  1148.  
  1149.     static szTruncatedWeapon[33], iAttacker, iVictim
  1150.  
  1151.    
  1152.  
  1153.     get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  1154.  
  1155.    
  1156.  
  1157.     iAttacker = get_msg_arg_int(1)
  1158.  
  1159.     iVictim = get_msg_arg_int(2)
  1160.  
  1161.    
  1162.  
  1163.     if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  1164.  
  1165.         return PLUGIN_CONTINUE
  1166.  
  1167.    
  1168.  
  1169.     if(equal(szTruncatedWeapon, "sg550") && get_user_weapon(iAttacker) == CSW_G3SG1)
  1170.  
  1171.     {
  1172.  
  1173.         if(g_has_scsr[iAttacker])
  1174.  
  1175.             set_msg_arg_string(4, "sg550")
  1176.  
  1177.     }
  1178.  
  1179.     return PLUGIN_CONTINUE
  1180.  
  1181. }
  1182.  
  1183.  
  1184.  
  1185. stock fm_cs_get_current_weapon_ent(id)
  1186.  
  1187. {
  1188.  
  1189.     return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
  1190.  
  1191. }
  1192.  
  1193.  
  1194.  
  1195. stock fm_cs_get_weapon_ent_owner(ent)
  1196.  
  1197. {
  1198.  
  1199.     return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
  1200.  
  1201. }
  1202.  
  1203.  
  1204.  
  1205. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
  1206.  
  1207. {
  1208.  
  1209.     set_pev(Player, pev_weaponanim, Sequence)
  1210.  
  1211.    
  1212.  
  1213.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  1214.  
  1215.     write_byte(Sequence)
  1216.  
  1217.     write_byte(pev(Player, pev_body))
  1218.  
  1219.     message_end()
  1220.  
  1221. }
  1222.  
  1223.  
  1224.  
  1225. public scsr_ItemPostFrame(weapon_entity)
  1226.  
  1227. {
  1228.  
  1229.      new id = pev(weapon_entity, pev_owner)
  1230.  
  1231.      if (!is_user_connected(id))
  1232.  
  1233.           return HAM_IGNORED
  1234.  
  1235.  
  1236.  
  1237.      if (!g_has_scsr[id])
  1238.  
  1239.           return HAM_IGNORED
  1240.  
  1241.  
  1242.  
  1243.      static iClipExtra
  1244.  
  1245.      
  1246.  
  1247.      iClipExtra = get_pcvar_num(cvar_clip_scsr)
  1248.  
  1249.      new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)
  1250.  
  1251.  
  1252.  
  1253.      new iBpAmmo = cs_get_user_bpammo(id, CSW_G3SG1)
  1254.  
  1255.      new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  1256.  
  1257.  
  1258.  
  1259.      new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF)
  1260.  
  1261.  
  1262.  
  1263.      if(!(get_user_button(id) & IN_ATTACK))
  1264.  
  1265.         g_lastexpl[id] = get_gametime()
  1266.  
  1267.  
  1268.  
  1269.      if( fInReload && flNextAttack <= 0.0 )
  1270.  
  1271.      {
  1272.  
  1273.          new j = min(iClipExtra - iClip, iBpAmmo)
  1274.  
  1275.    
  1276.  
  1277.          set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
  1278.  
  1279.          cs_set_user_bpammo(id, CSW_G3SG1, iBpAmmo-j)
  1280.  
  1281.        
  1282.  
  1283.          set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
  1284.  
  1285.          fInReload = 0
  1286.  
  1287.      }
  1288.  
  1289.      return HAM_IGNORED
  1290.  
  1291. }
  1292.  
  1293.  
  1294.  
  1295. public scsr_Reload(weapon_entity)
  1296.  
  1297. {
  1298.  
  1299.      new id = pev(weapon_entity, pev_owner)
  1300.  
  1301.      if (!is_user_connected(id))
  1302.  
  1303.           return HAM_IGNORED
  1304.  
  1305.  
  1306.  
  1307.      if (!g_has_scsr[id])
  1308.  
  1309.           return HAM_IGNORED
  1310.  
  1311.  
  1312.  
  1313.      static iClipExtra
  1314.  
  1315.  
  1316.  
  1317.      if(g_has_scsr[id])
  1318.  
  1319.           iClipExtra = get_pcvar_num(cvar_clip_scsr)
  1320.  
  1321.  
  1322.  
  1323.      g_scsr_TmpClip[id] = -1
  1324.  
  1325.  
  1326.  
  1327.      new iBpAmmo = cs_get_user_bpammo(id, CSW_G3SG1)
  1328.  
  1329.      new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  1330.  
  1331.  
  1332.  
  1333.      if (iBpAmmo <= 0)
  1334.  
  1335.           return HAM_SUPERCEDE
  1336.  
  1337.  
  1338.  
  1339.      if (iClip >= iClipExtra)
  1340.  
  1341.           return HAM_SUPERCEDE
  1342.  
  1343.  
  1344.  
  1345.      g_scsr_TmpClip[id] = iClip
  1346.  
  1347.  
  1348.  
  1349.      return HAM_IGNORED
  1350.  
  1351. }
  1352.  
  1353.  
  1354.  
  1355. public scsr_Reload_Post(weapon_entity)
  1356.  
  1357. {
  1358.  
  1359.     new id = pev(weapon_entity, pev_owner)
  1360.  
  1361.     if (!is_user_connected(id))
  1362.  
  1363.         return HAM_IGNORED
  1364.  
  1365.  
  1366.  
  1367.     if (!g_has_scsr[id])
  1368.  
  1369.         return HAM_IGNORED
  1370.  
  1371.  
  1372.  
  1373.     if (g_scsr_TmpClip[id] == -1)
  1374.  
  1375.         return HAM_IGNORED
  1376.  
  1377.  
  1378.  
  1379.     set_pdata_int(weapon_entity, m_iClip, g_scsr_TmpClip[id], WEAP_LINUX_XTRA_OFF)
  1380.  
  1381.  
  1382.  
  1383.     set_pdata_float(weapon_entity, m_flTimeWeaponIdle, scsr_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)
  1384.  
  1385.  
  1386.  
  1387.     set_pdata_float(id, m_flNextAttack, scsr_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)
  1388.  
  1389.  
  1390.  
  1391.     set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)
  1392.  
  1393.  
  1394.  
  1395.     UTIL_PlayWeaponAnimation(id, scsr_RELOAD)
  1396.  
  1397.  
  1398.  
  1399.     return HAM_IGNORED
  1400.  
  1401. }
  1402.  
  1403.  
  1404.  
  1405. stock scsr_spr_ball(id, Float:fVec1[3], Float:fVec2[3])
  1406.  
  1407. {
  1408.  
  1409.     static iVec1[3]
  1410.  
  1411.     FVecIVec(fVec1, iVec1)
  1412.  
  1413.  
  1414.  
  1415.     static Float:origin[3], Float:vSrc[3], Float:angles[3], Float:v_forward[3], Float:v_right[3], Float:v_up[3], Float:gun_position[3], Float:player_origin[3], Float:player_view_offset[3]
  1416.  
  1417.     pev(id, pev_v_angle, angles)
  1418.  
  1419.     engfunc(EngFunc_MakeVectors, angles)
  1420.  
  1421.     global_get(glb_v_forward, v_forward)
  1422.  
  1423.     global_get(glb_v_right, v_right)
  1424.  
  1425.     global_get(glb_v_up, v_up)
  1426.  
  1427.  
  1428.  
  1429.     //m_pPlayer->GetGunPosition( ) = pev->origin + pev->view_ofs
  1430.  
  1431.     pev(id, pev_origin, player_origin)
  1432.  
  1433.     pev(id, pev_view_ofs, player_view_offset)
  1434.  
  1435.     xs_vec_add(player_origin, player_view_offset, gun_position)
  1436.  
  1437.  
  1438.  
  1439.     xs_vec_mul_scalar(v_forward, 24.0, v_forward)
  1440.  
  1441.     xs_vec_mul_scalar(v_right, 3.0, v_right)
  1442.  
  1443.  
  1444.  
  1445.     if ((pev(id, pev_flags) & FL_DUCKING) == FL_DUCKING)
  1446.  
  1447.         xs_vec_mul_scalar(v_up, 6.0, v_up)
  1448.  
  1449.     else
  1450.  
  1451.         xs_vec_mul_scalar(v_up, -2.0, v_up)
  1452.  
  1453.  
  1454.  
  1455.     xs_vec_add(gun_position, v_forward, origin)
  1456.  
  1457.     xs_vec_add(origin, v_right, origin)
  1458.  
  1459.     xs_vec_add(origin, v_up, origin)
  1460.  
  1461.  
  1462.  
  1463.     vSrc[0] = origin[0]
  1464.  
  1465.     vSrc[1] = origin[1]
  1466.  
  1467.     vSrc[2] = origin[2]
  1468.  
  1469.  
  1470.  
  1471.     new Float:dist = get_distance_f(vSrc, fVec2)
  1472.  
  1473.     new CountDrops = floatround(dist / 50.0)
  1474.  
  1475.    
  1476.  
  1477.     if (CountDrops > 20)
  1478.  
  1479.         CountDrops = 20
  1480.  
  1481.    
  1482.  
  1483.     if (CountDrops < 2)
  1484.  
  1485.         CountDrops = 2
  1486.  
  1487.  
  1488.  
  1489.     message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
  1490.  
  1491.     write_byte(TE_SPRITETRAIL)
  1492.  
  1493.     engfunc(EngFunc_WriteCoord, vSrc[0])
  1494.  
  1495.     engfunc(EngFunc_WriteCoord, vSrc[1])
  1496.  
  1497.     engfunc(EngFunc_WriteCoord, vSrc[2])
  1498.  
  1499.     engfunc(EngFunc_WriteCoord, fVec2[0])
  1500.  
  1501.     engfunc(EngFunc_WriteCoord, fVec2[1])
  1502.  
  1503.     engfunc(EngFunc_WriteCoord, fVec2[2])
  1504.  
  1505.     write_short(scsr_ball)
  1506.  
  1507.     write_byte(CountDrops)
  1508.  
  1509.     write_byte(0)
  1510.  
  1511.     write_byte(1)
  1512.  
  1513.     write_byte(60)
  1514.  
  1515.     write_byte(10)
  1516.  
  1517.     message_end()
  1518.  
  1519. }
  1520.  
  1521.  
  1522.  
  1523. stock drop_weapons(id, dropwhat)
  1524.  
  1525. {
  1526.  
  1527.      static weapons[32], num, i, weaponid
  1528.  
  1529.      num = 0
  1530.  
  1531.      get_user_weapons(id, weapons, num)
  1532.  
  1533.      
  1534.  
  1535.      for (i = 0; i < num; i++)
  1536.  
  1537.      {
  1538.  
  1539.           weaponid = weapons[i]
  1540.  
  1541.          
  1542.  
  1543.           if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
  1544.  
  1545.           {
  1546.  
  1547.                static wname[32]
  1548.  
  1549.                get_weaponname(weaponid, wname, sizeof wname - 1)
  1550.  
  1551.                engclient_cmd(id, "drop", wname)
  1552.  
  1553.           }
  1554.  
  1555.      }
  1556.  
  1557. }
Screenshots:



20180903134903_1.jpg
20180903134858_1.jpg
20180903134855_1.jpg
Download:



StarChaserSR.zip
(1.76 MiB) Downloaded 80 times
StarChaserSR.zip
(1.76 MiB) Downloaded 80 times
These users thanked the author Mark for the post (total 3):
Raheem (1 Year Ago) • DarkZombie (1 Year Ago) • Muhammet20 (3 Months Ago)

xman2030
Member
Member
Russia
Posts: 2
Joined: 1 Year Ago
Has thanked: 0
Been thanked: 0
Contact:

#2

Post by xman2030 » 1 Year Ago

Did you download this plugin from zombie-amxx?

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#3

Post by Mark » 1 Year Ago

xman2030 wrote:
1 Year Ago
Did you download this plugin from zombie-amxx?
Probably I don’t remember had it for awhile and use it on my ZP server.

I just converted it to ZE and fixed a bug with it.

Why?

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 391
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#4

Post by Muhammet20 » 3 Months Ago

Mark wrote:
1 Year Ago
Description:
  • A new extra-item for humans, Star Chaser SR
  • I did not make this weapon only converted!
Cvars:
  • ze_scsr_dmg 2.0
  • ze_scsr_recoil 1.90
  • ze_scsr_clip 15
  • ze_scsr_spd 2.48
  • ze_scsr_ammo 120
Code:
  1. #pragma compress 1
  2.  
  3. #include <zombie_escape>
  4. #include <engine>
  5. #include <fakemeta_util>
  6. #include <cstrike>
  7. #include <fun>
  8. #include <xs>
  9.  
  10. #pragma tabsize 0
  11.  
  12. #define ENG_NULLENT         -1
  13.  
  14. #define EV_INT_WEAPONKEY    EV_INT_impulse
  15.  
  16. #define scsr_WEAPONKEY      10018
  17.  
  18. #define MAX_PLAYERS         32
  19.  
  20. #define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
  21.  
  22.  
  23.  
  24. const USE_STOPPED = 0
  25.  
  26. const OFFSET_ACTIVE_ITEM = 373
  27.  
  28. const OFFSET_WEAPONOWNER = 41
  29.  
  30. const OFFSET_LINUX = 5
  31.  
  32. const OFFSET_LINUX_WEAPONS = 4
  33.  
  34.  
  35.  
  36. #define WEAP_LINUX_XTRA_OFF     4
  37.  
  38. #define m_fKnown                    44
  39.  
  40. #define m_flNextPrimaryAttack       46
  41.  
  42. #define m_flTimeWeaponIdle          48
  43.  
  44. #define m_iClip                 51
  45.  
  46. #define m_fInReload             54
  47.  
  48. #define PLAYER_LINUX_XTRA_OFF   5
  49.  
  50. #define m_flNextAttack              83
  51.  
  52.  
  53.  
  54. #define scsr_RELOAD_TIME        4.0
  55.  
  56. #define scsr_SHOOT1             1
  57.  
  58. #define scsr_SHOOT2             2
  59.  
  60. #define scsr_RELOAD             3
  61.  
  62. #define scsr_DRAW               4
  63.  
  64.  
  65.  
  66. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
  67.  
  68.  
  69.  
  70. new const Fire_Sounds[][] = { "weapons/starchasersr-1.wav" }
  71.  
  72.  
  73.  
  74. new scsr_V_MODEL[64] = "models/v_starchasersr.mdl"
  75.  
  76. new scsr_P_MODEL[64] = "models/p_starchasersr.mdl"
  77.  
  78. new scsr_W_MODEL[64] = "models/w_starchasersr.mdl"
  79.  
  80.  
  81.  
  82. new const scsr_name[] = "weapon_starchasersr"
  83.  
  84.  
  85.  
  86. new const scsr_spr[][] =
  87.  
  88. {
  89.  
  90.     "sprites/640hud171.spr",
  91.  
  92.     "sprites/640hud18.spr"
  93.  
  94. }
  95.  
  96.  
  97.  
  98. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
  99.  
  100.  
  101.  
  102. new cvar_dmg_scsr, cvar_recoil_scsr, g_itemid_scsr, cvar_clip_scsr, cvar_spd_scsr, cvar_scsr_ammo
  103.  
  104. new g_MaxPlayers, g_orig_event_scsr, g_IsInPrimaryAttack
  105.  
  106. new Float:cl_pushangle[MAX_PLAYERS + 1][3]
  107.  
  108. new g_has_scsr[33], g_clip_ammo[33], g_scsr_TmpClip[33], oldweap[33]
  109.  
  110. new gmsgWeaponList, scsr_ball
  111.  
  112. new g_SprID
  113.  
  114. new Float:g_lastexpl[33]
  115.  
  116.  
  117.  
  118. const PRIMARY_WEAPONS_BIT_SUM =
  119.  
  120. (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<
  121.  
  122. CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
  123.  
  124. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
  125.  
  126.             "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
  127.  
  128.             "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  129.  
  130.             "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  131.  
  132.             "weapon_ak47", "weapon_knife", "weapon_p90" }
  133.  
  134.  
  135. public plugin_precache()
  136.  
  137. {
  138.  
  139.     precache_model(scsr_V_MODEL)
  140.  
  141.     precache_model(scsr_P_MODEL)
  142.  
  143.     precache_model(scsr_W_MODEL)
  144.  
  145.     for(new i = 0; i < sizeof Fire_Sounds; i++)
  146.  
  147.     precache_sound(Fire_Sounds[i])  
  148.  
  149.     precache_sound("weapons/starchasersr_clipin.wav")
  150.  
  151.     precache_sound("weapons/starchasersr_clipout.wav")
  152.  
  153.     precache_sound("weapons/starchasersr_idle.wav")
  154.  
  155.  
  156.  
  157.     g_SprID = precache_model("sprites/ef_starchasersr_explosion.spr")
  158.  
  159.     scsr_ball = precache_model("sprites/ef_starchasersr_star.spr")
  160.  
  161.  
  162.  
  163.     new sFile[64]
  164.  
  165.     formatex(sFile, charsmax(sFile), "sprites/%s.txt", scsr_name)
  166.  
  167.     precache_generic(sFile)
  168.  
  169.    
  170.  
  171.     for(new i = 0; i < sizeof(scsr_spr); i++)
  172.  
  173.     {
  174.  
  175.         precache_generic(scsr_spr[i])
  176.  
  177.     }
  178.  
  179.  
  180.  
  181.     register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
  182.  
  183. }
  184.  
  185. public plugin_init()
  186.  
  187. {
  188.  
  189.     register_plugin("Star Chaser SR", "1.0", "[YouTube]COBA/Mark")
  190.  
  191.     register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
  192.  
  193.     register_event("CurWeapon","CurrentWeapon","be","1=1")
  194.  
  195.     RegisterHam(Ham_Item_AddToPlayer, "weapon_g3sg1", "fw_scsr_AddToPlayer")
  196.  
  197.     RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
  198.  
  199.     RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
  200.  
  201.     RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
  202.  
  203.     RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
  204.  
  205.     for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
  206.  
  207.     if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
  208.  
  209.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_g3sg1", "fw_scsr_PrimaryAttack")
  210.  
  211.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_g3sg1", "fw_scsr_PrimaryAttack_Post", 1)
  212.  
  213.     RegisterHam(Ham_Item_PostFrame, "weapon_g3sg1", "scsr_ItemPostFrame")
  214.  
  215.     RegisterHam(Ham_Weapon_Reload, "weapon_g3sg1", "scsr_Reload")
  216.  
  217.     RegisterHam(Ham_Weapon_Reload, "weapon_g3sg1", "scsr_Reload_Post", 1)
  218.  
  219.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  220.  
  221.     register_forward(FM_SetModel, "fw_SetModel")
  222.  
  223.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  224.  
  225.     register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
  226.  
  227.  
  228.  
  229.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
  230.  
  231.     RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
  232.  
  233.     RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
  234.  
  235.     RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
  236.  
  237.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
  238.  
  239.     RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
  240.  
  241.     RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
  242.  
  243.  
  244.  
  245.     cvar_dmg_scsr = register_cvar("ze_scsr_dmg", "2.0")
  246.  
  247.     cvar_recoil_scsr = register_cvar("ze_scsr_recoil", "1.90")
  248.  
  249.     cvar_clip_scsr = register_cvar("ze_scsr_clip", "15")
  250.  
  251.     cvar_spd_scsr = register_cvar("ze_scsr_spd", "2.48")
  252.  
  253.     cvar_scsr_ammo = register_cvar("ze_scsr_ammo", "120")
  254.  
  255.    
  256.  
  257.     g_itemid_scsr = ze_register_item("Star Chaser SR", 80, 0)
  258.  
  259.     g_MaxPlayers = get_maxplayers()
  260.  
  261.     gmsgWeaponList = get_user_msgid("WeaponList")
  262.  
  263.     register_clcmd(scsr_name, "command_scsr")
  264.  
  265. }
  266.  
  267. public ze_user_humanized(id)
  268. {
  269.     g_has_scsr[id] = false
  270. }
  271.  
  272. public ze_user_infected(Victim)
  273. {
  274.     g_has_scsr[Victim] = false
  275. }
  276.  
  277. public client_putinserver(id)
  278. {
  279.     g_has_scsr[id] = false
  280. }
  281.  
  282. public client_disconnected(id)
  283. {
  284.     g_has_scsr[id] = false
  285. }
  286.  
  287.  
  288.  
  289. public fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType, Player, id)
  290.  
  291. {
  292.  
  293.     if(!is_user_alive(iAttacker))
  294.  
  295.         return
  296.  
  297.  
  298.  
  299.     new g_currentweapon = get_user_weapon(iAttacker)
  300.  
  301.  
  302.  
  303.     if(g_currentweapon != CSW_G3SG1) return
  304.  
  305.    
  306.  
  307.     if(!g_has_scsr[iAttacker]) return
  308.  
  309.  
  310.  
  311.     static Float:flEnd[3]
  312.  
  313.     get_tr2(ptr, TR_vecEndPos, flEnd)
  314.  
  315.  
  316.  
  317.     if(iEnt)
  318.  
  319.     {
  320.  
  321.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  322.  
  323.         write_byte(TE_DECAL)
  324.  
  325.         write_coord_f(flEnd[0])
  326.  
  327.         write_coord_f(flEnd[1])
  328.  
  329.         write_coord_f(flEnd[2])
  330.  
  331.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  332.  
  333.         write_short(iEnt)
  334.  
  335.         message_end()
  336.  
  337.     }
  338.  
  339.     else
  340.  
  341.     {
  342.  
  343.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  344.  
  345.         write_byte(TE_WORLDDECAL)
  346.  
  347.         write_coord_f(flEnd[0])
  348.  
  349.         write_coord_f(flEnd[1])
  350.  
  351.         write_coord_f(flEnd[2])
  352.  
  353.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  354.  
  355.         message_end()
  356.  
  357.     }
  358.  
  359.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  360.  
  361.     write_byte(TE_GUNSHOTDECAL)
  362.  
  363.     write_coord_f(flEnd[0])
  364.  
  365.     write_coord_f(flEnd[1])
  366.  
  367.     write_coord_f(flEnd[2])
  368.  
  369.     write_short(iAttacker)
  370.  
  371.     write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  372.  
  373.     message_end()
  374.  
  375. }
  376.  
  377.  
  378.  
  379. public command_scsr(Player)
  380.  
  381. {
  382.  
  383.     engclient_cmd(Player, "weapon_g3sg1")
  384.  
  385.     return PLUGIN_HANDLED
  386.  
  387. }
  388.  
  389.  
  390. public plugin_natives ()
  391.  
  392. {
  393.  
  394.     register_native("give_weapon_scsr", "native_give_weapon_add", 1)
  395.  
  396. }
  397.  
  398. public native_give_weapon_add(id)
  399.  
  400. {
  401.  
  402.     give_scsr(id)
  403.  
  404. }
  405.  
  406.  
  407.  
  408. public fwPrecacheEvent_Post(type, const name[])
  409.  
  410. {
  411.  
  412.     if (equal("events/g3sg1.sc", name))
  413.  
  414.     {
  415.  
  416.         g_orig_event_scsr = get_orig_retval()
  417.  
  418.         return FMRES_HANDLED
  419.  
  420.     }
  421.  
  422.     return FMRES_IGNORED
  423.  
  424. }
  425.  
  426.  
  427.  
  428.  
  429. public fw_SetModel(entity, model[])
  430.  
  431. {
  432.  
  433.     if(!is_valid_ent(entity))
  434.  
  435.         return FMRES_IGNORED
  436.  
  437.    
  438.  
  439.     static szClassName[33]
  440.  
  441.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  442.  
  443.        
  444.  
  445.     if(!equal(szClassName, "weaponbox"))
  446.  
  447.         return FMRES_IGNORED
  448.  
  449.    
  450.  
  451.     static iOwner
  452.  
  453.    
  454.  
  455.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  456.  
  457.    
  458.  
  459.     if(equal(model, "models/w_g3sg1.mdl"))
  460.  
  461.     {
  462.  
  463.         static iStoredAugID
  464.  
  465.        
  466.  
  467.         iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_g3sg1", entity)
  468.  
  469.    
  470.  
  471.         if(!is_valid_ent(iStoredAugID))
  472.  
  473.             return FMRES_IGNORED
  474.  
  475.    
  476.  
  477.         if(g_has_scsr[iOwner])
  478.  
  479.         {
  480.  
  481.             entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, scsr_WEAPONKEY)
  482.  
  483.            
  484.  
  485.             g_has_scsr[iOwner] = false
  486.  
  487.            
  488.  
  489.             entity_set_model(entity, scsr_W_MODEL)
  490.  
  491.            
  492.  
  493.             return FMRES_SUPERCEDE
  494.  
  495.         }
  496.  
  497.     }
  498.  
  499.     return FMRES_IGNORED
  500.  
  501. }
  502.  
  503.  
  504.  
  505. public give_scsr(id)
  506.  
  507. {
  508.  
  509.     drop_weapons(id, 1)
  510.  
  511.     new iWep2 = give_item(id,"weapon_g3sg1")
  512.  
  513.     if( iWep2 > 0 )
  514.  
  515.     {
  516.  
  517.         cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_scsr))
  518.  
  519.         cs_set_user_bpammo (id, CSW_G3SG1, get_pcvar_num(cvar_scsr_ammo))  
  520.  
  521.         UTIL_PlayWeaponAnimation(id, scsr_DRAW)
  522.  
  523.         set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
  524.  
  525.  
  526.  
  527.         message_begin(MSG_ONE, gmsgWeaponList, _, id)
  528.  
  529.         write_string(scsr_name)
  530.  
  531.         write_byte(2)
  532.  
  533.         write_byte(90)
  534.  
  535.         write_byte(-1)
  536.  
  537.         write_byte(-1)
  538.  
  539.         write_byte(0)
  540.  
  541.         write_byte(3)
  542.  
  543.         write_byte(CSW_G3SG1)
  544.  
  545.         message_end()
  546.  
  547.     }
  548.  
  549.     g_has_scsr[id] = true
  550.  
  551. }
  552.  
  553.  
  554.  
  555. public ze_select_item_pre(id, itemid)
  556. {  
  557.     if (itemid != g_itemid_scsr)
  558.         return ZE_ITEM_AVAILABLE
  559.    
  560.     if (ze_is_user_zombie(id))
  561.         return ZE_ITEM_DONT_SHOW
  562.        
  563.     return ZE_ITEM_AVAILABLE
  564. }
  565.  
  566. public ze_select_item_post(id, itemid)
  567. {
  568.     if (itemid != g_itemid_scsr)
  569.         return
  570.        
  571.     ze_colored_print(id, "Congrats! You have bought Star Chaser SR! :D")
  572.    
  573.     give_scsr(id)
  574. }
  575.  
  576. public fw_scsr_AddToPlayer(scsr, id)
  577.  
  578. {
  579.  
  580.     if(!is_valid_ent(scsr) || !is_user_connected(id))
  581.  
  582.         return HAM_IGNORED
  583.  
  584.    
  585.  
  586.     if(entity_get_int(scsr, EV_INT_WEAPONKEY) == scsr_WEAPONKEY)
  587.  
  588.     {
  589.  
  590.         g_has_scsr[id] = true
  591.  
  592.        
  593.  
  594.         entity_set_int(scsr, EV_INT_WEAPONKEY, 0)
  595.  
  596.  
  597.  
  598.         message_begin(MSG_ONE, gmsgWeaponList, _, id)
  599.  
  600.         write_string(scsr_name)
  601.  
  602.         write_byte(2)
  603.  
  604.         write_byte(90)
  605.  
  606.         write_byte(-1)
  607.  
  608.         write_byte(-1)
  609.  
  610.         write_byte(0)
  611.  
  612.         write_byte(3)
  613.  
  614.         write_byte(CSW_G3SG1)
  615.  
  616.         message_end()
  617.  
  618.  
  619.  
  620.         return HAM_HANDLED
  621.  
  622.     }
  623.  
  624.     else
  625.  
  626.     {
  627.  
  628.         message_begin(MSG_ONE, gmsgWeaponList, _, id)
  629.  
  630.         write_string("weapon_g3sg1")
  631.  
  632.         write_byte(2)
  633.  
  634.         write_byte(90)
  635.  
  636.         write_byte(-1)
  637.  
  638.         write_byte(-1)
  639.  
  640.         write_byte(0)
  641.  
  642.         write_byte(3)
  643.  
  644.         write_byte(CSW_G3SG1)
  645.  
  646.         message_end()
  647.  
  648.     }
  649.  
  650.     return HAM_IGNORED
  651.  
  652. }
  653.  
  654.  
  655.  
  656. public fw_UseStationary_Post(entity, caller, activator, use_type)
  657.  
  658. {
  659.  
  660.     if (use_type == USE_STOPPED && is_user_connected(caller))
  661.  
  662.         replace_weapon_models(caller, get_user_weapon(caller))
  663.  
  664. }
  665.  
  666.  
  667.  
  668. public fw_Item_Deploy_Post(weapon_ent)
  669.  
  670. {
  671.  
  672.     static owner
  673.  
  674.     owner = fm_cs_get_weapon_ent_owner(weapon_ent)
  675.  
  676.    
  677.  
  678.     static weaponid
  679.  
  680.     weaponid = cs_get_weapon_id(weapon_ent)
  681.  
  682.    
  683.  
  684.     replace_weapon_models(owner, weaponid)
  685.  
  686. }
  687.  
  688.  
  689.  
  690. public CurrentWeapon(id)
  691.  
  692. {
  693.  
  694.      replace_weapon_models(id, read_data(2))
  695.  
  696.  
  697.  
  698.      if(read_data(2) != CSW_G3SG1 || !g_has_scsr[id])
  699.  
  700.           return
  701.  
  702.      
  703.  
  704.      static Float:iSpeed
  705.  
  706.      if(g_has_scsr[id])
  707.  
  708.           iSpeed = get_pcvar_float(cvar_spd_scsr)
  709.  
  710.      
  711.  
  712.      static weapon[32],Ent
  713.  
  714.      get_weaponname(read_data(2),weapon,31)
  715.  
  716.      Ent = find_ent_by_owner(-1,weapon,id)
  717.  
  718.      if(Ent)
  719.  
  720.      {
  721.  
  722.           static Float:Delay
  723.  
  724.           Delay = get_pdata_float( Ent, 46, 4) * iSpeed
  725.  
  726.           if (Delay > 0.0)
  727.  
  728.           {
  729.  
  730.                set_pdata_float(Ent, 46, Delay, 4)
  731.  
  732.           }
  733.  
  734.      }
  735.  
  736. }
  737.  
  738.  
  739.  
  740. replace_weapon_models(id, weaponid)
  741.  
  742. {
  743.  
  744.     switch (weaponid)
  745.  
  746.     {
  747.  
  748.         case CSW_G3SG1:
  749.  
  750.         {      
  751.             if(g_has_scsr[id])
  752.  
  753.             {
  754.  
  755.                 set_pev(id, pev_viewmodel2, scsr_V_MODEL)
  756.  
  757.                 set_pev(id, pev_weaponmodel2, scsr_P_MODEL)
  758.  
  759.                 if(oldweap[id] != CSW_G3SG1)
  760.  
  761.                 {
  762.  
  763.                     UTIL_PlayWeaponAnimation(id, scsr_DRAW)
  764.  
  765.                     set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
  766.  
  767.  
  768.  
  769.                     message_begin(MSG_ONE, gmsgWeaponList, _, id)
  770.  
  771.                     write_string(scsr_name)
  772.  
  773.                     write_byte(2)
  774.  
  775.                     write_byte(90)
  776.  
  777.                     write_byte(-1)
  778.  
  779.                     write_byte(-1)
  780.  
  781.                     write_byte(0)
  782.  
  783.                     write_byte(3)
  784.  
  785.                     write_byte(CSW_G3SG1)
  786.  
  787.                     message_end()
  788.  
  789.                 }
  790.  
  791.             }
  792.  
  793.         }
  794.  
  795.     }
  796.  
  797.     oldweap[id] = weaponid
  798.  
  799. }
  800.  
  801.  
  802.  
  803. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  804.  
  805. {
  806.  
  807.     if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_G3SG1 || !g_has_scsr[Player]))
  808.  
  809.         return FMRES_IGNORED
  810.  
  811.    
  812.  
  813.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  814.  
  815.     return FMRES_HANDLED
  816.  
  817. }
  818.  
  819.  
  820.  
  821. public fw_scsr_PrimaryAttack(Weapon)
  822.  
  823. {
  824.  
  825.     new Player = get_pdata_cbase(Weapon, 41, 4)
  826.  
  827.    
  828.  
  829.     if (!g_has_scsr[Player])
  830.  
  831.         return
  832.  
  833.    
  834.  
  835.     g_IsInPrimaryAttack = 1
  836.  
  837.     pev(Player,pev_punchangle,cl_pushangle[Player])
  838.  
  839.    
  840.  
  841.     g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
  842.  
  843. }
  844.  
  845.  
  846.  
  847. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  848.  
  849. {
  850.  
  851.     if ((eventid != g_orig_event_scsr) || !g_IsInPrimaryAttack)
  852.  
  853.         return FMRES_IGNORED
  854.  
  855.     if (!(1 <= invoker <= g_MaxPlayers))
  856.  
  857.     return FMRES_IGNORED
  858.  
  859.  
  860.  
  861.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  862.  
  863.     return FMRES_SUPERCEDE
  864.  
  865. }
  866.  
  867.  
  868.  
  869. public fw_scsr_PrimaryAttack_Post(Weapon)
  870.  
  871. {
  872.  
  873.     g_IsInPrimaryAttack = 0
  874.  
  875.     new iPlayer = get_pdata_cbase(Weapon, 41, 4)
  876.  
  877.    
  878.  
  879.     new szClip, szAmmo
  880.  
  881.     get_user_weapon(iPlayer, szClip, szAmmo)
  882.  
  883.    
  884.  
  885.     if(!is_user_alive(iPlayer))
  886.  
  887.         return
  888.  
  889.  
  890.  
  891.     if(g_has_scsr[iPlayer])
  892.  
  893.     {
  894.  
  895.         if (!g_clip_ammo[iPlayer])
  896.  
  897.             return
  898.  
  899.  
  900.  
  901.         new Float:push[3]
  902.  
  903.         pev(iPlayer,pev_punchangle,push)
  904.  
  905.         xs_vec_sub(push,cl_pushangle[iPlayer],push)
  906.  
  907.        
  908.  
  909.         xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil_scsr),push)
  910.  
  911.         xs_vec_add(push,cl_pushangle[iPlayer],push)
  912.  
  913.         set_pev(iPlayer,pev_punchangle,push)
  914.  
  915.        
  916.  
  917.         emit_sound(iPlayer, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  918.  
  919.         UTIL_PlayWeaponAnimation(iPlayer, random_num(scsr_SHOOT1, scsr_SHOOT2))
  920.  
  921.  
  922.  
  923.         static Float:plrViewAngles[3], Float:VecEnd[3], Float:VecDir[3], Float:PlrOrigin[3]
  924.  
  925.         pev(iPlayer, pev_v_angle, plrViewAngles)
  926.  
  927.  
  928.  
  929.         static Float:VecSrc[3], Float:VecDst[3]
  930.  
  931.    
  932.  
  933.         //VecSrc = pev->origin + pev->view_ofs
  934.  
  935.         pev(iPlayer, pev_origin, PlrOrigin)
  936.  
  937.         pev(iPlayer, pev_view_ofs, VecSrc)
  938.  
  939.         xs_vec_add(VecSrc, PlrOrigin, VecSrc)
  940.  
  941.  
  942.  
  943.         //VecDst = VecDir * 8192.0
  944.  
  945.         angle_vector(plrViewAngles, ANGLEVECTOR_FORWARD, VecDir)
  946.  
  947.         xs_vec_mul_scalar(VecDir, 8192.0, VecDst)
  948.  
  949.         xs_vec_add(VecDst, VecSrc, VecDst)
  950.  
  951.    
  952.  
  953.         new hTrace = create_tr2()
  954.  
  955.         engfunc(EngFunc_TraceLine, VecSrc, VecDst, 0, iPlayer, hTrace)
  956.  
  957.         get_tr2(hTrace, TR_vecEndPos, VecEnd)
  958.  
  959.  
  960.  
  961.         explode(iPlayer);
  962.  
  963.         scsr_spr_ball(iPlayer, VecSrc, VecEnd);
  964.  
  965.     }
  966.  
  967. }
  968.  
  969.  
  970.  
  971. public explode(id)
  972.  
  973. {
  974.  
  975.     if(is_user_alive(id))
  976.  
  977.     {      
  978.  
  979.         new Float:originF[3]
  980.  
  981.         fm_get_aim_origin(id, originF)
  982.  
  983.         message_begin(MSG_ALL, SVC_TEMPENTITY)
  984.  
  985.         write_byte(TE_SPARKS)
  986.  
  987.         engfunc(EngFunc_WriteCoord, originF[0])
  988.  
  989.         engfunc(EngFunc_WriteCoord, originF[1])
  990.  
  991.         engfunc(EngFunc_WriteCoord, originF[2]+30.0)
  992.  
  993.         message_end()
  994.  
  995.        
  996.  
  997.         message_begin(MSG_ALL, SVC_TEMPENTITY)
  998.  
  999.         write_byte(TE_SPARKS)
  1000.  
  1001.         engfunc(EngFunc_WriteCoord, originF[0]+30.0)
  1002.  
  1003.         engfunc(EngFunc_WriteCoord, originF[1])
  1004.  
  1005.         engfunc(EngFunc_WriteCoord, originF[2]+30.0)
  1006.  
  1007.         message_end()
  1008.  
  1009.        
  1010.  
  1011.         message_begin(MSG_ALL, SVC_TEMPENTITY)
  1012.  
  1013.         write_byte(TE_SPARKS)
  1014.  
  1015.         engfunc(EngFunc_WriteCoord, originF[0])
  1016.  
  1017.         engfunc(EngFunc_WriteCoord, originF[1]+30.0)
  1018.  
  1019.         engfunc(EngFunc_WriteCoord, originF[2]+30.0)
  1020.  
  1021.         message_end()
  1022.  
  1023.        
  1024.  
  1025.         message_begin(MSG_ALL, SVC_TEMPENTITY)
  1026.  
  1027.         write_byte(TE_SPARKS)
  1028.  
  1029.         engfunc(EngFunc_WriteCoord, originF[0])
  1030.  
  1031.         engfunc(EngFunc_WriteCoord, originF[1]+40.0)
  1032.  
  1033.         engfunc(EngFunc_WriteCoord, originF[2]+40.0)
  1034.  
  1035.         message_end()
  1036.  
  1037.        
  1038.  
  1039.         message_begin(MSG_ALL, SVC_TEMPENTITY)
  1040.  
  1041.         write_byte(TE_SPARKS)
  1042.  
  1043.         engfunc(EngFunc_WriteCoord, originF[0])
  1044.  
  1045.         engfunc(EngFunc_WriteCoord, originF[1]+40.0)
  1046.  
  1047.         engfunc(EngFunc_WriteCoord, originF[2]+30.0)
  1048.  
  1049.         message_end()
  1050.  
  1051.        
  1052.  
  1053.         message_begin(MSG_ALL, SVC_TEMPENTITY)
  1054.  
  1055.         write_byte(TE_SPARKS)
  1056.  
  1057.         engfunc(EngFunc_WriteCoord, originF[0])
  1058.  
  1059.         engfunc(EngFunc_WriteCoord, originF[1]+30.0)
  1060.  
  1061.         engfunc(EngFunc_WriteCoord, originF[2]+40.0)
  1062.  
  1063.         message_end()
  1064.  
  1065.        
  1066.  
  1067.         // Draw explosion
  1068.  
  1069.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  1070.  
  1071.         write_byte(TE_SPRITE) // Temporary entity ID
  1072.  
  1073.         engfunc(EngFunc_WriteCoord, originF[0]) // engfunc because float
  1074.  
  1075.         engfunc(EngFunc_WriteCoord, originF[1])
  1076.  
  1077.         engfunc(EngFunc_WriteCoord, originF[2]+40.0)
  1078.  
  1079.         write_short(g_SprID) // Sprite index
  1080.  
  1081.         write_byte(8) // Scale
  1082.  
  1083.         write_byte(255) // Framerate
  1084.  
  1085.         message_end()
  1086.  
  1087.  
  1088.  
  1089.         new a = FM_NULLENT
  1090.  
  1091.         while((a = find_ent_in_sphere(a, originF, 60.0)) != 0)
  1092.  
  1093.         {
  1094.  
  1095.             if (id == a)
  1096.  
  1097.                 continue
  1098.  
  1099.                
  1100.  
  1101.             if(pev(a, pev_takedamage) != DAMAGE_NO)
  1102.  
  1103.             {
  1104.  
  1105.                 ExecuteHamB(Ham_TakeDamage, a, id, id, 50.0, DMG_BULLET)
  1106.  
  1107.             }
  1108.  
  1109.         }
  1110.  
  1111.         return PLUGIN_HANDLED
  1112.  
  1113.     }
  1114.  
  1115.     return PLUGIN_HANDLED
  1116.  
  1117. }
  1118.  
  1119.  
  1120.  
  1121. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, ent)
  1122.  
  1123. {
  1124.  
  1125.     if (victim != attacker && is_user_connected(attacker))
  1126.  
  1127.     {
  1128.  
  1129.         if(get_user_weapon(attacker) == CSW_G3SG1)
  1130.  
  1131.         {
  1132.  
  1133.             if(g_has_scsr[attacker])
  1134.  
  1135.                 SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_scsr))
  1136.  
  1137.         }
  1138.  
  1139.     }
  1140.  
  1141. }
  1142.  
  1143.  
  1144.  
  1145. public message_DeathMsg(msg_id, msg_dest, id)
  1146.  
  1147. {
  1148.  
  1149.     static szTruncatedWeapon[33], iAttacker, iVictim
  1150.  
  1151.    
  1152.  
  1153.     get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  1154.  
  1155.    
  1156.  
  1157.     iAttacker = get_msg_arg_int(1)
  1158.  
  1159.     iVictim = get_msg_arg_int(2)
  1160.  
  1161.    
  1162.  
  1163.     if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  1164.  
  1165.         return PLUGIN_CONTINUE
  1166.  
  1167.    
  1168.  
  1169.     if(equal(szTruncatedWeapon, "sg550") && get_user_weapon(iAttacker) == CSW_G3SG1)
  1170.  
  1171.     {
  1172.  
  1173.         if(g_has_scsr[iAttacker])
  1174.  
  1175.             set_msg_arg_string(4, "sg550")
  1176.  
  1177.     }
  1178.  
  1179.     return PLUGIN_CONTINUE
  1180.  
  1181. }
  1182.  
  1183.  
  1184.  
  1185. stock fm_cs_get_current_weapon_ent(id)
  1186.  
  1187. {
  1188.  
  1189.     return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
  1190.  
  1191. }
  1192.  
  1193.  
  1194.  
  1195. stock fm_cs_get_weapon_ent_owner(ent)
  1196.  
  1197. {
  1198.  
  1199.     return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
  1200.  
  1201. }
  1202.  
  1203.  
  1204.  
  1205. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
  1206.  
  1207. {
  1208.  
  1209.     set_pev(Player, pev_weaponanim, Sequence)
  1210.  
  1211.    
  1212.  
  1213.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  1214.  
  1215.     write_byte(Sequence)
  1216.  
  1217.     write_byte(pev(Player, pev_body))
  1218.  
  1219.     message_end()
  1220.  
  1221. }
  1222.  
  1223.  
  1224.  
  1225. public scsr_ItemPostFrame(weapon_entity)
  1226.  
  1227. {
  1228.  
  1229.      new id = pev(weapon_entity, pev_owner)
  1230.  
  1231.      if (!is_user_connected(id))
  1232.  
  1233.           return HAM_IGNORED
  1234.  
  1235.  
  1236.  
  1237.      if (!g_has_scsr[id])
  1238.  
  1239.           return HAM_IGNORED
  1240.  
  1241.  
  1242.  
  1243.      static iClipExtra
  1244.  
  1245.      
  1246.  
  1247.      iClipExtra = get_pcvar_num(cvar_clip_scsr)
  1248.  
  1249.      new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)
  1250.  
  1251.  
  1252.  
  1253.      new iBpAmmo = cs_get_user_bpammo(id, CSW_G3SG1)
  1254.  
  1255.      new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  1256.  
  1257.  
  1258.  
  1259.      new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF)
  1260.  
  1261.  
  1262.  
  1263.      if(!(get_user_button(id) & IN_ATTACK))
  1264.  
  1265.         g_lastexpl[id] = get_gametime()
  1266.  
  1267.  
  1268.  
  1269.      if( fInReload && flNextAttack <= 0.0 )
  1270.  
  1271.      {
  1272.  
  1273.          new j = min(iClipExtra - iClip, iBpAmmo)
  1274.  
  1275.    
  1276.  
  1277.          set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
  1278.  
  1279.          cs_set_user_bpammo(id, CSW_G3SG1, iBpAmmo-j)
  1280.  
  1281.        
  1282.  
  1283.          set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
  1284.  
  1285.          fInReload = 0
  1286.  
  1287.      }
  1288.  
  1289.      return HAM_IGNORED
  1290.  
  1291. }
  1292.  
  1293.  
  1294.  
  1295. public scsr_Reload(weapon_entity)
  1296.  
  1297. {
  1298.  
  1299.      new id = pev(weapon_entity, pev_owner)
  1300.  
  1301.      if (!is_user_connected(id))
  1302.  
  1303.           return HAM_IGNORED
  1304.  
  1305.  
  1306.  
  1307.      if (!g_has_scsr[id])
  1308.  
  1309.           return HAM_IGNORED
  1310.  
  1311.  
  1312.  
  1313.      static iClipExtra
  1314.  
  1315.  
  1316.  
  1317.      if(g_has_scsr[id])
  1318.  
  1319.           iClipExtra = get_pcvar_num(cvar_clip_scsr)
  1320.  
  1321.  
  1322.  
  1323.      g_scsr_TmpClip[id] = -1
  1324.  
  1325.  
  1326.  
  1327.      new iBpAmmo = cs_get_user_bpammo(id, CSW_G3SG1)
  1328.  
  1329.      new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  1330.  
  1331.  
  1332.  
  1333.      if (iBpAmmo <= 0)
  1334.  
  1335.           return HAM_SUPERCEDE
  1336.  
  1337.  
  1338.  
  1339.      if (iClip >= iClipExtra)
  1340.  
  1341.           return HAM_SUPERCEDE
  1342.  
  1343.  
  1344.  
  1345.      g_scsr_TmpClip[id] = iClip
  1346.  
  1347.  
  1348.  
  1349.      return HAM_IGNORED
  1350.  
  1351. }
  1352.  
  1353.  
  1354.  
  1355. public scsr_Reload_Post(weapon_entity)
  1356.  
  1357. {
  1358.  
  1359.     new id = pev(weapon_entity, pev_owner)
  1360.  
  1361.     if (!is_user_connected(id))
  1362.  
  1363.         return HAM_IGNORED
  1364.  
  1365.  
  1366.  
  1367.     if (!g_has_scsr[id])
  1368.  
  1369.         return HAM_IGNORED
  1370.  
  1371.  
  1372.  
  1373.     if (g_scsr_TmpClip[id] == -1)
  1374.  
  1375.         return HAM_IGNORED
  1376.  
  1377.  
  1378.  
  1379.     set_pdata_int(weapon_entity, m_iClip, g_scsr_TmpClip[id], WEAP_LINUX_XTRA_OFF)
  1380.  
  1381.  
  1382.  
  1383.     set_pdata_float(weapon_entity, m_flTimeWeaponIdle, scsr_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)
  1384.  
  1385.  
  1386.  
  1387.     set_pdata_float(id, m_flNextAttack, scsr_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)
  1388.  
  1389.  
  1390.  
  1391.     set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)
  1392.  
  1393.  
  1394.  
  1395.     UTIL_PlayWeaponAnimation(id, scsr_RELOAD)
  1396.  
  1397.  
  1398.  
  1399.     return HAM_IGNORED
  1400.  
  1401. }
  1402.  
  1403.  
  1404.  
  1405. stock scsr_spr_ball(id, Float:fVec1[3], Float:fVec2[3])
  1406.  
  1407. {
  1408.  
  1409.     static iVec1[3]
  1410.  
  1411.     FVecIVec(fVec1, iVec1)
  1412.  
  1413.  
  1414.  
  1415.     static Float:origin[3], Float:vSrc[3], Float:angles[3], Float:v_forward[3], Float:v_right[3], Float:v_up[3], Float:gun_position[3], Float:player_origin[3], Float:player_view_offset[3]
  1416.  
  1417.     pev(id, pev_v_angle, angles)
  1418.  
  1419.     engfunc(EngFunc_MakeVectors, angles)
  1420.  
  1421.     global_get(glb_v_forward, v_forward)
  1422.  
  1423.     global_get(glb_v_right, v_right)
  1424.  
  1425.     global_get(glb_v_up, v_up)
  1426.  
  1427.  
  1428.  
  1429.     //m_pPlayer->GetGunPosition( ) = pev->origin + pev->view_ofs
  1430.  
  1431.     pev(id, pev_origin, player_origin)
  1432.  
  1433.     pev(id, pev_view_ofs, player_view_offset)
  1434.  
  1435.     xs_vec_add(player_origin, player_view_offset, gun_position)
  1436.  
  1437.  
  1438.  
  1439.     xs_vec_mul_scalar(v_forward, 24.0, v_forward)
  1440.  
  1441.     xs_vec_mul_scalar(v_right, 3.0, v_right)
  1442.  
  1443.  
  1444.  
  1445.     if ((pev(id, pev_flags) & FL_DUCKING) == FL_DUCKING)
  1446.  
  1447.         xs_vec_mul_scalar(v_up, 6.0, v_up)
  1448.  
  1449.     else
  1450.  
  1451.         xs_vec_mul_scalar(v_up, -2.0, v_up)
  1452.  
  1453.  
  1454.  
  1455.     xs_vec_add(gun_position, v_forward, origin)
  1456.  
  1457.     xs_vec_add(origin, v_right, origin)
  1458.  
  1459.     xs_vec_add(origin, v_up, origin)
  1460.  
  1461.  
  1462.  
  1463.     vSrc[0] = origin[0]
  1464.  
  1465.     vSrc[1] = origin[1]
  1466.  
  1467.     vSrc[2] = origin[2]
  1468.  
  1469.  
  1470.  
  1471.     new Float:dist = get_distance_f(vSrc, fVec2)
  1472.  
  1473.     new CountDrops = floatround(dist / 50.0)
  1474.  
  1475.    
  1476.  
  1477.     if (CountDrops > 20)
  1478.  
  1479.         CountDrops = 20
  1480.  
  1481.    
  1482.  
  1483.     if (CountDrops < 2)
  1484.  
  1485.         CountDrops = 2
  1486.  
  1487.  
  1488.  
  1489.     message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
  1490.  
  1491.     write_byte(TE_SPRITETRAIL)
  1492.  
  1493.     engfunc(EngFunc_WriteCoord, vSrc[0])
  1494.  
  1495.     engfunc(EngFunc_WriteCoord, vSrc[1])
  1496.  
  1497.     engfunc(EngFunc_WriteCoord, vSrc[2])
  1498.  
  1499.     engfunc(EngFunc_WriteCoord, fVec2[0])
  1500.  
  1501.     engfunc(EngFunc_WriteCoord, fVec2[1])
  1502.  
  1503.     engfunc(EngFunc_WriteCoord, fVec2[2])
  1504.  
  1505.     write_short(scsr_ball)
  1506.  
  1507.     write_byte(CountDrops)
  1508.  
  1509.     write_byte(0)
  1510.  
  1511.     write_byte(1)
  1512.  
  1513.     write_byte(60)
  1514.  
  1515.     write_byte(10)
  1516.  
  1517.     message_end()
  1518.  
  1519. }
  1520.  
  1521.  
  1522.  
  1523. stock drop_weapons(id, dropwhat)
  1524.  
  1525. {
  1526.  
  1527.      static weapons[32], num, i, weaponid
  1528.  
  1529.      num = 0
  1530.  
  1531.      get_user_weapons(id, weapons, num)
  1532.  
  1533.      
  1534.  
  1535.      for (i = 0; i < num; i++)
  1536.  
  1537.      {
  1538.  
  1539.           weaponid = weapons[i]
  1540.  
  1541.          
  1542.  
  1543.           if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
  1544.  
  1545.           {
  1546.  
  1547.                static wname[32]
  1548.  
  1549.                get_weaponname(weaponid, wname, sizeof wname - 1)
  1550.  
  1551.                engclient_cmd(id, "drop", wname)
  1552.  
  1553.           }
  1554.  
  1555.      }
  1556.  
  1557. }
Screenshots:




20180903134903_1.jpg
20180903134858_1.jpg
20180903134855_1.jpg

Download:




StarChaserSR.zip
Nice Mark :)
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest