Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 105.41 KB | None | 0 0
  1. /****************************************************************************
  2. * [S]imulated [M]edieval [A]dventure multi[U]ser [G]ame | \\._.// *
  3. * -----------------------------------------------------------| (0...0) *
  4. * SMAUG 1.8 (C) 1994, 1995, 1996, 1998 by Derek Snider | ).:.( *
  5. * -----------------------------------------------------------| {o o} *
  6. * SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus, | / ' ' \ *
  7. * Scryn, Rennard, Swordbearer, Gorog, Grishnakh, Nivek, |~'~.VxvxV.~'~*
  8. * Tricops, Fireblade, Edmond, Conran | *
  9. * ------------------------------------------------------------------------ *
  10. * Merc 2.1 Diku Mud improvments copyright (C) 1992, 1993 by Michael *
  11. * Chastain, Michael Quan, and Mitchell Tse. *
  12. * Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
  13. * Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
  14. * ------------------------------------------------------------------------ *
  15. * Object manipulation module *
  16. ****************************************************************************/
  17.  
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include "mud.h"
  21. #include "bet.h"
  22.  
  23. /*
  24. * External functions
  25. */
  26. void write_corpses( CHAR_DATA * ch, const char *name, OBJ_DATA * objrem );
  27. void save_house_by_vnum( int vnum );
  28.  
  29. /*
  30. * how resistant an object is to damage -Thoric
  31. */
  32. short get_obj_resistance( OBJ_DATA * obj )
  33. {
  34. short resist;
  35.  
  36. resist = number_fuzzy( MAX_ITEM_IMPACT );
  37.  
  38. /*
  39. * magical items are more resistant
  40. */
  41. if( IS_OBJ_STAT( obj, ITEM_MAGIC ) )
  42. resist += number_fuzzy( 12 );
  43.  
  44. /*
  45. * metal objects are definately stronger
  46. */
  47. if( IS_OBJ_STAT( obj, ITEM_METAL ) )
  48. resist += number_fuzzy( 5 );
  49.  
  50. /*
  51. * organic objects are most likely weaker
  52. */
  53. if( IS_OBJ_STAT( obj, ITEM_ORGANIC ) )
  54. resist -= number_fuzzy( 5 );
  55.  
  56. /*
  57. * blessed objects should have a little bonus
  58. */
  59. if( IS_OBJ_STAT( obj, ITEM_BLESS ) )
  60. resist += number_fuzzy( 5 );
  61.  
  62. /*
  63. * lets make store inventory pretty tough
  64. */
  65. if( IS_OBJ_STAT( obj, ITEM_INVENTORY ) )
  66. resist += 20;
  67.  
  68. /*
  69. * okay... let's add some bonus/penalty for item level...
  70. */
  71. resist += ( obj->level / 10 ) - 2;
  72.  
  73. /*
  74. * and lasty... take armor or weapon's condition into consideration
  75. */
  76. if( obj->item_type == ITEM_ARMOR || obj->item_type == ITEM_WEAPON )
  77. resist += ( obj->value[0] / 2 ) - 2;
  78.  
  79. return URANGE( 10, resist, 99 );
  80. }
  81.  
  82. void get_obj( CHAR_DATA * ch, OBJ_DATA * obj, OBJ_DATA * container )
  83. {
  84. VAULT_DATA *vault;
  85. int weight;
  86. int amt; /* gold per-race multipliers */
  87.  
  88. if( !CAN_WEAR( obj, ITEM_TAKE ) && ( ch->level < sysdata.level_getobjnotake ) )
  89. {
  90. send_to_char( "You can't take that.\r\n", ch );
  91. return;
  92. }
  93.  
  94. if( IS_SET( obj->magic_flags, ITEM_PKDISARMED ) && !IS_NPC( ch ) )
  95. {
  96. if( CAN_PKILL( ch ) && !get_timer( ch, TIMER_PKILLED ) )
  97. {
  98. if( !is_name( ch->name, obj->action_desc ) && !IS_IMMORTAL( ch ) )
  99. {
  100. send_to_char_color( "\r\n&bA godly force freezes your outstretched hand.\r\n", ch );
  101. return;
  102. }
  103. else
  104. {
  105. REMOVE_BIT( obj->magic_flags, ITEM_PKDISARMED );
  106. STRFREE( obj->action_desc );
  107. obj->action_desc = STRALLOC( "" );
  108. }
  109. }
  110. else
  111. {
  112. send_to_char_color( "\r\n&BA godly force freezes your outstretched hand.\r\n", ch );
  113. return;
  114. }
  115. }
  116.  
  117. if( IS_OBJ_STAT( obj, ITEM_PROTOTYPE ) && !can_take_proto( ch ) )
  118. {
  119. send_to_char( "A godly force prevents you from getting close to it.\r\n", ch );
  120. return;
  121. }
  122.  
  123. if( ch->carry_number + get_obj_number( obj ) > can_carry_n( ch ) )
  124. {
  125. act( AT_PLAIN, "$d: you can't carry that many items.", ch, NULL, obj->short_descr, TO_CHAR );
  126. return;
  127. }
  128.  
  129. if( IS_OBJ_STAT( obj, ITEM_COVERING ) )
  130. weight = obj->weight;
  131. else
  132. weight = get_obj_weight( obj );
  133.  
  134. /*
  135. * Money weight shouldn't count
  136. */
  137. if( obj->item_type != ITEM_MONEY )
  138. {
  139. if( obj->in_obj )
  140. {
  141. OBJ_DATA *tobj = obj->in_obj;
  142. int inobj = 1;
  143. bool checkweight = FALSE;
  144.  
  145. /*
  146. * need to make it check weight if its in a magic container
  147. */
  148. if( tobj->item_type == ITEM_CONTAINER && IS_OBJ_STAT( tobj, ITEM_MAGIC ) )
  149. checkweight = TRUE;
  150.  
  151. while( tobj->in_obj )
  152. {
  153. tobj = tobj->in_obj;
  154. inobj++;
  155.  
  156. /*
  157. * need to make it check weight if its in a magic container
  158. */
  159. if( tobj->item_type == ITEM_CONTAINER && IS_OBJ_STAT( tobj, ITEM_MAGIC ) )
  160. checkweight = TRUE;
  161. }
  162.  
  163. /*
  164. * need to check weight if not carried by ch or in a magic container.
  165. */
  166. if( !tobj->carried_by || tobj->carried_by != ch || checkweight )
  167. {
  168. if( ( ch->carry_weight + weight ) > can_carry_w( ch ) )
  169. {
  170. act( AT_PLAIN, "$d: you can't carry that much weight.", ch, NULL, obj->short_descr, TO_CHAR );
  171. return;
  172. }
  173. }
  174. }
  175. else if( ( ch->carry_weight + weight ) > can_carry_w( ch ) )
  176. {
  177. act( AT_PLAIN, "$d: you can't carry that much weight.", ch, NULL, obj->short_descr, TO_CHAR );
  178. return;
  179. }
  180. }
  181.  
  182. if( container )
  183. {
  184. if( container->item_type == ITEM_KEYRING && !IS_OBJ_STAT( container, ITEM_COVERING ) )
  185. {
  186. act( AT_ACTION, "You remove $p from $P", ch, obj, container, TO_CHAR );
  187. act( AT_ACTION, "$n removes $p from $P", ch, obj, container, TO_ROOM );
  188. }
  189. else
  190. {
  191. act( AT_ACTION, IS_OBJ_STAT( container, ITEM_COVERING ) ?
  192. "You get $p from beneath $P." : "You get $p from $P", ch, obj, container, TO_CHAR );
  193. act( AT_ACTION, IS_OBJ_STAT( container, ITEM_COVERING ) ?
  194. "$n gets $p from beneath $P." : "$n gets $p from $P", ch, obj, container, TO_ROOM );
  195. }
  196. if( IS_OBJ_STAT( container, ITEM_CLANCORPSE ) && !IS_NPC( ch ) && str_cmp( container->name + 7, ch->name ) )
  197. container->value[5]++;
  198. obj_from_obj( obj );
  199. }
  200. else
  201. {
  202. act( AT_ACTION, "You get $p.", ch, obj, container, TO_CHAR );
  203. act( AT_ACTION, "$n gets $p.", ch, obj, container, TO_ROOM );
  204. obj_from_room( obj );
  205. }
  206.  
  207. if( xIS_SET( ch->in_room->room_flags, ROOM_HOUSE ) )
  208. save_house_by_vnum( ch->in_room->vnum ); /* House Object Saving */
  209.  
  210. /*
  211. * Clan storeroom checks
  212. */
  213. if( xIS_SET( ch->in_room->room_flags, ROOM_CLANSTOREROOM ) && ( !container || container->carried_by == NULL ) )
  214. {
  215. for( vault = first_vault; vault; vault = vault->next )
  216. if( vault->vnum == ch->in_room->vnum )
  217. save_storeroom( ch, vault->vnum );
  218. }
  219.  
  220. check_for_trap( ch, obj, TRAP_GET );
  221. if( char_died( ch ) )
  222. return;
  223.  
  224. if( obj->item_type == ITEM_MONEY )
  225. {
  226. amt = obj->value[0] * obj->count;
  227.  
  228. ch->gold += amt;
  229. extract_obj( obj );
  230. }
  231. else
  232. obj = obj_to_char( obj, ch );
  233.  
  234. if( char_died( ch ) || obj_extracted( obj ) )
  235. return;
  236. oprog_get_trigger( ch, obj );
  237. return;
  238. }
  239.  
  240. void do_connect( CHAR_DATA *ch, const char *argument )
  241. {
  242. OBJ_DATA *first_ob;
  243. OBJ_DATA *second_ob;
  244. OBJ_DATA *new_ob;
  245. char arg1[MAX_STRING_LENGTH], arg2[MAX_STRING_LENGTH];
  246.  
  247. argument = one_argument( argument, arg1 );
  248. argument = one_argument( argument, arg2 );
  249.  
  250. if( arg1[0] == '\0' || arg2[0] == '\0' )
  251. {
  252. send_to_char( "Connect what to what?\r\n", ch );
  253. return;
  254. }
  255.  
  256. if( ( first_ob = get_obj_carry( ch, arg1 ) ) == NULL )
  257. {
  258. send_to_char( "You aren't holding the necessary objects.\r\n", ch );
  259. return;
  260. }
  261.  
  262. if( ( second_ob = get_obj_carry( ch, arg2 ) ) == NULL )
  263. {
  264. send_to_char( "You aren't holding the necessary objects.\r\n", ch );
  265. return;
  266. }
  267.  
  268. separate_obj( first_ob );
  269. separate_obj( second_ob );
  270.  
  271. if( first_ob->item_type != ITEM_PIECE || second_ob->item_type !=ITEM_PIECE )
  272. {
  273. send_to_char( "You stare at them for a moment, but these items clearly don't go together.\r\n", ch );
  274. return;
  275. }
  276.  
  277. /* check to see if the pieces connect */
  278. if( ( first_ob->value[0] == second_ob->pIndexData->vnum ) || ( first_ob->value[1] == second_ob->pIndexData->vnum ) )
  279. /* good connection */
  280. {
  281. new_ob = create_object( get_obj_index( first_ob->value[2] ), ch->level );
  282. extract_obj( first_ob );
  283. extract_obj( second_ob );
  284. obj_to_char( new_ob , ch );
  285. act( AT_ACTION, "$n cobbles some objects together.... suddenly they snap together, creating $p!", ch, new_ob,NULL, TO_ROOM );
  286. act( AT_ACTION, "You cobble the objects together.... suddenly they snap together, creating $p!", ch, new_ob, NULL, TO_CHAR );
  287. }
  288. else
  289. {
  290. act( AT_ACTION, "$n jiggles some objects against each other, but can't seem to make them connect.", ch, NULL, NULL, TO_ROOM );
  291. act( AT_ACTION, "You try to fit them together every which way, but they just don't want to connect.", ch, NULL, NULL, TO_CHAR );
  292. }
  293. }
  294.  
  295. void do_get( CHAR_DATA* ch, const char* argument)
  296. {
  297. char arg1[MAX_INPUT_LENGTH];
  298. char arg2[MAX_INPUT_LENGTH];
  299. OBJ_DATA *obj;
  300. OBJ_DATA *obj_next;
  301. OBJ_DATA *container;
  302. short number;
  303. bool found;
  304.  
  305. argument = one_argument( argument, arg1 );
  306.  
  307. if( ch->carry_number < 0 || ch->carry_weight < 0 )
  308. {
  309. send_to_char( "Uh oh ... better contact an immortal about your number or weight of items carried.\r\n", ch );
  310. log_printf( "%s has negative carry_number or carry_weight!", ch->name );
  311. return;
  312. }
  313.  
  314. if( is_number( arg1 ) )
  315. {
  316. number = atoi( arg1 );
  317. if( number < 1 )
  318. {
  319. send_to_char( "That was easy...\r\n", ch );
  320. return;
  321. }
  322. if( ( ch->carry_number + number ) > can_carry_n( ch ) )
  323. {
  324. send_to_char( "You can't carry that many.\r\n", ch );
  325. return;
  326. }
  327. argument = one_argument( argument, arg1 );
  328. }
  329. else
  330. number = 0;
  331. argument = one_argument( argument, arg2 );
  332. /*
  333. * munch optional words
  334. */
  335. if( !str_cmp( arg2, "from" ) && argument[0] != '\0' )
  336. argument = one_argument( argument, arg2 );
  337.  
  338. /*
  339. * Get type.
  340. */
  341. if( arg1[0] == '\0' )
  342. {
  343. send_to_char( "Get what?\r\n", ch );
  344. return;
  345. }
  346.  
  347. if( ms_find_obj( ch ) )
  348. return;
  349.  
  350. if( arg2[0] == '\0' )
  351. {
  352. if( number <= 1 && str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) )
  353. {
  354. /*
  355. * 'get obj'
  356. */
  357. obj = get_obj_list( ch, arg1, ch->in_room->first_content );
  358. if( !obj )
  359. {
  360. act( AT_PLAIN, "I see no $T here.", ch, NULL, arg1, TO_CHAR );
  361. return;
  362. }
  363. separate_obj( obj );
  364. get_obj( ch, obj, NULL );
  365. if( char_died( ch ) )
  366. return;
  367. if( IS_SET( sysdata.save_flags, SV_GET ) )
  368. save_char_obj( ch );
  369. }
  370. else
  371. {
  372. short cnt = 0;
  373. bool fAll;
  374. char *chk;
  375.  
  376. if( xIS_SET( ch->in_room->room_flags, ROOM_DONATION ) )
  377. {
  378. send_to_char( "The gods frown upon such a display of greed!\r\n", ch );
  379. return;
  380. }
  381. if( !str_cmp( arg1, "all" ) )
  382. fAll = TRUE;
  383. else
  384. fAll = FALSE;
  385. if( number > 1 )
  386. chk = arg1;
  387. else
  388. chk = &arg1[4];
  389. /*
  390. * 'get all' or 'get all.obj'
  391. */
  392. found = FALSE;
  393. for( obj = ch->in_room->last_content; obj; obj = obj_next )
  394. {
  395. obj_next = obj->prev_content;
  396. if( ( fAll || nifty_is_name( chk, obj->name ) ) && can_see_obj( ch, obj ) )
  397. {
  398. found = TRUE;
  399. if( number && ( cnt + obj->count ) > number )
  400. split_obj( obj, number - cnt );
  401. cnt += obj->count;
  402. get_obj( ch, obj, NULL );
  403. if( char_died( ch )
  404. || ch->carry_number >= can_carry_n( ch )
  405. || ch->carry_weight >= can_carry_w( ch ) || ( number && cnt >= number ) )
  406. {
  407. if( IS_SET( sysdata.save_flags, SV_GET ) && !char_died( ch ) )
  408. save_char_obj( ch );
  409. return;
  410. }
  411. }
  412. }
  413.  
  414. if( !found )
  415. {
  416. if( fAll )
  417. send_to_char( "I see nothing here.\r\n", ch );
  418. else
  419. act( AT_PLAIN, "I see no $T here.", ch, NULL, chk, TO_CHAR );
  420. }
  421. else if( IS_SET( sysdata.save_flags, SV_GET ) )
  422. save_char_obj( ch );
  423. }
  424. }
  425. else
  426. {
  427. /*
  428. * 'get ... container'
  429. */
  430. if( !str_cmp( arg2, "all" ) || !str_prefix( "all.", arg2 ) )
  431. {
  432. send_to_char( "You can't do that.\r\n", ch );
  433. return;
  434. }
  435.  
  436. if( ( container = get_obj_here( ch, arg2 ) ) == NULL )
  437. {
  438. act( AT_PLAIN, "I see no $T here.", ch, NULL, arg2, TO_CHAR );
  439. return;
  440. }
  441.  
  442. switch ( container->item_type )
  443. {
  444. default:
  445. if( !IS_OBJ_STAT( container, ITEM_COVERING ) )
  446. {
  447. send_to_char( "That's not a container.\r\n", ch );
  448. return;
  449. }
  450. if( ch->carry_weight + container->weight > can_carry_w( ch ) )
  451. {
  452. send_to_char( "It's too heavy for you to lift.\r\n", ch );
  453. return;
  454. }
  455. break;
  456.  
  457. case ITEM_CONTAINER:
  458. case ITEM_CORPSE_NPC:
  459. case ITEM_KEYRING:
  460. case ITEM_QUIVER:
  461. break;
  462.  
  463. case ITEM_CORPSE_PC:
  464. {
  465. char name[MAX_INPUT_LENGTH];
  466. CHAR_DATA *gch;
  467. const char *pd;
  468.  
  469. if( IS_NPC( ch ) )
  470. {
  471. send_to_char( "You can't do that.\r\n", ch );
  472. return;
  473. }
  474.  
  475. pd = container->short_descr;
  476. pd = one_argument( pd, name );
  477. pd = one_argument( pd, name );
  478. pd = one_argument( pd, name );
  479. pd = one_argument( pd, name );
  480.  
  481. if( IS_OBJ_STAT( container, ITEM_CLANCORPSE )
  482. && !IS_NPC( ch ) && ( get_timer( ch, TIMER_PKILLED ) > 0 ) && str_cmp( name, ch->name ) )
  483. {
  484. send_to_char( "You cannot loot from that corpse...yet.\r\n", ch );
  485. return;
  486. }
  487.  
  488. /*
  489. * Killer/owner loot only if die to pkill blow --Blod
  490. */
  491. /*
  492. * Added check for immortal so IMMS can get things out of
  493. * * corpses --Shaddai
  494. */
  495.  
  496. if( IS_OBJ_STAT( container, ITEM_CLANCORPSE )
  497. && !IS_NPC( ch ) && !IS_IMMORTAL( ch )
  498. && container->action_desc[0] != '\0'
  499. && str_cmp( name, ch->name ) && str_cmp( container->action_desc, ch->name ) )
  500. {
  501. send_to_char( "You did not inflict the death blow upon this corpse.\r\n", ch );
  502. return;
  503. }
  504.  
  505. if( IS_OBJ_STAT( container, ITEM_CLANCORPSE ) && !IS_IMMORTAL( ch )
  506. && !IS_NPC( ch ) && str_cmp( name, ch->name ) && container->value[5] >= 3 )
  507. {
  508. send_to_char( "Frequent looting has left this corpse protected by the gods.\r\n", ch );
  509. return;
  510. }
  511.  
  512. if( IS_OBJ_STAT( container, ITEM_CLANCORPSE )
  513. && !IS_NPC( ch ) && IS_SET( ch->pcdata->flags, PCFLAG_DEADLY )
  514. && container->value[4] - ch->level < 6 && container->value[4] - ch->level > -6 )
  515. break;
  516.  
  517. if( !str_cmp( name, ch->name ) && !IS_IMMORTAL( ch ) )
  518. {
  519. bool fGroup;
  520.  
  521. fGroup = FALSE;
  522. for( gch = first_char; gch; gch = gch->next )
  523. {
  524. if( !IS_NPC( gch ) && is_same_group( ch, gch ) && !str_cmp( name, gch->name ) )
  525. {
  526. fGroup = TRUE;
  527. break;
  528. }
  529. }
  530.  
  531. if( !fGroup )
  532. {
  533. send_to_char( "That's someone else's corpse.\r\n", ch );
  534. return;
  535. }
  536. }
  537. }
  538. }
  539.  
  540. if( !IS_OBJ_STAT( container, ITEM_COVERING ) && IS_SET( container->value[1], CONT_CLOSED ) )
  541. {
  542. act( AT_PLAIN, "The $d is closed.", ch, NULL, container->name, TO_CHAR );
  543. return;
  544. }
  545.  
  546. if( number <= 1 && str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) )
  547. {
  548. /*
  549. * 'get obj container'
  550. */
  551. obj = get_obj_list( ch, arg1, container->first_content );
  552. if( !obj )
  553. {
  554. act( AT_PLAIN, IS_OBJ_STAT( container, ITEM_COVERING ) ?
  555. "I see nothing like that beneath the $T." : "I see nothing like that in the $T.", ch, NULL, container->short_descr, TO_CHAR );
  556. return;
  557. }
  558. separate_obj( obj );
  559. get_obj( ch, obj, container );
  560. /*
  561. * Oops no wonder corpses were duping oopsie did I do that
  562. * * --Shaddai
  563. */
  564. if( container->item_type == ITEM_CORPSE_PC )
  565. write_corpses( NULL, container->short_descr + 14, NULL );
  566. check_for_trap( ch, container, TRAP_GET );
  567. if( char_died( ch ) )
  568. return;
  569. if( IS_SET( sysdata.save_flags, SV_GET ) )
  570. save_char_obj( ch );
  571. }
  572. else
  573. {
  574. int cnt = 0;
  575. bool fAll;
  576. char *chk;
  577.  
  578. /*
  579. * 'get all container' or 'get all.obj container'
  580. */
  581. if( IS_OBJ_STAT( container, ITEM_DONATION ) )
  582. {
  583. send_to_char( "The gods frown upon such an act of greed!\r\n", ch );
  584. return;
  585. }
  586.  
  587. if( IS_OBJ_STAT( container, ITEM_CLANCORPSE )
  588. && !IS_IMMORTAL( ch ) && !IS_NPC( ch ) && str_cmp( ch->name, container->name + 7 ) )
  589. {
  590. send_to_char( "The gods frown upon such wanton greed!\r\n", ch );
  591. return;
  592. }
  593.  
  594. if( !str_cmp( arg1, "all" ) )
  595. fAll = TRUE;
  596. else
  597. fAll = FALSE;
  598. if( number > 1 )
  599. chk = arg1;
  600. else
  601. chk = &arg1[4];
  602. found = FALSE;
  603. for( obj = container->first_content; obj; obj = obj_next )
  604. {
  605. obj_next = obj->next_content;
  606. if( ( fAll || nifty_is_name( chk, obj->name ) ) && can_see_obj( ch, obj ) )
  607. {
  608. found = TRUE;
  609. if( number && ( cnt + obj->count ) > number )
  610. split_obj( obj, number - cnt );
  611. cnt += obj->count;
  612. get_obj( ch, obj, container );
  613. if( char_died( ch )
  614. || ch->carry_number >= can_carry_n( ch )
  615. || ch->carry_weight >= can_carry_w( ch ) || ( number && cnt >= number ) )
  616. {
  617. if( container->item_type == ITEM_CORPSE_PC )
  618. write_corpses( NULL, container->short_descr + 14, NULL );
  619. if( found && IS_SET( sysdata.save_flags, SV_GET ) )
  620. save_char_obj( ch );
  621. return;
  622. }
  623. }
  624. }
  625.  
  626. if( !found )
  627. {
  628. if( fAll )
  629. {
  630. if( container->item_type == ITEM_KEYRING && !IS_OBJ_STAT( container, ITEM_COVERING ) )
  631. act( AT_PLAIN, "The $T holds no keys.", ch, NULL, container->short_descr, TO_CHAR );
  632. else
  633. act( AT_PLAIN, IS_OBJ_STAT( container, ITEM_COVERING ) ?
  634. "I see nothing beneath the $T." : "I see nothing in the $T.", ch, NULL, container->short_descr, TO_CHAR );
  635. }
  636. else
  637. {
  638. if( container->item_type == ITEM_KEYRING && !IS_OBJ_STAT( container, ITEM_COVERING ) )
  639. act( AT_PLAIN, "The $T does not hold that key.", ch, NULL, container->short_descr, TO_CHAR );
  640. else
  641. act( AT_PLAIN, IS_OBJ_STAT( container, ITEM_COVERING ) ?
  642. "I see nothing like that beneath the $T." :
  643. "I see nothing like that in the $T.", ch, NULL, container->short_descr, TO_CHAR );
  644. }
  645. }
  646. else
  647. check_for_trap( ch, container, TRAP_GET );
  648. if( char_died( ch ) )
  649. return;
  650. /*
  651. * Oops no wonder corpses were duping oopsie did I do that
  652. * * --Shaddai
  653. */
  654. if( container->item_type == ITEM_CORPSE_PC )
  655. write_corpses( NULL, container->short_descr + 14, NULL );
  656. if( found && IS_SET( sysdata.save_flags, SV_GET ) )
  657. save_char_obj( ch );
  658. }
  659. }
  660. return;
  661. }
  662.  
  663. void do_put( CHAR_DATA* ch, const char* argument)
  664. {
  665. char arg1[MAX_INPUT_LENGTH];
  666. char arg2[MAX_INPUT_LENGTH];
  667. OBJ_DATA *container;
  668. OBJ_DATA *obj;
  669. OBJ_DATA *obj_next;
  670. VAULT_DATA *vault;
  671. short count;
  672. int number;
  673. bool save_char = FALSE;
  674.  
  675. argument = one_argument( argument, arg1 );
  676. if( is_number( arg1 ) )
  677. {
  678. number = atoi( arg1 );
  679. if( number < 1 )
  680. {
  681. send_to_char( "That was easy...\r\n", ch );
  682. return;
  683. }
  684. argument = one_argument( argument, arg1 );
  685. }
  686. else
  687. number = 0;
  688. argument = one_argument( argument, arg2 );
  689. /*
  690. * munch optional words
  691. */
  692. if( ( !str_cmp( arg2, "into" ) || !str_cmp( arg2, "inside" )
  693. || !str_cmp( arg2, "in" ) || !str_cmp( arg2, "under" )
  694. || !str_cmp( arg2, "onto" ) || !str_cmp( arg2, "on" ) ) && argument[0] != '\0' )
  695. argument = one_argument( argument, arg2 );
  696.  
  697. if( arg1[0] == '\0' || arg2[0] == '\0' )
  698. {
  699. send_to_char( "Put what in what?\r\n", ch );
  700. return;
  701. }
  702.  
  703. if( ms_find_obj( ch ) )
  704. return;
  705.  
  706. if( !str_cmp( arg2, "all" ) || !str_prefix( "all.", arg2 ) )
  707. {
  708. send_to_char( "You can't do that.\r\n", ch );
  709. return;
  710. }
  711.  
  712. if( ( container = get_obj_here( ch, arg2 ) ) == NULL )
  713. {
  714. act( AT_PLAIN, "I see no $T here.", ch, NULL, arg2, TO_CHAR );
  715. return;
  716. }
  717.  
  718. if( !container->carried_by && IS_SET( sysdata.save_flags, SV_PUT ) )
  719. save_char = TRUE;
  720.  
  721. if( IS_OBJ_STAT( container, ITEM_COVERING ) )
  722. {
  723. if( ch->carry_weight + container->weight > can_carry_w( ch ) )
  724. {
  725. send_to_char( "It's too heavy for you to lift.\r\n", ch );
  726. return;
  727. }
  728. }
  729. else
  730. {
  731. if( container->item_type != ITEM_CONTAINER
  732. && container->item_type != ITEM_KEYRING && container->item_type != ITEM_QUIVER )
  733. {
  734. send_to_char( "That's not a container.\r\n", ch );
  735. return;
  736. }
  737.  
  738. if( IS_SET( container->value[1], CONT_CLOSED ) )
  739. {
  740. act( AT_PLAIN, "The $d is closed.", ch, NULL, container->name, TO_CHAR );
  741. return;
  742. }
  743. }
  744.  
  745. if( number <= 1 && str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) )
  746. {
  747. /*
  748. * 'put obj container'
  749. */
  750. if( ( obj = get_obj_carry( ch, arg1 ) ) == NULL )
  751. {
  752. send_to_char( "You do not have that item.\r\n", ch );
  753. return;
  754. }
  755.  
  756. if( obj == container )
  757. {
  758. send_to_char( "You can't fold it into itself.\r\n", ch );
  759. return;
  760. }
  761.  
  762. if( !can_drop_obj( ch, obj ) )
  763. {
  764. send_to_char( "You can't let go of it.\r\n", ch );
  765. return;
  766. }
  767.  
  768. if( container->item_type == ITEM_KEYRING && obj->item_type != ITEM_KEY )
  769. {
  770. send_to_char( "That's not a key.\r\n", ch );
  771. return;
  772. }
  773.  
  774. if( container->item_type == ITEM_QUIVER && obj->item_type != ITEM_PROJECTILE )
  775. {
  776. send_to_char( "That's not a projectile.\r\n", ch );
  777. return;
  778. }
  779.  
  780. // Fix by Luc - Sometime in 2000?
  781. {
  782. int tweight = ( get_real_obj_weight( container ) / container->count ) + ( get_real_obj_weight( obj ) / obj->count );
  783.  
  784. if( IS_OBJ_STAT( container, ITEM_COVERING ) )
  785. {
  786. if( container->item_type == ITEM_CONTAINER
  787. ? tweight > container->value[0] : tweight - container->weight > container->weight )
  788. {
  789. send_to_char( "It won't fit under there.\r\n", ch );
  790. return;
  791. }
  792. }
  793. else if( tweight - container->weight > container->value[0] )
  794. {
  795. send_to_char( "It won't fit.\r\n", ch );
  796. return;
  797. }
  798. }
  799. // Fix end
  800.  
  801. if( container->in_room && container->in_room->max_weight
  802. && container->in_room->max_weight < get_real_obj_weight( obj ) / obj->count + container->in_room->weight )
  803. {
  804. send_to_char( "It won't fit.\r\n", ch );
  805. return;
  806. }
  807.  
  808. separate_obj( obj );
  809. separate_obj( container );
  810. obj_from_char( obj );
  811. obj = obj_to_obj( obj, container );
  812. check_for_trap( ch, container, TRAP_PUT );
  813. if( char_died( ch ) )
  814. return;
  815. count = obj->count;
  816. obj->count = 1;
  817. if( container->item_type == ITEM_KEYRING && !IS_OBJ_STAT( container, ITEM_COVERING ) )
  818. {
  819. act( AT_ACTION, "$n slips $p onto $P.", ch, obj, container, TO_ROOM );
  820. act( AT_ACTION, "You slip $p onto $P.", ch, obj, container, TO_CHAR );
  821. }
  822. else
  823. {
  824. act( AT_ACTION, IS_OBJ_STAT( container, ITEM_COVERING )
  825. ? "$n hides $p beneath $P." : "$n puts $p in $P.", ch, obj, container, TO_ROOM );
  826. act( AT_ACTION, IS_OBJ_STAT( container, ITEM_COVERING )
  827. ? "You hide $p beneath $P." : "You put $p in $P.", ch, obj, container, TO_CHAR );
  828. }
  829. obj->count = count;
  830.  
  831. /*
  832. * Oops no wonder corpses were duping oopsie did I do that
  833. * * --Shaddai
  834. */
  835. if( container->item_type == ITEM_CORPSE_PC )
  836. write_corpses( NULL, container->short_descr + 14, NULL );
  837.  
  838. if( save_char )
  839. save_char_obj( ch );
  840.  
  841. if( xIS_SET( ch->in_room->room_flags, ROOM_HOUSE ) )
  842. save_house_by_vnum( ch->in_room->vnum ); /* House Object Saving */
  843.  
  844. /*
  845. * Clan storeroom check
  846. */
  847. if( xIS_SET( ch->in_room->room_flags, ROOM_CLANSTOREROOM ) && container->carried_by == NULL )
  848. {
  849. for( vault = first_vault; vault; vault = vault->next )
  850. if( vault->vnum == ch->in_room->vnum )
  851. save_storeroom( ch, vault->vnum );
  852. }
  853. }
  854. else
  855. {
  856. bool found = FALSE;
  857. int cnt = 0;
  858. bool fAll;
  859. char *chk;
  860.  
  861. if( !str_cmp( arg1, "all" ) )
  862. fAll = TRUE;
  863. else
  864. fAll = FALSE;
  865. if( number > 1 )
  866. chk = arg1;
  867. else
  868. chk = &arg1[4];
  869.  
  870. separate_obj( container );
  871. /*
  872. * 'put all container' or 'put all.obj container'
  873. */
  874. for( obj = ch->first_carrying; obj; obj = obj_next )
  875. {
  876. obj_next = obj->next_content;
  877.  
  878. if( ( fAll || nifty_is_name( chk, obj->name ) )
  879. && can_see_obj( ch, obj )
  880. && obj->wear_loc == WEAR_NONE
  881. && obj != container
  882. && can_drop_obj( ch, obj )
  883. && ( container->item_type != ITEM_KEYRING || obj->item_type == ITEM_KEY )
  884. && ( container->item_type != ITEM_QUIVER || obj->item_type == ITEM_PROJECTILE )
  885. && get_obj_weight( obj ) + get_obj_weight( container ) <= container->value[0] )
  886. {
  887. if( number && ( cnt + obj->count ) > number )
  888. split_obj( obj, number - cnt );
  889. cnt += obj->count;
  890. obj_from_char( obj );
  891. if( container->item_type == ITEM_KEYRING )
  892. {
  893. act( AT_ACTION, "$n slips $p onto $P.", ch, obj, container, TO_ROOM );
  894. act( AT_ACTION, "You slip $p onto $P.", ch, obj, container, TO_CHAR );
  895. }
  896. else
  897. {
  898. act( AT_ACTION, "$n puts $p in $P.", ch, obj, container, TO_ROOM );
  899. act( AT_ACTION, "You put $p in $P.", ch, obj, container, TO_CHAR );
  900. }
  901. obj = obj_to_obj( obj, container );
  902. found = TRUE;
  903.  
  904. check_for_trap( ch, container, TRAP_PUT );
  905. if( char_died( ch ) )
  906. return;
  907. if( number && cnt >= number )
  908. break;
  909. }
  910. }
  911.  
  912. /*
  913. * Don't bother to save anything if nothing was dropped -Thoric
  914. */
  915. if( !found )
  916. {
  917. if( fAll )
  918. act( AT_PLAIN, "You are not carrying anything.", ch, NULL, NULL, TO_CHAR );
  919. else
  920. act( AT_PLAIN, "You are not carrying any $T.", ch, NULL, chk, TO_CHAR );
  921. return;
  922. }
  923.  
  924. if( save_char )
  925. save_char_obj( ch );
  926. /*
  927. * Oops no wonder corpses were duping oopsie did I do that
  928. * * --Shaddai
  929. */
  930. if( container->item_type == ITEM_CORPSE_PC )
  931. write_corpses( NULL, container->short_descr + 14, NULL );
  932.  
  933. if( xIS_SET( ch->in_room->room_flags, ROOM_HOUSE ) )
  934. save_house_by_vnum( ch->in_room->vnum ); /* House Object Saving */
  935.  
  936. /*
  937. * Clan storeroom check
  938. */
  939. if( xIS_SET( ch->in_room->room_flags, ROOM_CLANSTOREROOM ) && container->carried_by == NULL )
  940. {
  941. for( vault = first_vault; vault; vault = vault->next )
  942. if( vault->vnum == ch->in_room->vnum )
  943. save_storeroom( ch, vault->vnum );
  944. }
  945. }
  946. return;
  947. }
  948.  
  949. void do_drop( CHAR_DATA* ch, const char* argument)
  950. {
  951. char arg[MAX_INPUT_LENGTH];
  952. OBJ_DATA *obj;
  953. OBJ_DATA *obj_next;
  954. bool found;
  955. VAULT_DATA *vault;
  956. int number;
  957.  
  958. argument = one_argument( argument, arg );
  959. if( is_number( arg ) )
  960. {
  961. number = atoi( arg );
  962. if( number < 1 )
  963. {
  964. send_to_char( "That was easy...\r\n", ch );
  965. return;
  966. }
  967. argument = one_argument( argument, arg );
  968. }
  969. else
  970. number = 0;
  971.  
  972. if( arg[0] == '\0' )
  973. {
  974. send_to_char( "Drop what?\r\n", ch );
  975. return;
  976. }
  977.  
  978. if( ms_find_obj( ch ) )
  979. return;
  980.  
  981. if( !IS_NPC( ch ) && xIS_SET( ch->act, PLR_LITTERBUG ) )
  982. {
  983. set_char_color( AT_YELLOW, ch );
  984. send_to_char( "A godly force prevents you from dropping anything...\r\n", ch );
  985. return;
  986. }
  987.  
  988. if( xIS_SET( ch->in_room->room_flags, ROOM_NODROP ) && ch != supermob )
  989. {
  990. set_char_color( AT_MAGIC, ch );
  991. send_to_char( "A magical force stops you!\r\n", ch );
  992. set_char_color( AT_TELL, ch );
  993. send_to_char( "Someone tells you, 'No littering here!'\r\n", ch );
  994. return;
  995. }
  996.  
  997. if( number > 0 )
  998. {
  999. /*
  1000. * 'drop NNNN coins'
  1001. */
  1002. if( !str_cmp( arg, "coins" ) || !str_cmp( arg, "coin" ) )
  1003. {
  1004. if( ch->gold < number )
  1005. {
  1006. send_to_char( "You haven't got that many coins.\r\n", ch );
  1007. return;
  1008. }
  1009.  
  1010. ch->gold -= number;
  1011.  
  1012. for( obj = ch->in_room->first_content; obj; obj = obj_next )
  1013. {
  1014. obj_next = obj->next_content;
  1015.  
  1016. switch ( obj->pIndexData->vnum )
  1017. {
  1018. case OBJ_VNUM_MONEY_ONE:
  1019. number += 1;
  1020. extract_obj( obj );
  1021. break;
  1022.  
  1023. case OBJ_VNUM_MONEY_SOME:
  1024. number += obj->value[0];
  1025. extract_obj( obj );
  1026. break;
  1027. }
  1028. }
  1029.  
  1030. act( AT_ACTION, "$n drops some gold.", ch, NULL, NULL, TO_ROOM );
  1031. obj_to_room( create_money( number ), ch->in_room );
  1032. send_to_char( "You let the gold slip from your hand.\r\n", ch );
  1033. if( IS_SET( sysdata.save_flags, SV_DROP ) )
  1034. save_char_obj( ch );
  1035. return;
  1036. }
  1037. }
  1038.  
  1039. if( number <= 1 && str_cmp( arg, "all" ) && str_prefix( "all.", arg ) )
  1040. {
  1041. /*
  1042. * 'drop obj'
  1043. */
  1044. if( ( obj = get_obj_carry( ch, arg ) ) == NULL )
  1045. {
  1046. send_to_char( "You do not have that item.\r\n", ch );
  1047. return;
  1048. }
  1049.  
  1050. if( !can_drop_obj( ch, obj ) )
  1051. {
  1052. send_to_char( "You can't let go of it.\r\n", ch );
  1053. return;
  1054. }
  1055.  
  1056. if( ch->in_room->max_weight > 0
  1057. && ch->in_room->max_weight < get_real_obj_weight( obj ) / obj->count + ch->in_room->weight )
  1058. {
  1059. send_to_char( "There is not enough room on the ground for that.\r\n", ch );
  1060. return;
  1061. }
  1062.  
  1063. separate_obj( obj );
  1064. act( AT_ACTION, "$n drops $p.", ch, obj, NULL, TO_ROOM );
  1065. act( AT_ACTION, "You drop $p.", ch, obj, NULL, TO_CHAR );
  1066.  
  1067. obj_from_char( obj );
  1068. obj = obj_to_room( obj, ch->in_room );
  1069. oprog_drop_trigger( ch, obj ); /* mudprogs */
  1070.  
  1071. if( char_died( ch ) || obj_extracted( obj ) )
  1072. return;
  1073.  
  1074. if( xIS_SET( ch->in_room->room_flags, ROOM_HOUSE ) )
  1075. save_house_by_vnum( ch->in_room->vnum ); /* House Object Saving */
  1076.  
  1077. /*
  1078. * Clan storeroom saving
  1079. */
  1080. if( xIS_SET( ch->in_room->room_flags, ROOM_CLANSTOREROOM ) )
  1081. {
  1082. for( vault = first_vault; vault; vault = vault->next )
  1083. if( vault->vnum == ch->in_room->vnum )
  1084. save_storeroom( ch, vault->vnum );
  1085. }
  1086. }
  1087. else
  1088. {
  1089. int cnt = 0;
  1090. char *chk;
  1091. bool fAll;
  1092.  
  1093. if( !str_cmp( arg, "all" ) )
  1094. fAll = TRUE;
  1095. else
  1096. fAll = FALSE;
  1097. if( number > 1 )
  1098. chk = arg;
  1099. else
  1100. chk = &arg[4];
  1101. /*
  1102. * 'drop all' or 'drop all.obj'
  1103. */
  1104. if( xIS_SET( ch->in_room->room_flags, ROOM_NODROPALL ) || xIS_SET( ch->in_room->room_flags, ROOM_CLANSTOREROOM ) )
  1105. {
  1106. send_to_char( "You can't seem to do that here...\r\n", ch );
  1107. return;
  1108. }
  1109.  
  1110. found = FALSE;
  1111. for( obj = ch->first_carrying; obj; obj = obj_next )
  1112. {
  1113. obj_next = obj->next_content;
  1114.  
  1115. if( ( fAll || nifty_is_name( chk, obj->name ) )
  1116. && can_see_obj( ch, obj ) && obj->wear_loc == WEAR_NONE && can_drop_obj( ch, obj )
  1117. && ( !ch->in_room->max_weight || ch->in_room->max_weight > get_real_obj_weight( obj ) / obj->count + ch->in_room->weight ) )
  1118. {
  1119. found = TRUE;
  1120. if( HAS_PROG( obj->pIndexData, DROP_PROG ) && obj->count > 1 )
  1121. {
  1122. ++cnt;
  1123. separate_obj( obj );
  1124. obj_from_char( obj );
  1125. if( !obj_next )
  1126. obj_next = ch->first_carrying;
  1127. }
  1128. else
  1129. {
  1130. if( number && ( cnt + obj->count ) > number )
  1131. split_obj( obj, number - cnt );
  1132. cnt += obj->count;
  1133. obj_from_char( obj );
  1134. }
  1135. act( AT_ACTION, "$n drops $p.", ch, obj, NULL, TO_ROOM );
  1136. act( AT_ACTION, "You drop $p.", ch, obj, NULL, TO_CHAR );
  1137. obj = obj_to_room( obj, ch->in_room );
  1138. oprog_drop_trigger( ch, obj ); /* mudprogs */
  1139. if( char_died( ch ) )
  1140. return;
  1141. if( number && cnt >= number )
  1142. break;
  1143. }
  1144. }
  1145.  
  1146. if( !found )
  1147. {
  1148. if( fAll )
  1149. act( AT_PLAIN, "You are not carrying anything.", ch, NULL, NULL, TO_CHAR );
  1150. else
  1151. act( AT_PLAIN, "You are not carrying any $T.", ch, NULL, chk, TO_CHAR );
  1152. }
  1153. }
  1154.  
  1155. if( xIS_SET( ch->in_room->room_flags, ROOM_HOUSE ) )
  1156. save_house_by_vnum( ch->in_room->vnum ); /* House Object Saving */
  1157.  
  1158. /*
  1159. * Clan storeroom saving
  1160. */
  1161. if( xIS_SET( ch->in_room->room_flags, ROOM_CLANSTOREROOM ) )
  1162. {
  1163. for( vault = first_vault; vault; vault = vault->next )
  1164. if( vault->vnum == ch->in_room->vnum )
  1165. save_storeroom( ch, vault->vnum );
  1166. }
  1167.  
  1168. if( IS_SET( sysdata.save_flags, SV_DROP ) )
  1169. save_char_obj( ch ); /* duping protector */
  1170. return;
  1171. }
  1172.  
  1173. void do_give( CHAR_DATA* ch, const char* argument)
  1174. {
  1175. char arg1[MAX_INPUT_LENGTH];
  1176. char arg2[MAX_INPUT_LENGTH];
  1177. char buf[MAX_INPUT_LENGTH];
  1178. CHAR_DATA *victim;
  1179. OBJ_DATA *obj;
  1180.  
  1181. argument = one_argument( argument, arg1 );
  1182. argument = one_argument( argument, arg2 );
  1183. if( !str_cmp( arg2, "to" ) && argument[0] != '\0' )
  1184. argument = one_argument( argument, arg2 );
  1185.  
  1186. if( arg1[0] == '\0' || arg2[0] == '\0' )
  1187. {
  1188. send_to_char( "Give what to whom?\r\n", ch );
  1189. return;
  1190. }
  1191.  
  1192. if( ms_find_obj( ch ) )
  1193. return;
  1194.  
  1195. if( is_number( arg1 ) )
  1196. {
  1197. /*
  1198. * 'give NNNN coins victim'
  1199. */
  1200. int amount;
  1201.  
  1202. amount = atoi( arg1 );
  1203. if( amount <= 0 || ( str_cmp( arg2, "coins" ) && str_cmp( arg2, "coin" ) ) )
  1204. {
  1205. send_to_char( "Sorry, you can't do that.\r\n", ch );
  1206. return;
  1207. }
  1208.  
  1209. argument = one_argument( argument, arg2 );
  1210. if( !str_cmp( arg2, "to" ) && argument[0] != '\0' )
  1211. argument = one_argument( argument, arg2 );
  1212. if( arg2[0] == '\0' )
  1213. {
  1214. send_to_char( "Give what to whom?\r\n", ch );
  1215. return;
  1216. }
  1217.  
  1218. if( ( victim = get_char_room( ch, arg2 ) ) == NULL )
  1219. {
  1220. send_to_char( "They aren't here.\r\n", ch );
  1221. return;
  1222. }
  1223.  
  1224. if( ch->gold < amount )
  1225. {
  1226. send_to_char( "Very generous of you, but you haven't got that much gold.\r\n", ch );
  1227. return;
  1228. }
  1229.  
  1230. ch->gold -= amount;
  1231. victim->gold += amount;
  1232. mudstrlcpy( buf, "$n gives you ", MAX_STRING_LENGTH );
  1233. mudstrlcat( buf, arg1, MAX_STRING_LENGTH );
  1234. mudstrlcat( buf, ( amount > 1 ) ? " coins." : " coin.", MAX_STRING_LENGTH );
  1235.  
  1236. set_char_color( AT_GOLD, victim );
  1237. act( AT_ACTION, buf, ch, NULL, victim, TO_VICT );
  1238. act( AT_ACTION, "$n gives $N some gold.", ch, NULL, victim, TO_NOTVICT );
  1239. act( AT_ACTION, "You give $N some gold.", ch, NULL, victim, TO_CHAR );
  1240. mprog_bribe_trigger( victim, ch, amount );
  1241. if( IS_SET( sysdata.save_flags, SV_GIVE ) && !char_died( ch ) )
  1242. save_char_obj( ch );
  1243. if( IS_SET( sysdata.save_flags, SV_RECEIVE ) && !char_died( victim ) )
  1244. save_char_obj( victim );
  1245. return;
  1246. }
  1247.  
  1248. if( ( obj = get_obj_carry( ch, arg1 ) ) == NULL )
  1249. {
  1250. send_to_char( "You do not have that item.\r\n", ch );
  1251. return;
  1252. }
  1253.  
  1254. if( obj->wear_loc != WEAR_NONE )
  1255. {
  1256. send_to_char( "You must remove it first.\r\n", ch );
  1257. return;
  1258. }
  1259.  
  1260. if( ( victim = get_char_room( ch, arg2 ) ) == NULL )
  1261. {
  1262. send_to_char( "They aren't here.\r\n", ch );
  1263. return;
  1264. }
  1265.  
  1266. if( !can_drop_obj( ch, obj ) )
  1267. {
  1268. send_to_char( "You can't let go of it.\r\n", ch );
  1269. return;
  1270. }
  1271.  
  1272. if( victim->carry_number + ( get_obj_number( obj ) / obj->count ) > can_carry_n( victim ) )
  1273. {
  1274. act( AT_PLAIN, "$N has $S hands full.", ch, NULL, victim, TO_CHAR );
  1275. return;
  1276. }
  1277.  
  1278. if( victim->carry_weight + ( get_obj_weight( obj ) / obj->count ) > can_carry_w( victim ) )
  1279. {
  1280. act( AT_PLAIN, "$N can't carry that much weight.", ch, NULL, victim, TO_CHAR );
  1281. return;
  1282. }
  1283.  
  1284. if( !can_see_obj( victim, obj ) )
  1285. {
  1286. act( AT_PLAIN, "$N can't see it.", ch, NULL, victim, TO_CHAR );
  1287. return;
  1288. }
  1289.  
  1290. if( IS_OBJ_STAT( obj, ITEM_PROTOTYPE ) && !can_take_proto( victim ) )
  1291. {
  1292. act( AT_PLAIN, "You cannot give that to $N!", ch, NULL, victim, TO_CHAR );
  1293. return;
  1294. }
  1295.  
  1296. separate_obj( obj );
  1297. obj_from_char( obj );
  1298. act( AT_ACTION, "$n gives $p to $N.", ch, obj, victim, TO_NOTVICT );
  1299. act( AT_ACTION, "$n gives you $p.", ch, obj, victim, TO_VICT );
  1300. act( AT_ACTION, "You give $p to $N.", ch, obj, victim, TO_CHAR );
  1301. obj = obj_to_char( obj, victim );
  1302. mprog_give_trigger( victim, ch, obj );
  1303. if( IS_SET( sysdata.save_flags, SV_GIVE ) && !char_died( ch ) )
  1304. save_char_obj( ch );
  1305. if( IS_SET( sysdata.save_flags, SV_RECEIVE ) && !char_died( victim ) )
  1306. save_char_obj( victim );
  1307. return;
  1308. }
  1309.  
  1310. /*
  1311. * Damage an object. -Thoric
  1312. * Affect player's AC if necessary.
  1313. * Make object into scraps if necessary.
  1314. * Send message about damaged object.
  1315. */
  1316. obj_ret damage_obj( OBJ_DATA * obj )
  1317. {
  1318. CHAR_DATA *ch;
  1319. obj_ret objcode;
  1320.  
  1321. if( IS_OBJ_STAT( obj, ITEM_PERMANENT ) )
  1322. return rNONE;
  1323.  
  1324. ch = obj->carried_by;
  1325. objcode = rNONE;
  1326.  
  1327. separate_obj( obj );
  1328. if( !IS_NPC( ch ) && ( !IS_PKILL( ch ) || ( IS_PKILL( ch ) && !IS_SET( ch->pcdata->flags, PCFLAG_GAG ) ) ) )
  1329. act( AT_OBJECT, "($p gets damaged)", ch, obj, NULL, TO_CHAR );
  1330. else if( obj->in_room && ( ch = obj->in_room->first_person ) != NULL )
  1331. {
  1332. act( AT_OBJECT, "($p gets damaged)", ch, obj, NULL, TO_ROOM );
  1333. act( AT_OBJECT, "($p gets damaged)", ch, obj, NULL, TO_CHAR );
  1334. ch = NULL;
  1335. }
  1336.  
  1337. if( obj->item_type != ITEM_LIGHT )
  1338. oprog_damage_trigger( ch, obj );
  1339. else if( !in_arena( ch ) )
  1340. oprog_damage_trigger( ch, obj );
  1341.  
  1342. if( obj_extracted( obj ) )
  1343. return global_objcode;
  1344.  
  1345. switch ( obj->item_type )
  1346. {
  1347. default:
  1348. make_scraps( obj );
  1349. objcode = rOBJ_SCRAPPED;
  1350. break;
  1351. case ITEM_CONTAINER:
  1352. case ITEM_KEYRING:
  1353. case ITEM_QUIVER:
  1354. if( --obj->value[3] <= 0 )
  1355. {
  1356. if( !in_arena( ch ) )
  1357. {
  1358. make_scraps( obj );
  1359. objcode = rOBJ_SCRAPPED;
  1360. }
  1361. else
  1362. obj->value[3] = 1;
  1363. }
  1364. break;
  1365. case ITEM_LIGHT:
  1366. if( --obj->value[0] <= 0 )
  1367. {
  1368. if( !in_arena( ch ) )
  1369. {
  1370. make_scraps( obj );
  1371. objcode = rOBJ_SCRAPPED;
  1372. }
  1373. else
  1374. obj->value[0] = 1;
  1375. }
  1376. break;
  1377. case ITEM_ARMOR:
  1378. if( ch && obj->value[0] >= 1 )
  1379. ch->armor += apply_ac( obj, obj->wear_loc );
  1380. if( --obj->value[0] <= 0 )
  1381. {
  1382. if( !IS_PKILL( ch ) && !in_arena( ch ) )
  1383. {
  1384. make_scraps( obj );
  1385. objcode = rOBJ_SCRAPPED;
  1386. }
  1387. else
  1388. {
  1389. obj->value[0] = 1;
  1390. ch->armor -= apply_ac( obj, obj->wear_loc );
  1391. }
  1392. }
  1393. else if( ch && obj->value[0] >= 1 )
  1394. ch->armor -= apply_ac( obj, obj->wear_loc );
  1395. break;
  1396. case ITEM_WEAPON:
  1397. if( --obj->value[0] <= 0 )
  1398. {
  1399. if( !IS_PKILL( ch ) && !in_arena( ch ) )
  1400. {
  1401. make_scraps( obj );
  1402. objcode = rOBJ_SCRAPPED;
  1403. }
  1404. else
  1405. obj->value[0] = 1;
  1406. }
  1407. break;
  1408. }
  1409. if( ch != NULL )
  1410. save_char_obj( ch ); /* Stop scrap duping - Samson 1-2-00 */
  1411.  
  1412. if( objcode == rOBJ_SCRAPPED && !IS_NPC( ch ) )
  1413. log_printf( "%s scrapped %s (vnum: %d)", ch->name, obj->short_descr, obj->pIndexData->vnum );
  1414.  
  1415. return objcode;
  1416. }
  1417.  
  1418. /*
  1419. * Remove an object.
  1420. */
  1421. bool remove_obj( CHAR_DATA * ch, int iWear, bool fReplace )
  1422. {
  1423. OBJ_DATA *obj, *tmpobj;
  1424.  
  1425. if( ( obj = get_eq_char( ch, iWear ) ) == NULL )
  1426. return TRUE;
  1427.  
  1428. if( !fReplace && ch->carry_number + get_obj_number( obj ) > can_carry_n( ch ) )
  1429. {
  1430. act( AT_PLAIN, "$d: you can't carry that many items.", ch, NULL, obj->short_descr, TO_CHAR );
  1431. return FALSE;
  1432. }
  1433.  
  1434. if( !fReplace )
  1435. return FALSE;
  1436.  
  1437. if( IS_OBJ_STAT( obj, ITEM_NOREMOVE ) )
  1438. {
  1439. act( AT_PLAIN, "You can't remove $p.", ch, obj, NULL, TO_CHAR );
  1440. return FALSE;
  1441. }
  1442.  
  1443. if( obj == get_eq_char( ch, WEAR_WIELD ) && ( tmpobj = get_eq_char( ch, WEAR_DUAL_WIELD ) ) != NULL )
  1444. tmpobj->wear_loc = WEAR_WIELD;
  1445.  
  1446. unequip_char( ch, obj );
  1447.  
  1448. act( AT_ACTION, "$n stops using $p.", ch, obj, NULL, TO_ROOM );
  1449. act( AT_ACTION, "You stop using $p.", ch, obj, NULL, TO_CHAR );
  1450. oprog_remove_trigger( ch, obj );
  1451. /*
  1452. * Added check in case, the trigger forces them to rewear the item
  1453. * * --Shaddai
  1454. */
  1455. if( !( obj = get_eq_char( ch, iWear ) ) )
  1456. return TRUE;
  1457. else
  1458. return FALSE;
  1459. }
  1460.  
  1461. /*
  1462. * See if char could be capable of dual-wielding -Thoric
  1463. */
  1464. bool could_dual( CHAR_DATA * ch )
  1465. {
  1466. if( IS_NPC( ch ) || ch->pcdata->learned[gsn_dual_wield] )
  1467. return TRUE;
  1468.  
  1469. return FALSE;
  1470. }
  1471.  
  1472. bool can_dual( CHAR_DATA * ch )
  1473. {
  1474. bool wield = FALSE, nwield = FALSE;
  1475.  
  1476. if( !could_dual( ch ) )
  1477. return FALSE;
  1478. if( get_eq_char( ch, WEAR_WIELD ) )
  1479. wield = TRUE;
  1480. /*
  1481. * Check for missile wield or dual wield
  1482. */
  1483. if( get_eq_char( ch, WEAR_MISSILE_WIELD ) || get_eq_char( ch, WEAR_DUAL_WIELD ) )
  1484. nwield = TRUE;
  1485. if( wield && nwield )
  1486. {
  1487. send_to_char( "You are already wielding two weapons... grow some more arms!\r\n", ch );
  1488. return FALSE;
  1489. }
  1490. if( ( wield || nwield ) && get_eq_char( ch, WEAR_SHIELD ) )
  1491. {
  1492. send_to_char( "You cannot dual wield, you're already holding a shield!\r\n", ch );
  1493. return FALSE;
  1494. }
  1495. if( ( wield || nwield ) && get_eq_char( ch, WEAR_HOLD ) )
  1496. {
  1497. send_to_char( "You cannot hold another weapon, you're already holding something in that hand!\r\n", ch );
  1498. return FALSE;
  1499. }
  1500. return TRUE;
  1501. }
  1502.  
  1503. /*
  1504. * Check to see if there is room to wear another object on this location
  1505. * (Layered clothing support)
  1506. */
  1507. bool can_layer( CHAR_DATA * ch, OBJ_DATA * obj, short wear_loc )
  1508. {
  1509. OBJ_DATA *otmp;
  1510. short bitlayers = 0;
  1511. short objlayers = obj->pIndexData->layers;
  1512.  
  1513. for( otmp = ch->first_carrying; otmp; otmp = otmp->next_content )
  1514. {
  1515. if( otmp->wear_loc == wear_loc )
  1516. {
  1517. if( !otmp->pIndexData->layers )
  1518. return FALSE;
  1519. else
  1520. bitlayers |= otmp->pIndexData->layers;
  1521. }
  1522. }
  1523.  
  1524. if( ( bitlayers && !objlayers ) || bitlayers > objlayers )
  1525. return FALSE;
  1526. if( !bitlayers || ( ( bitlayers & ~objlayers ) == bitlayers ) )
  1527. return TRUE;
  1528. return FALSE;
  1529. }
  1530.  
  1531. /*
  1532. * Wear one object.
  1533. * Optional replacement of existing objects.
  1534. * Big repetitive code, ick.
  1535. *
  1536. * Restructured a bit to allow for specifying body location -Thoric
  1537. * & Added support for layering on certain body locations
  1538. */
  1539. void wear_obj( CHAR_DATA * ch, OBJ_DATA * obj, bool fReplace, short wear_bit )
  1540. {
  1541. OBJ_DATA *tmpobj = NULL;
  1542. short bit, tmp;
  1543.  
  1544. separate_obj( obj );
  1545. /*if( get_trust( ch ) < obj->level )
  1546. *{
  1547. * ch_printf( ch, "You must be level %d to use this object.\r\n", obj->level );
  1548. * act( AT_ACTION, "$n tries to use $p, but is too inexperienced.", ch, obj, NULL, TO_ROOM );
  1549. * return;
  1550. *}
  1551. */
  1552.  
  1553. if( !IS_IMMORTAL( ch )
  1554. && ( ( IS_OBJ_STAT( obj, ITEM_ANTI_WARRIOR ) && ch->Class == CLASS_WARRIOR )
  1555. || ( IS_OBJ_STAT( obj, ITEM_ANTI_WARRIOR ) && ch->Class == CLASS_SAVAGE )
  1556. || ( IS_OBJ_STAT( obj, ITEM_ANTI_WARRIOR ) && ch->Class == CLASS_PALADIN )
  1557. || ( IS_OBJ_STAT( obj, ITEM_ANTI_MAGE ) && ch->Class == CLASS_MAGE )
  1558. || ( IS_OBJ_STAT( obj, ITEM_ANTI_MAGE ) && ch->Class == CLASS_NEPHANDI )
  1559. || ( IS_OBJ_STAT( obj, ITEM_ANTI_THIEF ) && ch->Class == CLASS_THIEF )
  1560. || ( IS_OBJ_STAT( obj, ITEM_ANTI_VAMPIRE ) && ch->Class == CLASS_VAMPIRE )
  1561. || ( IS_OBJ_STAT( obj, ITEM_ANTI_DRUID ) && ch->Class == CLASS_DRUID )
  1562. || ( IS_OBJ_STAT( obj, ITEM_ANTI_WARRIOR ) && ch->Class == CLASS_RANGER )
  1563. || ( IS_OBJ_STAT( obj, ITEM_ANTI_MAGE ) && ch->Class == CLASS_AUGURER )
  1564. || ( IS_OBJ_STAT( obj, ITEM_ANTI_CLERIC ) && ch->Class == CLASS_CLERIC )
  1565. || ( IS_OBJ_STAT( obj, ITEM_ANTI_GOOD ) && ch->alignment > 350 )
  1566. || ( IS_OBJ_STAT( obj, ITEM_ANTI_NEUTRAL ) && ch->alignment >= -350 && ch->alignment <= 350 )
  1567. || ( IS_OBJ_STAT( obj, ITEM_ANTI_EVIL ) && ch->alignment < -350 ) ) )
  1568. {
  1569. act( AT_MAGIC, "You are forbidden to use that item.", ch, NULL, NULL, TO_CHAR );
  1570. act( AT_ACTION, "$n tries to use $p, but is forbidden to do so.", ch, obj, NULL, TO_ROOM );
  1571. return;
  1572. }
  1573.  
  1574. if( IS_OBJ_STAT( obj, ITEM_PERSONAL ) && str_cmp( ch->name, obj->owner ) )
  1575. {
  1576. send_to_char( "That item is personalized and belongs to someone else.\r\n", ch );
  1577. if( obj->carried_by )
  1578. obj_from_char( obj );
  1579. obj_to_room( obj, ch->in_room );
  1580. return;
  1581. }
  1582.  
  1583. if( wear_bit > -1 )
  1584. {
  1585. bit = wear_bit;
  1586. if( !CAN_WEAR( obj, 1 << bit ) )
  1587. {
  1588. if( fReplace )
  1589. {
  1590. switch ( 1 << bit )
  1591. {
  1592. case ITEM_HOLD:
  1593. send_to_char( "You cannot hold that.\r\n", ch );
  1594. break;
  1595. case ITEM_WIELD:
  1596. case ITEM_MISSILE_WIELD:
  1597. switch ( obj->value[4] )
  1598. {
  1599. default:
  1600. *gsn_ptr = -1;
  1601. break;
  1602. case DAM_HIT:
  1603. *gsn_ptr = gsn_daggers;
  1604. break;
  1605. case DAM_SUCTION:
  1606. *gsn_ptr = gsn_swords;
  1607. break;
  1608. case DAM_BITE:
  1609. *gsn_ptr = gsn_greatswords;
  1610. break;
  1611. case DAM_BLAST:
  1612. *gsn_ptr = gsn_hatchets;
  1613. break;
  1614. case DAM_SLASH:
  1615. *gsn_ptr = gsn_greataxes;
  1616. break;
  1617. case DAM_SLICE:
  1618. *gsn_ptr = gsn_maces;
  1619. break;
  1620. case DAM_PIERCE:
  1621. *gsn_ptr = gsn_mauls;
  1622. break;
  1623. case DAM_STAB:
  1624. *gsn_ptr = gsn_polearms;
  1625. break;
  1626. case DAM_WHIP:
  1627. *gsn_ptr = gsn_fists;
  1628. break;
  1629. case DAM_CLAW:
  1630. *gsn_ptr = gsn_staves;
  1631. break;
  1632. case DAM_POUND:
  1633. *gsn_ptr = gsn_wands;
  1634. break;
  1635. case DAM_CRUSH:
  1636. *gsn_ptr = gsn_guns;
  1637. break;
  1638. case DAM_BOLT:
  1639. *gsn_ptr = gsn_bows;
  1640. break;
  1641. case DAM_ARROW:
  1642. *gsn_ptr = gsn_crossbows;
  1643. break;
  1644. case DAM_DART:
  1645. case DAM_STONE:
  1646. case DAM_PEA:
  1647. *gsn_ptr = gsn_thrown;
  1648. break;
  1649. }
  1650.  
  1651. ch_printf( ch, "gsn_ptr = %d", gsn_ptr );
  1652. if( LEARNED( ch, gsn_ptr ) < 1 )
  1653. {
  1654. send_to_char( "You have not trained in this form of weaponry.\r\n", ch );
  1655. return;
  1656. }
  1657.  
  1658. }
  1659. }
  1660. return;
  1661. }
  1662. }
  1663. else
  1664. {
  1665. for( bit = -1, tmp = 1; tmp < 31; tmp++ )
  1666. {
  1667. if( CAN_WEAR( obj, 1 << tmp ) )
  1668. {
  1669. bit = tmp;
  1670. break;
  1671. }
  1672. }
  1673. }
  1674.  
  1675. /*
  1676. * currently cannot have a light in non-light position
  1677. */
  1678. if( obj->item_type == ITEM_LIGHT )
  1679. {
  1680. if( !remove_obj( ch, WEAR_LIGHT, fReplace ) )
  1681. return;
  1682. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1683. {
  1684. act( AT_ACTION, "$n holds $p as a light.", ch, obj, NULL, TO_ROOM );
  1685. act( AT_ACTION, "You hold $p as your light.", ch, obj, NULL, TO_CHAR );
  1686. }
  1687. equip_char( ch, obj, WEAR_LIGHT );
  1688. oprog_wear_trigger( ch, obj );
  1689. return;
  1690. }
  1691.  
  1692. if( bit == -1 )
  1693. {
  1694. if( fReplace )
  1695. send_to_char( "You can't wear, wield, or hold that.\r\n", ch );
  1696. return;
  1697. }
  1698.  
  1699. switch ( 1 << bit )
  1700. {
  1701. default:
  1702. bug( "%s: uknown/unused item_wear bit %d", __func__, bit );
  1703. if( fReplace )
  1704. send_to_char( "You can't wear, wield, or hold that.\r\n", ch );
  1705. return;
  1706.  
  1707. case ITEM_WEAR_FINGER:
  1708. if( get_eq_char( ch, WEAR_FINGER_L )
  1709. && get_eq_char( ch, WEAR_FINGER_R )
  1710. && !remove_obj( ch, WEAR_FINGER_L, fReplace ) && !remove_obj( ch, WEAR_FINGER_R, fReplace ) )
  1711. return;
  1712.  
  1713. if( !get_eq_char( ch, WEAR_FINGER_L ) )
  1714. {
  1715. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1716. {
  1717. act( AT_ACTION, "$n slips $s left finger into $p.", ch, obj, NULL, TO_ROOM );
  1718. act( AT_ACTION, "You slip your left finger into $p.", ch, obj, NULL, TO_CHAR );
  1719. }
  1720. equip_char( ch, obj, WEAR_FINGER_L );
  1721. oprog_wear_trigger( ch, obj );
  1722. return;
  1723. }
  1724.  
  1725. if( !get_eq_char( ch, WEAR_FINGER_R ) )
  1726. {
  1727. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1728. {
  1729. act( AT_ACTION, "$n slips $s right finger into $p.", ch, obj, NULL, TO_ROOM );
  1730. act( AT_ACTION, "You slip your right finger into $p.", ch, obj, NULL, TO_CHAR );
  1731. }
  1732. equip_char( ch, obj, WEAR_FINGER_R );
  1733. oprog_wear_trigger( ch, obj );
  1734. return;
  1735. }
  1736.  
  1737. bug( "%s: no free finger.", __func__ );
  1738. send_to_char( "You already wear something on both fingers.\r\n", ch );
  1739. return;
  1740.  
  1741. case ITEM_WEAR_NECK:
  1742. if( get_eq_char( ch, WEAR_NECK_1 ) != NULL
  1743. && get_eq_char( ch, WEAR_NECK_2 ) != NULL
  1744. && !remove_obj( ch, WEAR_NECK_1, fReplace ) && !remove_obj( ch, WEAR_NECK_2, fReplace ) )
  1745. return;
  1746.  
  1747. if( !get_eq_char( ch, WEAR_NECK_1 ) )
  1748. {
  1749. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1750. {
  1751. act( AT_ACTION, "$n wears $p around $s neck.", ch, obj, NULL, TO_ROOM );
  1752. act( AT_ACTION, "You wear $p around your neck.", ch, obj, NULL, TO_CHAR );
  1753. }
  1754. equip_char( ch, obj, WEAR_NECK_1 );
  1755. oprog_wear_trigger( ch, obj );
  1756. return;
  1757. }
  1758.  
  1759. if( !get_eq_char( ch, WEAR_NECK_2 ) )
  1760. {
  1761. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1762. {
  1763. act( AT_ACTION, "$n wears $p around $s neck.", ch, obj, NULL, TO_ROOM );
  1764. act( AT_ACTION, "You wear $p around your neck.", ch, obj, NULL, TO_CHAR );
  1765. }
  1766. equip_char( ch, obj, WEAR_NECK_2 );
  1767. oprog_wear_trigger( ch, obj );
  1768. return;
  1769. }
  1770.  
  1771. bug( "%s: no free neck.", __func__ );
  1772. send_to_char( "You already wear two neck items.\r\n", ch );
  1773. return;
  1774.  
  1775. case ITEM_WEAR_BODY:
  1776. if( !can_layer( ch, obj, WEAR_BODY ) )
  1777. {
  1778. send_to_char( "It won't fit overtop of what you're already wearing.\r\n", ch );
  1779. return;
  1780. }
  1781. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1782. {
  1783. act( AT_ACTION, "$n fits $p on $s body.", ch, obj, NULL, TO_ROOM );
  1784. act( AT_ACTION, "You fit $p on your body.", ch, obj, NULL, TO_CHAR );
  1785. }
  1786. equip_char( ch, obj, WEAR_BODY );
  1787. oprog_wear_trigger( ch, obj );
  1788. return;
  1789.  
  1790. case ITEM_WEAR_HEAD:
  1791. if( !remove_obj( ch, WEAR_HEAD, fReplace ) )
  1792. return;
  1793. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1794. {
  1795. act( AT_ACTION, "$n dons $p upon $s head.", ch, obj, NULL, TO_ROOM );
  1796. act( AT_ACTION, "You don $p upon your head.", ch, obj, NULL, TO_CHAR );
  1797. }
  1798. equip_char( ch, obj, WEAR_HEAD );
  1799. oprog_wear_trigger( ch, obj );
  1800. return;
  1801.  
  1802. case ITEM_WEAR_EYES:
  1803. if( !remove_obj( ch, WEAR_EYES, fReplace ) )
  1804. return;
  1805. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1806. {
  1807. act( AT_ACTION, "$n places $p on $s eyes.", ch, obj, NULL, TO_ROOM );
  1808. act( AT_ACTION, "You place $p on your eyes.", ch, obj, NULL, TO_CHAR );
  1809. }
  1810. equip_char( ch, obj, WEAR_EYES );
  1811. oprog_wear_trigger( ch, obj );
  1812. return;
  1813.  
  1814. case ITEM_WEAR_FACE:
  1815. if( !remove_obj( ch, WEAR_FACE, fReplace ) )
  1816. return;
  1817. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1818. {
  1819. act( AT_ACTION, "$n places $p on $s face.", ch, obj, NULL, TO_ROOM );
  1820. act( AT_ACTION, "You place $p on your face.", ch, obj, NULL, TO_CHAR );
  1821. }
  1822. equip_char( ch, obj, WEAR_FACE );
  1823. oprog_wear_trigger( ch, obj );
  1824. return;
  1825.  
  1826. case ITEM_WEAR_EARS:
  1827. if( !remove_obj( ch, WEAR_EARS, fReplace ) )
  1828. return;
  1829. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1830. {
  1831. act( AT_ACTION, "$n wears $p on $s ears.", ch, obj, NULL, TO_ROOM );
  1832. act( AT_ACTION, "You wear $p on your ears.", ch, obj, NULL, TO_CHAR );
  1833. }
  1834. equip_char( ch, obj, WEAR_EARS );
  1835. oprog_wear_trigger( ch, obj );
  1836. return;
  1837.  
  1838. case ITEM_WEAR_LEGS:
  1839. if( !can_layer( ch, obj, WEAR_LEGS ) )
  1840. {
  1841. send_to_char( "It won't fit overtop of what you're already wearing.\r\n", ch );
  1842. return;
  1843. }
  1844. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1845. {
  1846. act( AT_ACTION, "$n slips into $p.", ch, obj, NULL, TO_ROOM );
  1847. act( AT_ACTION, "You slip into $p.", ch, obj, NULL, TO_CHAR );
  1848. }
  1849. equip_char( ch, obj, WEAR_LEGS );
  1850. oprog_wear_trigger( ch, obj );
  1851. return;
  1852.  
  1853. case ITEM_WEAR_FEET:
  1854. if( !can_layer( ch, obj, WEAR_FEET ) )
  1855. {
  1856. send_to_char( "It won't fit overtop of what you're already wearing.\r\n", ch );
  1857. return;
  1858. }
  1859. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1860. {
  1861. act( AT_ACTION, "$n wears $p on $s feet.", ch, obj, NULL, TO_ROOM );
  1862. act( AT_ACTION, "You wear $p on your feet.", ch, obj, NULL, TO_CHAR );
  1863. }
  1864. equip_char( ch, obj, WEAR_FEET );
  1865. oprog_wear_trigger( ch, obj );
  1866. return;
  1867.  
  1868. case ITEM_WEAR_HANDS:
  1869. if( !can_layer( ch, obj, WEAR_HANDS ) )
  1870. {
  1871. send_to_char( "It won't fit overtop of what you're already wearing.\r\n", ch );
  1872. return;
  1873. }
  1874. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1875. {
  1876. act( AT_ACTION, "$n wears $p on $s hands.", ch, obj, NULL, TO_ROOM );
  1877. act( AT_ACTION, "You wear $p on your hands.", ch, obj, NULL, TO_CHAR );
  1878. }
  1879. equip_char( ch, obj, WEAR_HANDS );
  1880. oprog_wear_trigger( ch, obj );
  1881. return;
  1882.  
  1883. case ITEM_WEAR_ARMS:
  1884. if( !can_layer( ch, obj, WEAR_ARMS ) )
  1885. {
  1886. send_to_char( "It won't fit overtop of what you're already wearing.\r\n", ch );
  1887. return;
  1888. }
  1889. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1890. {
  1891. act( AT_ACTION, "$n wears $p on $s arms.", ch, obj, NULL, TO_ROOM );
  1892. act( AT_ACTION, "You wear $p on your arms.", ch, obj, NULL, TO_CHAR );
  1893. }
  1894. equip_char( ch, obj, WEAR_ARMS );
  1895. oprog_wear_trigger( ch, obj );
  1896. return;
  1897.  
  1898. case ITEM_WEAR_ABOUT:
  1899. if( !can_layer( ch, obj, WEAR_ABOUT ) )
  1900. {
  1901. send_to_char( "It won't fit overtop of what you're already wearing.\r\n", ch );
  1902. return;
  1903. }
  1904. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1905. {
  1906. act( AT_ACTION, "$n wears $p about $s body.", ch, obj, NULL, TO_ROOM );
  1907. act( AT_ACTION, "You wear $p about your body.", ch, obj, NULL, TO_CHAR );
  1908. }
  1909. equip_char( ch, obj, WEAR_ABOUT );
  1910. oprog_wear_trigger( ch, obj );
  1911. return;
  1912.  
  1913. case ITEM_WEAR_BACK:
  1914. if( !remove_obj( ch, WEAR_BACK, fReplace ) )
  1915. return;
  1916. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1917. {
  1918. act( AT_ACTION, "$n slings $p on $s back.", ch, obj, NULL, TO_ROOM );
  1919. act( AT_ACTION, "You sling $p on your back.", ch, obj, NULL, TO_CHAR );
  1920. }
  1921. equip_char( ch, obj, WEAR_BACK );
  1922. oprog_wear_trigger( ch, obj );
  1923. return;
  1924.  
  1925. case ITEM_WEAR_WAIST:
  1926. if( !can_layer( ch, obj, WEAR_WAIST ) )
  1927. {
  1928. send_to_char( "It won't fit overtop of what you're already wearing.\r\n", ch );
  1929. return;
  1930. }
  1931. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1932. {
  1933. act( AT_ACTION, "$n wears $p about $s waist.", ch, obj, NULL, TO_ROOM );
  1934. act( AT_ACTION, "You wear $p about your waist.", ch, obj, NULL, TO_CHAR );
  1935. }
  1936. equip_char( ch, obj, WEAR_WAIST );
  1937. oprog_wear_trigger( ch, obj );
  1938. return;
  1939.  
  1940. case ITEM_WEAR_WRIST:
  1941. if( get_eq_char( ch, WEAR_WRIST_L )
  1942. && get_eq_char( ch, WEAR_WRIST_R )
  1943. && !remove_obj( ch, WEAR_WRIST_L, fReplace ) && !remove_obj( ch, WEAR_WRIST_R, fReplace ) )
  1944. return;
  1945.  
  1946. if( !get_eq_char( ch, WEAR_WRIST_L ) )
  1947. {
  1948. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1949. {
  1950. act( AT_ACTION, "$n fits $p around $s left wrist.", ch, obj, NULL, TO_ROOM );
  1951. act( AT_ACTION, "You fit $p around your left wrist.", ch, obj, NULL, TO_CHAR );
  1952. }
  1953. equip_char( ch, obj, WEAR_WRIST_L );
  1954. oprog_wear_trigger( ch, obj );
  1955. return;
  1956. }
  1957.  
  1958. if( !get_eq_char( ch, WEAR_WRIST_R ) )
  1959. {
  1960. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1961. {
  1962. act( AT_ACTION, "$n fits $p around $s right wrist.", ch, obj, NULL, TO_ROOM );
  1963. act( AT_ACTION, "You fit $p around your right wrist.", ch, obj, NULL, TO_CHAR );
  1964. }
  1965. equip_char( ch, obj, WEAR_WRIST_R );
  1966. oprog_wear_trigger( ch, obj );
  1967. return;
  1968. }
  1969.  
  1970. bug( "%s", "Wear_obj: no free wrist." );
  1971. send_to_char( "You already wear two wrist items.\r\n", ch );
  1972. return;
  1973.  
  1974. case ITEM_WEAR_ANKLE:
  1975. if( get_eq_char( ch, WEAR_ANKLE_L )
  1976. && get_eq_char( ch, WEAR_ANKLE_R )
  1977. && !remove_obj( ch, WEAR_ANKLE_L, fReplace ) && !remove_obj( ch, WEAR_ANKLE_R, fReplace ) )
  1978. return;
  1979.  
  1980. if( !get_eq_char( ch, WEAR_ANKLE_L ) )
  1981. {
  1982. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1983. {
  1984. act( AT_ACTION, "$n fits $p around $s left ankle.", ch, obj, NULL, TO_ROOM );
  1985. act( AT_ACTION, "You fit $p around your left ankle.", ch, obj, NULL, TO_CHAR );
  1986. }
  1987. equip_char( ch, obj, WEAR_ANKLE_L );
  1988. oprog_wear_trigger( ch, obj );
  1989. return;
  1990. }
  1991.  
  1992. if( !get_eq_char( ch, WEAR_ANKLE_R ) )
  1993. {
  1994. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  1995. {
  1996. act( AT_ACTION, "$n fits $p around $s right ankle.", ch, obj, NULL, TO_ROOM );
  1997. act( AT_ACTION, "You fit $p around your right ankle.", ch, obj, NULL, TO_CHAR );
  1998. }
  1999. equip_char( ch, obj, WEAR_ANKLE_R );
  2000. oprog_wear_trigger( ch, obj );
  2001. return;
  2002. }
  2003.  
  2004. bug( "%s: no free ankle.", __func__ );
  2005. send_to_char( "You already wear two ankle items.\r\n", ch );
  2006. return;
  2007.  
  2008. case ITEM_WEAR_SHIELD:
  2009. if( get_eq_char( ch, WEAR_DUAL_WIELD )
  2010. || ( get_eq_char( ch, WEAR_WIELD ) && get_eq_char( ch, WEAR_MISSILE_WIELD ) )
  2011. || ( get_eq_char( ch, WEAR_WIELD ) && get_eq_char( ch, WEAR_HOLD ) ) )
  2012. {
  2013. if( get_eq_char( ch, WEAR_HOLD ) )
  2014. send_to_char( "You can't use a shield while using a weapon and holding something!\r\n", ch );
  2015. else
  2016. send_to_char( "You can't use a shield AND two weapons!\r\n", ch );
  2017. return;
  2018. }
  2019. if( !remove_obj( ch, WEAR_SHIELD, fReplace ) )
  2020. return;
  2021. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  2022. {
  2023. act( AT_ACTION, "$n uses $p as a shield.", ch, obj, NULL, TO_ROOM );
  2024. act( AT_ACTION, "You use $p as a shield.", ch, obj, NULL, TO_CHAR );
  2025. }
  2026. equip_char( ch, obj, WEAR_SHIELD );
  2027. oprog_wear_trigger( ch, obj );
  2028. return;
  2029.  
  2030. case ITEM_MISSILE_WIELD:
  2031. case ITEM_WIELD:
  2032. if( !could_dual( ch ) )
  2033. {
  2034. if( !remove_obj( ch, WEAR_MISSILE_WIELD, fReplace ) )
  2035. return;
  2036. if( !remove_obj( ch, WEAR_WIELD, fReplace ) )
  2037. return;
  2038. tmpobj = NULL;
  2039. }
  2040. else
  2041. {
  2042. OBJ_DATA *mw, *dw, *hd, *sd;
  2043. tmpobj = get_eq_char( ch, WEAR_WIELD );
  2044. mw = get_eq_char( ch, WEAR_MISSILE_WIELD );
  2045. dw = get_eq_char( ch, WEAR_DUAL_WIELD );
  2046. hd = get_eq_char( ch, WEAR_HOLD );
  2047. sd = get_eq_char( ch, WEAR_SHIELD );
  2048.  
  2049. if( hd && sd )
  2050. {
  2051. send_to_char( "You are already holding something and wearing a shield.\r\n", ch );
  2052. return;
  2053. }
  2054.  
  2055. if( tmpobj )
  2056. {
  2057. if( !can_dual( ch ) )
  2058. return;
  2059.  
  2060. if( get_obj_weight( obj ) + get_obj_weight( tmpobj ) > str_app[get_curr_str( ch )].wield )
  2061. {
  2062. send_to_char( "It is too heavy for you to wield.\r\n", ch );
  2063. return;
  2064. }
  2065.  
  2066. if( mw || dw )
  2067. {
  2068. send_to_char( "You're already wielding two weapons.\r\n", ch );
  2069. return;
  2070. }
  2071.  
  2072. if( hd || sd )
  2073. {
  2074. send_to_char( "You're already wielding a weapon AND holding something.\r\n", ch );
  2075. return;
  2076. }
  2077.  
  2078. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  2079. {
  2080. act( AT_ACTION, "$n dual-wields $p.", ch, obj, NULL, TO_ROOM );
  2081. act( AT_ACTION, "You dual-wield $p.", ch, obj, NULL, TO_CHAR );
  2082. }
  2083. if( 1 << bit == ITEM_MISSILE_WIELD )
  2084. equip_char( ch, obj, WEAR_MISSILE_WIELD );
  2085. else
  2086. equip_char( ch, obj, WEAR_DUAL_WIELD );
  2087. oprog_wear_trigger( ch, obj );
  2088. return;
  2089. }
  2090.  
  2091. if( mw )
  2092. {
  2093. if( !can_dual( ch ) )
  2094. return;
  2095.  
  2096. if( 1 << bit == ITEM_MISSILE_WIELD )
  2097. {
  2098. send_to_char( "You're already wielding a missile weapon.\r\n", ch );
  2099. return;
  2100. }
  2101.  
  2102. if( get_obj_weight( obj ) + get_obj_weight( mw ) > str_app[get_curr_str( ch )].wield )
  2103. {
  2104. send_to_char( "It is too heavy for you to wield.\r\n", ch );
  2105. return;
  2106. }
  2107.  
  2108. if( tmpobj || dw )
  2109. {
  2110. send_to_char( "You're already wielding two weapons.\r\n", ch );
  2111. return;
  2112. }
  2113.  
  2114. if( hd || sd )
  2115. {
  2116. send_to_char( "You're already wielding a weapon AND holding something.\r\n", ch );
  2117. return;
  2118. }
  2119.  
  2120. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  2121. {
  2122. act( AT_ACTION, "$n wields $p.", ch, obj, NULL, TO_ROOM );
  2123. act( AT_ACTION, "You wield $p.", ch, obj, NULL, TO_CHAR );
  2124. }
  2125. equip_char( ch, obj, WEAR_WIELD );
  2126. oprog_wear_trigger( ch, obj );
  2127. return;
  2128. }
  2129. }
  2130.  
  2131. if( get_obj_weight( obj ) > str_app[get_curr_str( ch )].wield )
  2132. {
  2133. send_to_char( "It is too heavy for you to wield.\r\n", ch );
  2134. return;
  2135. }
  2136.  
  2137. if( !oprog_use_trigger( ch, obj, NULL, NULL ) )
  2138. {
  2139. act( AT_ACTION, "$n wields $p.", ch, obj, NULL, TO_ROOM );
  2140. act( AT_ACTION, "You wield $p.", ch, obj, NULL, TO_CHAR );
  2141. }
  2142. if( 1 << bit == ITEM_MISSILE_WIELD )
  2143. equip_char( ch, obj, WEAR_MISSILE_WIELD );
  2144. else
  2145. equip_char( ch, obj, WEAR_WIELD );
  2146. oprog_wear_trigger( ch, obj );
  2147. return;
  2148.  
  2149. case ITEM_HOLD:
  2150. if( get_eq_char( ch, WEAR_DUAL_WIELD )
  2151. || ( get_eq_char( ch, WEAR_WIELD )
  2152. && ( get_eq_char( ch, WEAR_MISSILE_WIELD ) || get_eq_char( ch, WEAR_SHIELD ) ) ) )
  2153. {
  2154. if( get_eq_char( ch, WEAR_SHIELD ) )
  2155. send_to_char( "You cannot hold something while using a weapon and a shield!\r\n", ch );
  2156. else
  2157. send_to_char( "You cannot hold something AND two weapons!\r\n", ch );
  2158. return;
  2159. }
  2160. if( !remove_obj( ch, WEAR_HOLD, fReplace ) )
  2161. return;
  2162. if( obj->item_type == ITEM_WAND
  2163. || obj->item_type == ITEM_STAFF
  2164. || obj->item_type == ITEM_FOOD
  2165. || obj->item_type == ITEM_COOK
  2166. || obj->item_type == ITEM_PILL
  2167. || obj->item_type == ITEM_POTION
  2168. || obj->item_type == ITEM_SCROLL
  2169. || obj->item_type == ITEM_DRINK_CON
  2170. || obj->item_type == ITEM_BLOOD
  2171. || obj->item_type == ITEM_PIPE
  2172. || obj->item_type == ITEM_HERB || obj->item_type == ITEM_KEY || !oprog_use_trigger( ch, obj, NULL, NULL ) )
  2173. {
  2174. act( AT_ACTION, "$n holds $p in $s hands.", ch, obj, NULL, TO_ROOM );
  2175. act( AT_ACTION, "You hold $p in your hands.", ch, obj, NULL, TO_CHAR );
  2176. }
  2177. equip_char( ch, obj, WEAR_HOLD );
  2178. oprog_wear_trigger( ch, obj );
  2179. return;
  2180. }
  2181. }
  2182.  
  2183. void do_wear( CHAR_DATA* ch, const char* argument)
  2184. {
  2185. char arg1[MAX_INPUT_LENGTH];
  2186. char arg2[MAX_INPUT_LENGTH];
  2187. OBJ_DATA *obj;
  2188. short wear_bit;
  2189.  
  2190. argument = one_argument( argument, arg1 );
  2191. argument = one_argument( argument, arg2 );
  2192. if( ( !str_cmp( arg2, "on" ) || !str_cmp( arg2, "upon" ) || !str_cmp( arg2, "around" ) ) && argument[0] != '\0' )
  2193. argument = one_argument( argument, arg2 );
  2194.  
  2195. if( arg1[0] == '\0' )
  2196. {
  2197. send_to_char( "Wear, wield, or hold what?\r\n", ch );
  2198. return;
  2199. }
  2200.  
  2201. if( ms_find_obj( ch ) )
  2202. return;
  2203.  
  2204. if( !str_cmp( arg1, "all" ) )
  2205. {
  2206. OBJ_DATA *obj_next;
  2207.  
  2208. for( obj = ch->first_carrying; obj; obj = obj_next )
  2209. {
  2210. obj_next = obj->next_content;
  2211. if( obj->wear_loc == WEAR_NONE && can_see_obj( ch, obj ) )
  2212. {
  2213. wear_obj( ch, obj, FALSE, -1 );
  2214. if( char_died( ch ) )
  2215. return;
  2216. }
  2217. }
  2218. return;
  2219. }
  2220. else
  2221. {
  2222. if( ( obj = get_obj_carry( ch, arg1 ) ) == NULL )
  2223. {
  2224. send_to_char( "You do not have that item.\r\n", ch );
  2225. return;
  2226. }
  2227. if( arg2[0] != '\0' )
  2228. wear_bit = get_wflag( arg2 );
  2229. else
  2230. wear_bit = -1;
  2231. wear_obj( ch, obj, TRUE, wear_bit );
  2232. }
  2233.  
  2234. return;
  2235. }
  2236.  
  2237.  
  2238.  
  2239. void do_remove( CHAR_DATA* ch, const char* argument)
  2240. {
  2241. char arg[MAX_INPUT_LENGTH];
  2242. OBJ_DATA *obj, *obj_next;
  2243.  
  2244.  
  2245. one_argument( argument, arg );
  2246.  
  2247. if( arg[0] == '\0' )
  2248. {
  2249. send_to_char( "Remove what?\r\n", ch );
  2250. return;
  2251. }
  2252.  
  2253. if( ms_find_obj( ch ) )
  2254. return;
  2255.  
  2256. if( !str_cmp( arg, "all" ) ) /* SB Remove all */
  2257. {
  2258. for( obj = ch->first_carrying; obj != NULL; obj = obj_next )
  2259. {
  2260. obj_next = obj->next_content;
  2261. if( obj->wear_loc != WEAR_NONE && can_see_obj( ch, obj ) )
  2262. remove_obj( ch, obj->wear_loc, TRUE );
  2263. }
  2264. return;
  2265. }
  2266.  
  2267. if( ( obj = get_obj_wear( ch, arg ) ) == NULL )
  2268. {
  2269. send_to_char( "You are not using that item.\r\n", ch );
  2270. return;
  2271. }
  2272. if( ( obj_next = get_eq_char( ch, obj->wear_loc ) ) != obj )
  2273. {
  2274. act( AT_PLAIN, "You must remove $p first.", ch, obj_next, NULL, TO_CHAR );
  2275. return;
  2276. }
  2277.  
  2278. remove_obj( ch, obj->wear_loc, TRUE );
  2279. return;
  2280. }
  2281.  
  2282.  
  2283. void do_bury( CHAR_DATA* ch, const char* argument)
  2284. {
  2285. char arg[MAX_INPUT_LENGTH];
  2286. OBJ_DATA *obj;
  2287. bool shovel;
  2288. short move;
  2289.  
  2290. one_argument( argument, arg );
  2291.  
  2292. if( arg[0] == '\0' )
  2293. {
  2294. send_to_char( "What do you wish to bury?\r\n", ch );
  2295. return;
  2296. }
  2297.  
  2298. if( ms_find_obj( ch ) )
  2299. return;
  2300.  
  2301. shovel = FALSE;
  2302. for( obj = ch->first_carrying; obj; obj = obj->next_content )
  2303. if( obj->item_type == ITEM_SHOVEL )
  2304. {
  2305. shovel = TRUE;
  2306. break;
  2307. }
  2308.  
  2309. obj = get_obj_list_rev( ch, arg, ch->in_room->last_content );
  2310. if( !obj )
  2311. {
  2312. send_to_char( "You can't find it.\r\n", ch );
  2313. return;
  2314. }
  2315.  
  2316. separate_obj( obj );
  2317.  
  2318. if( !CAN_WEAR( obj, ITEM_TAKE ) )
  2319. {
  2320. act( AT_PLAIN, "You cannot bury $p.", ch, obj, NULL, TO_CHAR );
  2321. return;
  2322. }
  2323.  
  2324. switch( ch->in_room->sector_type )
  2325. {
  2326. case SECT_CITY:
  2327. case SECT_INSIDE:
  2328. send_to_char( "The floor is too hard to dig through.\r\n", ch );
  2329. return;
  2330. case SECT_WATER_SWIM:
  2331. case SECT_WATER_NOSWIM:
  2332. case SECT_UNDERWATER:
  2333. send_to_char( "You cannot bury something here.\r\n", ch );
  2334. return;
  2335. case SECT_AIR:
  2336. send_to_char( "What? In the air?!\r\n", ch );
  2337. return;
  2338. }
  2339.  
  2340. if( obj->weight > ( UMAX( 5, ( can_carry_w( ch ) / 10 ) ) ) && !shovel )
  2341. {
  2342. send_to_char( "You'd need a shovel to bury something that big.\r\n", ch );
  2343. return;
  2344. }
  2345.  
  2346. move = ( obj->weight * 50 * ( shovel ? 1 : 5 ) ) / UMAX( 1, can_carry_w( ch ) );
  2347. move = URANGE( 2, move, 1000 );
  2348. if( move > ch->move )
  2349. {
  2350. send_to_char( "You don't have the energy to bury something of that size.\r\n", ch );
  2351. return;
  2352. }
  2353. ch->move -= move;
  2354. if( obj->item_type == ITEM_CORPSE_NPC || obj->item_type == ITEM_CORPSE_PC )
  2355. adjust_favor( ch, 6, 1 );
  2356.  
  2357. act( AT_ACTION, "You solemnly bury $p...", ch, obj, NULL, TO_CHAR );
  2358. act( AT_ACTION, "$n solemnly buries $p...", ch, obj, NULL, TO_ROOM );
  2359. xSET_BIT( obj->extra_flags, ITEM_BURIED );
  2360. WAIT_STATE( ch, URANGE( 10, move / 2, 100 ) );
  2361. return;
  2362. }
  2363.  
  2364. void do_sacrifice( CHAR_DATA* ch, const char* argument)
  2365. {
  2366. char arg[MAX_INPUT_LENGTH];
  2367. char buf[MAX_STRING_LENGTH];
  2368. char name[50];
  2369. OBJ_DATA *obj;
  2370.  
  2371. one_argument( argument, arg );
  2372.  
  2373. if( arg[0] == '\0' || !str_cmp( arg, ch->name ) )
  2374. {
  2375. act( AT_ACTION, "$n offers $mself to $s deity, who graciously declines.", ch, NULL, NULL, TO_ROOM );
  2376. send_to_char( "Your deity appreciates your offer and may accept it later.\r\n", ch );
  2377. return;
  2378. }
  2379.  
  2380. if( ms_find_obj( ch ) )
  2381. return;
  2382.  
  2383. obj = get_obj_list_rev( ch, arg, ch->in_room->last_content );
  2384. if( !obj )
  2385. {
  2386. send_to_char( "You can't find it.\r\n", ch );
  2387. return;
  2388. }
  2389.  
  2390. separate_obj( obj );
  2391.  
  2392. if( !CAN_WEAR( obj, ITEM_TAKE ) )
  2393. {
  2394. act( AT_PLAIN, "$p is not an acceptable sacrifice.", ch, obj, NULL, TO_CHAR );
  2395. return;
  2396. }
  2397.  
  2398. if( xIS_SET( ch->in_room->room_flags, ROOM_CLANSTOREROOM ) )
  2399. {
  2400. send_to_char( "The gods would not accept such a foolish sacrifice.\r\n", ch );
  2401. return;
  2402. }
  2403.  
  2404. if( IS_SET( obj->magic_flags, ITEM_PKDISARMED ) && !IS_NPC( ch ) && !IS_IMMORTAL( ch ) )
  2405. {
  2406. if( CAN_PKILL( ch ) && !get_timer( ch, TIMER_PKILLED ) )
  2407. {
  2408. if( ch->level - obj->value[5] > 5 || obj->value[5] - ch->level > 5 )
  2409. {
  2410. send_to_char_color( "\r\n&bA godly force freezes your outstretched hand.\r\n", ch );
  2411. return;
  2412. }
  2413. }
  2414. }
  2415. if( !IS_NPC( ch ) && ch->pcdata->deity && ch->pcdata->deity->name[0] != '\0' )
  2416. {
  2417. mudstrlcpy( name, ch->pcdata->deity->name, 50 );
  2418. }
  2419. else if( !IS_NPC( ch ) && IS_GUILDED( ch ) && sysdata.guild_overseer[0] != '\0' )
  2420. {
  2421. mudstrlcpy( name, sysdata.guild_overseer, 50 );
  2422. }
  2423. else if( !IS_NPC( ch ) && ch->pcdata->clan && ch->pcdata->clan->deity[0] != '\0' )
  2424. {
  2425. mudstrlcpy( name, ch->pcdata->clan->deity, 50 );
  2426. }
  2427. else
  2428. {
  2429. mudstrlcpy( name, "Thoric", 50 );
  2430. }
  2431. ch->gold += 1;
  2432. if( obj->item_type == ITEM_CORPSE_NPC || obj->item_type == ITEM_CORPSE_PC )
  2433. adjust_favor( ch, 5, 1 );
  2434. ch_printf( ch, "%s gives you one gold coin for your sacrifice.\r\n", name );
  2435.  
  2436. if( obj->item_type == ITEM_PAPER )
  2437. snprintf( buf, MAX_STRING_LENGTH, "$n sacrifices a note to %s.", name );
  2438. else
  2439. snprintf( buf, MAX_STRING_LENGTH, "$n sacrifices $p to %s.", name );
  2440. act( AT_ACTION, buf, ch, obj, NULL, TO_ROOM );
  2441.  
  2442. if( obj->item_type != ITEM_PAPER )
  2443. oprog_sac_trigger( ch, obj );
  2444.  
  2445. if( obj_extracted( obj ) )
  2446. {
  2447. if( xIS_SET( ch->in_room->room_flags, ROOM_HOUSE ) )
  2448. save_house_by_vnum( ch->in_room->vnum ); /* Prevent House Object Duplication */
  2449. return;
  2450. }
  2451.  
  2452. if( cur_obj == obj->serial )
  2453. global_objcode = rOBJ_SACCED;
  2454. /* Separate again. There was a problem here with sac_progs in that if the
  2455. object respawned a copy of itself, it would sometimes link it to the
  2456. one that was being extracted, resulting in them both getting that evil
  2457. extraction :) -- Alty */
  2458. separate_obj( obj );
  2459. extract_obj( obj );
  2460.  
  2461. if( xIS_SET( ch->in_room->room_flags, ROOM_HOUSE ) )
  2462. save_house_by_vnum( ch->in_room->vnum ); /* Prevent House Object Duplication */
  2463. return;
  2464. }
  2465.  
  2466. void do_brandish( CHAR_DATA* ch, const char* argument)
  2467. {
  2468. CHAR_DATA *vch;
  2469. CHAR_DATA *vch_next;
  2470. OBJ_DATA *staff;
  2471. ch_ret retcode;
  2472. int sn;
  2473.  
  2474. if( ( staff = get_eq_char( ch, WEAR_HOLD ) ) == NULL )
  2475. {
  2476. send_to_char( "You hold nothing in your hand.\r\n", ch );
  2477. return;
  2478. }
  2479.  
  2480. if( staff->item_type != ITEM_STAFF )
  2481. {
  2482. send_to_char( "You can brandish only with a staff.\r\n", ch );
  2483. return;
  2484. }
  2485.  
  2486. if( ( sn = staff->value[3] ) < 0 || sn >= num_skills || skill_table[sn]->spell_fun == NULL )
  2487. {
  2488. bug( "%s: bad sn %d.", __func__, sn );
  2489. return;
  2490. }
  2491.  
  2492. WAIT_STATE( ch, 2 * PULSE_VIOLENCE );
  2493.  
  2494. if( staff->value[2] > 0 )
  2495. {
  2496. if( !oprog_use_trigger( ch, staff, NULL, NULL ) )
  2497. {
  2498. act( AT_MAGIC, "$n brandishes $p.", ch, staff, NULL, TO_ROOM );
  2499. act( AT_MAGIC, "You brandish $p.", ch, staff, NULL, TO_CHAR );
  2500. }
  2501.  
  2502. for( vch = ch->in_room->first_person; vch; vch = vch_next )
  2503. {
  2504. vch_next = vch->next_in_room;
  2505.  
  2506. if( !IS_NPC( vch ) && xIS_SET( vch->act, PLR_WIZINVIS ) && vch->pcdata->wizinvis >= LEVEL_IMMORTAL )
  2507. continue;
  2508. else
  2509. switch ( skill_table[sn]->target )
  2510. {
  2511. default:
  2512. bug( "%s: bad target for sn %d.", __func__, sn );
  2513. return;
  2514.  
  2515. case TAR_IGNORE:
  2516. if( vch != ch )
  2517. continue;
  2518. break;
  2519.  
  2520. case TAR_CHAR_OFFENSIVE:
  2521. if( IS_NPC( ch ) ? IS_NPC( vch ) : !IS_NPC( vch ) )
  2522. continue;
  2523. break;
  2524.  
  2525. case TAR_CHAR_DEFENSIVE:
  2526. if( IS_NPC( ch ) ? !IS_NPC( vch ) : IS_NPC( vch ) )
  2527. continue;
  2528. break;
  2529.  
  2530. case TAR_CHAR_SELF:
  2531. if( vch != ch )
  2532. continue;
  2533. break;
  2534. }
  2535.  
  2536. retcode = obj_cast_spell( staff->value[3], staff->value[0], ch, vch, NULL );
  2537. if( retcode == rCHAR_DIED || retcode == rBOTH_DIED )
  2538. {
  2539. bug( "%s: char died", __func__ );
  2540. return;
  2541. }
  2542. }
  2543. }
  2544.  
  2545. if( --staff->value[2] <= 0 )
  2546. {
  2547. act( AT_MAGIC, "$p blazes bright and vanishes from $n's hands!", ch, staff, NULL, TO_ROOM );
  2548. act( AT_MAGIC, "$p blazes bright and is gone!", ch, staff, NULL, TO_CHAR );
  2549. if( staff->serial == cur_obj )
  2550. global_objcode = rOBJ_USED;
  2551. extract_obj( staff );
  2552. }
  2553.  
  2554. return;
  2555. }
  2556.  
  2557. void do_zap( CHAR_DATA* ch, const char* argument)
  2558. {
  2559. char arg[MAX_INPUT_LENGTH];
  2560. CHAR_DATA *victim;
  2561. OBJ_DATA *wand;
  2562. OBJ_DATA *obj;
  2563. ch_ret retcode;
  2564.  
  2565. one_argument( argument, arg );
  2566. if( arg[0] == '\0' && !ch->fighting )
  2567. {
  2568. send_to_char( "Zap whom or what?\r\n", ch );
  2569. return;
  2570. }
  2571.  
  2572. if( ( wand = get_eq_char( ch, WEAR_HOLD ) ) == NULL )
  2573. {
  2574. send_to_char( "You hold nothing in your hand.\r\n", ch );
  2575. return;
  2576. }
  2577.  
  2578. if( wand->item_type != ITEM_WAND )
  2579. {
  2580. send_to_char( "You can zap only with a wand.\r\n", ch );
  2581. return;
  2582. }
  2583.  
  2584. obj = NULL;
  2585. if( arg[0] == '\0' )
  2586. {
  2587. if( ch->fighting )
  2588. {
  2589. victim = who_fighting( ch );
  2590. }
  2591. else
  2592. {
  2593. send_to_char( "Zap whom or what?\r\n", ch );
  2594. return;
  2595. }
  2596. }
  2597. else
  2598. {
  2599. if( ( victim = get_char_room( ch, arg ) ) == NULL && ( obj = get_obj_here( ch, arg ) ) == NULL )
  2600. {
  2601. send_to_char( "You can't find it.\r\n", ch );
  2602. return;
  2603. }
  2604. }
  2605.  
  2606. WAIT_STATE( ch, 1 * PULSE_VIOLENCE );
  2607.  
  2608. if( wand->value[2] > 0 )
  2609. {
  2610. if( victim )
  2611. {
  2612. if( !oprog_use_trigger( ch, wand, victim, NULL ) )
  2613. {
  2614. act( AT_MAGIC, "$n aims $p at $N.", ch, wand, victim, TO_ROOM );
  2615. act( AT_MAGIC, "You aim $p at $N.", ch, wand, victim, TO_CHAR );
  2616. }
  2617. }
  2618. else
  2619. {
  2620. if( !oprog_use_trigger( ch, wand, NULL, obj ) )
  2621. {
  2622. act( AT_MAGIC, "$n aims $p at $P.", ch, wand, obj, TO_ROOM );
  2623. act( AT_MAGIC, "You aim $p at $P.", ch, wand, obj, TO_CHAR );
  2624. }
  2625. }
  2626.  
  2627. retcode = obj_cast_spell( wand->value[3], wand->value[0], ch, victim, obj );
  2628. if( retcode == rCHAR_DIED || retcode == rBOTH_DIED )
  2629. {
  2630. bug( "%s", "do_zap: char died" );
  2631. return;
  2632. }
  2633. }
  2634.  
  2635. if( --wand->value[2] <= 0 )
  2636. {
  2637. act( AT_MAGIC, "$p explodes into fragments.", ch, wand, NULL, TO_ROOM );
  2638. act( AT_MAGIC, "$p explodes into fragments.", ch, wand, NULL, TO_CHAR );
  2639. if( wand->serial == cur_obj )
  2640. global_objcode = rOBJ_USED;
  2641. extract_obj( wand );
  2642. }
  2643. return;
  2644. }
  2645.  
  2646. /* put an item on auction, or see the stats on the current item or bet */
  2647. void do_auction( CHAR_DATA* ch, const char* argument)
  2648. {
  2649. OBJ_DATA *obj;
  2650. char arg1[MAX_INPUT_LENGTH];
  2651. char arg2[MAX_INPUT_LENGTH];
  2652. char arg3[MAX_INPUT_LENGTH];
  2653. char buf[MAX_STRING_LENGTH];
  2654. int i;
  2655.  
  2656. argument = one_argument( argument, arg1 );
  2657. argument = one_argument( argument, arg2 );
  2658. argument = one_argument( argument, arg3 );
  2659.  
  2660. set_char_color( AT_LBLUE, ch );
  2661.  
  2662. if( IS_NPC( ch ) ) /* NPC can be extracted at any time and thus can't auction! */
  2663. return;
  2664.  
  2665. if( ch->level < 3 )
  2666. {
  2667. send_to_char( "You must be at least level three to use the auction...\r\n", ch );
  2668. return;
  2669. }
  2670.  
  2671. if( ( time_info.hour > 18 || time_info.hour < 9 ) && auction->item == NULL && !IS_IMMORTAL( ch ) )
  2672. {
  2673. send_to_char( "\r\nThe auctioneer works between the hours of 9 AM and 6 PM\r\n", ch );
  2674. return;
  2675. }
  2676.  
  2677. if( arg1[0] == '\0' )
  2678. {
  2679. if( auction->item != NULL )
  2680. {
  2681. AFFECT_DATA *paf;
  2682. obj = auction->item;
  2683.  
  2684. /*
  2685. * show item data here
  2686. */
  2687. set_char_color( AT_BLUE, ch );
  2688. if( auction->bet > 0 )
  2689. ch_printf( ch, "\r\nCurrent bid on this item is %s gold.\r\n", num_punct( auction->bet ) );
  2690. else
  2691. send_to_char( "\r\nNo bids on this item have been received.\r\n", ch );
  2692. /* spell_identify (0, LEVEL_HERO - 1, ch, auction->item); */
  2693.  
  2694. set_char_color( AT_LBLUE, ch );
  2695. ch_printf( ch,
  2696. "Object '%s' is %s, special properties: %s\r\nIts weight is %d, value is %d, and level is %d.\r\n",
  2697. obj->name, aoran( item_type_name( obj ) ), extra_bit_name( &obj->extra_flags ),
  2698. /* magic_bit_name( obj->magic_flags ), -- currently unused */
  2699. obj->weight, obj->cost, obj->level );
  2700. if( obj->item_type != ITEM_LIGHT && obj->wear_flags - 1 > 0 )
  2701. ch_printf( ch, "Item's wear location: %s\r\n", flag_string( obj->wear_flags - 1, w_flags ) );
  2702.  
  2703. set_char_color( AT_BLUE, ch );
  2704.  
  2705. switch ( obj->item_type )
  2706. {
  2707. case ITEM_CONTAINER:
  2708. case ITEM_KEYRING:
  2709. case ITEM_QUIVER:
  2710. ch_printf( ch, "%s appears to %s.\r\n", capitalize( obj->short_descr ),
  2711. obj->value[0] < 76 ? "have a small capacity" :
  2712. obj->value[0] < 150 ? "have a small to medium capacity" :
  2713. obj->value[0] < 300 ? "have a medium capacity" :
  2714. obj->value[0] < 500 ? "have a medium to large capacity" :
  2715. obj->value[0] < 751 ? "have a large capacity" : "have a giant capacity" );
  2716. break;
  2717.  
  2718. case ITEM_PILL:
  2719. case ITEM_SCROLL:
  2720. case ITEM_POTION:
  2721. ch_printf( ch, "Level %d spells of:", obj->value[0] );
  2722.  
  2723. if( obj->value[1] >= 0 && obj->value[1] < num_skills )
  2724. {
  2725. send_to_char( " '", ch );
  2726. send_to_char( skill_table[obj->value[1]]->name, ch );
  2727. send_to_char( "'", ch );
  2728. }
  2729.  
  2730. if( obj->value[2] >= 0 && obj->value[2] < num_skills )
  2731. {
  2732. send_to_char( " '", ch );
  2733. send_to_char( skill_table[obj->value[2]]->name, ch );
  2734. send_to_char( "'", ch );
  2735. }
  2736.  
  2737. if( obj->value[3] >= 0 && obj->value[3] < num_skills )
  2738. {
  2739. send_to_char( " '", ch );
  2740. send_to_char( skill_table[obj->value[3]]->name, ch );
  2741. send_to_char( "'", ch );
  2742. }
  2743.  
  2744. send_to_char( ".\r\n", ch );
  2745. break;
  2746.  
  2747. case ITEM_WAND:
  2748. case ITEM_STAFF:
  2749. ch_printf( ch, "Has %d(%d) charges of level %d", obj->value[1], obj->value[2], obj->value[0] );
  2750.  
  2751. if( obj->value[3] >= 0 && obj->value[3] < num_skills )
  2752. {
  2753. send_to_char( " '", ch );
  2754. send_to_char( skill_table[obj->value[3]]->name, ch );
  2755. send_to_char( "'", ch );
  2756. }
  2757.  
  2758. send_to_char( ".\r\n", ch );
  2759. break;
  2760.  
  2761. case ITEM_MISSILE_WEAPON:
  2762. case ITEM_WEAPON:
  2763. ch_printf( ch, "Damage is %d to %d (average %d).%s\r\n",
  2764. obj->value[1], obj->value[2],
  2765. ( obj->value[1] + obj->value[2] ) / 2,
  2766. IS_OBJ_STAT( obj, ITEM_POISONED ) ? "\r\nThis weapon is poisoned." : "" );
  2767. break;
  2768.  
  2769. case ITEM_ARMOR:
  2770. ch_printf( ch, "Armor class is %d.\r\n", obj->value[0] );
  2771. break;
  2772. }
  2773.  
  2774. for( paf = obj->pIndexData->first_affect; paf; paf = paf->next )
  2775. showaffect( ch, paf );
  2776.  
  2777. for( paf = obj->first_affect; paf; paf = paf->next )
  2778. showaffect( ch, paf );
  2779. if( ( obj->item_type == ITEM_CONTAINER || obj->item_type == ITEM_KEYRING
  2780. || obj->item_type == ITEM_QUIVER ) && obj->first_content )
  2781. {
  2782. set_char_color( AT_OBJECT, ch );
  2783. send_to_char( "Contents:\r\n", ch );
  2784. show_list_to_char( obj->first_content, ch, TRUE, FALSE );
  2785. }
  2786.  
  2787. if( IS_IMMORTAL( ch ) )
  2788. {
  2789. ch_printf( ch, "Seller: %s. Bidder: %s. Round: %d.\r\n",
  2790. auction->seller->name, auction->buyer->name, ( auction->going + 1 ) );
  2791. ch_printf( ch, "Time left in round: %d.\r\n", auction->pulse );
  2792. }
  2793. return;
  2794. }
  2795. else
  2796. {
  2797. set_char_color( AT_LBLUE, ch );
  2798. send_to_char( "\r\nThere is nothing being auctioned right now. What would you like to auction?\r\n", ch );
  2799. return;
  2800. }
  2801. }
  2802.  
  2803. if( IS_IMMORTAL( ch ) && !str_cmp( arg1, "stop" ) )
  2804. {
  2805. if( auction->item == NULL )
  2806. {
  2807. send_to_char( "There is no auction to stop.\r\n", ch );
  2808. return;
  2809. }
  2810. else /* stop the auction */
  2811. {
  2812. set_char_color( AT_LBLUE, ch );
  2813. snprintf( buf, MAX_STRING_LENGTH, "Sale of %s has been stopped by an Immortal.", auction->item->short_descr );
  2814. talk_auction( buf );
  2815. obj_to_char( auction->item, auction->seller );
  2816. if( IS_SET( sysdata.save_flags, SV_AUCTION ) )
  2817. save_char_obj( auction->seller );
  2818. auction->item = NULL;
  2819. if( auction->buyer != NULL && auction->buyer != auction->seller ) /* return money to the buyer */
  2820. {
  2821. auction->buyer->gold += auction->bet;
  2822. send_to_char( "Your money has been returned.\r\n", auction->buyer );
  2823. }
  2824. return;
  2825. }
  2826. }
  2827.  
  2828. if( !str_cmp( arg1, "bid" ) )
  2829. {
  2830. if( auction->item != NULL )
  2831. {
  2832. int newbet;
  2833.  
  2834. if( ch->level < auction->item->level )
  2835. {
  2836. send_to_char( "This object's level is too high for your use.\r\n", ch );
  2837. return;
  2838. }
  2839.  
  2840. if( ch == auction->seller )
  2841. {
  2842. send_to_char( "You can't bid on your own item!\r\n", ch );
  2843. return;
  2844. }
  2845.  
  2846. /*
  2847. * make - perhaps - a bet now
  2848. */
  2849. if( arg2[0] == '\0' )
  2850. {
  2851. send_to_char( "Bid how much?\r\n", ch );
  2852. return;
  2853. }
  2854.  
  2855. newbet = parsebet( auction->bet, arg2 );
  2856. /* ch_printf( ch, "Bid: %d\r\n",newbet); */
  2857.  
  2858. if( newbet < auction->starting )
  2859. {
  2860. send_to_char( "You must place a bid that is higher than the starting bet.\r\n", ch );
  2861. return;
  2862. }
  2863.  
  2864. /*
  2865. * to avoid slow auction, use a bigger amount than 100 if the bet
  2866. * is higher up - changed to 10000 for our high economy
  2867. */
  2868. if( newbet < auction->bet || newbet < ( auction->bet + 10000 ) )
  2869. {
  2870. send_to_char( "You must at least bid 10000 coins over the current bid.\r\n", ch );
  2871. return;
  2872. }
  2873.  
  2874. if( newbet > ch->gold )
  2875. {
  2876. send_to_char( "You don't have that much money!\r\n", ch );
  2877. return;
  2878. }
  2879.  
  2880. if( newbet > 2000000000 )
  2881. {
  2882. send_to_char( "You can't bid over 2 billion coins.\r\n", ch );
  2883. return;
  2884. }
  2885.  
  2886. /*
  2887. * Is it the item they really want to bid on? --Shaddai
  2888. */
  2889. if( arg3[0] != '\0' && !nifty_is_name( arg3, auction->item->name ) )
  2890. {
  2891. send_to_char( "That item is not being auctioned right now.\r\n", ch );
  2892. return;
  2893. }
  2894.  
  2895. /*
  2896. * the actual bet is OK!
  2897. * return the gold to the last buyer, if one exists
  2898. */
  2899. if( auction->buyer != NULL && auction->buyer != auction->seller )
  2900. auction->buyer->gold += auction->bet;
  2901.  
  2902. ch->gold -= newbet; /* substract the gold - important :) */
  2903. if( IS_SET( sysdata.save_flags, SV_AUCTION ) )
  2904. save_char_obj( ch );
  2905. auction->buyer = ch;
  2906. auction->bet = newbet;
  2907. auction->going = 0;
  2908. auction->pulse = PULSE_AUCTION; /* start the auction over again */
  2909. snprintf( buf, MAX_STRING_LENGTH, "A bid of %s gold has been received on %s.", num_punct( newbet ), auction->item->short_descr );
  2910. talk_auction( buf );
  2911. return;
  2912. }
  2913. else
  2914. {
  2915. send_to_char( "There isn't anything being auctioned right now.\r\n", ch );
  2916. return;
  2917. }
  2918. }
  2919.  
  2920. /*
  2921. * finally...
  2922. */
  2923. if( ms_find_obj( ch ) )
  2924. return;
  2925.  
  2926. obj = get_obj_carry( ch, arg1 ); /* does char have the item ? */
  2927.  
  2928. if( obj == NULL )
  2929. {
  2930. send_to_char( "You aren't carrying that.\r\n", ch );
  2931. return;
  2932. }
  2933.  
  2934. if( obj->timer > 0 )
  2935. {
  2936. send_to_char( "You can't auction objects that are decaying.\r\n", ch );
  2937. return;
  2938. }
  2939.  
  2940. if( IS_OBJ_STAT( obj, ITEM_CLANOBJECT ) )
  2941. {
  2942. send_to_char( "You can't auction clan items.\r\n", ch );
  2943. return;
  2944. }
  2945.  
  2946. if( IS_OBJ_STAT( obj, ITEM_PERMANENT ) )
  2947. {
  2948. send_to_char( "This item cannot leave your possession.\r\n", ch );
  2949. return;
  2950. }
  2951.  
  2952. if( IS_OBJ_STAT( obj, ITEM_PERSONAL ) )
  2953. {
  2954. send_to_char( "Personal items may not be auctioned.\r\n", ch );
  2955. return;
  2956. }
  2957.  
  2958. /*
  2959. * prevent repeat auction items
  2960. */
  2961. for( i = 0; i < AUCTION_MEM && auction->history[i]; i++ )
  2962. {
  2963. if( auction->history[i] == obj->pIndexData )
  2964. {
  2965. send_to_char( "Such an item has been auctioned recently, try again later.\r\n", ch );
  2966. return;
  2967. }
  2968. }
  2969.  
  2970. if( arg2[0] == '\0' )
  2971. {
  2972. auction->starting = 0;
  2973. mudstrlcpy( arg2, "0", MAX_INPUT_LENGTH );
  2974. }
  2975.  
  2976. if( !is_number( arg2 ) )
  2977. {
  2978. send_to_char( "You must input a number at which to start the auction.\r\n", ch );
  2979. return;
  2980. }
  2981.  
  2982. if( atoi( arg2 ) < 0 )
  2983. {
  2984. send_to_char( "You can't auction something for less than 0 gold!\r\n", ch );
  2985. return;
  2986. }
  2987.  
  2988. if( auction->item == NULL )
  2989. {
  2990. switch ( obj->item_type )
  2991. {
  2992.  
  2993. default:
  2994. act( AT_TELL, "You cannot auction $Ts.", ch, NULL, item_type_name( obj ), TO_CHAR );
  2995. return;
  2996.  
  2997. /* insert any more item types here... items with a timer MAY NOT BE
  2998. AUCTIONED!
  2999. */
  3000. case ITEM_PAPER:
  3001. case ITEM_LIGHT:
  3002. case ITEM_TREASURE:
  3003. case ITEM_POTION:
  3004. case ITEM_KEYRING:
  3005. case ITEM_QUIVER:
  3006. case ITEM_DRINK_CON:
  3007. case ITEM_FOOD:
  3008. case ITEM_COOK:
  3009. case ITEM_PEN:
  3010. case ITEM_BOAT:
  3011. case ITEM_PILL:
  3012. case ITEM_PIPE:
  3013. case ITEM_HERB_CON:
  3014. case ITEM_INCENSE:
  3015. case ITEM_FIRE:
  3016. case ITEM_RUNEPOUCH:
  3017. case ITEM_MAP:
  3018. case ITEM_BOOK:
  3019. case ITEM_RUNE:
  3020. case ITEM_MATCH:
  3021. case ITEM_HERB:
  3022. case ITEM_WEAPON:
  3023. case ITEM_MISSILE_WEAPON:
  3024. case ITEM_ARMOR:
  3025. case ITEM_STAFF:
  3026. case ITEM_WAND:
  3027. case ITEM_SCROLL:
  3028. separate_obj( obj );
  3029. obj_from_char( obj );
  3030. if( IS_SET( sysdata.save_flags, SV_AUCTION ) )
  3031. save_char_obj( ch );
  3032. auction->item = obj;
  3033. auction->bet = 0;
  3034. auction->buyer = ch;
  3035. auction->seller = ch;
  3036. auction->pulse = PULSE_AUCTION;
  3037. auction->going = 0;
  3038. auction->starting = atoi( arg2 );
  3039.  
  3040. /*
  3041. * add the new item to the history
  3042. */
  3043. if( AUCTION_MEM > 0 )
  3044. {
  3045. memmove( ( char * )auction->history + sizeof( OBJ_INDEX_DATA * ),
  3046. auction->history, ( AUCTION_MEM - 1 ) * sizeof( OBJ_INDEX_DATA * ) );
  3047. auction->history[0] = obj->pIndexData;
  3048. }
  3049.  
  3050. /*
  3051. * reset the history timer
  3052. */
  3053. auction->hist_timer = 0;
  3054.  
  3055. if( auction->starting > 0 )
  3056. auction->bet = auction->starting;
  3057. snprintf( buf, MAX_STRING_LENGTH, "A new item is being auctioned: %s at %d gold.", obj->short_descr,
  3058. auction->starting );
  3059. talk_auction( buf );
  3060.  
  3061. return;
  3062.  
  3063. } /* switch */
  3064. }
  3065. else
  3066. {
  3067. act( AT_TELL, "Try again later - $p is being auctioned right now!", ch, auction->item, NULL, TO_CHAR );
  3068. if( !IS_IMMORTAL( ch ) )
  3069. WAIT_STATE( ch, PULSE_VIOLENCE );
  3070. return;
  3071. }
  3072. }
  3073.  
  3074. /* Make objects in rooms that are nofloor fall - Scryn 1/23/96 */
  3075. void obj_fall( OBJ_DATA * obj, bool through )
  3076. {
  3077. EXIT_DATA *pexit;
  3078. ROOM_INDEX_DATA *to_room;
  3079. static int fall_count;
  3080. static bool is_falling; /* Stop loops from the call to obj_to_room() -- Altrag */
  3081.  
  3082. if( !obj->in_room || is_falling )
  3083. return;
  3084.  
  3085. if( fall_count > 30 )
  3086. {
  3087. bug( "%s", "object falling in loop more than 30 times" );
  3088. extract_obj( obj );
  3089. fall_count = 0;
  3090. return;
  3091. }
  3092.  
  3093. if( xIS_SET( obj->in_room->room_flags, ROOM_NOFLOOR ) && CAN_GO( obj, DIR_DOWN ) && !IS_OBJ_STAT( obj, ITEM_MAGIC ) )
  3094. {
  3095.  
  3096. pexit = get_exit( obj->in_room, DIR_DOWN );
  3097. to_room = pexit->to_room;
  3098.  
  3099. if( through )
  3100. fall_count++;
  3101. else
  3102. fall_count = 0;
  3103.  
  3104. if( obj->in_room == to_room )
  3105. {
  3106. bug( "Object falling into same room, room %d", to_room->vnum );
  3107. extract_obj( obj );
  3108. return;
  3109. }
  3110.  
  3111. if( obj->in_room->first_person )
  3112. {
  3113. act( AT_PLAIN, "$p falls far below...", obj->in_room->first_person, obj, NULL, TO_ROOM );
  3114. act( AT_PLAIN, "$p falls far below...", obj->in_room->first_person, obj, NULL, TO_CHAR );
  3115. }
  3116. obj_from_room( obj );
  3117. is_falling = TRUE;
  3118. obj = obj_to_room( obj, to_room );
  3119. is_falling = FALSE;
  3120.  
  3121. if( obj->in_room->first_person )
  3122. {
  3123. act( AT_PLAIN, "$p falls from above...", obj->in_room->first_person, obj, NULL, TO_ROOM );
  3124. act( AT_PLAIN, "$p falls from above...", obj->in_room->first_person, obj, NULL, TO_CHAR );
  3125. }
  3126.  
  3127. if( !xIS_SET( obj->in_room->room_flags, ROOM_NOFLOOR ) && through )
  3128. {
  3129. /* int dam = (int)9.81*sqrt(fall_count*2/9.81)*obj->weight/2;
  3130. */ int dam = fall_count * obj->weight / 2;
  3131. /*
  3132. * Damage players
  3133. */
  3134. if( obj->in_room->first_person && number_percent( ) > 15 )
  3135. {
  3136. CHAR_DATA *rch;
  3137. CHAR_DATA *vch = NULL;
  3138. int chcnt = 0;
  3139.  
  3140. for( rch = obj->in_room->first_person; rch; rch = rch->next_in_room, chcnt++ )
  3141. if( number_range( 0, chcnt ) == 0 )
  3142. vch = rch;
  3143. act( AT_WHITE, "$p falls on $n!", vch, obj, NULL, TO_ROOM );
  3144. act( AT_WHITE, "$p falls on you!", vch, obj, NULL, TO_CHAR );
  3145.  
  3146. if( IS_NPC( vch ) && xIS_SET( vch->act, ACT_HARDHAT ) )
  3147. act( AT_WHITE, "$p bounces harmlessly off your head!", vch, obj, NULL, TO_CHAR );
  3148. else
  3149. damage( vch, vch, dam * vch->level, TYPE_UNDEFINED );
  3150. }
  3151. /*
  3152. * Damage objects
  3153. */
  3154. switch ( obj->item_type )
  3155. {
  3156. case ITEM_WEAPON:
  3157. case ITEM_ARMOR:
  3158. if( ( obj->value[0] - dam ) <= 0 )
  3159. {
  3160. if( obj->in_room->first_person )
  3161. {
  3162. act( AT_PLAIN, "$p is destroyed by the fall!", obj->in_room->first_person, obj, NULL, TO_ROOM );
  3163. act( AT_PLAIN, "$p is destroyed by the fall!", obj->in_room->first_person, obj, NULL, TO_CHAR );
  3164. }
  3165. make_scraps( obj );
  3166. }
  3167. else
  3168. obj->value[0] -= dam;
  3169. break;
  3170. default:
  3171. if( ( dam * 15 ) > get_obj_resistance( obj ) )
  3172. {
  3173. if( obj->in_room->first_person )
  3174. {
  3175. act( AT_PLAIN, "$p is destroyed by the fall!", obj->in_room->first_person, obj, NULL, TO_ROOM );
  3176. act( AT_PLAIN, "$p is destroyed by the fall!", obj->in_room->first_person, obj, NULL, TO_CHAR );
  3177. }
  3178. make_scraps( obj );
  3179. }
  3180. break;
  3181. }
  3182. }
  3183. obj_fall( obj, TRUE );
  3184. }
  3185. return;
  3186. }
  3187.  
  3188. /* Scryn, by request of Darkur, 12/04/98 */
  3189. /* Reworked recursive_note_find to fix crash bug when the note was left
  3190. * blank. 7/6/98 -- Shaddai
  3191. */
  3192. OBJ_DATA *recursive_note_find( OBJ_DATA * obj, const char *argument )
  3193. {
  3194. OBJ_DATA *returned_obj;
  3195. bool match = TRUE;
  3196. const char *argcopy;
  3197. const char *subject;
  3198.  
  3199. char arg[MAX_INPUT_LENGTH];
  3200. char subj[MAX_STRING_LENGTH];
  3201.  
  3202. if( !obj )
  3203. return NULL;
  3204.  
  3205. switch ( obj->item_type )
  3206. {
  3207. case ITEM_PAPER:
  3208.  
  3209. if( ( subject = get_extra_descr( "_subject_", obj->first_extradesc ) ) == NULL )
  3210. break;
  3211. snprintf( subj, MAX_STRING_LENGTH, "%s", strlower( subject ) );
  3212. subject = strlower( subj );
  3213.  
  3214. argcopy = argument;
  3215.  
  3216. while( match )
  3217. {
  3218. argcopy = one_argument( argcopy, arg );
  3219.  
  3220. if( arg[0] == '\0' )
  3221. break;
  3222.  
  3223. if( !strstr( subject, arg ) )
  3224. match = FALSE;
  3225. }
  3226.  
  3227.  
  3228. if( match )
  3229. return obj;
  3230. break;
  3231.  
  3232. case ITEM_CONTAINER:
  3233. case ITEM_CORPSE_NPC:
  3234. case ITEM_CORPSE_PC:
  3235. if( obj->first_content )
  3236. {
  3237. returned_obj = recursive_note_find( obj->first_content, argument );
  3238. if( returned_obj )
  3239. return returned_obj;
  3240. }
  3241. break;
  3242.  
  3243. default:
  3244. break;
  3245. }
  3246.  
  3247. return recursive_note_find( obj->next_content, argument );
  3248. }
  3249.  
  3250. void do_findnote( CHAR_DATA* ch, const char* argument)
  3251. {
  3252. OBJ_DATA *obj;
  3253.  
  3254. if( IS_NPC( ch ) )
  3255. {
  3256. send_to_char( "Huh?\r\n", ch );
  3257. return;
  3258. }
  3259.  
  3260. if( argument[0] == '\0' )
  3261. {
  3262. send_to_char( "You must specify at least one keyword.\r\n", ch );
  3263. return;
  3264. }
  3265.  
  3266. obj = recursive_note_find( ch->first_carrying, argument );
  3267.  
  3268. if( obj )
  3269. {
  3270. if( obj->in_obj )
  3271. {
  3272. obj_from_obj( obj );
  3273. obj = obj_to_char( obj, ch );
  3274. }
  3275. wear_obj( ch, obj, TRUE, -1 );
  3276. }
  3277. else
  3278. send_to_char( "Note not found.\r\n", ch );
  3279. return;
  3280. }
  3281.  
  3282. const char *get_chance_verb( OBJ_DATA * obj )
  3283. {
  3284. return ( obj->action_desc[0] != '\0' ) ? obj->action_desc : "roll$q";
  3285. }
  3286.  
  3287. const char *get_ed_number( OBJ_DATA * obj, int number )
  3288. {
  3289. EXTRA_DESCR_DATA *ed;
  3290. int count;
  3291.  
  3292. for( ed = obj->first_extradesc, count = 1; ed; ed = ed->next, count++ )
  3293. {
  3294. if( count == number )
  3295. return ed->description;
  3296. }
  3297.  
  3298. return NULL;
  3299. }
  3300.  
  3301. void do_rolldie( CHAR_DATA* ch, const char* argument)
  3302. {
  3303. OBJ_DATA *die;
  3304.  
  3305. char output_string[MAX_STRING_LENGTH];
  3306. char roll_string[MAX_STRING_LENGTH];
  3307. char total_string[MAX_STRING_LENGTH];
  3308.  
  3309. const char *verb;
  3310.  
  3311. /* char* face_string = NULL;
  3312. char** face_table = NULL;*/
  3313. int rollsum = 0;
  3314. int roll_count = 0;
  3315.  
  3316. int numsides;
  3317. int numrolls;
  3318.  
  3319. bool *face_seen_table = NULL;
  3320.  
  3321. if( ( die = get_eq_char( ch, WEAR_HOLD ) ) == NULL || die->item_type != ITEM_CHANCE )
  3322. {
  3323. ch_printf( ch, "You must be holding an item of chance!\r\n" );
  3324. return;
  3325. }
  3326.  
  3327. numrolls = ( is_number( argument ) ) ? atoi( argument ) : 1;
  3328. verb = get_chance_verb( die );
  3329.  
  3330. if( numrolls > 100 )
  3331. {
  3332. ch_printf( ch, "You can't %s more than 100 times!\r\n", verb );
  3333. return;
  3334. }
  3335.  
  3336. numsides = die->value[0];
  3337.  
  3338. if( numsides <= 1 )
  3339. {
  3340. ch_printf( ch, "There is no element of chance in this game!\r\n" );
  3341. return;
  3342. }
  3343.  
  3344. if( die->value[3] == 1 )
  3345. {
  3346. if( numrolls > numsides )
  3347. {
  3348. ch_printf( ch, "Nice try, but you can only %s %d times.\r\n", verb, numsides );
  3349. return;
  3350. }
  3351. face_seen_table = ( bool * ) calloc( numsides, sizeof( bool ) );
  3352. if( !face_seen_table )
  3353. {
  3354. bug( "%s", "do_rolldie: cannot allocate memory for face_seen_table array, terminating.\r\n" );
  3355. return;
  3356. }
  3357. }
  3358.  
  3359. snprintf( roll_string, MAX_STRING_LENGTH, "%s", " " );
  3360.  
  3361. while( roll_count++ < numrolls )
  3362. {
  3363. int current_roll;
  3364. char current_roll_string[MAX_STRING_LENGTH];
  3365.  
  3366. do
  3367. {
  3368. current_roll = number_range( 1, numsides );
  3369. }
  3370. while( die->value[3] == 1 && face_seen_table[current_roll - 1] == TRUE );
  3371.  
  3372. if( die->value[3] == 1 )
  3373. face_seen_table[current_roll - 1] = TRUE;
  3374.  
  3375. rollsum += current_roll;
  3376.  
  3377. if( roll_count > 1 )
  3378. mudstrlcat( roll_string, ", ", MAX_STRING_LENGTH );
  3379. if( numrolls > 1 && roll_count == numrolls )
  3380. mudstrlcat( roll_string, "and ", MAX_STRING_LENGTH );
  3381.  
  3382. if( die->value[1] == 1 )
  3383. {
  3384. const char *face_name = get_ed_number( die, current_roll );
  3385. if( face_name )
  3386. {
  3387. char *face_name_copy = strdup( face_name ); /* Since I want to tokenize without modifying the original string */
  3388. snprintf( current_roll_string, MAX_STRING_LENGTH, "%s", strtok( face_name_copy, "\n" ) );
  3389. free( face_name_copy );
  3390. }
  3391. else
  3392. snprintf( current_roll_string, MAX_STRING_LENGTH, "%d", current_roll );
  3393. }
  3394. else
  3395. snprintf( current_roll_string, MAX_STRING_LENGTH, "%d", current_roll );
  3396. mudstrlcat( roll_string, current_roll_string, MAX_STRING_LENGTH );
  3397. }
  3398.  
  3399. if( numrolls > 1 && die->value[2] == 1 )
  3400. {
  3401. snprintf( total_string, MAX_STRING_LENGTH, ", for a total of %d", rollsum );
  3402. mudstrlcat( roll_string, total_string, MAX_STRING_LENGTH );
  3403. }
  3404.  
  3405. mudstrlcat( roll_string, ".\r\n", MAX_STRING_LENGTH );
  3406.  
  3407. snprintf( output_string, MAX_STRING_LENGTH, "You %s%s", verb, roll_string );
  3408. act( AT_GREEN, output_string, ch, NULL, NULL, TO_CHAR );
  3409.  
  3410. snprintf( output_string, MAX_STRING_LENGTH, "$n %s%s", verb, roll_string );
  3411. act( AT_GREEN, output_string, ch, NULL, NULL, TO_ROOM );
  3412.  
  3413. if( face_seen_table )
  3414. free( face_seen_table );
  3415. return;
  3416. }
  3417.  
  3418. /*dice chance deal throw*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement