/
lib/banish/
lib/d/
lib/doc/
lib/doc/domains/
lib/doc/efun/
lib/doc/examples/
lib/doc/examples/armour/
lib/doc/examples/contain/
lib/doc/examples/food/
lib/doc/examples/magic/
lib/doc/examples/monster/
lib/doc/examples/room/
lib/doc/examples/weapons/
lib/function/
lib/include/
lib/include/fn_specs/
lib/include/skills/
lib/info/
lib/inherit/base/
lib/log/
lib/manuals/312/
lib/news/
lib/obj/party/
lib/objects/components/
lib/open/
lib/open/library/
lib/open/party/
lib/players/
lib/players/zilanthius/
lib/room/
lib/room/city/arena/
lib/room/city/creator/
lib/room/city/garden/monst/
lib/room/city/obj/
lib/room/city/shop/
lib/room/death/
lib/room/registry/
lib/secure/
lib/secure/UDP_CMD_DIR/
lib/skills/
lib/skills/fighter/
lib/skills/thief/
lib/usr/
lib/usr/creators/
lib/usr/players/
/* basis for a summoned monster */

inherit "inherit/monster";
inherit "inherit/timer";

object master;

object query_master()     { return master; }
void set_master(object m) { master = m; }

string short(status wiz) {
  return (master ? (string)master->query_name() +"'s " : "") 
       + ::short(wiz);
}


void heart_beat() {
  object attack;

  ::heart_beat();
  if(!master) {
    time_out();
    return;
  }
  attack = (object)master->query_primary_attack();
  if(attack == this_object()) {
    time_out();
    return;
  }
  if(attack) {
    if(attack != query_primary_attack()) {
      add_secondary_attacker(attack);
      set_primary_attack(attack);      
    }
    if((object)attack->query_primary_attack() == this_object()) {
      attack->add_secondary_attacker(master);
      attack->set_primary_attack(master);
    }
  }
  if(!attack) {
    if(attack = query_primary_attack()) {
      tell_room(environment(),query_name() +" stops fighting.\n");
      stop_fight(attack);
      attack->stop_fight(this_object());
    }
    set_heart_beat(1);
  }
}


status cast_spell(object caster,object target,object prev,int level) {
  master = caster;
  adj_time(level * 30);
  set_heart_beat(1);
  if(this_object()->id("summoned"))
    tell_room(environment(),"The "+ query_name() +" arrives in a flurry.\n");
  else if(this_object()->id("animated"))
    tell_room(environment(),"The "+ query_name() +" starts to move!\n");
  else if(this_object()->id("conjured")) 
    tell_room(environment(),"The "+ query_name() +
              " appears in a flash of light.\n");
  else
    tell_room(environment(),query_name() +" arrives\n");

  return 1;
}


void time_out() {
  if(this_object()->id("summoned"))
    tell_room(environment(),query_name() +" flees...\n");
  else if(this_object()->id("animated"))
    tell_room(environment(),query_name() +" crumbles to dust!\n");
  else if(this_object()->id("conjured")) 
    tell_room(environment(),query_name() +" disappears...\n");
  else
    tell_room(environment(),query_name() +" fades away...\n");
  
  ::time_out();
}


status dispel_magic() {  time_out(); }


status monster_died() {
  object corpse;

  remove_call_out("time_out");
  if((corpse = present("corpse", environment()))) destruct(corpse);
  tell_room(environment(),"The corpse disappears.\n");
}    

/* Native Mode Move */

#include <move.h>