Raised This Month: $ Target: $400
 0% 

Checking if damage dealt was penetration damage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FaceCSGO
Junior Member
Join Date: Mar 2015
Old 03-13-2015 , 05:22   Checking if damage dealt was penetration damage
Reply With Quote #1

After doing some research I thought about trying to use traceray, but I can't exactly figure out how to get the result I'm looking for.

I'm brand new to sourcepawn (like... within the last 3 hours) and I can't seem to find exactly what I'm looking for.

Inside of a "Public OnW3TakeDmgBulletPre(victim,attacker,Float:da mage)" (this is obviously a war3 mod server) I need to check if the damage dealt is penetration damage.

I figured I could accomplish this using a traceray to check if it ends at a non-player object before hitting a player, or if the first thing it encounters is a non-player object.

I'm not familiar enough with traceray to know exactly how to do it.

This is what I currently have:
Code:
Public OnW3TakeDmgBulletPre(victim,attacker,Float:damage)
{
	GetClientEyePosition(client, vecClientEyePos); // Get the position of the player's eyes
	GetClientEyeAngles(client, vecClientEyeAng); // Get the angle the player is looking

	//Check for colliding entities
	TR_TraceRayFilter(vecClientEyePos, vecClientEyeAng, MASK_SOLID, RayType_EndPoint, TraceRayDontHitSelf, client);

	if(TR_DidHit(INVALID_HANDLE))
	{
		new TRIndex = TR_GetEntityIndex(INVALID_HANDLE);
		PrintToChatAll("Entity Found %i", TRIndex);
	}

}

public bool:TraceRayDontHitSelf(entity, mask, any:data)
{
 	if(entity == data) // Check if the TraceRay hit the itself.
	{
		return false // Don't let the entity be hit
 	}
 	return true // It didn't hit itself
}
One thought I had is can you use the TR_DidHit to check if it hits a hitbox?
Another thought I had is can I do two tracerays (e.g. one on hitbox and one on solids) and see if the solid ends before the hitbox (thus it must be a penetration hit).

Any help is greatly appreciated. Sorry if this is confusing in any way, I am quite tired right now.

Edit: I learned how to do handles and this is what I have now, no idea if it works or not.
It should trace a ray to a player hitbox, then trace a ray to a solid object. If the traceray doesn't hit the player hitbox, then hopefully it will work.

Code:
Public OnW3TakeDmgBulletPre(victim,attacker,Float:damage)
{
	if(RaceDisabled)
    {
        return;
    }
	if(race==thisRaceID)
	{
		GetClientEyePosition(client, vecClientEyePos); // Get the position of the player's eyes
		GetClientEyeAngles(client, vecClientEyeAng); // Get the angle the player is looking

		//Check for colliding entities
		TR_TraceRayFilter(vecClientEyePos, vecClientEyeAng, MASK_SOLID, RayType_Infinity, TraceRayDontHitSelf, client);
		new Handle:trace = TR_TraceRayFilter(vecClientEyePos, vecClientEyeAng, CONTENTS_HITBOX, RayType_Infinity, TraceRayDontHitSelf, client);

		if(!TR_DidHit(trace))
		{
			War3_DealDamage(victim,war3_dealdamagelevel(client,thisRaceID,Penetration),client,DMG_BURN,"stim pack",W3DMGORIGIN_SKILL);
			new TRIndex = TR_GetEntityIndex(INVALID_HANDLE);
			new TRIndex2 = TR_GetEntityIndex(trace);
			PrintToChatAll("Entity Found %i, hitbox found %i", TRIndex, TRIndex1);
		}

}

public bool:TraceRayDontHitSelf(entity, mask, any:data)
{
    if(RaceDisabled)
    {
        return;
    }
	if(race==thisRaceID)
	{
		if(entity == data) // Check if the TraceRay hit the itself.
		{
			return false // Don't let the entity be hit
		}
		return true // It didn't hit itself
}

Last edited by FaceCSGO; 03-13-2015 at 12:24.
FaceCSGO is offline
D.Moder
I uploaded 2 great gameplay plugins here
Join Date: Sep 2009
Location: Sin city
Old 03-14-2015 , 04:08   Re: Checking if damage dealt was penetration damage
Reply With Quote #2

I would first check if that filter is called twice.
Then if its twice, find out the difference between to object,
First should be world, second player.
Just an idea,
Get entity class to check

Edit: remove first TR_Trace, its results is being ignored, and try different masks.
__________________
Creator of COD-Life (Half COD, Half Life)
https://forums.alliedmods.net/showthread.php?t=261162
twitter: @D_Moder_61216

Last edited by D.Moder; 03-14-2015 at 04:11.
D.Moder is offline
FaceCSGO
Junior Member
Join Date: Mar 2015
Old 03-14-2015 , 14:41   Re: Checking if damage dealt was penetration damage
Reply With Quote #3

Quote:
Originally Posted by D.Moder View Post
I would first check if that filter is called twice.
Then if its twice, find out the difference between to object,
First should be world, second player.
Just an idea,
Get entity class to check

Edit: remove first TR_Trace, its results is being ignored, and try different masks.
I appreciate your help, we tested it out and I was having some significant issues with TR.

I ended up getting help from someone who works on the server and used WAR3 function we have (that I didn't know existed) to check if you have line of sight of the player when you deal damage.
FaceCSGO is offline
Reply



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 23:04.


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