Author Topic: Unique deaths per player  (Read 2087 times)

Offline Elohim@ForgottenGods

  • Acquaintance
  • *
  • Posts: 5
    • View Profile
Unique deaths per player
« on: April 06, 2012, 09:44:54 am »
Default death will move players into communal death room. Following code hacks imitates virtual void rooms so you can create a unique death scene or run specific functions through conditionals. Remember to back-up original files.

1. Create virtual room and container directory:

$ cd /domains/default/virtual/
$ cp void death.c
$ mkdir death

2. Modify room defines. Example below should insert line above ROOM_DEATH definition. Check your work!

$ ed /secure/include/rooms.h
$ 9,i
$ #define ROOM_VIRT_DEATH      DIR_STANDARD_DOMAIN "/virtual/death"
$ .
$x

3. Modify room daemon

$ cd /secure/daemon/
$ cp rooms.c rooms.c.YYYYMMDD
$ ed rooms.c

Line 22, should be "static string void_room, SaveFile;". Change to:
Code: [Select]
static string void_room, death_room, SaveFile;
Line 40, the "#ifdef ROOM_VIRT_VOID" area, edit the next few lines to match the following
Code: [Select]
#ifdef ROOM_VIRT_VOID
    err = catch(vvoid = load_object(ROOM_VIRT_VOID));
    if(!err && vvoid) void_room = ROOM_VIRT_VOID;
#endif
#ifdef ROOM_VIRT_DEATH
    err = catch(vvoid = load_object(ROOM_VIRT_DEATH));
    if(!err && vvoid) death_room = ROOM_VIRT_DEATH;
#endif
    if(undefinedp(void_room)) void_room = ROOM_VOID;
    if(undefinedp(death_room)) death_room = ROOM_DEATH;

Line 70, add the following function
Code: [Select]
string GetDeath(mixed ob){
    if(!ob) ob = previous_object();
    if(!ob) return ROOM_DEATH;
    if(void_room == ROOM_DEATH) return ROOM_DEATH;
    if(stringp(ob)) ob = find_object(ob);
    if(interactive(ob)){
        return death_room+"/user_"+ob->GetKeyName();
    }
    return ROOM_DEATH;
}

indent with i save with x, update to check for errors. When no errors reported update recursively and test with
Code: [Select]
eval return ROOMS_D->GetDeath(TP)it should return "/domains/default/virtual/death/user_(+your name)"

4. Modify player object
:'( !!!DO NOT PROCEED WITHOUT BACKING UP. YOU MUD WILL DIE N STUFF!!!  :'(
$ cd /std/
$ cp player.c player.c.YYYYMMDD
$ ed player.c

Line 156 In the eventDie() function look for "string agentname;". Change to:
Code: [Select]
string rdeath, agentname;
Line 194 We are now changing "this_object()->eventMove(ROOM_DEATH);" to
Code: [Select]

string rdeath = ROOMS_D->GetDeath(this_object());
( eventMove(rdeath) || eventMove(ROOM_DEATH));


Indent, exit, test with an update. If no errors-- update recursively.

At this point, if you haven't already, you might want to revise /domains/default/virtual/death.c with the contents of /domains/default/death.c

Log on your test character and test with:
Code: [Select]
eval return find_player("testdude")->eventDie("testing")

Offline quixadhal

  • BFF
  • ***
  • Posts: 642
    • View Profile
    • WileyMUD
Re: Unique deaths per player
« Reply #1 on: April 06, 2012, 08:32:43 pm »
Amusing idea.

Have whatever killed you spawn in the death room with you, so it can have a nice chat and point out where you went wrong.

Filthy Orc says "Oh, Hello Quixadhal.  You put up a good fight there, but you really should have dodged that last scimitar slash instead of trying to cast a spell.  Eleven of the last thirteen times I killed you, I used that offhand feint, so you really should have expected it by now."

Offline Elohim@ForgottenGods

  • Acquaintance
  • *
  • Posts: 5
    • View Profile
Re: Unique deaths per player
« Reply #2 on: April 07, 2012, 02:50:40 am »
Seems I left out the server.c file update in my original post and I don't have edit abilities yet, lol

/domains/default/virtual.c update the following function:

Code: [Select]
mixed compile_object(string file) {
    string *path, rtype;
    object ob;
    int x, y, z, elements;
    if(strsrch(file, "user_") != -1 || strsrch(file, "object_") != -1){
        if(strsrch(file, rtype = "void") )
    ob = new("/domains/default/virtual/void");
if(strsrch(file, rtype = "death") )
    ob = new("/domains/default/virtual/death");
        if(!ob){
            return "No "+rtype+" room available.";
        }
        return ob;
    }