Archived from groups: rec.games.roguelike.development (
More info?)
The Sheep wrote:
> Dnia 22 Apr 2005 20:28:42 -0700,
> Brent Ritchie napisal(a):
>
> > The Sheep wrote:
> >> Dnia Fri, 22 Apr 2005 18:19:00 +0200,
> >> Filip Dreger napisal(a):
>
> >
> >> I want to separate the items and their kinds (physical objects,
> >> with attributes light weight, size, material, looks, position,
etc.),
> >> and the 'usages', being in fact things you can do with the items,
and
> >> having things like AC bonus, damage bonus, magical effect, etc.
> >> The usages further separated from equipment slots, which are
simply
> > flags
> >> telling whether your upper arm is already occupied.
>
>
> > Maybe flags aren't such a good idea? If you have alot of usages as
> > flags and most items only use then as a subset then maybe there's a
> > better way. I'm not sure what language your using, but if it can
> > refrence data structures you might consider giving each item a list
or
> > array of properties. If your using c or c++ then you could just
> > refrence a list of structs. An example would be.
>
> Yes, Iprobably expressed it wrong.
>
> Uasages are kept on a list in the item kind struct. Every item kind
has
> it's own list of usages.
>
> Flags are for equipment slots, they tell whether you can wear one
more
> t-shirt or don your armor.
>
> > If you have a bunch of these then you'll have all the information
for
> > all of the properties an item might have but only those properties
that
> > it has. Voila, no more switch statements, just search the list for
the
> > proper PropertyID and execute it's script. If you don't have
scripting
> > this could be a good reason to put it in, or you could make a
function
> > pointer (If your language of choice allows it).
>
> I don't want to go scripting every single property.
> Instead, there are several basic usage kinds (weapon, armor, magic
item,
> etc.) that have their attributes (damage bonus, AC bonus, magic
effect).
> What's the difference between switch statement and an array of
function
> pointer anyways?
Probably no difference in speed, but I you use switch statements for
more then a couple of things. It can turn to spaghetti prety quick, and
if you use function pointers you only have to iterate (or traverse, the
list with a sort). Iteration gets rid of switch statements, and is more
readable and compact(read 'Maintainable'), because loops tend to take
up fewer lines of code then switch statements.
>
> > I think your over analyzing here. Maybe you should take a step back
and
> > consider creating a basic inventory with only one item in mind.
>
> Done already.
>
> > Then
> > after you have that simple scenario working add another item of a
> > different sort and adapt as necessary.
>
> Done.
>
Glad to hear, I made these mistakes a few times.
> > I know what it's like to start
> > analyzing and try to figure every nuance. Waterfall thinking can be
> > exciting but hard to recover from if something dosen't go right.
>
> Well, it's pretty clear. You start with only one usage per item --
it's
> the same as with normal items, only you have a part of it's
description
> separated in another struct.
> Then you change it into a list, and done -- mostly UI changes.
>
> > Believe me I know, I've been through a total of 15 rewrites,
because of
> > this. Just something to consider.
>
> Don't tell me about rewrites. To get to this idea with usages took me
> several rewrites of item system.
>
> >> The items itself are offcourse also moved when you equip their
usages
> > --
> >> yopu have basically your 'eqipment' inventory and your 'treasure
bag'
> >> inventory. You can put something into your equipment inventory
even
> > when
> >> you don't have any of it's usages equipped -- it just indicates
> > you've got
> >> it strapped somewhere on you, or maybe put into pocket.
>
> > I think this could be a boolean flag, An item could be equipped or
not.
> > Sounds like a good candidate to me.
>
> It's nor really that inportant how you mark thje items that are
equipped.
>
> > Then you don't have the overhead of
> > managing two lists.
>
> What overhead?
> You mean those several bytes of additional memory? I can put
everything
> into constant size arrays, since there's a limit on the size of both
> lists.
>
> Or maybe you mean the CPU time needed to traverse the list?
> But with two lists I only traverse the one that's needed -- it takes
less
> time.
Maintnence overhead mostly, more code = more maintnence = more bugs(or
features if you prefer).
But having two lists _CAN_ be a dramatic overhead. First there is the
condition code, then the traversal. These would have to be performed
seperatly. for each item. Whereas, if you have one list, you eliminate
the conditional, if you use a flag you can traverse the list once and
change everything that needs to be changed. (If you log your changes in
the inventory screen, or something similar.) Plus less code
😉 .
>
> --
> Radomir @**@_ Bee! .**._ .**._ .**._ .**._ zZ
> `The Sheep' ('') 3 (..) 3 (..) 3 (..) 3 (--) 3
> Dopieralski
..vvVvVVVVVvVVVvVVVvVvVVvVvvVvVVVVVVvvVVvvVvvvvVVvVVvv.v.
Brent Ritchie