Game Development Community

SimSets/SimGroups in text gaming

by Derek Kittrell · in Torque Game Builder · 05/14/2005 (4:05 pm) · 2 replies

I've finally had some time to poke around a bit with my text game idea and I have a question.

Currently, when a client connects using a telnet client, the client object is stored in a SimSet. Then, when they successfully log in (standard name/password routine), they are added to a SimGroup which represents a room. I was initially using the built-in ClientGroup, but you can see what problem that would pose in using my own SimGroups for rooms.

Anyhow, I decided to try doing things this way because it seems to make pretty good sense. If I have room1 and the player wants to go to room2, the player object would simply be added to room2 (after any necessary checks to make sure this is possible). This would also work rather easily for the item and inventory system.

Now onto the question.. Does anyone agree or disagree with using this method, and for what reasons? If you disagree, what options do you think would be preferable, and why?


Any comments would be greatly appreciated.

#1
05/15/2005 (7:24 am)
Yes, there is one major flaw with your idea:

Objects can only belong to a single SimGroup at any one time. However, this is easily fixed: change your rooms from using a SimGroup to a SimSet.

The reason for this constraint on SimGroups is that in Torque, SimGroups are a special implementation of SimSets that guarantee that if you delete a SimGroup, everything that is a member of that SimGroup is deleted as well. SimSets do not have this functionality, so you are free to have a SimObject in as many SimGroups as you like.

Other than that, the idea is fine--and a great use of SimSets. If you happen to be referencing any old MUD code for what you are working on, SimSets are the equivalent of the various linked lists used in many (DIKU/Merc) code bases--except that SimSets do not guarantee consistent order within the set by default. However, the ease of use is quite better than a basic linked list implementation due to the fact that the Sim itself handles a lot of association and cleanup issues for you automatically due to it's implementation.
#2
05/15/2005 (11:39 am)
The universal player list is stored as a SimSet, so I have a list of clients that does not get altered when moving clients around. Say there is a broadsword on a table in a room, represented by the broadsword SimObject in the table SimGroup in the room SimGroup. If the player attempts to "get" the broadsword, after checking to make sure he can carry it, we add the broadsword to the player's inventory, and it is automatically removed from the table group. This is probably just a minor convenience, so if there is something that I'm missing here that would make this a bad idea, just let me know.