Raised This Month: $51 Target: $400
 12% 

Grenade / Player collision help?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xm3kilo
Member
Join Date: Jan 2018
Old 01-14-2018 , 11:03   Grenade / Player collision help?
Reply With Quote #1

Hey guys,

I'm trying to make it so on CSGO a player can throw any sort of grenade and have it get stuck inside the player and thus freezing them in place, I was hinted by another user to change the players collision groups and not the nades.

I've tried changing the collision group on the player to every group as well as the grenades

Code:
 SetEntData(entity, g_CollisionOffset2, 3, 4, true);
SetEntProp(entity, Prop_Send, "m_CollisionGroup", 3);
Am I on the right track? Help is appreciated, thanks!

Not sure on the collision group or if I should put both in one, I need noblock as well so its quite annoying
its probably something super simple, but im new to sp so im still learning

Last edited by DarkDeviL; 02-21-2018 at 01:39. Reason: Restored post
xm3kilo is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 01-14-2018 , 18:24   Re: Grenade / Player collision help?
Reply With Quote #2

using this method you would be required to disable the collision from the grenade to the player in the game code, however still make your own collision detection to see if the nade is intersecting the player. Then change the games collision code back so they then get stuck inside of each other. If you just set collision group where they don't collide then the nade will fly through the player completely and not get stuck inside of them by default. This isn't a logical approach. Instead what you want to do is check when the grenade collides with something, then if the thing it collided with is an enemy player team from the thrower of the nade. Make that player entity freeze in place until the grenade detonates.

You can use SDKHooks for a Touch hook event on the grenade entity, once it gets called you get the owner this way:

PHP Code:
new Owner GetEntPropEnt(entityProp_Send"m_hThrower");
int Thrower EntRefToEntIndex(Owner); 
Get that players team and compare it with the collided entitys team. If that logic is correct then you want to freeze the player by setting the entitys move type to MOVETYPE_NONE. Then on OnEntityDestroyed you want to check if it's the projectile nade that stopped the players movement and if so, reset the players move type back to the orginal.
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
xm3kilo
Member
Join Date: Jan 2018
Old 01-15-2018 , 00:23   Re: Grenade / Player collision help?
Reply With Quote #3

Yeah sorry should have been a bit more clear, I was doing something similar to that.
This was the code when I posted:

Code:
public OnEntityCreated(entity, const String:classname[])
{
if (StrEqual(classname, "smokegrenade_projectile"))
{
SetEntProp(entity, Prop_Send, "m_CollisionGroup", 2);

SDKHook(entity, SDKHook_StartTouch, OnStartTouch); // Hook touch event
}
}



public OnStartTouch(entity, client)
{


decl String:classname[32];
GetEdictClassname(client, classname, sizeof(classname));
SetEntPropEnt(entity, Prop_Send, "m_hEffectEntity", client);
SetEntProp(entity, Prop_Send, "m_usSolidFlags", 152);

SetEntProp(entity, Prop_Send, "m_CollisionGroup", 11 );

SetEntProp(client, Prop_Send, "m_CollisionGroup", 11 );
SetEntityMoveType(entity, MOVETYPE_NONE);

}
You can see the smoke has originally no collision, and it when it hits anything it freezes it, I've been practicing on bots so maybe this is why its not working?
I also want the collision to freeze them, you should hear the smoke bouncing back and forth inside them, maybe its something to do with movetype?
That code is also only registering touch when the smoke deploys
Cheers

From my other thread:
Plugin needs to work with no block, someone will walk inside another player, throw a nade at their feet, have the grenade vibrate and trap them there (probs because of collision) until the smoke disappears.

Last edited by DarkDeviL; 02-21-2018 at 01:39. Reason: Restored post
xm3kilo is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 01-15-2018 , 04:21   Re: Grenade / Player collision help?
Reply With Quote #4

Did you check to see if the OnStartTouch code is called when it collides with a player? It shouldn't be called if the players collision group is set so they don't collide with other players. If 1 object only collides with world and the second object collides with all i believe they shouldn't collide at all since the first object will prevent it. If it's still firing i'd be surprised but if it is and the bots aren't stopping it's possible the movetype_none isn't working as expected. You can alternatively set the netprop on the player m_flLaggedMovementValue to 0 to prevent player movement. Also set the velocity netprops to 0 so when you reset m_flLaggedMovementValue to 1 after the nade detonates they don't continue at the original velocity before you froze them. You can emulate the sound of the smoke grenade bouncing manually but i'm assuming you want it from how it originally happens when a grenades stuck inside a player in source engine and repeats the bounce sound. You don't have to replicate this 1:1 but can get the same effects.

