Discussion:
Looking for a piece of code
(too old to reply)
Paul Tangfeldt
2003-10-15 19:55:39 UTC
Permalink
Well, I'm looking for a piece of code, or help to code, two things for my
circlebased mud.

First I want to code a greet system, so you won't see other players names
unless they've greeted you.

Second, I also want to code a bodypart system, where you can lose limbs etc
in combat.

Has anyone got any pointers I could look at for this?

Thanks, Paul Tångfeldt
Ryan
2003-10-15 22:48:11 UTC
Permalink
Post by Paul Tangfeldt
Well, I'm looking for a piece of code, or help to code, two things for my
circlebased mud.
First I want to code a greet system, so you won't see other players names
unless they've greeted you.
Second, I also want to code a bodypart system, where you can lose limbs etc
in combat.
Has anyone got any pointers I could look at for this?
Thanks, Paul Tångfeldt
These are how I would code it, but that doesn't mean it is necessarily the
"right" way.
for the greet system I have 2 methods:
method 1: create a new datatype like
struct known_person
{
char *name;
struct known_person *next;
};
simply add new nodes when someone greets themselves to another.
method 2: create a delimited string with all persons known.
the problems with both is that as the person meets more and more people,
you will get a lot of overhead unless you can create a faster means of
searching for persons that are known.

for the body parts. the easiest way is to create a new field I your
char_data or pc_data or what have you of type int. create a buncha of new
bitvectors (i.e. LOST_LEFT_ARM, LOST_RIGHT_ARM, etc)
create a function that is randomly decides where to cut something off, set
the bit, remove the proper equipment from the victim. then simply call the
function on a crit hit, spell, or whatever. also be sure to modify your
equip code so that if someone has lost a body part, they cant re-wear the
item. You may also want to modify your movement and regen code as well.
Alan Schwartz
2003-10-15 23:17:12 UTC
Permalink
Post by Ryan
Post by Paul Tangfeldt
Well, I'm looking for a piece of code, or help to code, two things for my
circlebased mud.
First I want to code a greet system, so you won't see other players names
unless they've greeted you.
Second, I also want to code a bodypart system, where you can lose limbs
etc
Post by Paul Tangfeldt
in combat.
Has anyone got any pointers I could look at for this?
Thanks, Paul Tångfeldt
These are how I would code it, but that doesn't mean it is necessarily the
"right" way.
method 1: create a new datatype like
struct known_person
{
char *name;
struct known_person *next;
};
simply add new nodes when someone greets themselves to another.
method 2: create a delimited string with all persons known.
the problems with both is that as the person meets more and more people,
you will get a lot of overhead unless you can create a faster means of
searching for persons that are known.
Perhaps a hash table associated with each player, keyed on the
canonical names of people they've met and storing the names
they've chosen to refer to them by. Good speed, at the cost
of some computation and memory.

See any data structures book for alternatives, though. :)

- Javelin

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
***@M*U*S*H (mush.pennmush.org 4201) | Alan Schwartz
| ***@pennmush.org
***@DuneMUSH, and Javelin elsewhere | PennMUSH Server Maintainer
=-------------------------------------------------------------------------=
PennMUSH God's Guide: http://www.pennmush.org/~alansz/guide.html
PennMUSH Source: ftp://ftp.pennmush.org/pub/PennMUSH/Source
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Continue reading on narkive:
Loading...