fight.c

source/src/fight.c · 297.9 KB

From the archive forsakenlands.tgz

Download the archive   « Back to the archive contents

#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include "merc.h"
#include "magic.h"
#include "interp.h"
#include "recycle.h"
#include "jail.h"
#include "cabal.h"
#include "bounty.h"
#include "armies.h"
#include "clan.h"
#include "autoquest.h"

extern void dreamprobe_cast( CHAR_DATA* victim, char* msg );
CHAR_DATA* masochism_effect( CHAR_DATA* ch, int dam, int dt );
extern bool forms(CHAR_DATA *ch, char *argument, AFFECT_DATA* paf);
extern void fulfill_bounty( CHAR_DATA *ch, CHAR_DATA *victim, char* name);
extern CHAR_DATA* undead_check_guard args( (CHAR_DATA* ch, CHAR_DATA* mob) );
extern CHAR_DATA* knight_rescue args( (CHAR_DATA* ch, CHAR_DATA* victim, int dam, int dt) );
extern void throw(CHAR_DATA *ch, CHAR_DATA *victim, OBJ_DATA *obj, int throw, bool fThief, bool fAutoMiss);
extern bool check_melee_actions( CHAR_DATA* ch);
extern bool check_secart_actions( CHAR_DATA* ch);
extern void deathblow( CHAR_DATA* ch, CHAR_DATA* victim, int type, bool fMiss );
extern void fire_ranged_weapons( CHAR_DATA* ch, CHAR_DATA* victim );

//checks if doomsinger works
bool doomsingerCheck( CHAR_DATA* ch ){
  if (IS_NPC(ch))
    return FALSE;
  else if (ch->class != gcn_blademaster)
    return FALSE;
  else if (!is_affected(ch, gsn_doomsinger))
    return FALSE;
  else if (!has_twohanded(ch))
    return FALSE;

  return TRUE;
}
//checks for possibility of deathstrike when blademaster dies to pc
bool deathstrikeCheck( CHAR_DATA* ch, CHAR_DATA* victim){
  const int sn = skill_lookup("deathstrike");
  int skill, anat, dur, dam;

  if (ch == NULL || victim == NULL)
    return FALSE;
  else if (ch == victim)
    return FALSE;
  else if (ch->in_room == NULL || victim->in_room == NULL || ch->in_room != victim->in_room)
    return FALSE;
  else if (IS_IMMORTAL(ch))
    return FALSE;
  else if (IS_NPC(ch))
    return FALSE;
  else if (IS_NPC(victim))
    return FALSE;
  else if (getBmWep(victim, TRUE) == NULL)
    return FALSE;

  //get the skill/chance
  skill = get_skill(victim, sn );

  if (skill < 2)
    return FALSE;

  skill = (skill - 50) * 2;
  skill += (get_curr_stat(victim, STAT_LUCK) - get_curr_stat(ch, STAT_LUCK)) * 5;

  if (number_percent() > skill){
    check_improve(victim, sn, FALSE, -99);
    dam = 0;
  }
  else{
    check_improve(victim, sn, TRUE, -99);
    dam = ch->max_hit / 3;
  }

  //get the duration based on anatomy
  anat = anatomy_lookup(race_table[ch->race].name);
  anat = victim->pcdata->anatomy[anat];

  if (anat < 101)
    dur = 0;
  else if (anat < 111)
    dur = 1;
  else
    dur = 2;
  
  act("$n suddenly spins about, $s back against your chest!", victim, NULL, ch, TO_VICT );
  act("$n suddenly spins about, $s back against $N's chest!", victim, NULL, ch, TO_NOTVICT );
  act_new("You spin about placing your back against $N's chest!", victim, NULL, ch, TO_CHAR, POS_DEAD );

 
  //if they can survive the hit, just damage, otherwise, mortal wound
  if (ch->hit < dam){
    int temp_hp = ch->hit;
    int temp_mana = ch->mana;
    int temp_pos = victim->position;

    victim->position = POS_STANDING;
    //fake messages
    dam_message( victim, victim, NULL, dam, sn, FALSE, FALSE, sn, TRUE );
    dam_message( victim, ch, NULL, dam, sn, FALSE, FALSE, sn, TRUE );
    mercy_effect(victim, ch, dur );

    victim->position = temp_pos;

    ch->hit = temp_hp;
    ch->mana = temp_mana;
    return TRUE;
  }
  else{
    int temp_pos = victim->position;

    victim->position = POS_STANDING;

    dam /= 2;
    dam_message( victim, victim, NULL, dam, sn, FALSE, FALSE, sn, TRUE );
    damage(victim, ch, dam, sn, DAM_INTERNAL, TRUE );

    victim->position = temp_pos;
    return FALSE;
  }
}

//blademaster deathweaver defense check
CHAR_DATA* bmDeathweaverCheck( CHAR_DATA* att, CHAR_DATA* weaver){
  const int MAX_CHARS = 6;
  CHAR_DATA* vch;
  CHAR_DATA* chars[MAX_CHARS];
  
  int max = 0;

  if (IS_NPC(weaver))
    return NULL;
  else if (weaver->class != gcn_blademaster)
    return NULL;
  else if (weaver->mana < 2)
    return NULL;
  else if (!is_affected(weaver, gsn_deathweaver))
    return NULL;
  else if (number_percent() < (get_skill(weaver, gsn_deathweaver) / 2 + (get_curr_stat(weaver, STAT_LUCK) - 14) * 2) )
    return NULL;

  check_improve(weaver, gsn_deathweaver, TRUE, 1);

  /* find possible redirection targets */
  for (vch = att->in_room->people; vch; vch = vch->next_in_room){
    if (vch->fighting == NULL || vch->fighting != weaver || vch == att)
      continue;
    else
      chars[max++] = vch;
  }

  if (max < 1)
    return NULL;
  else
    return (chars[number_range(0, max - 1)]);
}

/* checks if person has sheathed weapons, and no primaries */
bool is_sheathed(CHAR_DATA* ch){
  if (get_eq_char(ch, WEAR_SHEATH_L) == NULL)
    return FALSE;
  if (get_eq_char(ch, WEAR_SHEATH_R) == NULL)
    return FALSE;
  if (get_eq_char(ch, WEAR_WIELD) != NULL)
    return FALSE;
  if (get_eq_char(ch, WEAR_SECONDARY) != NULL)
    return FALSE;
  return TRUE;
}

/* ninja shadow arts */
bool shadow_strike(CHAR_DATA* ch, CHAR_DATA* victim){
  const int skill = get_skill(ch, gsn_shadow_strike);
  const int damage_ch = (skill / 2)
    + 2 * (get_curr_stat(ch,STAT_LUCK) - get_curr_stat(victim,STAT_LUCK))
    + (skill > 80? 3 : 0) + (skill > 90? 6 : 0) + (skill > 99? 9 : 0);  
  int chance = 20;

  chance += UMAX(0, (skill - 75) * 2);
  if (IS_NPC(ch))
    return FALSE;
  if (skill < 2 || number_percent() > chance)
    return FALSE;
  if (ch->fighting != victim)
    return FALSE;
  act("You feign and strike at $N's nerve point.", ch, NULL, victim, TO_CHAR);
  act("$n feigns and reaches out towards $N.",ch, NULL, victim, TO_NOTVICT);
  act("$n feigns and reaches out towards you.",ch, NULL, victim, TO_VICT);
  
  if (number_percent() < damage_ch){
    AFFECT_DATA af, *paf;
    int high = -99;
    int high_loc = 0;
    bool fMax = FALSE;
    
    check_improve(ch, gsn_shadow_strike, TRUE, 1);  
    
    af.location = number_range(1, 5); //(str to con)
    //check for maximum -3 penalty
    for (paf = victim->affected; paf; paf = paf->next){
      if (paf->type != gsn_shadow_strike)
	continue;
      if (paf->location == af.location && paf->modifier <= -3)
	fMax = TRUE;
      if (paf->modifier > high){
	high = paf->modifier;
	high_loc = paf->location;
      }
    }
  
    //if highest value is lower then -3 we do nothing
    if (high != -99 && high < -3)
      return FALSE;
    //switch location if required
    if (fMax){
      if (high > -3 && high_loc)
	af.location = high_loc;
      else{
	damage(ch, victim, number_range(1 + ch->level / 2, 1 + ch->level), gsn_shadow_strike, DAM_PIERCE, TRUE);
	return FALSE;
      }
    }
    af.type = gsn_shadow_strike;
    af.level = ch->level;
    af.duration = number_range(1, 3);
    af.where = TO_AFFECTS;
    af.bitvector = 0;
    af.modifier = -1;
    affect_join(victim, &af);

    damage(ch, victim, number_range(1 + ch->level / 2, 1 + ch->level), gsn_shadow_strike, DAM_PIERCE, TRUE);
    return TRUE;
  }
  else{
    damage(ch, victim, 0, gsn_shadow_strike, DAM_BASH, TRUE);
    check_improve(ch, gsn_shadow_strike, FALSE, 2);
    return FALSE;
  }
}

/* this kicks in when a person fleels giving skilled opponent chance
for free hit to the back
*/

bool throw_effect(CHAR_DATA* ch, CHAR_DATA* victim, bool fAutoMiss){
/* all we do here is check for ninja/thief and their types of 
   ammo, then try to throw */
  bool fThief = ch->class == class_lookup("thief");
  bool fNinja = ch->class == class_lookup("ninja");

  OBJ_DATA* obj;

  int throws = (get_skill(ch, gsn_throw) - 60) / 8;
  int i = 1;

  //need double sheeth and empty sheaths
  if (get_skill(ch, gsn_sheath) < 2
      || (get_eq_char(ch, WEAR_SHEATH_L) != NULL
	  && get_eq_char(ch, WEAR_SHEATH_R) != NULL)
      ){
    return FALSE;
  }
  else if ((!fThief && !fNinja) || !can_see(ch, victim))
    return FALSE;
  else if (number_percent() > get_skill(ch, gsn_throw)){
    check_improve(ch, gsn_throw, FALSE, 1);
    return FALSE;
  }

/* get ammo */
  for (obj = ch->carrying; obj; obj = obj->next_content){
    if (obj->item_type != ITEM_THROW)
      continue;
    if (fNinja && obj->cost != 0)
      continue;
    if (fThief && obj->cost != 1)
      continue;
    break;
  }
  if (obj == NULL || obj->value[0] < 1)
    return FALSE;

  if (fNinja)
    i = number_range(1, throws);
  check_improve(ch, gsn_throw, TRUE, 1);
  throw(ch, victim, obj, i, fThief, fAutoMiss);
  return TRUE;
}

bool backcutter_effect(CHAR_DATA* ch, CHAR_DATA* victim, bool fAutoMiss){
  OBJ_DATA* obj;
  int chance = 0;
  int sn = skill_lookup("backcutter");
  int dam_type = DAM_PIERCE;
  int dam = number_range(ch->level, 2 * ch->level);
  const int cost = skill_table[sn].min_mana;

/* safety */
  if (ch == NULL)
    return FALSE;

  if (IS_NPC(ch) || is_safe_quiet(ch, victim))
    return FALSE;

  if ( (chance = get_skill(ch, gsn_orealts_2nd))  < 1){
    if ( (chance = get_skill(ch, sn)) < 1)
      return FALSE;
  }

/* final parting effect */
  if (is_affected(ch, gsn_fpart) || is_affected(victim, gsn_fpart)){
    /* check if fleeing person gets hit */
    if (victim->hit < (25 * victim->max_hit / 100)){
      int dam = number_range(2 * victim->level, 3 * victim->level);
      if (is_affected(ch, gsn_fpart)){
	affect_strip(ch, gsn_fpart);
	act_new(skill_table[gsn_fpart].msg_off,ch,NULL,NULL,TO_CHAR,POS_DEAD);
      }
      if (is_affected(victim, gsn_fpart)){
	affect_strip(victim, gsn_fpart);
	act_new(skill_table[gsn_fpart].msg_off,victim,NULL,NULL,TO_CHAR,POS_DEAD);
      }
      damage(ch, victim, dam, gsn_fpart, DAM_INTERNAL, TRUE);
      return TRUE;
    }//sucessful final parting
  }//final part check

/* check for mana */
  if (ch->mana < cost)
    return FALSE;

  /* get weapon to be used if any */
  obj = get_eq_char( ch, WEAR_WIELD );
  /* warriors can only do this using spears and staffs */
  if ((!obj || (obj->value[0] != WEAPON_SPEAR 
		&& obj->value[0] != WEAPON_STAFF))
      && ch->class == class_lookup("warrior")){
    return FALSE;
  }

  if (fAutoMiss || number_percent() > chance){
    check_improve(ch, gsn_orealts_2nd, FALSE, 1);
    check_improve(ch, sn, FALSE, 1);
    dam = 0;
  }

  /* draw mana only on success */
  ch->mana -= cost;
  /* hit them */

  dam_type = obj ? attack_table[obj->value[3]].damage : DAM_BASH;
  damage(ch, victim, dam, sn, dam_type, TRUE);

  check_improve(ch, gsn_orealts_2nd, FALSE, 1);
  check_improve(ch, sn, FALSE, 1);
  return TRUE;
}


/* checks and validates if ch is on crusade against victim */
/* Returns CRUSADE_NONE, CRUSADE_MATCH, CRUSADE_NOTMATCH */
/* used in defense checks */
int check_crusade(CHAR_DATA* ch, CHAR_DATA* victim){
  AFFECT_DATA* paf;

  if (IS_NPC(ch) || IS_NPC(victim))
    return CRUSADE_NONE;

  if ( (paf = affect_find(ch->affected, gen_crusade)) == NULL)
    return CRUSADE_NONE;

/* start checking */
  switch(paf->level){
  case CRUSADE_RACE:
    if (paf->modifier == -1
	&& IS_AVATAR(victim))
      return CRUSADE_MATCH;
    else if (paf->modifier == race_lookup("undead") && IS_UNDEAD(victim))
      return CRUSADE_MATCH;
    else if (paf->modifier == victim->race)
      return CRUSADE_MATCH;
    break;
  case CRUSADE_CLASS:
    if (paf->modifier == victim->class)
      return CRUSADE_MATCH;
    break;
  case CRUSADE_CABAL:
    if (victim->pCabal && paf->modifier == get_parent(victim->pCabal)->vnum)
      return CRUSADE_MATCH;
    break;
  default:
    return CRUSADE_NONE;
  }
  return CRUSADE_NOTMATCH;
}

/* checks for avenger match, uses same codes as check_crusade */
int check_avenger(CHAR_DATA* ch, CHAR_DATA* victim){
  AFFECT_DATA* paf, *baf;

  if (IS_NPC(ch))
    return CRUSADE_NONE;

  /* check for the paf */
  if ( (paf = affect_find(ch->affected, gen_avenger)) == NULL)
    return CRUSADE_NONE;

  /* we know the char is avenger, check victim now */
  if (!is_name(paf->string, victim->name))
    return CRUSADE_NOTMATCH;

  /* now if npc we check if this is the victim we are looking for */
  if (IS_NPC(victim)){
    for (baf = victim->affected; baf != NULL; baf = baf->next){
      if (baf->type == gsn_avenger
	  && baf->modifier == paf->modifier)
	return CRUSADE_MATCH;
    }
    return CRUSADE_NOTMATCH;
  }
  else
    return CRUSADE_MATCH;
}

