Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert individual monsters to subclasses of Monster #14

Open
cwc opened this issue Mar 14, 2013 · 6 comments
Open

Convert individual monsters to subclasses of Monster #14

cwc opened this issue Mar 14, 2013 · 6 comments
Labels
Milestone

Comments

@cwc
Copy link
Owner

cwc commented Mar 14, 2013

  • Each monster should have its own class (e.g. MonsterHornet.cpp)
  • The Monster class should be made more generic (i.e. have virtual methods for attacking the player that will be overridden)
  • Each monster should subclass Monster in order to provide e.g. specialized attacks, movement behavior, etc.
@vsrz
Copy link
Contributor

vsrz commented Mar 14, 2013

First, I like your idea. Just a design question though: Why wouldn't we just load that data from a file instead rather than making new monster objects in code for each individual monster? Obviously you have your special monsters that cause events, but in general it seems like that would be easier to add more generic monsters by reading data from a separate file rather than writing a brand new child class for every mob.

@cwc
Copy link
Owner Author

cwc commented Mar 18, 2013

Sorry I'm just now getting around to replying.

Dynamic NPC/object loading actually is something I'd like to implement at some point. There are a lot of benefits, not least of which is ease of modding. For now though, I think as part of the initial refactoring to an object-oriented model it's easiest to keep things hardcoded. Dynamic loading is a pretty big feature to add, which I'm generally trying to avoid at this point (though obviously not completely freezing on features, yet).

@cwc
Copy link
Owner Author

cwc commented Mar 19, 2013

Created #17 for dynamic NPC discussion.

@vsrz
Copy link
Contributor

vsrz commented Mar 19, 2013

Should this same technique be used to abstract the object class? Each item has its own effect but based on the way it's implemented, each item can only produce one effect. It's effect ID is sent to a huge switch statement which calls the corresponding effect. That seems wrong to me but I can't see another way to do it. Suggestions? See vsrz@b6cad93 Omega/src/Thing.h

@cwc
Copy link
Owner Author

cwc commented Mar 19, 2013

Yes, I need to create an issue for individual Object subclasses. My thinking was along the lines of: Object defines a virtual use method that takes various parameters such as a user and target (depending on the context they might be the same, or one might be null - potentially tricky but can probably be worked around), then the use method is overridden by the subclasses.

It looks like you've got it headed in the right direction with that commit. Let me read it more thoroughly; I'll leave further comments there.

@cwc
Copy link
Owner Author

cwc commented Mar 19, 2013

Created #18 for individual object/item classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants