DieHard Wolfers Forum Index DieHard Wolfers
A Wolfenstein 3d Fan Community


  Hosted by: MCS & Areyep.com - Designed by: BrotherTank

Original Yahoo Forum - Die Hard Archives

AReyeP HomepageAreyep Homepage DieHard Wolfenstein BunkerDieHard Wolfenstein Bunker Log inLog in RegisterRegister Banlist FAQFAQ Search ForumsSearch

  Username:    Password:      Remember me       

[Tutorial] Deathwish's Bonus System
Page 1 of 1
DieHard Wolfers Forum Index -> Code Tutorials View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page BottomView Next Topic
Post new topicReply to topic
Author Message
Zombie_Plan
DieHard Wolfer
DieHard Wolfer


Joined: 12 Oct 2004
Last Visit: 07 Jun 2016

Topics: 101
Posts: 1614
Location: A hole in the wall
australia.gif

PostPosted: Wed Jan 19, 2005 6:05 pm
   Subject: [Tutorial] Deathwish's Bonus System
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

This tutorial will add an item that, when 30 of it is collected, rewards the player with 100% health, an extra life and 15000 points. Kind of like in ROTT.

Here we go:

Open VERSION.H and add this line:
::: CODE :::

// #define BONUS      // Bonus count item


This is in case you change your mind about using it, you can just turn it on and off by uncommenting/commenting it.

Open WL_DEF.C and search for secretcount. You should get taken to the gamestate structure. Underneath int attackframe, add this line:
::: CODE :::

#ifdef BONUS
   int      bonuscount;
#endif


This gamestate is used to count the amount of the item you collect. Now, while we are in this file, search for bo_gibs. You should get:
::: CODE :::

   bo_gibs,
   bo_alpo,
   bo_firstaid,
   bo_key1,
   bo_key2,


Add the following code underneath bo_gibs, :
::: CODE :::

#ifdef BONUS
                bo_bonus,
#endif


Now, open WL_AGENT.C and search for 'bo_alpo'. You should get something like:
::: CODE :::

   case   bo_alpo:
      if (gamestate.health == 100)
         return;

      SD_PlaySound (HEALTH1SND);
      HealSelf (4);
      break;


Now, underneath this case, add a case for bo_bonus:
::: CODE :::

#ifdef BONUS
   case   bo_bonus:
      SD_PlaySound (BONUS4SND); //Play BONUS4 sound when collected
      GivePoints (100);     //Reward player with 100 points
      gamestate.bonuscount++;     //Make the bonus count go up by 1.
      break;
#endif


When collected, the item will play the sound you hear when the crown is collected, you get 100 points, and the bonus count goes up by 1. Now we need to set the limit, so that once 30 is reached, it resets and you get the rewards. In WL_PLAY.C, search for FUNNY FACE:
::: CODE :::

      //
      // MAKE FUNNY FACE IF BJ DOESN'T MOVE FOR AWHILE
      //
      #ifdef SPEAR
      funnyticount += tics;
      if (funnyticount > 30l*70)
      {
         funnyticount = 0;
         StatusDrawPic (17,4,BJWAITING1PIC+(US_RndT()&1));
         facecount = 0;
      }
      #endif


Add this directly underneath:
::: CODE :::

/*===============================
== Count Bonus Items Collected ==
===============================*/
#ifdef BONUS
   if (gamestate.bonuscount == 30)    //if the bonuscount reaches 30
   {
      GiveExtraMan ();      //gain a bonus life
      GivePoints (15000);      //score 15000 points
      gamestate.health = 100;      //go to full health
      gamestate.bonuscount = 0;   //reset the bonuscount
   }
#endif


Time to add a sprite to use this attribute! Open WL_DEF.C and scroll down until you find:
::: CODE :::