/* handle all combinations of defenses */
bool check_defenses( CHAR_DATA *ch, 
		CHAR_DATA *victim, 
		OBJ_DATA* obj, 
		int dt, 
		int h_roll, 
		int lvl, 
		bool fVirt, 
		int sn){

  const int MAX_DEF = 9;	//Current maximum number of defenses
  int seed[MAX_DEF];
  int order[MAX_DEF];
  int i;
  int cur_max = MAX_DEF;
  int cur_order = 0;

  /* absolute fails */
  if (victim->position < POS_FIGHTING 
      || is_affected(victim, gsn_mortally_wounded)
      || is_affected(ch, gsn_feign))
    return FALSE;

  /* check for mirage */
  if (ch->class == gcn_psi 
      && is_affected(ch, gsn_mirage)
      && !saves_spell(ch->level, victim, DAM_MENTAL, skill_table[gsn_mirage].spell_type)){
    return FALSE;
  }
/* we first fill the seed with ordered defense numbers */
  for (i = 0; i  < MAX_DEF; i++){
    seed[i] = i;
    order[i] = -1;
  }

/* begin to randomly put seed in order */
  for (i = 0; i  < MAX_DEF; i++){
    int rand = number_range(0, cur_max - 1);
    int j = 0;
    /* place a random seed into a spot in order */
    order[cur_order++] = seed[rand];
    /* set that seed spot to -1 indicating empty */
    seed[rand] = -1;

    /* now we need to compact the seed array */
    for (j = 0; j < cur_max; j++){
      /* we check if the current sport is empty */
      if (seed[j] == -1 ){
	/* we compact by bubbling the empty spot up */
	seed[j] = seed[j + 1];
	seed[j + 1] = -1;
      }
    }
    /* lower current max by one, since the empty spot is now at top */
    cur_max--;
  }

/* DEBUG 
  sendf(ch, "Defense Order [");
  for (i = 0; i < MAX_DEF; i++)
    sendf(ch, "%d ", order[i]);
  sendf(ch, "]\n\r");
*/
/* now we apply the defenses */

/* PARRY		0
 * DUAL PARRY		1	
 * MONK FIRST PARRY	2
 * MONK SECOND PARRY	3
 * DODGE		4
 * SHIELD BLOCK		5
 * WEAPON BLOCK		6
 * RIPOSTE		7
 * BLINK		8
 */

  for (i = 0; i < MAX_DEF; i++){
    switch (order[i]){
/* PARRY */
    case 0:
      if (check_parry( ch, victim, obj, dt, h_roll, lvl, fVirt, sn))
	return TRUE;
      break;
/* DUAL PARRY */
    case 1:
      if (check_dual_parry( ch, victim, obj, dt, h_roll, lvl, fVirt, sn))
	return TRUE;
      break;
/* MONK FIRST PARRY */
    case 2:
      if ( check_parry_monk( ch, victim, obj, dt, h_roll, lvl,  FALSE, fVirt, sn))
	return TRUE;
      break;
/* MONK SECOND PARRY */
    case 3:
      if ( check_parry_monk( ch, victim, obj, dt, h_roll, lvl,  TRUE, fVirt, sn))
	return TRUE;
      break;
/* DODGE */
    case 4:
      if ( check_dodge( ch, victim, obj, dt, h_roll, lvl, fVirt, sn) )
	return TRUE;
      break;
/* SHIELD BLOCK */
    case 5:
      if ( check_shield_block( ch, victim, obj, dt, h_roll, lvl, fVirt, sn) )
	return TRUE;
      break;
/* WEAPON BLOCK */
    case 6:
      if ( check_block( ch, victim, obj, dt, h_roll, lvl, fVirt, sn) )
	return TRUE;
      break;
/* RIPOSTE */
    case 7:
      if ( check_riposte( ch, victim, obj, dt, h_roll, lvl, fVirt, sn) )
	return TRUE;
      break;
/* BLINK */
    case 8:
      if ( check_blink( ch, victim, obj, dt, h_roll, lvl, fVirt, sn) )
	return TRUE;
      break;
    }
/* END DEFENSES */
  }
  return FALSE;
}

/* Used to morph a mob to current victims level and power */
/* Assumes that the original stats for the mob were set for */
/* an opponent of level 50				   */
void morph_mob(CHAR_DATA* mob, CHAR_DATA* victim){
  MOB_INDEX_DATA* pMobIndex;

  int mod = 0;
  int hp_level = 0;
  int level = mob->level;
  int i = 0;
  int hitroll = 0;
  int damroll = 0;

  bool fWarrior = FALSE;
  bool fHalfWar = FALSE;
  bool fRouge = FALSE;
  bool fMage = FALSE;

/* decide what type of character this is */
  if (IS_NPC(victim))
    fWarrior = TRUE;
  else if (victim->class == gcn_blademaster)
    fWarrior = TRUE;
  else if (victim->class == class_lookup("monk"))
    fHalfWar = TRUE;
  else if (victim->class == class_lookup("vampire"))
    fWarrior = TRUE;
  else{
    int attack = 1;
    int defense = 0;

/* Offense */
    if (victim->pcdata->learned[gsn_second_attack])
      attack++;
    if (victim->pcdata->learned[gsn_third_attack])
      attack++;
    if (victim->pcdata->learned[gsn_fourth_attack])
      attack++;
    if (victim->pcdata->learned[gsn_blades])
      attack += 2;
    if (victim->pcdata->learned[gsn_dan_blade])
      attack++;

/* defense */
    if (victim->pcdata->learned[gsn_parry])
      defense++;
    if (victim->pcdata->learned[gsn_dual_parry])
      defense++;
    if (victim->pcdata->learned[gsn_dodge])
      defense++;
    if (victim->pcdata->learned[gsn_shield_block]
	|| victim->pcdata->learned[gsn_2hands])
      defense++;
    if (victim->pcdata->learned[gsn_terra_shield])
      defense++;
    if (victim->pcdata->learned[gsn_blades])
      defense++;
    if (victim->pcdata->learned[skill_lookup("blur")])
      defense++;

/* select which type this is */
    if (attack > 3 || defense > 3)
      fWarrior = TRUE;
    else if (attack > 2 || defense > 1){
      if (victim->pcdata->learned[gsn_hide]
	  || victim->pcdata->learned[gsn_camouflage])
	fRouge = TRUE;
      else
	fHalfWar = TRUE;
    }
    else
      fMage = TRUE;
  }
  act("$n seems to change in size and shape to match yours.", 
      mob, NULL, victim, TO_VICT);
  act("$n seems to change in size and shape to match $N's.", 
      mob, NULL, victim, TO_NOTVICT);
  
/* adjust things base on general archtype */
/* most of this is based on special guards plus few modifications */
  if (!IS_NPC(mob)){
    bug("morph_mob: PC passed as mob.", 0);
    return;
  }
  else{
    if ( ( pMobIndex = get_mob_index( mob->pIndexData->vnum)) == NULL){
      bug("morph_mob: mob index not found.", mob->pIndexData->vnum);
      return;
    }
  }
  if (fWarrior){
    level += 2;
    hitroll += level/5;
    damroll += level/6;
  }
  else if (fHalfWar){
    level += 1;
    hitroll += level/6;
    damroll += level/6;
  }
  else if (fRouge){
    hitroll -= level/6;
    damroll -= level/8;
  }
  else if (fMage){
    level --;
    hitroll -= level/8;
    damroll -= level/10;
  }

  mob->size = victim->size;  
  level = UMAX(5, (victim->level + (victim->level/15) ));
  mod = 100 * victim->level / pMobIndex->level;
  mob->level = level;

  for (i=0;i < MAX_STATS; i++)  
    mob->perm_stat[i] = get_max_train(victim, i);
  for (i=0; i < 4; i++)
    mob->armor[i] = pMobIndex->ac[i] * mod / 100;
  hp_level = 100 * mob->hit / mob->max_hit;
  mob->max_hit = UMAX(1, mod * mob->max_hit / 100);
  mob->hit = UMAX(1, hp_level * mob->max_hit / 100);
  
  damroll = pMobIndex->damage[DICE_BONUS] * mod / 100;
  hitroll = pMobIndex->hitroll * mod / 100;
  
  mob->hitroll    = hitroll;
  mob->damroll    = damroll;
  mob->damage[DICE_NUMBER]  = UMAX(1, mod * pMobIndex->damage[DICE_NUMBER] / 100);
  
}

/* PREVOILENCE_CHECK */
/* Called in fight.c only */
/* same args as set_fighting in which it will be called. */
int PREVIOLENCE_CHECK( CHAR_DATA *ch, CHAR_DATA *victim)
{
  CHAR_DATA* vch = ch;
  AFFECT_DATA* paf;
  AFFECT_DATA* paf_next;

  int fSuccess = TRUE;
  int result = 0;

  for (paf = vch->affected; paf != NULL; paf = paf_next) {
    paf_next = paf->next;
    //we only run the update once per effect.
    if (paf_next != NULL)
      if (paf->type == paf_next->type)
	continue;
    
    if (IS_GEN(paf->type)) {
      if ((result = run_effect_update(vch, paf, victim, paf->type, NULL, NULL, 
				      TRUE, EFF_UPDATE_PREVIOLENCE)) != TRUE) {
	if (result == -1) {
	  return -1;
	}
	else {
	  fSuccess = result;
	}
      }
    }
  }

  return fSuccess;
}//end PREVIOLENCE_CHECK

/* POSTVOILENCE_CHECK */
/* Called in fight.c only */
/* same args as stop_fighting in which it will be called. */
int POSTVIOLENCE_CHECK( CHAR_DATA *ch)
{
  CHAR_DATA* vch = ch;
  AFFECT_DATA* paf;
  AFFECT_DATA* paf_next;

  int fSuccess = TRUE;
  int result = 0;

  for (paf = vch->affected; paf != NULL; paf = paf_next) {
    paf_next = paf->next;
    //we only run the update once per effect.
    if (paf_next != NULL) {
      if (paf->type == paf_next->type) {
	continue;
      }
    }
    
    if (IS_GEN(paf->type)) {
      if ((result = run_effect_update(vch, paf, NULL, paf->type, 
				      NULL, NULL, TRUE, EFF_UPDATE_POSTVIOLENCE)) != TRUE) {
	if (result == -1) {
	  return -1;
	}
	else {
	  fSuccess = result;
	}
      }
    }
  }

  return fSuccess;
}//end POSTVIOLENCE_CHECK

/* DODGE_CHECK */
/* Called in fight.c only */
inline int DODGE_CHECK( CHAR_DATA *ch, CHAR_DATA *victim, int dt)
{
  int fSuccess  = TRUE;
  CHAR_DATA* vch = ch;

  AFFECT_DATA* paf;
  AFFECT_DATA* paf_next;

  int result = 0;

  for (paf = vch->affected; paf != NULL; paf = paf_next) {
      paf_next = paf->next;
      //we only run the update once per effect.
      if (paf_next != NULL) {
	if (paf->type == paf_next->type) {
	  continue;
	}
      }
      
      //GENS THAT ARE HANDLED SEPERATLY

      
      if (IS_GEN(paf->type)) {
	if ((result = run_effect_update(vch, victim, paf, paf->type, 
					&dt, NULL, TRUE, EFF_UPDATE_DODGE)) != TRUE) {
	  if (result == -1) {
	    return -1;
	  }
	  else {
	    fSuccess = result;
	  }
	}
      }
    }
  
  return fSuccess;
}// end DODGE_CHECK

/* PARRY_CHECK */
/* Called in fight.c only */
inline int PARRY_CHECK( CHAR_DATA *ch, OBJ_DATA* obj, OBJ_DATA* vobj, int dt)
{

  int fSuccess  = TRUE;
  CHAR_DATA* vch = ch;
  AFFECT_DATA* paf;
  AFFECT_DATA* paf_next;

  int result = 0;


//OBJECT ORIENTATED EFFECS>
  if (obj == NULL || vobj == NULL) {
    return fSuccess;
  }

  for (paf = obj->affected; paf != NULL; paf = paf_next) {
      paf_next = paf->next;
      //we only run the update once per effect.
      if (paf_next != NULL) {
	if (paf->type == paf_next->type) {
	  continue;
	}
      }
      
      //GENS THAT ARE HANDLED SEPERATLY

      
      if (IS_GEN(paf->type)) {
	if ((result = run_effect_update(vch, obj, vobj, paf->type, 
					&dt, NULL, TRUE, EFF_UPDATE_PARRY)) != TRUE) {
	  if (result == -1) {
	    return -1;
	  }
	  else {
	    fSuccess = result;
	  }
	}
      }
    }
  
  return fSuccess;
}// end PARRY_CHECK


/* SHBLOCK_CHECK */
/* Called in fight.c only */
inline int SHBLOCK_CHECK( CHAR_DATA *ch, OBJ_DATA* obj, OBJ_DATA* vobj, int dt)
{
  int fSuccess  = TRUE;
  CHAR_DATA* vch = ch;
  AFFECT_DATA* paf;
  AFFECT_DATA* paf_next;

  int result = 0;


//OBJECT ORIENTATED EFFECS>
  if (obj == NULL || vobj == NULL) {
    return fSuccess;
  }

  for (paf = obj->affected; paf != NULL; paf = paf_next) {
      paf_next = paf->next;
      //we only run the update once per effect.
      if (paf_next != NULL) {
	if (paf->type == paf_next->type) {
	  continue;
	}
      }
      
      //GENS THAT ARE HANDLED SEPERATLY

      
      if (IS_GEN(paf->type)) {
	if ((result = run_effect_update(vch, obj, vobj, paf->type, &dt, 
					NULL, TRUE, EFF_UPDATE_SHBLOCK)) != TRUE) {
	  if (result == -1) {
	    return -1;
	  }
	  else {
	    fSuccess = result;
	  }
	}
      }
    }
  
  return fSuccess;

}// end SHBLOCK_CHECK



/* PREKILL_CHECK */
/* Called in fight.c only */
/* same args as raw_kill in which it will be called. */
int PREKILL_CHECK( CHAR_DATA *ch, CHAR_DATA *victim)
{
  CHAR_DATA* vch = ch;
  AFFECT_DATA* paf;
  AFFECT_DATA* paf_next;

  int fSuccess = TRUE;
  int result = 0;

  for (paf = vch->affected; paf != NULL; paf = paf_next) {
    paf_next = paf->next;
    //we only run the update once per effect.
    if (paf_next != NULL) {
      if (paf->type == paf_next->type) {
	continue;
      }
    }
    
    if (IS_GEN(paf->type)) {
      if ((result = run_effect_update(vch, victim, paf, paf->type, 
				      NULL, NULL, TRUE, EFF_UPDATE_PREKILL)) != TRUE) {
	if (result == -1) {
	  return -1;
	}
	else {
	  fSuccess = result;
	}
      }
    }
  }

  return fSuccess;

}//end PREKILL_CHECK

/* PREDEATH_CHECK */
/* Called in fight.c only */
/* same args as raw_kill in which it will be called. */
int PREDEATH_CHECK( CHAR_DATA *ch, CHAR_DATA *victim)
{
  CHAR_DATA* vch = ch;
  AFFECT_DATA* paf;
  AFFECT_DATA* paf_next;

  int fSuccess = TRUE;
  int result = 0;

  //MALFORM WEAPON
  run_effect_update(victim, vch, NULL, gen_malform, NULL, NULL, TRUE, EFF_UPDATE_PREDEATH);

  for (paf = vch->affected; paf != NULL; paf = paf_next) {
    paf_next = paf->next;
    //we only run the update once per effect.
    if (paf_next != NULL) {
      if (paf->type == paf_next->type) {
	continue;
      }
    }
    
    if (IS_GEN(paf->type)) {
      if ((result = run_effect_update(vch, victim, paf, paf->type, 
				      NULL, NULL, TRUE, EFF_UPDATE_PREDEATH)) != TRUE) {
	if (result == -1) {
	  return -1;
	}
	else {
	  fSuccess = result;
	}
      }
    }
  }

  return fSuccess;

}//end PREDEAH_CHECK


/* POSTKILL_CHECK */
/* Called in fight.c only */
/* same args as raw_kill in which it will be called. */
int POSTKILL_CHECK( CHAR_DATA *ch, CHAR_DATA *victim)
{
  CHAR_DATA* vch = ch;
  AFFECT_DATA* paf;
  AFFECT_DATA* paf_next;

  int fSuccess = TRUE;
  int result = 0;

  //MALFORM WEAPON//
  run_effect_update(vch, victim, NULL, gen_malform, NULL, NULL, TRUE, EFF_UPDATE_POSTKILL);

  //COUP
  run_effect_update(vch, victim, NULL, gen_coup, NULL, NULL, TRUE, EFF_UPDATE_POSTKILL);

  for (paf = vch->affected; paf != NULL; paf = paf_next) {
    paf_next = paf->next;
    //we only run the update once per effect.
    if (paf_next != NULL) {
      if (paf->type == paf_next->type) {
	continue;
      }
    }
    
//SPECIAL GENS HERE
    if (paf->type == gen_malform
	|| paf->type == gen_coup) {
      continue;
    }
    if (IS_GEN(paf->type)) {
      if ((result = run_effect_update(vch, victim, paf, paf->type, 
				      NULL, NULL, TRUE, EFF_UPDATE_POSTKILL)) != TRUE) {
	if (result == -1) {
	  return -1;
	}
	else {
	  fSuccess = result;
	}
      }
    }
  }

  return fSuccess;
}//end POSTKILL_CHECK



