/
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/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/
/* DISINTEGRATE */

#define NON_LIVING_SAVE 15

#define NAME "@@query_name:$this_player()$@@"  /* gives greater flexibilty */
#define TARG "@@query_name:$this_object()$@@"


status disintergrate(mixed targ, mixed alt_type) {
  int cl, i;
  string file;

  if(!alt_type) alt_type = "alteration";
  cl = (objectp(alt_type))
     ? (int)alt_type->query_cast_level()
     : (int)this_player()->query(alt_type);

  file = file_name(this_object());
  sscanf(file, "%s#%d", file, i);

  this_player()->load_spell(({
  "target",            targ,
  "name",              "Disintergrate",
  "sphere",            alt_type, 
  "cost",              26,
  "damage",            cl, /* used as a save flag */
  "level",             26, /* 30 instant kill - 4 casting time */
  "cast time",         3,
  "spell object",      file,
  "casting msg",       "A dull grey aura starts forming around your hands.\n",
  "casting msg room",  "A dull grey aura starts forming around "+NAME+
                       "'s hands.\n",
  }));
  return 1;
}


/* call when this object is cloned to target */

status cast_spell(object caster,object target,object prev,int dmg) {
  write("A dark grey beam springs from your hands.\n");
  say("A dark grey beam springs from "+(string)caster->query_name()+
      "'s Hands.\n");
  if(!living(target)) {
    if(random(15) < random(dmg)) {
      call_out("disintergrate_ob",1,target);
    }
    else {
      tell_object(caster,"Nothing Happens...\n");
      say("Nothing Happens...\n", caster);
    }
    return 1;
  }           
  if(!(target->query_npc() || caster->query_npc())) {
    tell_room(environment(target), "Nothing happens...\n");
    return 1;
  }
  if(dmg == (int)caster->query_spell_dmg()) { /* did not save */
    call_out("disintergrate_ob", 1, target);
  }
  else if(!dmg) {
    write("You see the beam hit "+(string)target->query_name()+".\n"+
          capitalize((string)target->query_pronoun())+
          " resist the beam.\n");
    tell_object(target,"You resist the disintergration beam.\n");
    say("The beam has no effect on "+(string)target->query_name()+".\n");
    destruct(this_object());
  }
  else {
    write("You see "+(string)target->query_name()+" dodge the beam!\n");
    tell_object(target,"You dodge the beam!!\n");
    say((string)target->query_name()+" dodges the beam.\n");
    destruct(this_object()); /* get rid of cloned object */
  }
  return 1; /* don't do damage */
}


static void disintergrate_ob(object target) {
  string name;
  object env;

  env = environment();
  name = (string)target->query_name();
  target->death();
  if(env)
    tell_object(env,"You see the beam strike "+name+" turn to dust.\n");
  say("The dark grey beam turns "+name+" to dust.\n");
  if(target) {
    destruct(target);
  }
  else {
    target = environment();
    if(target->id("corpse")) destruct(target); /* death() has moved us */
  }
  env = environment();
  move_object(clone_object("players/angel/spells/obj/dust"), env);
  destruct(this_object());
}

status id(string str) { return (str == "spell"); }

/* Native Mode Move */

#include <move.h>