Author Topic: Permanent colors, help please?  (Read 3678 times)

Offline kernth

  • Acquaintance
  • *
  • Posts: 6
    • View Profile
Permanent colors, help please?
« on: December 05, 2007, 10:32:11 pm »
Well, I am Amythist, owner/creator of DSTHTBVSM (Dead Souls Test Hopefully To Be Vampire Stain MUD). I was wondering what file I would have to edit and what bit I would need to edit in that file to make permanent color changes, such as, all room descriptions are a certain color, all items, all obvious exits, stuff like that?

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: Permanent colors, help please?
« Reply #1 on: December 06, 2007, 06:16:08 am »
There are probably a few ways to do it.
Some ideas:

To colorize obvious exists, edit /lib/exits.c:
Change
Code: [Select]
return (Obvious = str);To
Code: [Select]
return (Obvious = "%^RED%^"+str);

To colorize room descriptions, edit /lib/std/room.c:
Change
Code: [Select]
return GetInternalDesc();To
Code: [Select]
return "%^B_RED%^"+GetInternalDesc();
To colorize item descriptions, edit /lib/events/look.c:
Change
Code: [Select]
return ExternalDesc + openstate;To
Code: [Select]
return "%^GREEN%^" + ExternalDesc + "%^RESET%^" + openstate;
To reload the existing objects you can either reboot the mud, or type:

reload every room
reload every item


Always back up lib files before editing. Your mileage may vary.

-Crat

Offline kernth

  • Acquaintance
  • *
  • Posts: 6
    • View Profile
Re: Permanent colors, help please?
« Reply #2 on: December 06, 2007, 11:59:05 am »
Ahah! THanks a ton!

Normally, I would make a new topic now, but I guess I'll just say it here:: I am having trouble trying to get a mob to automatically 'reset'/'respawn' itself. I have done:
set_heart_beat(60);
void heart_beat(){
this_object()->eventForce("reset");
}

That should work, no? But that would just reset 'em every minute, even if he is dead...

Offline kernth

  • Acquaintance
  • *
  • Posts: 6
    • View Profile
Re: Permanent colors, help please?
« Reply #3 on: December 06, 2007, 12:09:02 pm »
Couldn't find the edit button!


Any tips as to where to search for the spot to send color through things such as combat?

Offline kernth

  • Acquaintance
  • *
  • Posts: 6
    • View Profile
Re: Permanent colors, help please?
« Reply #4 on: December 06, 2007, 12:15:46 pm »
Found it, for combat atleast. lib/something.../combatmsg.c!!


I like browsing files :P

Offline kernth

  • Acquaintance
  • *
  • Posts: 6
    • View Profile
Re: Permanent colors, help please?
« Reply #5 on: December 06, 2007, 01:03:08 pm »
Ok, colorfied room descriptions, items, and combat messages. Weehoo!

Offline Nulvect

  • BFF
  • ***
  • Posts: 127
    • View Profile
Re: Permanent colors, help please?
« Reply #6 on: December 06, 2007, 09:37:34 pm »
I'm not sure what you're asking for the mob part, but the code you posted is definitely not what you want. Changing a mob to only have a heart_beat every 60 heart_beats will affect the way it fights as well as other periodic things it may do (like talk at random).

If you need to make sure the mob respawns in a certain room, I _think_ that on DS, using SetInventory in that room is the way to go. On many other LP muds you simply put some code in the reset() of the room to check if the mob is there, and if not, then clone a new one.

While I've never used reset() in a mob, it would work if you want to have something happen just as often as rooms respawn. Normally you need mobs to do things more often, though, so you would just use a counter in their heart_beat, like so:
Code: [Select]
int counter = 0;

void heart_beat() {
  ::heart_beat();
  if (!this_object()) return; // important, mob might not exist anymore if it died in combat
  if (++counter >= 8) { // every 8 rounds
    counter = 0;
    do_something_here;
  }
}

Offline tigwyk

  • Acquaintance
  • *
  • Posts: 45
    • View Profile
Re: Permanent colors, help please?
« Reply #7 on: December 06, 2007, 11:16:10 pm »
While we're on the topic of mobs respawning in rooms, there's the one tiny chance that someone's moved your mob out of the room, so that it respawns again and now you've got two beasties. I forget how to deal with this issue, though there is a way. Just wanted to make sure people are aware of the "outside-the-box" methods that players use to beat the system. ;)

Offline Atomic

  • BFF
  • ***
  • Posts: 115
  • To infinity and beyond!
    • View Profile
Re: Permanent colors, help please?
« Reply #8 on: December 07, 2007, 02:54:36 am »
I think you should have posted your mob/respawn question in its own thread, just to keep things separated.

Your other comment about the edit-function: this was disabled for a reason: http://lpmuds.net/forum/index.php?topic=407.0
Always remember that the early bird gets the worm first, but the fi...*SNAP*...second mouse gets the cheese.

Offline quixadhal

  • BFF
  • ***
  • Posts: 642
    • View Profile
    • WileyMUD
Re: Permanent colors, help please?
« Reply #9 on: December 08, 2007, 05:54:44 pm »
As far as colours go, I personally don't like to use colour overly much.  I find it's hard enough to get the users to actually read and pay attention to the text I've written, let alone having them just watch for the GREEN lines, or the BLUE lines. :)

However, if you were going to make all of a certain kind of thing be a certain colour, it is nice to give the player some control over those choices.

For example, rather than hard coding a particular colour code into your description routine, you could place color routines into the player object itself and query that.

Code: [Select]
return "%^B_RED%^"+GetInternalDesc();
becomes something like

Code: [Select]
return this_player()->getRoomColour() + GetInternalDesc();
You can initialize the colour to whatever you like, and if you want the users to be able to change them, you can provide them a command/device/quest/whatever which would call setRoomColour() on them with the appropriate arguments.  Bumping up a level of abstraction, you could also provide themes which sets all the colours in one swoop.

For sanity, you might need a check somewhere to ensure that this_player() returns something valid, in case you have npc's that use room description text to navigate or something.

As for mob resets... I'm a big fan of handlers doing the work for me.  Instead of having code scattered around in various room reset functions, I'd rather have a mob_factory which does things like:

Code: [Select]
if( mob_count("/d/fooland/forest") < 25 )
  breed_mob("/d/fooland/forest");

Where breed_mob() would randomly spawn a mob of the appropriate type for that zone and spawn it into a room which has no players (and preferably no other mobs).

If you want specific mobs in specific places, just have the handler check a particular type and a particular set of rooms.

It's a personal preference, but it makes it much easier to adjust things IMHO.