Two more changes I would suggest for the stock code

Login to reply  Page: « < 1 of 1 > »
14 Jul 2010 - 21:542849
Two more changes I would suggest for the stock code
First up is the wonderful act() function.
If for some reason you HAPPEN to send a vict_obj to act without also sending it an obj or ch pointer as well, it will puke with this error message in your syslog:
Quote:
SYSERR: no valid target to act()!

Which isn't exactly 100% true since we've established that there is one valid target to act, but in a case that requires two of them.

My fix, in comm.c replace:
  if (ch && IN_ROOM(ch) != NOWHERE)
    to = world[IN_ROOM(ch)].people;
  else if (obj && IN_ROOM(obj) != NOWHERE)
    to = world[IN_ROOM(obj)].people;
  else {
    log("SYSERR: no valid target to act()!");
    return;
  }

With:
  if (ch && IN_ROOM(ch) != NOWHERE)
    to = world[IN_ROOM(ch)].people;
  else if (obj && IN_ROOM(obj) != NOWHERE)
    to = world[IN_ROOM(obj)].people;
  else if (vict_obj && !ch && !obj) {
    log("SYSERR: act() received vict_obj without a valid ch or obj");
	return;
  } else {
    log("SYSERR: no valid target to act()!");
    return;
  }

Which simply returns a more descriptive error message. It still fails, though this could be coded around by finding out if vict_obj is a char or obj and going to = world[IN_ROOM(vict_obj)].people, however that seems messy and weird to me, since we really shouldn't have a victim without someone or something acting upon said victim.




The second item on today's agenda... keys. On several MUDs I have been on there has been a serious problem with people hoarding keys, especially ones that wont load again if they're in game. This is how I've solved this issue. Also, I would note that I have no idea if the tbaMUD codebase has already implemented something to solve this issue, however I feel my solution is far more elegant than other solutions I've seen... such as dissolving the key on use which is annoying if you need the same key for multiple things. Feedback appreciated, but pointless criticism isn't.

in db.c reset_zone():
In variable declarations add: struct obj_data *key; /* For key purging */
Now, below the variable declarations add:
	/* Purge all keys for this zone that are on a player or in a room */
	for (key = object_list; key; key = key->next) {
		if (GET_OBJ_TYPE(key) == ITEM_KEY && GET_OBJ_VNUM(key) >= zone_table[zone].bot && GET_OBJ_VNUM(key) <= zone_table[zone].top) {
			if (key->in_room && !key->carried_by && !key->worn_by && !key->in_obj) /* Purge a key from a room */
				act("$P dissolves into nothingness.", TRUE, NULL, key, NULL, TO_ROOM);
			if (key->carried_by && !IS_NPC(key->carried_by)) /* Purge a carried key */
				act("$p dissolves into nothingness.", TRUE, key->carried_by, key, NULL, TO_CHAR);
			if (key->worn_by && !IS_NPC(key->worn_by)) /* Purge a worn key */
				act("$p dissolves into nothingness.", TRUE, key->worn_by, key, NULL, TO_CHAR);
			if (key->in_obj) { /* Purge a key from inside another obj */
				for (obj = key->in_obj; obj->in_obj == NULL; obj = obj->in_obj) {} /* Get to the top of the container tree... */
				if (obj->in_room)
					act("$p dissolves into nothingness.", TRUE, NULL, key, NULL, TO_ROOM);
				if (obj->carried_by && !IS_NPC(obj->carried_by))
					act("$p dissolves into nothingness.", TRUE, obj->carried_by, key, NULL, TO_CHAR);
				if (obj->worn_by && !IS_NPC(obj->worn_by))
					act("$p dissolves into nothingness.", TRUE, obj->worn_by, key, NULL, TO_CHAR);
			}
			extract_obj(key);
		}
	}


__________________
Owner/Coder/Head Admin
Caer Dubrin
14 Jul 2010 - 22:192851
An idea just occurred to me, it may be a good idea to add bool dissolve_keys = TRUE/FALSE to config.c and the appropriate cedits for it as well, and then only perform the dissolve loop IF we're dissolving keys.


__________________
Owner/Coder/Head Admin
Caer Dubrin
14 Jul 2010 - 22:252852
I like the keys solution.

I've created a system that allows pre-resets and post-resets. This is simply code executed before and after a zone reset. A pre-reset can also prevent a normal reset from occurring.

