Raised This Month: $ Target: $400
 0% 

[TF2] Projectile Collision


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: Fish Tank
Old 03-15-2017 , 17:57   [TF2] Projectile Collision
Reply With Quote #1

This concept is similar to arrow colliding another arrow; it'd destroy each other. But I'm trying to do it with "tf_projectile_flare" and "tf_projectile_rocket."

But would I use SDKHooks work for this? Or should I use something like this: https://forums.alliedmods.net/showthread.php?t=197815

Last edited by RumbleFrog; 03-15-2017 at 20:46.
RumbleFrog is offline
TF2CutContentWiki
( ͡ ͜ʖ ͡)
Join Date: Dec 2011
Old 03-15-2017 , 19:11   Re: [TF2] Projectile Collision
Reply With Quote #2

I would say try looking at the datamap of the entity. For example, CTFBall_Ornament - tf_projectile_ball_ornament. Check that out, search for collision, see what you find and experiment with it

Also I've not messed around with entity collision myself yet, so I don't really know, but I think the datamaps are the way to go.
__________________

Last edited by TF2CutContentWiki; 03-15-2017 at 19:14.
TF2CutContentWiki is offline
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: Fish Tank
Old 03-15-2017 , 20:46   Re: [TF2] Projectile Collision
Reply With Quote #3

Quote:
Originally Posted by abrandnewday View Post
I would say try looking at the datamap of the entity. For example, CTFBall_Ornament - tf_projectile_ball_ornament. Check that out, search for collision, see what you find and experiment with it

Also I've not messed around with entity collision myself yet, so I don't really know, but I think the datamaps are the way to go.
I'll look into it.
RumbleFrog is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 03-15-2017 , 21:47   Re: [TF2] Projectile Collision
Reply With Quote #4

I think SDKHooks should work.

Code:
public void OnEntityCreated(int entity, const char[] classname)
{
	if (StrContains(classname, "tf_projectile_") != -1)
	{
		SDKHook(entity, SDKHook_Touch, Hook_Touch);
		//Forgot which touch hook to use, one of them gave me troubles
		//SDKHook(client, SDKHook_StartTouch, Hook_Touch);
	}
}

public void Hook_Touch(int entity, int other)
{
	char other_classname[32];
	GetEntityClassname(other, other_classname, sizeof(other_classname));
	
	if (StrContains(other_classname, "tf_projectile_") != -1)
	{
		//do something
	}
}
__________________

Last edited by Chaosxk; 03-17-2017 at 01:52. Reason: strcontains should check for != -1
Chaosxk is offline
TF2CutContentWiki
( ͡ ͜ʖ ͡)
Join Date: Dec 2011
Old 03-16-2017 , 18:43   Re: [TF2] Projectile Collision
Reply With Quote #5

Quote:
Originally Posted by Chaosxk View Post
I think SDKHooks should work.

Code:
public void OnEntityCreated(int entity, const char[] classname)
{
    if (StrContains(classname, "tf_projectile_"))
    {
        SDKHook(entity, SDKHook_Touch, Hook_Touch);
        //Forgot which touch hook to use, one of them gave me troubles
        //SDKHook(client, SDKHook_StartTouch, Hook_Touch);
    }
}

public void Hook_Touch(int entity, int other)
{
    char other_classname[32];
    GetEntityClassname(other, other_classname, sizeof(other_classname));
    
    if (StrContains(other_classname, "tf_projectile_"))
    {
        //do something
    }
}
Oh, so then I do know the answer somewhat! I had a brain fart when I made that first post and completely forgot to mention to use SDK Hooks to make the modification despite me having just released a plugin that modifies projectiles. I am a doofus sometimes.

But yeah, use the SDK code up there (because I use SDKHooks in my Enhanced Rockets plugin which changes the projectile model) and where it says "do something", that's where you would send the new collision data to the projectile.
__________________

Last edited by TF2CutContentWiki; 03-16-2017 at 18:47.
TF2CutContentWiki is offline
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: Fish Tank
Old 03-17-2017 , 16:23   Re: [TF2] Projectile Collision
Reply With Quote #6

Quote:
Originally Posted by Chaosxk View Post
I think SDKHooks should work.