/* POSTDEATH_CHECK */
/* Called in fight.c only */
/* same args as raw_kill in which it will be called. */
/* FIRST argument is the attacker, SECOND the person that died */
int POSTDEATH_CHECK( CHAR_DATA *ch, CHAR_DATA *victim)
{
  CHAR_DATA* vch = victim;
  AFFECT_DATA* paf;
  AFFECT_DATA* paf_next;

  int fSuccess = TRUE;
  int result = 0;

  //COUP
  run_effect_update(victim, ch, NULL, gen_coup, NULL, NULL, TRUE, EFF_UPDATE_POSTDEATH);


  for (paf = vch->affected; paf != NULL; paf = paf_next) {
    paf_next = paf->next;
    //we only run the update once per effect.
    if (paf_next != NULL) {
      if (paf->type == paf_next->type) {
	continue;
      }
    }
//SPECIAL GENS HERE
    if (paf->type == gen_coup) {
      continue;
    }
    
    if (IS_GEN(paf->type)) {
      if ((result = run_effect_update(victim, vch, paf, paf->type, 
				      NULL, NULL, TRUE, EFF_UPDATE_POSTDEATH)) != TRUE) {
	if (result == -1) {
	  return -1;
	}
	else {
	  fSuccess = result;
	}
      }
    }
  }
  
  return fSuccess;
}//end POSTDEATH_CHECK




/* PRECOMBAT_CHECK */
/* Called in fight.c only */
/* same args as multi_hit in which it will be called. */
int PRECOMBAT_CHECK( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
//This is the function that perfomrs checking for any 
//PRE_COMBAT effects.
  CHAR_DATA* vch = ch;
  AFFECT_DATA* paf;
  AFFECT_DATA* paf_next;

  int fSuccess = TRUE;
  int result = 0;

/* victim check
  for (paf = victim->affected; paf != NULL; paf = paf_next) {
    paf_next = paf->next;
    //we only run the update once per effect.
    if (paf_next != NULL) {
      if (paf->type == paf_next->type) {
	continue;
      }
    }
    if (IS_GEN(paf->type)) {
      if ((result = run_effect_update(vch, paf, victim, paf->type, 
				      &dt, NULL, TRUE, EFF_UPDATE_PRECOMBAT)) != TRUE) {
	if (result == -1) {
	  return -1;
	}
	else {
	  fSuccess = result;
	}
      }
    }
  }
*/

  for (paf = vch->affected; paf != NULL; paf = paf_next) {
    paf_next = paf->next;
    //we only run the update once per effect.
    if (paf_next != NULL) {
      if (paf->type == paf_next->type) {
	continue;
      }
    }
//SPECIAL GENS HERE
    if (IS_GEN(paf->type)) {
      if ((result = run_effect_update(vch, paf, victim, paf->type, 
				      &dt, NULL, TRUE, EFF_UPDATE_PRECOMBAT)) != TRUE) {
	if (result == -1) {
	  return -1;
	}
	else {
	  fSuccess = result;
	}
      }
    }
  }

  return fSuccess;

}//end PRECOMBAT CHECK



/* POSTCOMBAT_CHECK */
/* Called in fight.c only */
/* same args as multi_hit in which it will be called. */

int POSTCOMBAT_CHECK( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
  CHAR_DATA* vch = ch;
  AFFECT_DATA* paf;
  AFFECT_DATA* paf_next;

  int result = 0;
  int fSuccess = TRUE;

//SPECIAL GENS
  //-----PANIC---//
  if (vch->class == class_lookup("berserker")) {
    fSuccess =  run_effect_update(vch, NULL, victim, gen_panic, NULL, 
				  NULL, TRUE, EFF_UPDATE_POSTCOMBAT);
  }

  //-----PLUMBUM---//
  if ( (paf = affect_find(ch->affected, gsn_plumbum)) != NULL) {
    run_effect_update(ch, victim, paf, gen_plumbum, NULL, NULL, dt, EFF_UPDATE_POSTCOMBAT);
  }

  for (paf = vch->affected; paf != NULL; paf = paf_next) {
      paf_next = paf->next;
      //we only run the update once per effect.
      if (paf_next != NULL) {
	if (paf->type == paf_next->type) {
	  continue;
	}
      }
      
      //GENS THAT ARE HANDLED SEPERATLY
      if (paf->type == gen_panic
	  || paf->type == gen_plumbum) {
	continue;
      }

      
      if (IS_GEN(paf->type)) {
	if ((result = run_effect_update(vch, victim, paf, paf->type, 
					NULL, NULL, dt, EFF_UPDATE_POSTCOMBAT)) != TRUE) {
	  if (result == -1) {
	    return -1;
	  }
	  else {
	    fSuccess = result;
	  }
	}
      }
    }
  
  return fSuccess;

}//end POSTCOMBAT CHECK

/* PREDAMAGE_CHECK */
/* Called in fight.c only */
/* same args as damage in which it will be called. */

int PREDAMAGE_CHECK(CHAR_DATA *ch,CHAR_DATA *victim,int* dam,int* dt,int* dam_type) 
{
//This is the function that perfomrs checking for any 
//PRE_DAMAGE effects.

  CHAR_DATA* vch = ch;

  AFFECT_DATA* paf;
  AFFECT_DATA* paf_next;

  int result = 0;
  int fSuccess = TRUE;

//SPECIAL GENS
//----POSITION----//
    if (victim->position == POS_MEDITATE) {
	act_new("You stop meditating and stand up.",victim,NULL,NULL,TO_CHAR,POS_DEAD);
	act("$n stops meditating and stands up.",victim,NULL,NULL,TO_ROOM);
//	victim->position = POS_STANDING;
    }
    for (paf = victim->affected; paf; paf = paf_next ){
      paf_next = paf->next;
//-----BLADES----- ON VICTIM (DEFLECT)
      if ( paf->type == gen_blades){
	run_effect_update(ch, victim, paf, paf->type, dam, dam_type, *dt, EFF_UPDATE_PREDAMAGE);
      }
//-----TERRASHIELD----- ON VICTIM (DEFLECT)
      else if ( paf->type == gen_terra_shield){
	run_effect_update(ch, victim, paf, paf->type, dam, dam_type, *dt, EFF_UPDATE_PREDAMAGE);
      }
//-----REFLECTIVE SHIELD----- ON VICTIM (REFLECT)
      else if ( paf->type == gen_ref_shield) {
	run_effect_update(ch, victim, paf, paf->type, dam, dam_type,*dt, EFF_UPDATE_PREDAMAGE);
      }
//-----CHRONO SHIELD----- ON VICTIM (ABSORB)
      else if ( paf->type == gen_chron) {
	run_effect_update(ch, victim, paf, paf->type, dam, dam_type,*dt, EFF_UPDATE_PREDAMAGE);
      }
//-----EFUZAN'S WARD----- ON VICTIM (REDUCTION)
      else if ( paf->type == gen_sav_ward) {
	run_effect_update(ch, victim, paf, paf->type, dam, dam_type, *dt, EFF_UPDATE_PREDAMAGE);
      }
//------PC CHARM ON VICTIM (WAKE UP)
      else if (paf->type == gen_pc_charm) {
	run_effect_update(victim, victim, paf, paf->type, dam, dt, TRUE, EFF_UPDATE_PREDAMAGE);
      }
//------REQUEST ON VICTIM (SHATTER)
      else if (paf->type == gen_request) {
	run_effect_update(victim, victim, paf, paf->type, dam,  dt, TRUE, EFF_UPDATE_PREDAMAGE);
      }
//------CONJURE ON VICTIM (SHATTER)
      else if ( paf->type == gen_conjure) {
	run_effect_update(victim, victim, paf, paf->type, dam,  dt, TRUE, EFF_UPDATE_PREDAMAGE);
      }
//------CHANT ON VICTIM (DRAIN)
      else if (paf->type == gen_chant) {
	run_effect_update(victim, victim, paf, paf->type, dam,  dt, TRUE, EFF_UPDATE_PREDAMAGE);
      }
    }
/* NORMAL PAFS */

  for (paf = vch->affected; paf != NULL; paf = paf_next) {
      paf_next = paf->next;
      //we only run the update once per effect.
      if (paf_next != NULL) {
	if (paf->type == paf_next->type) {
	  continue;
	}
      }
      
      //GENS THAT ARE HANDLED IN ABOVE
      if (paf->type == gen_blades
	  || paf->type == gen_terra_shield
	  || paf->type == gen_sav_ward
	  || paf->type == gen_ref_shield
	  || paf->type == gen_chron) {
	continue;
      }
      /* special check for apierce */
      if (paf->type == gen_apierce){
	  if ((result = run_effect_update(vch, victim, paf, paf->type, dam, 
					 dam_type, *dt, EFF_UPDATE_PREDAMAGE)) == TRUE){
	    *dt = gen_apierce;
	  }
      }
//------BATTER( NEEDS A DAMAGE CHANGE IF CON DAMAGE ACTIVE)
      else if ( paf->type == gen_batter){
	if (number_percent() < (get_skill(ch, gsn_con_damage) - 60) * 2){
	  *dam_type = DAM_BASH;
	  if (*dt >= TYPE_NOBLOCKHIT)
	    *dt = attack_lookup("slap") + TYPE_NOBLOCKHIT;
	  else if (*dt >= TYPE_HIT)
	    *dt = attack_lookup("slap") + TYPE_HIT;
	  check_improve(vch, gsn_con_damage, TRUE, 1);
	}
	run_effect_update(vch, victim, paf, paf->type, dam, dam_type, *dt, EFF_UPDATE_PREDAMAGE);
      }
      else if (IS_GEN(paf->type)) {
	if ((result = run_effect_update(vch, victim, paf, paf->type, dam, 
					dam_type, *dt, EFF_UPDATE_PREDAMAGE)) != TRUE) {
	  if (result == -1) {
	    return -1;
	  }
	  else {
	    fSuccess = result;
	  }
	}
      }
    }
  return fSuccess;
}//end PREDAMAGE CHECK


/* POSTDAMAGE_CHECK */
/* Called in fight.c only */
/* same args as damage in which it will be called. */

int POSTDAMAGE_CHECK(CHAR_DATA *ch, CHAR_DATA *victim, OBJ_DATA* obj, int dam,int dt,int dam_type) 
{
  //THIS IS SPLIT INTO TW PARTS:
  //OBJECT AND CHARATER

  CHAR_DATA* vch = ch;

  AFFECT_DATA* paf;
  AFFECT_DATA* paf_next;

  int result = 0;
  int fSuccess = TRUE;


//-----VENGEGEANCE----- ON VICTIM (REFLECT)
  if ( (paf = affect_find(victim->affected, gen_vengeance)) != NULL) {
    run_effect_update(vch, victim, paf, paf->type, &dam, &dam_type, dt, EFF_UPDATE_POSTDAMAGE);
  }
//-----TEMPORAL AVENGER----- ON VICTIM (COLLECT)
  if ( (paf = affect_find(victim->affected, gen_temp_avenger)) != NULL) {
    run_effect_update(vch, victim, paf, paf->type, &dam, &dam_type, dt, EFF_UPDATE_POSTDAMAGE);
  }



  //REST OF EFFECTCS  
  for (paf = vch->affected; paf != NULL; paf = paf_next) {
      paf_next = paf->next;
      //we only run the update once per effect.
      if (paf_next != NULL) {
	if (paf->type == paf_next->type) {
	  continue;
	}
      }
      
      //GENS THAT ARE HANDLED SEPERATLY
      if (paf->type == gen_vengeance)
	continue;
      
      if (IS_GEN(paf->type)) {
	if ((result = run_effect_update(vch, victim, paf, paf->type, &dam, 
					&dam_type, dt, EFF_UPDATE_POSTDAMAGE)) != TRUE) {
	  if (result == -1) {
	    return -1;
	  }
	  else {
	    fSuccess = result;
	  }
	}
      }
    }
  

//OBJECT ORIENTATED EFFECS>
  if (obj == NULL || victim == NULL)
    return fSuccess;

  for (paf = obj->affected; paf != NULL; paf = paf_next)
    {
      paf_next = paf->next;
      //we only run the update once per effect.
      if (paf_next != NULL) {
	if (paf->type == paf_next->type) {
	  continue;
	}
      }
      
      //GENS THAT ARE HANDLED SEPERATLY

      
      if (IS_GEN(paf->type)) {
	if ((result = run_effect_update(vch, victim, obj, paf->type, &dam, 
					&dam_type, dt, EFF_UPDATE_POSTDAMAGE)) != TRUE) {
	  if (result == -1) {
	    return -1;
	  }
	  else {
	    fSuccess = result;
	  }
	}
      }
    }
  
  return fSuccess;

  

/*
  //-----DARK METAMORPHOSIS---//
  if ( (paf = affect_find(obj->affected, gen_dark_meta)) != NULL) 
    fSuccess = run_effect_update(ch, victim, obj, gen_dark_meta, &dam, 
    &dam_type, TRUE, EFF_UPDATE_POSTDAMAGE);


  //-----Soul Reaver---//
  if ( (paf = affect_find(obj->affected, gen_soul_reaver)) != NULL)
    fSuccess = run_effect_update(ch, victim, obj, gen_soul_reaver, &dam, &dam_type, TRUE, EFF_UPDATE_POSTDAMAGE);

  //-----Hand of Chaos---//
  if ( (paf = affect_find(obj->affected, gen_handof_chaos)) != NULL)
    fSuccess = run_effect_update(ch, victim, obj, gen_handof_chaos, &dam, &dam_type, TRUE, EFF_UPDATE_POSTDAMAGE);
*/

  return fSuccess;
}//end POSTDAMAGE CHECK

//-----------------------------------END CHECKS----------------------------//



/* ogre damage ignore */
bool ogre_ignore(CHAR_DATA* ch, CHAR_DATA* victim, OBJ_DATA* obj, int dam, int dt, bool fVirt)
{
  int chance = 5 + (dam > 50? 5 : 0) 
    + (dam > 120 ? 80 : 0)
    + (dam > 350 ?  45 : 0);
  bool fOgre = victim->race == grn_ogre;
  bool fBlood = get_skill(victim, gsn_bloodhaze) > 1;

  //safety
  if (obj == NULL )
    fVirt = FALSE;

  if (ch == NULL || victim == NULL || ch == victim)
    return FALSE;

  if (!fOgre && !fBlood){
    return FALSE;
  }

  /* bonus from bloodhaze for ogres */
  if (fOgre && fBlood){
    chance += 15;
  }

  if (dam < 1 ) {
    return FALSE;
  }
  //roll for ignore
  if (number_range(1, 1000) < chance) {
      char buf[MIL];
      sprintf(buf, "You roar in pain and ignore %s %s.", 
	      fVirt? "$p's" : "$N's",
	      get_vir_attack(dt));
      act(buf, victim, obj, ch, TO_CHAR);
      sprintf(buf, "$n roars in pain and ignores %s %s.", 
	      fVirt? "$p's" : "$N's",
	      get_vir_attack(dt));
      act(buf, victim, obj, ch, TO_NOTVICT);
      sprintf(buf, "$n roars in pain and ignores %s %s.", 
	      fVirt? "$p's" : "your",
	      get_vir_attack(dt));
      act(buf, victim, obj, ch, TO_VICT);
      return TRUE;
    }
  return FALSE;
}

/* juggernaut plate damage ignore */
bool jugger_ignore(CHAR_DATA* ch, CHAR_DATA* victim, OBJ_DATA* obj, int dam, int dt, bool fVirt)
{
  int chance = 40 + (dam < 41 ? (41 - dam) * 4 : 0);

  //safety
  if (obj == NULL)
    fVirt = FALSE;
  if (ch == victim)
    return FALSE;
  if (is_armor_enhanced(victim) < ENHANCE_JUGGER){
    return FALSE;
  }
  if (dam < 1) {
    return FALSE;
  }
  //roll for ignore
  if (number_range(1, 1000) < chance) {
      char buf[MIL];
      sprintf(buf, "%s %s glances off of the Juggernaut Plate.", 
	      fVirt? "$p's" : "$N's",
	      get_vir_attack(dt));
      act(buf, victim, obj, ch, TO_ALL);
      return TRUE;
  }
  return FALSE;
}