Because my pre/post-resets are zone dependant, by putting your key removal code into a function, and then calling it only for zones that have rare keys, it means that players wouldn't just lose all their keys.

If you are interested in my pre/post-reset code, I'd be happy to share. I use it mostly for my 'Gauntlet' zone, to reload mobs only in empty rooms, but it's proved useful for other things too.

Of course, making rare keys !RENT also helps to control hoarding, unless every player owns a 'house' to keep keys in, and your MUD never reboots or performs a copyover.


__________________
14 Jul 2010 - 22:362854
Thats cool Jamdog, but I'm personally concerned with ALL keys, because I don't want players able to use keys from previous zone resets to rush past someone else who has just started a zone and is fighting to get the key. Once a zone resets you should start it again from the beginning, not rush past early stuff to the end.


__________________
Owner/Coder/Head Admin
Caer Dubrin
14 Jul 2010 - 22:392856
Oops, forgot to say that yes I'm interested in seeing your pre/post code, though I probably wont use it :)

I'll definitely add it to my "maybe" folder of snippets though in case I need it in the future. No sense reinventing the wheel!


__________________
Owner/Coder/Head Admin
Caer Dubrin
14 Jul 2010 - 22:482857
Quote ralgith:
Oops, forgot to say that yes I'm interested in seeing your pre/post code, though I probably wont use it :)

I'll definitely add it to my "maybe" folder of snippets though in case I need it in the future. No sense reinventing the wheel!

Cool, I'll put together a patch for you, and post it here...


__________________
14 Jul 2010 - 23:002858
Quote ralgith:
I'll definitely add it to my "maybe" folder of snippets though in case I need it in the future. No sense reinventing the wheel!

Where do you get your snippets from? You may already be aware of these, but the following are good resources for tbaMUD snippets:
My DG-Scripts Resource Site
CWG Forums Suggestions forum
Are there other good snippets resources that you know of?


__________________
15 Jul 2010 - 00:172859
I'm aware of your site hehe, I point my builders to it for DG Script reference.


__________________
Owner/Coder/Head Admin
Caer Dubrin
15 Jul 2010 - 00:592860
Bah, and then I didn't answer your question. I get snippets all over the web. And not just for CircleMUD base either, I've converted many Merc, ROM, ROT, SMAUG, and DBZMUD snippets to Circle as well, since they're all Diku based it isn't too hard.

I've used the original CircleMUD ftp/website
MudBytes.org
Here @ tbaMUD
http://www.andreasen.org/snip.shtml
http://www.mudmagic.com/codes/
http://islands.freehosting.net/snippets.html
http://www.auricmud.com/snippets/
http://www.aardwolf.com/lua/lua-howto.html
http://www.teamsaber.com/john/snippets/
http://smaugcodesnippets.blogspot.com/
http://www.dystopiamud.dk/snippets.php
http://midboss.eotmud.com/code.html
http://thevedic.net/mud/new/


__________________
Owner/Coder/Head Admin
Caer Dubrin
15 Jul 2010 - 15:142868
I've just uploaded a patch which includes:
* My Gauntlet zone - players love this one
* pre-resets and post resets (which are used by the Gauntlet)
* rank command

You can grab it here.


__________________
15 Jul 2010 - 15:272869
Jam, if you want to host the my_str files I made go ahead :)


__________________
Owner/Coder/Head Admin
Caer Dubrin
15 Jul 2010 - 15:352870
My DG-Scripts site's snippets page has an "Add a Snippet" button just below the folder tree - feel free to upload any snippets you think other people might enjoy.

Snippets need to be approved by a site admin (Me, Rumble, Welcor or Fizban) before it appears on the site, so if you PM/email/mudmail one of us when you post one, we can 'activate' it. ;)


__________________
15 Jul 2010 - 17:302875
Quote Jamdog:
My DG-Scripts site's snippets page has an "Add a Snippet" button just below the folder tree - feel free to upload any snippets you think other people might enjoy.

Snippets need to be approved by a site admin (Me, Rumble, Welcor or Fizban) before it appears on the site, so if you PM/email/mudmail one of us when you post one, we can 'activate' it. ;)


Done and Done.


__________________
Owner/Coder/Head Admin
Caer Dubrin
15 Jul 2010 - 17:552876
Quote ralgith:

Done and Done.

Cool, I've activated it too ;)


__________________
Login to reply  Page: « < 1 of 1 > »