Code:
public void OnEntityCreated(int entity, const char[] classname)
{
	if (StrContains(classname, "tf_projectile_") != -1)
	{
		SDKHook(entity, SDKHook_Touch, Hook_Touch);
		//Forgot which touch hook to use, one of them gave me troubles
		//SDKHook(client, SDKHook_StartTouch, Hook_Touch);
	}
}

public void Hook_Touch(int entity, int other)
{
	char other_classname[32];
	GetEntityClassname(other, other_classname, sizeof(other_classname));
	
	if (StrContains(other_classname, "tf_projectile_") != -1)
	{
		//do something
	}
}
Interesting, I thought I needed to constantly do tracerays on the projectile. I'll try this and report back

Last edited by RumbleFrog; 03-17-2017 at 16:24.
RumbleFrog is offline
TF2CutContentWiki
( ͡ ͜ʖ ͡)
Join Date: Dec 2011
Old 03-17-2017 , 16:44   Re: [TF2] Projectile Collision
Reply With Quote #7

Quote:
Originally Posted by RumbleFrog View Post
Interesting, I thought I needed to constantly do tracerays on the projectile. I'll try this and report back
Oh lord no. That would be awful.
__________________
TF2CutContentWiki is offline
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: Fish Tank
Old 03-17-2017 , 17:14   Re: [TF2] Projectile Collision
Reply With Quote #8

Quote:
Originally Posted by Chaosxk View Post
I think SDKHooks should work.

Code:
public void OnEntityCreated(int entity, const char[] classname)
{
	if (StrContains(classname, "tf_projectile_") != -1)
	{
		SDKHook(entity, SDKHook_Touch, Hook_Touch);
		//Forgot which touch hook to use, one of them gave me troubles
		//SDKHook(client, SDKHook_StartTouch, Hook_Touch);
	}
}

public void Hook_Touch(int entity, int other)
{
	char other_classname[32];
	GetEntityClassname(other, other_classname, sizeof(other_classname));
	
	if (StrContains(other_classname, "tf_projectile_") != -1)
	{
		//do something
	}
}
It doesn't seem to be accounting projectiles for touch, unless the aim has to be exact. Any other theories? Maybe I need to change the hitbox of the flare projectile, but wouldn't that require a modded model?

Last edited by RumbleFrog; 03-17-2017 at 17:16.
RumbleFrog is offline
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: Fish Tank
Old 03-17-2017 , 19:11   Re: [TF2] Projectile Collision
Reply With Quote #9

I take that back, I changed the model to something bigger like a cow, but now I have another issue.

I currently have this:

Code:
public void OnEntityCreated(int entity, const char[] classname)
{
	if (StrEqual(classname, Rocket_Projectile))
	{
		SDKHook(entity, SDKHook_StartTouch, Hook_Touch);
	}
	
	if (StrEqual(classname, Flare_Weapon_Projectile))
	{
		SDKHook(entity, SDKHook_SpawnPost, Hook_SpawnPost);
	}
}

public void Hook_SpawnPost(int entity)
{
	SetEntityModel(entity, "models/props_2fort/cow001_reference.mdl");
}
My theory of the problem is that it have to finish the call of SpawnPost before it can act on any other hooks such as the StartTouch. But since, it takes like a solid second for SpawnPost to be done, I have to really far away to fire the projectile for it to finish in time for StartTouch.

Correct me if I'm wrong, but this is just my theory.

Any other way to set models without SDKHooks?

Last edited by RumbleFrog; 03-17-2017 at 19:20.
RumbleFrog is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 03-17-2017 , 20:23   Re: [TF2] Projectile Collision
Reply With Quote #10

Try RequestFrame,

Code:
public void OnEntityCreated(int entity, const char[] classname)
{
	if (StrEqual(classname, Rocket_Projectile))
	{
		SDKHook(entity, SDKHook_StartTouch, Hook_Touch);
	}
	
	if (StrEqual(classname, Flare_Weapon_Projectile))
	{
		RequestFrame(Frame_SetModel, entity);
	}
}

public void Frame_SetModel(int entity)
{
	SetEntityModel(entity, "models/props_2fort/cow001_reference.mdl");
}
__________________
Chaosxk is offline
Reply


Thread Tools
Display Modes

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 14:30.


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