/* check_anatomy */
/* returns TRUE if learned, -1 if mob level reached. */
inline int check_anatomy_improve(CHAR_DATA* ch, int anatomy, bool fMOB, int iMobLvl)
{
  /* 
     runs a check for improvement of monk anatomies. 
     Anatomies are learned from mobs bit slower then pc's but the 
     maximum level is npc_max of the mob level. 
  */

  const int npc_max = 200;//(lvl 50 mob can teach up to 100 anatom.)
  const int npc_pen = -10;//penatly to learnm from npc
  const int npc_extra = 4000;
  const int pc_extra = 1000;

  int chance = 50 + (anatomy? 0: npc_pen); //base level
  int max = get_max_anat(ch, anatomy);
  
  //Check for max anatomy
  if (ch->pcdata->anatomy[anatomy] >= max)
    {
      ch->pcdata->anatomy[anatomy] = max;
      return FALSE;
    }


//INT
  chance += int_app[get_curr_stat(ch,STAT_INT)].learn / 5;
//LEVEL
  chance += ch->level / 4;
//WIS
  chance += get_curr_stat(ch,STAT_WIS) / 2;
//CURRENT VALUE
  chance -= ch->pcdata->anatomy[anatomy] / 2;

//Check to learn  
  if (number_range(1,(fMOB? npc_extra: pc_extra)) < chance)
    {
      //MOB LEARN CHECK
      if (fMOB && (ch->pcdata->anatomy[anatomy] >= (npc_max * iMobLvl / 100 )))
	return -1;
      ch->pcdata->anatomy[anatomy]++;
      return TRUE;
    }
  return FALSE;
}

/* check_anatomy */
/* returns damage increase or 0 in percent */
inline int check_anatomy(CHAR_DATA* ch, CHAR_DATA* victim)
{
  int diceroll = 0;
  int result = 0;
  int anatomy = 0;
  bool fMOB = IS_NPC(victim);

  if ( IS_NPC(ch) || get_skill(ch,gsn_anatomy) < 1)
    return FALSE;
  
  diceroll = number_percent();
  diceroll -= 2*(get_curr_stat(ch,STAT_LUCK) - 16);
  
  if (diceroll <= get_skill(ch,gsn_anatomy))
    {
      if (race_table[victim->race].pc_race)
	anatomy = anatomy_lookup(pc_race_table[victim->race].anatomy);
      
      //check for improve of anatomies.
      check_improve(ch,gsn_anatomy,TRUE,1);

      result = check_anatomy_improve(ch, anatomy, fMOB, victim->level);

      if (result == -1)
	sendf(ch, "You sense there is little more you can learn about %s here.\n\r", anatomy_table[anatomy].name);
      else if (result)
	sendf(ch,"You have gained knowledge about %s!\n\r", anatomy_table[anatomy].name);

      
      result = number_range(ch->pcdata->anatomy[anatomy] / 3, get_skill(ch,gsn_anatomy) / 5 + ch->pcdata->anatomy[anatomy]);
      return (UMIN(result, 110));
      
    }//end success check
  return 0;
}




/*Unholy Gift*/
/*exists only in fight.c*/
bool unholy_gift(CHAR_DATA* ch, CHAR_DATA* victim)
{
  //This is the ability only given to  a single head vamp.
  //It allows for conversion of race to _undead_ when killed.
  int chance_mod = 30;
  int skill;

//EZ
  if ( (ch==NULL) || (victim == NULL) )
    return FALSE;

  
//This only works if the character is not undead. and is an PC
  if (IS_NPC(victim) || IS_UNDEAD(victim))
    return FALSE;
//Also only works if the charcter is not mob and vampire.
  if (IS_NPC(ch) || ch->class != class_lookup("vampire"))
    return FALSE;
  
//The attacker must have the skill
  if( (skill = get_skill(ch, gsn_unholy_gift)) == 0)
    return FALSE;

 
//If al those are ok, then we make a roll.
  if (number_percent() > chance_mod)
    return FALSE;

//Else we succeeded.  So we begin spitting out messages.
  act_new("The last thing you feel is $n's fangs in your neck.", ch, NULL, victim, TO_VICT, POS_DEAD);
  act("Aura of evil fills the room as $n buries $s fangs in $N's neck.", ch, NULL, victim, TO_NOTVICT);
  act("You bless $N with your dark gift and bury your fangs in $S throat.", ch, NULL, victim, TO_CHAR);

  
//Now we simply slay him.
  raw_kill(ch, victim);
  act_new( "You have been `1EMBRACED!!``", victim,NULL,NULL,TO_CHAR,POS_DEAD);
  /* cast unlife on him */
  spell_unholy_gift(gsn_unholy_gift, ch->level, ch, victim, 0);
  return TRUE;
}//end unholygift.


/*MULT_HIT_WOLF*/
/*exists only in fight.c*/
void multi_hit_wolf(CHAR_DATA* ch, CHAR_DATA* victim)
{
//Modifiers:
  const int haste_mod = 25;
  const int slow_mod = 20;
  const int poison_mod = 20;
  const int bite_mod = 30;

//variables.
  int i =0;
  bool haste = FALSE;
  bool slow = FALSE;

//holders for attack skills.
  int skill_2 = 0;
  int skill_3 = 0;
  int skill_4 = 0;

//Poison Afffect.
  AFFECT_DATA af;

//EZ cases.
  if ((ch == NULL) || (victim == NULL) )
    return;
  if(!is_affected(ch, gsn_wolf_form))
    return;


//First few checks for haste/slow:
  if (IS_AFFECTED(ch, AFF_HASTE))
    haste = TRUE;
//day is equivalent to being slow.
  if (IS_AFFECTED(ch, AFF_SLOW) 
      || vamp_day_check(ch) )
    slow = TRUE;
  if(haste && slow)
    haste = slow = FALSE;

//and skills.
  skill_2 = (get_skill(ch, gsn_second_attack)*3)/4;
  skill_4 = (get_skill(ch, gsn_third_attack)*3)/4;
  skill_3 = (skill_2 + skill_4)/2;


//now we slap on modifiers
  if (haste){skill_2 = 100;skill_3+=haste_mod;skill_4+=haste_mod;}
  if (slow){skill_2-=slow_mod;skill_3-=slow_mod;skill_4=0;}

//Executes the whole round of attaks for wolf_form.                          
//chance of attacks is based on 1/2/3 attack skill.
//the whole thing is run twice.
  for(i = 0; i < 2; i++)
    {
//First attack always succeeds.
      one_hit(ch, victim, attack_lookup("claw") + TYPE_HIT, FALSE);
      if ( ch->fighting != victim )
	return;
//second attack 
      if (number_percent() < skill_2){
	one_hit( ch, victim, attack_lookup("charge") + TYPE_HIT, FALSE );
	if ( ch->fighting != victim )
	  return;
      }

//third
      if (number_percent() < skill_3){
//we do a roll here for poison bite
	if (number_percent() < bite_mod)
	  {
//we roll if we actuly bite him.
	    if( (number_percent() < poison_mod) && (!is_affected(victim, gsn_poison)) )
	      {
		AFFECT_DATA* baf;
//we apply poison
		act("$n's jaws dig deep into your flesh, the bite setting your blood afire with pain.",ch,NULL,victim,TO_VICT);
		act("$n's jaws dig deep into $N's flesh and $E screams in pain.",ch,NULL,victim,TO_NOTVICT);
		act("You tear a big chunk of $N's flesh out with your slavering teeth.",ch,NULL,victim,TO_CHAR);

		//we cast a little spell.
		af.where     = TO_AFFECTS;
		af.type      = gsn_poison;
		af.level     = ch->level;
		af.duration  = ch->level/5;
		af.location  = APPLY_STR;
		af.modifier  = -2;
		af.bitvector = AFF_POISON;
		baf = affect_to_char( victim, &af );
		if (!IS_NPC(ch))
		  string_to_affect(baf, ch->name);
		act_new( "You feel very sick.", victim,NULL,NULL,TO_CHAR,POS_DEAD );
		act("$n looks very ill.",victim,NULL,NULL,TO_ROOM);
	      }//end if poison
	    else
	      {
//we didnt poison him.
		//we didnt poison him.
		act("$n's jaws dig deep into your flesh, the bite flashing with seering pain.",ch,NULL,victim,TO_VICT);
		act("$n's jaws dig deep into $N's flesh and $E winces in pain.",ch,NULL,victim,TO_NOTVICT);
		act("You tear a big chunk of $N's flesh out with your slavering teeth.",ch,NULL,victim,TO_CHAR);
	      }//end else
	  }//end poiso roll
//end we make the attack.
	one_hit(ch, victim, attack_lookup("bite")+ TYPE_HIT, FALSE);
	if ( ch->fighting != victim )
	  return;
      }//end if third.
      
//fourth (only if not slow ie: not slow, in home terrain and at night.)
      if (number_percent() < skill_4 && !slow){
	one_hit(ch, victim, attack_lookup("slash")  + TYPE_HIT, FALSE);
	if ( ch->fighting != victim )
	  return;
      }

//end of run we do it again.
    }//end for
}//end multi_hit_wolf;

/*exists only in fight.c*/
void multi_hit_werebeast(CHAR_DATA* ch, CHAR_DATA* victim){
  AFFECT_DATA* paf;

//Modifiers:
  const int haste_mod = 25;
  const int slow_mod = 25;

//variables.
  int i = 0, max = 2;
  bool haste = FALSE;
  bool slow = FALSE;

//holders for attack skills.
  int skill_2 = 0;
  int skill_3 = 0;

//EZ cases.
  if ((ch == NULL) || (victim == NULL) )
    return;

//First few checks for haste/slow:
  if (IS_AFFECTED(ch, AFF_HASTE))
    haste = TRUE;
  if (IS_AFFECTED(ch, AFF_SLOW) )
    slow = TRUE;
  if(haste && slow)
    haste = slow = FALSE;

//and skills.
  skill_2 = 2 * get_skill(ch, gsn_second_attack) / 3;
  skill_3 = get_skill(ch, gsn_third_attack) / 2;



//now we slap on modifiers
  if (haste){skill_2 = 100; skill_3 += haste_mod;}
  if (slow){skill_2 -= slow_mod; skill_3 -= 0;}

//Executes the whole round of attaks for wereform
//chance of attacks is based on 1/2/3 attack skill.
//the whole thing is run twice.
  if ( (paf = affect_find(ch->affected, gsn_wlock)) != NULL && paf->modifier > 0)
    max = 1;
  else
    max = 2;

  for(i = 0; i < max; i++){
//First attack always succeeds.
    one_hit(ch, victim, ch->dam_type + TYPE_HIT, FALSE);
    if ( ch->fighting != victim )
      return;
//mob spec attacks
    if (IS_NPC(ch)){
      CHAR_DATA* vch, *vch_next;
      int number;
      if (IS_SET(ch->off_flags,OFF_AREA_ATTACK)){
	for (vch = ch->in_room->people; vch != NULL; vch = vch_next){
	  vch_next = vch->next_in_room;
	  if ((vch != victim && vch->fighting == ch))
	    one_hit(ch, vch, ch->dam_type + TYPE_HIT,FALSE);
	}
      }
      if (ch->wait > 0)
	return;
      number = number_range(0,8);
      switch(number) {
      case (0) :
        if (IS_SET(ch->off_flags,OFF_BASH))
	  do_bash(ch,""); break;
      case (1) :
        if (IS_SET(ch->off_flags,OFF_BERSERK) && !IS_AFFECTED(ch,AFF_BERSERK))
	  do_berserk(ch,""); break;
      case (2) :
        if (IS_SET(ch->off_flags,OFF_DISARM) || (get_weapon_sn(ch,FALSE) != gsn_hand_to_hand && IS_SET(ch->act,ACT_WARRIOR)))
	  do_disarm(ch,""); break;
      case (3) :
        if (IS_SET(ch->off_flags,OFF_KICK))
	  do_kick(ch,""); break;
      case (4) :
        if (IS_SET(ch->off_flags,OFF_KICK_DIRT))
	  do_dirt(ch,""); break;
      case (5) :
	break;
      case (6) :
	if (IS_SET(ch->off_flags,OFF_TRIP))
	  do_trip(ch,""); break;
      case (7) :
	if (IS_SET(ch->act,ACT_WARRIOR))
	  do_shield_disarm(ch,""); break;
      case (8) :
	break;
      }
    }
//second attack 
    if (number_percent() < skill_2){
      one_hit( ch, victim, ch->dam_type + TYPE_HIT, FALSE );
    }
    if ( ch->fighting != victim )
      return;
//third
    if (number_percent() < skill_3){
      one_hit(ch, victim, ch->dam_type + TYPE_HIT, FALSE);
    }//end if third.
    if ( ch->fighting != victim )
      return;      
  }
}


/* holy hands evade */
bool holy_hands_evade(CHAR_DATA* ch, CHAR_DATA* victim, int dt)
{
  //ability of the cleric to sptop a blow with his holy hands.
  int base_chance = 30 + (number_percent())/10;
  int lvl_mod = 1;

  base_chance+= (victim->level - ch->level) *lvl_mod;
     
//now we make a quick roll
     if (number_percent() < base_chance)
       {
  //we evaded!
	 act("$n stretches his hands, palms out and the blow stops short.", victim, NULL, NULL, TO_ROOM);
	 act("Your faith holding fast, you stop the blow with $g's power.", victim, NULL, NULL, TO_CHAR);
	 victim->mana = UMAX(0, victim->mana - 1);
	 return TRUE;
       }
     else
       return FALSE;
}

/*wolf evade*/
/*used only in fight.c*/
bool wolf_evade(CHAR_DATA* ch, CHAR_DATA* victim, int dt)
{
//This is much like spell_blur except more mundane and works
//in places that vamp wolf can sneak.
     int base_chance = 15 + (number_percent())/5;
     int haste_mod = 15;
     int dex_mod = 2;
     int lvl_mod = 1;
     
     bool haste = FALSE;
     bool slow = FALSE;
     
//EZ cases
     if( (ch == NULL || victim == NULL))
       return FALSE;
     if (ch == victim)
       return FALSE;
     if (!is_affected(victim, gsn_wolf_form))
       return FALSE;
     if (!vamp_can_sneak(victim, victim->in_room))
       return FALSE;
     
//now we add things up.

//First few checks for haste/slow:
     if (IS_AFFECTED(ch, AFF_HASTE))
       haste = TRUE;
//day is equivalent to being slow.
     if (IS_AFFECTED(ch, AFF_SLOW) || vamp_day_check(ch))
       slow = TRUE;
     if(haste && slow)
       haste = slow = FALSE;
     
     if (haste) base_chance+=haste_mod;
     if (slow)base_chance-=haste_mod;

     base_chance+= (get_curr_stat(victim, STAT_DEX) - get_curr_stat(ch, STAT_DEX)) * dex_mod;
     base_chance+= (victim->level - ch->level) *lvl_mod;
     
//now we make a quick roll
     if (number_percent() < base_chance)
       {
  //we evaded!
	 act("Blurring with speed, $N disappears in undergrowth and evades the blow.", ch, NULL, victim, TO_NOTVICT);
	 act("$N disappears in undergrowth momentarly and your blow lands short.", ch, NULL, victim, TO_CHAR);
	 act("Confident in your enviroment, you easly evade the blow.", ch, NULL, victim, TO_VICT);
	 return TRUE;
       }
 //we didn't.
     return FALSE;
}//end wolf_evade


/*check_dodge_wolf*/
/*linked only to fight.c*/
bool check_dodge_wolf( CHAR_DATA *ch, CHAR_DATA *victim, OBJ_DATA* vir_obj, int dt, int h_roll, int level, bool fVirt, int sn)
{
//this is the dodge for vamp wolves.
//they get huge bonus to dodge
//in order to boost the defenses to match that of a human form or more.

//EZ
  if (ch == NULL || victim == NULL)
    return FALSE;
  if (!is_affected(victim, gsn_wolf_form))
      return FALSE;

 //and this little eazy check.

  if (!check_dodge( ch, victim, vir_obj, dt, h_roll, level, fVirt, sn))
    {
      if (!check_dodge( ch, victim, vir_obj, dt, h_roll, level, fVirt, sn))
	return FALSE;
    }

    return TRUE;
}//end check_dodge_wolf


