Raised This Month: $ Target: $400
 0% 

Ham_TakeDamage with FF, Ham_TraceAttack not working correctly


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 07-17-2014 , 07:02   Ham_TakeDamage with FF, Ham_TraceAttack not working correctly
Reply With Quote #1

I'll start by copy pasting the function I have problems with. This is mostly work by Black Rose, I take very little credit.

Code:
public DelayAttack(TaskData[]) {     new Player = TaskData[0]     new Knife = TaskData[1]     new AttackType = TaskData[2]     new Entity = TaskData[3]         new KnifeData[KnifeDataStructure]     ArrayGetArray(g_Knives, Knife, KnifeData)         new Float:ViewOfs[3], Float:Start[3], Float:End[3], Float:Aim[3]         pev(Player, pev_origin, Start)     pev(Player, pev_view_ofs, ViewOfs)     xs_vec_add(Start, ViewOfs, Start)         velocity_by_aim(Player, 1, Aim)     xs_vec_mul_scalar(Aim, KnifeData[_Range][AttackType], End)     xs_vec_add(Start, End, End)         new Trace, Float:Fraction, bool:Hull                 engfunc(EngFunc_TraceLine, Start, End, DONT_IGNORE_MONSTERS, Player, Trace)     get_tr2(Trace, TR_flFraction, Fraction)             if(Fraction >= 1.0)     {         engfunc(EngFunc_TraceHull, Start, End, DONT_IGNORE_MONSTERS, HULL_HEAD, Player, Trace)         get_tr2(Trace, TR_flFraction, Fraction)         Hull = true     }         if(Fraction >= 1.0)     {           emit_sound(Player, CHAN_WEAPON, KnifeData[_WhiffSound], VOL_NORM, ATTN_NORM, 0, 94)     }     else     {         new HitPlayer = get_tr2(Trace, TR_pHit)                 if(IsPlayer(HitPlayer))         {             new Hitgroup = get_tr2(Trace, TR_iHitgroup)                         new bool:Backstab = isBackstab(Player, HitPlayer)                         new Float:Damage = AttackType == Primary ?                 g_HitgroupPrimary[Hitgroup] * (Float:KnifeData[_Damage][Primary]) :                 g_HitgroupSecondary[Hitgroup] * (Float:KnifeData[_Damage][Secondary]) * (Backstab ? 3.0 : 1.0)                         new DmgBits = KnifeData[_DmgBits][AttackType] ? KnifeData[_DmgBits][AttackType] : DMG_BULLET|DMG_NEVERGIB                         emit_sound(HitPlayer, CHAN_VOICE, g_HitFleshSound[random(sizeof g_HitFleshSound)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)                         new TraceAttack = create_tr2()             if (Hull)                 engfunc(EngFunc_TraceHull, Start, End, DONT_IGNORE_MONSTERS, HULL_HEAD, Player, TraceAttack)             else                 engfunc(EngFunc_TraceLine, Start, End, DONT_IGNORE_MONSTERS, Player, TraceAttack)                             ExecuteHam(Ham_TraceAttack, HitPlayer, Player, 1.0, Aim, TraceAttack, DmgBits)             free_tr2(TraceAttack)                                     if(AttackType == Primary)             {                 emit_sound(Player, CHAN_WEAPON, KnifeData[_SlashSound], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)                 ExecuteHam(Ham_TakeDamage, HitPlayer, Entity, Player, Damage, DmgBits)             }             else             {                 emit_sound(Player, CHAN_WEAPON, KnifeData[_StabSound], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)                 ExecuteHam(Ham_TakeDamage, HitPlayer, Entity, Player, Damage, DmgBits)             }         }     }         free_tr2(Trace) }

The most desirable solution (probably) to my problem is to completely get rid of TakeDamage. That way, I wouldn't need to calculate the hitzone by myself and the mp_friendlyfire cvar should be ignored too, but I'm not exactly sure how CBasePlayer::TraceAttack works (no idea if it calls CBasePlayer::TakeDamage or does the damage in a different fashion). The problem with this, though, is that Ham_TraceAttack alone decides to only deal either 0 or 1 damage to the player regardless of what the damage is (I changed it to 1.0 for testing purposes, but even with 100000.0, it still does 1 or 0 damage). It also looks somehow jerky - there's no animation played on the player that gets hit, etc., but worst of all, if the victim dies, there's no attacker shown in the deathmsg. I have no idea what am I doing wrong.

On the other hand, without Ham_TraceAttack, no hitzones are taken into account (which I can deal with by changing m_LastHitGroup, so that's fine) but no blood is shown, so I'd have to re-create it myself.

With my way, both Ham_TraceAttack and Ham_TraceDamage is used. This creates the blood just fine and also shows the correct hitzone (headshot) in the DeathMsg, which is weird to say the least, since it's done in TraceAttack. It more or less works fine this way, however I'm unable to get rid of the friendly fire restriction. I need knives to deal damage even if mp_friendlyfire is off, as the knives have a special property (KN_CLL_IgnoreFriendlyFire) which would be extremely useful for example on my Banhammer.

If you have any suggestion (either why TraceAttack acts stupid or how to disable the teamfire check in TakeDamage), please tell me.
Backstabnoob is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:02.


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