mobact.c
empiremud/src/mobact.c · 2.9 KB
From the archive empire.zip
Download the archive « Back to the archive contents
/* ************************************************************************
* File: mobact.c EmpireMUD AD 1.0 *
* Usage: Functions for generating intelligent (?) behavior in mobiles *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Code base by Paul Clarke. EmpireMUD Project, a tbgMUD Production. *
* Based upon CircleMUD 3.0, beta patch level 17, by Jeremy Elson. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "db.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "skills.h"
/* local functions */
void mobile_activity(void) {
extern int perform_move(Creature ch, int dir, int need_specials_check, byte mode);
register Creature ch, next_ch, vict;
Object obj;
int dir, found;
for (ch = character_list; ch; ch = next_ch) {
next_ch = ch->next;
if (!IS_MOB(ch) || GET_RIDDEN_BY(ch) || GET_FED_ON_BY(ch))
continue;
/* If the mob has no specproc, do the default actions */
if (FIGHTING(ch) || !AWAKE(ch) || AFF_FLAGGED(ch, AFF_CHARM) || MOB_FLAGGED(ch, MOB_TIED) || GET_PULLING(ch) || GET_LED_BY(ch) || GET_RIDDEN_BY(ch))
continue;
if ((HAS_INFRA(ch) || !IS_DARK(ch->in_room)) && !MOB_FLAGGED(ch, MOB_SENTINEL) && GET_POS(ch) == POS_STANDING && SECT(ch->in_room) != SECT_BUILDING && SECT(ch->in_room) != SECT_MONUMENT_CLOSED && SECT(ch->in_room) != SECT_INSIDE)
if (!GET_RIDDEN_BY(ch) && !GET_LED_BY(ch))
if ((dir = number(0, 40)) < NUM_2D_DIRS)
if (IS_SET(MOB_SECTS(ch), (1 << SECT(real_shift(ch->in_room, shift_dir[dir][0], shift_dir[dir][1])))))
perform_move(ch, dir, 1, 0);
/* Aggressive Mobs */
if (MOB_FLAGGED(ch, MOB_AGGRESSIVE)) {
for (found = FALSE, vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) {
if (IS_NPC(vict) || !vict->desc || !CAN_SEE(ch, vict) || GET_LEVEL(vict) >= LVL_GOD)
continue;
if (GET_RIDING(vict) && MOB_FLAGGED(GET_RIDING(vict), MOB_FLYING))
continue;
if (AFF_FLAGGED(vict, AFF_FLY))
continue;
hit(ch, vict);
found = TRUE;
}
}
if (MOB_FLAGGED(ch, MOB_SCAVENGER) && !FIGHTING(ch))
for (obj = world[ch->in_room].contents; obj; obj = obj->next_content)
if (GET_OBJ_TYPE(obj) == ITEM_CORPSE && !number(0, 10)) {
while (obj->contains)
obj_to_room(obj->contains, obj->in_room);
extract_obj(obj);
break;
}
/* Add new mobile actions here */
}
}