void seasons_dam(CHAR_DATA *ch, int season)
{
    CHAR_DATA *vch, *vch_next;
    int dam = ch->level + 25 + dice(5,9);
    for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
    {
        vch_next = vch->next_in_room;
        if ( !is_area_safe(ch,vch))
        {
            s_yell(ch,vch,FALSE);
            if (saves_spell(ch->level,vch,DAM_OTHER,song_table[gsn_seasons].spell_type))
		dam /= 2;
	    switch (season)
	    {
		case (0):
                    damage( ch,vch,dam,skill_lookup("deluge water"), DAM_DROWNING,TRUE);
		    break;
		case (1):
                    damage( ch,vch,dam,skill_lookup("fireball"), DAM_FIRE,TRUE);
		    break;
		case (2):
                    damage( ch,vch,dam,skill_lookup("call lightning"), DAM_LIGHTNING,TRUE);
		    break;
		case (3):
                    damage( ch,vch,dam,skill_lookup("iceball"), DAM_COLD,TRUE);
		    break;
	    }
        }
    }
}

/* Control the fights going on.           *
 * Called periodically by update_handler. */
void violence_update( void )
{
    CHAR_DATA *ch, *ch_next, *victim;
    AFFECT_DATA af, *paf;
    OBJ_DATA *wield, *second;
    char buf[MSL];
    OBJ_DATA *obj, *obj_next;
    bool room_trig = FALSE;

    for ( ch = char_list; ch != NULL; ch = ch_next )
    {
	ch_next	= ch->next;

	if (IS_STONED(ch))
	  continue;

	if ( !IS_NPC(ch) && ch->position > POS_SLEEPING )
	  {
	    int wie_p, wie_s;
            wield = get_eq_char(ch,WEAR_WIELD);
            second = get_eq_char(ch,WEAR_SECONDARY);
	    wie_p = get_obj_weight(wield);
	    wie_s = get_obj_weight(second);

	    if (ch->fighting && do_combatdraw(ch, wield, second)){
	      wield = get_eq_char(ch,WEAR_WIELD);
	      second = get_eq_char(ch,WEAR_SECONDARY);
	    }            
	    if (second != NULL && (get_eq_char(ch,WEAR_WIELD) == NULL))
            {
                unequip_char(ch, second);
                equip_char( ch, second, WEAR_WIELD);
                act( "$n switches $p to their good hand.",ch,second,NULL,TO_ROOM);
                act( "You switch your weapon to your good hand.",ch,second,NULL,TO_CHAR);
	    }
	    if (wield != NULL 
		&& second != NULL 
		&& (ch->race != grn_minotaur || wield->value[0] != WEAPON_AXE || second->value[0] != WEAPON_AXE) 
		&& !IS_AFFECTED2(ch,AFF_RAGE)
		&& wie_s > 3 * wie_p / 4 
		&& wie_s > 100
		&& get_skill(ch, gsn_bladework) < 2)
	    {
		unequip_char(ch,second);
		act("Your secondary weapon becomes too heavy for you to wield.",ch,second,NULL,TO_CHAR);
		act("$p becomes too heavy for $n to wield.",ch,second,NULL,TO_ROOM);
	    }
        }
	if (!IS_NPC(ch) && IS_AFFECTED2(ch,AFF_SHADOWFORM) && get_charmed_by(ch))
	{
	    send_to_char("Your followers have given you away.\n\r", ch);
            affect_strip ( ch, gsn_shadowform                       );
            REMOVE_BIT       ( ch->affected2_by, AFF_SHADOWFORM     );
            act_new("Your body regains its substance, and you materialize into existence.",ch,NULL,NULL,TO_CHAR,POS_DEAD);
            act("$n's body regains its substance, and $e materializes into existence.",ch,NULL,NULL,TO_ROOM);
	}
        if (!IS_NPC(ch) && IS_AFFECTED(ch,AFF_TREEFORM) && get_charmed_by(ch))
        {
            send_to_char("Your followers have given you away.\n\r", ch);
            affect_strip ( ch, gsn_treeform                       );
            REMOVE_BIT       ( ch->affected_by, AFF_TREEFORM     );
            act_new("Your body returns to its normal form.",ch,NULL,NULL,TO_CHAR,POS_DEAD);
            act("$n's body returns to its normal form.",ch,NULL,NULL,TO_ROOM);	
	}    
	if (IS_AFFECTED2(ch, AFF_CATALEPSY) && ch->position != POS_SLEEPING)
	    do_revive(ch, "");
        if (IS_AFFECTED2(ch, AFF_RAGE) && ch->fighting == NULL && IS_AWAKE(ch) && !IS_AFFECTED(ch,AFF_CALM))
        {
	    CHAR_DATA *vch, *vch_next;
            bool found = FALSE;
            bool fight = FALSE;
            int count  = 0;
            victim     = NULL;
            for ( vch = ch->in_room->people; vch != NULL; vch = vch_next )
            {
                vch_next = vch->next_in_room;
                if ( is_area_safe_quiet(ch,vch) || !can_see( ch, vch ) || ch == vch)
		    continue;
                if (!IS_NPC(vch))
                {
                    found = TRUE;
                    if ( number_range( 0, count ) == 0 )
                    {
                        victim = vch;
                        fight = TRUE;
                    }
                    count++;
                }
            }
            if (found && !fight) 
            {
                REMOVE_BIT(ch->affected2_by, AFF_RAGE);
                affect_strip(ch,gsn_rage);
                act("After finding no one to fight, you snap out of your madness.",ch,NULL,NULL,TO_CHAR);
                act("$n gasps for air as $e snaps out of $s insanity.",ch,NULL,NULL,TO_ROOM); 
                ch->hit -= (ch->level * ch->perm_stat[STAT_CON]) /3;
                if (IS_IMMORTAL(ch))
                    ch->hit = UMAX(1,ch->hit);
                if (ch->hit < -2)
                {
                    int shock_mod = (25 * (0 - ch->hit)) / ch->max_hit;
                    if (number_percent( ) < con_app[UMAX(1,ch->perm_stat[STAT_CON] - shock_mod)].shock)
                    {
                        act_new("Your body suddenly awakens to the wounds you've sustained and you lose consciousness.",ch,NULL,NULL,TO_CHAR,POS_DEAD);
                        act("$n suddenly clutches $s wounds and slumps to the ground, unconscious.",ch,NULL,NULL,TO_ROOM);
                        ch->hit = -2;
                        ch->position = POS_STUNNED;
                        act("$n is stunned, but will probably recover.",ch,NULL,NULL,TO_ROOM);
                        act_new("You are stunned, but will probably recover.",ch,NULL,NULL,TO_CHAR,POS_DEAD);
                    }
                    else
                    {
                        act_new("Your body could not sustain the injuries you've suffered.",ch,NULL,NULL,TO_CHAR,POS_DEAD);  
                        act("$n suddenly clutches $s wounds and slumps to the ground.",ch,NULL,NULL,TO_ROOM);
                        act( "$n is DEAD!!", ch, NULL, NULL, TO_ROOM );   
                        act_new( "You have been KILLED!!", ch,NULL,NULL,TO_CHAR,POS_DEAD);
			raw_kill( ch, ch );
                    }
                }
                continue;
            }
            if ( victim != NULL )
                do_murder( ch, victim->name );
        }
	if ( ch == NULL || ch->in_room == NULL )
	  continue;
	update_violence(ch);
	if ( ch == NULL || ch->in_room == NULL )
	  continue;

	if ( is_song_affected(ch,gsn_dance_song))
	{
       	    if (!IS_AWAKE(ch) && !IS_AFFECTED(ch,AFF_SLEEP))
            	do_wake(ch,"");
    	    do_visible(ch,NULL);
	    send_to_char("You can't stop dancing!\n\r",ch);
	    act("$n dances wildly in front of you!",ch,NULL,NULL,TO_ROOM);
	    ch->move--;
	}
	if ( is_song_affected(ch,gsn_seasons))
	{
	    AFFECT_DATA *paf = affect_find(ch->affected2,gsn_seasons);
	    if (paf != NULL)
	    {
		switch (paf->modifier)
		{
		    case (0):
			sprintf(buf,"Rains of spring in flooding tides.");
			song_to_room(ch,buf,FALSE,FALSE,FALSE);
			paf->modifier++;
			seasons_dam(ch,0);
			break;
		    case (1):
			sprintf(buf,"Summer's heat is scorching high.");
			song_to_room(ch,buf,FALSE,FALSE,FALSE);
			paf->modifier++;
			seasons_dam(ch,1);
			break;
		    case (2):
			sprintf(buf,"Autumn storms lights up the skies.");
			song_to_room(ch,buf,FALSE,FALSE,FALSE);
			paf->modifier++;
			seasons_dam(ch,2);
			break;
		    case (3):
			sprintf(buf,"Glaciers in winter made of ice.");
			song_to_room(ch,buf,FALSE,FALSE,FALSE);
			paf->modifier++;
			seasons_dam(ch,3);
			break;
		    default:
			song_affect_remove(ch,paf);
			break;
		}
	    }
	}
	victim = NULL;
	if ( ( victim = ch->fighting ) != NULL ){
	  if ( IS_AWAKE(ch) 
	       && ch->in_room == victim->in_room 
	       && !is_affected(ch,gsn_ecstacy))
	    {
	      multi_hit( ch, victim, TYPE_UNDEFINED );
// POSTCOMBAT CHECK //
	      if (  POSTCOMBAT_CHECK(ch, victim, TYPE_UNDEFINED ) == -1)
		bug("Error at: PostcombatCheck, returned fail\n\r", 0);
	    }
	  else
	    stop_fighting( ch, FALSE );
	  if (ch == NULL)
	    continue;
	  if ( ( victim = ch->fighting ) == NULL ){
	    continue;
	  }
	  /* OLD MPROG */
	  if (IS_NPC(ch) && ch->pIndexData->progtypes & FIGHT_PROG)
	    mprog_fight_trigger( ch, victim );
	  if (ch == NULL || !ch->fighting)
	    continue;
	  if (IS_NPC(ch) && ch->pIndexData->progtypes & HITPRCNT_PROG)
	    mprog_hitprcnt_trigger( ch, victim );
	  if (ch == NULL || !ch->fighting)
	    continue;
	  
	  /* NEW PROGS */
	  if (IS_NPC(ch)){
	    if (HAS_TRIGGER_MOB(ch, TRIG_FIGHT))
	      p_percent_trigger( ch, NULL, NULL, victim, NULL, NULL, TRIG_FIGHT);
	    if (ch == NULL || !ch->fighting)
	      continue;
	    if ( HAS_TRIGGER_MOB(ch, TRIG_HPCNT) )
	      p_hprct_trigger( ch, victim );
	  }
	  if (ch == NULL || !ch->fighting)
	    continue;
	  for ( obj = ch->carrying; obj; obj = obj_next )
	    {
	      obj_next = obj->next_content;
	      
	      if ( obj->wear_loc != WEAR_NONE && HAS_TRIGGER_OBJ( obj, TRIG_FIGHT ) )
		p_percent_trigger( NULL, obj, NULL, victim, NULL, ch, TRIG_FIGHT );
	      if (ch == NULL || !ch->fighting)
		continue;
	    }
	  if ( HAS_TRIGGER_ROOM( ch->in_room, TRIG_FIGHT ) && room_trig == FALSE )
	    {
	      room_trig = TRUE;
	      p_percent_trigger( NULL, NULL, ch->in_room, victim, NULL, NULL, TRIG_FIGHT );
	    }
/* amke sure we are fighting after trigger */
	  if (!ch->fighting)
	    continue;
	  
	  if ( is_affected(ch,gsn_refrain) && number_percent() > 50)
	    {
	      AFFECT_DATA *saf;
	      saf = affect_find(ch->affected,gsn_refrain);
	      if (refrain_sing(ch,saf->modifier))
		affect_strip(ch,gsn_refrain);
	    }
	  check_assist(ch,victim);
	  if ( IS_AFFECTED(ch,AFF_SLEEP) && ch->position > POS_SLEEPING )
            {
	      REMOVE_BIT(ch->affected_by, AFF_SLEEP);
	      affect_strip(ch,gsn_sleep);
	      affect_strip(ch,gsn_hypnosis);
	      affect_strip(ch,gsn_coffin);
	      if ( is_affected(ch, gsn_camp)){
		send_to_char( "You feel drained from deprivation of sleep.\n\r", ch);
		if (!is_affected(ch, gsn_drained)){
		  af.where		= TO_AFFECTS;
		  af.type             = gsn_drained;
		  af.level            = ch->level;
		  af.duration         = 10;
		  af.location         = APPLY_NONE;
		  af.modifier         = 0;
		  af.bitvector        = 0;
		  affect_to_char(ch,&af);	    
		  affect_strip(ch,gsn_camp);
		}
	      }
	      affect_strip(ch,gsn_entomb);
	      song_strip(ch,gsn_lullaby);
	    }
	  if ( IS_AFFECTED(victim,AFF_SLEEP) && victim->position > POS_SLEEPING )
            {
	      REMOVE_BIT(victim->affected_by, AFF_SLEEP);
	      affect_strip(victim,gsn_sleep);
	      affect_strip(victim,gsn_hypnosis);
	      affect_strip(victim,gsn_coffin);
	      affect_strip(victim,gsn_entomb);
	      song_strip(victim,gsn_lullaby);
	      if ( is_affected(victim, gsn_camp)){
		send_to_char( "You feel drained from deprivation of sleep.\n\r", ch);
		if (!is_affected(victim, gsn_drained)){
		  af.where		= TO_AFFECTS;
		  af.type             = gsn_drained;
		  af.level            = victim->level;
		  af.duration         = 10;
		  af.location         = APPLY_NONE;
		  af.modifier         = 0;
		  af.bitvector        = 0;
		  affect_to_char(victim,&af);	    
		  affect_strip(victim,gsn_camp);
		}
	      }
            }
	}
	if (ch == NULL)
	  continue;
/* after violence cleanup */
	if ( is_affected(ch,gsn_rake) )
	  {
	    send_to_char("You gain control of your weapon.\n\r",ch);
	    affect_strip(ch,gsn_rake);
	  }
	if (!IS_NPC(ch)){
	  affect_strip(ch,gsn_feign);
	}
	if (!IS_NPC(ch) 
	    && (paf = affect_find(ch->affected,gsn_cyclone)) != NULL
	    && --paf->duration < 1){
	  affect_strip(ch, gsn_cyclone);
	}
	if (!IS_NPC(ch) 
	    && (paf = affect_find(ch->affected,gsn_maelstrom)) != NULL
	    && --paf->duration < 1){
	  affect_strip(ch, gsn_maelstrom);
	}
	if (!IS_NPC(ch) 
	    && (paf = affect_find(ch->affected,gsn_onslaught)) != NULL
	    && --paf->duration < 1){
	  affect_strip(ch, gsn_onslaught);
	}
    }
}