//
// player attack frames
//
      SPR_KNIFEREADY,SPR_KNIFEATK1,SPR_KNIFEATK2,SPR_KNIFEATK3,
      SPR_KNIFEATK4,

      SPR_PISTOLREADY,SPR_PISTOLATK1,SPR_PISTOLATK2,SPR_PISTOLATK3,
      SPR_PISTOLATK4,

      SPR_MACHINEGUNREADY,SPR_MACHINEGUNATK1,SPR_MACHINEGUNATK2,
      MACHINEGUNATK3,SPR_MACHINEGUNATK4,

      SPR_CHAINREADY,SPR_CHAINATK1,SPR_CHAINATK2,SPR_CHAINATK3,
      SPR_CHAINATK4,


These are the defines for sprites. Add the following underneath:
::: CODE :::

#ifdef BONUS
      SPR_BONUS1,
#endif


Now, save and close. Open WL_ACT1.C and scroll down until you find:
::: CODE :::

{SPR_STAT_26,bo_clip2},         // Clip            "


Underneath, add:
::: CODE :::

#ifdef BONUS
{SPR_BONUS1,bo_bonus},         // Bonus Item
#endif


One last thing to finish the code side of things. Search for bo_25clip inside of WL_ACT1.C . You should get:
::: CODE :::

   case   bo_key4:
   case   bo_clip:
   case   bo_25clip:
   case   bo_machinegun:
   case   bo_chaingun:


Add the following directly underneath case bo_25clip:
::: CODE :::

#ifdef BONUS
   case   bo_bonus:
#endif


Save and build all. Now the code part of the tutorial is finished, give yourself a pat on the back. Now, open Flo-Edit (or whatever editor you use) and add one sprite to the end of the VSWAP, after the chaingun attack frames. Now insert the sprite of choice for the item.

Now adding the sprite into the map. First you need to define it. I will explain how to do this in both Mapedit and Flo-Edit. We will start with Flo-Edit, as it is simplest:

