V
vk_phoenixfr
Guest
Importing the SP gravity gun into a MP mod from scratch.
--------------------------------------------------------
Hi there !
I make this tutorial because i finally managed to have my GGun in my MP mod,
and would have been pleased to find such a guide to help me. So i share with you
There are two steps to get this working (well three in fact but two coding ones).
Let's have a look at the non coding step first: You must exctract from the halflife2 gcf file
the sounds/scripts/models and put them into your mod, so you can find them when you need them.
For example, it will give you the sounds when you walk, jump, and...shoot the GGun
Use GCFScape for this.
Now the coding.
For the GGun to appear in your mod, you must have code for it in both the client and server dll's.
So the 2 steps are obviously :
1. import GGun into client dll;
2. import GGun into server dll.
1. Client DLL
-------------
This step is quite easy.
You will see in you client source directory a c_weapon_physgun.cpp. This is not the one you must use.
Actually, there is another GGun source file called c_weapon_gravitygun.cpp.
You must add it to your solution (client project).
In VS 2003, go to the client/HL2_DLL node, right click then choose "add an existing element".
Then in the file browser window, go to src/cl_dll/hl2_hud then select c_weapon_gravitygun.cpp.
Build your client project. you're done for the first step. But we'll be back to the client side soon.
2. Server DLL
-------------
Now comes the tricky part.
First, go to the hl project (server) then in the HL2_DLL node, select weapon_physcannon.cpp, right click, properties
and include it into the build (Excluded from Build : No)
Now compile, you'll have many errors.
Now look into the include section of this file. You have to change some include files.
Change : #include "hl2_player.h" to #include "sdk_player.h"
Change : #include "basehlcombatweapon.h" to #include "basecombatweapon.h"
Basicly, each time you find a reference to hl in an include file, you must either remove the hl or replace the
file by an sdk equivalent (see the hl2_player >> sdk_player example).
Now, you'll find other errors, because of class use in the weapon_physcannon.cpp file.
Actually it uses the CHL2_Player class, which is defined in hl2_player.h/cpp. But we removed this file remember?
So you must remove this class by the SDK equivalent (defined in sdk_player) : CSDKPlayer.
Use the "replace all" feature, no bad replacement will be made (i checked that).
The same problem will araise with the CBaseHLCombatWeapon (again a replaced header file, now missing).
Do the same job, replace all with CBaseCombatWeapon.
Now another problem. The EnableSprint (bool) method doesn't exist in the sdk_player.
I removed the calls to this method because i don't need in my mod by now, but you can take it from HL2_Player and add it to
the sdk_player (don't forget to add its declaration in the sdk_player.h if you choose this solution).
Last problem i remember about before compilation and linkage works, the extern links.
weapon_physcannon makes use of the hl2_normspeed, hl2_sprintspeed and hl2_walkspeed.
Two of them are externs, the last is not but not defined in sdk_player.
Two solution to this. Replace the references to these vars by their values (320.0f for sprint, 190.0f for norm, and 150.0f for walk).
Or create these vars in sdk_player.
You can find them in HL2_Player, under a #ifdef HL2DM /* values */ #else /* hl2 var definition */
Then remove the declaration of links to these extern vars in weapon_physcannon ( look for : extern ConVar hl2_normspeed )
Now if you compile, it should work.
But in game, doesn't work.
You get the errors :
Datatable Warning: No matching RecvTable for SendTable 'DT_WeaponGravityGun'.
Client missing DT class CWeaponGravityGun
Host_EndGame: CL_ParseClassInfo_EndClasses: CreateDecoders Failed.
First, in the c_weapon_gravitygun.cpp (and .h) rename the class CWeapon_GravityGun by CWeapon_PhysCannon (check the name in
the server side weapon_physcannon, and make it the same). Not so usefull, but cleaner.
Then in the client c_weapon_gravitygun.cpp, find the DECLARE_DATA... statement, one of them will declare the DT_WeaponGravityGun
table. Make it the same name as declared in the server weapon_physcannon.cpp.
Finally, in c_weapon_physcannon.cpp take the property declaration (RecvProp) about m_bIsUpgrading or something like that, then add it to
the props definition of c_weapon_gravitygun.cpp (if you don't you'll get another in-game error).
compile, link, launch, and smile
By now, only the primary attack works, but i'm working on it. I'll update this tutorial when i make it grab things.
Have fun, and i hope you find it usefull !
Comments welcome of course.
--------------------------------------------------------
Hi there !
I make this tutorial because i finally managed to have my GGun in my MP mod,
and would have been pleased to find such a guide to help me. So i share with you
There are two steps to get this working (well three in fact but two coding ones).
Let's have a look at the non coding step first: You must exctract from the halflife2 gcf file
the sounds/scripts/models and put them into your mod, so you can find them when you need them.
For example, it will give you the sounds when you walk, jump, and...shoot the GGun
Use GCFScape for this.
Now the coding.
For the GGun to appear in your mod, you must have code for it in both the client and server dll's.
So the 2 steps are obviously :
1. import GGun into client dll;
2. import GGun into server dll.
1. Client DLL
-------------
This step is quite easy.
You will see in you client source directory a c_weapon_physgun.cpp. This is not the one you must use.
Actually, there is another GGun source file called c_weapon_gravitygun.cpp.
You must add it to your solution (client project).
In VS 2003, go to the client/HL2_DLL node, right click then choose "add an existing element".
Then in the file browser window, go to src/cl_dll/hl2_hud then select c_weapon_gravitygun.cpp.
Build your client project. you're done for the first step. But we'll be back to the client side soon.
2. Server DLL
-------------
Now comes the tricky part.
First, go to the hl project (server) then in the HL2_DLL node, select weapon_physcannon.cpp, right click, properties
and include it into the build (Excluded from Build : No)
Now compile, you'll have many errors.
Now look into the include section of this file. You have to change some include files.
Change : #include "hl2_player.h" to #include "sdk_player.h"
Change : #include "basehlcombatweapon.h" to #include "basecombatweapon.h"
Basicly, each time you find a reference to hl in an include file, you must either remove the hl or replace the
file by an sdk equivalent (see the hl2_player >> sdk_player example).
Now, you'll find other errors, because of class use in the weapon_physcannon.cpp file.
Actually it uses the CHL2_Player class, which is defined in hl2_player.h/cpp. But we removed this file remember?
So you must remove this class by the SDK equivalent (defined in sdk_player) : CSDKPlayer.
Use the "replace all" feature, no bad replacement will be made (i checked that).
The same problem will araise with the CBaseHLCombatWeapon (again a replaced header file, now missing).
Do the same job, replace all with CBaseCombatWeapon.
Now another problem. The EnableSprint (bool) method doesn't exist in the sdk_player.
I removed the calls to this method because i don't need in my mod by now, but you can take it from HL2_Player and add it to
the sdk_player (don't forget to add its declaration in the sdk_player.h if you choose this solution).
Last problem i remember about before compilation and linkage works, the extern links.
weapon_physcannon makes use of the hl2_normspeed, hl2_sprintspeed and hl2_walkspeed.
Two of them are externs, the last is not but not defined in sdk_player.
Two solution to this. Replace the references to these vars by their values (320.0f for sprint, 190.0f for norm, and 150.0f for walk).
Or create these vars in sdk_player.
You can find them in HL2_Player, under a #ifdef HL2DM /* values */ #else /* hl2 var definition */
Then remove the declaration of links to these extern vars in weapon_physcannon ( look for : extern ConVar hl2_normspeed )
Now if you compile, it should work.
But in game, doesn't work.
You get the errors :
Datatable Warning: No matching RecvTable for SendTable 'DT_WeaponGravityGun'.
Client missing DT class CWeaponGravityGun
Host_EndGame: CL_ParseClassInfo_EndClasses: CreateDecoders Failed.
First, in the c_weapon_gravitygun.cpp (and .h) rename the class CWeapon_GravityGun by CWeapon_PhysCannon (check the name in
the server side weapon_physcannon, and make it the same). Not so usefull, but cleaner.
Then in the client c_weapon_gravitygun.cpp, find the DECLARE_DATA... statement, one of them will declare the DT_WeaponGravityGun
table. Make it the same name as declared in the server weapon_physcannon.cpp.
Finally, in c_weapon_physcannon.cpp take the property declaration (RecvProp) about m_bIsUpgrading or something like that, then add it to
the props definition of c_weapon_gravitygun.cpp (if you don't you'll get another in-game error).
compile, link, launch, and smile
By now, only the primary attack works, but i'm working on it. I'll update this tutorial when i make it grab things.
Have fun, and i hope you find it usefull !
Comments welcome of course.