void check_assist(CHAR_DATA *ch,CHAR_DATA *victim)
{
    CHAR_DATA *rch, *rch_next;
    char buf[MSL];
    if (ch->in_room == NULL)
	return;
    for (rch = ch->in_room->people; rch != NULL; rch = rch_next)
    {
	rch_next = rch->next_in_room;
	if (IS_AWAKE(rch) && rch->fighting == NULL && !is_affected(rch,gsn_ecstacy)){
	  /* quick check for ASSIST_PLAYER */
	  if (!IS_NPC(ch) && IS_NPC(rch) && IS_SET(rch->off_flags,ASSIST_PLAYERS)
	      && rch->level + 6 > victim->level && !IS_AFFECTED2(ch, AFF_HOLD) && can_see(rch,victim)){
	    act("$n screams and attacks!",rch,NULL,victim,TO_ALL);
	    multi_hit(rch,victim,TYPE_UNDEFINED);
	    continue;
	  }
	  /* PCs next */
	  else if (!IS_NPC(ch) 
	      || IS_AFFECTED(ch,AFF_CHARM) 
	      || IS_AFFECTED(rch,AFF_CHARM)){
	    if ( ((!IS_NPC(rch) && IS_SET(rch->act,PLR_AUTOASSIST))
		  || IS_AFFECTED(rch,AFF_CHARM))
		 && is_same_group(ch,rch) 
		 && !is_safe(rch, victim) )
	      {
		if ( IS_NPC(rch) 
		     && !IS_NPC(victim) 
		     && rch->master != NULL 
		     && rch->master != victim
		     && !IS_NPC(rch->master) 
		     && !is_pk(rch->master, victim) ) 
		  continue;
		/* JUSTICE GUARD CAPTAIN/HOUND ASSIST CHECK  */
		if (IS_NPC(rch) 
		    && rch->in_room
		    && (rch->pIndexData->vnum == MOB_VNUM_SPECIAL_GUARD
			|| rch->pIndexData->vnum == MOB_VNUM_HOUND)
		    && !IS_LEADER( ch )
		    && !IS_AREA(rch->in_room->area, AREA_LAWFUL)
		    && !IS_WANTED(victim))
		  continue;
		
		if (IS_NPC(rch) && IS_SET(rch->act, ACT_NONCOMBAT))
		  continue;

		/*Viri: sheath check for ps's didn't want this to be run
		  as often as the if's above 
		*/
		if (!IS_NPC(rch) && is_sheathed(rch))
		  continue;
		a_yell(rch,victim);
		if (!IS_NPC(rch))
		  {
		    sprintf(buf, "Help! I am being attacked by %s!",PERS(rch,victim));
		    j_yell(victim, buf );
		  }
		if (IS_NPC(rch) 
		    && (rch->pIndexData->vnum == MOB_VNUM_SPECIAL_GUARD
			|| rch->pIndexData->vnum == MOB_VNUM_HOUND)){
		  rch->fighting = victim;
		  spec_special_guard(rch);
		}
		else
		  multi_hit (rch,victim,TYPE_UNDEFINED);
	      }
	    continue;
	  }
	  /* now check the NPC cases */
	  if (IS_NPC(ch) && !IS_AFFECTED(ch,AFF_CHARM))
	    if ( ((IS_NPC(rch) && IS_SET(rch->off_flags,ASSIST_ALL)) 
		  || (IS_NPC(rch) && rch->group && rch->group == ch->group)
		  || (IS_NPC(rch) && rch->race == ch->race 
		      && IS_SET(rch->off_flags,ASSIST_RACE))
		  || (IS_NPC(rch) && IS_SET(rch->off_flags,ASSIST_ALIGN) 
		      && ((IS_GOOD(rch) && IS_GOOD(ch))
			  || (IS_EVIL(rch) && IS_EVIL(ch)) || (IS_NEUTRAL(rch) && IS_NEUTRAL(ch)))) 
		  || (is_same_group(ch,rch) && !is_safe(rch, victim) )
		  || (rch->pIndexData == ch->pIndexData && IS_SET(rch->off_flags,ASSIST_VNUM)))
		 && !(IS_AFFECTED(rch,AFF_CHARM) && rch->master != ch)
		 && !IS_SET(rch->act, ACT_IS_HEALER) )
	      {
		CHAR_DATA *vch, *target = NULL;
		int number = 0;
		if (number_bits(1) == 0)
		  continue;
		for (vch = ch->in_room->people; vch; vch = vch->next_in_room)
		  if (can_see(rch,vch) && is_same_group(vch,victim) && number_range(0,number) == 0)
		    {
		      target = vch;
		      number++;
		    }
		if (target != NULL && !IS_AFFECTED2(rch, AFF_HOLD) && can_see(rch,target))
		  {
		    act("$n screams and attacks!",rch,NULL,target,TO_ALL);
		    multi_hit(rch,target,TYPE_UNDEFINED);
		  }
	      }	
	}
    }
}

