# NPC

BEFORECREATE:
#pragma strict_types
inherit "/w/piper/inheritables/zmonster";

/* Core code was created by Jerusulum's Code Generator. */

#define PATH "/w/jerusulum/"

// Zmonster implementation is copied verbatim from Buxley.
// Buxley is Jerusulum's hero.  To join the Buxley Fan Club, merely
// send him a tell or mail that says: Jerusulum hugs you tightly!
// Use the following routines to customize the behaviour of monsters.
// For these to work, you have to call set_up_zmonster() at the end
// of the monster's create routine. By default, ALL zmonster abilities
// are turned off. Save them for the intelligent monsters!
// All hail the mighty Piper and his Zmonsters!!!

int query_rooms_to_follow()    { return 0; }  // Return how many.
int query_will_loot_corpse()   { return 0; }  // 1 yes, 0 no
int query_will_eat_and_drink() { return 0; }  // 1 yes, 0 no
int query_picks_on_weaklings() { return 0; }  // 1 yes, 0 no
int query_evasions()           { return 0; }  // 1 yes, 0 no
void setup_zmonster();

void noisy(); /* On/Off for use with dramas. */
void silent();

int query_has_name() { return 1; } /* 1 - 'Jacob', 0 - 'an orc' */
void announce(string str);
void emote(string str);
void speak(string str);

void e_affectionate_physical(object player); /* affectionate_physical */
void e_hurt(object player); /* hurt */

void k_bonk(object player, string verb); /* bonk */

INCREATE:
set_name("Killable");
  set_alias(({"monster", "killable monster"}));
  set_short("a killable monster");
  set_long("Killable is not balanced at all.");
  set_level(1);
  set_race("Human");
  set_gender(1);             /* Male */
  add_money(3243);

  clone_object((string) PATH + "obj/obj/scarf")->move(this_object());
  command("wear scarf");

  set_stats(6, 6, 6, 6, 6);  /* SDICW */
  set_al(-3000);
  set_wc(8);
  set_dex_wc(8);
  set_head_ac(8);
  set_body_ac(8);
  set_arm_ac(8);
  set_leg_ac(8);
  set_leg_str("flipper");
  set_aggressive(1);  /* Aggressive */
  set_aim(3);         /* Arms */

  load_a_chat(10, ({
    "Killable's not very creative, I guess. \n",
    }));     /* Random */

  add_spell(({"fire", 10, 100, 
    "# is toasted.", 
    "##"}));


  enable_commands();
  //set_living_name("Killable");

  noisy();

  setup_zmonster();

AFTERCREATE:
void noisy(){
  /* For use with dramas. */

  load_chat(5, ({
    "Killable has only one normal chat. \n",
    }));     /* Random */

  add_emotion("affectionate_physical", "e_affectionate_physical");
  add_emotion("hurt", "e_hurt");

  add_keyword("bonk", "k_bonk");

  return;
  }

void silent(){
  /* For use with dramas. */
  load_chat();
  remove_emotion("affectionate_physical");
  remove_emotion("hurt");
  remove_keyword("bonk");
  return;
  }

void e_affectionate_physical(object player){
  /* affectionate_physical */
  announce((string) "Beans fall from the sky.");
  return;
  }

void e_hurt(object player){
  /* hurt */
  emote((string) "hits you on your head!");
  return;
  }

void k_bonk(object player, string verb){
  /* bonk */
  if(verb != "say") return;
  speak((string) "I shall bonk you too!");
  return;
  }

void setup_zmonster()
{
  int num_rooms;

  // follow player? How far?
  set_moves_allowed(num_rooms = query_rooms_to_follow());
  set_smart(query_level());
  if (num_rooms > 0) {
    //set_panic_file(ZMONSTER_LOG); // define this if you want.
    set_evade_harmful(1);   // evade cloudkills?
    set_break_snare(1);     // pesky rangers!
  }
  // loot player corpses and use their stuff?
  if (query_will_loot_corpse()) {
    set_grab_delay(2);     // time delay to loot pc corpse
    set_wield_grabbed(1);  // pick best weapon
    set_wear_grabbed(1);   // pick best armour
  }
  // eat food and drink alcohol/potions to aid in healing?
  if (query_will_eat_and_drink()) {
    set_alc_percent(50);   // alcohol
    set_pot_percent(40);   // potions
    set_food_percent(60);  // food
  }
  // pick on weakest attackers?
  if (query_picks_on_weaklings()) {
    set_ymonster_capabilities(1);  // attack player with lowest AC?
    set_dying_level(30);           // attack any player with < 30 hp
    set_change_percent(20);  // % chance of target switch per heartbeat
  }
  if (query_evasions()){
    set_disbelieve(20); // % chance of disbelieving mindkill.
    set_break_snare(1); // Break snares and keep chasing?
  }
}

// Swiped from Buxley, who is my hero.

void announce(string str){
  if (environment())
    tell_room(environment((object) this_object()),
      get_f_string(str));
  }

void emote(string str){
  string who;
  if (environment()) {
    who = query_has_name() ?
      (string) query_name() : capitalize((string) short());
    tell_room(environment((object) this_object()),
      get_f_string(who+" "+str,77,strlen(who)+1));
    }
  }

void speak(string str){
  string who;
  if (environment()) {
    who = query_has_name() ?
      (string) query_name() : capitalize((string) short());
    tell_room(environment((object) this_object()),
      get_f_string(who+" says: "+str,77,strlen(who)+7));
    }
  }


# NPCEMOTION

AFTERCREATE:
void e_hurt(object player){
  /* hurt */
  emote((string) "hits you on your head!");
  return;
  }


BEFORECREATE:
void e_affectionate_physical(object player); /* affectionate_physical */

AFTERCREATE:
void e_affectionate_physical(object player){
  /* affectionate_physical */
  announce((string) "Beans fall from the sky.");
  return;
  }


# NPCKEYWORD

BEFORECREATE:
void k_bonk(object player, string verb); /* bonk */

AFTERCREATE:
void k_bonk(object player, string verb){
  /* bonk */
  if(verb != "say") return;
  speak((string) "I shall bonk you too!");
  return;
  }


# NPCLOAD_A_CHAT

INCREATE:
"Killable's not very creative, I guess. \n",


# NPCLOADCHAT

INCREATE:
"Killable has only one normal chat. \n",


# NPCOBJECT

INCREATE:
clone_object((string) PATH + "obj/obj/scarf")->move(this_object());
  command("wear scarf");