Enter 'Professional Mode' and choose 'Add New Record'. Under new ID add 72. Why? Because this is the case that the sprite is in (I'll explain later). Choose the record to be an object, Type the description as Bonus Item. Set the Database position to one after the Endgame trigger, 9015. Save, and now you can add the item into the maps.

Now, about this case. Flo-edit explains all:

Quote:

Different types of sprites are "spawned" by different engine routines. The spawner routine is ScanInfoPlane() from file WL_GAME.C. Look at the code snipped:

switch (tile)
{
case 19:
case 20:
case 21:
case 22:

SpawnPlayer(x,y,NORTH+tile-19);
break;

For static objects (starting at ID 23), the code is:

(...)
case 70:
case 71:

case 72: // This (predefined) is our new ID!
case 73: // Unused
case 74: // Unused

SpawnStatic(x,y,tile-23);
break;


I couldn't have explained it better. Now, should you use the last two cases as well, just add more:

::: CODE :::

                case 73: // FULL
                case 74: // FULL
   case 75: // New case define
   case 76: // New case define
   case 77: // New case define


Not too hard. Now, to define an object for use in Mapedit is harder, as it uses Hexidecimal instead of normal numbers. This means instead of say 500, it would say 01F4. To work out what number you need, open up Windows Calculator. Enter Scientific mode and type 72 with the decimal checkbox checked. When 72 comes up, hit the hex checkbox. 48 should come up. This means that in the OBJDATA.WL6 file, you should write:

0048

Now you need to add a symbol and name. I will use a white tidal symbol and call it Bonus Item:

0048 f00~ Bonus Item

Save and fire it up. You now have use of the item in Mapedit!

I hope people use this in their games. Don't forget to credit me if you do!

-Deathshead

_________________
Zombieskittles

Welcome to 2016, where DHW still thinks it is okay to ban the world's most popular email service provider, and I can't have an avatar over 10kb


Last edited by Zombie_Plan on Mon May 29, 2006 10:06 pm; edited 1 time in total
ZuljinRaynor
DieHard Officer
DieHard Officer


Joined: 17 Jan 2004
Last Visit: 30 Apr 2011

Topics: 19
Posts: 559
Location: New Jersey, USA
usa.gif

PostPosted: Thu Jan 20, 2005 2:29 pm
   Subject: Re: [Tutorial] Bonus item. Counts items
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I knew how to code this. But then again, it makes the game more Supernatural. You'll have to think before adding it.
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 12 Dec 2017

Topics: 46
Posts: 2291
Location: USA
usa.gif

PostPosted: Thu Jan 20, 2005 6:20 pm
   Subject: Re: [Tutorial] Bonus item. Counts items
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Couldn't this also be done? Unless I'm missing something...
::: CODE :::
#ifdef BONUS
   case   bo_bonus:
      SD_PlaySound (BONUS4SND); //Play BONUS4 sound when collected
      GivePoints (100);     //Reward player with 100 points
      gamestate.bonuscount++;     //Make the bonus count go up by 1.
      /*===============================
      == Count Bonus Items Collected ==
      ===============================*/
      if (gamestate.bonuscount == 30)    //if the bonuscount reaches 30
      {
            GiveExtraMan ();      //gain a bonus life
            GivePoints (15000);      //score 15000 points
            gamestate.health = 100;      //go to full health
            gamestate.bonuscount = 0;   //reset the bonuscount
      }
      break;
#endif

This just moves the code from the "funny face" stuff to where the object is being picked up. No other changes.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
Zombie_Plan
DieHard Wolfer
DieHard Wolfer


Joined: 12 Oct 2004
Last Visit: 07 Jun 2016

Topics: 101
Posts: 1614
Location: A hole in the wall
australia.gif

PostPosted: Sat Jan 22, 2005 2:06 am
   Subject: Re: [Tutorial] Bonus item. Counts items
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yeah, I wrote this for n00bs in a spare moment. I saw it in ROTT and thought 'This would be nice to do', and wrote it down as I went. As you have said before Adam

The code is not most optimized, and could be cleaned up...

or something along those lines.

_________________
Zombieskittles

Welcome to 2016, where DHW still thinks it is okay to ban the world's most popular email service provider, and I can't have an avatar over 10kb
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 12 Dec 2017

Topics: 46
Posts: 2291
Location: USA
usa.gif

PostPosted: Sat Jan 22, 2005 6:57 am
   Subject: Re: [Tutorial] Bonus item. Counts items
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

@Deathshead: I know what you mean. I meant no offense. Just offering a suggestion. Smile

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
Zombie_Plan
DieHard Wolfer
DieHard Wolfer


Joined: 12 Oct 2004
Last Visit: 07 Jun 2016

Topics: 101
Posts: 1614
Location: A hole in the wall
australia.gif

PostPosted: Sun Jan 23, 2005 10:30 pm
   Subject: Re: [Tutorial] Bonus item. Counts items
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

No offense taken, I'm just learning, so I can't code like you or BT Razz

_________________
Zombieskittles

Welcome to 2016, where DHW still thinks it is okay to ban the world's most popular email service provider, and I can't have an avatar over 10kb
Zombie_Plan
DieHard Wolfer
DieHard Wolfer


Joined: 12 Oct 2004
Last Visit: 07 Jun 2016

Topics: 101
Posts: 1614
Location: A hole in the wall
australia.gif

PostPosted: Wed Jan 26, 2005 3:32 pm
   Subject: [Tutorial] Deathshead's Bonus System
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

As a player of many games, I especially love the various bonuses you can get, especially in present games. However, Wolfenstein doesn't have very many. I present here, code that will increase the number of bonuses, and all can be customised to suit your needs. There are bonuses like Ammo Cruncher, Silent Assassin, and the bonusitemcount from my last tutorial. Also, I'll admit my coding may be a bit sloppy, and could be improved in many places, simplified, etc. But this is how I coded it, and it worked fine.

First things first before we start: BACKUP YOUR SOURCE! Nobody except yourself can be held responsible if something happens to your project.

On with the code. Open VERSION.H and add the following code:
::: CODE :::

// #define BONUSSTRUCTURE


If you want the bonus system your adding to be used, simply uncomment (remove //) the line. If you don't want it, comment the line.

Now open up WL_DEF.C and search for the gamestate structure. Underneath the gamestate section, add the following:

::: CODE :::

#ifdef BONUSSTRUCTURE

//----------------
//
// Deathshead's Bonus System
//
//----------------
typedef struct
{
   byte   bonuscount;   // Bonus Item. When 30 is collected- BONUS!
   byte   chainguncount;   // 40 enemies killed with chaingun in a row
   byte   silentkillcount;   // 40 enemies killed with knife in a row
   int   hardknifecount;   // 60 killed with knife in a row on hard
   boolean   noammobonus;   // Don't pick up any ammo on a level
   boolean   nohealthbonus;   // Don't pick up any health on a level
   int   justpistolbonus;   // Kill 100 enemies with a pistol only
   int   bosswithknife;   // Eliminate a boss with a knife
} bonustype;

#endif


This is where the variables that keep track of the bonuses are 'defined'. They are stored in what is known as a 'typedef structure'. This is where you 'define new data type names'. When you use this structure, you are actually 'defining a new name for an existing type', rather than creating a whole new type. It allows for more easier code editting as you can 'self-document' your code by giving each varialbe a descriptive name.

On reading the above code, you will notice that I use either byte, int, and boolean to define each bonus variable. While it wouldn't matter if you were to do something like name all of them int, they each have different effects and are used for slightly different purposes:

byte and int - Byte and int are used to track integers (whole numbers) for certain aspects of the game. Both do the same thing, but in different ways. int will track numbers from 'well beyond' -10000 and 10000. Byte only tracks integers from 0-255. Int also, if you're memory conscious, will take up 2 bytes of memory, where as bytes only take up 1. So, should your variable not go under 0 or any higher than 255, then a byte is the way to go. All the int variables in the Bonus Structure should, infact, be of byte type, so as to save memory, but for learning purposes, I left them as ints.

boolean - This is used for true/false statements in the code. I use it in this bonus system to keep track of whether ammo or health has been collected, but it is moreso used for on/off type things. You COULD instead use int/byte and make 1 true and 0 false, but this is much easier, and saves more memory.

The last point of interest, is the '#ifdef BONUSSTRUCTURE' and '#endif'. These are more preprocessors, that coincidentily work alongside the '#define preprocessor'. If translated to straight english, '#ifdef BONUSSTRUCTURE' reads 'IF BONUSSTRUCTURE is DEFINED, then this section will be compiled, overwise it will be skipped over'. '#endif' simply means the end of the section that is under question.

Now, we must rename the structure, so that it is simpler to recognize and edit. In WL_DEF.C, search for 'gametype', ignore the hit that comes after the gamestate structure, and look for the hit that looks like:

::: CODE :::

extern   boolean      ingame,fizzlein;
extern   unsigned   latchpics[NUMLATCHPICS];
extern   gametype   gamestate;
extern   int         doornum;

extern   char      demoname[13];


Add the following line(s) underneath the 'gametype gamestate' line:

::: CODE :::

#ifdef BONUSSTRUCTURE
extern bonustype   bonus;
#endif


This will make the variable(s) become refered to as 'bonus.variable'. This allows easier code editting, saves using the gamestate structure, and is appropriate. Also, notice I used the preprocessors again. Now, I reckon we can start creating the actual bonuses now.

THE BONUSCOUNT BONUS

Time for our first bonus. This bonus will reward the player with 100% health, an extra life and a whopping 10000 points when thirty of a special item is collected. And, this (along with all the other bonuses) is fully customisable, so you can change the rewards, the conditions, etc. This tutorial was placed not too long ago in the forum (by me! Razz), so this is almost a complete copy&paste job.

Open WL_DEF.C again and search for 'bo_gibs'. You should get:

::: CODE :::

   bo_gibs,
   bo_alpo,
   bo_firstaid,
   bo_key1,
   bo_key2,


Underneath 'bo_gibs,', add the following line:

::: CODE :::

#ifdef BONUSSTRUCTURE
bo_bonus,
#endif


This will define the stats for the object, which we will see now. Open WL_AGENT.C and search for 'bo_alpo'. You should get something like:

::: CODE :::

   case   bo_alpo:
      if (gamestate.health == 100)
         return;

      SD_PlaySound (HEALTH1SND);
      HealSelf (4);
      break;


Now, underneath this case, add a case for bo_bonus:

::: CODE :::

#ifdef BONUSSTRUCTURE
   case   bo_bonus:
      SD_PlaySound (BONUS4SND); //Play BONUS4 sound when collected
      GivePoints (100);     //Reward player with 100 points
      bonus.bonuscount++;     //Make the bonus count go up by 1.
      break;
#endif


When collected, the item will play the sound you hear when the crown is collected ((BONUS4SND)), you get 100 points (GivePoints (100)Wink, and the bonus count goes up by 1 (bonus.bonuscount++). Now we need to set the limit, so that once 30 is reached, it resets and you get the rewards. In WL_PLAY.C, search for FUNNY FACE:

::: CODE :::

      //
      // MAKE FUNNY FACE IF BJ DOESN'T MOVE FOR AWHILE
      //
      #ifdef SPEAR
      funnyticount += tics;
      if (funnyticount > 30l*70)
      {
         funnyticount = 0;
         StatusDrawPic (17,4,BJWAITING1PIC+(US_RndT()&1));
         facecount = 0;
      }
      #endif


Add this directly underneath:

::: CODE :::

/*===============================
== Count Bonus Items Collected ==
===============================*/
#ifdef BONUSSTRUCTURE
   if (bonus.bonuscount == 30)       //if the bonuscount reaches 30
   {
      GiveExtraMan ();      //gain a bonus life
      GivePoints (10000);      //score 15000 points
      gamestate.health = 100;      //go to full health
      gamestate.bonuscount = 0;   //reset the bonuscount
   }
#endif


So, now we have something you may/may not have seen before. The 'if statement' is used as a conditional. In this case, we have stated that 'IF' bonus.bonuscount reaches 30, 'THEN' the rewards inside the condition (inbetween { and }) are given.

Time to add a sprite to use this attribute! You do not have to do the next 4 steps if you plan to use an exiting sprite. Open WL_DEF.C and scroll down until you find:

::: CODE :::

//
// player attack frames
//
   SPR_KNIFEREADY,SPR_KNIFEATK1,SPR_KNIFEATK2,SPR_KNIFEATK3,
   SPR_KNIFEATK4,

   SPR_PISTOLREADY,SPR_PISTOLATK1,SPR_PISTOLATK2,SPR_PISTOLATK3,
   SPR_PISTOLATK4,

   SPR_MACHINEGUNREADY,SPR_MACHINEGUNATK1,SPR_MACHINEGUNATK2,
   MACHINEGUNATK3,SPR_MACHINEGUNATK4,

   SPR_CHAINREADY,SPR_CHAINATK1,SPR_CHAINATK2,SPR_CHAINATK3,
   SPR_CHAINATK4,


These are the defines for sprites. Add the following underneath:

::: CODE :::

#ifdef BONUSSTRUCTURE
      SPR_BONUS1,
#endif


Now, save and close. Open WL_ACT1.C and scroll down until you find:

::: CODE :::

{SPR_STAT_26,bo_clip2},   // Clip            "


Underneath, add:

::: CODE :::

#ifdef BONUSSTRUCTURE
{SPR_BONUS1,bo_bonus},   // Bonus Item
#endif


If you plan to use an existing sprite, just pick one (I use the ammo clip) and replace the line with the following:

::: CODE :::

#ifdef BONUSSTRUCTURE
{SPR_STAT_26,bo_bonus},   // Bonus Item
#endif


One last thing to finish the code side of things. Search for bo_25clip inside of WL_ACT1.C . You should get:

::: CODE :::

   case   bo_key4:
   case   bo_clip:
   case   bo_25clip:
   case   bo_machinegun:
   case   bo_chaingun:


Add the following directly underneath case bo_25clip:

::: CODE :::

#ifdef BONUSSTRUCTURE
   case   bo_bonus:
#endif


Save and build all. Now the code part of the tutorial is finished, give yourself a pat on the back. Now, open Flo-Edit (or whatever editor you use) and add one sprite to the end of the VSWAP, after the chaingun attack frames. Now insert the sprite of choice for the item.

Now adding the sprite into the map. First you need to define it. I will explain how to do this in both Mapedit and Flo-Edit. We will start with Flo-Edit, as it is simplest:

Enter 'Professional Mode' and choose 'Add New Record'. Under new ID add 72. Why? Because this is the case that the sprite is in (I'll explain later). Choose the record to be an object, Type the description as Bonus Item. Set the Database position to one after the Endgame trigger, 9015. Save, and now you can add the item into the maps.

Now, about this case. Flo-edit explains all:

Quote:

Different types of sprites are "spawned" by different engine routines. The spawner routine is ScanInfoPlane() from file WL_GAME.C. Look at the code snipped:

switch (tile)
{
case 19:
case 20:
case 21:
case 22:

SpawnPlayer(x,y,NORTH+tile-19);
break;

For static objects (starting at ID 23), the code is:

(...)
case 70:
case 71:

case 72: // This (predefined) is our new ID!
case 73: // Unused
case 74: // Unused

SpawnStatic(x,y,tile-23);
break;

I couldn't have explained it better. Now, should you use the last two cases as well, just add more:

::: CODE :::

                case 73: // FULL
                case 74: // FULL
      case 75: // New case define
      case 76: // New case define
      case 77: // New case define


Not too hard. Now, to define an object for use in Mapedit is harder, as it uses Hexidecimal instead of normal numbers. This means instead of say 500, it would say 01F4. To work out what number you need, open up Windows Calculator. Enter Scientific mode and type 72 with the decimal checkbox checked. When 72 comes up, hit the hex checkbox. 48 should come up. This means that in the OBJDATA.WL6 file, you should write:

0048

Now you need to add a symbol and name. I will use a white tidal symbol and call it Bonus Item:

0048 f00~ Bonus Item

Save and fire it up. You now have use of the item in Mapedit! This concludes the Bonuscount Bonus part of the tutorial. Next, we will work on the AMMO CRUNCHER bonus, 'bonus.chainguncount'.

AMMO CRUNCHER BONUS

In more recent games, like UT2004 and QUAKE3, they have awards where say, if you kill a certain amount of enemies with, say, the chaingun, you get an award. This is what we plan to achieve here. When 40 enemies are killed with the chaingun, then the player is awarded the AMMO CRUNCHER award, and is given full health, an extra life, and 15000 points. Also, should the player swap weapons and kill an enemy with the pistol, knife, or machinegun, then the count will reset. Now, on with the code, which is pretty simple.

!!WARNING!!
This tutorial is used with the thought that you are using WSJ's Ingame Messages. Should you not have it installed, refer to the correct tutorial.
!!WARNING!!

Open WL_STATE.C, and locate the 'KillActor' function. Inside each case (guardobj, ssobj, officerobj, dogobj, and mutantobj) add the following lines before 'break;':

::: CODE :::

#ifdef BONUSSTRUCTURE
   if (gamestate.weapon == wp_chaingun)
      bonus.chainguncount++;
   else
      bonus.chainguncount = 0;
#endif


Open WL_PLAY.C now and locate 'Count Bonus':

::: CODE :::

/*===============================
== Count Bonus Items Collected ==
===============================*/
#ifdef BONUSSTRUCTURE
   if (bonus.bonuscount == 30)       //if the bonuscount reaches 30
   {
      GiveExtraMan ();      //gain a bonus life
      GivePoints (10000);      //score 15000 points
      gamestate.health = 100;      //go to full health
      bonus.bonuscount = 0;      //reset the bonuscount
   }
#endif


Underneath the bonus we place earlier, add the following:

::: CODE :::

/*===============================
== AMMO CRUNCHER BONUS REWARDS ==
===============================*/
   if (bonus.chainguncount == 40)      //if chainguncount reaches 40
   {
      GiveExtraMan ();      //gain a bonus life
      GivePoints (15000);      //score 15000 points
      gamestate.healthe = 100;   //restore full health
      bonus.chainguncount = 0;   //reset the chainguncount
      GetMessage("AMMO CRUNCHER!!!");   //the message comes up
   }
#endif


Now, notice I haven't added an '#ifdef' BUT I HAVE added an '#endif'. That is for appearance purposes. Too many '#ifdefs' can eventually look really ugly, and since both conditions are next to each other, it is easier and neater to use the one perprocessor. Simply delete the earlier '#endif' (coloured red, so it doesn't get confused) and there you go.

Next post, I will give you the SILENT KILL bonus. This particular bonus will edit the chainguncount bonus, and therefore teach you more of the code. Feel free to post replies and opinions.

_________________
Zombieskittles

Welcome to 2016, where DHW still thinks it is okay to ban the world's most popular email service provider, and I can't have an avatar over 10kb
Guest




Last Visit:





PostPosted: Thu Jan 27, 2005 7:40 am
   Subject: Re: [Tutorial] Deathshead's Bonus System
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Cool. Maybe i`ll use a part of it in my mod.
lucky_foot
Don't Hurt Me
Don't Hurt Me


Joined: 05 Nov 2004
Last Visit: 19 Sep 2010

Topics: 13
Posts: 69
Location: Pennsylvania
usa.gif

PostPosted: Wed May 04, 2005 1:15 pm
   Subject: Re: [Tutorial] Deathshead's Bonus System
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Really good tutorial!

Can't wait for the next part to come out. Very Happy

_________________
JonathanS
Lucky foot Productions

www.luckyfootproductions.jtworld.net
Zombie_Plan
DieHard Wolfer
DieHard Wolfer


Joined: 12 Oct 2004
Last Visit: 07 Jun 2016

Topics: 101
Posts: 1614
Location: A hole in the wall
australia.gif

PostPosted: Mon May 29, 2006 10:05 pm
   Subject: Re: [Tutorial] Deathshead's Bonus System
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Ewww....I can't believe i was responsible for this O.O

I reckon I might look at this again...see what can be saved and what's gone mouldy.

_________________
Zombieskittles

Welcome to 2016, where DHW still thinks it is okay to ban the world's most popular email service provider, and I can't have an avatar over 10kb
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 3:20 ago.

Topics: 160
Posts: 8008
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Tue May 30, 2006 9:17 pm
   Subject: Re: [Tutorial] Deathwish's Bonus System
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Will this sort of bonus system run into any problems with saving/loading of games?
Codetech84
Code Master
Code Master


Joined: 12 Mar 2003
Last Visit: 15 Oct 2017

Topics: 22
Posts: 1281
Location: Rauma - Finland
finland.gif

PostPosted: Wed May 31, 2006 12:26 am
   Subject: Re: [Tutorial] Deathwish's Bonus System
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

He used the gamestate structure for the variables, so only problem with savegames is that your old savegames will not work, new savegames will work (Unless I'm missing something).

The update, or whatever it is, the one defined with "BONUSSTRUCTURE" will not work in savegames, check how gamestate is saved in wl_main.c
Add the marked lines carefully, and check to see is I missed something.


Add "bonus" structure right after each "gamestate" make sure you don't miss anything.

SaveTheGame:

::: CODE :::

<-- Skip -->

size += sizeof(gamestate) +

// Add me
#ifdef BONUSSTRUCTURE
  sizeof(bonus) +
#endif

<-- Skip -->

DiskFlopAnim(x,y);
CA_FarWrite (file,(void far *)&gamestate,sizeof(gamestate));
checksum = DoChecksum((byte far *)&gamestate,sizeof(gamestate),checksum);

// Add me...
#ifdef BONUSSTRUCTURE
  DiskFlopAnim(x,y);
  CA_FarWrite (file,(void far *)&bonus,sizeof(bonus));
  checksum = DoChecksum((byte far *)&bonus,sizeof(bonus),checksum);
#endif

<-- Skip -->


LoadTheGame:

::: CODE :::

<-- Skip -->

CA_FarRead (file,(void far *)&gamestate,sizeof(gamestate));
checksum = DoChecksum((byte far *)&gamestate,sizeof(gamestate),checksum);

// Add me...
#ifdef BONUSSTRUCTURE
  CA_FarRead (file,(void far *)&bonus,sizeof(bonus));
  checksum = DoChecksum((byte far *)&bonus,sizeof(bonus),checksum);
#endif

<-- Skip -->


Hope that's everything... Mr Green

Update: Fixed a little bug in the first code segment, check your code... Embarassed

_________________
Click here to visit KFH Games website!
*UPDATED* Spear of Destiny Reloaded
KFH Games on Facebook


Last edited by Codetech84 on Wed May 31, 2006 9:47 am; edited 2 times in total
insurrectionman
DieHard Mutant
DieHard Mutant


Joined: 07 May 2005
Last Visit: 09 Dec 2017

Topics: 86
Posts: 752
Location: Wisconsin
usa.gif

PostPosted: Wed May 31, 2006 8:44 am
   Subject: Re: [Tutorial] Deathwish's Bonus System
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

To save it in the CONFIG file you add it to the ReadConfig and WriteConfig functions in the WL_MENU.C file.

_________________
I'm back! I missed this community!
Youtube Channel: TreeSapThief

New Site: http://www.treesapthief.com
Twitter: @treesapthief
Codetech84
Code Master
Code Master


Joined: 12 Mar 2003
Last Visit: 15 Oct 2017

Topics: 22
Posts: 1281
Location: Rauma - Finland
finland.gif

PostPosted: Wed May 31, 2006 9:43 am
   Subject: Re: [Tutorial] Deathwish's Bonus System
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

There's no sense saving ingame data to config. I strongly advice to save only in savegame files.

_________________
Click here to visit KFH Games website!
*UPDATED* Spear of Destiny Reloaded
KFH Games on Facebook
insurrectionman
DieHard Mutant
DieHard Mutant


Joined: 07 May 2005
Last Visit: 09 Dec 2017

Topics: 86
Posts: 752
Location: Wisconsin
usa.gif

PostPosted: Wed May 31, 2006 2:17 pm
   Subject: Re: [Tutorial] Deathwish's Bonus System
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Oops, I just thought that from KyleRTCW's Menu tutorial, I would imagine there was something similar to that in the code.

_________________
I'm back! I missed this community!
Youtube Channel: TreeSapThief

New Site: http://www.treesapthief.com
Twitter: @treesapthief
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> Code Tutorials View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 1 of 1
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts [Code] Display Different Ammo Types on Statusbar-BrotherTank
Author: BrotherTank
1 2381 Fri Feb 11, 2005 9:18 pm
Zombie_Plan View latest post
No new posts [Code] Adding a Frames per Second Counter - Darkone
Author: BrotherTank
0 1703 Sat Mar 13, 2004 2:07 pm
BrotherTank View latest post
No new posts [Code] Changing an Enemies Attack Strength - BrotherTank
Author: BrotherTank
0 1969 Tue Jan 27, 2004 10:29 am
BrotherTank View latest post
No new posts [Code] Changing Weapons -CheckWeaponChange- BrotherTank
Author: BrotherTank
2 2700 Sun Oct 26, 2003 1:21 am
Guest View latest post
No new posts [Help] Different Enemy Dying Frames/Views
Author: Guest
7 607 Tue Jul 29, 2003 3:00 pm
Codetech84 View latest post
 
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


Copyright ©2003-2008 DieHard Wolfers
A Modified subBunker Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group