void multi_hit( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
    int chance, chance1 = 0, change = victim->hit;
    AFFECT_DATA *paf, *paf_next, *form;
    CHAR_DATA *vch, *vch_next;
    OBJ_DATA *hold, *obj;

    int melee_loc = number_range(1, 3);	//after which attack we do meleeactions
    int secart_loc = number_range(1, 3);//after which attack we do sec-arts
    int shadow_loc = number_range(1, 3);//after which attack we do sec-arts
//bool
    bool fHaste = (IS_AFFECTED(ch, AFF_HASTE) && !IS_AFFECTED(ch, AFF_SLOW));
    bool fSlow = (!IS_AFFECTED(ch, AFF_HASTE) && IS_AFFECTED(ch, AFF_SLOW));
    bool fPugil = FALSE;
    bool fFeign = !IS_NPC(ch) && is_affected(ch, gsn_feign);
    bool fWlock = !IS_NPC(ch) && ((paf = affect_find(ch->affected, gsn_wlock)) != NULL && paf->modifier > 0);
    bool fWerebeastMultiHit = FALSE;

    //check for blademaster bladestorm haste
    if (fHaste && ch->class == gcn_blademaster && is_affected(ch, gsn_bladestorm) && get_eq_char( ch, WEAR_SECONDARY) == NULL)
      fHaste = FALSE;

    if ( victim != ch && victim->in_room == ch->in_room)
      {
	if ( ch->position > POS_STUNNED )
	  {
	    if ( ch->fighting == NULL )
	      set_fighting( ch, victim);
	    if (ch->timer <= 4)
	      ch->position = POS_FIGHTING;
	  }
/*
	if ( victim->position > POS_STUNNED )
	  {
	    if ( victim->fighting == NULL )
	      set_fighting( victim, ch);
	    if (victim->timer <= 4)
	      victim->position = POS_FIGHTING;
	  }
*/
      }
    if (ch->desc == NULL)
	ch->wait = UMAX(0,ch->wait - PULSE_VIOLENCE);

// PRECOMBAT CHECK //
    if (  PRECOMBAT_CHECK(ch, victim, dt) == -1)
      bug("Error at: PrecombatCheck, returned fail\n\r", 0);
    

    if (ch->class == class_lookup("monk"))
        for ( paf = ch->affected; paf != NULL; paf = paf_next )
	{
	    paf_next = paf->next;
            if ( paf->type == gsn_throw )
		if (paf->duration-- == 0)
		{
		    act_new(skill_table[gsn_throw].msg_off,ch,NULL,NULL,TO_CHAR,POS_DEAD);
		    affect_remove( ch, paf);
		}
	}
    if ( is_affected(ch,gsn_mortally_wounded) )
	return;
    if ( is_affected(ch,gsn_ecstacy) )
	return;
    if (ch->position < POS_RESTING)
	return;
    /* Make sure they are fighting at this point */
    if (!ch->fighting)
      return;
    else if (ch->fighting != victim)
      return;
    if ( dt == gsn_backstab || dt == gsn_cleave
	 || dt == gsn_assassinate || dt == gsn_charge || dt == gsn_ambush)
      return;
    if (!IS_NPC(victim))
    	victim = check_guard(victim,ch);

    /* ranged weapons fire */
    fire_ranged_weapons( ch, victim );
    if (ch->fighting != victim )
      return;

    /* check for future use of pugil here */
    if ( (obj = get_eq_char(ch, WEAR_WIELD)) != NULL
	 && obj->item_type == ITEM_WEAPON
	 && obj->value[0] == WEAPON_STAFF
	 && get_eq_char(ch, WEAR_SECONDARY) == NULL
	 && get_eq_char(ch, WEAR_SHIELD) == NULL
	 && get_eq_char(ch, WEAR_HOLD) == NULL
	 && number_percent() < get_skill(ch, gsn_pugil)){
      check_improve(ch, gsn_pugil, TRUE, 1);
//      send_to_char("PUGIL\n\r", ch);
      fPugil = TRUE;
    }
    /* auto-deathblow check */
    if (is_affected(ch, gsn_cyclone) && is_affected(ch, gsn_maelstrom)){
      deathblow( ch, victim, DB_FULL, FALSE );
      affect_strip(ch, gsn_cyclone );
      affect_strip(ch, gsn_maelstrom );
    }
    if (ch->fighting == NULL)
      return;
    /* form execution */
    if ( (form = affect_find(ch->affected, gsn_forms)) != NULL
	 && form->modifier++ % 2 != 0
	 && form->has_string){
      forms(ch, form->string, form);
      if (ch->fighting != victim)
	return;
    }

    /* transorm check */
    if (ch != victim && ch->race == grn_werebeast && ch->level >= 15 && ch->hit < ch->max_hit / 2){
      int transchance = 20 - (20 * ch->hit / ch->max_hit);
      if (number_percent() < transchance){
	if (!is_affected(ch,gsn_transform))
	  beast_transform(ch);
      }
    }
    /* check if we are going to run werebeast multihit */
    for (paf = ch->affected; paf; paf = paf->next){
      if (paf->type == gsn_weretiger
	  || paf->type == gsn_werewolf
	  || paf->type == gsn_werebear
	  || paf->type == gsn_werefalcon){
	fWerebeastMultiHit = TRUE;
	break;
      }
    }
    
    if (ch->race == grn_werebeast && fWerebeastMultiHit){
      multi_hit_werebeast(ch, victim);
      multi_hit_extra( ch, victim, dt, change );
    }
    else if (ch->race == grn_vampire && is_affected(ch, gsn_wolf_form))
      multi_hit_wolf(ch, victim);
    else if (IS_NPC(ch)){
      mob_hit(ch,victim,dt);
      multi_hit_extra( ch, victim, dt, change );
      return;
    }
//otherwise we proced with all this junk that will need to be cleaned up.
    else
      {
	if (ch->fighting != NULL && ch->fighting->fighting != NULL && ch->fighting->fighting == ch
	    && ch->class == class_lookup("monk") && ch->hit > 0 && ch->hit < ch->max_hit / 10
	    && (hold = get_eq_char(ch, WEAR_HOLD)) != NULL && hold->pIndexData->vnum == OBJ_VNUM_PRAYER_BEADS)
	  {
	    int anatomy = 0;
	    if (!IS_NPC(victim))
	      anatomy = anatomy_lookup(pc_race_table[victim->race].anatomy);
	    chance = 25 + ch->pcdata->anatomy[anatomy] / 10;
	    chance += get_skill(ch,gsn_anatomy) / 20;
	    chance += (get_curr_stat(ch,STAT_DEX) - get_curr_stat(victim,STAT_DEX))/2;
	    chance += get_curr_stat(ch,STAT_LUCK) - get_curr_stat(ch,STAT_LUCK);
	    if (IS_NPC(victim) && IS_SET(victim->act,ACT_TOO_BIG) )
	      chance = 0;
	    if ( number_percent( ) < chance && !IS_IMMORTAL(victim) && !IS_SET(victim->act, ACT_UNDEAD))
	      {
		AFFECT_DATA af;
		af.type             = gsn_strangle;
		af.level            = ch->level;
		af.duration         = number_range(1, 2);
		af.location         = APPLY_NONE;
		af.where            = TO_AFFECTS;
		af.modifier         = 0;
		af.bitvector        = AFF_SLEEP;
		affect_to_char(victim,&af);
		act("$n places $s prayer beads around your neck and tightens.",ch,NULL,victim,TO_VICT);
		act("You place your prayer beads around $N's neck and tighten.",ch,NULL,victim,TO_CHAR);
		act("$n places $s prayer beads around $N's neck and tightens.",ch,NULL,victim,TO_NOTVICT);
		stop_fighting( ch, FALSE );
		stop_fighting( victim, FALSE );
		do_sleep(victim,"");
		if ( number_percent( ) > chance )
		  {
		    act("The string breaks and the prayer beads fall apart.",ch,NULL,NULL,TO_ALL);
		    obj_from_char( hold );
		    extract_obj( hold );
		  }
		return;
	      }
	  }
     	     
	if (ch->class == class_lookup("monk") && get_eq_char( ch, WEAR_WIELD ) == NULL )
	  {
/* monk first attack */
	    if (!fFeign)
	      one_hit( ch, victim, number_range(1053,1055), FALSE );
	    if ( ch->fighting != victim )
	      return;
	    if (melee_loc == 1 && check_melee_actions(ch))
	      return;
	    if (secart_loc == 1 && check_secart_actions(ch))
	      return;
	    if (shadow_loc == 1 && shadow_strike(ch, victim)){
	      if (ch->fighting != victim)
		return;
	    }

	    if (is_affected(ch,gsn_monkey) && monk_good(ch, WEAR_ABOUT) && monk_good(ch, WEAR_WAIST) )
	      {
		chance = 100;
		if (!IS_AFFECTED(ch,AFF_HASTE) && IS_AFFECTED(ch,AFF_SLOW))
		  chance = 50;
		if (number_percent( ) < chance){
		  one_hit( ch, victim, number_range(1053,1055), FALSE );
		  check_improve(ch, gsn_monkey, TRUE, 1);
		  if ( ch->fighting != victim )
		    return;
		}
	      }
	  }
	else
	  {
	    /* first attack */
	    if (ch->class == gcn_blademaster && getBmWearLoc(ch, TRUE) == WEAR_SECONDARY)	    
	      one_hit( ch, victim, dt, TRUE );
	    else
	      one_hit( ch, victim, dt, FALSE );

	    if ( ch->fighting != victim )
	      return;
	    if (melee_loc == 1 && check_melee_actions(ch))
	      return;
	    if (secart_loc == 1 && check_secart_actions(ch))
	      return;
	    if (shadow_loc == 1 && shadow_strike(ch, victim)){
	      if (ch->fighting != victim)
		return;
	    }
	    //Additional attack due to haste
	    if (fHaste && ch->fighting){
	      if (ch->class == gcn_blademaster && getBmWearLoc(ch, TRUE) == WEAR_SECONDARY)	    
		one_hit( ch, victim, dt, TRUE );
	      else
		one_hit( ch, victim, dt, FALSE );
	      if ( ch->fighting != victim )
		return;
	    }
	    /* first dual attack */
	    chance = get_skill(ch, gsn_dual_wield);
	    if (!fFeign 
		&& !fWlock
		&& (fPugil || get_eq_char(ch,WEAR_SECONDARY))
		&& number_percent( ) < chance){
	      one_hit( ch,victim,dt,TRUE);
	      check_improve(ch,gsn_dual_wield,TRUE,1);
	      if (ch->fighting != victim)
		return;
	    }
	  }
	if (IS_AFFECTED2(ch, AFF_RAGE)){
	  for (vch = ch->in_room->people; vch != NULL; vch = vch_next){
	    vch_next = vch->next_in_room;
	    if ((vch != victim && vch->fighting == ch)){
	      if (IS_NPC(ch))
		one_hit(ch,vch,dt,FALSE);
	      if (!IS_NPC(ch) && number_percent( ) < 2 * get_skill(ch, gsn_swing) /3){
		one_hit(ch,vch,dt,FALSE);
		check_improve(ch,gsn_swing, TRUE, 1);
		if (!IS_NPC(ch) && number_percent( ) < get_skill(ch, gsn_swing)/2
		    && (fPugil || get_eq_char(ch, WEAR_SECONDARY)) && number_percent( ) < get_skill(ch, gsn_dual_wield)){
		  check_improve(ch, gsn_swing, TRUE, 1);
		  one_hit(ch,vch,dt,TRUE);
		}
	      }
	    }
	  }
	}
	else if ( ((chance = get_skill(ch, gsn_cusinart)) 
		   || is_affected(ch, gsn_windmill))
		  && has_twohanded(ch) != NULL){
	  /* you hit a mate if they are near by */
	  if ( chance < 2 && (vch = get_group_room(ch, FALSE)) != NULL ){
	    if (ch->fighting == NULL ||  ch->fighting != vch 
		|| vch->fighting == NULL ||  vch->fighting != ch ){
	      char buf[MIL];
	      sprintf(buf, "Die %s you inconsiderate fool!", PERS2(ch));
	      a_yell(ch, vch);
	      j_yell(vch, buf);
	    }
	    one_hit(ch,vch,dt,FALSE);
	  }
	  for (vch = ch->in_room->people; vch != NULL; vch = vch_next){
	    vch_next = vch->next_in_room;
	    if ((vch == victim || vch->fighting != ch))
	      continue;
	    if (IS_NPC(ch))
	      one_hit(ch,vch,dt,FALSE);
	    if (!IS_NPC(ch) && number_percent( ) < 2 * get_skill(ch, gsn_swing) /3){
	      one_hit(ch,vch,dt,FALSE);
	      check_improve(ch,gsn_windmill, TRUE, 1);
	      check_improve(ch,gsn_swing, TRUE, 1);
	    }
	  }
	  if (chance > 1){
	    for (vch = ch->in_room->people; vch != NULL; vch = vch_next){
	      vch_next = vch->next_in_room;
	      if ((vch == victim || vch->fighting != ch))
		continue;
	      if (IS_NPC(ch))
		one_hit(ch,vch,dt,FALSE);
	      if (!IS_NPC(ch) && number_percent( ) < 2 * chance / 3){
		one_hit(ch,vch,dt,FALSE);
		check_improve(ch,gsn_swing, TRUE, 1);
		check_improve(ch,gsn_cusinart, TRUE, 1);
	      }
	    }
	  }
	}
//BEGIN MONK MULTI HIT
	if (ch->class == class_lookup("monk"))
	  {
	    //check for items wornd
	    int items = 0;
	    OBJ_DATA *hold;
	    if (get_eq_char( ch, WEAR_WIELD ) != NULL )
	      items = 3;
	    if (get_eq_char( ch, WEAR_SHIELD ) != NULL )
	      items++;
	    hold = get_eq_char( ch, WEAR_HOLD);
	    if ( hold != NULL && hold->pIndexData->vnum != OBJ_VNUM_PRAYER_BEADS)
	      items++; 

	    //Second attack
	    chance = get_skill(ch, gsn_martial_arts_b);
	    if (!fWlock && items < 3 && number_percent( ) < chance && monk_good(ch, WEAR_ARMS))
	      {
		one_hit( ch, victim, number_range(1053,1055), FALSE );
		check_improve(ch,gsn_martial_arts_b,TRUE,1);
		if ( ch->fighting != victim )
		  return;
	      }
	    if (melee_loc == 2 && check_melee_actions(ch))
	      return;
	    if (secart_loc == 2 && check_secart_actions(ch))
	      return;
	    if (shadow_loc == 2 && shadow_strike(ch, victim)){
	      if (ch->fighting != victim)
		return;
	    }
	    //third attack
	    chance = get_skill(ch, gsn_kickboxing_b);
	    if (items < 2 && number_percent( ) < chance && monk_good(ch, WEAR_LEGS))
	      {
		one_hit( ch, victim, number_range(1059,1061), FALSE );
		check_improve(ch,gsn_kickboxing_b,TRUE,1);
		if ( ch->fighting != victim )
		  return;

		//zaf 11-14-99 (extra atack hasted.)
		if (IS_AFFECTED(ch,AFF_HASTE) && !IS_AFFECTED(ch,AFF_SLOW)) 
		  {
		    one_hit( ch, victim, number_range(1059,1061), FALSE );
		    check_improve(ch,gsn_kickboxing_b,TRUE,0);
		    if ( ch->fighting != victim )
		      return;
		  }

	      }
	    if (melee_loc == 3 && check_melee_actions(ch))
	      return;
	    if (secart_loc == 3 && check_secart_actions(ch))
	      return;
	    if (shadow_loc == 3 && shadow_strike(ch, victim)){
	      if (ch->fighting != victim)
		return;
	    }
//ADVANCED ATTACKS
	    //FIRST
	    chance = get_skill(ch, gsn_martial_arts_a)/2;
	    if (!fWlock && items < 2 && is_empowered_quiet(ch,3) && number_percent( ) < chance && monk_good(ch, WEAR_HANDS))
	      {
		one_hit( ch, victim, number_range(1056,1058), FALSE );
		check_improve(ch,gsn_martial_arts_a,TRUE,0);
		if ( ch->fighting != victim )
		  return;
	    
		//zaf 11-14-99 (extra attack)
		if (IS_AFFECTED(ch,AFF_HASTE) && !IS_AFFECTED(ch,AFF_SLOW)) 
		  {
		    one_hit( ch, victim, number_range(1056,1058), FALSE );
		    check_improve(ch,gsn_martial_arts_a,TRUE,0);
		    if ( ch->fighting != victim )
		      return;
		  }
	      }
	    //SECOND
	    chance = get_skill(ch, gsn_kickboxing_a)/2;
	    if (items < 1 && is_empowered_quiet(ch,0) && number_percent( ) < chance && monk_good(ch, WEAR_FEET))
	      {
		one_hit( ch, victim, number_range(1062,1064), FALSE );
		check_improve(ch,gsn_kickboxing_a,TRUE,0);
		if ( ch->fighting != victim )
		  return;
	      }
	  
	    multi_hit_extra( ch, victim, dt, change );
	    if ( ch->fighting != victim )
	      return;
//MONKEY STANCE ATTACKS
	    if (!is_affected(ch,gsn_monkey) || !monk_good(ch, WEAR_ABOUT) || !monk_good(ch, WEAR_WAIST))
	      return;
	    check_improve(ch, gsn_monkey, TRUE, 1);
	    //FIRST
	    chance = get_skill(ch, gsn_martial_arts_b);
	    if (!IS_AFFECTED(ch,AFF_HASTE) && IS_AFFECTED(ch,AFF_SLOW))
	      chance /= 2;
	    if (items < 3 && number_percent( ) < chance && monk_good(ch, WEAR_ARMS))
	      {
		one_hit( ch, victim, number_range(1053,1055), FALSE );
		check_improve(ch,gsn_martial_arts_b,TRUE,0);
		if ( ch->fighting != victim )
		  return;
	      }

	    //SECOND
	    chance = get_skill(ch, gsn_kickboxing_b);
	    if (!IS_AFFECTED(ch,AFF_HASTE) && IS_AFFECTED(ch,AFF_SLOW))
	      chance /= 2;
	    if (items < 3 && number_percent( ) < chance && monk_good(ch, WEAR_LEGS))
	      {
		one_hit( ch, victim, number_range(1059,1061), FALSE );
		check_improve(ch,gsn_kickboxing_b,TRUE,0);
		if ( ch->fighting != victim )
		  return;
	      }

	    //THIRD
	    chance = get_skill(ch, gsn_martial_arts_a)/2;
	    if (!IS_AFFECTED(ch,AFF_HASTE) && IS_AFFECTED(ch,AFF_SLOW))
	      chance /= 2;
	    if (items < 1 && number_percent( ) < chance && monk_good(ch, WEAR_HANDS))
	      {
		one_hit( ch, victim, number_range(1056,1058), FALSE );
		check_improve(ch,gsn_martial_arts_a,TRUE,0);
		if ( ch->fighting != victim )
		  return;
	      }

	    //FOURTH
	    chance = get_skill(ch, gsn_kickboxing_a)/2;
	    if (!IS_AFFECTED(ch,AFF_HASTE) && IS_AFFECTED(ch,AFF_SLOW))
	      chance /= 2;
	    if (items < 2 && number_percent( ) < chance && monk_good(ch, WEAR_FEET))
	      {
		one_hit( ch, victim, number_range(1062,1064), FALSE );
		check_improve(ch,gsn_kickboxing_a,TRUE,0);
		if ( ch->fighting != victim )
		  return;
	      }
    ////////////////
    //RETURNS HERE//
    ////////////////
	    return;
	  }//END MONK ATTACKS
//NORMAL ATTACKS
/* Second Attack */
	if (fSlow)
	  chance = 0;
	//this stance requires 2 weapons, but the attack is lost even without 2 weapons
	else if (ch->class == gcn_blademaster && is_affected(ch, gsn_iron_curtain))
	  chance = 0;
	else if (fHaste){
	  if (ch->class == gcn_blademaster && monk_good(ch, WEAR_FEET))
	    chance = 100;
	  else 
	    chance = get_skill(ch, gsn_second_attack);
	}
	else{
	  if (ch->class == gcn_blademaster && monk_good(ch, WEAR_FEET))
	    chance = get_skill(ch, gsn_footwork);
	  else
	    chance = get_skill(ch, gsn_second_attack)/2;
	}
	//fury for ferals
	if (ch->race == grn_feral)
	  chance += ch->level;
	if ( has_twohanded(ch) != NULL
	     && number_percent() < get_skill( ch, gsn_adv_handling) ){
	  check_improve(ch, gsn_adv_handling, TRUE, 0);
	  chance += 15;
	}
	 
	/* Second Primary Attack */
	if (number_percent( ) < chance )
	  {
	    if (ch->class == gcn_blademaster && getBmWearLoc(ch, FALSE) == WEAR_SECONDARY)
	      one_hit( ch, victim, dt, TRUE );
	    else
	      one_hit( ch, victim, dt, FALSE );
	    check_improve(ch, gsn_footwork, TRUE, 0);
	    check_improve(ch,gsn_second_attack,TRUE,0);
	    if ( ch->fighting != victim )
	      return;
	  }

	if (melee_loc == 2 && check_melee_actions(ch))
	  return;
	if (secart_loc == 2 && check_secart_actions(ch))
	  return;
	if (shadow_loc == 2 && shadow_strike(ch, victim)){
	  if (ch->fighting != victim)
	    return;
	}
	/* Secondary Dual Attack */
	if (fSlow )
	  chance = 0;
	else if (fHaste)
	  chance = 4 * get_skill(ch, gsn_second_attack)/ 5;
	else
	  chance = get_skill(ch, gsn_second_attack)/2;

	//fury for ferals
	if (chance && ch->race == grn_feral)
	  chance += ch->level;

	if ( !fWlock
	     && (fPugil || get_eq_char(ch,WEAR_SECONDARY))
	     && number_percent( ) < chance
	     && ((!IS_NPC(ch) 
		  && get_skill(ch,gsn_dual_wield) > number_range( 0, 100 )) 
		 || IS_NPC(ch)) )
	  {
	    one_hit( ch,victim,dt,TRUE);
	    check_improve(ch,gsn_dual_wield,TRUE,1);
	    if (ch->fighting != victim)
	      return;
	  }


/* Third Attack */
	/* Third attack Primary */
	if (fSlow)
	  chance = 0;
	else if (fHaste){
	  if (ch->class == gcn_blademaster)
	    chance  = 8 * get_skill(ch, gsn_bladework) / 10;
	  else
	    chance  = get_skill(ch, gsn_third_attack) / 2;
	}
	else{
	  if (ch->class == gcn_blademaster)
	    chance  = 7 * get_skill(ch, gsn_bladework) / 10;
	  else 
	    chance = get_skill(ch, gsn_third_attack) / 4;
	}

	//Psi Time Compression
	if (chance == 0 && !fSlow 
	    && ch->class == gcn_psi
	    && is_affected(ch, gsn_time_comp))
	  chance = fHaste ? 50  : 25;
	//fury for ferals
	if (ch->race == grn_feral)
	  chance += ch->level;
	if ( has_twohanded(ch) != NULL
	     && number_percent() < get_skill( ch, gsn_adv_handling) ){
	  check_improve(ch, gsn_adv_handling, TRUE, 1);
	  chance += 10;
	}

	if (melee_loc == 3 && check_melee_actions(ch))
	  return;
	if (secart_loc == 3 && check_secart_actions(ch))
	  return;
	if (shadow_loc == 3 && shadow_strike(ch, victim)){
	  if (ch->fighting != victim)
	    return;
	}
	if ( number_percent( ) < chance )
	  {
	    if (ch->class == gcn_blademaster && getBmWearLoc(ch, TRUE) == WEAR_SECONDARY)
	      one_hit( ch, victim, dt, TRUE );
	    else
	      one_hit( ch, victim, dt, FALSE );
	    check_improve(ch, gsn_bladework, TRUE, 0);
	    check_improve(ch,gsn_third_attack,TRUE,1);
	    if ( ch->fighting != victim )
	      return;
	  }
	/* Third attack Secondary */
	if (fSlow || fWlock)
	  chance = 0;
	else if (fHaste)
	  chance = 3 * get_skill(ch, gsn_third_attack) /5;
	else
	  chance = get_skill(ch, gsn_third_attack) / 5;
	
	if ((fPugil 
	     || get_eq_char(ch,WEAR_SECONDARY)) && number_percent( ) < chance
	    && ( ( !IS_NPC(ch) && get_skill(ch,gsn_dual_wield) > number_range( 0, 100 )) 
		 || IS_NPC(ch)) )
	  {
	    one_hit( ch,victim,dt,TRUE);
	    check_improve(ch,gsn_dual_wield,TRUE, 1);
	    if (ch->fighting != victim)
	      return;
	  }

/* Fourth Attack */
	/* Fourth attack Primary */
	if (fSlow || fPugil)
	  chance = 0;
	else if (fHaste){
	  if (ch->class == gcn_blademaster && monk_good(ch, WEAR_LEGS))//same chance as not hasted
	    chance  = 5 * get_skill(ch, gsn_battlestance) / 10;
	  else 
	    chance = get_skill(ch, gsn_fourth_attack) / 4;
	}
	else{
	  if (ch->class == gcn_blademaster && monk_good(ch, WEAR_LEGS))//same chance as hsted
	    chance  = 5 * get_skill(ch, gsn_battlestance) / 10;
	  else 
	    chance = get_skill(ch, gsn_fourth_attack) / 6;
	}

	//Psi Time Compression
	if (chance == 0 && !fSlow 
	    && ch->class == gcn_psi
	    && is_affected(ch, gsn_time_comp))
	  chance = fHaste ? 30  : 15;

	if ( has_twohanded(ch) != NULL
	     && number_percent() < get_skill( ch, gsn_adv_handling) ){
	  check_improve(ch, gsn_adv_handling, TRUE, 1);
	  chance += 10;
	}
	if ( number_percent( ) < chance  
	     || (ch->class == gcn_vampire
		 && !vamp_day_check(ch)))
	  {
	    if (ch->class == gcn_blademaster && getBmWearLoc(ch, FALSE) == WEAR_SECONDARY)
	      one_hit( ch, victim, dt, TRUE );
	    else
	      one_hit( ch, victim, dt, FALSE );
	    check_improve(ch, gsn_battlestance, TRUE, 0);
	    check_improve(ch,gsn_fourth_attack,TRUE,0);
	    if ( ch->fighting != victim )
	      return;
	  }
	/* Fourth Attack Secondary */
	if (fSlow || fPugil || fWlock)
	  chance = 0;
	else if (fHaste)
	  chance = get_skill(ch, gsn_fourth_attack) / 6;
	else
	  chance = get_skill(ch, gsn_fourth_attack) / 8;

	if ( (get_eq_char(ch,WEAR_SECONDARY)) && number_percent( ) < chance
	     && ( ( !IS_NPC(ch) && get_skill(ch,gsn_dual_wield) > number_range( 0, 100 )) 
		  || IS_NPC(ch))
	     )
	  {
	    one_hit( ch,victim,dt,TRUE);
	    check_improve(ch,gsn_dual_wield,TRUE,1);
	    if (ch->fighting != victim)
	      return;
	  }

	/* fifth attack for blademasters */
	if (fSlow || fPugil)
	  chance = 0;
	else if (fHaste){
	  chance  = 3 * get_skill(ch, gsn_avatar_of_steel) / 10;
	}
	else{
	  chance  = 3 * get_skill(ch, gsn_avatar_of_steel) / 10;
	}
	if ( has_twohanded(ch) != NULL
	     && number_percent() < get_skill( ch, gsn_adv_handling) ){
	  check_improve(ch, gsn_adv_handling, TRUE, 1);
	  chance += 10;
	}
	if ( number_percent( ) < chance  ){
	  bool fPrim = number_percent() < 50;
	  if (ch->class == gcn_blademaster && getBmWearLoc(ch, fPrim) == WEAR_SECONDARY)
	    one_hit( ch, victim, dt, TRUE );
	  else
	    one_hit( ch, victim, dt, FALSE );
	  check_improve(ch, gsn_avatar_of_steel, TRUE, 0);
	  if ( ch->fighting != victim )
	    return;
	}

/* END OF REGUARL 5 ATTCKS */
	if (ch->class == gcn_bard && IS_AREA(ch->in_room->area, AREA_CITY)){
	  if ( (chance = get_skill(ch,gsn_brawl)) > 1 ){
	    chance /= 2;
	    if ( number_percent( ) < chance ){
	      one_hit( ch, victim, dt, FALSE);
	      check_improve(ch,gsn_brawl,TRUE,1);
	    }
	    if ( ch->fighting != victim )
	      return;
	  }
	}
	
	multi_hit_extra( ch, victim, dt, change );
	if ( ch->fighting != victim )
	  return;
	if (ch->class == class_lookup("berserker") && !IS_AFFECTED2(ch,AFF_RAGE) && !IS_NPC(ch) && ch->level >= 6)
	  {
	    chance1 = 4;
	    if (IS_AFFECTED(ch, AFF_SLOW) && !IS_AFFECTED(ch, AFF_HASTE))
	      chance1 = 0;
	    if (IS_AFFECTED(ch, AFF_CALM))
	      chance1 = 0;
	    if (100 * ch->hit / ch->max_hit > 75 - ch->level)
	      chance1 = 0;
	    if (chance1 != 0)
	      {
		if (IS_AFFECTED(ch, AFF_BERSERK))
		  chance1 += 1;
		if (ch->race == race_lookup("dwarf"))
		  chance1 += 1;
		if (IS_AFFECTED(ch,AFF_HASTE))
		  chance1 += 1;   
		chance1 += ((75 - ch->level) - (100 * ch->hit / ch->max_hit))/5;
		chance1 -= (get_skill(ch,gsn_rage)/25);
		chance1 = UMAX(1, chance1);
	      }
	    if (number_percent( ) < chance1)
	      {
		AFFECT_DATA af;
		act("You feel your veins course with power as the madness engulfs you!",ch,NULL,NULL,TO_CHAR);
		act("$n's eyes suddenly burn like hot coals as $e is gripped by insanity!",ch,NULL,NULL,TO_ROOM);
		af.where            = TO_AFFECTS2;
		af.type             = gsn_rage;
		af.level            = ch->level;
		af.duration         = UMAX(0, 4 - number_fuzzy(ch->level / 11));
		af.location         = APPLY_STR;
		af.modifier         = ch->size * 2;
		af.bitvector        = AFF_RAGE;
		affect_to_char(ch,&af);
		af.location         = APPLY_HITROLL;
		af.modifier         = str_app[get_curr_stat(ch,STAT_STR)].tohit + ch->level/4; 
		affect_to_char(ch,&af);
		af.location         = APPLY_DAMROLL;
		af.modifier         = str_app[get_curr_stat(ch,STAT_STR)].todam + ch->level/4;
		affect_to_char(ch,&af);
		af.location         = APPLY_HIT;
		af.modifier         = (ch->level * ch->perm_stat[STAT_CON])/3;
	    affect_to_char(ch,&af);
            ch->hit += (ch->level * ch->perm_stat[STAT_CON]) / 3;
            check_improve(ch,gsn_rage,TRUE,1);
	      }
	  }                                                                            
      }//end if WOLF
    
}
    
