News: SMF - Just Installed!
 
Welcome, Guest. Please login or register.
+  AnthraxBio
|-+  Return to Castle Wolfenstein
| |-+  Coding Tutorials
| | |-+  Adding Additional Items
« previous next »
Pages: [1] Print
Author Topic: Adding Additional Items  (Read 390 times)
SkreamerVirii
Administrator
Full Member
*****
Posts: 133


View Profile
« on: September 03, 2008, 11:21:33 PM »

In this tutorial i will show you how to assign a certain player class an item in this case i will be assigning the binoculars to the soldier

So let us begin
open g_client .c and scroll down to
// Soldiers and Lieutenants get a 2-handed weapon
if ( pc == PC_SOLDIER || pc == PC_LT ) {
// JPW NERVE -- if LT is selected but illegal weapon, set to team-specific SMG
if ((pc == PC_LT) && (client->sess.playerWeapon > 5)) {
if (client->sess.sessionTeam == TEAM_RED)
client->sess.playerWeapon = 3;
else
client->sess.playerWeapon = 4;
}
we are going to want to add this code
client->ps.stats[STAT_KEYS] |= ( 1 << INV_BINOCS );

which was found when i scolled back up to this code
// Lieutenant gets binoculars, ammo pack, artillery, and a grenade
if ( pc == PC_LT ) {
client->ps.stats[STAT_KEYS] |= ( 1 << INV_BINOCS );
COM_BitSet(client->ps.weapons, WP_AMMO);
client->ps.ammo[BG_FindAmmoForWeapon(WP_AMMO)] = 0;
client->ps.ammoclip[BG_FindClipForWeapon(WP_AMMO)] = 1;
COM_BitSet(client->ps.weapons, WP_ARTY);
client->ps.ammo[BG_FindAmmoForWeapon(WP_ARTY)] = 0;
client->ps.ammoclip[BG_FindClipForWeapon(WP_ARTY)] = 1;


So now that you know where i got lets put it in the same area in another class
which in our case is the soldierclass
so now make

// Soldiers and Lieutenants get a 2-handed weapon
if ( pc == PC_SOLDIER || pc == PC_LT ) {
// JPW NERVE -- if LT is selected but illegal weapon, set to team-specific SMG
if ((pc == PC_LT) && (client->sess.playerWeapon > 5)) {
if (client->sess.sessionTeam == TEAM_RED)
client->sess.playerWeapon = 3;
else
client->sess.playerWeapon = 4;
}
look like this

// Soldiers and Lieutenants get a 2-handed weapon
if ( pc == PC_SOLDIER || pc == PC_LT ) {
client->ps.stats[STAT_KEYS] |= ( 1 << INV_BINOCS );
// JPW NERVE -- if LT is selected but illegal weapon, set to team-specific SMG
if ((pc == PC_LT) && (client->sess.playerWeapon > 5)) {
if (client->sess.sessionTeam == TEAM_RED)
client->sess.playerWeapon = 3;
else
client->sess.playerWeapon = 4;
}
if you have any troubles try modifing this part of the code
f ( pc == PC_SOLDIER || pc == PC_LT ) {
to look like tis
f ( pc == PC_SOLDIER ) {
the reason i say that is because my player class code is different
it is all independent for the most part
ill explain in a future tutorial
YOur done nw go compile and try using you binoculars while playing as the soldier i find the spacebar convienent to bind it itoo
if you have any troubles just email me or post in the ri forums

Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Free SMF 1.1.5 Forum Theme by Tamuril. © 2008.