• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
vincero

Item system - design patterns

6 posts in this topic

Hello,

I want to design an easily extensible item system for my game where I don't need to modify existing code much. I want to add items with new effects on the fly.

Traits my items have in common:

A name,
a description,
an npc sell price,
if it can be equipped,
required level,
if it is usable in battle,
if it is usable outside of battle,
a cooldown

So I can encapsulate this already into a class. But now there are item effects.

Example:
heals x health points,
heals x mana points,
removes debuff x,
adds buff x,
gives x stat points on equipping,
has x% chance to create some other effect when equipped,
etc.

And those can be combined like: heals x health and mana points. The first four are examples for effects a usable item can have while the last two are examples for effects equipable items can have.

The idea behind it is that I have this structure in a database as well and I can add a new item with a new effect combination in my database, my code reads this then and builds it together into a new fancy item, without me having to modify much. The only time I need to modify my code is when I add new effects obviously.

How would you put this together in design pattern(s)? I am writing my game in a language which has support for OO obviously.
0

Share this post


Link to post
Share on other sites
I'd recommend an effect class that the item class has a pointer to. The effect class is the base class for all the different kinds of desired effects. You could have a list of effects in the item class instead of a single pointer to chain effects together, but that might complicate things. Either way, separate the effect from the item and make the interface for enabling the effect generic so it can be enabled in a consistent manner.

Cheers,

Bob
2

Share this post


Link to post
Share on other sites
makeing one myself and as far as iv seen you will need an item object with a list of effects of each one.
the effects are generic and you dont even have to name them or make them all in advance thats the work of you item creator.

now the effects need nothing unless you adress them BUT you can make new effect any time you need.
0

Share this post


Link to post
Share on other sites
Are you interested in generating them on the fly (I mean, randomly) or you're going to make the objects one by one (by a human)? Or perhaps use them as templates?
I worked on an RPG-oriented game system years ago with a friend for his MUD. I don't remember much but in the end we had to classify all the possible effects in advance to resolve cross-dependancies when generating.
So for example, if an object dealt fire damage, it couldn't roll a ice damage enchant (he decided fire would negate ice).
Similarly, we had to merge damage bonus such as +30%, +20% ends up being +50% and not (130*120=+56%).
Stacking was surprisingly involved as we needed to figure out if similar effect would stack linearly (+), negate each other, not stack, or combine by (*).

Besides generation, game play was relatively straightforward, we designed a set of signals/callbacks/events to be broadcast to each object. They took care of implementing the per-object requisite testing, checking against various conditions etc.
I have to admit the way we made combat work was pretty ugly. I'd probably make it nicer nowadays but at the time I was really unsatisfied by it, magic such as "regen" or anything else enabling lasting effects went through several holes in the design. Edited by Krohm
0

Share this post


Link to post
Share on other sites
Separate item system and effect system, don't mix them up.

The effect system manages a collection of effects.
Each effect has a unique ID (the ID can be either string or integer, whatever), and implement an interface, e.g IEffect.
IEffect has a function, something like, void perform(Item * item);
When you add new effect, just implement IEffect and add the interface to effect system.

The item system manages a collection of items.
The items can be read from database, or added by code.
An item holds a collection of effect IDs.
When you want to do the effect, just ask the effect system with the effect ID, and the call IEffect::perform with the given item.

With this design, your item only knows an effect ID. It doesn't care what's the effect, or how effect works. Edited by wqking
0

Share this post


Link to post
Share on other sites
When I was messing around with a magic the gathering clone I used a sortve hardcover + scripted solution. I boiled everything down to; cost - what is needed to use the ability. Target - what kind of objects can it effect. Effect - what the ability does.

Effects were hardcover as a series of functions. Ie DealDamage(target&, amountOfDamage). I had a separate functions that would validate cost, target, etc.

If every thing passed another function would parse the effect and pass its parameters and the desired target to the abilities corresponding function which would apply the actual effect.
0

Share this post


Link to post
Share on other sites
[i]You could use a combination of what was mentioned above with EffectID but enumerate them with names like what is used in most common games now like Borderlands, and Diablo, etc.. where your Items have names like Fiery Vampiric Longsword of Flight. Then you have 3 effects Fiery, Vampiric, and Flight, which can fall into 3 different categories that have various levels like say: Hot, Flame, Fiery, Inferno, Hellfire for example and then you can have an exclusion list so you couldn't have a Fiery Blizzard Mace, etc...[/i]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0