Adding the Physgun

B

badpigeon

Guest
Could someone please post some sort of guide, or the code to get the physgun working in hl2? Ive been messing with this for hours, and because of my lack of coding knowledge I have gotten nowhere.

Aparently, what I have been told, is there is no class for CWeaponGravityGun defined in the entire project file. So whenever I create a game (after adding physgun.cpp to the project) and compiling, I get 2 errors, the first saying "Datatable Warning: No matching RecvTable for SendTable 'DT_WeaponGravityGun'." ,and an error saying "Client missing DT class CWeaponGravityGun" followed by Host_EndGame: CL_ParseClassInfo_EndClasses: CreateDecoders Failed."

Any Help would be awesome.
 
well, it's CWeaponPhysCannon

I don't know what you mean by "adding", but btw, id you start a mod "from scratch" or "modify HL2"? if you chose the first, you might get probs with wepoans and stuff (I have no idea thu tbh).

btw, I also made my first modification and added a command to upgrade the physcannon to super physcannon :p
 
Well, the physgun sourcecode is there, but it is missing something in the main project file. I dont understand why Valve would release the SDK with weapons that dont work. If anyone knows how to do this modification, and would like to share, BY ALL MEANS PLEASE DO!!
 
I dont want a mod, I want to make a mod. I'm asking for help in trying to add the physgun sourcecode. The peson that made that little mod will not respond to PM's or Email, and I know a whole bunch of people that would like to know how to add this weapon.

IT DOES NOT COME IN THE SOURCE PROJECT FILES. Compiling them and running your mod does not include the physgun. It must be added. When I add it, I get errors

The following link shows the errors in the Physgun.cpp code. TO OPEN YOU MUST COPY AND PASTE THE LINK IN YOUR ADDRESS BAR. You also have to "save as" the picture, because image-dump sucks...

http://www.image-dump.com/image.php?x=23751&fn=c.jpg

Can anyone make anything of this?
 
it IS in the project.
look it up under HL2 DLL folder.
right click those files and click properties,make sure they are not excluded from the build. (set exclude form build to no)
 
I've tried adding the physgun.cpp to the project and compiling, of course I ended up with the error you posted in the first post. I haven't had the time to look into it further.

I'm not sure what you're trying to do in that screenshot, I get no errors at all when I compile the whole project.
 
why do you have to add it? it's there already.
 
Yeah, I think I messed something up in the screenshot, but the main error I was getting is the one in the origonal screenshot...

and Hasan, it isnt in the game already, it has to be added. The minimod that jb55 made is his mod, and I would like to add the physgun to my mod.

TheGreenBunny, do you have any clue what might be the problem? There are 2 model errors, but I can fix those. I just need the stupid thing to work when I type give weapon_physgun :D

If you figure anything out, please post!
 
Have you read the network entity documention?

That error's basically telling you it can't find a class on the client for the physgun and hence it can't find a receive data table (the send data table of a class on the server tells the engine what variables of it need to be replicated on the client, the receive data table on the client maps the received data back into the appropiate variable).

So to get it working you need to create an appropiate entity for it on the client and setup a receive table for it (read the network entity docs for more info). Or prehaps just remove the send table stuff from the server class, not entirely sure if this will work but it's worth a try :)

Oh and if you want to use this gun in mp games you'll have to write some client side prediction code for it. Check how exisiting weapons have been done in the SDK client side for more info.
 
I seem to have gotten past that first error by putting WeaponGravityGun in the c_basehlcombatweapon.cpp and .h files. I'd explain in more detail but I'm just doing a quick post, gotta go soon. Now I get a new error:

Missing RecvProp for DT_WeaponGravityGun - DT_WeaponGravityGun/m_targetPosition
Host_EndGame: CL_ParseClassInfo_EndClasses: CreateDecoders failed.

I plan to work on it some more tomorrow afternoon.

edit: Ah, I'll look into the stuff you mentioned... tomorrow :x must... sleep...
 
Missing RecvProp for DT_WeaponGravityGun - DT_WeaponGravityGun/m_targetPosition
Host_EndGame: CL_ParseClassInfo_EndClasses: CreateDecoders failed.

That'll be caused by the lack of a receive table on the client (see above for more info).
 
Im reading this Network Entity tutorial, but I was wondering, do I put my network entity code in a cpp file? If so, where do I put that file in the project?

Basically, my mod needs a physgun that works in some sort of multiplayer. I was hoping to have a very primitive version of the physgun in the mod (www.wireproject.com/konstruct) and get some map testing going. Since I lack the obvioulsly needed coding experience, I may just post on Moddb.com help wanted for a coder.
 
badpigeon said:
I get 2 errors, the first saying "Datatable Warning: No matching RecvTable for SendTable 'DT_WeaponGravityGun'." ,and an error saying "Client missing DT class CWeaponGravityGun" followed by Host_EndGame: CL_ParseClassInfo_EndClasses: CreateDecoders Failed."

Any Help would be awesome.
this is really simple. the error is because there's no client code for the gun, to add this, simply add the file to the client project:
\cl_dll\hl2_hud\c_weapon_gravitygun.cpp
 
Ok, but why in hl2_hud? is that c_weapon_gravitygun.cpp the file that goes to the physgun?
 
That's the file you need in your client project. Just add it in and you're done.

I ran into the same problem mainly because I was expecting the file to be named something along the lines of c_physgun.cpp or c_weapon_physgun.cpp

The naming made for a small scavenger hunt, but it works perfectly :)
 
qckbeam said:
That's the file you need in your client project. Just add it in and you're done.

I ran into the same problem mainly because I was expecting the file to be named something along the lines of c_physgun.cpp or c_weapon_physgun.cpp

The naming made for a small scavenger hunt, but it works perfectly :)

Yeah, took me a while to find that as well. In fact I had already constructed my own c_weapon_physgun.cpp before finding out that file existed (argh). Oh well, I do understand the whole server/client thing a lot better now.
 
theGreenBunny said:
Yeah, took me a while to find that as well. In fact I had already constructed my own c_weapon_physgun.cpp before finding out that file existed (argh). Oh well, I do understand the whole server/client thing a lot better now.

Did the exact same thing myself last night :p At least we learned something :)
 
where exactly can I find the cl_dll folder in the project file?
 
badpigeon said:
where exactly can I find the cl_dll folder in the project file?

When you open Game_SDK.sln you should see two project files in the solution explorer.

"client" is the project which compiles as the client.dll and "hl" is the project that compiles as the server.dll
 
Ok, yeah I figured out what he ment by the \cl_dll\hl2_hud\c_weapon_gravitygun.cpp

I thought he was refering to something inside the project, but he was talking about where the file is located in the sourcecode directory :D

So did you test this? does it actually work?

Im compiling the code now :D
 
YES! THANK YOU! it works

There are some errors though. Some of them have to do with weapon models, which i know how to fix, other have to do with sound, I shoud beable to fix those, but there is one I dont know how to fix

I get red pieces of HUD on the upper right and left side of my screen when I pick up the weapon, maybe due to not have a model set? I think I can change that in the physgun.txt script file.

Also I am getting this error in the console: ERROR: Weapon (weapon_physgun) using undefined secondary ammo type (Gravity)

Any Idea how I could fix this error?

I know that I dont have a model for the goo that it shoots, and I remember seeing that model defined in the physgun.cpp code near the top. Couldnt I use a basic model, exported from 3dsmax Maybe a sphere?
 
Sorry for the spamming, but I think I found the majority of my errors. I dont have any of the needed weapon scripts in my scripts folder :D I think this is because I chose the create a mod "start from scratch"

BTW, thank you all for your help, you helped me when pretty much noone else would on hl2world or any other forum. Thank you for your time!
 
Hi badpigeon (or anybody able to answer).

I'm trying to do the same.
Created a MP mod from scratch, tried to add the physgun to it.

I tried to add the \cl_dll\hl2_hud\c_weapon_gravi tygun.cpp to the project, but creates some errors (header files (.h) not found, thing like that). I included some header files, having to change the path in the #include command, but i end up with no compilation problem, but many linkage problem.


Can you tell me exactly the steps to have the physgun working in a "Mp mod from scratch"?

Thanks.
 
Actually i restarted from a fresh SDK.

I found the weapon_gravitygun.cpp file and added it (cl_dll).
Compiles, but nothing in game, even after impulse 101.

There is a weapon_physgun.h/cpp in the server dll (hl_dll), but adding it to build creates errors :
- first cannot find headers; i can find them, but not where it's looking for them (bad include path)
- if i include headers, modifying the include pathes, i get link errors.

So atm, i have only added the weapon_gravitygun.cpp (not physgun) to the cl_dll.

What to do next?

I was thinking creating a new weapon in the hl_dll/sdk dir., but don't know how.
And anyway, seems useless, as the original phys_gun code should be reusable...

So now i don't have a buid_log, as it compiles and links correctly. But i don't know how to make it work.

BTW : I never had the DT_PHYSGUN errors seen in first post of the topic.
 
I finally did it, no use to say i was happy...

Now : the primary fire shoots correctly, but the secondary fire doesn't work. I always have the "deny" sound, and can't grab things...

Any idea on this?
 
I think i can help you there, if you look in the .FGD gamedata file for HalfLide2, under physcannon:

Code:
@PointClass base(Weapon) studio("models/weapons/w_physics.mdl") = weapon_physcannon : "Physics Cannon"
[
	spawnflags(Flags) =
	[
		2 : "Start without grab functionality." : 0
	]

	input EnableGrab(void) : "Enable the grab functionality."
]

Grab functionality is disabled by default when the weapon is spawned, you may need to set that value either in hammer, or through some other call.

:D
 
Thanks, that's nice. ;)

Actually, i ran the process in debug mode, with a breakpoint on secondary attack. The point is it doesn't find an object (but it should). I end up with the NO_OBJECT_FOUND return statement, in the called FindObject method.

But perhaps it's because of this. I'm wondering why it would bother looking for an object if grabbing is disabled but worth a look.

Thanks a lot.

Oh by the way, your post may explain one of my other problem (well not really a problem because i want to change the physgun model). The GGun spawing in my MP mod has not the same model as in the SP game.

Take a look :

http://img62.exs.cx/my.php?loc=img62&image=ggun7xv.jpg
 
no glueblob model lol, ill send it to you if you want
 
Similar Error Message

Missing RecvProp for DT_WeaponGlock20 - DT_BaseEntity/AnimTimeMustBeFirst

I am trying to add a custom model to a HL2MP Mod.

I did a google on the error and this thread was teh closest thing i could find.... seems like a similar enough error can someone please give me some help on fixing that so i can get this model implemented??
 
So I was trying to do this and it all seems very simple but, I tried adding the "c_weapon_gravitygun.cpp" to the client "source files" folder and in the client source files->hl2_dll folder and neither allowed me to use "give weapon_physgun" (with sv_cheats 1 on of course)

Can anyone tell me what I did wrong please?
 
on the projects (server and client) where do i add the c_weapon_gravitygun in hl2_dll ect
and this is on hl2 mp by the way and also do i put the weapon_physgun.cpp in hl2mp/weapons in both
because i dont have a .h for it or the physgun.cpp code either
 
Back
Top