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

[TF2] Prevent rockets explode by allies


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
oplkill
Member
Join Date: Aug 2015
Old 01-01-2019 , 07:39   [TF2] Prevent rockets explode by allies
Reply With Quote #1

In some maps, where many many allies in a small area - playing as a soldier is enraging, because when you shooting with rockets through allies, it's simply exploding and making damage to you.

How to make rockets do not exploding by allies, just fly through them?
oplkill is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 01-01-2019 , 08:25   Re: [TF2] Prevent rockets explode by allies
Reply With Quote #2

I belive you would have to hook SDKHook_ShouldCollide on the entity of the rocket projectile on the spawn event. Then on when the function is called you will have to check the other entity it's colliding with, if it's a player and it has the same teamindex as the m_hOwner netprop, then you would have to return false and plugin_changed possibly. This should prevent it from colliding with teammates, however there might be something easier like a CVAR that exists for this that i'm unaware of as i don't play tf2.
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
oplkill
Member
Join Date: Aug 2015
Old 01-01-2019 , 16:52   Re: [TF2] Prevent rockets explode by allies
Reply With Quote #3

That's interesting hook, but it doesn't gives enough information about with which exactly entity we colliding.
PHP Code:
//entity - hooked entity
//collisiongroup - with that type of entity we colliding(for ex COLLISION_GROUP_PLAYER)
//contentmask - collide mask of hooked entity? Or colliding entity?
//originalresult - collision result by default collision rules
public bool:ShouldCollideentitycollisiongroupcontentsmaskbool:originalResult)
{
    
// modify collision rules return false for not collide, true - for collide

We can't get colliding player team because don't know it Entity index.
And I tested this hook and it doesn't work in ~50%, it's just exploding with allies without calling collide func, but sometimes calling...
oplkill is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 01-01-2019 , 22:49   Re: [TF2] Prevent rockets explode by allies
Reply With Quote #4

Haven't tried it myself, but try DHooks and hook CBaseProjectile::CanCollideWithTeammates()
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 01-01-2019 at 22:49.
nosoop is offline
oplkill
Member
Join Date: Aug 2015
Old 01-02-2019 , 15:32   Re: [TF2] Prevent rockets explode by allies
Reply With Quote #5

Any tries about DHooks CBaseProjectile::CanCollideWithTeammates() even CBaseProjectile::GetCollideWithTeammatesDelay () are crashing the server without any logs...

I used that code:
PHP Code:

new Handle:hTeammateCollide;

public 
OnPluginStart()
{
    new 
Handle:temp LoadGameConfigFile("dhooks-test.games");
    
    if(
temp == INVALID_HANDLE)
    {
        
SetFailState("Why you no has gamedata?");
    }
    
    new 
offset;

    
offset GameConfGetOffset(temp"CanCollideWithTeammates");
    
hTeammateCollide DHookCreate(offsetHookType_EntityReturnType_BoolThisPointer_CBaseEntityCanCollideWithTeammates);
    
CloseHandle(temp);
}

public 
OnEntityCreated(entity, const String:classname[])
{
    if (
StrContains(classname"_projectile") > 0)
    {
        
PrintToChatAll("created entity = %d"entity);
        
DHookEntity(hTeammateCollidetrueentity); //tryed true/false
         
}
}

//bool CBaseProjectile::CanCollideWithTeammates()
public MRESReturn:CanCollideWithTeammates(pThisHandle:hReturn)
{
    
DHookSetReturn(hReturnfalse);
        return 
MRES_ChangedHandled//tryed MRES_ChangedHandled, MRES_ChangedOverride, MRES_Override, MRES_Supercede

oplkill 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 00:10.


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