Thread: Have a quick question

  1. #1
    DJ who loves Goa Trance!!
    Join Date
    Sep 2004

    Have a quick question

    I am making a Text RPG and have a kinda newbish question. If I was to use bool in a Monster Class to see if the monster is unique or not, would that be a good way? Or is there an easier way?

  2. #2
    Registered User
    Join Date
    Mar 2003
    It'd work, but there are better ways to store information about monsters. The way I do things is store all information as an integer, that's 32 bits, where each bit can either be 1 or 0, true or false, and relates to a particular trait of the monster.

    If you don't know how to, I can show you how to change the values of each bit in an integer.
    See you in 13

  3. #3
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Thats how i would do it, theres also alot of information on text rpg's if u run a board search

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Unique as in ? A bool will only be true or false and to say a monster is unique is kind of a misnomer since all monster classes will be derived from base classes. So perhaps they are unique in their characteristics but at the core code level they are simply identical types.
    It would be cool to generate some sort of system that would generate unique monster classes from already known bases or derived's but that is extremely complex code.

    You could create a base monster class with base characteristics that they all share and then derive from that base for new monsters. The bool flag would only indicate if their characteristics were alike, however you would have to link the bool to the baseline of their characteristics. Say monster1 starts out with a defense of 5 and monster2 has a defense of 6. When monster1 levels up to level 6 your bool would falsely claim that neither monster was unique if it checked their current characteristics. So you probably want to keep a copy of the starting point or starting values of all monsters and then the bool function would look at those.

    Again though if these are derived from the same class you MUST compare attributes only, not types.

    operator BaseMonster::IsUnique == (BaseMonster &Monster2)
      return ((Attack==Monster2.Attack) & (Defense==Monster2.Defense));
    This is just a short sample of a way to do it. This will compare the attributes of the two monsters. If either attribute is not exactly the same as the other it will return false.

    The options are:

    true=1, false=0

    true & true = true or 1 & 1 = 1
    false & true = false or 0 & 1 =0
    true & false = false 1 & 0 = 0
    false & false = false 0 & 0=0

    The only one that might be incorrect is false and false. This might return true since both are false, but I think both must be true for an AND to return true. In this case both are false so while they are identically not true, they are not identically true.

    Check the MSVC 6 help file for a good explantion of the available logical operators and their associated truth tables.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very quick math question
    By jverkoey in forum A Brief History of
    Replies: 8
    Last Post: 10-26-2005, 11:05 PM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM