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

[TF2] Attaching a stickybomb model to someone?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zethax
Member
Join Date: Sep 2015
Location: In my couch
Old 06-09-2016 , 12:52   [TF2] Attaching a stickybomb model to someone?
Reply With Quote #1

Hi.
I'm making a bow that shoots arrows with bombs attached to them. I've got most of the features down, but I want to attach a stickybomb to the player where the arrow hit, so their team has an indication that he has a bomb on him, I better keep away from him!

Is it even possible?
Thanks for any replies that come through
__________________
I code, I guess.
Zethax is offline
sdz
Senior Member
Join Date: Feb 2012
Old 06-09-2016 , 12:53   Re: [TF2] Attaching a stickybomb model to someone?
Reply With Quote #2

Tracerays and Parenting would be the route to take.
Let me know if you're lost
sdz is offline
Zethax
Member
Join Date: Sep 2015
Location: In my couch
Old 06-09-2016 , 13:02   Re: [TF2] Attaching a stickybomb model to someone?
Reply With Quote #3

Quote:
Originally Posted by EasSidezz View Post
Tracerays and Parenting would be the route to take.
Let me know if you're lost
Yeah, I'm lost. Like my signature says. I haven't been doing Sourcepawn for very long, and I learn off of other people's work rather than the wiki since I've had previous experience in coding.
__________________
I code, I guess.
Zethax is offline
sdz
Senior Member
Join Date: Feb 2012
Old 06-09-2016 , 13:15   Re: [TF2] Attaching a stickybomb model to someone?
Reply With Quote #4

PHP Code:
public Thing(whatever)
{
    
decl Float:fEnd[3];
    new 
Handle:trace TR_TraceRayFilterEx(cOrigincEyesMASK_SHOTRayType_InfiniteTraceRayDontHitSelfclient);
    if(
TR_DidHit(trace))
    {
        
TR_GetEndPosition(fEndtrace); //Returns a vector with the ending position
        
new entity TR_GetEntityIndex(trace);
        
/*   
        *    Teleport Stickybomb to fEnd and SetParent to the entity. Something like...
        *    SetVariantString("!activator");
        *    AcceptEntityInput(stickyBombEnt, "SetParent", entity);
        *    ...
        */
        
CloseHandle(trace);
    }
}

public 
bool:TraceRayDontHitSelf(entitymaskany:data)
{    
    if(
entity == data)
    {
        return 
false
    
}
    else if(
entity != data && entity && entity <= MaxClients)
    {
        return 
true;
    }
    return 
true

Additionally, you could check if entity was a player and use that index for parenting the stickybomb to the target.
Added to the code instead.

TR_TraceRayFilterEx

Last edited by sdz; 06-09-2016 at 13:23.
sdz is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 06-09-2016 , 13:55   Re: [TF2] Attaching a stickybomb model to someone?
Reply With Quote #5

The easier route is to just hook SDKHook_StartTouchPost onto the entity "tf_projectile_arrow" at OnEntityCreated().
Then in StartTouchPost get the origin of where the arrow hit and spawn the sticky bomb there.

If you need an example code, take a look at my explosive arrows plugin. It creates a delayed explosion whenever an arrow hits someone which is similar to what your asking, except spawning an entity instead of exploding.

The code is 4 years old, so if you need a cleaner/better example, ask away.
__________________

Last edited by Chaosxk; 06-09-2016 at 13:57.
Chaosxk is offline
Zethax
Member
Join Date: Sep 2015
Location: In my couch
Old 06-09-2016 , 17:23   Re: [TF2] Attaching a stickybomb model to someone?
Reply With Quote #6

Quote:
Originally Posted by Chaosxk View Post
The easier route is to just hook SDKHook_StartTouchPost onto the entity "tf_projectile_arrow" at OnEntityCreated().
Then in StartTouchPost get the origin of where the arrow hit and spawn the sticky bomb there.

If you need an example code, take a look at my explosive arrows plugin. It creates a delayed explosion whenever an arrow hits someone which is similar to what your asking, except spawning an entity instead of exploding.

The code is 4 years old, so if you need a cleaner/better example, ask away.
Thanks. I have an idea of what I'm supposed to do after looking at your plugin. As for spawning the stickybomb and keeping it there I'm not sure what to do, as I believe if I spawn a normal stickybomb it will either flop to the ground or bounce off of the victim. And like abrandnewday said parenting the model to the player will result in it becoming invisible.
__________________
I code, I guess.
Zethax is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 06-09-2016 , 17:42   Re: [TF2] Attaching a stickybomb model to someone?
Reply With Quote #7

Parent the sticky to player to prevent it from falling down.
You can parent the sticky entity, just not a prop_dynamic entity.
__________________

Last edited by Chaosxk; 06-09-2016 at 17:42.
Chaosxk is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 06-09-2016 , 17:55   Re: [TF2] Attaching a stickybomb model to someone?
Reply With Quote #8

There are other entities like prop_static and tf_wearable that turns invisible.
I didn't test but I doubt the sticky entity would turn invisible.
__________________
Chaosxk is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-09-2016 , 18:03   Re: [TF2] Attaching a stickybomb model to someone?
Reply With Quote #9

Have you considered attaching the bomb to the arrow instead?

Quote:
Originally Posted by Chaosxk View Post
There are other entities like prop_static and tf_wearable that turns invisible.
I didn't test but I doubt the sticky entity would turn invisible.
Are you sure you didn't mean prop_physics instead of prop_static? prop_static is a compile-time map entity that doesn't exist at runtime as it gets compiled into the map geometry.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 06-09-2016 , 18:15   Re: [TF2] Attaching a stickybomb model to someone?
Reply With Quote #10

Yep, writing on phone. I just know prop_* turns invisible if parented. Not sure about ragdoll though.
__________________
Chaosxk 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 05:25.


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