Code:
utils.h
+ #define ORIGINALROOM(ch) ((ch)->char_specials.originalroom)
structs.h
in struct char_special_data
+ room_rnum originalroom; /* room mob was spawned into, used for sentinel to go back to */
in act.wizard.c
static void do_stat_character(struct char_data *ch, struct char_data *k)
{
sprinttype(GET_SEX(k), genders, buf, sizeof(buf));
+ send_to_char(ch, "%s %s '%s' IDNum: [%5ld], In room [%5d], Loadroom : [%5d] OriginalRoom : [%5d]\r\n",
+ buf, (!IS_NPC(k) ? "PC" : (!IS_MOB(k) ? "NPC" : "MOB")),
+ GET_NAME(k), IS_NPC(k) ? char_script_id(k) : GET_IDNUM(k), GET_ROOM_VNUM(IN_ROOM(k)), IS_NPC(k) ? NOWHERE : GET_LOADROOM(k), IS_NPC(k) ? ORIGINALROOM(k) : NOWHERE);
in graph.c
change:
- static int find_first_step(room_rnum src, room_rnum target);
to
+ int find_first_step(room_rnum src, room_rnum target);
and where the function itself is (this makes it available outside of graph.c):
-static int find_first_step(room_rnum src, room_rnum target)
{
+int find_first_step(room_rnum src, room_rnum target)
{
in mob_act.c
At the top:
+ extern int find_first_step(room_rnum src, room_rnum target);
+ void do_sentinel(struct char_data *mob);
void mobile_activity(void)
{
/* Add new mobile actions here */
+ if (MOB_FLAGGED(ch, MOB_SENTINEL)) {
+ do_sentinel(ch);
+ continue;
+ }
then after the mobil_activity() function:
+/* MOB_SENTINEL mobs go back to their original room if they have been moved */
+void do_sentinel(struct char_data *mob)
+{
+ int dir;
+
+ if (MOB_FLAGGED(mob, MOB_SENTINEL)) {
+ if (ORIGINALROOM(mob) && ORIGINALROOM(mob) != NOWHERE) {
+ if (IN_ROOM(mob) != real_room(ORIGINALROOM(mob))) {
+ dir = find_first_step(IN_ROOM(mob), real_room(ORIGINALROOM(mob)));
+ if(EXIT(mob, dir))
+ perform_move(mob, dir, 1);
+ }
+ }
+ return;
+ }
+}
in dg_scripts.c
void load_mtrigger(char_data *ch)
{
trig_data *t;
int result = 0;
+if (MOB_FLAGGED(ch, MOB_SENTINEL))
+ {
+ ORIGINALROOM(ch) = GET_ROOM_VNUM(IN_ROOM(ch));
+ }