-
Notifications
You must be signed in to change notification settings - Fork 17
/
act_move.c
641 lines (550 loc) · 21.6 KB
/
act_move.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
/***************************************************************************
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik Strfeldt, Tom Madsen, and Katja Nyboe. *
* *
* Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* *
* In order to use any part of this Merc Diku Mud, you must comply with *
* both the original Diku license in 'license.doc' as well the Merc *
* license in 'license.txt'. In particular, you may not remove either of *
* these copyright notices. *
* *
* Much time and thought has gone into this software and you are *
* benefitting. We hope that you share your changes too. What goes *
* around, comes around. *
***************************************************************************/
/***************************************************************************
* ROM 2.4 is copyright 1993-1998 Russ Taylor *
* ROM has been brought to you by the ROM consortium *
* Russ Taylor ([email protected]) *
* Gabrielle Taylor ([email protected]) *
* Brian Moore ([email protected]) *
* By using this code, you have agreed to follow the terms of the *
* ROM license, in the file Rom24/doc/rom.license *
***************************************************************************/
/* QuickMUD - The Lazy Man's ROM - $Id: act_move.c,v 1.2 2000/12/01 10:48:33 ring0 Exp $ */
#include "act_move.h"
#include "act_info.h"
#include "affects.h"
#include "chars.h"
#include "comm.h"
#include "fight.h"
#include "find.h"
#include "globals.h"
#include "interp.h"
#include "items.h"
#include "lookup.h"
#include "objs.h"
#include "players.h"
#include "rooms.h"
#include "tables.h"
#include "utils.h"
int do_door_filter_find (CHAR_T *ch, char *argument) {
EXIT_T *pexit;
int door;
/* Lookup by direction. */
if ((door = door_lookup (argument)) >= 0) {
/* This method wants to continue from a previous find_() if looking
* for a door by name, so we can assume there was a
* find_continue_count() somewhere. This will "consume" it. */
find_next_count = 0;
RETURN_IF_ACT ((pexit = ch->in_room->exit[door]) == NULL,
"You see no door $T here.", ch, NULL, door_get_name (door), -1);
RETURN_IF_ACT (!IS_SET (pexit->exit_flags, EX_ISDOOR),
"You can't do that.", ch, NULL, NULL, -1);
return door;
}
/* Lookup by name. */
RETURN_IF_ACT ((door = find_door_same_room (ch, argument)) == -1,
"You see no $T here.", ch, NULL, argument, -1);
return door;
}
bool do_door_filter_is_door (CHAR_T *ch, EXIT_T *pexit,
OBJ_T *obj, flag_t *out_flags, bool *out_container, int *out_key)
{
flag_t flags;
bool container = FALSE;
int key;
/* Evaluate flags and flag types for objects. */
if (obj) {
switch (item_get_door_flags (obj, &flags, &key)) {
case ITEM_DOOR_EXIT:
container = FALSE;
break;
case ITEM_DOOR_CONTAINER:
container = TRUE;
break;
default:
send_to_char ("That's not a container.\n\r", ch);
return TRUE;
}
}
/* Evaluate flags and flag types of exits. */
else if (pexit) {
container = FALSE;
flags = pexit->exit_flags;
key = pexit->key;
}
/* Not sure what we're evaluating. */
else {
bug ("do_door_filter_can_open: No exit or object provided", 0);
return TRUE;
}
/* Filter the flags we want. */
FILTER (!IS_SET (flags, container ? CONT_CLOSEABLE : EX_ISDOOR),
"You can't do that.\n\r", ch);
/* Write output flags and return 'FALSE' to indicate 'not filtered'. */
if (out_flags) *out_flags = flags;
if (out_container) *out_container = container;
if (out_key) *out_key = key;
return FALSE;
}
bool do_door_filter_can_open (CHAR_T *ch, EXIT_T *pexit, OBJ_T *obj) {
flag_t flags;
bool container;
if (do_door_filter_is_door (ch, pexit, obj, &flags, &container, NULL))
return TRUE;
FILTER (!IS_SET (flags, container ? CONT_CLOSED : EX_CLOSED),
"It's already open.\n\r", ch);
FILTER (IS_SET (flags, container ? CONT_LOCKED : EX_LOCKED),
"It's locked.\n\r", ch);
return FALSE;
}
bool do_door_filter_can_close (CHAR_T *ch, EXIT_T *pexit, OBJ_T *obj) {
flag_t flags;
bool container;
if (do_door_filter_is_door (ch, pexit, obj, &flags, &container, NULL))
return TRUE;
FILTER (IS_SET (flags, container ? CONT_CLOSED : EX_CLOSED),
"It's already closed.\n\r", ch);
return FALSE;
}
bool do_door_filter_can_lock (CHAR_T *ch, EXIT_T *pexit, OBJ_T *obj) {
flag_t flags;
bool container;
int key;
if (do_door_filter_is_door (ch, pexit, obj, &flags, &container, &key))
return TRUE;
FILTER (!IS_SET (flags, container ? CONT_CLOSED : EX_CLOSED),
"It's not closed.\n\r", ch);
FILTER (IS_SET (flags, container ? CONT_LOCKED : EX_LOCKED),
"It's already locked.\n\r", ch);
FILTER (key == KEY_NOKEYHOLE,
"It can't be locked.\n\r", ch);
FILTER (!(IS_IMMORTAL (ch) || char_has_key (ch, key)),
"You lack the key.\n\r", ch);
return FALSE;
}
bool do_door_filter_can_unlock (CHAR_T *ch, EXIT_T *pexit, OBJ_T *obj) {
flag_t flags;
bool container;
int key;
if (do_door_filter_is_door (ch, pexit, obj, &flags, &container, &key))
return TRUE;
FILTER (!IS_SET (flags, container ? CONT_CLOSED : EX_CLOSED),
"It's not closed.\n\r", ch);
FILTER (!IS_SET (flags, container ? CONT_LOCKED : EX_LOCKED),
"It's already unlocked.\n\r", ch);
FILTER (key == KEY_NOKEYHOLE,
"It can't be unlocked.\n\r", ch);
FILTER (!(IS_IMMORTAL (ch) || char_has_key (ch, key)),
"You lack the key.\n\r", ch);
return FALSE;
}
bool do_door_filter_can_pick (CHAR_T *ch, EXIT_T *pexit, OBJ_T *obj) {
flag_t flags;
bool container;
int key;
if (do_door_filter_is_door (ch, pexit, obj, &flags, &container, &key))
return TRUE;
FILTER (!IS_SET (flags, container ? CONT_CLOSED : EX_CLOSED),
"It's not closed.\n\r", ch);
FILTER (!IS_SET (flags, container ? CONT_LOCKED : EX_LOCKED),
"It's already unlocked.\n\r", ch);
FILTER (key == KEY_NOKEYHOLE,
"It can't be unlocked.\n\r", ch);
/* look for guards, but not if it's ch's own object. */
if (obj == NULL || obj->carried_by != ch) {
CHAR_T *gch;
for (gch = ch->in_room->people_first; gch; gch = gch->room_next) {
if (IS_NPC (gch) && IS_AWAKE (gch) && ch->level + 5 < gch->level) {
act ("$N is standing too close to the lock.", ch, NULL, gch, TO_CHAR);
return TRUE;
}
}
}
/* we're actually trying to pick something - make us wait. */
WAIT_STATE (ch, skill_table[SN(PICK_LOCK)].beats);
/* pick-specific checks. */
if (!IS_NPC (ch) && number_percent () > char_get_skill (ch, SN(PICK_LOCK))) {
send_to_char ("You failed.\n\r", ch);
player_try_skill_improve (ch, SN(PICK_LOCK), FALSE, 2);
return TRUE;
}
FILTER (IS_SET (flags, container ? CONT_PICKPROOF : EX_PICKPROOF),
"You failed.\n\r", ch);
return FALSE;
}
void do_open_object (CHAR_T *ch, OBJ_T *obj) {
if (do_door_filter_can_open (ch, NULL, obj))
return;
item_remove_exit_flag (obj, EX_CLOSED);
act2 ("You open $p.", "$n opens $p.", ch, obj, NULL, 0, POS_RESTING);
}
void do_close_object (CHAR_T *ch, OBJ_T *obj) {
if (do_door_filter_can_close (ch, NULL, obj))
return;
item_set_exit_flag (obj, EX_CLOSED);
act2 ("You close $p.", "$n closes $p.", ch, obj, NULL, 0, POS_RESTING);
}
void do_unlock_object (CHAR_T *ch, OBJ_T *obj) {
if (do_door_filter_can_unlock (ch, NULL, obj))
return;
item_remove_exit_flag (obj, EX_LOCKED);
act2 ("You unlock $p.", "$n unlocks $p.", ch, obj, NULL, 0, POS_RESTING);
}
void do_lock_object (CHAR_T *ch, OBJ_T *obj) {
if (do_door_filter_can_lock (ch, NULL, obj))
return;
item_set_exit_flag (obj, EX_LOCKED);
act2 ("You lock $p.", "$n locks $p.", ch, obj, NULL, 0, POS_RESTING);
}
void do_pick_object (CHAR_T *ch, OBJ_T *obj) {
if (do_door_filter_can_pick (ch, NULL, obj))
return;
item_remove_exit_flag (obj, EX_LOCKED);
act2 ("You pick the lock on $p.", "$n picks the lock on $p.",
ch, obj, NULL, 0, POS_RESTING);
player_try_skill_improve (ch, SN(PICK_LOCK), TRUE, 2);
}
void do_open_door (CHAR_T *ch, int door) {
EXIT_T *pexit;
EXIT_T *pexit_rev;
pexit = ch->in_room->exit[door];
if (do_door_filter_can_open (ch, pexit, NULL))
return;
REMOVE_BIT (pexit->exit_flags, EX_CLOSED);
act2 ("You open the $d.", "$n opens the $d.",
ch, NULL, pexit->keyword, 0, POS_RESTING);
/* open the other side */
if ((pexit_rev = room_get_opposite_exit (ch->in_room, door, NULL)) != NULL) {
CHAR_T *rch;
REMOVE_BIT (pexit_rev->exit_flags, EX_CLOSED);
for (rch = pexit->to_room->people_first; rch != NULL; rch = rch->room_next)
act ("The $d is opened from the other side.", rch, NULL,
pexit_rev->keyword, TO_CHAR);
}
}
void do_close_door (CHAR_T *ch, int door) {
EXIT_T *pexit;
EXIT_T *pexit_rev;
pexit = ch->in_room->exit[door];
if (do_door_filter_can_close (ch, pexit, NULL))
return;
SET_BIT (pexit->exit_flags, EX_CLOSED);
act2 ("You close the $d.", "$n closes the $d.",
ch, NULL, pexit->keyword, 0, POS_RESTING);
/* close the other side */
if ((pexit_rev = room_get_opposite_exit (ch->in_room, door, NULL)) != NULL) {
CHAR_T *rch;
SET_BIT (pexit_rev->exit_flags, EX_CLOSED);
for (rch = pexit->to_room->people_first; rch != NULL; rch = rch->room_next)
act ("The $d is closed from the other side.", rch, NULL,
pexit_rev->keyword, TO_CHAR);
}
}
void do_unlock_door (CHAR_T *ch, int door) {
EXIT_T *pexit;
EXIT_T *pexit_rev;
pexit = ch->in_room->exit[door];
if (do_door_filter_can_unlock (ch, pexit, NULL))
return;
REMOVE_BIT (pexit->exit_flags, EX_LOCKED);
act2 ("*Click*", "$n unlocks the $d.",
ch, NULL, pexit->keyword, 0, POS_RESTING);
/* unlock the other side */
if ((pexit_rev = room_get_opposite_exit (ch->in_room, door, NULL)) != NULL)
REMOVE_BIT (pexit_rev->exit_flags, EX_LOCKED);
}
void do_lock_door (CHAR_T *ch, int door) {
EXIT_T *pexit;
EXIT_T *pexit_rev;
pexit = ch->in_room->exit[door];
if (do_door_filter_can_lock (ch, pexit, NULL))
return;
SET_BIT (pexit->exit_flags, EX_LOCKED);
act2 ("*Click*", "$n locks the $d.",
ch, NULL, pexit->keyword, 0, POS_RESTING);
/* lock the other side */
if ((pexit_rev = room_get_opposite_exit (ch->in_room, door, NULL)) != NULL)
SET_BIT (pexit_rev->exit_flags, EX_LOCKED);
}
void do_pick_door (CHAR_T *ch, int door) {
EXIT_T *pexit;
EXIT_T *pexit_rev;
pexit = ch->in_room->exit[door];
if (do_door_filter_can_pick (ch, pexit, NULL))
return;
REMOVE_BIT (pexit->exit_flags, EX_LOCKED);
act2 ("*Click*", "$n picks the lock on $d.",
ch, NULL, pexit->keyword, 0, POS_RESTING);
player_try_skill_improve (ch, SN(PICK_LOCK), TRUE, 2);
/* unlock the other side */
if ((pexit_rev = room_get_opposite_exit (ch->in_room, door, NULL)) != NULL)
REMOVE_BIT (pexit_rev->exit_flags, EX_LOCKED);
}
void do_door (CHAR_T *ch, char *argument, char *verb,
void (*func_obj) (CHAR_T *, OBJ_T *),
void (*func_door) (CHAR_T *, int))
{
char arg[MAX_INPUT_LENGTH];
OBJ_T *obj;
int door;
one_argument (argument, arg);
BAIL_IF_ACT (arg[0] == '\0',
"$t what?", ch, verb, NULL);
if ((obj = find_obj_here (ch, arg)) != NULL) {
func_obj (ch, obj);
return;
}
find_continue_counting ();
if ((door = do_door_filter_find (ch, arg)) >= 0)
func_door (ch, door);
}
DEFINE_DO_FUN (do_north)
{ char_move (ch, DIR_NORTH, FALSE); }
DEFINE_DO_FUN (do_east)
{ char_move (ch, DIR_EAST, FALSE); }
DEFINE_DO_FUN (do_south)
{ char_move (ch, DIR_SOUTH, FALSE); }
DEFINE_DO_FUN (do_west)
{ char_move (ch, DIR_WEST, FALSE); }
DEFINE_DO_FUN (do_up)
{ char_move (ch, DIR_UP, FALSE); }
DEFINE_DO_FUN (do_down)
{ char_move (ch, DIR_DOWN, FALSE); }
DEFINE_DO_FUN (do_open)
{ do_door (ch, argument, "open", do_open_object, do_open_door); }
DEFINE_DO_FUN (do_close)
{ do_door (ch, argument, "close", do_close_object, do_close_door); }
DEFINE_DO_FUN (do_unlock)
{ do_door (ch, argument, "unlock", do_unlock_object, do_unlock_door); }
DEFINE_DO_FUN (do_lock)
{ do_door (ch, argument, "lock", do_lock_object, do_lock_door); }
DEFINE_DO_FUN (do_pick)
{ do_door (ch, argument, "pick", do_pick_object, do_pick_door); }
void do_change_position_sub(CHAR_T *ch, const char *argument, int pos,
bool stay_on, const char *msg_cant_on, const char *msg_cant)
{
OBJ_T *obj = NULL;
/* are we repositioning ourselves on something? */
if (argument[0] != '\0') {
obj = find_obj_same_room (ch, argument);
BAIL_IF (obj == NULL,
"You don't see that here.\n\r", ch);
}
/* if we're not repositioning ourselves on anything, use what we're already
* on (or nothing, if the flag is set) */
else
obj = stay_on ? ch->on : NULL;
/* if we're repositioning onto something, make sure it's possible. */
if (obj != NULL) {
BAIL_IF (!item_can_position_at (obj, pos),
msg_cant_on, ch);
BAIL_IF_ACT (ch->on != obj && obj_count_users (obj) >=
obj->v.furniture.max_people,
"There's no more room on $p.", ch, obj, NULL);
}
/* checks passed! set our positions. */
char_change_position(ch, pos, obj, msg_cant);
}
DEFINE_DO_FUN (do_stand) {
int new_pos;
/* Extra checks for magical affects. */
BAIL_IF (ch->position == POS_SLEEPING && IS_AFFECTED (ch, AFF_SLEEP),
"You can't wake up!\n\r", ch);
/* Special logic for 'stand':
* 1) we need to differentiate between POS_STANDING/POS_FIGHTING.
* TODO: POS_FIGHTING is stupid and not really a position - remove!
* 2) For sit/rest/sleep, players retain the objects they are on if no
* argument is provided. For standing, the player steps off of the
* object if no argument is provided. */
if (argument[0] != '\0') {
BAIL_IF (ch->position == POS_FIGHTING,
"Maybe you should finish fighting first?\n\r", ch);
BAIL_IF (ch->daze > 0,
"You're too dazed to re-orient yourself right now!\n\r", ch);
}
else {
if (ch->on) {
BAIL_IF (ch->position == POS_FIGHTING,
"Maybe you should finish fighting first?\n\r", ch);
}
else {
BAIL_IF (ch->position == POS_FIGHTING,
"You are already fighting!\n\r", ch);
BAIL_IF (ch->position == POS_STANDING,
"You are already standing.\n\r", ch);
}
BAIL_IF (ch->daze > 0,
"You're too dazed to re-orient yourself right now!\n\r", ch);
}
/* If we're fighting someone, move to fighting position instead. */
/* TODO: POS_FIGHTING is dumb, get rid of it! */
new_pos = ch->fighting ? POS_FIGHTING : POS_STANDING;
do_change_position_sub(ch, argument, new_pos, FALSE,
"You can't seem to find a place to stand.\n\r",
"You can't stand up from your current position.\n\r"
);
}
bool do_filter_change_position (CHAR_T *ch, int pos, const char *same_msg) {
FILTER (ch->position == pos,
same_msg, ch);
FILTER (ch->position == POS_SLEEPING && IS_AFFECTED (ch, AFF_SLEEP),
"You can't wake up!\n\r", ch);
FILTER (ch->position == POS_FIGHTING,
"Maybe you should finish this fight first?\n\r", ch);
FILTER (ch->daze > 0,
"You're too dazed to re-orient yourself right now!\n\r", ch);
return FALSE;
}
DEFINE_DO_FUN (do_sit) {
if (do_filter_change_position (ch, POS_SITTING,
"You are already sitting down.\n\r"))
return;
do_change_position_sub(ch, argument, POS_SITTING, TRUE,
"You can't sit on that.\n\r",
"You can't sit from your current position.\n\r"
);
}
DEFINE_DO_FUN (do_rest) {
if (do_filter_change_position (ch, POS_RESTING,
"You are already resting.\n\r"))
return;
do_change_position_sub(ch, argument, POS_RESTING, TRUE,
"You can't rest on that.\n\r",
"You can't rest from your current position.\n\r"
);
}
DEFINE_DO_FUN (do_sleep) {
if (do_filter_change_position (ch, POS_SLEEPING,
"You are already sleeping.\n\r"))
return;
do_change_position_sub(ch, argument, POS_SLEEPING, TRUE,
"You can't sleep on that.\n\r",
"You can't sleep from your current position.\n\r"
);
}
DEFINE_DO_FUN (do_wake) {
char arg[MAX_INPUT_LENGTH];
CHAR_T *victim;
one_argument (argument, arg);
if (arg[0] == '\0') {
do_function (ch, &do_stand, "");
return;
}
BAIL_IF (!IS_AWAKE (ch),
"You are asleep yourself!\n\r", ch);
BAIL_IF ((victim = find_char_same_room (ch, arg)) == NULL,
"They aren't here.\n\r", ch);
BAIL_IF_ACT (IS_AWAKE (victim),
"$N is already awake.", ch, NULL, victim);
BAIL_IF_ACT (IS_AFFECTED (victim, AFF_SLEEP),
"You can't wake $M!", ch, NULL, victim);
act3 ("You wake $N.", "$n wakes you.", "$n wakes $N.",
ch, NULL, victim, 0, POS_SLEEPING);
do_function (victim, &do_stand, "");
}
DEFINE_DO_FUN (do_sneak) {
AFFECT_T af;
send_to_char ("You attempt to move silently.\n\r", ch);
affect_strip_char (ch, SN(SNEAK));
if (IS_AFFECTED (ch, AFF_SNEAK))
return;
if (number_percent () < char_get_skill (ch, SN(SNEAK))) {
player_try_skill_improve (ch, SN(SNEAK), TRUE, 3);
affect_init (&af, AFF_TO_AFFECTS, SN(SNEAK), ch->level, ch->level, APPLY_NONE, 0, AFF_SNEAK);
affect_copy_to_char (&af, ch);
}
else
player_try_skill_improve (ch, SN(SNEAK), FALSE, 3);
}
DEFINE_DO_FUN (do_hide) {
send_to_char ("You attempt to hide.\n\r", ch);
if (IS_AFFECTED (ch, AFF_HIDE))
REMOVE_BIT (ch->affected_by, AFF_HIDE);
if (number_percent () < char_get_skill (ch, SN(HIDE))) {
SET_BIT (ch->affected_by, AFF_HIDE);
player_try_skill_improve (ch, SN(HIDE), TRUE, 3);
}
else
player_try_skill_improve (ch, SN(HIDE), FALSE, 3);
}
/* Contributed by Alander. */
DEFINE_DO_FUN (do_visible) {
affect_strip_char (ch, SN(INVIS));
affect_strip_char (ch, SN(MASS_INVIS));
affect_strip_char (ch, SN(SNEAK));
REMOVE_BIT (ch->affected_by, AFF_HIDE);
REMOVE_BIT (ch->affected_by, AFF_INVISIBLE);
REMOVE_BIT (ch->affected_by, AFF_SNEAK);
printf_to_char(ch, "You are now visible.\n\r");
}
DEFINE_DO_FUN (do_recall) {
CHAR_T *victim;
ROOM_INDEX_T *location;
BAIL_IF (IS_NPC (ch) && !IS_PET (ch),
"Only players can recall.\n\r", ch);
act ("$n prays for transportation!", ch, NULL, NULL, TO_NOTCHAR);
BAIL_IF ((location = room_get_index (ROOM_VNUM_TEMPLE)) == NULL,
"You are completely lost.\n\r", ch);
#ifdef BASEMUD_NO_RECALL_TO_SAME_ROOM
BAIL_IF (ch->in_room == location,
"Mota ignores your frivolous request.\n\r", ch);
#endif
BAIL_IF (IS_SET (ch->in_room->room_flags, ROOM_NO_RECALL) ||
IS_AFFECTED (ch, AFF_CURSE),
"Mota has forsaken you.\n\r", ch);
if ((victim = ch->fighting) != NULL) {
int lose, skill;
skill = char_get_skill (ch, SN(RECALL));
if (number_percent () < 80 * skill / 100) {
player_try_skill_improve (ch, SN(RECALL), FALSE, 6);
WAIT_STATE (ch, 4);
send_to_char ("You failed!\n\r", ch);
return;
}
lose = (ch->desc != NULL) ? 25 : 50;
player_gain_exp (ch, 0 - lose);
player_try_skill_improve (ch, SN(RECALL), TRUE, 4);
printf_to_char (ch, "You recall from combat! You lose %d exps.\n\r",
lose);
stop_fighting (ch, TRUE);
}
ch->move /= 2;
act ("$n disappears.", ch, NULL, NULL, TO_NOTCHAR);
char_to_room (ch, location);
act ("$n appears in the room.", ch, NULL, NULL, TO_NOTCHAR);
do_function (ch, &do_look, "auto");
if (ch->pet != NULL)
do_function (ch->pet, &do_recall, "");
}
/* RT Enter portals */
DEFINE_DO_FUN (do_enter) {
OBJ_T *portal;
/* Basic character / command checks. */
BAIL_IF (ch->fighting != NULL,
"Maybe finish the fight first?!\n\r", ch);
BAIL_IF (argument[0] == '\0',
"Nope, can't do it.\n\r", ch);
/* Make sure we have a valid portal. */
portal = find_obj_same_room (ch, argument);
BAIL_IF (portal == NULL,
"You don't see that here.\n\r", ch);
BAIL_IF (!item_can_enter_as (portal, ch),
"You can't seem to find a way in.\n\r", ch);
/* Enter the portal. */
if (!item_enter_effect (portal, ch))
send_to_char ("You can't enter that.\n\r", ch);
}