-
关注Ta
-
- 注册时间 2010-08-05
- 最后登录 2020-06-28
-
- 发帖1195
- 在线729小时
- 精华0
- DB14706
- 威望4585
- 保证金0
- 桃子0
- 鲜花0
- 鸡蛋0
-
访问TA的空间加好友用道具
|
- /*================================================================================
- * Please don't change plugin register information.
- #include <amxmodx>
- #include <fakemeta>
- #include <hamsandwich>
- #include <xs>
- // plugin's main information
- #define PLUGIN_NAME "[CS] Weapon Knockback Set"
- #define PLUGIN_VERSION "1.0"
- #define PLUGIN_AUTHOR "Jim"
- // Weapons calssname
- new const weapon_classname[][] = { "", "weapon_p228", "", "weapon_scout", "", "weapon_xm1014", "", "weapon_mac10",
- "weapon_aug", "", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550", "weapon_galil", "weapon_famas",
- "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249", "weapon_m3", "weapon_m4a1",
- "weapon_tmp", "weapon_g3sg1", "", "weapon_deagle", "weapon_sg552", "weapon_ak47", "weapon_knife", "weapon_p90" }
- // Knockback set (無擊退效果=-1.0 , 擊退力減半=0.5 , 擊退力雙倍=2.0)
- new const weapon_knockback[][] = {
- "-1.0", //-----
- "-1.0", //p228
- "-1.0", //-----
- "-1.0", //scout
- "-1.0", //-----
- "-1.0", //xm1014
- "-1.0", //-----
- "-1.0", //mac10
- "-1.0", //aug
- "-1.0", //-----
- "-1.0", //elites
- "-1.0", //fiveseven
- "-1.0", //ump45
- "-1.0", //sg550
- "-1.0", //galil
- "-1.0", //famas
- "-1.0", //usp
- "-1.0", //glock
- "-1.0", //awp
- "-1.0", //mp5navy
- "-1.0", //m249
- "-1.0", //m3
- "-1.0", //m4a1
- "-1.0", //tmp
- "-1.0", //g3sg1
- "-1.0", //-----
- "-1.0", //deagle
- "-1.0", //sg552
- "-1.0", //ak47
- "-1.0", //knife
- "-1.0" //p90
- }
- new g_weap_knockback[sizeof weapon_classname]
- new cvar_check_bitsum
- public plugin_init()
- {
- register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
-
- cvar_check_bitsum = 0
-
- new cvar_string[32]
- for (new i = 0; i < sizeof weapon_classname; i++)
- {
- if (strlen(weapon_classname[i]) == 0)
- continue;
-
- formatex(cvar_string, charsmax(cvar_string), "weap_%s_knockback", weapon_classname[i][7])
- g_weap_knockback[i] = register_cvar(cvar_string, weapon_knockback[i])
- cvar_check_bitsum |= (1<<i)
- }
-
- RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
- }
- public fw_TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damage_type)
- {
- // Non-player damage or self damage
- if (victim == attacker || !is_user_connected(attacker))
- return HAM_IGNORED;
-
- // If not bullet damage
- if (!(damage_type & DMG_BULLET))
- return HAM_IGNORED;
-
- static weap_id
- weap_id = get_user_weapon(attacker)
-
- if (!((1<<weap_id) & cvar_check_bitsum))
- return HAM_IGNORED;
-
- // Get knockback multiplier
- static Float:multiplier
- multiplier = get_pcvar_float(g_weap_knockback[weap_id])
-
- // Use weapon power on knockback calculation
- if (multiplier < 0.0)
- return HAM_IGNORED;
-
- static Float:hit_direction[3]
- hit_direction = direction
-
- // Get victim's velocity
- static Float:velocity[3]
- pev(victim, pev_velocity, velocity)
-
- // Get knockback direction value
- xs_vec_mul_scalar(hit_direction, multiplier, hit_direction)
- xs_vec_mul_scalar(hit_direction, damage, hit_direction)
- xs_vec_add(velocity, hit_direction, hit_direction)
-
- // If use knife attack, set knockback direction change vertical angle up 15.0
- if (weap_id == CSW_KNIFE)
- set_vector_change_angle2(hit_direction, 0.0, 15.0, hit_direction)
-
- // Set the knockback'd victim's velocity
- set_pev(victim, pev_velocity, hit_direction)
-
- SetHamParamVector(4, Float:{0.0, 0.0, 0.0});
-
- return HAM_IGNORED;
- }
- stock set_vector_change_angle2(const Float:velocity[3], Float:angle, Float:vertical_angle, Float:new_velocity[3])
- {
- new Float:v_angles[3]
- vector_to_angle(velocity, v_angles)
-
- v_angles[1] += angle
- while (v_angles[1] < 0.0)
- v_angles[1] += 360.0
-
- v_angles[2] += vertical_angle
- while (v_angles[2] < 0.0)
- v_angles[2] += 360.0
-
- new Float:v_length
- v_length = vector_length(velocity)
-
- new Float:temp
- temp = v_length * floatcos(v_angles[2], degrees)
-
- new_velocity[0] = temp * floatcos(v_angles[1], degrees)
- new_velocity[1] = temp * floatsin(v_angles[1], degrees)
- new_velocity[2] = v_length * floatsin(v_angles[2], degrees)
- }
|