AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [TF2] Projectile Collision (https://forums.alliedmods.net/showthread.php?t=295080)

RumbleFrog 03-15-2017 17:57

[TF2] Projectile Collision
 
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

404UserNotFound 03-15-2017 19:11

Re: [TF2] Projectile Collision
 
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.

RumbleFrog 03-15-2017 20:46

Re: [TF2] Projectile Collision
 
Quote:

Originally Posted by abrandnewday (Post 2503970)
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.

Chaosxk 03-15-2017 21:47

Re: [TF2] Projectile Collision
 
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
        }
}


404UserNotFound 03-16-2017 18:43

Re: [TF2] Projectile Collision
 
Quote:

Originally Posted by Chaosxk (Post 2503992)
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.

RumbleFrog 03-17-2017 16:23

Re: [TF2] Projectile Collision
 
Quote:

Originally Posted by Chaosxk (Post 2503992)
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 :3

404UserNotFound 03-17-2017 16:44

Re: [TF2] Projectile Collision
 
Quote:

Originally Posted by RumbleFrog (Post 2504486)
Interesting, I thought I needed to constantly do tracerays on the projectile. I'll try this and report back :3

Oh lord no. That would be awful.

RumbleFrog 03-17-2017 17:14

Re: [TF2] Projectile Collision
 
Quote:

Originally Posted by Chaosxk (Post 2503992)
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?

RumbleFrog 03-17-2017 19:11

Re: [TF2] Projectile Collision
 
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?

Chaosxk 03-17-2017 20:23

Re: [TF2] Projectile Collision
 
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");
}



All times are GMT -4. The time now is 02:45.

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