Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 07-07-2012, 10:25 AM   #1
Codexofwisdom
 
Join Date: Nov 2011
Reputation: 0
Posts: 11
Weapon Questions

Because I'm tired and feel bad about posting so many threads here, I'll just ask my three questions in one post, since they all relate to weapons. (This should keep me busy a while).

1) How do I make a new tracer? I added my bullet type to the hl2mp_gamerules list, but it still says it's undefined. Furthermore, I tell defined ammo types to have tracers (be they line, beam, etc.) and I see nothing. Where is the tracer info that I'm missing? The documentation is very poor on tracers.

2) Can somebody point me to documentation on secondary attacks? I can't figure it out either. Specifically, I want to add a melee secondary (like in L4D), but don't have the L4D weapon CPPs to look at.

3) Finally, does anyone have tips, or even the files I should look in for implementing weapon unlocks and configurable loadouts (like TF2 uses)?

I know, I'm shooting high for this being a first project, but as the saying goes "shoot for the stars and you'll at least reach the Moon." This will hopefully be the last question I ask for a while, if I can figure these things out.
Thanks!
Codexofwisdom is offline  
Reply With Quote
Old 07-07-2012, 05:31 PM   #2
killermonkey01
 
 
 
Join Date: Dec 2008
Reputation: 4
Posts: 42
For #2 look at the crowbar files
killermonkey01 is offline   Reply With Quote
Old 07-08-2012, 04:09 PM   #3
Codexofwisdom
 
Join Date: Nov 2011
Reputation: 0
Posts: 11
Yeah, I did look at those some, but how would I go about implementing it as a secondary attack, instead of declaring the whole weapon as melee?
Codexofwisdom is offline   Reply With Quote
Old 07-08-2012, 04:35 PM   #4
frostcat
 
Join Date: Aug 2007
Reputation: 9
Posts: 555
I would try this in the ItemPostFrame function of your weapon:
Code:
/*
-------------------------------------------
 slapping code
-------------------------------------------
*/
	
if (pOwner->m_nButtons & IN_ATTACK2)
	{
					
					SlapThat();
	}

This is only the basic code that detects when you press ATTACK2. Then you would have to fill the brackets with the melee stuff.
frostcat is offline   Reply With Quote
Old 07-11-2012, 08:12 AM   #5
durrchet
 
Join Date: Mar 2012
Reputation: 204
Posts: 895
Quote:
Originally Posted by frostcat View Post
I would try this in the ItemPostFrame function of your weapon:
Code:
/*
-------------------------------------------
 slapping code
-------------------------------------------
*/
	
if (pOwner->m_nButtons & IN_ATTACK2)
	{
					
					SlapThat();
	}

This is only the basic code that detects when you press ATTACK2. Then you would have to fill the brackets with the melee stuff.
Bad and hacky idea. Instead you should override baseweapon seconadry attack, or do it for every weapon separately, but will take longer. And even then you still need to check if it's not called every tick, or else it will spamming.

1. Not sure haven't tried.
2. Already replied, by replying to frostcat
3. Start with inventory, if you need one, then a new base weapon class, so it would read the scripts from a single file, or multiple. This way you won't have to create a new entity for every single weapon you add. I've done similar thing for my item inventory, but instead of weapons with stats the script file contains data, model, name and other requirements. This way you save time.

For example my script file looks like this:

Code:
// The name of item branch must me unique numeric value, should never be under 1
// 0 - determines NULL item model
//----------------------------------
// INFO ABOUT KEYVALUES
//----------------------------------
// MUST EXIST:
// Model
//	Modelname 	- model name
//	Spotlight 	- should be 1
//	anglex_x,y,z 	- angle in model panel
//	origin_x,y,z	- origin in model panel
//
// OTHERS:
// Name		- Item name || Def. ("unknown")
// Sound	- Sound when used, etc..
// Type		- Item type || Def. (0)
// Value	- Extra info, effect depends on item type || Def. (0)
// NoFlame	- Makes item non-flamable
//----------------------------------

