KyleRTCW Moderator

Joined: 17 Jan 2005 Posts: 36 Location: United States
|
Posted: Mon Jan 17, 2005 4:56 pm Post subject: [Code] Adding a Silencer + Extras |
|
|
Hello, welcome to my forth tutorial here at WolfPlanet Forums
In this tutorial, I will be showing you how to add a silencer to the pistol and also how to make the silencer wear down and eventually the player must find a new one.
You may need to adjust this tutorial based on your Game.
Read on.
Step 1: Open up WL_DEF.H and do a search for: keys;
You should see this:
| Code: |
int ammo;
int keys;
weapontype bestweapon,weapon,chosenweapon; |
Below Add:
| Code: |
int silencer;
int silencertime; |
Step 1: Open WL_ACT1.C and change the puddle for example to this:
| Code: |
| {SPR_STAT_0,bo_alpo}, // puddle |
Step 2: Open WL_AGENT.C and do a search for GunAttack
You should see this:
| Code: |
void GunAttack (objtype *ob)
{
objtype *check,*closest,*oldclosest;
int damage;
int dx,dy,dist;
long viewdist;
switch (gamestate.weapon)
{
case wp_pistol:
SD_PlaySound (ATKPISTOLSND);
break;
case wp_machinegun:
SD_PlaySound (ATKMACHINEGUNSND);
break;
case wp_chaingun:
SD_PlaySound (ATKGATLINGSND);
break;
}
madenoise = true; |
Change the gamestate.weapon part to:
| Code: |
switch (gamestate.weapon)
{
case wp_pistol:
if (!gamestate.silencer)
{
SD_PlaySound (ATKPISTOLSND);
madenoise = true;
}
else
SD_PlaySound (YOUSNDSND); // Silenced Sound
break;
case wp_machinegun:
SD_PlaySound (ATKMACHINEGUNSND);
madenoise = true;
break;
case wp_chaingun:
SD_PlaySound (ATKGATLINGSND);
madenoise = true;
breakl
}
// madenoise = true; |
Step 3: Now do a search for case 1:
You should see this:
| Code: |
case 1:
if (!gamestate.ammo)
{ // can only happen with chain gun
gamestate.attackframe++;
break;
}
GunAttack (ob);
gamestate.ammo--;
DrawAmmo ();
break; |
Change it to this:
| Code: |
case 1:
if (!gamestate.ammo)
{ // can only happen with chain gun
gamestate.attackframe++;
break;
}
GunAttack (ob);
gamestate.ammo--;
switch (gamestate.weapon)
{
case wp_pistol:
if (gamestate.silencer)
{
gamestate.silencertime += 1; // Add to the wearing dowm
if (gamestate.silencertime >= 45)
{
gamestate.silencer = 0; // No more silencer
gamestate.silencertime = 0; // Wear down resets
}
}
break;
}
DrawAmmo ();
break; |
Step 4: Now go up to the GetBonus function and change bo_alpo to this:
| Code: |
case bo_alpo:
SD_PlaySound (BONUS1SND);
gamestate.silencer = 1;
gamestate.silencertime = 0;
break; |
Step 5: Open up WL_GAME.C and search for if (gamestate.lives > -1)
Add this above gamestate.health = 100; located just below the searched line
| Code: |
gamstate.silencer = 0;
gamestate.silencertime = 0; |
Now it looks like
| Code: |
if (tedlevel == false) // SO'S YA DON'T GET KILLED WHILE LAUNCHING!
gamestate.lives--;
if (gamestate.lives > -1)
{
gamestate.silencer = 0;
gamestate.silencertime = 0;
gamestate.health = 100;
gamestate.weapon = gamestate.bestweapon
= gamestate.chosenweapon = wp_knife;
[...] |
Step 6: Open WL_MAIN.C and do a search for NewGame
Add this below memset (&gamestate,0,sizeof(gamestate));
| Code: |
gamestate.silencer = 0;
gamestate.silencertime = 0; |
Compile and Make, now you should have a good silencer. _________________ ~Kyle Albert
Check out my TC: Click Here and Forum: Click Here |
|