MasamuneDate

Cod Class + Skull 3 no skill

May 27th, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 21.56 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <fakemeta_util>
  4. #include <hamsandwich>
  5. #include <cstrike>
  6. #include <codmod>
  7.  
  8. #define PLUGIN "zp_skull3"
  9. #define VERSION "1.0"
  10. #define AUTHOR "kntot"
  11.  
  12. #define MODEL_V "models/zth/v_skull3_single.mdl"
  13. #define MODEL_V2 "models/zth/v_skull3_dual.mdl"
  14. #define MODEL_P "models/zth/p_skull3.mdl"
  15. #define MODEL_P2 "models/zth/p_skull3dual.mdl"
  16. #define MODEL_W "models/zth/w_skull3.mdl"
  17.  
  18. #define ANIM_EXT1 "carbine"
  19. #define ANIM_EXT2 "dualpistols_1"
  20.  
  21. #define CSW_BASEDON CSW_P90
  22. #define weapon_basedon "weapon_p90"
  23.  
  24. #define DAMAGE_S 54 // 54 for Zombie
  25. #define DAMAGE_D 62 // 62 for Zombie
  26. #define CLIP_S 35
  27. #define CLIP_D 70
  28. #define BPAMMO 240
  29. #define SPEED_S 1.25
  30. #define SPEED_D 0.80
  31. #define RECOIL 0.75
  32. #define RELOAD_TIME 2.0
  33.  
  34. #define BODY_NUM 0
  35. #define TASK_SWITCHING 20141
  36.  
  37.  
  38. #define WEAPON_SECRETCODE 156851
  39. #define WEAPON_EVENT "events/p90.sc"
  40. #define OLD_W_MODEL "models/w_p90.mdl"
  41.  
  42. #define TIME_CHANGE 3.0
  43.  
  44. #define PSPEED_S 240.0
  45. #define PSPEED_D 180.0
  46.  
  47. #define ANIM_EXT1 "carbine"
  48. #define ANIM_EXT2 "dualpistols_1"
  49. new const Skull3_Sounds[5][] =
  50. {
  51.     "weapons/skull3_shoot.wav",
  52.     "weapons/skull3_shoot_2.wav",
  53.     "weapons/skull3_idle.wav",
  54.     "weapons/skull3_clipin.wav",
  55.     "weapons/skull3_boltpull.wav"
  56. }
  57. enum
  58. {
  59.     SKULL3_SINGLE = 0,
  60.     SKULL3_DUAL
  61. }
  62.  
  63. enum
  64. {
  65.     ANIM_IDLE = 0,
  66.     ANIM_RELOAD,
  67.     ANIM_DRAW,
  68.     ANIM_SHOOT1,
  69.     ANIM_SHOOT2,
  70.     ANIM_SHOOT3,
  71.     ANIM_SWITCH
  72. }
  73. new g_Weapon, Skull_State
  74. new g_Had_Weapon, g_Old_Weapon[33], Float:g_Recoil[33][3], g_Clip[33]
  75. new g_weapon_event, g_ShellId, g_SmokePuff_SprId
  76. new g_HamBot, g_Msg_CurWeapon
  77.  
  78. // MACROS
  79. #define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
  80. #define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
  81. #define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))
  82.  
  83. new const nazwa[]   = "Test Class";
  84. new const opis[]    = "Got Supress SMG with low recoil, also a laser sight";
  85. new const bronie    = (1<<CSW_P90) | (1<<CSW_M4A1) | (1<<CSW_USP) | (1<<CSW_XM1014) | (1<<CSW_GLOCK18);
  86. new const zdrowie   = 55;
  87. new const kondycja  = 60;
  88. new const inteligencja = 0;
  89. new const wytrzymalosc = 45;
  90.  
  91. new ma_klase[33];
  92. new bool:g_laser[33]
  93. new sprite
  94.  
  95. public plugin_init()
  96. {
  97.     // Skull 3 Plugin - ZP
  98.     register_plugin(PLUGIN, VERSION, AUTHOR)
  99.    
  100.     register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
  101.     register_message(get_user_msgid("DeathMsg"), "message_DeathMsg");
  102.    
  103.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)   
  104.     register_forward(FM_PlaybackEvent, "fw_PlaybackEvent") 
  105.     register_forward(FM_SetModel, "fw_SetModel")
  106.     register_forward(FM_CmdStart, "fm_cmdstart")
  107.    
  108.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_World")
  109.     RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack_Player")
  110.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_basedon, "fw_Weapon_PrimaryAttack")
  111.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_basedon, "fw_Weapon_PrimaryAttack_Post", 1)
  112.     RegisterHam(Ham_Item_AddToPlayer, weapon_basedon, "fw_Item_AddToPlayer_Post", 1)
  113.     RegisterHam(Ham_Weapon_Reload, weapon_basedon, "fw_Weapon_Reload")
  114.     RegisterHam(Ham_Weapon_Reload, weapon_basedon, "fw_Weapon_Reload_Post", 1)
  115.     RegisterHam(Ham_Item_PostFrame, weapon_basedon, "fw_Item_PostFrame")
  116.     RegisterHam(Ham_Spawn, "player", "Remove_Weapon", 1)
  117.    
  118.     g_Msg_CurWeapon = get_user_msgid("CurWeapon")
  119.    
  120.     // Laser Sight
  121.     register_forward(FM_PlayerPreThink, "FW_playerprethink")
  122.     register_event("DeathMsg", "Death", "a")
  123.    
  124.     // Cod Basic
  125.     cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc);
  126. }
  127.  
  128. public plugin_precache()
  129. {
  130.     engfunc(EngFunc_PrecacheModel, MODEL_V)
  131.     engfunc(EngFunc_PrecacheModel, MODEL_V2)
  132.     engfunc(EngFunc_PrecacheModel, MODEL_P)
  133.     engfunc(EngFunc_PrecacheModel, MODEL_P2)
  134.     engfunc(EngFunc_PrecacheModel, MODEL_W)
  135.     for(new i = 0; i <sizeof(Skull3_Sounds); i++)
  136.         precache_sound(Skull3_Sounds[i])
  137.    
  138.     g_SmokePuff_SprId = engfunc(EngFunc_PrecacheModel, "sprites/wall_puff1.spr")
  139.     g_ShellId = engfunc(EngFunc_PrecacheModel, "models/rshell.mdl")
  140.    
  141.     register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
  142.    
  143.     sprite = precache_model("sprites/white.spr")
  144. }
  145.  
  146. public cod_class_enabled(id)
  147. {
  148.     ma_klase[id] = true;
  149.     cod_give_weapon(id, CSW_P90);
  150.     Get_Weapon(id);
  151.     g_laser[id] = true;
  152. }
  153.  
  154. public cod_class_disabled(id)
  155. {
  156.     ma_klase[id] = false;
  157.     cod_take_weapon(id, CSW_P90);
  158.     Remove_Weapon(id);
  159.     g_laser[id] = false;
  160. }
  161.  
  162. public FW_playerprethink(id)
  163. {
  164.     if(!is_user_connected(id))
  165.         return;
  166.     if(!ma_klase[id])
  167.         return;
  168.     if(!g_laser[id])
  169.         return;
  170.     {
  171.         new e[3]
  172.         get_user_origin(id, e, 3)
  173.         message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
  174.         write_byte (TE_BEAMENTPOINT)
  175.         write_short(id | 0x1000)
  176.         write_coord (e[0])         
  177.         write_coord (e[1])         
  178.         write_coord (e[2])         
  179.  
  180.         write_short(sprite)        
  181.        
  182.         write_byte (1)                             
  183.         write_byte (10)                                    
  184.         write_byte (1)             
  185.         write_byte (5)                         
  186.         write_byte (0)             
  187.         write_byte (255)           
  188.         write_byte (0)             
  189.         write_byte (0)             
  190.         write_byte (150)                               
  191.         write_byte (25)                    
  192.         message_end()
  193.     }
  194. }
  195.  
  196. public Get_Weapon(id)
  197. {
  198.     if(!is_user_alive(id))
  199.         return
  200.        
  201.     Set_BitVar(g_Had_Weapon, id)
  202.     fm_give_item(id, weapon_basedon)
  203.    
  204.     Skull_State = SKULL3_SINGLE
  205.    
  206.     // Set Ammo
  207.     if(Skull_State == SKULL3_DUAL)
  208.     {
  209.         static Ent; Ent = fm_get_user_weapon_entity(id, CSW_BASEDON)
  210.         if(pev_valid(Ent)) cs_set_weapon_ammo(Ent, CLIP_D)
  211.         engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, g_Msg_CurWeapon, {0, 0, 0}, id)
  212.         write_byte(1)
  213.         write_byte(CSW_BASEDON)
  214.         write_byte(CLIP_D)
  215.         message_end()
  216.     }
  217.     else
  218.     {
  219.         static Ent; Ent = fm_get_user_weapon_entity(id, CSW_BASEDON)
  220.         if(pev_valid(Ent)) cs_set_weapon_ammo(Ent, CLIP_S)
  221.         engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, g_Msg_CurWeapon, {0, 0, 0}, id)
  222.         write_byte(1)
  223.         write_byte(CSW_BASEDON)
  224.         write_byte(CLIP_S)
  225.         message_end()
  226.     }
  227.     cs_set_user_bpammo(id, CSW_BASEDON, BPAMMO)
  228. }
  229.  
  230. public Remove_Weapon(id)
  231. {
  232.     UnSet_BitVar(g_Had_Weapon, id)
  233.     if(ma_klase[id])
  234.     {
  235.         Get_Weapon(id)
  236.     }
  237. }
  238.  
  239. public fw_PrecacheEvent_Post(type, const name[])
  240. {
  241.     if(equal(WEAPON_EVENT, name))
  242.         g_weapon_event = get_orig_retval()     
  243. }
  244.  
  245. public client_putinserver(id)
  246. {
  247.     if(!g_HamBot && is_user_bot(id))
  248.     {
  249.         g_HamBot = 1
  250.         set_task(0.1, "Do_RegisterHam", id)
  251.     }
  252. }
  253.  
  254. public Do_RegisterHam(id)
  255. {
  256.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack_Player")
  257. }
  258.  
  259. public zp_extra_item_selected(id, itemid)
  260. {
  261.     if(itemid == g_Weapon) Get_Weapon(id)
  262. }
  263.  
  264. public message_DeathMsg(msg_id, msg_dest, id)
  265. {
  266.     static szTruncatedWeapon[33], iAttacker, iVictim
  267.     get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  268.    
  269.     iAttacker = get_msg_arg_int(1)
  270.     iVictim = get_msg_arg_int(2)
  271.    
  272.     if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  273.         return PLUGIN_CONTINUE
  274.    
  275.     if(equal(szTruncatedWeapon, "p90") && get_user_weapon(iAttacker) == CSW_BASEDON)
  276.     {
  277.         if(Set_BitVar(g_Had_Weapon, id))
  278.             set_msg_arg_string(4, "Skull-3")
  279.     }
  280.     return PLUGIN_CONTINUE
  281. }
  282.  
  283. public plugin_natives()
  284. {
  285.     register_native("refill", "RefillMySkull3", 1)
  286. }
  287. public RefillMySkull3(id)
  288. {
  289.     if(!is_user_alive(id))
  290.         return
  291.     if(get_user_weapon(id) != CSW_BASEDON || !Get_BitVar(g_Had_Weapon, id))
  292.         return
  293.    
  294.     cs_set_user_bpammo(id, CSW_BASEDON, BPAMMO)
  295. }
  296. public fm_cmdstart(id)
  297. {
  298.     static Weapon; Weapon = fm_find_ent_by_owner(-1, weapon_basedon, id);
  299.     if(!pev_valid(Weapon))
  300.         return
  301.     if(!is_user_alive(id))
  302.         return
  303.     if(get_user_weapon(id) != CSW_BASEDON || !Get_BitVar(g_Had_Weapon, id))
  304.         return
  305.     if(get_pdata_float(id, 83, 5) > 0.0 || get_pdata_float(Weapon, 46, 4) > 0.0 || get_pdata_float(Weapon, 47, 4) > 0.0)
  306.         return
  307.    
  308.     if(pev(id, pev_button) & IN_ATTACK2)
  309.     {
  310.         if(cs_get_user_bpammo(id, CSW_BASEDON) <= 0)
  311.             return
  312.         if(Skull_State == SKULL3_SINGLE)
  313.         {
  314.             set_weapon_anim(id, ANIM_SWITCH)
  315.             Set_Player_NextAttack(id, TIME_CHANGE)
  316.             Set_Weapon_TimeIdle(id, CSW_BASEDON ,TIME_CHANGE)
  317.             set_task(TIME_CHANGE, "Complete_Change_To_Dual", id+TASK_SWITCHING)
  318.         }
  319.         else if(Skull_State == SKULL3_DUAL)
  320.         {
  321.             set_weapon_anim(id, ANIM_SWITCH)
  322.             Set_Player_NextAttack(id, TIME_CHANGE)
  323.             Set_Weapon_TimeIdle(id, CSW_BASEDON ,TIME_CHANGE)
  324.             set_task(TIME_CHANGE, "Complete_Change_To_Single", id+TASK_SWITCHING)
  325.         }
  326.     }
  327. }
  328.  
  329. public Complete_Change_To_Single(id)
  330. {
  331.     id -= TASK_SWITCHING
  332.     if(!is_user_alive(id))
  333.         return
  334.     if(get_user_weapon(id) != CSW_BASEDON || !Get_BitVar(g_Had_Weapon, id))
  335.         return
  336.    
  337.     set_weapon_anim(id, ANIM_IDLE)
  338.     Skull_State = SKULL3_SINGLE
  339.     set_pev(id, pev_weaponmodel2, MODEL_P)
  340.     set_pev(id, pev_viewmodel2, MODEL_V)
  341.     set_pev(id, pev_maxspeed, PSPEED_S)
  342.     set_pdata_string(id, (492) * 4, ANIM_EXT1, -1 , 20)
  343.     static Ent; Ent = fm_get_user_weapon_entity(id, CSW_BASEDON)
  344.     if(pev_valid(Ent)) cs_set_weapon_ammo(Ent, CLIP_S)
  345.     engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, g_Msg_CurWeapon, {0, 0, 0}, id)
  346.     write_byte(1)
  347.     write_byte(CSW_BASEDON)
  348.     write_byte(CLIP_S)
  349.     message_end()
  350. }
  351. public Complete_Change_To_Dual(id)
  352. {
  353.     id -= TASK_SWITCHING
  354.     if(!is_user_alive(id))
  355.         return
  356.     if(get_user_weapon(id) != CSW_BASEDON || !Get_BitVar(g_Had_Weapon, id))
  357.         return
  358.    
  359.     set_weapon_anim(id, ANIM_IDLE)
  360.     Skull_State = SKULL3_DUAL
  361.     set_pdata_string(id, (492) * 4, ANIM_EXT2, -1 , 20)
  362.     set_pev(id, pev_weaponmodel2, MODEL_P2)
  363.     set_pev(id, pev_viewmodel2, MODEL_V2)
  364.     set_pev(id, pev_maxspeed, PSPEED_D)
  365.     static Ent; Ent = fm_get_user_weapon_entity(id, CSW_BASEDON)
  366.     if(pev_valid(Ent)) cs_set_weapon_ammo(Ent, CLIP_D)
  367.     engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, g_Msg_CurWeapon, {0, 0, 0}, id)
  368.     write_byte(1)
  369.     write_byte(CSW_BASEDON)
  370.     write_byte(CLIP_D)
  371.     message_end()
  372. }
  373.  
  374. public Event_CurWeapon(id)
  375. {
  376.     if(!is_user_alive(id))
  377.         return
  378.    
  379.     static CSWID; CSWID = read_data(2)
  380.    
  381.     if((CSWID == CSW_BASEDON && g_Old_Weapon[id] != CSW_BASEDON) && Get_BitVar(g_Had_Weapon, id))
  382.     {
  383.         if(Skull_State == SKULL3_DUAL)
  384.         {
  385.             set_weapon_anim(id, ANIM_DRAW)
  386.             set_pev(id, pev_maxspeed, PSPEED_D)
  387.             set_pev(id, pev_viewmodel2, MODEL_V2)
  388.             set_pev(id, pev_weaponmodel2, MODEL_P2)
  389.             set_pdata_string(id, (492) * 4, ANIM_EXT2, -1 , 20)
  390.         }
  391.         else if(Skull_State == SKULL3_SINGLE)
  392.         {
  393.             set_pev(id, pev_viewmodel2, MODEL_V);
  394.             set_pev(id, pev_weaponmodel2, MODEL_P)
  395.             set_pev(id, pev_maxspeed, PSPEED_S)
  396.             set_pdata_string(id, (492) * 4, ANIM_EXT1, -1 , 20)
  397.             set_weapon_anim(id, ANIM_DRAW)
  398.         }
  399.         Draw_NewWeapon(id, CSWID)
  400.     } else if((CSWID == CSW_BASEDON && g_Old_Weapon[id] == CSW_BASEDON) && Get_BitVar(g_Had_Weapon, id)) {
  401.         static Ent; Ent = fm_get_user_weapon_entity(id, CSW_BASEDON)
  402.         if(!pev_valid(Ent))
  403.         {
  404.             g_Old_Weapon[id] = get_user_weapon(id)
  405.             return
  406.         }
  407.         set_pdata_float(Ent, 46, get_pdata_float(Ent, 46, 4) * SPEED_D, 4)
  408.     } else if(CSWID != CSW_BASEDON && g_Old_Weapon[id] == CSW_BASEDON) Draw_NewWeapon(id, CSWID)
  409.    
  410.     g_Old_Weapon[id] = get_user_weapon(id)
  411. }
  412.  
  413. public Draw_NewWeapon(id, CSW_ID)
  414. {
  415.     if(CSW_ID == CSW_BASEDON)
  416.     {
  417.         static ent
  418.         ent = fm_get_user_weapon_entity(id, CSW_BASEDON)
  419.        
  420.         if(pev_valid(ent) && Get_BitVar(g_Had_Weapon, id))
  421.         {
  422.             set_pev(ent, pev_effects, pev(ent, pev_effects) &~ EF_NODRAW)
  423.             if(Skull_State == SKULL3_DUAL) engfunc(EngFunc_SetModel, ent, MODEL_P2)
  424.             else engfunc(EngFunc_SetModel, ent, MODEL_P)
  425.             set_pev(ent, pev_body, BODY_NUM)
  426.         }
  427.     } else {
  428.         static ent
  429.         ent = fm_get_user_weapon_entity(id, CSW_BASEDON)
  430.        
  431.         if(pev_valid(ent)) set_pev(ent, pev_effects, pev(ent, pev_effects) | EF_NODRAW)            
  432.     }
  433.    
  434. }
  435.  
  436. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  437. {
  438.     if(!is_user_alive(id))
  439.         return FMRES_IGNORED   
  440.     if(get_user_weapon(id) == CSW_BASEDON && Get_BitVar(g_Had_Weapon, id))
  441.         set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  442.    
  443.     return FMRES_HANDLED
  444. }
  445.  
  446. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  447. {
  448.     if (!is_user_connected(invoker))
  449.         return FMRES_IGNORED   
  450.     if(get_user_weapon(invoker) != CSW_BASEDON || !Get_BitVar(g_Had_Weapon, invoker))
  451.         return FMRES_IGNORED
  452.     if(eventid != g_weapon_event)
  453.         return FMRES_IGNORED
  454.    
  455.     engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  456.    
  457.     if(Skull_State == SKULL3_DUAL) set_weapon_anim(invoker, random_num(ANIM_SHOOT1, ANIM_SHOOT3))
  458.     else set_weapon_anim(invoker, ANIM_SHOOT1)
  459.     emit_sound(invoker, CHAN_WEAPON, Skull3_Sounds[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
  460.    
  461.     Eject_Shell(invoker, g_ShellId, 0.0)
  462.        
  463.     return FMRES_SUPERCEDE
  464. }
  465.  
  466. public fw_SetModel(entity, model[])
  467. {
  468.     if(!pev_valid(entity))
  469.         return FMRES_IGNORED
  470.    
  471.     static Classname[32]
  472.     pev(entity, pev_classname, Classname, sizeof(Classname))
  473.    
  474.     if(!equal(Classname, "weaponbox"))
  475.         return FMRES_IGNORED
  476.    
  477.     static iOwner
  478.     iOwner = pev(entity, pev_owner)
  479.    
  480.     if(equal(model, OLD_W_MODEL))
  481.     {
  482.         static weapon; weapon = fm_find_ent_by_owner(-1, weapon_basedon, entity)
  483.        
  484.         if(!pev_valid(weapon))
  485.             return FMRES_IGNORED;
  486.        
  487.         if(Get_BitVar(g_Had_Weapon, iOwner))
  488.         {
  489.             Remove_Weapon(iOwner)
  490.            
  491.             set_pev(weapon, pev_impulse, WEAPON_SECRETCODE)
  492.             engfunc(EngFunc_SetModel, entity, MODEL_W)
  493.             set_pev(entity, pev_body, BODY_NUM)
  494.            
  495.             return FMRES_SUPERCEDE
  496.         }
  497.     }
  498.  
  499.     return FMRES_IGNORED;
  500. }
  501.  
  502. public fw_TraceAttack_World(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
  503. {
  504.     if(!is_user_connected(Attacker))
  505.         return HAM_IGNORED 
  506.     if(get_user_weapon(Attacker) != CSW_BASEDON || !Get_BitVar(g_Had_Weapon, Attacker))
  507.         return HAM_IGNORED
  508.        
  509.     static Float:flEnd[3], Float:vecPlane[3]
  510.    
  511.     get_tr2(Ptr, TR_vecEndPos, flEnd)
  512.     get_tr2(Ptr, TR_vecPlaneNormal, vecPlane)      
  513.        
  514.     Make_BulletHole(Attacker, flEnd, Damage)
  515.     Make_BulletSmoke(Attacker, Ptr)
  516.    
  517.     static Float:iHitgroup
  518.     new Float:MultifDamage
  519.     get_tr2(Ptr, TR_iHitgroup, iHitgroup)
  520.     switch(iHitgroup)
  521.     {
  522.         case HIT_HEAD: MultifDamage  = 1.75
  523.         case HIT_STOMACH: MultifDamage  = 1.25
  524.         case HIT_LEFTLEG: MultifDamage  = 1.75
  525.         case HIT_RIGHTLEG: MultifDamage  = 1.75
  526.         case HIT_GENERIC: MultifDamage =  1.75
  527.         default: MultifDamage  = 1.0
  528.     }
  529.     if(Skull_State == SKULL3_DUAL) SetHamParamFloat(3, float(DAMAGE_D) * MultifDamage)
  530.     else SetHamParamFloat(3, float(DAMAGE_S) * MultifDamage)
  531.    
  532.     return HAM_IGNORED
  533. }
  534.  
  535. public fw_TraceAttack_Player(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
  536. {
  537.     if(!is_user_connected(Attacker))
  538.         return HAM_IGNORED 
  539.     if(get_user_weapon(Attacker) != CSW_BASEDON || !Get_BitVar(g_Had_Weapon, Attacker))
  540.         return HAM_IGNORED
  541.    
  542.     static Float:iHitgroup
  543.     new Float:MultifDamage
  544.     get_tr2(Ptr, TR_iHitgroup, iHitgroup)
  545.     switch(iHitgroup)
  546.     {
  547.         case HIT_HEAD: MultifDamage  = 1.75
  548.         case HIT_STOMACH: MultifDamage  = 1.25
  549.         case HIT_LEFTLEG: MultifDamage  = 1.75
  550.         case HIT_RIGHTLEG: MultifDamage  = 1.75
  551.         case HIT_GENERIC: MultifDamage =  1.75
  552.         default: MultifDamage  = 1.0
  553.     }
  554.     if(Skull_State == SKULL3_DUAL) SetHamParamFloat(3, float(DAMAGE_D) * MultifDamage)
  555.     else SetHamParamFloat(3, float(DAMAGE_S) * MultifDamage)
  556.  
  557.     return HAM_IGNORED
  558. }
  559.  
  560. public fw_Weapon_PrimaryAttack(Ent)
  561. {
  562.     static id; id = pev(Ent, pev_owner)
  563.     pev(id, pev_punchangle, g_Recoil[id])
  564.    
  565.     return HAM_IGNORED
  566. }
  567.  
  568. public fw_Weapon_PrimaryAttack_Post(Ent)
  569. {
  570.     static id; id = pev(Ent, pev_owner)
  571.    
  572.     if(Get_BitVar(g_Had_Weapon, id))
  573.     {
  574.         static Float:Push[3]
  575.         pev(id, pev_punchangle, Push)
  576.         xs_vec_sub(Push, g_Recoil[id], Push)
  577.        
  578.         xs_vec_mul_scalar(Push, RECOIL, Push)
  579.         xs_vec_add(Push, g_Recoil[id], Push)
  580.         set_pev(id, pev_punchangle, Push)
  581.     }
  582. }
  583.  
  584. public fw_Item_AddToPlayer_Post(ent, id)
  585. {
  586.     if(!pev_valid(ent))
  587.         return HAM_IGNORED
  588.        
  589.     if(pev(ent, pev_impulse) == WEAPON_SECRETCODE)
  590.     {
  591.         Set_BitVar(g_Had_Weapon, id)
  592.         set_pev(ent, pev_impulse, 0)
  593.     }      
  594.  
  595.     return HAM_HANDLED 
  596. }
  597.  
  598. public fw_Item_PostFrame(ent)
  599. {
  600.     if(!pev_valid(ent))
  601.         return HAM_IGNORED
  602.    
  603.     static id
  604.     id = pev(ent, pev_owner)
  605.    
  606.     if(is_user_alive(id) && Get_BitVar(g_Had_Weapon, id))
  607.     {  
  608.         static Float:flNextAttack; flNextAttack = get_pdata_float(id, 83, 5)
  609.         static bpammo; bpammo = cs_get_user_bpammo(id, CSW_BASEDON)
  610.         static iClip; iClip = get_pdata_int(ent, 51, 4)
  611.         static fInReload; fInReload = get_pdata_int(ent, 54, 4)
  612.        
  613.         if(fInReload && flNextAttack <= 0.0)
  614.         {
  615.             new isclip
  616.             if(Skull_State == SKULL3_DUAL)isclip = CLIP_D
  617.             else isclip = CLIP_S
  618.             static temp1;temp1 = min(isclip - iClip, bpammo)
  619.             set_pdata_int(ent, 51, iClip + temp1, 4)
  620.             cs_set_user_bpammo(id, CSW_BASEDON, bpammo - temp1)    
  621.            
  622.             set_pdata_int(ent, 54, 0, 4)
  623.            
  624.             fInReload = 0
  625.         }      
  626.     }
  627.    
  628.     return HAM_IGNORED 
  629. }
  630.  
  631. public fw_Weapon_Reload(ent)
  632. {
  633.     static id; id = pev(ent, pev_owner)
  634.     if(!is_user_alive(id))
  635.         return HAM_IGNORED
  636.     if(!Get_BitVar(g_Had_Weapon, id))
  637.         return HAM_IGNORED
  638.    
  639.     g_Clip[id] = -1
  640.    
  641.     static bpammo; bpammo = cs_get_user_bpammo(id, CSW_BASEDON)
  642.     static iClip; iClip = get_pdata_int(ent, 51, 4)
  643.    
  644.     if(bpammo <= 0) return HAM_SUPERCEDE
  645.     new isclip
  646.     if(Skull_State == SKULL3_DUAL)isclip = CLIP_D
  647.     else isclip = CLIP_S
  648.    
  649.     if(iClip >= isclip) return HAM_SUPERCEDE       
  650.        
  651.     g_Clip[id] = iClip
  652.  
  653.     return HAM_HANDLED
  654. }
  655.  
  656. public fw_Weapon_Reload_Post(ent)
  657. {
  658.     static id; id = pev(ent, pev_owner)
  659.     if(!is_user_alive(id))
  660.         return HAM_IGNORED
  661.     if(!Get_BitVar(g_Had_Weapon, id))
  662.         return HAM_IGNORED
  663.  
  664.     if (g_Clip[id] == -1)
  665.         return HAM_IGNORED
  666.    
  667.     set_pdata_int(ent, 51, g_Clip[id], 4)
  668.     set_pdata_int(ent, 54, 1, 4)
  669.    
  670.     set_weapon_anim(id, ANIM_RELOAD)
  671.     set_pdata_float(id, 83, RELOAD_TIME, 5)
  672.  
  673.     return HAM_HANDLED
  674. }
  675.  
  676. stock Make_BulletHole(id, Float:Origin[3], Float:Damage)
  677. {
  678.     // Find target
  679.     static Decal; Decal = random_num(41, 45)
  680.     static LoopTime;
  681.    
  682.     if(Damage > 100.0) LoopTime = 2
  683.     else LoopTime = 1
  684.    
  685.     for(new i = 0; i < LoopTime; i++)
  686.     {
  687.         // Put decal on "world" (a wall)
  688.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  689.         write_byte(TE_WORLDDECAL)
  690.         engfunc(EngFunc_WriteCoord, Origin[0])
  691.         engfunc(EngFunc_WriteCoord, Origin[1])
  692.         engfunc(EngFunc_WriteCoord, Origin[2])
  693.         write_byte(Decal)
  694.         message_end()
  695.        
  696.         // Show sparcles
  697.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  698.         write_byte(TE_GUNSHOTDECAL)
  699.         engfunc(EngFunc_WriteCoord, Origin[0])
  700.         engfunc(EngFunc_WriteCoord, Origin[1])
  701.         engfunc(EngFunc_WriteCoord, Origin[2])
  702.         write_short(id)
  703.         write_byte(Decal)
  704.         message_end()
  705.     }
  706. }
  707.  
  708. public Make_BulletSmoke(id, TrResult)
  709. {
  710.     static Float:vecSrc[3], Float:vecEnd[3], TE_FLAG
  711.    
  712.     get_weapon_attachment(id, vecSrc)
  713.     global_get(glb_v_forward, vecEnd)
  714.    
  715.     xs_vec_mul_scalar(vecEnd, 8192.0, vecEnd)
  716.     xs_vec_add(vecSrc, vecEnd, vecEnd)
  717.  
  718.     get_tr2(TrResult, TR_vecEndPos, vecSrc)
  719.     get_tr2(TrResult, TR_vecPlaneNormal, vecEnd)
  720.    
  721.     xs_vec_mul_scalar(vecEnd, 2.5, vecEnd)
  722.     xs_vec_add(vecSrc, vecEnd, vecEnd)
  723.    
  724.     TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  725.     TE_FLAG |= TE_EXPLFLAG_NOSOUND
  726.     TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  727.    
  728.     engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0)
  729.     write_byte(TE_EXPLOSION)
  730.     engfunc(EngFunc_WriteCoord, vecEnd[0])
  731.     engfunc(EngFunc_WriteCoord, vecEnd[1])
  732.     engfunc(EngFunc_WriteCoord, vecEnd[2] - 10.0)
  733.     write_short(g_SmokePuff_SprId)
  734.     write_byte(2)
  735.     write_byte(50)
  736.     write_byte(TE_FLAG)
  737.     message_end()
  738. }
  739.  
  740.  
  741. stock hook_ent2(ent, Float:VicOrigin[3], Float:speed, Float:multi, type)
  742. {
  743.     static Float:fl_Velocity[3]
  744.     static Float:EntOrigin[3]
  745.     static Float:EntVelocity[3]
  746.    
  747.     pev(ent, pev_velocity, EntVelocity)
  748.     pev(ent, pev_origin, EntOrigin)
  749.     static Float:distance_f
  750.     distance_f = get_distance_f(EntOrigin, VicOrigin)
  751.    
  752.     static Float:fl_Time; fl_Time = distance_f / speed
  753.     static Float:fl_Time2; fl_Time2 = distance_f / (speed * multi)
  754.    
  755.     if(type == 1)
  756.     {
  757.         fl_Velocity[0] = ((VicOrigin[0] - EntOrigin[0]) / fl_Time2) * 1.5
  758.         fl_Velocity[1] = ((VicOrigin[1] - EntOrigin[1]) / fl_Time2) * 1.5
  759.         fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time       
  760.     } else if(type == 2) {
  761.         fl_Velocity[0] = ((EntOrigin[0] - VicOrigin[0]) / fl_Time2) * 1.5
  762.         fl_Velocity[1] = ((EntOrigin[1] - VicOrigin[1]) / fl_Time2) * 1.5
  763.         fl_Velocity[2] = (EntOrigin[2] - VicOrigin[2]) / fl_Time
  764.     }
  765.  
  766.     xs_vec_add(EntVelocity, fl_Velocity, fl_Velocity)
  767.     set_pev(ent, pev_velocity, fl_Velocity)
  768. }
  769.  
  770. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
  771. {
  772.     static Float:vfEnd[3], viEnd[3]
  773.     get_user_origin(id, viEnd, 3)  
  774.     IVecFVec(viEnd, vfEnd)
  775.    
  776.     static Float:fOrigin[3], Float:fAngle[3]
  777.    
  778.     pev(id, pev_origin, fOrigin)
  779.     pev(id, pev_view_ofs, fAngle)
  780.    
  781.     xs_vec_add(fOrigin, fAngle, fOrigin)
  782.    
  783.     static Float:fAttack[3]
  784.    
  785.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  786.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  787.    
  788.     static Float:fRate
  789.    
  790.     fRate = fDis / vector_length(fAttack)
  791.     xs_vec_mul_scalar(fAttack, fRate, fAttack)
  792.    
  793.     xs_vec_add(fOrigin, fAttack, output)
  794. }
  795.  
  796. stock Eject_Shell(id, Shell_ModelIndex, Float:Time) // By Dias
  797. {
  798.     static Ent; Ent = get_pdata_cbase(id, 373, 5)
  799.     if(!pev_valid(Ent))
  800.         return
  801.  
  802.         set_pdata_int(Ent, 57, Shell_ModelIndex, 4)
  803.         set_pdata_float(id, 111, get_gametime() + Time)
  804. }
  805.  
  806. stock set_weapon_anim(id, anim)
  807. {
  808.     if(!is_user_alive(id))
  809.         return
  810.    
  811.     set_pev(id, pev_weaponanim, anim)
  812.    
  813.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
  814.     write_byte(anim)
  815.     write_byte(pev(id, pev_body))
  816.     message_end()
  817. }
  818. stock Set_Weapon_TimeIdle(id, WeaponId ,Float:TimeIdle)
  819. {
  820.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
  821.     if(!pev_valid(entwpn))
  822.         return
  823.        
  824.     set_pdata_float(entwpn, 46, TimeIdle, 4)
  825.     set_pdata_float(entwpn, 47, TimeIdle, 4)
  826.     set_pdata_float(entwpn, 48, TimeIdle + 0.5, 4)
  827. }
  828.  
  829. stock Set_Player_NextAttack(id, Float:Time)
  830. {
  831.     set_pdata_float(id, 83, Time, 5)
  832. }
Advertisement
Add Comment
Please, Sign In to add comment