[CODE] Throw skill

From: Melissa Jadwinski (meersan@earthlink.net)
Date: 10/08/00


Here is the code for a 'throw' skill, which allows a player to throw darts
or daggers (actually, any weapon) at an opponent.  Probably dozens of these
have been written, but here's my version.

In spells.h :
#define SKILL_THROW    XXX /* Use next unused skill # */

In interpreter.c :
After:
ACMD(do_tell);
Put:
ACMD(do_throw);

After:
  { "teleport" , POS_DEAD    , do_teleport , LVL_GOD, 0 },
Put:
  { "throw"    , POS_FIGHTING, do_throw    , 1, 0 },

In act.offensive.c :

ACMD(do_throw)
{
  struct char_data *vict;
  int percent, prob, dam;

  if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_THROW)) {
    send_to_char("You have no idea how.\r\n", ch);
    return;
  }

  if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_PEACEFUL)) {
    send_to_char("This room just has such a peaceful, easy feeling...\r\n",
ch);
    return;
  }

  skip_spaces(&argument);

  if (!*argument) {
    send_to_char("Usage: throw <weapon> <victim>\r\n", ch);
    return;
  }

  two_arguments(argument, arg1, arg2);

  if (!(obj = get_obj_in_list_vis(ch, arg1, ch->carrying))) {
    send_to_char("You can't seem to find it.\r\n", ch);
    return;
  }

  if ((GET_OBJ_TYPE(obj) != ITEM_WEAPON)) {
    send_to_char("You can only throw weapons!\r\n", ch);
    return;
  }

  if (!(vict = get_char_vis(ch, arg2, FIND_CHAR_ROOM))) {
    if (FIGHTING(ch) && IN_ROOM(ch) == IN_ROOM(FIGHTING(ch))) {
      vict = FIGHTING(ch);
    } else {
      send_to_char("Throw it at whom?\r\n", ch);
      return;
    }
  }
  if (vict == ch) {
    send_to_char("Aren't we funny today...\r\n", ch);
    return;
  }

  /* 101% is a complete failure */
  percent = ((10 - (compute_armor_class(vict) / 10)) * 2) + number(1, 101);
  prob = GET_SKILL(ch, SKILL_THROW);

  dam  = dice(GET_OBJ_VAL(obj, 1), GET_OBJ_VAL(obj, 2));
  dam *= number(2, 5);
  if (percent > prob) {
    dam = 0;

  obj_from_char(obj);
  obj_to_char(obj, vict);

  act("You throw $p at $N!", FALSE, ch, obj, vict, TO_CHAR);
  act("$n throws $p at $N!", FALSE, ch, obj, vict, TO_NOTVICT);
  act("$n throws $p at you!", FALSE, ch, obj, vict, TO_VICT);

  damage(ch, vict, dam, SKILL_THROW);
  WAIT_STATE(ch, PULSE_VIOLENCE * 2);
}


In lib/text/help/commands.hlp :
Near the end of the file, put:
THROW

Usage: throw <weapon> [<victim>]

This skill allows a player to throw a weapon at a victim. The
weapon thrown will strike the victim with full force, dealing
a significant amount of damage.  The amount of damage depends on
the weapon used.
#


That should do it.
Melissa Jadwinski / meersan@earthlink.net
Meer / Shameless meersan.net 4200


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT