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

[TF2] Change projectile type?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-22-2012 , 12:11   [TF2] Change projectile type?
Reply With Quote #1

I was wondering if it were possible to change the projectile type for a weapon.

For instance, is it possible to make a rocket launcher fire a Sandman ball instead?

SDKHooks will be available in the plugin I'm working on, so anything involving SDKHooks is OK.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-22-2012 at 12:11.
Powerlord is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 05-22-2012 , 13:54   Re: [TF2] Change projectile type?
Reply With Quote #2

replace entity?
when tf_projectile_rocket creates
get position and velocity
create tf_projectile_ball
set owner and velocity
and... done?

this is how I would try

Last edited by Leonardo; 05-22-2012 at 14:01.
Leonardo is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-22-2012 , 16:08   Re: [TF2] Change projectile type?
Reply With Quote #3

Quote:
Originally Posted by Leonardo View Post
replace entity?
when tf_projectile_rocket creates
get position and velocity
create tf_projectile_ball
set owner and velocity
and... done?

this is how I would try
Unfortunately, it's implied in this thread that simply spawning a new entity won't make it work like the actual projectile would.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 05-22-2012 , 17:21   Re: [TF2] Change projectile type?
Reply With Quote #4

but how when game itself can do so? D:
afaik from sdk, weapon creates projectile entity with params, etc
Leonardo is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 05-23-2012 , 01:42   Re: [TF2] Change projectile type?
Reply With Quote #5

Just curiously, in your first example, would you want the rocket-turned-sandman-balls to stun the player upon hit, or explode like a normal rocket with with the ball model instead?
__________________
11530 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-23-2012 , 15:03   Re: [TF2] Change projectile type?
Reply With Quote #6

Quote:
Originally Posted by 11530 View Post
Just curiously, in your first example, would you want the rocket-turned-sandman-balls to stun the player upon hit, or explode like a normal rocket with with the ball model instead?
Stun the player. I already know how to change the actual model used (SetEntityModel).
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-23-2012 , 19:44   Re: [TF2] Change projectile type?
Reply With Quote #7

Anyway, using an OnEntityCreated with a timer (because the properties aren't assigned for another game frame) doesn't appear to work. The code I tried is attached.

I added in the TeleportEntity when I saw weird VPhysics errors regarding the position of the tf_projectile_stun_ball entity in the server log. However, the baseball is never actually seen.
Attached Files
File Type: sp Get Plugin or Get Source (rocketball.sp - 433 views - 2.9 KB)
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-23-2012 at 19:48.
Powerlord is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-24-2012 , 06:01   Re: [TF2] Change projectile type?
Reply With Quote #8

Quote:
Originally Posted by Powerlord View Post
Anyway, using an OnEntityCreated with a timer (because the properties aren't assigned for another game frame) doesn't appear to work.
You need to hook Spawn in OnEntityCreated, then do your work in that callback.
Not that that would actually help with the fact the balls aren't appearing.
__________________

Last edited by asherkin; 05-24-2012 at 06:03.
asherkin is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 05-24-2012 , 06:04   Re: [TF2] Change projectile type?
Reply With Quote #9

Quote:
Originally Posted by asherkin View Post
You need to hook Spawn in OnEntityCreated, then do your work in that callback.
SpawnPost.
I tryed it, but results are same - nothing. no balls, no rockets, no errors. sad panda :c

EDIT:
Oh! Maybe you need to set model?
__________________

Last edited by Leonardo; 05-24-2012 at 06:08.
Leonardo is offline
Andersso
Member
Join Date: Nov 2009
Location: E8 2A 2A 2A 2A
Old 05-24-2012 , 08:11   Re: [TF2] Change projectile type?
Reply With Quote #10

I looked a bit inside the function that spawns the stun ball, and I saw that it calls these two virtual functions: CTFWeaponBaseGrenadeProj::InitGrenade() and CTFWeaponBaseGrenadeProj::SetLauncher()

It also sets a variable (pseudo code)
Code:
 *(float *)(pGrenProjectile + 1232) = tf_scout_stunball_base_speed.GetFloat();
Maybe if you call these two virtual functions I mentioned with sdktools, and then use SetEntDataFloat() to set the value of the variable..

I don't know what values that needs to be passed into these functions, or if the offset of the variable is the same on all platforms (I got it from the Mac binary). Maybe if someone look into this into this with IDA, you may be able to spawn a stun ball in SM
Andersso 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 20:04.


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