HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. //based on a plugin I had made for superhero mod(Squall) which in turn was based on Avalanche's i_aim_good plugin
  2.  
  3. #include <amxmodx>
  4. #include <fakemeta>
  5. #include <xs>
  6. #include <zombieplague>
  7.  
  8. /*================================================================================
  9.  [Plugin Customization]
  10. =================================================================================*/
  11.  
  12. new const knifemodel[] = "models/v_extra_glock18.mdl";
  13. new const gunsound[] = "weapons/glock18-2.wav";
  14. new const gItemName[] = "Fertozo Glock-18 Pisztoly";
  15. const gItemCost = 100
  16.  
  17. /*================================================================================
  18.  [End Customization]
  19.  ================================================================================*/
  20.  
  21. // GLOBAL VARIABLES
  22. new oldmodel[33][64];
  23. new gBullets[33];
  24. new gItemid;
  25.  
  26. //pcvars
  27. new pcvar_bullets;
  28. /*============================================================================*/
  29. public plugin_init()
  30. {
  31. register_plugin("[ZP] Infection Glock", "0.1", "Random1");
  32.  
  33. // cvars
  34. pcvar_bullets = register_cvar("zp_infgun_bullets", "7");
  35.  
  36. // Register our item to zombie plague
  37. gItemid = zp_register_extra_item(gItemName, gItemCost, ZP_TEAM_ZOMBIE);
  38.  
  39. // Knife Model
  40. register_event( "CurWeapon", "weaponChange", "be", "1=1", "2=29" );
  41.  
  42. //knife hack part
  43. register_forward(FM_TraceLine,"fw_traceline");
  44. register_forward(FM_EmitSound, "fw_emitsound")
  45. }
  46.  
  47. public zp_extra_item_selected(player, itemid)
  48. if (itemid == gItemid) {
  49. gBullets[player] += get_pcvar_num(pcvar_bullets);
  50. weaponChange(player);
  51. }
  52.  
  53. //----------------------------------------------------------------------------------------------
  54. public plugin_precache() //we still precache the files in case the user decides to use a custom model and/or sound
  55. {
  56. engfunc( EngFunc_PrecacheSound, gunsound );
  57. engfunc( EngFunc_PrecacheModel, knifemodel );
  58. }
  59. //----------------------------------------------------------------------------------------------
  60. public weaponChange(id)
  61. if ( is_user_alive(id) && zp_get_user_zombie(id) && gBullets[id] > 0 )
  62. {
  63. pev(id, pev_viewmodel2, oldmodel[id], charsmax(oldmodel[]));
  64. set_pev(id, pev_viewmodel2, knifemodel);
  65. }
  66.  
  67. //----------------------------------------------------------------------------------------------
  68. public fw_traceline(Float:v1[3],Float:v2[3],noMonsters,id)
  69. {
  70. if( !is_user_alive(id) || !zp_get_user_zombie(id) || gBullets[id] <= 0 )
  71. return;
  72.  
  73. static Float:flMyAim[3], ent, body;
  74. static weapid;
  75. weapid = get_user_weapon(id);
  76. if(weapid != CSW_KNIFE)
  77. return;
  78.  
  79. // get crosshair aim
  80. _get_aim_origin(id, flMyAim);
  81.  
  82. // set crosshair aim
  83. set_tr(TR_vecEndPos,flMyAim);
  84.  
  85. // get ent looking at
  86. get_user_aiming(id,ent,body);
  87.  
  88. // if looking at something
  89. if(pev_valid(ent)) {
  90. set_tr(TR_flFraction,0.1); // 1.0 == no hit, < 1.0 == hit
  91. set_tr(TR_pHit,ent); // entity hit
  92. set_tr(TR_iHitgroup,body); // bodypart hit
  93. }
  94. }
  95. //----------------------------------------------------------------------------------------------
  96. public fw_emitsound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
  97. {
  98. if ( !is_user_alive(id) || !zp_get_user_zombie(id) || gBullets[id] <= 0 )
  99. return FMRES_IGNORED;
  100.  
  101. if ( !equali(sample,"weapons/knife_deploy1.wav", 25) && equali(sample,"weapons/knife_", 14) ) //9 sounds dealing with knife, 1 of which not useful
  102. {
  103. gBullets[id]--;
  104. if ( 0 < gBullets[id] < 5 )
  105. client_print( id, print_center, "Meg van [%d] loszered !!", gBullets[id], gBullets[id] == 1 ? "" : "s" );
  106.  
  107. engfunc(EngFunc_EmitSound, id, channel, gunsound, volume, attn, flags, pitch);
  108. if ( !gBullets[id] ) //force our knife model to revert to normal since we just ran out of bullets
  109. set_pev(id, pev_viewmodel2, oldmodel[id]);
  110.  
  111. return FMRES_SUPERCEDE;
  112. }
  113. return FMRES_IGNORED;
  114. }
  115. //---------------------------------------------------------------------------------------
  116. _get_aim_origin(index, Float:origin[3])
  117. {
  118. static Float:start[3], Float:view_ofs[3];
  119. pev(index, pev_origin, start);
  120. pev(index, pev_view_ofs, view_ofs);
  121. xs_vec_add(start, view_ofs, start);
  122.  
  123. static Float:dest[3];
  124. pev(index, pev_v_angle, dest);
  125. engfunc(EngFunc_MakeVectors, dest);
  126. global_get(glb_v_forward, dest);
  127. xs_vec_mul_scalar(dest, 9999.0, dest);
  128. xs_vec_add(start, dest, dest);
  129.  
  130. engfunc(EngFunc_TraceLine, start, dest, 0, index, 0);
  131. get_tr2(0, TR_vecEndPos, origin);
  132.  
  133. return 1;
  134. }