Ejemplo n.º 1
0
int GiveMinStrToWield(struct obj_data *obj, struct char_data *ch)
{
  int str=0;

  GET_STR(ch) = 16;  /* nice, semi-reasonable start */
  /* 
    will have a problem with except. str, that i do not care to solve
  */

  while (GET_OBJ_WEIGHT(obj) > str_app[STRENGTH_APPLY_INDEX(ch)].wield_w)
     GET_STR(ch)++;

  return(str);

}
Ejemplo n.º 2
0
/*
 * Calculate the THAC0 of the attacker.
 *
 * 'victim' currently isn't used but you could use it for special cases like
 * weapons that hit evil creatures easier or a weapon that always misses
 * attacking an animal.
 */
int compute_thaco(struct char_data *ch, struct char_data *victim)
{
  (void)victim;
  int calc_thaco;

  if (!IS_NPC(ch))
    calc_thaco = thaco(GET_CLASS(ch), GET_LEVEL(ch));
  else		/* THAC0 for monsters is set in the HitRoll */
    calc_thaco = 20;
  calc_thaco -= str_app[STRENGTH_APPLY_INDEX(ch)].tohit;
  calc_thaco -= GET_HITROLL(ch);
  calc_thaco -= (int) ((GET_INT(ch) - 13) / 1.5);	/* Intelligence helps! */
  calc_thaco -= (int) ((GET_WIS(ch) - 13) / 1.5);	/* So does wisdom */

  return calc_thaco;
}
Ejemplo n.º 3
0
/*
 * Calculate the THAC0 of the attacker.
 *
 * 'victim' currently isn't used but you could use it for special cases like
 * weapons that hit evil creatures easier or a weapon that always misses
 * attacking an animal.
 */
