Jump to content
  • Advertisement

AmagicalFishy

Member
  • Content Count

    27
  • Joined

  • Last visited

Everything posted by AmagicalFishy

  1. Point me in the right direction, please! So, I've got a basic (albeit, over engineered  ) text-RPG system down. Rooms, with characters inside of them, and items inside of those. Characters can move, interact, get items, etc. There's a class that parses player-input-commands and is imported by the main game loop—so the basics are there. Now that I have all the basic systems down, I'd like to start creating and storing the world, but am at somewhat of a loss as to how to do this.   I'm using C++, and can think of several things: Hardcoding the creation of each object and its containers in C++. For testing purposes, this is working for now, but it's not a long-term solution   An SQL database - which I really want to use, just because I think it'd be a good learning experience). This would require learning a C++ interface for SQL (or maybe a non-SQL database like MongoDB). I'm looking at SQLite now.   Text files - which I don't want to use, but might be easier. I'd do something like have a "Rooms" file, a "Characters" file, and an "Items" file or something. I'd then have to figure out a way of getting C++ to read the appropriate lines from these files and use them to instantiate the respective objects   JSON, XML, etc. - which I don't fully understand, but think it's something that turns strings into numbers for easy storage and recalling. Might it be the interface through which Rooms will probably have to be hard "coded" at first (until I get to random-room generation!)  Items and characters (i.e. - monsters) I'd like to randomly generate.  So, what do you guys use, and how do you use/implement it? 
  2. AmagicalFishy

    Generating and initializing content for a text RPG

    Whoa. What language was it, if you don't mind my asking?   Just to clarify, "I hate it" referred to hating the floundering. I love C++ !
  3. AmagicalFishy

    Generating and initializing content for a text RPG

    That particular website has helped me out a lot, actually!    I've been programming for ~4 years indeed, so I understand the floundering around (though I only started w/ C++ a couple of weeks ago).   But god damned do I hate it. 
  4. AmagicalFishy

    Need to be taught to make a 3D MMORPG

    I don't know much about game engines, but isn't Unreal like... the EA of engines? (That is, you can't actually do anything without buying a bunch of game-engine "DLC" equivalents.)
  5. AmagicalFishy

    Generating and initializing content for a text RPG

    I'm spending a ton of time floundering around, struggling to get syntax correct—and not actually learning anything.  There is a distinct lack of good, succinct tutorials.
  6. AmagicalFishy

    Generating and initializing content for a text RPG

    Thanks, guys.   After a lot of research, and some benchmarking I've decided to go with rapidjson.   Now to figure it out!
  7. I'm building a text-RPG and, while everything's working fine for now, I'm concerned that my structure sucks. The primary objects in play are: Characters Rooms Items Notifiers Handlers (Attack, Item, and Movement handlers) World (stores handlers, notifiers and events) The basic process is something like this: Character.move() from Room A to Room B World registers a move-event MoveNotifier.notify() Registered handlers receive notification and do their thing (i.e. - MoveHandler takes the pointer to Character stored in a member of Room A and moves it to the respective member in Room B. DescriptionHandler prints out the appropriate Room B description, what items it contains, etc.) (I know the notifier-handler thing may be a bit overkill for a single-player text-RPG, but this is all practice for the big picture—please think of this as early practice for creating a larger, multi-player game.)   Here's my worry: Many of these objects store pointers to other objects. Character has a pointer to the Room in which it stands, while Room has a vector of pointers to every Character contained within it. This doesn't feel right. Part of me thinks that Character should know what Room it stands in, but another part of me wants every object to be totally independent and self contained. If everything should be self-contained, then my question is:   Is there a standard line of containment? Should Room know what Character is in it? Should a Character know what Item it has equipped? Should an Item know what Enhancements it's infused with?   If nothing should be aware of anything else, then should everything be stored in a relational database? I've been looking into object storage w/ MySQL or some SQL variant anyway.
  8. AmagicalFishy

    Is my object-structure bad? [Related to Text RPG]

    Excellent! Thank you, this was exactly the type of advice I was looking for (especially the one-way references).    It's totally doable to get rid of most of the Character verbs and group everything up in the handler. My purpose for having them was moreso for programmer-intuition. Something like: If the player types in "get item," then the resulting command sent to to the game would be Character->get(item). The Character.get method tries to associate the "item" string that the player typed in with an item-pointer in the inventory. If that is successful, it really does just pass along a message—and the handler does all the work of removing the item-pointer from the Room and putting it in Character->inventory_,  printing out a message like "You get [item]," etc. Otherwise, we get something like "You don't have that item."   I can similarly get rid of the World class entirely in favor of the Character class directly creating events. Or even having the Character class itself do all the work that the handler would otherwise do (but I don't think this translates well into multi-player, and don't really like the idea of the main classes [Room, Character, Item] having direct access to one another).    Maybe the best way to go about it would be: Rooms know what Character they contain (vector of pointers to const) Characters know what items they have (vector of pointers to const) Notifiers notify Handlers do the dirty work Characters directly create events (move events, item events, etc.) The most direct way would be just for Character A to call a method in Character B, but I don't like this idea (nor do I think it scales well to multiple characters interacting). The World class existed to be the structure in which the notifiers/handlers existed, but there's nothing wrong with them just free-floating.   Maybe I'm just thinking too much about structure? (I love thinking about structure, but at the same time I want to progress!)   haegarr, that sounds pretty awesome, actually. Let me make sure I have the idea straight:   Define an Interrelation container which just holds pairs of unique IDs, and call an instance of this "presence," for example. For a character to contain an item, the ID of the character and the ID of the item are combined and put in the table. For a room to contain an item, the ID of the room and the ID of the item are combined and put in the table. To check if a room contains a character, just see if the ID-ID key is in the table. Is this correct?
  9. AmagicalFishy

    Terraria clone. What do I need to learn

    Tangletail: I understand that parts of these fields play a role in randomly generating a world, but my point was that saying something like "you have to study advanced mathematics. Study trig, algebra, calculus, discrete mathematics..." isn't helpful. For example, discrete mathematics covers everything from set theory, to number theory, to information theory, to game theory—which are all huge fields in and of themselves, and wildly different. Some of the most prominent theoretical mathematicians study "discrete mathematics," while some of the earliest high-school classes teach it.   As much as I love and encourage learning of mathematics, I'd be sorry to see someone who just wants to randomly generate a world undertake such an enormous endeavor of study, thinking it will teach them how to do so. On the other hand, your most recent book suggestions are much better; they're specific to game design.   Might I suggest a process to OP, which I find pretty helpful: Start with (very) small things and work your way up. You know you want to randomly generate [complex] worlds. Start with simple, 2D cave generation (read the link that SimonForsman posted above) and slowly work your way up from there.
  10. AmagicalFishy

    Terraria clone. What do I need to learn

    OP: I'm not sure what your current education level is, but "Trig, algebra, calculus, discrete math, vector algebra, and algorithms" is a huge, totally non-specific list. Furthermore, you could take multiple classes in all of these (except maybe for algorithms) and still be totally clueless as to how to apply these to randomly generated worlds. Unless you're looking for the mathematics to be your primary focus, I think using the internet to find specific things will be a much better option than books.   Don't get me wrong, a good grasp of mathematics will always help, and if you want to learn all the mathematics required for a really in-depth, intuitive understanding of what's going on, then good! But you don't need to learn all of those things to be able to use an algorithm.
  11. I've been using a lot of std::map<std::string, int> or something. An example would be:   std::map<std::string, int> attributes_; attributes_["str"] = 5 attributes_["def"] = 5   I'm not sure I'm good enough at C++ yet to know, but using "std::string" as a key too much feels like it could go incredibly wrong in the future. What do you guys suggest for readable/usable code?   I considered a global enum, but that strikes me as worse than the string idea.
  12. AmagicalFishy

    What do you guys use as a key in RPG data structures?

    They're not, no.  I was just using them as an example, though.
  13. AmagicalFishy

    What do you guys use as a key in RPG data structures?

    If anyone reading this thread is similarly confused about decorators, this article really helped me. I revisited the (totally wrong) implementation of the Weapon wrappers that I attempted above. #include <string> #include <iostream> // Superclass class Item { public: Item() : durability_(100) {} void crumble() { std::cout << "Your item broke!\n"; } int durability_; }; // To-be wrapped class Weapon : public Item { public: Weapon() : Item() {} virtual void chip() { durability_ -= 6; } virtual void raise() { std::cout << "The sword is raised into the air\n";} }; // Decorator SuperClass class WeaponDecorator : public Weapon { public: WeaponDecorator(Weapon* baseWeapon) : baseWeapon_(baseWeapon) {} virtual void chip() { baseWeapon_->chip(); } virtual void raise() { baseWeapon_->raise(); } private: Weapon* baseWeapon_; }; // Decorators (which take after WeaponDecorator superclass) // Strong weapon halves the durability loss for chip() class StrongWeapon : public WeaponDecorator { public: StrongWeapon(Weapon* baseWeapon) : WeaponDecorator(baseWeapon) {} virtual void chip() { WeaponDecorator::chip(); durability_ += 3; } }; // Fire weapon sets the weapon aflame class FireWeapon : public WeaponDecorator { public: FireWeapon(Weapon* baseWeapon) : WeaponDecorator(baseWeapon) {} virtual void raise() { WeaponDecorator::raise(); std::cout << "It's on fire!\n"; } }; int main() { Weapon* baseWeapon = new Weapon; WeaponDecorator* enhancedWeapon = new StrongWeapon( new FireWeapon(baseWeapon)); enhancedWeapon->raise(); enhancedWeapon->crumble(); return 0; } The output:  The sword is raised into the air It's on fire! Your item broke! I'd explain more in-depth, but I'm pretty sure everyone in this thread already knows what a decorator is.  Now to go back and read the relevant posts.   Thanks for the help, everyone.
  14. AmagicalFishy

    What do you guys use as a key in RPG data structures?

    Sorry for being a little dense—I'm just not quite wrapping my head around this. (huehuehuehuehuehuehue) class Item { Item(std::string name) : durability_(100) { name_ = name; } void break() { std::cout << "Your item broke!"; } int durability_; std::string name_; }; // To-be wrapped class Weapon : public Item { Weapon(std::string name) : Item(name) {} void chip() { durability_ -= 5; } void rust() { durability_ -= 7; } } // Wrapper class StrongWeapon : public Item { StrongWeapon(std::string name) : Item(name) {} Weapon* baseWeapon = new Weapon; void chip() { durability_ -= 2; } }; // Wrapper class GlowingWeapon : public Item { GlowingWeapon(std::string name) : Item(name) {} Weapon* baseWeapon = new Weapon; void glow() { std::cout << "You're blinded by your own weapon!"; } }; Do I have the setup right?    The idea is that I can now have a strong weapon, a glowing weapon, or a strong-glowing weapon, right? I've seen code like this in all the tutorials, but it seems to either go on for 350 more lines, or just stop there.  I guess I'm not sure how to use these wrappers. How does a GlowingWeapon access the rust() method? Is it going to be something like: GlowingWeapon->baseWeapon->rust() ? Or just GlowingWeapon->rust() ? If it's the latter case, how (and why) does this work? How do I create a Strong, Glowing Weapon? Also, is it true that anything that takes a Weapon (or a pointer to a Weapon) will also be able to take a GlowingWeapon, or StrongWeapon (or both?)    I understand that "one class wraps another to change functionality," but beyond that I'm totally confused, and having a really hard time finding clear, succinct tutorials.   (Thanks for your patience, guys.)
  15. AmagicalFishy

    What do you guys use as a key in RPG data structures?

    So the wrapper only modifies the already-existing methods of the wrapped? That is, it doesn't add or remove any actual members?
  16. AmagicalFishy

    What do you guys use as a key in RPG data structures?

    Another question (pretty unrelated to the title of this thread: I've been reading a lot of the decorator and component patterns (I'd like to implement it for items. For example, while an inheritance pattern would look something like Item -> Equipment -> Weapon and Item -> Equipment -> Armor, I'd like to just wrap an item in an equipment wrapper, giving it stats, and then in a weapon wrapper, maybe giving it a damage-boost stat or something like this.   I'm not actually sure what wrapping entails, though. All the tutorials I see are... not very helpful. From what I've seen, it looks like putting an item object inside of a weapon object? Then accessing a weapon method  would be something like item->weapon->method()? I was under the impression that decoration should actually add the method, like an item wrapped in a weapon decoration would just be item->method()?. I'm having a hard time figuring out how to do this without inheritance. 
  17. AmagicalFishy

    What do you guys use as a key in RPG data structures?

    I do have a character.attack(target) function for my characters, actually!   This is the function that prompts the creation of an attack object. The closest parallels to real life I can think of for attack objects and handlers are: an attack object is the act of swinging the sword towards your target (with more strength, your attack object has an increase in damage). Attack handlers are the physics behind said swing, what happens when the swing hits an armored target vs. what happens when it hits an unarmored target, etc (if an attack handler doesn't consider strength, then it doesn't matter how high one's strength stat is, it won't affect what happens).    Perhaps it's my naiveté speaking, but, while programatically modelling things after their respective nouns or verbs is a good starting point—I think at some point more complexity is needed (i.e. - it seems that the easiest way to maintain a lot of freedom in creating different attacks is to actually have an attack object with some standardized structure).   Maybe this is the equivalent of asking a question like: "Is an attack the [more verb-y] action of swinging a sword, or do I consider it the [more noun-y] aggregation of causes-and-effects. In the latter case, I can model a branch falling from a tree and hitting a player as an attack without necessarily having to give the tree a target, or add an attackWithFallingBranch(target) method to the tree.
  18. AmagicalFishy

    What do you guys use as a key in RPG data structures?

    Ah!    I was planning to implement status-objects (buffs, debuffs, etc.) but I didn't think of following this same route with base-stats (str., def., etc.)    The way it works now is: - There are "attack" objects, which all inherit from a base attack class (and may be composed of some other things in the future)—they do all the calculations given a character's stats and some damage multiplier. This will make it easier to give specific characters specific abilities. When performing an attack, one of these objects is created, passed to an attack-event, and an attack-handler applies all the appropriate damage.  - Items have the same attribute-map as characters. When items are equipped, an iterator just adds the appropriate item stats to the character stats by key (equipping, picking up items, etc. is actually handled by a handler, too, since it requires things like removing an item from a room and putting it in the character's inventory.)   This might be an inefficient system, but it's my first game~   Would creating a separate object for each "set" of stats really be less overhead than just using a map? Considering that attacks use these stats, items affect these stats, etc. I didn't really have dynamism in mind when I started using maps, I just thought it was the easiest way to store a base-attribute integer.
  19. AmagicalFishy

    What do you guys use as a key in RPG data structures?

    I'm not trying to be dynamic, no, haha.    std::string as a key just feels wrong. I'm not sure why—but apparently it's fine, and I'm still using it. 
  20. AmagicalFishy

    What do you guys use as a key in RPG data structures?

    I should use an unordered map! The issue with the global enum is that I also use strings as keys to a map which keeps track of what item is equipped where.  Also, using an unordered map would lessen the changes I'd have to make to any codes using iterators. ;)   Thanks, by the way. I totally forgot unordered_map was a thing.
  21. I've begun making a text-RPG by creating the general logic of objects (rooms, creatures, items), but haven't much interaction between items yet. I can think of a couple of ways to do this, but am not that sure which is best.   Consider the situation wherein a creature attacks another creature (say Creature A attacking Creature B). It's easy for the objects to interact if we call a method in Creature A that directly affects Creature B. Something like:   Creature A::attack( Creature B ) {     Creature B.changeHP( - 5 ); }    While this is easily implemented, part of me doesn't think it's... good. What I'd like to do is have there be something like a middle-man that sees Creature A's attack, that Creature B exists, then applies the results of Creature A's attack to Creature B (is this what an event-handler does?) If instead that is a better idea—what is the general implementation of such a structure? Do Creature A's methods throw some flag, and send data to the "world," and then the world applies this to Creature B accordingly?   Eventually, I'd like to move on from a simple text-RPG. That is, even if one isn't typically considering these things when creating a text-RPG, I think this is a good opportunity to familiarize myself with them. In another thread, someone mentioned "designing the game as a client-server application and running the single player game in localserver host." Maybe that is a little bit above my ability (for now), but what paradigm can I embrace that would best accommodate such a thing?   Right now, everything is still pure from-scratch (except STL) C++; I assume it will be for a while. But, at what point should I really start considering moving to something more specific and less fundamental? When I get into graphics? Or is networking, even, something that I shouldn't even try tackling without some kind of heavy tool-set?
  22. Thank you so much for this post, dmatter.   Out of curiosity: How does this work in games with many creatures and many interactions? I imagine that all interactions aren't piped through a single "world-update," right? Are there separate event handlers for each, unrelated interaction? (i.e. - Creatures A, B, and C are in one battle, while Creatures D, E, F, and G are in another, nearby battle).
  23. God damn, gentlemen, that's exactly the type of stuff I was looking for—no more, no less.   Thank you!   Are there implementations of Inform7 for something other than text-games? Say, do video games use it aswell? (It seems like it'd be useful)
  24. I have rooms, actually! Is this the type of strategy that other developers use?
  25. I know—I just decided that having actual code would have detracted from the question, so threw up a sort of psuedo code.   Now that I look at it again the spaces in "Creature A" and "Creature B" do make it look like I'm returning a "Creature" type, haha. I meant it to be a single name, and should have probably put "Creature_A" or something.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!