AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [ H3LP ] Knife ? (https://forums.alliedmods.net/showthread.php?t=302454)

CrazY. 10-29-2017 22:42

[ H3LP ] Knife ?
 
Hello, does anyone have the .cpp of knife? I need to understand how the sounds are emitted, as the damage is inflicted... Anyway, all the functionality of the knife.

HamletEagle 10-30-2017 04:43

Re: [ H3LP ] Knife ?
 
Look on regamedll: wpn_knife.cpp

DjSoftero 10-31-2017 14:13

Re: [ H3LP ] Knife ?
 
https://github.com/s1lentq/ReGameDLL...lls/wpn_shared

CrazY. 10-31-2017 15:32

Re: [ H3LP ] Knife ?
 
Good, what I tried to do was:

Code:
public task_primary_attack(data[]) {     new attacker = data[0], inflictor = data[1]     new Float:angles[3], Float:start[3], Float:end[3], Float:dir[3], Float:fakeend[3]     new Float:flFraction, pHit     new tr = create_tr2()     get_entvar(attacker, var_angles, angles)     angle_vector(angles, ANGLEVECTOR_FORWARD, dir)     xs_vec_mul_scalar(dir, 80.0, fakeend)     get_entvar(attacker, var_origin, start)     get_entvar(attacker, var_view_ofs, end)     xs_vec_add(end, start, start)     xs_vec_add(start, fakeend, end)     engfunc(EngFunc_TraceLine, start, end, DONT_IGNORE_MONSTERS, attacker, tr)     get_tr2(tr, TR_flFraction, flFraction)     if (flFraction >= 1.0)     {         emit_sound(attacker, CHAN_WEAPON, sound_combistick_slash[random_num(0, sizeof sound_combistick_slash - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_LOW)     }     else     {         pHit = get_tr2(tr, TR_pHit)         if (pHit == -1)         {             pHit = 0             set_tr2(tr, TR_pHit, pHit)         }         rg_multidmg_clear()         ExecuteHamB(Ham_TraceAttack, pHit, attacker, 35.0, dir, tr, DMG_NEVERGIB | DMG_BULLET)         rg_multidmg_apply(inflictor, attacker)         if (pHit && is_user_alive(pHit))             emit_sound(attacker, CHAN_WEAPON, sound_combistick_hit[random_num(0, sizeof sound_combistick_hit - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)         else             emit_sound(attacker, CHAN_WEAPON, sound_combistick_hit_wall, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)     }     free_tr2(tr) }

However, my code is with the following problems:

- when I attack the player, no matter what part of the body, it is always inflicted damage to the head rather than the affected area.

- when I attack a box (in the Cs_assault, a blue box, for example) or the floor, the sound "hit_wall" is not emitted, instead, the "slash" is being emitted.

- in some entities, the damage is only inflicted if I really pull it over, and if I'm crouching at the same time.

Were these the problems I could identify, any idea?

DeMNiX 11-01-2017 01:16

Re: [ H3LP ] Knife ?
 
Quote:

when I attack the player, no matter what part of the body, it is always inflicted damage to the head rather than the affected area.
check your hitboxes of the model

CrazY. 11-01-2017 08:27

Re: [ H3LP ] Knife ?
 
The problem is not in the model, because I tested with the other weapons, including the knife itself, and presented no problem.

CrazY. 11-02-2017 10:03

Re: [ H3LP ] Knife ?
 
Thank you @PRoSToTeM@.

https://forums.alliedmods.net/showpo...83&postcount=9


All times are GMT -4. The time now is 03:40.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.