-
Notifications
You must be signed in to change notification settings - Fork 1
/
mobact.c
108 lines (93 loc) · 3.22 KB
/
mobact.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
/* ************************************************************************
* file: mobact.c , Mobile action module. Part of DIKUMUD *
* Usage: Procedures generating 'intelligent' behavior in the mobiles. *
* Copyright (C) 1990, 1991 - see 'license.doc' for complete information. *
************************************************************************* */
#include <stdio.h>
#include "utils.h"
#include "structs.h"
#include "db.h"
#include "comm.h"
extern struct char_data *character_list;
extern struct index_data *mob_index;
extern struct room_data *world;
extern struct str_app_type str_app[];
void hit(struct char_data *ch, struct char_data *victim, int type);
void log(char *str);
void mobile_activity(void)
{
char buf[256];
register struct char_data *ch;
struct char_data *tmp_ch;
struct obj_data *obj, *best_obj, *worst_obj;
int door, found, max, min;
extern int no_specials;
void do_move(struct char_data *ch, char *argument, int cmd);
void do_get(struct char_data *ch, char *argument, int cmd);
for (ch = character_list; ch; ch = ch->next)
if (IS_MOB(ch))
{
/* Examine call for special procedure */
if (IS_SET(ch->specials.act, ACT_SPEC) && !no_specials) {
if (!mob_index[ch->nr].func) {
sprintf(buf, "Non-Existing MOB[%d] SPEC procedure (mobact.c)",mob_index[ch->nr].virtual);
log(buf);
REMOVE_BIT(ch->specials.act, ACT_SPEC);
} else {
if ((*mob_index[ch->nr].func) (ch, 0, ""))
continue;
}
}
if (AWAKE(ch) && !(ch->specials.fighting)) {
if (IS_SET(ch->specials.act, ACT_SCAVENGER)) {
if (world[ch->in_room].contents && !number(0,10)) {
for (max = 1, best_obj = 0, obj = world[ch->in_room].contents;
obj; obj = obj->next_content) {
if (CAN_GET_OBJ(ch, obj)) {
if (obj->obj_flags.cost > max) {
best_obj = obj;
max = obj->obj_flags.cost;
}
}
} /* for */
if (best_obj) {
obj_from_room(best_obj);
obj_to_char(best_obj, ch);
act("$n gets $p.",FALSE,ch,best_obj,0,TO_ROOM);
}
}
} /* Scavenger */
if (!IS_SET(ch->specials.act, ACT_SENTINEL) &&
(GET_POS(ch) == POSITION_STANDING) &&
((door = number(0, 45)) <= 5) && CAN_GO(ch,door) &&
!IS_SET(world[EXIT(ch, door)->to_room].room_flags, NO_MOB) &&
!IS_SET(world[EXIT(ch, door)->to_room].room_flags, DEATH)) {
if (ch->specials.last_direction == door) {
ch->specials.last_direction = -1;
} else {
if (!IS_SET(ch->specials.act, ACT_STAY_ZONE)) {
ch->specials.last_direction = door;
do_move(ch, "", ++door);
} else {
if (world[EXIT(ch, door)->to_room].zone == world[ch->in_room].zone) {
ch->specials.last_direction = door;
do_move(ch, "", ++door);
}
}
}
} /* if can go */
if (IS_SET(ch->specials.act,ACT_AGGRESSIVE)) {
found = FALSE;
for (tmp_ch = world[ch->in_room].people; tmp_ch && !found;
tmp_ch = tmp_ch->next_in_room) {
if (!IS_NPC(tmp_ch) && CAN_SEE(ch, tmp_ch)) {
if (!IS_SET(ch->specials.act, ACT_WIMPY) || !AWAKE(tmp_ch)) {
hit(ch, tmp_ch, 0);
found = TRUE;
}
}
}
}
} /* If AWAKE(ch) */
} /* If IS_MOB(ch) */
}