Raised This Month: $32 Target: $400
 8% 

[TF2] Projectile Collision


Post New Thread Reply   
 
Thread Tools Display Modes
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: Fish Tank
Old 03-18-2017 , 11:08   Re: [TF2] Projectile Collision
Reply With Quote #11

Quote:
Originally Posted by Chaosxk View Post
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");
}
This did set the model earlier, however, now it rarely triggers the touch hook. I assume it's something with the model again, could I potentially use "ShouldCollide" hook instead of StartTouch for this? Or somehow increase the hitbox size, as I believe it still uses the flare projectile hitbox instead of the new model.

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

Interestingly, I added another hook just to test both side by side, but it actually made the previous hook more responsive:

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

public bool Should_Collide(int entity, int collisiongroup, int contentsmask, bool originalResult)
{
	//Dummy, does nothing
}

public void Hook_Touch(int entity, int other)
{
        //Process the info and destroy 
}
What's reasoning behind this? Now the hook triggers 100% of the time simply because I added another Hook(Should_Collide).

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

Maybe because your using SDKHook_BlockedPost?
__________________
Chaosxk is offline
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: Fish Tank
Old 03-18-2017 , 17:18   Re: [TF2] Projectile Collision
Reply With Quote #14

Quote:
Originally Posted by Chaosxk View Post
Maybe because your using SDKHook_BlockedPost?
That's what I thought at first, so then I took the collision out, and it went to back to only 10%. Added it back in, 100% of the time.

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

Derp, I think ShouldCollide is the one doing the work here.

Any documentation on ShouldCollide forward, for collisiongroup and contentsmask and get what entity it's colliding with? I was going to use https://forums.alliedmods.net/showthread.php?t=197815 but it seems like it's broken and no longer maintained.
RumbleFrog is offline
starsfan
BANNED
Join Date: Apr 2017
Location: Texas
Old 04-02-2017 , 21:29   Re: [TF2] Projectile Collision
Reply With Quote #16

this is quick & dirty but appears to do what you want for the most part. i just wanted to see if i could do it. if you like it and want to help testing, i can work on it further and make a public release.

for the time being, tf_projectile_* will explode upon collision. you may also want to tinker with the collision radius. i also put in a different explosion than the stock explosions. just let me know.
Attached Files
File Type: sp Get Plugin or Get Source (projectile_collision.sp - 285 views - 4.2 KB)
File Type: smx projectile_collision.smx (6.8 KB, 148 views)
starsfan is offline
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: Fish Tank
Old 04-03-2017 , 06:21   Re: [TF2] Projectile Collision
Reply With Quote #17

Quote:
Originally Posted by starsfan View Post
this is quick & dirty but appears to do what you want for the most part. i just wanted to see if i could do it. if you like it and want to help testing, i can work on it further and make a public release.

for the time being, tf_projectile_* will explode upon collision. you may also want to tinker with the collision radius. i also put in a different explosion than the stock explosions. just let me know.
I got those down already, but how do you change collision radius?
RumbleFrog is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 04-03-2017 , 18:16   Re: [TF2] Projectile Collision
Reply With Quote #18

Looks like here
Code:
if ( (FloatAbs(FloatAbs(pos1[0]) - FloatAbs(pos2[0])) <  20) && 
             (FloatAbs(FloatAbs(pos1[1]) - FloatAbs(pos2[1])) <  20) && 
             (FloatAbs(FloatAbs(pos1[2]) - FloatAbs(pos2[2])) <  20) )
Although you can just do GetVectorDistance(pos1,pos2) < 20

Also running it OnGameFrame and storing the positions in a string is very inefficient. SDKHooks_Think on the projectile would be better to do.
__________________
Chaosxk is offline
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: Fish Tank
Old 04-03-2017 , 21:05   Re: [TF2] Projectile Collision
Reply With Quote #19

And would I do this to increase the model size?

Code:
SetEntPropFloat(iEntity, Prop_Send, "m_flModelScale", 2.0);
RumbleFrog is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 04-03-2017 , 22:47   Re: [TF2] Projectile Collision
Reply With Quote #20

Quote:
Originally Posted by RumbleFrog View Post
And would I do this to increase the model size?

Code:
SetEntPropFloat(iEntity, Prop_Send, "m_flModelScale", 2.0);
That would increase the model size but not the hitbox/collision if that's what your asking.

This might?
__________________
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 22:36.


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