int compute_thaco(struct char_data *ch, struct char_data *victim)
{
  int calc_thaco;

  if (!IS_NPC(ch))
    calc_thaco = thaco(GET_CLASS(ch), GET_LEVEL(ch));
  else		/* THAC0 for monsters is set in the HitRoll */
    calc_thaco = 20;
  calc_thaco -= str_app[STRENGTH_APPLY_INDEX(ch)].tohit;
  calc_thaco -= script_char_compute_hitroll(&ch, NULL);
  calc_thaco -= (int) ((GET_INT(ch) - 13) / 1.5);	/* Intelligence helps! */
  calc_thaco -= (int) ((GET_WIS(ch) - 13) / 1.5);	/* So does wisdom */
  script_char_compute_thaco(&ch, &victim, &calc_thaco);

  return calc_thaco;
}
Ejemplo n.º 4
0
void wear(struct char_data *ch, struct obj_data *obj_object, int keyword)
{
	char buffer[MAX_STRING_LENGTH];

	switch(keyword) {
		case 0: {  /* LIGHT SOURCE */
			if (ch->equipment[WEAR_LIGHT])
				send_to_char("You are already holding a light source.\n\r", ch);
			else {
				send_to_char("Ok.\n\r", ch);
				perform_wear(ch,obj_object,keyword);
				obj_from_char(obj_object);
				equip_char(ch,obj_object, WEAR_LIGHT);
				if (obj_object->obj_flags.value[2])
					world[ch->in_room].light++;
			}
		} break;

		case 1: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_FINGER)) {
				if ((ch->equipment[WEAR_FINGER_L]) && (ch->equipment[WEAR_FINGER_R])) {
					send_to_char(
						"You are already wearing something on your fingers.\n\r", ch);
				} else {
					perform_wear(ch,obj_object,keyword);
					if (ch->equipment[WEAR_FINGER_L]) {
						sprintf(buffer, "You put the %s on your right finger.\n\r", 
							fname(obj_object->name));
						send_to_char(buffer, ch);
						obj_from_char(obj_object);
						equip_char(ch, obj_object, WEAR_FINGER_R);
					} else {
						sprintf(buffer, "You put the %s on your left finger.\n\r", 
							fname(obj_object->name));
						send_to_char(buffer, ch);
						obj_from_char(obj_object);
						equip_char(ch, obj_object, WEAR_FINGER_L);
					}
				}
			} else {
				send_to_char("You can't wear that on your finger.\n\r", ch);
			}
		} break;
		case 2: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_NECK)) {
				if ((ch->equipment[WEAR_NECK_1]) && (ch->equipment[WEAR_NECK_2])) {
					send_to_char("You can't wear any more around your neck.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					if (ch->equipment[WEAR_NECK_1]) {
						obj_from_char(obj_object);
						equip_char(ch, obj_object, WEAR_NECK_2);
					} else {
						obj_from_char(obj_object);
						equip_char(ch, obj_object, WEAR_NECK_1);
					}
				}
			} else {
							send_to_char("You can't wear that around your neck.\n\r", ch);
			}
		} break;
		case 3: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_BODY)) {
				if (ch->equipment[WEAR_BODY]) {
					send_to_char("You already wear something on your body.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch,  obj_object, WEAR_BODY);
				}
			} else {
				send_to_char("You can't wear that on your body.\n\r", ch);
			}
		} break;
		case 4: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_HEAD)) {
				if (ch->equipment[WEAR_HEAD]) {
					send_to_char("You already wear something on your head.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, WEAR_HEAD);
				}
			} else {
				send_to_char("You can't wear that on your head.\n\r", ch);
			}
		} break;
		case 5: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_LEGS)) {
				if (ch->equipment[WEAR_LEGS]) {
					send_to_char("You already wear something on your legs.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, WEAR_LEGS);
				}
			} else {
				send_to_char("You can't wear that on your legs.\n\r", ch);
			}
		} break;
		case 6: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_FEET)) {
				if (ch->equipment[WEAR_FEET]) {
					send_to_char("You already wear something on your feet.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, WEAR_FEET);
				}
			} else {
				send_to_char("You can't wear that on your feet.\n\r", ch);
			}
		} break;
		case 7: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_HANDS)) {
				if (ch->equipment[WEAR_HANDS]) {
					send_to_char("You already wear something on your hands.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, WEAR_HANDS);
				}
			} else {
				send_to_char("You can't wear that on your hands.\n\r", ch);
			}
		} break;
		case 8: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_ARMS)) {
				if (ch->equipment[WEAR_ARMS]) {
					send_to_char("You already wear something on your arms.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, WEAR_ARMS);
				}
			} else {
				send_to_char("You can't wear that on your arms.\n\r", ch);
			}
		} break;
		case 9: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_ABOUT)) {
				if (ch->equipment[WEAR_ABOUT]) {
					send_to_char("You already wear something about your body.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, WEAR_ABOUT);
				}
			} else {
				send_to_char("You can't wear that about your body.\n\r", ch);
			}
		} break;
		case 10: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_WAISTE)) {
				if (ch->equipment[WEAR_WAISTE]) {
					send_to_char("You already wear something about your waiste.\n\r",
						ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch,  obj_object, WEAR_WAISTE);
				}
			} else {
				send_to_char("You can't wear that about your waist.\n\r", ch);
			}
		} break;
		case 11: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_WRIST)) {
				if ((ch->equipment[WEAR_WRIST_L]) && (ch->equipment[WEAR_WRIST_R])) {
					send_to_char(
						"You already wear something around both your wrists.\n\r", ch);
				} else {
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					if (ch->equipment[WEAR_WRIST_L]) {
						sprintf(buffer, "You wear the %s around your right wrist.\n\r", 
							fname(obj_object->name));
						send_to_char(buffer, ch);
						equip_char(ch,  obj_object, WEAR_WRIST_R);
					} else {
						sprintf(buffer, "You wear the %s around your left wrist.\n\r", 
							fname(obj_object->name));
						send_to_char(buffer, ch);
						equip_char(ch, obj_object, WEAR_WRIST_L);
					}
				}
			} else {
				send_to_char("You can't wear that around your wrist.\n\r", ch);
			}
		} break;

		case 12:
			if (CAN_WEAR(obj_object,ITEM_WIELD)) {
				if (ch->equipment[WIELD]) {
					send_to_char("You are already wielding something.\n\r", ch);
				} else {
					/* Cleric execption has been removed, and is temporarily placed */
					/* at the end of this file                                      */

					if (GET_OBJ_WEIGHT(obj_object) >
					    str_app[STRENGTH_APPLY_INDEX(ch)].wield_w) {
						send_to_char("It is too heavy for you to use.\n\r",ch);
					} else {
						send_to_char("OK.\n\r", ch);
						perform_wear(ch,obj_object,keyword);
						obj_from_char(obj_object);
						equip_char(ch, obj_object, WIELD);
					}
				}
			} else {
				send_to_char("You can't wield that.\n\r", ch);
			}
			break;

		case 13:
			if (CAN_WEAR(obj_object,ITEM_HOLD)) {
				if (ch->equipment[HOLD]) {
					send_to_char("You are already holding something.\n\r", ch);
				} else {
					/* Cleric execption has been removed, and is temporarily placed */
					/* at the end of this file                                      */

					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, HOLD);
				}
			} else {
				send_to_char("You can't hold this.\n\r", ch);
			}
			break;
		case 14: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_SHIELD)) {
				if ((ch->equipment[WEAR_SHIELD])) {
					send_to_char(
						"You are already using a shield\n\r", ch);
				} else {
					perform_wear(ch,obj_object,keyword);
					sprintf(buffer, "You start using the %s.\n\r", 
						fname(obj_object->name));
					send_to_char(buffer, ch);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, WEAR_SHIELD);
				}
			} else {
				send_to_char("You can't use that as a shield.\n\r", ch);
			}
		} break;
		case -1: {
			sprintf(buffer,"Wear %s where?.\n\r", fname(obj_object->name));
			send_to_char(buffer, ch);
		} break;
		case -2: {
			sprintf(buffer,"You can't wear the %s.\n\r", fname(obj_object->name));
			send_to_char(buffer, ch);
		} break;
		default: {
			log("Unknown type called in wear.");
		} break;
	}
}
Ejemplo n.º 5
0
void hit(struct char_data *ch, struct char_data *victim, int type)
{
  struct obj_data *wielded = GET_EQ(ch, WEAR_WIELD);
  int w_type, victim_ac, calc_thaco, dam, diceroll;

  /* Do some sanity checking, in case someone flees, etc. */
  if (IN_ROOM(ch) != IN_ROOM(victim)) {
    if (FIGHTING(ch) && FIGHTING(ch) == victim)
      stop_fighting(ch);
    return;
  }

  /* Find the weapon type (for display purposes only) */
  if (wielded && GET_OBJ_TYPE(wielded) == ITEM_WEAPON)
    w_type = GET_OBJ_VAL(wielded, 3) + TYPE_HIT;
  else {
    if (IS_NPC(ch) && ch->mob_specials.attack_type != 0)
      w_type = ch->mob_specials.attack_type + TYPE_HIT;
    else
      w_type = TYPE_HIT;
  }

  /* Calculate chance of hit. Lower THAC0 is better for attacker. */
  calc_thaco = compute_thaco(ch, victim);

  /* Calculate the raw armor including magic armor.  Lower AC is better for defender. */
  victim_ac = compute_armor_class(victim) / 10;

  /* roll the die and take your chances... */
  diceroll = rand_number(1, 20);

  /*
   * Decide whether this is a hit or a miss.
   *
   *  Victim asleep = hit, otherwise:
   *     1   = Automatic miss.
   *   2..19 = Checked vs. AC.
   *    20   = Automatic hit.
   */
  if (diceroll == 20 || !AWAKE(victim))
    dam = TRUE;
  else if (diceroll == 1)
    dam = FALSE;
  else
    dam = (calc_thaco - diceroll <= victim_ac);

  if (!dam)
    /* the attacker missed the victim */
    damage(ch, victim, 0, type == SKILL_BACKSTAB ? SKILL_BACKSTAB : w_type);
  else {
    /* okay, we know the guy has been hit.  now calculate damage. */

    /* Start with the damage bonuses: the damroll and strength apply */
    dam = str_app[STRENGTH_APPLY_INDEX(ch)].todam;
    dam += GET_DAMROLL(ch);

    /* Maybe holding arrow? */
    if (wielded && GET_OBJ_TYPE(wielded) == ITEM_WEAPON) {
      /* Add weapon-based damage if a weapon is being wielded */
      dam += dice(GET_OBJ_VAL(wielded, 1), GET_OBJ_VAL(wielded, 2));
    } else {
      /* If no weapon, add bare hand damage instead */
      if (IS_NPC(ch))
	dam += dice(ch->mob_specials.damnodice, ch->mob_specials.damsizedice);
      else
	dam += rand_number(0, 2);	/* Max 2 bare hand damage for players */
    }

    /*
     * Include a damage multiplier if victim isn't ready to fight:
     *
     * Position sitting  1.33 x normal
     * Position resting  1.66 x normal
     * Position sleeping 2.00 x normal
     * Position stunned  2.33 x normal
     * Position incap    2.66 x normal
     * Position mortally 3.00 x normal
     *
     * Note, this is a hack because it depends on the particular
     * values of the POSITION_XXX constants.
     */
    if (GET_POS(victim) < POS_FIGHTING)
      dam *= 1 + (POS_FIGHTING - GET_POS(victim)) / 3;

    /* at least 1 hp damage min per hit */
    dam = MAX(1, dam);

    if (type == SKILL_BACKSTAB)
      damage(ch, victim, dam * backstab_mult(GET_LEVEL(ch)), SKILL_BACKSTAB);
    else
      damage(ch, victim, dam, w_type);
  }
}
Ejemplo n.º 6
0
void hit(struct char_data * ch, struct char_data * victim, int type)
{
  struct obj_data *wielded = GET_EQ(ch, WEAR_WIELD);
  int w_type, victim_ac, calc_thaco, dam, diceroll;

  /* check if the character has a fight trigger */
  fight_mtrigger(ch);

  /* Do some sanity checking, in case someone flees, etc. */
  if (!char_within_range_of_vict(ch, victim) || \
     (IN_ROOM(ch) != IN_ROOM(victim))) {
    if (FIGHTING(ch) && (FIGHTING(ch) == victim))
      stop_fighting(ch);
    return;
  }

  /* Find the weapon type (for display purposes only) */
  if (wielded && GET_OBJ_TYPE(wielded) == ITEM_WEAPON)
    w_type = GET_OBJ_VAL(wielded, 3) + TYPE_HIT;
  else {
    if (IS_NPC(ch) && (ch->mob_specials.attack_type != 0))
      w_type = ch->mob_specials.attack_type + TYPE_HIT;
    else
      w_type = TYPE_HIT;
  }

  /* Calculate the THAC0 of the attacker */
  if (!IS_NPC(ch))
    calc_thaco = thaco((int) GET_CLASS(ch), (int) GET_LEVEL(ch));
  else		/* THAC0 for monsters is set in the HitRoll */
    calc_thaco = 20;
  calc_thaco -= str_app[STRENGTH_APPLY_INDEX(ch)].tohit;
  calc_thaco -= GET_HITROLL(ch);
  calc_thaco -= (int) ((GET_INT(ch) - 13) / 1.5);	/* Intelligence helps! */
  calc_thaco -= (int) ((GET_WIS(ch) - 13) / 1.5);	/* So does wisdom */


  /* Calculate the raw armor including magic armor.  Lower AC is better. */
  victim_ac = compute_armor_class(victim) / 10;

  /* roll the die and take your chances... */
  diceroll = number(1, 20);

  /* decide whether this is a hit or a miss */
  if ((((diceroll < 20) && AWAKE(victim)) &&
       ((diceroll == 1) || ((calc_thaco - diceroll) > victim_ac)))) {
    /* the attacker missed the victim */
    if (type == SKILL_BACKSTAB)
      damage(ch, victim, 0, SKILL_BACKSTAB);
    else
      damage(ch, victim, 0, w_type);
  } else {
    /* okay, we know the guy has been hit.  now calculate damage. */

    /* Start with the damage bonuses: the damroll and strength apply */
    dam = str_app[STRENGTH_APPLY_INDEX(ch)].todam;
    dam += GET_DAMROLL(ch);

    /* Maybe holding arrow? */
    if (wielded && GET_OBJ_TYPE(wielded) == ITEM_WEAPON) {
      /* Add weapon-based damage if a weapon is being wielded */
      dam += dice(GET_OBJ_VAL(wielded, 1), GET_OBJ_VAL(wielded, 2));
    } else {
      /* If no weapon, add bare hand damage instead */
      if (IS_NPC(ch)) {
	dam += dice(ch->mob_specials.damnodice, ch->mob_specials.damsizedice);
      } else {
	dam += number(0, 2);	/* Max 2 bare hand damage for players */
      }
    }

    /*
     * Include a damage multiplier if victim isn't ready to fight:
     *
     * Position sitting  1.33 x normal
     * Position resting  1.66 x normal
     * Position sleeping 2.00 x normal
     * Position stunned  2.33 x normal
     * Position incap    2.66 x normal
     * Position mortally 3.00 x normal
     *
     * Note, this is a hack because it depends on the particular
     * values of the POSITION_XXX constants.
     */
    if (GET_POS(victim) < POS_FIGHTING)
      dam *= 1 + (POS_FIGHTING - GET_POS(victim)) / 3;

    /* at least 1 hp damage min per hit */
    dam = MAX(1, dam);

    if (type == SKILL_BACKSTAB) {
      dam *= backstab_mult(GET_LEVEL(ch));
      damage(ch, victim, dam, SKILL_BACKSTAB);
    } else
      damage(ch, victim, dam, w_type);
  }
  /* check if the victim has a hitprcnt trigger */
  hitprcnt_mtrigger(victim);
}