home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / d / d-linux.zip / dm-dist / act.informativ < prev    next >
Text File  |  1991-03-01  |  31KB  |  1,255 lines

  1. /* ************************************************************************
  2. *  file: act.informative.c , Implementation of commands.  Part of DIKUMUD *
  3. *  Usage : Informative commands.                                          *
  4. *  Copyright (C) 1990, 1991 - see 'license.doc' for complete information. *
  5. ************************************************************************* */
  6.  
  7. #include <stdio.h>
  8. #include <string.h>
  9. #include <ctype.h>
  10. #include <time.h>
  11.  
  12. #include "structs.h"
  13. #include "utils.h"
  14. #include "comm.h"
  15. #include "interpreter.h"
  16. #include "handler.h"
  17. #include "db.h"
  18. #include "spells.h"
  19. #include "limits.h"
  20.  
  21. /* extern variables */
  22.  
  23. extern struct room_data *world;
  24. extern struct descriptor_data *descriptor_list;
  25. extern struct char_data *character_list;
  26. extern struct obj_data *object_list;
  27. extern char credits[MAX_STRING_LENGTH];
  28. extern char news[MAX_STRING_LENGTH];
  29. extern char info[MAX_STRING_LENGTH];
  30. extern char wizlist[MAX_STRING_LENGTH];
  31. extern char *dirs[]; 
  32. extern char *where[];
  33. extern char *color_liquid[];
  34. extern char *fullness[];
  35.  
  36. /* extern functions */
  37.  
  38. struct time_info_data age(struct char_data *ch);
  39. void page_string(struct descriptor_data *d, char *str, int keep_internal);
  40.  
  41. /* intern functions */
  42.  
  43. void list_obj_to_char(struct obj_data *list,struct char_data *ch, int mode,
  44.     bool show);
  45.  
  46.  
  47. /* Procedures related to 'look' */
  48.  
  49. void argument_split_2(char *argument, char *first_arg, char *second_arg) {
  50.     int look_at, found, begin;
  51.     found = begin = 0;
  52.  
  53.     /* Find first non blank */
  54.     for ( ;*(argument + begin ) == ' ' ; begin++);
  55.  
  56.     /* Find length of first word */
  57.     for (look_at=0; *(argument+begin+look_at) > ' ' ; look_at++)
  58.  
  59.     /* Make all letters lower case, AND copy them to first_arg */
  60.     *(first_arg + look_at) = LOWER(*(argument + begin + look_at));
  61.     *(first_arg + look_at) = '\0';
  62.     begin += look_at;
  63.  
  64.     /* Find first non blank */
  65.     for ( ;*(argument + begin ) == ' ' ; begin++);
  66.  
  67.     /* Find length of second word */
  68.     for ( look_at=0; *(argument+begin+look_at)> ' ' ; look_at++)
  69.  
  70.     /* Make all letters lower case, AND copy them to second_arg */
  71.     *(second_arg + look_at) = LOWER(*(argument + begin + look_at));
  72.     *(second_arg + look_at)='\0';
  73.     begin += look_at;
  74. }
  75.  
  76. struct obj_data *get_object_in_equip_vis(struct char_data *ch,
  77.     char *arg, struct obj_data *equipment[], int *j) {
  78.  
  79.     for ((*j) = 0; (*j) < MAX_WEAR ; (*j)++)
  80.         if (equipment[(*j)])
  81.             if (CAN_SEE_OBJ(ch,equipment[(*j)]))
  82.                 if (isname(arg, equipment[(*j)]->name))
  83.                     return(equipment[(*j)]);
  84.  
  85.     return (0);
  86. }
  87.  
  88. char *find_ex_description(char *word, struct extra_descr_data *list)
  89. {
  90.     struct extra_descr_data *i;
  91.  
  92.     for (i = list; i; i = i->next)
  93.         if (isname(word,i->keyword))
  94.             return(i->description);
  95.  
  96.     return(0);
  97. }
  98.  
  99. void show_obj_to_char(struct obj_data *object, struct char_data *ch, int mode)
  100. {
  101.     char buffer[MAX_STRING_LENGTH] = "\0";
  102.     char *temp_desc;
  103.     struct obj_data *i;
  104.     int temp;
  105.     bool found;
  106.  
  107.     if ((mode == 0) && object->description)
  108.         strcpy(buffer,object->description);
  109.     else     if (object->short_description && ((mode == 1) ||
  110.           (mode == 2) || (mode==3) || (mode == 4))) 
  111.         strcpy(buffer,object->short_description);
  112.     else if (mode == 5) {
  113.         if (object->obj_flags.type_flag == ITEM_NOTE)
  114.         {
  115.             if (object->action_description)
  116.             {
  117.                 strcpy(buffer, "There is something written upon it:\n\r\n\r");
  118.                 strcat(buffer, object->action_description);
  119.                 page_string(ch->desc, buffer, 1);
  120.             }
  121.             else
  122.                 act("It's blank.", FALSE, ch,0,0,TO_CHAR);
  123.             return;
  124.         }
  125.         else if((object->obj_flags.type_flag != ITEM_DRINKCON))
  126.         {
  127.             strcpy(buffer,"You see nothing special..");
  128.         }
  129.         else /* ITEM_TYPE == ITEM_DRINKCON */
  130.         {
  131.             strcpy(buffer, "It looks like a drink container.");
  132.         }
  133.     }
  134.  
  135.     if (mode != 3) { 
  136.         found = FALSE;
  137.         if (IS_OBJ_STAT(object,ITEM_INVISIBLE)) {
  138.              strcat(buffer,"(invisible)");
  139.              found = TRUE;
  140.         }
  141.         if (IS_OBJ_STAT(object,ITEM_EVIL) && IS_AFFECTED(ch,AFF_DETECT_EVIL)) {
  142.              strcat(buffer,"..It glows red!");
  143.              found = TRUE;
  144.         }
  145.         if (IS_OBJ_STAT(object,ITEM_MAGIC) && IS_AFFECTED(ch,AFF_DETECT_MAGIC)) {
  146.              strcat(buffer,"..It glows blue!");
  147.              found = TRUE;
  148.         }
  149.         if (IS_OBJ_STAT(object,ITEM_GLOW)) {
  150.             strcat(buffer,"..It has a soft glowing aura!");
  151.             found = TRUE;
  152.         }
  153.         if (IS_OBJ_STAT(object,ITEM_HUM)) {
  154.             strcat(buffer,"..It emits a faint humming sound!");
  155.             found = TRUE;
  156.         }
  157.     }
  158.  
  159.     strcat(buffer, "\n\r");
  160.     page_string(ch->desc, buffer, 1);
  161.  
  162. /*
  163.     if (((mode == 2) || (mode == 4)) && (GET_ITEM_TYPE(object) == 
  164.         ITEM_CONTAINER)) {
  165.         strcpy(buffer,"The ");
  166.         strcat(buffer,fname(object->name));
  167.         strcat(buffer," contains:\n\r");
  168.         send_to_char(buffer, ch);
  169.         if (mode == 2) list_obj_to_char(object->contains, ch, 1,TRUE);
  170.         if (mode == 4) list_obj_to_char(object->contains, ch, 3,TRUE);
  171.     }
  172. */
  173. }
  174.  
  175. void list_obj_to_char(struct obj_data *list,struct char_data *ch, int mode, 
  176.     bool show) {
  177.     struct obj_data *i;
  178.     bool found;
  179.  
  180.     found = FALSE;
  181.     for ( i = list ; i ; i = i->next_content ) { 
  182.         if (CAN_SEE_OBJ(ch,i)) {
  183.             show_obj_to_char(i, ch, mode);
  184.             found = TRUE;
  185.         }    
  186.     }  
  187.     if ((! found) && (show)) send_to_char("Nothing\n\r", ch);
  188. }
  189.  
  190.  
  191.  
  192. void show_char_to_char(struct char_data *i, struct char_data *ch, int mode)
  193. {
  194.     char buffer[MAX_STRING_LENGTH];
  195.     int j, found, percent;
  196.     struct obj_data *tmp_obj;
  197.  
  198.     if (mode == 0) {
  199.  
  200.         if (IS_AFFECTED(i, AFF_HIDE) || !CAN_SEE(ch,i)) {
  201.             if (IS_AFFECTED(ch, AFF_SENSE_LIFE))
  202.                 send_to_char("You sense a hidden life form in the room.\n\r", ch);
  203.             return;
  204.         }
  205.  
  206.         if (!(i->player.long_descr)||(GET_POS(i) != i->specials.default_pos)){
  207.             /* A player char or a mobile without long descr, or not in default pos. */
  208.             if (!IS_NPC(i)) {    
  209.                 strcpy(buffer,GET_NAME(i));
  210.                 strcat(buffer," ");
  211.                 strcat(buffer,GET_TITLE(i));
  212.             } else {
  213.                 strcpy(buffer, i->player.short_descr);
  214.                 CAP(buffer);
  215.             }
  216.  
  217.             if ( IS_AFFECTED(i,AFF_INVISIBLE))
  218.                strcat(buffer," (invisible)");
  219.  
  220.             switch(GET_POS(i)) {
  221.                 case POSITION_STUNNED  : 
  222.                     strcat(buffer," is lying here, stunned."); break;
  223.                 case POSITION_INCAP    : 
  224.                     strcat(buffer," is lying here, incapacitated."); break;
  225.                 case POSITION_MORTALLYW: 
  226.                     strcat(buffer," is lying here, mortally wounded."); break;
  227.                 case POSITION_DEAD     : 
  228.                     strcat(buffer," is lying here, dead."); break;
  229.                 case POSITION_STANDING : 
  230.                     strcat(buffer," is standing here."); break;
  231.                 case POSITION_SITTING  : 
  232.                     strcat(buffer," is sitting here.");  break;
  233.                 case POSITION_RESTING  : 
  234.                     strcat(buffer," is resting here.");  break;
  235.                 case POSITION_SLEEPING : 
  236.                     strcat(buffer," is sleeping here."); break;
  237.                 case POSITION_FIGHTING :
  238.                     if (i->specials.fighting) {
  239.  
  240.                         strcat(buffer," is here, fighting ");
  241.                         if (i->specials.fighting == ch)
  242.                             strcat(buffer," YOU!");
  243.                         else {
  244.                             if (i->in_room == i->specials.fighting->in_room)
  245.                                 if (IS_NPC(i->specials.fighting))
  246.                                     strcat(buffer, i->specials.fighting->player.short_descr);
  247.                                 else
  248.                                     strcat(buffer, GET_NAME(i->specials.fighting));
  249.                             else
  250.                                 strcat(buffer, "someone who has already left.");
  251.                         }
  252.                     } else /* NIL fighting pointer */
  253.                             strcat(buffer," is here struggling with thin air.");
  254.                     break;
  255.                 default : strcat(buffer," is floating here."); break;
  256.             }
  257.             if (IS_AFFECTED(ch, AFF_DETECT_EVIL)) {
  258.                 if (IS_EVIL(i))
  259.                     strcat(buffer, " (Red Aura)");
  260.             }
  261.  
  262.             strcat(buffer,"\n\r");
  263.             send_to_char(buffer, ch);
  264.         }
  265.         else  /* npc with long */
  266.         {
  267.             if (IS_AFFECTED(i,AFF_INVISIBLE))
  268.                 strcpy(buffer,"*");
  269.             else
  270.                 *buffer = '\0';
  271.  
  272.             if (IS_AFFECTED(ch, AFF_DETECT_EVIL)) {
  273.                 if (IS_EVIL(i))
  274.                     strcat(buffer, " (Red Aura)");
  275.             }
  276.  
  277.             strcat(buffer, i->player.long_descr);
  278.  
  279.             send_to_char(buffer, ch);
  280.         }
  281.                             
  282.         if (IS_AFFECTED(i,AFF_SANCTUARY))
  283.             act("$n glows with a bright light!", FALSE, i, 0, ch, TO_VICT);
  284.  
  285.     } else if (mode == 1) {
  286.  
  287.         if (i->player.description)
  288.             send_to_char(i->player.description, ch);
  289.         else {
  290.             act("You see nothing special about $m.", FALSE, i, 0, ch, TO_VICT);
  291.         }
  292.  
  293.         /* Show a character to another */
  294.  
  295.         if (GET_MAX_HIT(i) > 0)
  296.             percent = (100*GET_HIT(i))/GET_MAX_HIT(i);
  297.         else
  298.             percent = -1; /* How could MAX_HIT be < 1?? */
  299.  
  300.         if (IS_NPC(i))
  301.             strcpy(buffer, i->player.short_descr);
  302.         else
  303.             strcpy(buffer, GET_NAME(i));
  304.  
  305.         if (percent >= 100)
  306.             strcat(buffer, " is in an excellent condition.\n\r");
  307.         else if (percent >= 90)
  308.             strcat(buffer, " has a few scratches.\n\r");
  309.         else if (percent >= 75)
  310.             strcat(buffer, " has some small wounds and bruises.\n\r");
  311.         else if (percent >= 50)
  312.             strcat(buffer, " has quite a few wounds.\n\r");
  313.         else if (percent >= 30)
  314.             strcat(buffer, " has some big nasty wounds and scratches.\n\r");
  315.         else if (percent >= 15)
  316.             strcat(buffer, " looks pretty hurt.\n\r");
  317.         else if (percent >= 0)
  318.             strcat(buffer, " is in an awful condition.\n\r");
  319.         else
  320.             strcat(buffer, " is bleeding awfully from big wounds.\n\r");
  321.  
  322.         send_to_char(buffer, ch);
  323.  
  324.         found = FALSE;
  325.         for (j=0; j< MAX_WEAR; j++) {
  326.             if (i->equipment[j]) {
  327.                 if (CAN_SEE_OBJ(ch,i->equipment[j])) {
  328.                     found = TRUE;
  329.                 }
  330.             }
  331.         }
  332.         if (found) {
  333.             act("\n\r$n is using:", FALSE, i, 0, ch, TO_VICT);
  334.             for (j=0; j< MAX_WEAR; j++) {
  335.                 if (i->equipment[j]) {
  336.                     if (CAN_SEE_OBJ(ch,i->equipment[j])) {
  337.                         send_to_char(where[j],ch);
  338.                         show_obj_to_char(i->equipment[j],ch,1);
  339.                     }
  340.                 }
  341.             }
  342.         }
  343.         if ((GET_CLASS(ch) == CLASS_THIEF) && (ch != i)) {
  344.             found = FALSE;
  345.             send_to_char("\n\rYou attempt to peek at the inventory:\n\r", ch);
  346.             for(tmp_obj = i->carrying; tmp_obj; tmp_obj = tmp_obj->next_content) {
  347.                 if (CAN_SEE_OBJ(ch, tmp_obj) && (number(0,20) < GET_LEVEL(ch))) {
  348.                     show_obj_to_char(tmp_obj, ch, 1);
  349.                     found = TRUE;
  350.                 }
  351.             }
  352.             if (!found)
  353.                 send_to_char("You can't see anything.\n\r", ch);
  354.         }
  355.  
  356.     } else if (mode == 2) {
  357.  
  358.         /* Lists inventory */
  359.         act("$n is carrying:", FALSE, i, 0, ch, TO_VICT);
  360.         list_obj_to_char(i->carrying,ch,1,TRUE);
  361.     }
  362. }
  363.  
  364.  
  365.  
  366. void list_char_to_char(struct char_data *list, struct char_data *ch, 
  367.     int mode) {
  368.     struct char_data *i;
  369.  
  370.     for (i = list; i ; i = i->next_in_room) {
  371.         if ( (ch!=i) && (IS_AFFECTED(ch, AFF_SENSE_LIFE) ||
  372.              (CAN_SEE(ch,i) && !IS_AFFECTED(i, AFF_HIDE))) )
  373.             show_char_to_char(i,ch,0); 
  374.     } 
  375. }
  376.  
  377.  
  378.  
  379. void do_look(struct char_data *ch, char *argument, int cmd)
  380. {
  381.     char buffer[MAX_STRING_LENGTH];
  382.     char arg1[MAX_STRING_LENGTH];
  383.     char arg2[MAX_STRING_LENGTH];
  384.     int keyword_no;
  385.     int j, bits, temp;
  386.     bool found;
  387.     struct obj_data *tmp_object, *found_object;
  388.     struct char_data *tmp_char;
  389.     char *tmp_desc;
  390.     static char *keywords[]= { 
  391.         "north",
  392.         "east",
  393.         "south",
  394.         "west",
  395.         "up",
  396.         "down",
  397.         "in",
  398.         "at",
  399.         "",  /* Look at '' case */
  400.         "\n" };
  401.  
  402.     if (!ch->desc)
  403.         return;
  404.  
  405.     if (GET_POS(ch) < POSITION_SLEEPING)
  406.         send_to_char("You can't see anything but stars!\n\r", ch);
  407.     else if (GET_POS(ch) == POSITION_SLEEPING)
  408.         send_to_char("You can't see anything, you're sleeping!\n\r", ch);
  409.     else if ( IS_AFFECTED(ch, AFF_BLIND) )
  410.         send_to_char("You can't see a damn thing, you're blinded!\n\r", ch);
  411.     else if ( IS_DARK(ch->in_room) )
  412.         send_to_char("It is pitch black...\n\r", ch);
  413.     else {
  414.         argument_split_2(argument,arg1,arg2);
  415.         keyword_no = search_block(arg1, keywords, FALSE); /* Partiel Match */
  416.  
  417.         if ((keyword_no == -1) && *arg1) {
  418.             keyword_no = 7;
  419.             strcpy(arg2, arg1); /* Let arg2 become the target object (arg1) */
  420.         }
  421.  
  422.         found = FALSE;
  423.         tmp_object = 0;
  424.         tmp_char     = 0;
  425.         tmp_desc     = 0;
  426.  
  427.         switch(keyword_no) {
  428.             /* look <dir> */
  429.             case 0 :
  430.             case 1 :
  431.             case 2 : 
  432.             case 3 : 
  433.             case 4 :
  434.             case 5 : {   
  435.  
  436.                 if (EXIT(ch, keyword_no)) {
  437.  
  438.                     if (EXIT(ch, keyword_no)->general_description) {
  439.                         send_to_char(EXIT(ch, keyword_no)->
  440.                             general_description, ch);
  441.                     } else {
  442.                         send_to_char("You see nothing special.\n\r", ch);
  443.                     }
  444.  
  445.                     if (IS_SET(EXIT(ch, keyword_no)->exit_info, EX_CLOSED) && 
  446.                         (EXIT(ch, keyword_no)->keyword)) {
  447.                             sprintf(buffer, "The %s is closed.\n\r",
  448.                                 fname(EXIT(ch, keyword_no)->keyword));
  449.                             send_to_char(buffer, ch);
  450.                     }    else {
  451.                         if (IS_SET(EXIT(ch, keyword_no)->exit_info, EX_ISDOOR) &&
  452.                             EXIT(ch, keyword_no)->keyword) {
  453.                             sprintf(buffer, "The %s is open.\n\r",
  454.                                 fname(EXIT(ch, keyword_no)->keyword));
  455.                             send_to_char(buffer, ch);
  456.                         }
  457.                     }
  458.                 } else {
  459.                         send_to_char("Nothing special there...\n\r", ch);
  460.                 }
  461.             }
  462.             break;
  463.  
  464.             /* look 'in'    */
  465.             case 6: {
  466.                 if (*arg2) {
  467.                     /* Item carried */
  468.  
  469.                     bits = generic_find(arg2, FIND_OBJ_INV | FIND_OBJ_ROOM |
  470.                              FIND_OBJ_EQUIP, ch, &tmp_char, &tmp_object);
  471.  
  472.                     if (bits) { /* Found something */
  473.                         if (GET_ITEM_TYPE(tmp_object)== ITEM_DRINKCON)
  474.                         {
  475.                             if (tmp_object->obj_flags.value[1] <= 0) {
  476.                                 act("It is empty.", FALSE, ch, 0, 0, TO_CHAR);
  477.                             } else {
  478.                                 temp=((tmp_object->obj_flags.value[1]*3)/tmp_object->obj_flags.value[0]);
  479.                                 sprintf(buffer,"It's %sfull of a %s liquid.\n\r",
  480.                                 fullness[temp],color_liquid[tmp_object->obj_flags.value[2]]);
  481.                                 send_to_char(buffer, ch);
  482.                             }
  483.                         } else if (GET_ITEM_TYPE(tmp_object) == ITEM_CONTAINER) {
  484.                             if (!IS_SET(tmp_object->obj_flags.value[1],CONT_CLOSED)) {
  485.                                 send_to_char(fname(tmp_object->name), ch);
  486.                                 switch (bits) {
  487.                                     case FIND_OBJ_INV :
  488.                                         send_to_char(" (carried) : \n\r", ch);
  489.                                         break;
  490.                                     case FIND_OBJ_ROOM :
  491.                                         send_to_char(" (here) : \n\r", ch);
  492.                                         break;
  493.                                     case FIND_OBJ_EQUIP :
  494.                                         send_to_char(" (used) : \n\r", ch);
  495.                                         break;
  496.                                 }
  497.                                 list_obj_to_char(tmp_object->contains, ch, 2, TRUE);
  498.                             }
  499.                             else
  500.                                 send_to_char("It is closed.\n\r", ch);
  501.                         } else {
  502.                             send_to_char("That is not a container.\n\r", ch);
  503.                         }
  504.                     } else { /* wrong argument */
  505.                         send_to_char("You do not see that item here.\n\r", ch);
  506.                     }
  507.                 } else { /* no argument */
  508.                     send_to_char("Look in what?!\n\r", ch);
  509.                 }
  510.             }
  511.             break;
  512.  
  513.             /* look 'at'    */
  514.             case 7 : {
  515.  
  516.  
  517.                 if (*arg2) {
  518.  
  519.                     bits = generic_find(arg2, FIND_OBJ_INV | FIND_OBJ_ROOM |
  520.                            FIND_OBJ_EQUIP | FIND_CHAR_ROOM, ch, &tmp_char, &found_object);
  521.  
  522.                     if (tmp_char) {
  523.                         show_char_to_char(tmp_char, ch, 1);
  524.                         if (ch != tmp_char) {
  525.                             act("$n looks at you.", TRUE, ch, 0, tmp_char, TO_VICT);
  526.                             act("$n looks at $N.", TRUE, ch, 0, tmp_char, TO_NOTVICT);
  527.                         }
  528.                         return;
  529.                     }
  530.  
  531.  
  532.                     /* Search for Extra Descriptions in room and items */
  533.  
  534.                     /* Extra description in room?? */
  535.                     if (!found) {
  536.                         tmp_desc = find_ex_description(arg2, 
  537.                             world[ch->in_room].ex_description);
  538.                         if (tmp_desc) {
  539.                             page_string(ch->desc, tmp_desc, 0);
  540.                             return; /* RETURN SINCE IT WAS A ROOM DESCRIPTION */
  541.                             /* Old system was: found = TRUE; */
  542.                         }
  543.                     }
  544.  
  545.                     /* Search for extra descriptions in items */
  546.  
  547.                     /* Equipment Used */
  548.  
  549.                     if (!found) {
  550.                         for (j = 0; j< MAX_WEAR && !found; j++) {
  551.                             if (ch->equipment[j]) {
  552.                                 if (CAN_SEE_OBJ(ch,ch->equipment[j])) {
  553.                                     tmp_desc = find_ex_description(arg2, 
  554.                                         ch->equipment[j]->ex_description);
  555.                                     if (tmp_desc) {
  556.                                         page_string(ch->desc, tmp_desc, 1);
  557.                                         found = TRUE;
  558.                                     }
  559.                                 }
  560.                             }
  561.                         }
  562.                     }
  563.  
  564.                     /* In inventory */
  565.  
  566.                     if (!found) {
  567.                         for(tmp_object = ch->carrying; 
  568.                             tmp_object && !found; 
  569.                             tmp_object = tmp_object->next_content) {
  570.                             if CAN_SEE_OBJ(ch, tmp_object) {
  571.                                 tmp_desc = find_ex_description(arg2, 
  572.                                     tmp_object->ex_description);
  573.                                 if (tmp_desc) {
  574.                                     page_string(ch->desc, tmp_desc, 1);
  575.                                     found = TRUE;
  576.                                 }
  577.                             }
  578.                         }
  579.                     }
  580.  
  581.                     /* Object In room */
  582.  
  583.                     if (!found) {
  584.                         for(tmp_object = world[ch->in_room].contents; 
  585.                             tmp_object && !found; 
  586.                             tmp_object = tmp_object->next_content) {
  587.                             if CAN_SEE_OBJ(ch, tmp_object) {
  588.                                 tmp_desc = find_ex_description(arg2, 
  589.                                     tmp_object->ex_description);
  590.                                 if (tmp_desc) {
  591.                                     page_string(ch->desc, tmp_desc, 1);
  592.                                     found = TRUE;
  593.                                 }
  594.                             }
  595.                         }
  596.                     }
  597.                     /* wrong argument */
  598.  
  599.                     if (bits) { /* If an object was found */
  600.                         if (!found)
  601.                             show_obj_to_char(found_object, ch, 5); /* Show no-description */
  602.                         else
  603.                             show_obj_to_char(found_object, ch, 6); /* Find hum, glow etc */
  604.                     } else if (!found) {
  605.                         send_to_char("You do not see that here.\n\r", ch);
  606.                     }
  607.                 } else {
  608.                     /* no argument */
  609.  
  610.                     send_to_char("Look at what?\n\r", ch);
  611.                 }
  612.             }
  613.             break;
  614.  
  615.  
  616.             /* look ''        */ 
  617.             case 8 : {
  618.  
  619.                 send_to_char(world[ch->in_room].name, ch);
  620.                 send_to_char("\n\r", ch);
  621.  
  622.                 if (!IS_SET(ch->specials.act, PLR_BRIEF))
  623.                     send_to_char(world[ch->in_room].description, ch);
  624.  
  625.                 list_obj_to_char(world[ch->in_room].contents, ch, 0,FALSE);
  626.  
  627.                 list_char_to_char(world[ch->in_room].people, ch, 0);
  628.             }
  629.             break;
  630.  
  631.             /* wrong arg    */
  632.             case -1 : 
  633.                 send_to_char("Sorry, I didn't understand that!\n\r", ch);
  634.                 break;
  635.         }
  636.     }
  637. }
  638.  
  639. /* end of look */
  640.  
  641.  
  642.  
  643.  
  644. void do_read(struct char_data *ch, char *argument, int cmd)
  645. {
  646.     char buf[100];
  647.  
  648.     /* This is just for now - To be changed later.! */
  649.     sprintf(buf,"at %s",argument);
  650.     do_look(ch,buf,15);
  651. }
  652.  
  653.  
  654.  
  655. void do_examine(struct char_data *ch, char *argument, int cmd)
  656. {
  657.     char name[100], buf[100];
  658.     int bits;
  659.     struct char_data *tmp_char;
  660.     struct obj_data *tmp_object;
  661.  
  662.     sprintf(buf,"at %s",argument);
  663.     do_look(ch,buf,15);
  664.  
  665.     one_argument(argument, name);
  666.  
  667.     if (!*name)
  668.     {
  669.         send_to_char("Examine what?\n\r", ch);
  670.         return;
  671.     }
  672.  
  673.     bits = generic_find(name, FIND_OBJ_INV | FIND_OBJ_ROOM |
  674.            FIND_OBJ_EQUIP, ch, &tmp_char, &tmp_object);
  675.  
  676.     if (tmp_object) {
  677.         if ((GET_ITEM_TYPE(tmp_object)==ITEM_DRINKCON) ||
  678.             (GET_ITEM_TYPE(tmp_object)==ITEM_CONTAINER)) {
  679.             send_to_char("When you look inside, you see:\n\r", ch);
  680.             sprintf(buf,"in %s",argument);
  681.             do_look(ch,buf,15);
  682.         }
  683.     }
  684. }
  685.  
  686.  
  687.  
  688. void do_exits(struct char_data *ch, char *argument, int cmd)
  689. {
  690.     int door;
  691.     char buf[MAX_STRING_LENGTH];
  692.     char *exits[] =
  693.     {    
  694.         "North",
  695.         "East ",
  696.         "South",
  697.         "West ",
  698.         "Up   ",
  699.         "Down "
  700.     };
  701.  
  702.     *buf = '\0';
  703.  
  704.     for (door = 0; door <= 5; door++)
  705.         if (EXIT(ch, door))
  706.             if (EXIT(ch, door)->to_room != NOWHERE &&
  707.                 !IS_SET(EXIT(ch, door)->exit_info, EX_CLOSED))
  708.                 if (IS_DARK(EXIT(ch, door)->to_room))
  709.                     sprintf(buf + strlen(buf), "%s - Too dark to tell\n\r", exits[door]);
  710.                 else
  711.                     sprintf(buf + strlen(buf), "%s - %s\n\r", exits[door],
  712.                         world[EXIT(ch, door)->to_room].name);
  713.  
  714.     send_to_char("Obvious exits:\n\r", ch);
  715.  
  716.     if (*buf)
  717.         send_to_char(buf, ch);
  718.     else
  719.         send_to_char("None.\n\r", ch);
  720. }
  721.  
  722.  
  723. void do_score(struct char_data *ch, char *argument, int cmd)
  724. {
  725.     struct time_info_data playing_time;
  726.     static char buf[100];
  727.  
  728.     struct time_info_data real_time_passed(time_t t2, time_t t1);
  729.  
  730.     sprintf(buf, "You are %d years old.", GET_AGE(ch));
  731.  
  732.     if ((age(ch).month == 0) && (age(ch).day == 0))
  733.         strcat(buf," It's your birthday today.\n\r");
  734.     else
  735.         strcat(buf,"\n\r");
  736.     send_to_char(buf, ch);
  737.  
  738.     if (GET_COND(ch,DRUNK)>10)
  739.         send_to_char("You are intoxicated.\n\r", ch);
  740.  
  741.     sprintf(buf, 
  742.         "You have %d(%d) hit, %d(%d) mana and %d(%d) movement points.\n\r",
  743.         GET_HIT(ch),GET_MAX_HIT(ch),
  744.         GET_MANA(ch),GET_MAX_MANA(ch),
  745.         GET_MOVE(ch),GET_MAX_MOVE(ch));
  746.     send_to_char(buf,ch);
  747.  
  748.     sprintf(buf,"You have scored %d exp, and have %d gold coins.\n\r",
  749.         GET_EXP(ch),GET_GOLD(ch));
  750.     send_to_char(buf,ch);
  751.  
  752.     playing_time = real_time_passed((time(0)-ch->player.time.logon) +
  753.        ch->player.time.played, 0);
  754.     sprintf(buf,"You have been playing for %d days and %d hours.\n\r",
  755.         playing_time.day,
  756.         playing_time.hours);        
  757.     send_to_char(buf, ch);        
  758.  
  759.     sprintf(buf,"This ranks you as %s %s (level %d).\n\r",
  760.         GET_NAME(ch),
  761.         GET_TITLE(ch), GET_LEVEL(ch) );
  762.     send_to_char(buf,ch);
  763.  
  764.     switch(GET_POS(ch)) {
  765.         case POSITION_DEAD : 
  766.             send_to_char("You are DEAD!\n\r", ch); break;
  767.         case POSITION_MORTALLYW :
  768.             send_to_char("You are mortally wounded!, you should seek help!\n\r", ch); break;
  769.         case POSITION_INCAP : 
  770.             send_to_char("You are incapacitated, slowly fading away\n\r", ch); break;
  771.         case POSITION_STUNNED : 
  772.             send_to_char("You are stunned! You can't move\n\r", ch); break;
  773.         case POSITION_SLEEPING : 
  774.             send_to_char("You are sleeping.\n\r",ch); break;
  775.         case POSITION_RESTING  : 
  776.             send_to_char("You are resting.\n\r",ch); break;
  777.         case POSITION_SITTING  : 
  778.             send_to_char("You are sitting.\n\r",ch); break;
  779.         case POSITION_FIGHTING :
  780.             if (ch->specials.fighting)
  781.                 act("You are fighting $N.\n\r", FALSE, ch, 0,
  782.                      ch->specials.fighting, TO_CHAR);
  783.             else
  784.                 send_to_char("You are fighting thin air.\n\r", ch);
  785.             break;
  786.         case POSITION_STANDING : 
  787.             send_to_char("You are standing.\n\r",ch); break;
  788.         default :
  789.             send_to_char("You are floating.\n\r",ch); break;
  790.     }
  791.  
  792. }
  793.  
  794.  
  795. void do_time(struct char_data *ch, char *argument, int cmd)
  796. {
  797.     char buf[100], *suf;
  798.     int weekday, day;
  799.     extern struct time_info_data time_info;
  800.     extern const char *weekdays[];
  801.     extern const char *month_name[];
  802.  
  803.     sprintf(buf, "It is %d o'clock %s, on ",
  804.         ((time_info.hours % 12 == 0) ? 12 : ((time_info.hours) % 12)),
  805.         ((time_info.hours >= 12) ? "pm" : "am") );
  806.  
  807.     weekday = ((35*time_info.month)+time_info.day+1) % 7;/* 35 days in a month */
  808.  
  809.     strcat(buf,weekdays[weekday]);
  810.     strcat(buf,"\n\r");
  811.     send_to_char(buf,ch);
  812.  
  813.     day = time_info.day + 1;   /* day in [1..35] */
  814.  
  815.     if (day == 1)
  816.         suf = "st";
  817.     else if (day == 2)
  818.         suf = "nd";
  819.     else if (day == 3)
  820.         suf = "rd";
  821.     else if (day < 20)
  822.         suf = "th";
  823.     else if ((day % 10) == 1)
  824.         suf = "st";
  825.     else if ((day % 10) == 2)
  826.         suf = "nd";
  827.     else if ((day % 10) == 3)
  828.         suf = "rd";
  829.     else
  830.         suf = "th";
  831.  
  832.     sprintf(buf, "The %d%s Day of the %s, Year %d.\n\r",
  833.         day,
  834.         suf,
  835.         month_name[time_info.month],
  836.         time_info.year);
  837.  
  838.     send_to_char(buf,ch);
  839. }
  840.  
  841.  
  842. void do_weather(struct char_data *ch, char *argument, int cmd)
  843. {
  844.     extern struct weather_data weather_info;
  845.     static char buf[100];
  846.     char static *sky_look[4]= {
  847.     "cloudless",
  848.     "cloudy",
  849.     "rainy",
  850.     "lit by flashes of lightning"};
  851.  
  852.     if (OUTSIDE(ch)) {
  853.         sprintf(buf, 
  854.         "The sky is %s and %s.\n\r",
  855.             sky_look[weather_info.sky],
  856.             (weather_info.change >=0 ? "you feel a warm wind from south" :
  857.          "your foot tells you bad weather is due"));
  858.         send_to_char(buf,ch);
  859.     } else
  860.         send_to_char("You have no feeling about the weather at all.\n\r", ch);
  861. }
  862.  
  863.  
  864. void do_help(struct char_data *ch, char *argument, int cmd)
  865. {
  866.     extern char *spells[];   /* The list of spells (spells.c)         */
  867.     extern int top_of_helpt;
  868.     extern struct help_index_element *help_index;
  869.     extern FILE *help_fl;
  870.     extern char help[MAX_STRING_LENGTH];
  871.  
  872.     int i, no, chk, bot, top, mid, minlen;
  873.     char buf[MAX_STRING_LENGTH], buffer[MAX_STRING_LENGTH];
  874.  
  875.  
  876.     if (!ch->desc)
  877.         return;
  878.  
  879.     for(;isspace(*argument); argument++)  ;
  880.  
  881.  
  882.     if (*argument)
  883.     {
  884.         if (!help_index)
  885.         {
  886.             send_to_char("No help available.\n\r", ch);
  887.             return;
  888.         }
  889.         bot = 0;
  890.         top = top_of_helpt;
  891.  
  892.         for (;;)
  893.         {
  894.             mid = (bot + top) / 2;
  895.             minlen = strlen(argument);
  896.  
  897.             if (!(chk = strn_cmp(argument, help_index[mid].keyword, minlen)))
  898.             {
  899.                 fseek(help_fl, help_index[mid].pos, 0);
  900.                 *buffer = '\0';
  901.                 for (;;)
  902.                 {
  903.                     fgets(buf, 80, help_fl);
  904.                     if (*buf == '#')
  905.                         break;
  906.                     strcat(buffer, buf);
  907.                     strcat(buffer, "\r");
  908.                 }
  909.                 page_string(ch->desc, buffer, 1);
  910.                 return;
  911.             }
  912.             else if (bot >= top)
  913.             {
  914.                 send_to_char("There is no help on that word.\n\r", ch);
  915.                 return;
  916.             }
  917.             else if (chk > 0)
  918.                 bot = ++mid;
  919.             else
  920.                 top = --mid;
  921.         }
  922.         return;
  923.     }
  924.  
  925.  
  926.     send_to_char(help, ch);
  927.  
  928. }
  929.  
  930.  
  931.  
  932.  
  933.  
  934. do_wizhelp(struct char_data *ch, char *argument, int cmd)
  935. {
  936.     char buf[MAX_STRING_LENGTH];
  937.     int no, i;
  938.     extern char *command[];     /* The list of commands (interpreter.c)    */
  939.                              /* First command is command[0]           */
  940.     extern struct command_info cmd_info[];
  941.                              /* cmd_info[1] ~~ commando[0]            */
  942.  
  943.     if (IS_NPC(ch))
  944.         return;
  945.  
  946.     send_to_char("The following privileged comands are available:\n\r\n\r", ch);
  947.  
  948.     *buf = '\0';
  949.  
  950.     for (no = 1, i = 0; *command[i] != '\n'; i++)
  951.         if ((GET_LEVEL(ch) >= cmd_info[i+1].minimum_level) &&
  952.             (cmd_info[i+1].minimum_level >= 21))
  953.         {
  954.  
  955.             sprintf(buf + strlen(buf), "%-10s", command[i]);
  956.             if (!(no % 7))
  957.                 strcat(buf, "\n\r");
  958.             no++;
  959.         }
  960.     strcat(buf, "\n\r");
  961.     page_string(ch->desc, buf, 1);
  962. }
  963.  
  964.  
  965.  
  966.  
  967. void do_who(struct char_data *ch, char *argument, int cmd)
  968. {
  969.     struct descriptor_data *d;
  970.     char buf[256];
  971.  
  972.     send_to_char("Players\n\r-------\n\r", ch);
  973.     for (d = descriptor_list; d; d = d->next)
  974.     {
  975.         if (!d->connected && CAN_SEE(ch, d->character))
  976.         {
  977.  
  978.             if(d->original) /* If switched */            
  979.                 sprintf(buf, "%s %s\n\r", 
  980.                    GET_NAME(d->original),
  981.                       d->original->player.title);
  982.             else
  983.                 sprintf(buf, "%s %s\n\r", 
  984.                    GET_NAME(d->character),
  985.                    d->character->player.title);
  986.     
  987.         send_to_char(buf, ch);
  988.         }
  989.     }
  990. }
  991.  
  992.  
  993.  
  994.  
  995. void do_users(struct char_data *ch, char *argument, int cmd)
  996. {
  997.     char buf[MAX_STRING_LENGTH], line[200];
  998.  
  999.     struct descriptor_data *d;
  1000.  
  1001.     strcpy(buf, "Connections:\n\r------------\n\r");
  1002.     
  1003.     for (d = descriptor_list; d; d = d->next)
  1004.     {
  1005.         if (d->character && d->character->player.name)
  1006.         {
  1007.         if(d->original)
  1008.             sprintf(line, "%-16s: ", d->original->player.name);
  1009.         else
  1010.             sprintf(line, "%-16s: ", d->character->player.name);
  1011.         }
  1012.         else
  1013.             strcpy(line, "UNDEFINED       : ");
  1014.         if (d->host)
  1015.             sprintf(line + strlen(line), "[%s]\n\r", d->host);
  1016.         else
  1017.             strcat(line, "[Hostname unknown]\n\r");
  1018.  
  1019.         strcat(buf, line);
  1020.     }
  1021.     send_to_char(buf, ch);
  1022. }
  1023.  
  1024.  
  1025.  
  1026. void do_inventory(struct char_data *ch, char *argument, int cmd) {
  1027.  
  1028.     send_to_char("You are carrying:\n\r", ch);
  1029.     list_obj_to_char(ch->carrying, ch, 1, TRUE);
  1030. }
  1031.  
  1032.  
  1033. void do_equipment(struct char_data *ch, char *argument, int cmd) {
  1034. int j;
  1035. bool found;
  1036.  
  1037.     send_to_char("You are using:\n\r", ch);
  1038.     found = FALSE;
  1039.     for (j=0; j< MAX_WEAR; j++) {
  1040.         if (ch->equipment[j]) {
  1041.             if (CAN_SEE_OBJ(ch,ch->equipment[j])) {
  1042.                 send_to_char(where[j],ch);
  1043.                 show_obj_to_char(ch->equipment[j],ch,1);
  1044.                 found = TRUE;
  1045.             } else {
  1046.                 send_to_char(where[j],ch);
  1047.                 send_to_char("Something.\n\r",ch);
  1048.                 found = TRUE;
  1049.             }
  1050.         }
  1051.     }
  1052.     if(!found) {
  1053.         send_to_char(" Nothing.\n\r", ch);
  1054.     }
  1055. }
  1056.  
  1057.  
  1058. void do_credits(struct char_data *ch, char *argument, int cmd) {
  1059.  
  1060.     page_string(ch->desc, credits, 0);
  1061. }
  1062.  
  1063.  
  1064. void do_news(struct char_data *ch, char *argument, int cmd) {
  1065.  
  1066.     page_string(ch->desc, news, 0);
  1067. }
  1068.  
  1069.  
  1070. void do_info(struct char_data *ch, char *argument, int cmd) {
  1071.  
  1072.     page_string(ch->desc, info, 0);
  1073. }
  1074.  
  1075.  
  1076. void do_wizlist(struct char_data *ch, char *argument, int cmd) {
  1077.  
  1078.     page_string(ch->desc, wizlist, 0);
  1079. }
  1080.  
  1081.  
  1082.  
  1083. void do_where(struct char_data *ch, char *argument, int cmd)
  1084. {
  1085.     char name[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH], buf2[256];
  1086.     register struct char_data *i;
  1087.     register struct obj_data *k;
  1088.     struct descriptor_data *d;
  1089.  
  1090.     one_argument(argument, name);
  1091.  
  1092.     if (!*name) {
  1093.         if (GET_LEVEL(ch) < 21)
  1094.         {
  1095.             send_to_char("What are you looking for?\n\r", ch);
  1096.             return;
  1097.         }
  1098.         else
  1099.         {
  1100.             strcpy(buf, "Players:\n\r--------\n\r");
  1101.         
  1102.             for (d = descriptor_list; d; d = d->next) {
  1103.                 if (d->character && (d->connected == CON_PLYNG) && (d->character->in_room != NOWHERE)) {
  1104.                     if (d->original)   /* If switched */
  1105.                         sprintf(buf, "%-20s - %s [%d] In body of %s\n\r",
  1106.                           d->original->player.name,
  1107.                           world[d->character->in_room].name,
  1108.                           world[d->character->in_room].number,
  1109.                           fname(d->character->player.name));
  1110.                     else
  1111.                         sprintf(buf, "%-20s - %s [%d]\n\r",
  1112.                           d->character->player.name,
  1113.                           world[d->character->in_room].name,
  1114.                           world[d->character->in_room].number);
  1115.                          
  1116.                     send_to_char(buf, ch);
  1117.                 }
  1118.             }
  1119.             return;
  1120.         }
  1121.     }
  1122.  
  1123.     *buf = '\0';
  1124.  
  1125.     for (i = character_list; i; i = i->next)
  1126.         if (isname(name, i->player.name) && CAN_SEE(ch, i) )
  1127.         {
  1128.             if ((i->in_room != NOWHERE) && ((GET_LEVEL(ch)>20) ||
  1129.                 (world[i->in_room].zone == world[ch->in_room].zone))) {
  1130.  
  1131.                 if (IS_NPC(i))
  1132.                     sprintf(buf, "%-30s- %s ", i->player.short_descr,
  1133.                         world[i->in_room].name);
  1134.                 else
  1135.                     sprintf(buf, "%-30s- %s ", i->player.name,
  1136.                         world[i->in_room].name);
  1137.  
  1138.                 if (GET_LEVEL(ch) >= 21)
  1139.                     sprintf(buf2,"[%d]\n\r", world[i->in_room].number);
  1140.                 else
  1141.                     strcpy(buf2, "\n\r");
  1142.  
  1143.                 strcat(buf, buf2);
  1144.                 send_to_char(buf, ch);
  1145.  
  1146.                 if (GET_LEVEL(ch) < 21)
  1147.                     break;
  1148.             }
  1149.         }
  1150.  
  1151.     if (GET_LEVEL(ch) > 20) {
  1152.         for (k = object_list; k; k = k->next)
  1153.             if (isname(name, k->name) && CAN_SEE_OBJ(ch, k) && 
  1154.                 (k->in_room != NOWHERE)) {
  1155.                     sprintf(buf, "%-30s- %s [%d]\n\r",
  1156.                         k->short_description,
  1157.                         world[k->in_room].name,
  1158.                         world[k->in_room].number);
  1159.                         send_to_char(buf, ch);
  1160.                 }
  1161.     }
  1162.  
  1163.     if (!*buf)
  1164.         send_to_char("Couldn't find any such thing.\n\r", ch);
  1165. }
  1166.  
  1167.  
  1168.  
  1169.  
  1170. void do_levels(struct char_data *ch, char *argument, int cmd)
  1171. {
  1172.     int i;
  1173.     char buf[MAX_STRING_LENGTH];
  1174.  
  1175.     extern const struct title_type titles[4][25];
  1176.  
  1177.     if (IS_NPC(ch))
  1178.     {
  1179.         send_to_char("You ain't nothin' but a hound-dog.\n\r", ch);
  1180.         return;
  1181.     }
  1182.  
  1183.     *buf = '\0';
  1184.     
  1185.     for (i = 1; i < 21; i++)
  1186.     {
  1187.         sprintf(buf + strlen(buf), "%7d-%-7d : ",
  1188.             titles[GET_CLASS(ch) - 1][i].exp,
  1189.             titles[GET_CLASS(ch) - 1][i + 1].exp);
  1190.         switch(GET_SEX(ch))
  1191.         {
  1192.             case SEX_MALE:
  1193.                 strcat(buf, titles[GET_CLASS(ch) - 1][i].title_m); break;
  1194.             case SEX_FEMALE:
  1195.                 strcat(buf, titles[GET_CLASS(ch) - 1][i].title_f); break;
  1196.             default:
  1197.                 send_to_char("Oh dear.\n\r", ch); break;
  1198.         }
  1199.         strcat(buf, "\n\r");
  1200.     }
  1201.     send_to_char(buf, ch);
  1202. }
  1203.  
  1204.  
  1205.  
  1206. void do_consider(struct char_data *ch, char *argument, int cmd)
  1207. {
  1208.     struct char_data *victim;
  1209.     char name[256], buf[256];
  1210.     int diff;
  1211.  
  1212.     one_argument(argument, name);
  1213.  
  1214.     if (!(victim = get_char_room_vis(ch, name))) {
  1215.         send_to_char("Consider killing who?\n\r", ch);
  1216.         return;
  1217.     }
  1218.  
  1219.     if (victim == ch) {
  1220.         send_to_char("Easy! Very easy indeed!\n\r", ch);
  1221.         return;
  1222.     }
  1223.  
  1224.     if (!IS_NPC(victim)) {
  1225.         send_to_char("Would you like to borrow a cross and a shovel?\n\r", ch);
  1226.         return;
  1227.     }
  1228.  
  1229.     diff = (GET_LEVEL(victim)-GET_LEVEL(ch));
  1230.  
  1231.     if (diff <= -10)
  1232.         send_to_char("Now where did that chicken go?\n\r", ch);
  1233.     else if (diff <= -5)
  1234.         send_to_char("You could do it with a needle!\n\r", ch);
  1235.     else if (diff <= -2)
  1236.         send_to_char("Easy.\n\r", ch);
  1237.     else if (diff <= -1)
  1238.         send_to_char("Fairly easy.\n\r", ch);
  1239.     else if (diff == 0)
  1240.         send_to_char("The perfect match!\n\r", ch);
  1241.     else if (diff <= 1)
  1242.         send_to_char("You would need some luck!\n\r", ch);
  1243.     else if (diff <= 2)
  1244.         send_to_char("You would need a lot of luck!\n\r", ch);
  1245.     else if (diff <= 3)
  1246.         send_to_char("You would need a lot of luck and great equipment!\n\r", ch);
  1247.     else if (diff <= 5)
  1248.         send_to_char("Do you feel lucky, punk?\n\r", ch);
  1249.     else if (diff <= 10)
  1250.         send_to_char("Are you mad!?\n\r", ch);
  1251.     else if (diff <= 100)
  1252.         send_to_char("You ARE mad!\n\r", ch);
  1253.  
  1254. }
  1255.