Thread: Prototype Encounter System

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    26

    Prototype Encounter System

    I am now working on an encounter system. I would like to be able to pre-define each monster type, its stats, level etc.. but i don't want to duplicate the combat function for each type of monster and for different levels.


    So my plan is kind of for it to go like this


    Game() > EncounterCheck() > Combat() > ExperienceCalculator() > Game()


    in game You choose an option that triggers encounter
    sends you to encounter check which loads specifc variables into global variable for that encounter type, then triggers combat function where you have your fight then triggers my experience levelup system to see if you need leveling etc. then returns back to game.



    My thoughts are mainly how do i upon triggering the encounter function load the exact section of code needed to adjust the variables the best i could come up with is a ton of encounter functions just to store the variable transfer routines that way i dont have to duplicate the entire combat function

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You should only need one function, and the rest is data

    Eg.
    Code:
    struct monster {
      int hitpercent;  // chance of landing a hit
      int maxdamage;  // max damage, if a hit is made
    };
    Then you do
    Code:
    monster wasp = { 100, 1 };  // always stings, but no big deal
    monster ogre = { 10, 1000 };  // lumbering brute, but very bad if it hits
    Your eval function would be
    Code:
    void eval ( monster *m ) {
      if ( m->hitpercent ) 
      // .... and so on
    }
    Add variables as necessary to parametrize all your monsters.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2010
    Posts
    26
    I have never used structs before, and the chance to hit and other calculations are already part of the combat routine. I plan on storing the monster information in global variables. The only things i need is to figure out which monster and lvl pull the information from the variables and run it through the combat function. Could you post a full example?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > Could you post a full example?
    Based on the size of the hole you've dug for yourself already - no.

    > I have never used structs before
    That's not an excuse for not starting now.

    > I plan on storing the monster information in global variables.
    If you plan on keeping with bad design, then there's nothing more I can do for you.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using system icons
    By @nthony in forum Windows Programming
    Replies: 1
    Last Post: 01-13-2007, 07:56 PM
  2. Replies: 13
    Last Post: 08-24-2006, 12:22 AM
  3. Linux database system needed
    By BobS0327 in forum Tech Board
    Replies: 7
    Last Post: 06-11-2006, 03:56 PM
  4. measuring system resources used by a function
    By Aran in forum C Programming
    Replies: 1
    Last Post: 03-13-2006, 05:35 PM
  5. BIOS system and memory allocation problem
    By beely in forum Tech Board
    Replies: 9
    Last Post: 11-25-2003, 07:12 AM