View Full Version: [Code] Adding a Silencer + Extras

wolfers >>Coding Alliance >>[Code] Adding a Silencer + Extras


<< Prev | Next >>

KyleRTCW- 01-17-2005
[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: int ammo; int keys; weapontype bestweapon,weapon,chosenweapon; Below Add: int silencer; int silencertime; Step 1: Open WL_ACT1.C and change the puddle for example to this: {SPR_STAT_0,bo_alpo}, // puddle Step 2: Open WL_AGENT.C and do a search for GunAttack You should see this: 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: 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: case 1: if (!gamestate.ammo) { // can only happen with chain gun gamestate.attackframe++; break; } GunAttack (ob); gamestate.ammo--; DrawAmmo (); break; Change it to this: 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: 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 gamstate.silencer = 0; gamestate.silencertime = 0; Now it looks like 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)); gamestate.silencer = 0; gamestate.silencertime = 0; Compile and Make, now you should have a good silencer.


Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.