Wolf Planet Forum Index Wolf Planet
We want you here!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Code] Adding a Silencer + Extras

 
Post new topic   Reply to topic    Wolf Planet Forum Index -> Coding Alliance
View previous topic :: View next topic  
Author Message
KyleRTCW
Moderator


Joined: 17 Jan 2005
Posts: 36
Location: United States

PostPosted: Mon Jan 17, 2005 4:56 pm    Post subject: [Code] Adding a Silencer + Extras Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Wolf Planet Forum Index -> Coding Alliance All times are GMT
Page 1 of 1

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001 phpBB Group

Chronicles phpBB2 theme by Jakob Persson (http://www.eddingschronicles.com). Stone textures by Patty Herford.