Guest User

Untitled

a guest
Feb 19th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.36 KB | None | 0 0
  1. /*
  2.  
  3. * All you really need to do is to add this to mud.h
  4.  
  5. * And change around the vnums to match the locker room vnum, and
  6.  
  7. * object vnum of the locker itself. It should be setup as a container.
  8.  
  9. * Make SURE that neither locker or the locker room has the prototype
  10.  
  11. * flag on it. Make a directory called lockers in your /dist directory.
  12.  
  13. *
  14.  
  15. * #define ROOM_LOCKER 229
  16.  
  17. * #define OBJ_VNUM_LOCKER 39
  18.  
  19. * #define OS_LOCKER 2
  20.  
  21. *
  22.  
  23. * and add to save.c
  24.  
  25. * in the fread_obj() function
  26.  
  27. * under ...
  28.  
  29. * if ( room->vnum == ROOM_VNUM_HALLOFFALLEN
  30.  
  31. * && obj->first_content )
  32.  
  33. * obj->timer = -1;
  34.  
  35. * obj = obj_to_room( obj, room );
  36.  
  37. * }
  38.  
  39. * <<<<<< add ... >>>>>>>
  40.  
  41. * else if ( os_type == OS_LOCKER )
  42.  
  43. * {
  44.  
  45. * room->vnum = ROOM_LOCKER;
  46.  
  47. * if (obj->name == ch->name)
  48.  
  49. * obj = obj_to_room( obj, room );
  50.  
  51. * else
  52.  
  53. * {
  54.  
  55. * OBJ_DATA *locker;
  56.  
  57. * for( locker = ch->in_room->first_content; locker ; locker = locker->next_content )
  58.  
  59. * {
  60.  
  61. * if( locker->name == ch->name )
  62.  
  63. * break;
  64.  
  65. * }
  66.  
  67. * if (!locker)
  68.  
  69. * {
  70.  
  71. * bug("Unknown locker");
  72.  
  73. * return;
  74.  
  75. * }
  76.  
  77. *
  78.  
  79. * obj = obj_to_obj( obj, locker );
  80.  
  81. * }
  82.  
  83. * }
  84.  
  85. *
  86.  
  87. *
  88.  
  89. * in the fread_obj()
  90.  
  91. * change if ( obj->prev_content && (os_type != OS_CORPSE ) )
  92.  
  93. * to if ( obj->prev_content && (os_type != OS_CORPSE && os_type != OS_LOCKER ) )
  94.  
  95. *
  96.  
  97. * in the fwrite_obj() function
  98.  
  99. * change if (( os_type == OS_CORPSE ) && obj->in_room )
  100.  
  101. * to if (( os_type == OS_CORPSE || os_type == OS_LOCKER ) && obj->in_room )
  102.  
  103. */
  104.  
  105.  
  106.  
  107. #include <sys/types.h>
  108.  
  109. #include <ctype.h>
  110.  
  111. #include <stdio.h>
  112.  
  113. #include <stdlib.h>
  114.  
  115. #include <string.h>
  116.  
  117. #include <time.h>
  118.  
  119. #include "mud.h"
  120.  
  121.  
  122.  
  123. #define LOCKER_DIR "../lockers/"
  124.  
  125.  
  126.  
  127. void fwrite_locker( CHAR_DATA *ch, OBJ_DATA *locker )
  128.  
  129. {
  130.  
  131. /* Variables */
  132.  
  133. FILE *fp = NULL;
  134.  
  135. char strsave[MAX_INPUT_LENGTH];
  136.  
  137.  
  138.  
  139. if( !locker )
  140.  
  141. {
  142.  
  143. bug( "Fwrite_locker: NULL object.", 0 );
  144.  
  145. bug( ch->name, 0 );
  146.  
  147. return;
  148.  
  149. }
  150.  
  151.  
  152.  
  153. sprintf( strsave, "%s%s", LOCKER_DIR, capitalize( ch->name ) );
  154.  
  155.  
  156.  
  157. if ( ( fp = fopen( strsave, "w" ) ) != NULL )
  158.  
  159. {
  160.  
  161. fwrite_obj( ch, locker, fp, 0, OS_LOCKER );
  162.  
  163. fprintf( fp, "#END \n\r" );
  164.  
  165. fclose( fp );
  166.  
  167. }
  168.  
  169. return;
  170.  
  171. }
  172.  
  173.  
  174.  
  175. void do_locker( CHAR_DATA *ch, char *argument )
  176.  
  177. {
  178.  
  179. /* Variables */
  180.  
  181. FILE *fp = NULL;
  182.  
  183. char strsave[MAX_INPUT_LENGTH];
  184.  
  185. char buf [MAX_INPUT_LENGTH];
  186.  
  187. char arg[MAX_INPUT_LENGTH];
  188.  
  189. OBJ_DATA *locker;
  190.  
  191.  
  192.  
  193. if ( IS_NPC(ch) )
  194.  
  195. return;
  196.  
  197.  
  198.  
  199. argument = one_argument(argument, arg);
  200.  
  201. if ( arg[0] == '\0' )
  202.  
  203. {
  204.  
  205. send_to_char( "Syntax: locker <open | close>\r\n", ch );
  206.  
  207. }
  208.  
  209.  
  210.  
  211. if( ! str_cmp( arg, "open" ) )
  212.  
  213. {
  214.  
  215. if (ch->in_room->vnum != ROOM_LOCKER)
  216.  
  217. {
  218.  
  219. send_to_char( "Does this smell like a locker room to you?\r\n", ch );
  220.  
  221. return;
  222.  
  223. }
  224.  
  225.  
  226.  
  227. for( locker = ch->in_room->first_content; locker ; locker = locker->next_content)
  228.  
  229. {
  230.  
  231. if( locker->name == ch->name )
  232.  
  233. break;
  234.  
  235. }
  236.  
  237.  
  238.  
  239. if (locker)
  240.  
  241. {
  242.  
  243. send_to_char("Your locker is already open.\n\r",ch);
  244.  
  245. return;
  246.  
  247. }
  248.  
  249.  
  250.  
  251. sprintf( strsave, "%s%s", LOCKER_DIR, capitalize( ch->name ) );
  252.  
  253.  
  254.  
  255. if ( ( fp = fopen( strsave, "r" ) ) != NULL )
  256.  
  257. {
  258.  
  259. if (ch->gold < 10000)
  260.  
  261. {
  262.  
  263. send_to_char("You do not have enough gold.\n\r",ch);
  264.  
  265. fclose( fp );
  266.  
  267. return;
  268.  
  269. }
  270.  
  271.  
  272.  
  273. ch->gold -= 10000;
  274.  
  275. for ( ; ; )
  276.  
  277. {
  278.  
  279. char letter;
  280.  
  281. char *word;
  282.  
  283.  
  284.  
  285. letter = fread_letter( fp );
  286.  
  287. if ( letter == '#')
  288.  
  289. {
  290.  
  291. word = fread_word( fp );
  292.  
  293.  
  294.  
  295. if (!strcmp(word,"END" ))
  296.  
  297. break;
  298.  
  299.  
  300.  
  301. if (!strcmp(word,"OBJECT"))
  302.  
  303. {
  304.  
  305. fread_obj( ch, fp, OS_LOCKER );
  306.  
  307. }
  308.  
  309. }
  310.  
  311. }
  312.  
  313. fclose( fp );
  314.  
  315. }
  316.  
  317. else
  318.  
  319. {
  320.  
  321. if (ch->gold < 100000)
  322.  
  323. {
  324.  
  325. send_to_char("You do not have enough gold to create a locker.\n\r",ch);
  326.  
  327. return;
  328.  
  329. }
  330.  
  331.  
  332.  
  333. ch->gold -= 100000;
  334.  
  335. locker = create_object(get_obj_index(OBJ_VNUM_LOCKER),0);
  336.  
  337. sprintf(buf, locker->name, ch->name);
  338.  
  339. STRFREE( locker->name);
  340.  
  341. locker->name = STRALLOC(buf);
  342.  
  343. sprintf(buf, locker->short_descr, ch->name);
  344.  
  345. STRFREE( locker->short_descr);
  346.  
  347. locker->short_descr = STRALLOC(buf);
  348.  
  349. sprintf(buf, locker->description, ch->name);
  350.  
  351. STRFREE( locker->description);
  352.  
  353. locker->description = STRALLOC(buf);
  354.  
  355. obj_to_room( locker, ch->in_room );
  356.  
  357. }
  358.  
  359. act(AT_TELL, "$n opens $s locker.",ch, NULL, NULL, TO_ROOM);
  360.  
  361. act(AT_TELL, "You open your locker.",ch, NULL, NULL, TO_CHAR);
  362.  
  363. }
  364.  
  365. else if( ! str_cmp( arg, "close" ) )
  366.  
  367. {
  368.  
  369. if(ch->in_room->vnum != ROOM_LOCKER )
  370.  
  371. {
  372.  
  373. send_to_char( "You are not currently in the locker room.\r\n", ch );
  374.  
  375. return;
  376.  
  377. }
  378.  
  379.  
  380.  
  381. for( locker = ch->in_room->first_content; locker ; locker = locker->next_content )
  382.  
  383. {
  384.  
  385. if( locker->name == ch->name )
  386.  
  387. break;
  388.  
  389. }
  390.  
  391.  
  392.  
  393. if (!locker)
  394.  
  395. {
  396.  
  397. send_to_char("Your locker is not open.\n\r",ch);
  398.  
  399. return;
  400.  
  401. }
  402.  
  403. else
  404.  
  405. {
  406.  
  407. act(AT_TELL, "$n closes $s locker.",ch, NULL, NULL, TO_ROOM);
  408.  
  409. act(AT_TELL, "You close your locker.", ch, NULL, NULL, TO_CHAR);
  410.  
  411. fwrite_locker( ch, locker );
  412.  
  413. extract_obj(locker);
  414.  
  415. }
  416.  
  417. }
  418.  
  419. return;
  420.  
  421. }
Add Comment
Please, Sign In to add comment