"ItemList"
{
	0
	{
		Name	"#Inventory_empty"

		"Model"
		{
			"Modelname"	"models/items/flare.mdl"
		}
	}
	1
	{
		Name	"Wood"
		Type	"0"

		"Model"
		{
			"Modelname"	"models/props_debris/wood_chunk03b.mdl"
			"spotlight"	"1"
			"angles_z" "65"
			"origin_x" "80"
		}
	}
	2
	{
		Name	"Plank"
		Type	"0"
		
		"Model"
		{
			"modelname" "models/props_debris/wood_board06a.mdl"
			"spotlight" "1"
			"angles_z" "65"
			"origin_x" "55"
		}
	}
	3
	{
		Name	"Fence"
		Type	"1"
		Value	"500"
		
		"Model"
		{
			"modelname" "models/props_wasteland/wood_fence01a.mdl"
			"spotlight" "1"
			"angles_y" "90"
			"origin_x" "125"
		}
	}
	4
	{
		Name	"Melon"
		Type	"2"
		
		"Value"
		{
			Hunger	"75"
			Thirst	"250"
			Rest	"-5"
		}
		
		"Model"
		{
			"modelname" "models/props_junk/watermelon01.mdl"
			"spotlight" "1"
			"origin_x" "20"
		}
	}
}
As you see there's only a single item, but it changes all data accordingly to the script file, this is also similar to how tf2 handles weapons.
durrchet is offline   Reply With Quote
Old 07-11-2012, 11:21 AM   #6
Codexofwisdom
 
Join Date: Nov 2011
Reputation: 0
Posts: 11
Thanks! Looks like a lot of work, a lot of learning, and a lot of trial, error, error, and more error in store for me :P
Codexofwisdom is offline   Reply With Quote
Old 07-11-2012, 12:00 PM   #7
frostcat
 
Join Date: Aug 2007
Reputation: 9
Posts: 555
Quote:
Bad and hacky idea. Instead you should override baseweapon seconadry attack, or do it for every weapon separately, but will take longer. And even then you still need to check if it's not called every tick, or else it will spamming.
Why is that hacky?
frostcat is offline   Reply With Quote
Old 07-12-2012, 03:47 AM   #8
durrchet
 
Join Date: Mar 2012
Reputation: 204
Posts: 895
Quote:
Originally Posted by frostcat View Post
Why is that hacky?
Because it is being ran every tick, and you should restrain yourself from using post/preframe too much. Considering there's already secondary attack just for that.
durrchet is offline   Reply With Quote
Old 07-12-2012, 05:23 AM   #9
Lukeme99
 
 
 
Join Date: Oct 2011
Reputation: 2
Posts: 160
Quote:
Originally Posted by durrchet View Post
Because it is being ran every tick, and you should restrain yourself from using post/preframe too much. Considering there's already secondary attack just for that.
Hacky you say... I would use that method! Maybe only a few times in the entir project, but it's ok if it's only a few times...
Lukeme99 is offline   Reply With Quote
Old 07-12-2012, 12:52 PM   #10
frostcat
 
Join Date: Aug 2007
Reputation: 9
Posts: 555
Quote:
Because it is being ran every tick, and you should restrain yourself from using post/preframe too much. Considering there's already secondary attack just for that.
I do not get what is hacky about this. IN_RELOAD is used to detect the player pressing the reload key for example. So why is using postframe too hacky for detecting keypresses when valve does it too?
frostcat is offline   Reply With Quote
Old 07-12-2012, 01:01 PM   #11
durrchet
 
Join Date: Mar 2012
Reputation: 204
Posts: 895
Quote:
Originally Posted by frostcat View Post
I do not get what is hacky about this. IN_RELOAD is used to detect the player pressing the reload key for example. So why is using postframe too hacky for detecting keypresses when valve does it too?
Well maybe not as hacky as inpractical, but it would create problems in the end unless you only do it per single weapon. And if he wants to do it for more than one weapon, like in l4d as he mentioned, he will need to need to do it in base class. And if he wanted to add secondary attack for any weapon it would not be able to inhert the the postframe, and instead make a new one, just for the weapon. When instead he could just override secondary attack, that way you wont have secondary attack and bashing at the same time.

Maybe hackish is not the right word, but it's definetly a bad practice if you're thinking few steps ahead. I mean why would you need to worry about what is in baseclass, that's the beauty of OOP.

Last edited by durrchet: 07-12-2012 at 01:03 PM.
durrchet is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


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



All times are GMT -7. The time now is 08:58 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2012, All Rights Reserved.