void multi_hit_extra( CHAR_DATA *ch, CHAR_DATA *victim, int dt, int change )
{
  int chance = ch->level, iWear, cycle;
  OBJ_DATA *wield, *claw, *obj;
  wield = get_eq_char(ch,WEAR_WIELD);
  claw = get_eq_char(ch, WEAR_HANDS);

  if ( ch->fighting != victim )
    return;
  if (is_affected(victim, gsn_mortally_wounded))
    return;

  if (claw && claw->pIndexData->vnum == OBJ_VNUM_CLAWS){
    damage(ch,victim,number_range(0, (claw->level + ch->level)/4),1005,DAM_SLASH,TRUE);
    if (ch->fighting != victim)
      return;
  }
  for ( iWear = 0; iWear < MAX_WEAR; iWear++ ){
    obj = get_eq_char( ch, iWear );
    //cast combat spells.
    if( obj != NULL 
	&& (obj->eldritched || obj->pIndexData->spell != NULL) 
	&& ch->fighting != NULL)
      do_obj_spell( obj, ch, victim );
    if ( ch->fighting != victim )
      return;
  }
/* check prim/sec */
  for (cycle = 0; cycle < 2; cycle++){
    if (cycle == 0)
      wield = getBmWep(ch, TRUE);
    else
      wield = getBmWep(ch, FALSE);
    
    if (wield == NULL)
      continue;
    else
      chance = wield->level;

    if (number_percent( ) < chance ){
      int dam;
      if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_POISON)){
	int level;
	AFFECT_DATA *poison, af, *paf;
	if ((poison = affect_find(wield->affected,gsn_poison)) == NULL)
	  level = UMAX(wield->level,1);
	else
	  level = poison->level;
	if (!saves_spell(level / 2,victim,DAM_POISON,skill_table[gsn_poison].spell_type)) {
	  bool fNew = is_affected(victim, gsn_poison);
	  act("You feel poison coursing through your veins.", victim,wield,NULL,TO_CHAR);
	  act("$n is poisoned by the venom on $p.", victim,wield,NULL,TO_ROOM);
	  af.where     = TO_AFFECTS;
	  af.type      = gsn_poison;
	  af.level     = level * 3/4;
	  af.duration  = level / 10;
	  af.location  = APPLY_STR;
	  af.modifier  = fNew ? -1 : 0;
	  af.bitvector = AFF_POISON;
	  affect_join( victim, &af );
	  paf = affect_find( victim->affected, gsn_poison );
	  if (!IS_NPC(ch))
	    string_to_affect(paf, ch->name);
	  /* Set bit preventing damage till first tick. */
	  if (ch->class != class_lookup("shaman") && fNew)
	    SET_BIT(paf->bitvector, AFF_FLAG);
	}
	if (ch->fighting == NULL)
	  return;
      }
      if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_VAMPIRIC)){
	dam = number_range(1, wield->level / 3 + 1);
	act("$p draws life from $n.",victim,wield,NULL,TO_ROOM);
	act("You feel $p drawing your life away.", victim,wield,NULL,TO_CHAR);
	damage(ch,victim,dam,33 + TYPE_NOBLOCKHIT,DAM_NEGATIVE,TRUE);
	ch->hit += dam/2;
	if (ch->fighting == NULL)
	  return;
      }
      if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_FLAMING)){
	dam = number_range(1,wield->level / 3 + 5);
	act("$n's flesh is seared by the flaming $p.",victim,wield,NULL,TO_ROOM);
	act("$p sears your flesh with flames.",victim,wield,NULL,TO_CHAR);
	fire_effect(victim,wield->level,dam,TARGET_CHAR);
	if (ch->fighting == NULL)
	  return;
	damage(ch,victim,dam,29 + TYPE_NOBLOCKHIT,DAM_FIRE,TRUE);
	if (ch->fighting == NULL)
	  return;
      }
      if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_FROST)){
	dam = number_range(5,wield->level / 3 + 15);
	act("The cold touch of $p surrounds $n with ice.",victim,wield,NULL,TO_ROOM);
	act("The cold touch of $p surrounds you with ice.",victim,wield,NULL,TO_CHAR);
	cold_effect(victim,wield->level,dam,TARGET_CHAR);
	if (ch->fighting == NULL)
	  return;
	damage(ch,victim,dam,30 + TYPE_NOBLOCKHIT,DAM_COLD,TRUE);
	if (ch->fighting == NULL)
	  return;
      }
      if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_SHOCKING)){
	dam = number_range(10,wield->level/3 + 10);
	act("$n is shocked by the lightning from $p.",victim,wield,NULL,TO_ROOM);
	act("You are shocked by the lightning from $p.",victim,wield,NULL,TO_CHAR);
	shock_effect(victim,wield->level/2,dam,TARGET_CHAR);
	if (ch->fighting == NULL)
	  return;
	damage(ch,victim,dam,28 + TYPE_NOBLOCKHIT,DAM_LIGHTNING,TRUE);
      }
      if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_PARALYZE)){
	dam = number_range(10,wield->level/3 + 10);
	act("$p tears into your nerves.",victim,wield,NULL,TO_CHAR);
	act("$p tears into $n's nerves.",victim,wield,NULL,TO_ROOM);
	paralyze_effect(victim,wield->level,dam,TARGET_CHAR);
	if (ch->fighting == NULL)
	  return;
      }
      if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_VORPAL)){
	dam = number_range(1,wield->level/5 + 1);
	act("$p burns $n with corrosive acid.",victim,wield,NULL,TO_ROOM);
	act("You are burned by the corrosive acid on $p.",victim,wield,NULL,TO_CHAR);
	acid_effect(victim,wield->level,dam,TARGET_CHAR);
	if (ch->fighting == NULL)
	  return;
	damage(ch,victim,dam,31 + TYPE_NOBLOCKHIT,DAM_POISON,TRUE);
	if (ch->fighting == NULL)
	  return;
      }
      if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_SHARP)){
	dam = number_range(15,wield->level/2 + ch->level / 2);
	act("$p digs into $n's body.",victim,wield,NULL,TO_ROOM);
	act("You can feel $p dig into your body.",victim,wield,NULL,TO_CHAR);
	damage(ch,victim,dam,18 + TYPE_NOBLOCKHIT,DAM_SLASH,TRUE);
	if (ch->fighting == NULL)
	  return;
      }
      if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_WOUNDS)){
	wound_effect( ch, victim, ch->level, 0);
	if (ch->fighting == NULL)
	  return;
      }
      if (ch->fighting == victim && IS_WEAPON_STAT(wield,WEAPON_DEADLY)
	  && !IS_UNDEAD(ch->fighting)){
	dam = number_range(15,wield->level/2 + 25);
	if (!saves_spell(3 * wield->level / 4 + dam / 15, victim, 
			 DAM_SLASH, SPELL_AFFLICTIVE)){
	  AFFECT_DATA af, *paf;
	  act("A spray of blood shoots forth from $n's wound!", victim, NULL, NULL, TO_ROOM);
	  act("A spray of blood shoots forth from your wound!", victim, NULL, NULL, TO_CHAR);
	  if ( (paf = affect_find(victim->affected, gen_bleed)) == NULL){
	    af.type = gen_bleed;
	    af.level = ch->level;
	    af.duration = number_range(3, 6);
	    af.where = TO_NONE;
	    af.bitvector = 0;
	    af.location = APPLY_NONE;
	    /* modifier controls duration of damage (10/tick)*/
	    af.modifier = number_range(5, 15);
	    paf = affect_to_char(victim, &af);
	    string_to_affect(paf, ch->name);	
	  }
	  else{
	    /* modifier controls duration of damage (10/tick)*/
	    paf->modifier = number_range(5, 15);
	    string_to_affect(paf, ch->name);	
	  }
	}
      }
    }
    if ( ch->fighting == NULL || ch->fighting != victim )
      return;
    if (wield && !str_cmp(wield->material,"practice") && number_percent( ) < 10){
      if (ch->max_hit != 0 && ch->hit*100/ch->max_hit <= 20)
	act( "$p whispers 'Run away!'", ch, wield, NULL, TO_CHAR);
      else if (ch->max_hit != 0 && ch->hit*100/ch->max_hit <= 60) 
	act( "$p whispers 'You can do it!'", ch, wield, NULL, TO_CHAR);
      else
	act( "$p whispers 'You're doing great!'", ch, wield, NULL, TO_CHAR);
    }
  }//END PRIM/SEC LOOP
  if ( change != victim->hit && IS_AFFECTED2(victim, AFF_ICE_SHIELD) ){
    damage(victim,ch,number_range(victim->level/2,3*victim->level/2),skill_lookup("ice shield"),DAM_COLD,TRUE);
    if ( ch->fighting == NULL || ch->fighting != victim )
      return;
  }
  if ( change != victim->hit && IS_AFFECTED2(victim, AFF_FIRE_SHIELD) ){
    damage(victim,ch,number_range(victim->level/2,3*victim->level/2),skill_lookup("fire shield"),DAM_FIRE,TRUE);
    if ( ch->fighting == NULL || ch->fighting != victim )
      return;
  }
  if ( is_affected(victim, skill_lookup("divine retribution")) && !IS_GOOD(ch)){
    int dam2;
    dam2 = number_range(victim->level, 3*victim->level/2);
    if (IS_NEUTRAL(ch))
      dam2 = 2*dam2/3;
    damage(victim,ch,dam2,skill_lookup("divine retribution"),DAM_HOLY,TRUE);
    if ( ch->fighting == NULL || ch->fighting != victim )
      return;
  }
  if ( change != victim->hit && is_affected(victim, skill_lookup("shield of thorns"))){
    int dam2;
    dam2 = number_range(2*victim->level/3,3*victim->level/2); 
    damage(victim,ch,dam2,skill_lookup("shield of thorns"),DAM_PIERCE,TRUE);
    if ( ch->fighting == NULL || ch->fighting != victim )
      return;
  }
  if ( change != victim->hit && is_affected(victim, gsn_steel_wall )){
    int dam2;
    dam2 = number_range( victim->level / 2, 3 * victim->level / 2); 
    damage(victim, ch, dam2, gsn_steel_wall ,DAM_SLASH, TRUE);
    if ( ch->fighting == NULL || ch->fighting != victim )
      return;
  }
  
  if (ch->race == race_lookup("slith") && number_percent() < 15 + ch->level
      && get_curr_stat(ch, STAT_STR) > 12){
    if (number_percent() < 75)
      damage(ch,victim,number_range(ch->level, 3 * ch->level / 2 - (30 - ch->perm_stat[STAT_STR])),1071,DAM_PIERCE,TRUE);
    else
      {
	act("You strike with your tail at $N's legs.", ch, NULL, victim, TO_CHAR);
	act("$n strikes with $s tail at $N's legs.", ch, NULL, victim, TO_NOTVICT);
	act("$n strikes with $s tail at your legs.", ch, NULL, victim, TO_VICT);
	trip(ch, victim, 50);
      }
    if ( ch->fighting == NULL || ch->fighting != victim )
      return;
  }
  if ( ch->fighting != victim )
    return;
}

void mob_hit (CHAR_DATA *ch, CHAR_DATA *victim, int dt)
{
    int chance, number, change = victim->hit;
    CHAR_DATA *vch, *vch_next;
    char buf[MSL];
    if (IS_SET(ch->act,ACT_THIEF) && ch->fighting == NULL)
    {
	buf[0]='\0';
	strcat(buf,str_dup(victim->name));
	do_backstab(ch,buf);
    }
    one_hit(ch,victim,dt,FALSE);
    if (ch->fighting != victim)
	return;
    if (ch->fighting != victim || dt == gsn_backstab || dt == gsn_cleave 
    || dt == gsn_assassinate || dt == gsn_charge || dt == gsn_ambush)
	return;

    if (IS_SET(ch->off_flags,OFF_AREA_ATTACK)){
	for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
	{
	    vch_next = vch->next_in_room;
	    if ((vch != victim && vch->fighting == ch))
		one_hit(ch,vch,dt,FALSE);
	}
    }
    if (ch->fighting != victim)
	return;

    if ( (IS_AFFECTED(ch,AFF_HASTE) || IS_SET(ch->off_flags,OFF_FAST)) && !IS_AFFECTED(ch,AFF_SLOW))
      one_hit(ch,victim,dt,FALSE);
    if (ch->fighting != victim)
      return;

    if (IS_SET(ch->off_flags,OFF_EXTRA_ATTACK))
      one_hit(ch,victim,dt,FALSE);
    if (ch->fighting != victim)
      return;

    chance = get_skill(ch,gsn_second_attack)/2;
    if (IS_AFFECTED(ch,AFF_SLOW) && !IS_SET(ch->off_flags,OFF_FAST) && !IS_AFFECTED(ch,AFF_HASTE))
      chance /= 2;
    if (number_percent() < chance)
      {
        one_hit(ch,victim,dt,FALSE);
	if (ch->fighting != victim)
	  return;
      }
    chance = get_skill(ch,gsn_third_attack)/4;
    if (IS_AFFECTED(ch,AFF_SLOW) && !IS_SET(ch->off_flags,OFF_FAST) && !IS_AFFECTED(ch,AFF_HASTE))
      chance = 0;
    if (number_percent() < chance)
      {
        one_hit(ch,victim,dt,FALSE);
	if (ch->fighting != victim)
	  return;
      } 
    if ( change != victim->hit && IS_AFFECTED2(victim, AFF_ICE_SHIELD) )
      damage(victim,ch,number_range(victim->level/2,3*victim->level/2),skill_lookup("ice shield"),DAM_COLD,TRUE);
    if (ch->fighting != victim)
      return;
    if ( chance != victim->hit && IS_AFFECTED2(victim, AFF_FIRE_SHIELD) )
      damage(victim,ch,number_range(victim->level/2,3*victim->level/2),skill_lookup("fire shield"),DAM_FIRE,TRUE);
    if (ch->fighting != victim)
      return;
    if ( is_affected(victim, skill_lookup("divine retribution")) && !IS_GOOD(ch))
   

Showing the first 100 KB of 297.9 KB. Download the archive for the full file.

Site Stats

Snippets: 1791
Codebases: 571