So as far as it being compatible with no block. I'm confused if you want to replicate it so players can stand inside them and make the grenade stuck that way or you are wanting to prevent this from happening. To prevent it you're going to have to set the collision group like you have now so it wont collide with the player. Then have a game frame hook where you keep track of the distance from the origin or post throwing the greande use tracehulls to see if it will collide with the player and prevent it from being thrown in that case.
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
xm3kilo
Member
Join Date: Jan 2018
Old 01-15-2018 , 04:35   Re: Grenade / Player collision help?
Reply With Quote #5

Quote:
Originally Posted by 1337norway View Post
Did you check to see if the OnStartTouch code is called when it collides with a player? It shouldn't be called if the players collision group is set so they don't collide with other players. If 1 object only collides with world and the second object collides with all i believe they shouldn't collide at all since the first object will prevent it. If it's still firing i'd be surprised but if it is and the bots aren't stopping it's possible the movetype_none isn't working as expected. You can alternatively set the netprop on the player m_flLaggedMovementValue to 0 to prevent player movement. Also set the velocity netprops to 0 so when you reset m_flLaggedMovementValue to 1 after the nade detonates they don't continue at the original velocity before you froze them. You can emulate the sound of the smoke grenade bouncing manually but i'm assuming you want it from how it originally happens when a grenades stuck inside a player in source engine and repeats the bounce sound. You don't have to replicate this 1:1 but can get the same effects.

So as far as it being compatible with no block. I'm confused if you want to replicate it so players can stand inside them and make the grenade stuck that way or you are wanting to prevent this from happening. To prevent it you're going to have to set the collision group like you have now so it wont collide with the player. Then have a game frame hook where you keep track of the distance from the origin or post throwing the greande use tracehulls to see if it will collide with the player and prevent it from being thrown in that case.
I kind of have it working but not in the way I want. I'm trying to replicate another plugin, a player walks inside someone and purposely freezes them in the spot with the grenade. I was told it should be relatively simple and should be as easy as changing collision groups. The smoke makes the bouncing noise inside the player until it detonates and after the smoke is gone the player is free. That's what I'm trying to do

Last edited by DarkDeviL; 02-21-2018 at 01:40. Reason: Restored post
xm3kilo is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 01-15-2018 , 04:40   Re: Grenade / Player collision help?
Reply With Quote #6

That's the default behavior if you just change the players collision groups for no collide and don't touch the projectile grenade at all. I suppose on which collision group you change the player to be on though may effect if the grenade collides with the player. This is if you're inside the player and through the grenade, not if you just throw the grenade at them and are not inside of them with no block. You should be able to achieve no block for players with other values as well on collision group
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
xm3kilo
Member
Join Date: Jan 2018
Old 01-15-2018 , 04:42   Re: Grenade / Player collision help?
Reply With Quote #7

Quote:
Originally Posted by 1337norway View Post
That's the default behavior if you just change the players collision groups for no collide and don't touch the projectile grenade at all. I suppose on which collision group you change the player to be on though may effect if the grenade collides with the player. This is if you're inside the player and through the grenade, not if you just throw the grenade at them and are not inside of them with no block. You should be able to achieve no block for players with other values as well on collision group
Thanks for all your help. I've tried changing the collision group on the player at spawn and the grenade just flicks itself out. Do you have any idea what groups I should be using?

Thanks heaps

EDIT: atm im testing collision group 3, when you walk inside and throw the grenade as I said it finds its way out, shame

Can I use something as simple as

Code:
public Action:SpawnEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new client_id = GetEventInt(event, "userid");
new client = GetClientOfUserId(client_id);

SetEntProp(client, Prop_Send, "m_CollisionGroup", 4 );
}

Last edited by DarkDeviL; 02-21-2018 at 01:41. Reason: Restored post
xm3kilo is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 01-15-2018 , 04:53   Re: Grenade / Player collision help?
Reply With Quote #8

Awh right I forgot this was for CSGO, I've not tested anything like this with CSGO however for CSS this is the default behavior at least. The only way I currently know of to make the effect match would be to ghetto recreate it with the information I gave in the prior posts. I'd have to do some tests tomorrow but if all the hit groups are having the safe affect, maybe there's a console variable for physics that will prevent it from sliding out like that. Maybe sv_turbophysics 0?
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
xm3kilo
Member
Join Date: Jan 2018
Old 01-15-2018 , 04:59   Re: Grenade / Player collision help?
Reply With Quote #9

Hmm. I'm up to group 14 atm and some of them the grenade falls through the player onto the floor. Hmm I don't think so. Now that I think of it the server that runs this plugin has a plugin called 'Physics Fix' so maybe that's related... Doing more research now

Last edited by DarkDeviL; 02-21-2018 at 01:41. Reason: Restored post
xm3kilo is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 01-15-2018 , 05:08   Re: Grenade / Player collision help?
Reply With Quote #10

You can try my old plugin that worked well for CS:GO the last time that I tested it.
Attached Files
File Type: sp Get Plugin or Get Source (noblock_grenades.sp - 763 views - 904 Bytes)
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
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 17:10.


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