> @show me
Object: $character [3,346 bytes]
Parents: $admin, $programmer, $user
$npc variables matching "*":
stat_str: 20
stat_int: 13
stat_dex: 15
stat_will: 10
$user variables matching "*":
task_connections: #[[54965, $login_connection_23564]]
> @program $npc.will() +access=pub
– Programming public method $npc.will() –
arg @args;
if (args)
stat_will = args[1];
return stat_will;
.
@eval me.will();
=> 10
@eval me.will(25);
=> 25
@eval me.will();
=> 25
> @grep +d .int $spells
Searching for ".int"…
$spells.invisibility(): 13 and 19
$spells.detect_invisibility(): 1, 4, 5 and 7
$spells.charm(): 6, 13, and 17
I've been lurking for awhile, reading articles and such. This is a great resource, thanks!
Question: I am playing with making a MUD. Really, just an exercise for myself to see how far I can get. Currently, I have it up and talking, a basic NLP and am working on command support, etc.
I am looking for opinions on implementing objects in the game.
What I have noticed, looking at a few mud codebases and reading lots of posts is that the common idea is to have a single object or struct to represent objects. Objects have names and descriptions attached to them and lots of bit flags to indicate attributes / behaviors.
The approach that I am thinking of taking is to have a shallow object hierarchy of object classes to maintain state common to every object type (location, etc). For attributes / behaviors I am thinking of having an object type to encapsulate these concepts and have the object instances own these. So if I need to see if I can "unlock" an object I check for that behavior in the object. If I need to see if it is already unlocked, I would check the same behavior. All attributes would be structured this way: Is it a weapon, wearable, light source, magical, etc. The behavior hierarchy would probably be deeper than the object hierarchy since that is where the depth of functionality of objects would be represented.
Thoughts? I like the idea of having anything be able to take on any behavior, in theory. So spells like the old D&D "light" spell could work by making anything a light source.
My only real worry is performance. Every time :
- Need to operate on an object I would have to scan this list
- See if there is a light source in a room, scan the lists of all objects in the room
- etc.
I am grateful in advance for any feedback.
David