/*
 * Swat - Shaydz
 * Additions by Shiannar :)
 *
 */
#include <playerinfo.h>
inherit COMMAND_BASE;
varargs void pimp_shout( string words, object avoid ) {
   object thing, *things;
   things = users();
   foreach( thing in things ) {
      if ( ( thing != avoid ) && !thing->check_earmuffs( "shout" ) )
            thing->event_say( previous_object(), words, ({ }) );
   }
} /* pimp_shout() */
mixed cmd( string words ) {
  string player, reason;
  object ob;
  if (!words || sscanf( words, "%s %s", player, reason ) != 2)
      return notify_fail(" Usage: swat <player> <reason> \n" );
  ob = find_player( this_player()->expand_nickname( player) );
  if ( !ob )
      return notify_fail( player +" not found!\n" );
  PLAYERINFO_HANDLER->add_entry(TP,
                                ob->query_name(),
                                "swat",
                                reason);
  log_file("NUKE", (string)ctime( time() )+": "+
                    this_player()->query_short()+" swated "+
                     ob->query_short()+": "+reason+".\n");
  pimp_shout("You look up and see a rather large %^YELLOW%^HAND%^RESET%^ "+
        "forming in the sky.  It appears to be be be holding an "+
        "unusualy large %^YELLOW%^FLY SWATTER%^RESET%^.\n\n");
  write("Nuking player " +ob->query_name()+ ".\n");
  call_out("nuke2", 2, ob);
  return 1;
}
void nuke2(object ob) {
  pimp_shout("As you stare in amazement at this strange apparition "+
        "the %^YELLOW%^FLY SWATTER%^RESET%^ shoots high into the air "
        "looking across the planet for a new insect to crush.\n\n");
  tell_object(ob, "It looks like it is headed for you.\n\n");
  call_out("nuke3", 5, ob);
}
void nuke3(object ob) {
  string name;
  name = ob->query_cap_name();
  if(ob->query_property("fly_swatted") > 2) {
    tell_object(ob, "The %^YELLOW%^FLY SWATTER%^RESET swats all around "
                    "you, but due to your past encounters with it you find "
                    "that you can evade it rather easily.\n\nYou let out a "
                    "triumphant laugh at the useless swatter.\n\n");
    pimp_shout("The %^YELLOW%^FLY SWATTER%^RESET%^ pounds away at "+name+
               " but "+ob->query_pronoun()+" dances away from it easily.\n\n"+
               capitalize(ob->query_pronoun())+" lets out a triumphant "
               "laugh at the swatter.\n\n");
    ob->remove_property("fly_swatted");
    call_out("nuke4", 5, ob);
    return;
  }
  ob->add_property("fly_swatted", ob->query_property("fly_swatted")+1);
  tell_object(ob, "The %^YELLOW%^FLY SWATTER%^RESET%^ hits you squarely on "+
                  "top of the head.  You have the sensation of being "+
                  "squashed much like the flies you mindlessly kill.\n\n");
  ob->save();
  ob->quit();
  pimp_shout("The %^YELLOW%^FLY SWATTER%^RESET%^ begins decending at blinding "+
        "speed and hits "+name +" squarely on top of "+
        "the head.  You shudder as you remember all the flies you have "+
        "mindlessly killed.\n",ob);
}
void nuke4(object ob) {
  tell_object("A lightening bolt arcs out of the sky and completely destroys "
              "you.  The last thing you remember is a voice saying \"Laugh "
              "that off...\"\n\n");
  pimp_shout("A lightening bolt cracks past the %^YELLOW%^FLY SWATTER%^RESET%^ "
             "and earths itself through "+ob->query_cap_name()+".  A voice "
             "booms out, \"Laugh that off...\"\n\n");
  ob->save();
  ob->quit();
}