Thread: RPG Questions

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    195

    RPG Questions

    Lets say i wanted to make a simple rpg...

    Would i use Structs for items/monsters/magic? Is that the best choice?

    As for items, would there be a seperate struct for items and weapons since they use completely different variables (as weapons has to do damage etc)

    Please gimme some advice

    Thanks in advance

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    221
    if my brain wasnt stuck in bio mode, i'd help



    need any help with phylums?

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    221
    posted in another thread
    Code:
    typedef enum ITEM_TYPE { IT_WEAPON, IT_POTION, IT_ARMOR, IT_WHATEVER };
    
    struct ITEM {
        int minDmg; // damage minimum
        int maxDmg;// damage maximum
        int costbase;// cost to purchase and sell to be used in formula
        int craftxp; // xp you gain from crafting object
        char [25] name; // readable name of the object
        int id; // numerical value of item for quick comparisons
        ITEM_TYPE type; // enumerated type of item
    }
    
    
    ITEM gameItems[230]; 
    // might be a  good idea to have a function that can parse a file - with a specific format for item information to fill this array. That way you can modify all your game items in a text file with out recompiling.
    if ur using c++
    think of a class as a struct where u can check for stuff and what not. less checking code in ur actual code, its all abstractly hidden in the class

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    195
    But with that previous post, what woudl the struct look like for a potion for example? What would you do about the maxdamage and mindamage then?

  5. #5
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    you could turn that in to min health max health and that would be the bounds that it would randomly generate the new health with.......you don't *always* have to follow the naming convention , well, most of the time you should, but in this case you can make an exception

  6. #6
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Originally posted by KneeGrow
    But with that previous post, what woudl the struct look like for a potion for example? What would you do about the maxdamage and mindamage then?
    The original code posted was by me, and at the time I was basing the struct off of a weapon crafting rpg test. IN the middle of making the example struct to offer as help I added a feature to maek it more robust(I added the ITEMTYPE to the struct) but I forgot change the variable names to be move vague. THis would be a better example:

    Code:
    typedef enum ITEM_TYPE { IT_WEAPON, IT_POTION, IT_ARMOR, IT_WHATEVER };
    
    struct ITEM {
        int min; // minimum value - use is determined by item type. Weapons would equate this to damge
    		// potions would equate this to healing power
    		// armor might equate these to armorclass, weight or damge deflecting values
        int max;// maximum value - same as above
        int costbase;// cost to purchase and sell to be used in formula
        int craftxp; // xp you gain from crafting object - potions would call this alchemey
        char [25] name; // readable name of the object
        int id; // numerical value of item for quick comparisons
        ITEM_TYPE type; // enumerated type of item
    }
    
    
    ITEM gameItems[230]; 
    // gameItems would be the games list of all the items in the game.
    
    // else where in your player/character object
    
    ITEM inventory[230][100];
    // this is an array of an array. This limits the player to having 100 of every item.
    Of course this is a pretty simple item object. A real games item struct would probably be much bigger with a ton more variables that would or wouldnt be used in special item cases. Its up to you to come up with a suitable item object.


    Good luck.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  7. #7
    Registered User
    Join Date
    May 2003
    Posts
    195
    Originally posted by dbgt goten
    The original code posted was by me, and at the time I was basing the struct off of a weapon crafting rpg test. IN the middle of making the example struct to offer as help I added a feature to maek it more robust(I added the ITEMTYPE to the struct) but I forgot change the variable names to be move vague. THis would be a better example:

    Code:
    typedef enum ITEM_TYPE { IT_WEAPON, IT_POTION, IT_ARMOR, IT_WHATEVER };
    
    struct ITEM {
        int min; // minimum value - use is determined by item type. Weapons would equate this to damge
    		// potions would equate this to healing power
    		// armor might equate these to armorclass, weight or damge deflecting values
        int max;// maximum value - same as above
        int costbase;// cost to purchase and sell to be used in formula
        int craftxp; // xp you gain from crafting object - potions would call this alchemey
        char [25] name; // readable name of the object
        int id; // numerical value of item for quick comparisons
        ITEM_TYPE type; // enumerated type of item
    }
    
    
    ITEM gameItems[230]; 
    // gameItems would be the games list of all the items in the game.
    
    // else where in your player/character object
    
    ITEM inventory[230][100];
    // this is an array of an array. This limits the player to having 100 of every item.
    Of course this is a pretty simple item object. A real games item struct would probably be much bigger with a ton more variables that would or wouldnt be used in special item cases. Its up to you to come up with a suitable item object.


    Good luck.
    as for the struct that you posted, lets say i have an item that does no damage and is only used for one particular thing. For example this item is a Gem that can upgrade your weapons or a fishing rod to fish some fish. Would u just set item.min and item.max = to 0 since you arent gonna use those?

  8. #8
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    well, theoretically, if you aren't going to use those values, you shouldn't even have to bother with them at all

  9. #9
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Exactly. For example the quake 3 source code has a fairly huge entity struct that has variables for name, health, carried items, speed etc. etc. There are many cases where these variables arnt used. A map entity that spawns say quad or haste doesn't use the health variable, nor does it carry an items. In these special cases the variables simply arnt used. The functions that handle the struct list's loop through the item array checks what type it is, and sends it off to its appropriate handler. The appropriate handler ignores all variables that arn't needed.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem
    By ExDHaos in forum C++ Programming
    Replies: 12
    Last Post: 05-22-2009, 04:50 AM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  4. Char Variable Probelm
    By Krak in forum C++ Programming
    Replies: 1
    Last Post: 01-26-2003, 12:34 PM
  5. Lots of RPG questions...
    By Kyoto Oshiro in forum Game Programming
    Replies: 22
    Last Post: 07-21-2002, 10:47 PM