Prototype Encounter System

This is a discussion on Prototype Encounter System within the Game Programming forums, part of the General Programming Boards category; I am now working on an encounter system. I would like to be able to pre-define each monster type, its ...

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

    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,590
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Aug 2010
    Posts
    16
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,590
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 06: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, 04:35 PM
  5. BIOS system and memory allocation problem
    By beely in forum Tech Board
    Replies: 9
    Last Post: 11-25-2003, 06:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21