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

Solved How to hook into an internal float in a Source game, and change that value?


Post New Thread Reply   
 
Thread Tools Display Modes
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 02-05-2023 , 22:41   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #11

Greetings! Welcome to the forum!

I'm just a hobbyist plugin author so don't take what I say as absolute.

The goal of your project is difficult and will most likely require the use of gamedata. To start with you'll need to find a way to capture when a stickybomb is created. Here are a couple of examples.

In this example we only care about when stickybomb is created.
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sdkhooks>

public Plugin myinfo =
{
    
name "Stickybomb Tester",
    
author "TotalChaos",
    
description "Do something when Sticky Bomb spawns",
    
version "1.0",
}

public 
void OnEntityCreated(int entity, const char[] classname)
{
    if (
StrEqual(classname,"tf_projectile_pipe_remote"false))
    {
        
SDKHook(entitySDKHook_SpawnPostOnStickyCreated);
    }
}

Action OnStickyCreated(int sticky)
{
    
//Do something here. For example, print to server console when stickybomb is launched
    
    
PrintToServer("Stickybomb was launched");

    return 
Plugin_Changed;

In this next example, we are more concerned about the changes in the stickybombs status
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sdkhooks>

public Plugin myinfo =
{
    
name "Stickybomb Test 2",
    
author "TotalChaos",
    
description "Do something with Sticky Bombs",
    
version "1.0",
}

public 
void OnEntityCreated(int entity, const char[] classname)
{
    if (
StrEqual(classname,"tf_projectile_pipe_remote"false))
    {
        
SDKHook(entitySDKHook_ThinkOnStickyThink);
    }
}

Action OnStickyThink(int sticky)
{
    
//Do something here. For example, print to server console when stickybomb is launched and again when it touches something
    
    
int StickyStatus GetEntProp(stickyProp_Send"m_bTouched");

    if (
StickyStatus == 0)
    {
        
PrintToServer("Stickybomb was launched and hasn't touched anything yet");
    }    

    if (
StickyStatus == 1)
    {
        
PrintToServer("Stickybomb touched something");
    }

    return 
Plugin_Changed;

The second option is pretty expensive as it fires constantly while the stickybomb is alive.

As backwards mentioned the variable "m_flMinSleepTime" isn't exposed in a netprop so your odds of using it are pretty slim. I couldn't find any example of its use.

One option you may consider is to look at the plugin titled '[TF2] Ricochet' by Mr_panica. Here's a link: https://forums.alliedmods.net/showthread.php?p=2671241 In that plugin projectiles 'bounce' when they collide with an object. Perhaps you can use some code from that plugin to make your stickybombs bounce a few times before they stick.
PC Gamer is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 02-05-2023 , 23:34   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #12

Thank you so much for replying, PC Gamer!
I thought that this thread was done for.

Those are some great examples. However, I have not tested them.

If I can't use m_flMinSleepTime, then is there any way to override the code that causes Stickybombs to stick to stuff? Surely there is, right? Considering some of the other stuff people have managed to make.

I'll definitely look into that Ricochet plugin, as that might help a bit.

Also, in the code for the Stickybombs, I found this:
VPhysicsGetObject()->EnableMotion( true );

I found that under "CTFGrenadePipebombProjectile::OnTakeDama ge".
Would it be possible to use that, somehow?

Also, does m_bTouched control anything? Or is it just a boolean to tell the game when the Stickybomb touches something?

Last edited by TotalChaos SourcePawner; 02-05-2023 at 23:36.
TotalChaos SourcePawner is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 02-06-2023 , 10:26   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #13

Is this just gonna be one of those things where I'm given false hope?
Please don't do this to me. People always do this to me.

Yeah, ignore the coding noob's question and leave them in the dark.

This always happens. I ask what should be a simple question, and everybody ignores me.
It's almost like people are purposefully hiding stuff from me. And I'm sick of it.
TotalChaos SourcePawner is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 02-06-2023 , 16:53   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #14

Quote:
Originally Posted by TotalChaos SourcePawner View Post
It's almost like people are purposefully hiding stuff from me. And I'm sick of it.
Whining is not helpful.

Which scenario is more likely?
1. Yes. We are absolutely hiding things from you. Of course we have all the answers. We monitor this forum every few minutes and wait for a new member to ask a question. When that happens we conspire with other veteran members to determine the best intentionally vague answer to give that will foster false hope. We then provide that answer to the new member. We then never respond to the new member because we are too busy laughing maniacally when the new member whines.

2. Of course we don't know all the answers. We didn't develop the game. We'll give the best answer we have, even though it may not completely answer your question. A partial answer is better than no answer. You won't get immediate answers to your questions. This forum is not a real-time conversation. It's more of a bulletin board. You post a question and wait a few days for enough people to stop by the bulletin board to see your question and respond.

I don't believe people are ignoring you. It's more likely they don't know the answer. What makes your question challenging is that you want to change the game mechanic of a sticky bomb projectile to make it not stick when it collides with an object. To my knowledge that hasn't been done before. Its not something most people would want. I feel that most people would think "If you don't want a sticky bomb to stick, why not use a grenade launcher that already has the mechanic you are looking for?". As a result, there aren't any examples of how to do that within this forum. Why not simply remove the sticky bomb launcher from players and force the use of the grenade launcher? In other words, consider alternate ways to accomplish your goal.

However, all is not lost. You now know how to identify individual projectiles as they are fired from the sticky bomb launcher. You also know about the [TF2] Ricochet plugin that makes projectiles bounce when they come into contact with an object instead of explode. I suggest you learn how that plugin works to see if you can modify it to make your sticky bombs change their logic as they touch an object.

And to answer your last question, m_bTouched is a boolean that changes when the projectile touches something.
PC Gamer is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 02-06-2023 , 17:14   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #15

Sorry, PC Gamer. I was just getting worried because I get ignored, alot.

Of course I don't think anybody's doing option 1 there. But it does feel like that, sometimes.
I know that not everybody knows all the answers to everything. Even if somebody's like 10x or 100x more experienced in coding than me, they definitely won't know everything.

And I didn't think something as simple (in theory) as making a Stickybomb bounce and roll around like a Grenade would be so difficult. I mean, that sounds incredibly easy to me, compared to other stuff people have done.

Thank you for your examples, though. I will definitely be looking into all of that. If I can somehow make Stickybombs bounce/roll around like Grenades, I will definitely be posting the plugin somewhere here on Allied Modders.

And for that last part, I didn't think that m_bTouched would change anything if it was manually changed to true or false.

Thank you and backwards for your help.

TotalChaos.
TotalChaos SourcePawner is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-06-2023 , 20:08   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #16

I don't want hear more cry stories at this on...

*edit
I used some cvars, dunno would this still work.

PHP Code:
#include <sdktools>
#include <sdkhooks>

enum
{
    
TF_GL_MODE_REGULAR 0,
    
TF_GL_MODE_REMOTE_DETONATE,
    
TF_GL_MODE_REMOTE_DETONATE_PRACTICE,
    
TF_GL_MODE_CANNONBALL
}


public 
void OnPluginStart()
{

}



public 
void OnEntityCreated(int entity, const char[] classname)
{
    if(
StrEqual(classname"tf_projectile_pipe_remote"false))
        
SDKHook(entitySDKHook_SpawnPostSpawnPost);
}

public 
void SpawnPost(int entity)
{
    if(
HasStickyEffects(entity))
        
SetEntProp(entityProp_Send"m_iType"TF_GL_MODE_REGULAR);
}

bool HasStickyEffects(int entity)
{
    if(
HasEntProp(entityProp_Send"m_iType"))
    {
        return 
GetEntProp(entityProp_Send"m_iType") == TF_GL_MODE_REMOTE_DETONATE || TF_GL_MODE_REMOTE_DETONATE_PRACTICE;
    }
        
    return  
false;

__________________
Do not Private Message @me

Last edited by Bacardi; 02-06-2023 at 20:10.
Bacardi is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 02-06-2023 , 21:18   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #17

And just like that, Bacardi joins in the conversation and saves the day. He made a plugin that does exactly what you asked for. It changes the behavior of the sticky bomb so it doesn't stick.... at all.

The plugin he provided will impact all players using the sticky bomb launcher. For that matter, it affects all sticky bombs, including the sticky jumper.

You could change the plugin to only effect targeted players, or only specific stickybomb launchers, or both. If that is what you want and need help with that let us know.

If Bacardi's answer solves your issue then mark the thread as 'Solved'. To do that, edit your original post, then hit the edit button again, and use the prefix dropdown menu to select 'Solved'.
PC Gamer is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 02-06-2023 , 21:33   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #18

Bacardi, you absolute madman.
This is exactly what I was looking for.
It works perfectly!
You just restored the beta Pipebomb Launcher!
Congratulations!
I honestly have no idea how you got that to work, but thank you so much!

Honestly, I thought that nobody would've been interested in this.
I never thought that anybody would even want to do this.

I was actually just about to give up on all this.
But then you stepped in.
I am honestly forever grateful for what you did. You are an amazing human being.
You should, and will, go far in life.

Would you mind if I uploaded the plugin if you haven't already?
And would you mind if I promoted it?

Thank you and everybody else here for all the help you have given me (I should really be more grateful for even getting help in the first place),
TotalChaos.

Last edited by TotalChaos SourcePawner; 02-06-2023 at 21:42.
TotalChaos SourcePawner is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-06-2023 , 22:27   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #19

Your welcome
__________________
Do not Private Message @me
Bacardi is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 02-06-2023 , 23:00   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #20

Quote:
Originally Posted by Bacardi View Post
Your welcome
The reply is nice, but I really want to promote your plugin.
People need to know that this is a thing now.
That it is possible to have the beta Pipebomb Launcher in Team Fortress 2.

So, may I promote your plugin?
May I also distribute it here on AlliedModders if you haven't, or aren't planning to?

Edit: I found a small bug with the plugin.
The Stickybombs from the Scottish Resistance don't highlight anymore.
It's a very small bug, and not really that big of a deal.
Still a great plugin. Good for TFC or TF2 beta fans (and/or PF2 fans).

Last edited by TotalChaos SourcePawner; 02-06-2023 at 23:28.
TotalChaos SourcePawner 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 13:39.


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