Author Topic: Improvement to "come" message  (Read 1335 times)

Offline purlow

  • Acquaintance
  • *
  • Posts: 4
    • View Profile
Improvement to "come" message
« on: November 01, 2006, 10:59:52 AM »
Hello,



One of the things I dislike about the stock DS is when a person enters a room is  simply says "Dude enters."  I prefer to see something more along the lines of "Dude arrives from the west." or whatever other direction. I've hacked the lib a bit to get this behavior. Here are the affected (infected?  ;-) ) files and diffs. I don't *think* it breaks anything. If there is code that calls eventMoveLiving() on an npc, it should continue to work properly afaict.



If anyone finds any bugs or has suggestions on how to do this better, please let me know!

Thanks,

Purlow



code:
/lib/messages.c:
10a11,14
> private mapping oppMapping = ([ "north" : "south", "east" : "west",
>       "south" : "north", "west" : "east", "northeast" : "southwest",
>       "southeast" : "northwest", "southwest" : "northeast",
>       "northwest" : "southeast", "up" : "below", "down" : "above" ]);
46c50,62
<       if(stringp(arg)){ tmp = arg;}
---
>       if(stringp(arg)){
>          
>           //tmp = arg;
>          
>           // assume arg is the direction the object moved
>           // eg, go north, arg is north
>           if (stringp(oppMapping[arg])) {
>               string dir = oppMapping[arg];
>               tmp = "arrives from " +
>                   (dir == "below" || dir == "above" ? "" : "the ") + dir + ".";
>           }
>             else tmp = arg;
>       }




code:
/lib/npc.c:

486,487c486,494
<           else if( !imsg || imsg == "" ) imsg = GetMessage(msgclass = "come", imsg);
<           else imsg = replace_string(imsg, "$N", GetName());
---
>           else if( !imsg || imsg == "" )
>               imsg = GetMessage(msgclass = "come", imsg);
>           else {
>               string s = replace_string(imsg, "$N", GetName());
>               if (imsg != s)
>                   imsg = s;
>               else
>                   imsg = GetMessage(msgclass = "come", imsg);
>           }




code:
/lib/exits.c

65
<     who->eventMoveLiving(Exits[str]["room"], str);
---
>     who->eventMoveLiving(Exits[str]["room"], str, str);