fight.cm

DBZu/src/fight.cm · 185.1 KB

From the archive DBZu.zip

Download the archive   « Back to the archive contents

/****************************************************************************
 * [S]imulated [M]edieval [A]dventure multi[U]ser [G]ame      |   \\._.//   *
 * -----------------------------------------------------------|   (0...0)   *
 * SMAUG 1.4 (C) 1994, 1995, 1996, 1998  by Derek Snider      |    ).:.(    *
 * -----------------------------------------------------------|    {o o}    *
 * SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus,      |   / ' ' \   *
 * Scryn, Rennard, Swordbearer, Gorog, Grishnakh, Nivek,      |~'~.VxvxV.~'~*
 * Tricops and Fireblade                                      |             *
 * ------------------------------------------------------------------------ *
 * Merc 2.1 Diku Mud improvments copyright (C) 1992, 1993 by Michael        *
 * Chastain, Michael Quan, and Mitchell Tse.                                *
 * Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,          *
 * Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.     *
 * ------------------------------------------------------------------------ *
 *			    Battle & death module			    *
 ****************************************************************************/

#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "mud.h"


extern char		lastplayercmd[MAX_INPUT_LENGTH];
extern CHAR_DATA *	gch_prev;
double sqrt    args(  (double Nbr) );

OBJ_DATA *used_weapon;   /* Used to figure out which weapon later */

/*
 * Local functions.
 */
void	new_dam_message	args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dam,
			    int dt, OBJ_DATA *obj ) );
void	death_cry	args( ( CHAR_DATA *ch ) );
void	group_gain	args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
int	xp_compute	args( ( CHAR_DATA *gch, CHAR_DATA *victim ) );
int	align_compute	args( ( CHAR_DATA *gch, CHAR_DATA *victim ) );
ch_ret	one_hit		args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dt ) );
int	obj_hitroll	args( ( OBJ_DATA *obj ) );
void    show_condition  args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );


/*
 * Check to see if player's attacks are (still?) suppressed
 * #ifdef TRI
 */
bool is_attack_supressed( CHAR_DATA *ch )
{
  TIMER *timer;

  if (IS_NPC(ch))
    return FALSE;

  timer = get_timerptr( ch, TIMER_ASUPRESSED );

  if ( !timer )
    return FALSE;

  /* perma-supression -- bard? (can be reset at end of fight, or spell, etc) */
  if ( timer->value == -1 )
    return TRUE;

  /* this is for timed supressions */
  if ( timer->count >= 1 )
    return TRUE;

  return FALSE;
}

void give_nd( CHAR_DATA *ch, CHAR_DATA *victim )
{
  char logbuf[MAX_INPUT_LENGTH];
  int nd, pl;
pl = 0;
/*
  if ( ch->exp >= 92000000 )
  return; */

/*
  if ( ch->hit != -4 )
  return; */

  if ( ch->leader )
  return;

  if (!IS_HALFBREED(ch) && !IS_SAIYAN(ch) && !IS_BIODROID(ch) && !IS_HUMAN(ch) )
  return;

/*  if (IS_HUMAN(ch) && !xIS_SET(ch->act, PLR_CAN_ASCENSION) && ch->exp >= 85000000 )
  {
  ch->hit = 100;
  update_pos( ch );
  xREMOVE_BIT(ch->act, PLR_SUPERHUMAN);
  ch->mod_str = 0;
  ch->mod_wis = 0;
  ch->mod_dex = 0;
  ch->mod_con = 0;
  ch->mod_lck = 0;
  ch->suppress = 0;
  xREMOVE_BIT(ch->act, PLR_SUPPRESS);
  xSET_BIT(ch->act, PLR_CAN_ASCENSION);
  do_ascension( ch, "" );
  } */

/*  if (IS_BIODROID(ch) && !xIS_SET(ch->act, PLR_CAN_ULTRA) && ch->celltype == 1 && ch->biomass >= 5000 )
  {
  ch->hit = 100;
  update_pos( ch );
  xREMOVE_BIT(ch->act, PLR_PERFECT);
  xREMOVE_BIT(ch->act, PLR_ADULT);
  xREMOVE_BIT(ch->act, PLR_SEMIP);
  xSET_BIT(ch->act, PLR_CAN_ULTRA);
  ch->mod_str = 0;
  ch->mod_wis = 0;
  ch->mod_dex = 0;
  ch->mod_con = 0;
  ch->mod_lck = 0;
  ch->suppress = 0;
  xREMOVE_BIT(ch->act, PLR_SUPPRESS);
  do_evolve ( ch, "Ultra" );
  } */

  if ( ch->exp >= 92000000 )
  return;

 if ( ch->exp >= 5000000 && ch->exp < 25000000)  
  {pl = ch->pcdata->learned[gsn_chikone] * 250000;}
  else if ( ch->exp >= 25000000 && ch->exp < 55000000)
  {pl = ch->pcdata->learned[gsn_chiktwo] * 550000; }
  else if ( ch->exp >= 55000000 && ch->exp < 75000000) 
  {pl = ch->pcdata->learned[gsn_chikthree] * 750000; }
  else if ( ch->exp >= 75000000 && ch->exp < 90000000)
  {pl = ch->pcdata->learned[gsn_chikfour] *  900000;}
  else if ( ch->exp >= 75000000 && ch->exp < 110000000)
  {pl = ch->pcdata->learned[gsn_chikfive] * 1000000;}

  if (ch->exp >= 5000000)
  {
   if ( pl < ch->exp )
   return;
  } 

  nd = ch->exp / 40;
  if (IS_BIODROID(ch))
  nd = ch->exp / 45;

  ch->exp += nd;

  ch_printf(ch, "You feel stronger due to your near death experience.\n\r");
  sprintf(logbuf, "%s has had a near death experience.\n\r", ch->name );
  log_string( logbuf );

}  

/*
 * Check to see if weapon is poisoned.
 */
bool is_wielding_poisoned( CHAR_DATA *ch )
{
    OBJ_DATA *obj;

    if ( !used_weapon )
    	return FALSE;

    if ( (obj=get_eq_char(ch, WEAR_WIELD)) != NULL
    &&    used_weapon == obj
    &&    IS_OBJ_STAT(obj, ITEM_POISONED) )
	return TRUE;
    if ( (obj=get_eq_char(ch, WEAR_DUAL_WIELD)) != NULL
    &&    used_weapon == obj
    &&	  IS_OBJ_STAT(obj, ITEM_POISONED) )
    	return TRUE;

    return FALSE;
}

/*
 * hunting, hating and fearing code				-Thoric
 */
bool is_hunting( CHAR_DATA *ch, CHAR_DATA *victim )
{
    if ( !ch->hunting || ch->hunting->who != victim )
      return FALSE;
    
    return TRUE;    
}

bool is_hating( CHAR_DATA *ch, CHAR_DATA *victim )
{
    if ( !ch->hating || ch->hating->who != victim )
      return FALSE;
    
    return TRUE;    
}

bool is_fearing( CHAR_DATA *ch, CHAR_DATA *victim )
{
    if ( !ch->fearing || ch->fearing->who != victim )
      return FALSE;
    
    return TRUE;    
}

void stop_hunting( CHAR_DATA *ch )
{
    if ( ch->hunting )
    {
	STRFREE( ch->hunting->name );
	DISPOSE( ch->hunting );
	ch->hunting = NULL;
    }
    return;
}

void stop_hating( CHAR_DATA *ch )
{
    if ( ch->hating )
    {
	STRFREE( ch->hating->name );
	DISPOSE( ch->hating );
	ch->hating = NULL;
    }
    return;
}

void stop_fearing( CHAR_DATA *ch )
{
    if ( ch->fearing )
    {
	STRFREE( ch->fearing->name );
	DISPOSE( ch->fearing );
	ch->fearing = NULL;
    }
    return;
}

void start_hunting( CHAR_DATA *ch, CHAR_DATA *victim )
{
    if ( ch->hunting )
      stop_hunting( ch );

    CREATE( ch->hunting, HHF_DATA, 1 );
    ch->hunting->name = QUICKLINK( victim->name );
    ch->hunting->who  = victim;
    return;
}

void start_hating( CHAR_DATA *ch, CHAR_DATA *victim )
{
    if ( ch->hating )
      stop_hating( ch );

    CREATE( ch->hating, HHF_DATA, 1 );
    ch->hating->name = QUICKLINK( victim->name );
    ch->hating->who  = victim;
    return;
}

void start_fearing( CHAR_DATA *ch, CHAR_DATA *victim )
{
    if ( ch->fearing )
      stop_fearing( ch );

    CREATE( ch->fearing, HHF_DATA, 1 );
    ch->fearing->name = QUICKLINK( victim->name );
    ch->fearing->who  = victim;
    return;
}

/*
 * Get the current armor class for a vampire based on time of day
 */
sh_int VAMP_AC( CHAR_DATA * ch )
{
  if ( IS_VAMPIRE( ch ) && IS_OUTSIDE( ch ) )
  {
    switch(time_info.sunlight)
    {
    case SUN_DARK:
      return -10;
    case SUN_RISE:
      return 5;
    case SUN_LIGHT:
      return 10;
    case SUN_SET:
      return 2;
    default:
      return 0;
    }
  }
  else
    return 0;
}

int max_fight( CHAR_DATA *ch )
{
    return 8;
}



/*
 * Control the fights going on.
 * Called periodically by update_handler.
 * Many hours spent fixing bugs in here by Thoric, as noted by residual
 * debugging checks.  If you never get any of these error messages again
 * in your logs... then you can comment out some of the checks without
 * worry.
 *
 * Note:  This function also handles some non-violence updates.
 */
void violence_update( void )
{
    char buf[MAX_STRING_LENGTH];
    CHAR_DATA *ch;
    CHAR_DATA *lst_ch;
    CHAR_DATA *victim;
    CHAR_DATA *rch, *rch_next;
    AFFECT_DATA *paf, *paf_next;
    TIMER	*timer, *timer_next;
    ch_ret	retcode;
    int		attacktype, cnt;
    SKILLTYPE	*skill;
    static int	pulse = 0;

    lst_ch = NULL;
    pulse = (pulse+1) % 100;

    for ( ch = last_char; ch; lst_ch = ch, ch = gch_prev )
    {
	set_cur_char( ch );

	if ( ch == first_char && ch->prev )
	{
	   bug( "ERROR: first_char->prev != NULL, fixing...", 0 );
	   ch->prev = NULL;
	}

	gch_prev	= ch->prev;

	if ( gch_prev && gch_prev->next != ch )
	{
	    sprintf( buf, "FATAL: violence_update: %s->prev->next doesn't point to ch.",
		ch->name );
	    bug( buf, 0 );	    
	    bug( "Short-cutting here", 0 );
	    ch->prev = NULL;
	    gch_prev = NULL;
	    do_shout( ch, "Thoric says, 'Prepare for the worst!'" );
	}

	/*
	 * See if we got a pointer to someone who recently died...
	 * if so, either the pointer is bad... or it's a player who
	 * "died", and is back at the healer...
	 * Since he/she's in the char_list, it's likely to be the later...
	 * and should not already be in another fight already
	 */
	if ( char_died(ch) )
	    continue;

	/*
	 * See if we got a pointer to some bad looking data...
	 */
	if ( !ch->in_room || !ch->name )
	{
	    log_string( "violence_update: bad ch record!  (Shortcutting.)" );
	    sprintf( buf, "ch: %d  ch->in_room: %d  ch->prev: %d  ch->next: %d",
	    	(int) ch, (int) ch->in_room, (int) ch->prev, (int) ch->next );
	    log_string( buf );
	    log_string( lastplayercmd );
	    if ( lst_ch )
	      sprintf( buf, "lst_ch: %d  lst_ch->prev: %d  lst_ch->next: %d",
	      		(int) lst_ch, (int) lst_ch->prev, (int) lst_ch->next );
	    else
	      strcpy( buf, "lst_ch: NULL" );
	    log_string( buf );
	    gch_prev = NULL;
	    continue;
	}

        /*
         * Experience gained during battle deceases as battle drags on
         */
	if ( ch->fighting )
	  if ( (++ch->fighting->duration % 24) == 0 )
	    ch->fighting->xp = ((ch->fighting->xp * 9) / 10);


	for ( timer = ch->first_timer; timer; timer = timer_next )
	{
	    timer_next = timer->next;
	    if ( --timer->count <= 0 )
	    {
		if ( timer->type == TIMER_ASUPRESSED )
		{
		    if ( timer->value == -1 )
		    {
			timer->count = 1000;
			continue;
		    }
		}
		if ( timer->type == TIMER_NUISANCE )
		{
		    DISPOSE( ch->pcdata->nuisance );
		}

		if ( timer->type == TIMER_DO_FUN )
		{
		    int tempsub;

		    tempsub = ch->substate;
		    ch->substate = timer->value;
		    (timer->do_fun)( ch, "" );
		    if ( char_died(ch) )
			break;
		    ch->substate = tempsub;
		}
		extract_timer( ch, timer );
	    }
	}

	if ( char_died(ch) )
	    continue;

	/*
	 * We need spells that have shorter durations than an hour.
	 * So a melee round sounds good to me... -Thoric
	 */
	for ( paf = ch->first_affect; paf; paf = paf_next )
	{
	    paf_next	= paf->next;
	    if ( paf->duration > 0 )
		paf->duration--;
	    else
	    if ( paf->duration < 0 )
		;
	    else
	    {
		if ( !paf_next
		||    paf_next->type != paf->type
		||    paf_next->duration > 0 )
		{
		    skill = get_skilltype(paf->type);
		    if ( paf->type > 0 && skill && skill->msg_off )
		    {
			set_char_color( AT_WEAROFF, ch );
			send_to_char( skill->msg_off, ch );
			send_to_char( "\n\r", ch );
		    }
		}
		if (paf->type == gsn_possess)
	        {
		    ch->desc->character = ch->desc->original;
		    ch->desc->original  = NULL;
		    ch->desc->character->desc = ch->desc;
		    ch->desc->character->switched = NULL;
		    ch->desc            = NULL;
		}
		affect_remove( ch, paf );
	    }
	}
	
	if ( char_died(ch) )
	    continue;

	/* check for exits moving players around */
	if ( (retcode=pullcheck(ch, pulse)) == rCHAR_DIED || char_died(ch) )
	    continue;

	/* Let the battle begin! */

	if ( ( victim = who_fighting( ch ) ) == NULL
	||   IS_AFFECTED( ch, AFF_PARALYSIS ) )
	    continue;

        retcode = rNONE;

    if ( IS_AFFECTED(ch, AFF_HASTE) )
      {
            retcode = one_hit( ch, victim, TYPE_UNDEFINED );
      act( AT_MAGIC, "&PYou move as fast as lightning!", ch, NULL, NULL, TO_CHAR );
      act( AT_MAGIC, "&P$n moves as fast as lightning!", ch, NULL,NULL , TO_ROOM );
      }

	if ( xIS_SET(ch->in_room->room_flags, ROOM_SAFE ) )
	{
	   sprintf( buf, "violence_update: %s fighting %s in a SAFE room.",
	   	ch->name, victim->name );
	   log_string( buf );
	   stop_fighting( ch, TRUE );
	}
	else
        if ( IS_AWAKE(ch) && ch->in_room == victim->in_room )
        {
            retcode = multi_hit( ch, victim, TYPE_UNDEFINED );
        }
	else
	    stop_fighting( ch, FALSE );

	if ( char_died(ch) )
	    continue;

	if ( retcode == rCHAR_DIED
	|| ( victim = who_fighting( ch ) ) == NULL )
	    continue;

	/*
	 *  Mob triggers
	 *  -- Added some victim death checks, because it IS possible.. -- Alty
	 */
	rprog_rfight_trigger( ch );
	if ( char_died(ch) || char_died(victim) )
	    continue;
	mprog_hitprcnt_trigger( ch, victim );
	if ( char_died(ch) || char_died(victim) )
	    continue;
	mprog_fight_trigger( ch, victim );
	if ( char_died(ch) || char_died(victim) )
	    continue;

	/*
	 * NPC special attack flags				-Thoric
	 */
	if ( IS_NPC(ch) ) 
	{
	    if ( !xIS_EMPTY(ch->attacks) )
	    {
		attacktype = -1;
		if ( 30 + (ch->level/4) >= number_percent( ) )
		{
		    cnt = 0;
		    for ( ;; )
		    {
			if ( cnt++ > 10 )
			{
			    attacktype = -1;
			    break;
			}
			attacktype = number_range( 7, MAX_ATTACK_TYPE-1 );
			if ( xIS_SET( ch->attacks, attacktype ) )
			    break;
		    }
		    switch( attacktype )
		    {
			case ATCK_BASH:
			    do_bash( ch, "" );
			    retcode = global_retcode;
			    break;
			case ATCK_STUN:
			    do_stun( ch, "" ); 
			    retcode = global_retcode;
			    break;
            case ATCK_FINGERBEAM:
                do_fingerbeam( ch, "" );
                retcode = global_retcode;
                             break;
            case ATCK_MENTAL:
                do_mentalthrow( ch, "" );
                retcode = global_retcode;
                             break;
            case ATCK_DDD:
                do_ddd( ch, "" );
                retcode = global_retcode;
                             break;
                        case ATCK_GOUGE:
                            do_gouge( ch, "" );
                            retcode = global_retcode;
                            break;
			case ATCK_FEED:
			    do_gouge( ch, "" );
			    retcode = global_retcode;
			    break;
			case ATCK_DRAIN:
			    retcode = spell_energy_drain( skill_lookup( "energy drain" ), ch->level, ch, victim );
			    break;
			case ATCK_FIREBREATH:
			    retcode = spell_fire_breath( skill_lookup( "fire breath" ), ch->level, ch, victim );
			    break;
			case ATCK_FROSTBREATH:
			    retcode = spell_frost_breath( skill_lookup( "frost breath" ), ch->level, ch, victim );
			    break;
			case ATCK_ACIDBREATH:
			    retcode = spell_acid_breath( skill_lookup( "acid breath" ), ch->level, ch, victim );
			    break;
			case ATCK_LIGHTNBREATH:
			    retcode = spell_lightning_breath( skill_lookup( "lightning breath" ), ch->level, ch, victim );
			    break;
			case ATCK_GASBREATH:
			    retcode = spell_gas_breath( skill_lookup( "gas breath" ), ch->level, ch, victim );
			    break;
			case ATCK_SPIRALBLAST:         
			    retcode = spell_spiral_blast( skill_lookup( "spiral blast" ),
				ch->level, ch, victim );
			    break;
			case ATCK_POISON:
			    retcode = spell_poison( gsn_poison, ch->level, ch, victim );
			    break;
			case ATCK_NASTYPOISON:
			    /*
			    retcode = spell_nasty_poison( skill_lookup( "nasty poison" ), ch->level, ch, victim );
			    */
			    break;
			case ATCK_GAZE:
			    /*
			    retcode = spell_gaze( skill_lookup( "gaze" ), ch->level, ch, victim );
			    */
			    break;
			case ATCK_BLINDNESS:
			    retcode = spell_blindness( gsn_blindness, ch->level, ch, victim );
			    break;
			case ATCK_CAUSESERIOUS:
			    retcode = spell_cause_serious( skill_lookup( "cause serious" ), ch->level, ch, victim );
			    break;
			case ATCK_EARTHQUAKE:
			    retcode = spell_earthquake( skill_lookup( "earthquake" ), ch->level, ch, victim );
			    break;
			case ATCK_CAUSECRITICAL:
			    retcode = spell_cause_critical( skill_lookup( "cause critical" ), ch->level, ch, victim );
			    break;
			case ATCK_CURSE:
			    retcode = spell_curse( skill_lookup( "curse" ), ch->level, ch, victim );
			    break;
			case ATCK_FLAMESTRIKE:
			    retcode = spell_flamestrike( skill_lookup( "flamestrike" ), ch->level, ch, victim );
			    break;
			case ATCK_HARM:
			    retcode = spell_harm( skill_lookup( "harm" ), ch->level, ch, victim );
			    break;
			case ATCK_FIREBALL:
			    retcode = spell_fireball( skill_lookup( "fireball" ), ch->level, ch, victim );
			    break;
			case ATCK_COLORSPRAY:
			    retcode = spell_colour_spray( skill_lookup( "colour spray" ), ch->level, ch, victim );
			    break;
			case ATCK_WEAKEN:
			    retcode = spell_weaken( skill_lookup( "weaken" ), ch->level, ch, victim );
			    break;
		    }
		    if ( attacktype != -1 && (retcode == rCHAR_DIED || char_died(ch)) )
			continue;
		}
	    }
	    /*
	     * NPC special defense flags				-Thoric
	     */
	    if ( !xIS_EMPTY(ch->defenses) )
	    {
		attacktype = -1;
		if ( 50 + (ch->level/4) > number_percent( ) )
		{
		    cnt = 0;
		    for ( ;; )
		    {
			if ( cnt++ > 10 )
			{
			    attacktype = -1;
			    break;
			}
			attacktype = number_range( 2, MAX_DEFENSE_TYPE-1 );
			if ( xIS_SET( ch->defenses, attacktype ) )
			    break;
		    }

		    switch( attacktype )
		    {
			case DFND_CURELIGHT:
			    /* A few quick checks in the cure ones so that a) less spam and
			       b) we don't have mobs looking stupider than normal by healing
			       themselves when they aren't even being hit (although that
			       doesn't happen TOO often */
			    if ( ch->hit < ch->max_hit )
			    {
				act( AT_MAGIC, "$n mutters a few incantations...and looks a little better.", ch, NULL, NULL , TO_ROOM );
				retcode = spell_smaug( skill_lookup( "cure" ), ch->level, ch, ch );
			    }
			    break;
			case DFND_CURESERIOUS:
			    if ( ch->hit < ch->max_hit )
			    {
				act( AT_MAGIC, "$n mutters a few incantations...and looks a bit better.", ch, NULL, NULL, TO_ROOM );
				retcode = spell_smaug( skill_lookup( "cura" ), ch->level, ch, ch );
			    }
			    break;
			case DFND_CURECRITICAL:
			    if ( ch->hit < ch->max_hit )
			    {
				act( AT_MAGIC, "$n mutters a few incantations...and looks healthier.", ch, NULL, NULL, TO_ROOM );
				retcode = spell_smaug( skill_lookup( "curaga" ), ch->level, ch, ch );
			    }
			    break;
			case DFND_HEAL:
			    if ( ch->hit < ch->max_hit )
			    {
				act( AT_MAGIC, "$n mutters a few incantations...and looks much healthier.", ch, NULL, NULL, TO_ROOM );
				retcode = spell_smaug( skill_lookup( "heal" ), ch->level, ch, ch );
			    }
			    break;
			case DFND_DISPELMAGIC:
			    if ( victim->first_affect )
			    {
				act( AT_MAGIC, "$n utters an incantation...", ch, NULL, NULL, TO_ROOM );
				retcode = spell_dispel_magic( skill_lookup( "dispel magic" ), ch->level, ch, victim );
			    }
			    break;
			case DFND_DISPELEVIL:
			    act( AT_MAGIC, "$n utters an incantation...", ch, NULL, NULL, TO_ROOM );
			    retcode = spell_dispel_evil( skill_lookup( "dispel evil" ), ch->level, ch, victim );
			    break;
			case DFND_TELEPORT:
			    retcode = spell_teleport( skill_lookup( "teleport"), ch->level, ch, ch );
			    break;
			case DFND_SHOCKSHIELD:
			    if ( !IS_AFFECTED( ch, AFF_SHOCKSHIELD ) )
			    {
				act( AT_MAGIC, "$n utters a few incantations...", ch, NULL, NULL, TO_ROOM );
				retcode = spell_smaug( skill_lookup( "shockshield" ), ch->level, ch, ch );
			    }
			    else
				retcode = rNONE;
			    break;
                       case DFND_VENOMSHIELD:
                            if ( !IS_AFFECTED( ch, AFF_VENOMSHIELD ) )
                            {
                                act( AT_MAGIC, "$n utters a few incantations ...", ch, NULL, NULL, TO_ROOM );
                                retcode = spell_smaug( skill_lookup( "venomshield" ), ch->level, ch, ch );
                            }
                            else
                                retcode = rNONE;
                            break;
			case DFND_ACIDMIST:
			    if ( !IS_AFFECTED( ch, AFF_ACIDMIST ) )
			    {
				act( AT_MAGIC, "$n utters a few incantations ...", ch, NULL, NULL, TO_ROOM );
				retcode = spell_smaug( skill_lookup( "acidmist" ), ch->level, ch, ch );
			    }
			    else
				retcode = rNONE;
			    break;
			case DFND_FIRESHIELD:
			    if ( !IS_AFFECTED( ch, AFF_FIRESHIELD ) )
			    {
				act( AT_MAGIC, "$n utters a few incantations...", ch, NULL, NULL, TO_ROOM );
				retcode = spell_smaug( skill_lookup( "fireshield" ), ch->level, ch, ch );
			    }
			    else
				retcode = rNONE;
			    break;
			case DFND_ICESHIELD:
			    if ( !IS_AFFECTED( ch, AFF_ICESHIELD ) )
			    {
				act( AT_MAGIC, "$n utters a few incantations...", ch, NULL, NULL, TO_ROOM );
				retcode = spell_smaug( skill_lookup( "iceshield" ), ch->level, ch, ch );
			    }
			    else
				retcode = rNONE;
			    break;
			case DFND_TRUESIGHT:
			    if ( !IS_AFFECTED( ch, AFF_TRUESIGHT ) )
				retcode = spell_smaug( skill_lookup( "true" ), ch->level, ch, ch );
			    else
				retcode = rNONE;
			    break;
			case DFND_SANCTUARY:
			    if ( !IS_AFFECTED( ch, AFF_SANCTUARY ) )
			    {
				act( AT_MAGIC, "$n utters a few incantations...", ch, NULL, NULL, TO_ROOM );
				retcode = spell_smaug( skill_lookup( "sanctuary" ), ch->level, ch, ch );
			    }
			    else
				retcode = rNONE;
			    break;
		    }
		    if ( attacktype != -1 && (retcode == rCHAR_DIED || char_died(ch)) )
			continue;
		}
	    }
	}

	/*
	 * Fun for the whole family!
	 */
	for ( rch = ch->in_room->first_person; rch; rch = rch_next )
	{
	    rch_next = rch->next_in_room;

            /*
             *   Group Fighting Styles Support:
             *   If ch is tanking
             *   If rch is using a more aggressive style than ch
             *   Then rch is the new tank   -h
             */
            /* &&( is_same_group(ch, rch)      ) */

            if( ( !IS_NPC(ch) && !IS_NPC(rch) )
              &&( rch!=ch                     )
              &&( rch->fighting               )
              &&( who_fighting(rch->fighting->who) == ch    )
              &&( !xIS_SET( rch->fighting->who->act, ACT_AUTONOMOUS ) )
              &&( rch->style < ch->style      )
              )
            {
                 rch->fighting->who->fighting->who = rch; 

            }

	    if ( IS_AWAKE(rch) && !rch->fighting )
	    {
		/*
		 * PC's auto-assist others in their group.
		 */
		if ( !IS_NPC(ch) || IS_AFFECTED(ch, AFF_CHARM) )
		{
		    if ( ( ( !IS_NPC(rch) && rch->desc )
		    ||        IS_AFFECTED(rch, AFF_CHARM) )
		    && is_same_group(ch, rch)
		    && !is_safe( rch, victim, TRUE) )
			multi_hit( rch, victim, TYPE_UNDEFINED );
		    continue;
		}

		/*
		 * NPC's assist NPC's of same type or 12.5% chance regardless.
		 */
		if ( IS_NPC(rch) && !IS_AFFECTED(rch, AFF_CHARM)
		&&  !xIS_SET(rch->act, ACT_NOASSIST) )
		{
		    if ( char_died(ch) )
			break;
		    if ( rch->pIndexData == ch->pIndexData
		    ||   number_bits( 3 ) == 0 )
		    {
			CHAR_DATA *vch;
			CHAR_DATA *target;
			int number;

			target = NULL;
			number = 0;			
                        for ( vch = ch->in_room->first_person; vch; vch = vch->next )
			{
			    if ( can_see( rch, vch )
			    &&   is_same_group( vch, victim )
			    &&   number_range( 0, number ) == 0 )
			    {
				if ( vch->mount && vch->mount == rch )
				  target = NULL;
				else
				{
				  target = vch;
				  number++;
				}
			    }
			}

			if ( target )
			    multi_hit( rch, target, TYPE_UNDEFINED );
		    }
		}
	    }
	}
    }

    return;
}



/*
 * Do one group of attacks.
 */
ch_ret multi_hit( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
    int     chance;
    int	    dual_bonus;
    ch_ret  retcode;

    /* add timer to pkillers */
    if ( !IS_NPC(ch) && !IS_NPC(victim) )
    {
        if ( xIS_SET(ch->act, PLR_NICE) ) return rNONE;
        add_timer( ch,     TIMER_RECENTFIGHT, 30, NULL, 0 );
        add_timer( victim, TIMER_RECENTFIGHT, 30, NULL, 0 );
    }

    if ( is_attack_supressed( ch ) )
      return rNONE;

    if ( IS_NPC(ch) && xIS_SET(ch->act, ACT_NOATTACK) )
      return rNONE;

    if ( (retcode = one_hit( ch, victim, dt )) != rNONE )
      return retcode;

    if ( who_fighting( ch ) != victim || dt == gsn_backstab || dt == gsn_circle)
	return rNONE;
	
    /* Very high chance of hitting compared to chance of going berserk */
    /* 40% or higher is always hit.. don't learn anything here though. */
    /* -- Altrag */
    chance = IS_NPC(ch) ? 100 : (LEARNED(ch, gsn_berserk)*5/2);
    if ( IS_AFFECTED(ch, AFF_BERSERK) && number_percent() < chance )
      if ( (retcode = one_hit( ch, victim, dt )) != rNONE ||
            who_fighting( ch ) != victim )
        return retcode;

    if ( get_eq_char( ch, WEAR_DUAL_WIELD ) )
    {
      dual_bonus = IS_NPC(ch) ? (ch->level / 10) : (LEARNED(ch, gsn_dual_wield) / 10);
      chance = IS_NPC(ch) ? ch->level : LEARNED(ch, gsn_dual_wield);
      if ( number_percent( ) < chance )
      {
	learn_from_success( ch, gsn_dual_wield );
	retcode = one_hit( ch, victim, dt );
	if ( retcode != rNONE || who_fighting( ch ) != victim )
	    return retcode;
      }
      else
	learn_from_failure( ch, gsn_dual_wield );
    }
    else
      dual_bonus = 0;

    if ( ch->move < 10 )
      dual_bonus = -20;

    /*
     * NPC predetermined number of attacks			-Thoric
     */
    if ( IS_NPC(ch) && ch->numattacks > 0 )
    {
	for ( chance = 0; chance < ch->numattacks; chance++ )
	{
	   retcode = one_hit( ch, victim, dt );
	   if ( retcode != rNONE || who_fighting( ch ) != victim )
	     return retcode;
	}
	return retcode;
    }

    chance = IS_NPC(ch) ? ch->level
	   : (int) ((LEARNED(ch, gsn_second_attack)+dual_bonus)/1.5);
    if ( number_percent( ) < chance )
    {
	learn_from_success( ch, gsn_second_attack );
	retcode = one_hit( ch, victim, dt );
	if ( retcode != rNONE || who_fighting( ch ) != victim )
	    return retcode;
    }
    else
	learn_from_failure( ch, gsn_second_attack );

    chance = IS_NPC(ch) ? ch->level
	   : (int) ((LEARNED(ch, gsn_third_attack)+(dual_bonus*1.5))/2);
    if ( number_percent( ) < chance )
    {
	learn_from_success( ch, gsn_third_attack );
	retcode = one_hit( ch, victim, dt );
	if ( retcode != rNONE || who_fighting( ch ) != victim )
	    return retcode;
    }
    else
	learn_from_failure( ch, gsn_third_attack );

    chance = IS_NPC(ch) ? ch->level
	   : (int) ((LEARNED(ch, gsn_fourth_attack)+(dual_bonus*2))/3);
    if ( number_percent( ) < chance )
    {
	learn_from_success( ch, gsn_fourth_attack );
	retcode = one_hit( ch, victim, dt );
	if ( retcode != rNONE || who_fighting( ch ) != victim )
	    return retcode;
    }
    else
	learn_from_failure( ch, gsn_fourth_attack );

    chance = IS_NPC(ch) ? ch->level
	   : (int) ((LEARNED(ch, gsn_fifth_attack)+(dual_bonus*3))/4);
    if ( number_percent( ) < chance )
    {
	learn_from_success( ch, gsn_fifth_attack );
	retcode = one_hit( ch, victim, dt );
	if ( retcode != rNONE || who_fighting( ch ) != victim )
	    return retcode;
    }
    else
	learn_from_failure( ch, gsn_fifth_attack );

    retcode = rNONE;

    chance = IS_NPC(ch) ? (int) (ch->level / 2) : 0;
    if ( number_percent( ) < chance )
	retcode = one_hit( ch, victim, dt );

    if ( retcode == rNONE )
    {
	int move;

	if ( !IS_AFFECTED(ch, AFF_FLYING)
	&&   !IS_AFFECTED(ch, AFF_FLOATING) )
	  move = encumbrance( ch, movement_loss[UMIN(SECT_MAX-1, ch->in_room->sector_type)] );
	else
	  move = encumbrance( ch, 1 );
	if ( ch->move )
	  ch->move = UMAX( 0, ch->move - move );
    }
    return retcode;
}


/*
 * Weapon types, haus
 */
int weapon_prof_bonus_check( CHAR_DATA *ch, OBJ_DATA *wield, int *gsn_ptr )
{
    int bonus;

    bonus = 0;	*gsn_ptr = -1;
    if ( !IS_NPC(ch) && ch->level > 5 && wield )   
    {
	switch(wield->value[3])
	{
	   default:		*gsn_ptr = -1;			break;
           case DAM_HIT:
	   case DAM_SUCTION:
	   case DAM_BITE:
	   case DAM_BLAST:
           case DAM_SLASH:      break;
           case DAM_SLICE:	break;
           case DAM_PIERCE:     break;
           case DAM_STAB:	break;
           case DAM_WHIP:
           case DAM_CLAW:       break;
           case DAM_POUND:      break;
           case DAM_CRUSH:
	   case DAM_BOLT:       break;
	   case DAM_ARROW:
	   case DAM_DART:
	   case DAM_STONE:
	   case DAM_PEA:        break;

	}
	if ( *gsn_ptr != -1 )
	  bonus = (int) ((LEARNED(ch, *gsn_ptr) -50)/10);

       /* Reduce weapon bonuses for misaligned clannies.
       if ( IS_CLANNED(ch) )
       {
          bonus = bonus * 1000 / 
          ( 1 + abs( ch->alignment - ch->pcdata->clan->alignment ) );
       }*/

    }
    return bonus;
}

/*
 * Calculate the tohit bonus on the object and return RIS values.
 * -- Altrag
 */
int obj_hitroll( OBJ_DATA *obj )
{
	int tohit = 0;
	AFFECT_DATA *paf;
	
	for ( paf = obj->pIndexData->first_affect; paf; paf = paf->next )
		if ( paf->location == APPLY_HITROLL )
			tohit += paf->modifier;
	for ( paf = obj->first_affect; paf; paf = paf->next )
		if ( paf->location == APPLY_HITROLL )
			tohit += paf->modifier;
	return tohit;
}

/*
 * Offensive shield level modifier
 */
sh_int off_shld_lvl( CHAR_DATA *ch, CHAR_DATA *victim )
{
    sh_int lvl;

    if ( !IS_NPC(ch) )          /* players get much less effect */
    {
        lvl = UMAX( 1, (ch->level - 10) / 2 );
        if ( number_percent() + (victim->level - lvl) < 40 )
	{
	  if ( CAN_PKILL( ch ) && CAN_PKILL( victim ) )
	    return ch->level;
	  else
	    return lvl;
	}
        else
          return 0;
    }
    else
    {
	lvl = ch->level / 2;
	if ( number_percent() + (victim->level - lvl) < 70 )
	  return lvl;
	else
	  return 0;
    }
}

/*
 * Hit one guy once.
 */
ch_ret one_hit( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
    OBJ_DATA *wield;
    OBJ_DATA *obj;
    OBJ_DATA *pobj;
    long int victim_ac;
    long int thac0;
    long int thac0_00;
    long int thac0_32;
    long int plusris;
    long int dam;
    long int diceroll;
    int attacktype, cnt;
    long int	prof_bonus;
    int	prof_gsn = -1;
    ch_ret retcode = rNONE;
    static bool dual_flip = FALSE;
    int    strdown;
    int    condown;
    int    lckdown;
    int    dexdown;
    int    intdown;
    long extra;
    long var1;
    long var2;
    int charexp;
    int victexp;
    int spikes;
    int kamedam, kameextra, masdam, blastdam, scattdam, galicdam, charge_dam, mentaldam, clawdam, sbcdam, sbcextra,
        destructodam, kamedex, kamestr;
    int sbcint;
    int sbccon;
    int glowloss;
    int dammod;
    int chaextra;
    int weapondam;
    int defdown;
    int value1;
    int loss;
    int armordam;
    int altdam;
    
 
    dammod    = 1;
    weapondam = 0;
    glowloss  = 0;
    sbcint = 0;

    strdown  = (get_curr_str(victim) - get_curr_str(ch) );
    condown  = (get_curr_con(victim) - get_curr_con(ch) );
    lckdown  = (get_curr_lck(ch)*2 - get_curr_lck(victim)*2 );
    dexdown  = (get_curr_dex(victim)/2 - get_curr_dex(ch)/2 );
    defdown  = 10;
    intdown  = (get_curr_int(victim)/2 - get_curr_int(ch)/2 );

    var1 = 0;
    var2 = 0;

    if (IS_NPC(victim))
    var2 = victim->exp;
    else if (!IS_NPC(victim) && !xIS_SET(victim->act, PLR_SUPPRESS))
    var2 = victim->exp * victim->mod;

// dam  > 500000

    else if (!IS_NPC(victim) && xIS_SET(victim->act, PLR_SUPPRESS))
{
    if ( xIS_SET(victim->act, PLR_EBAR) && victim->barrier > victim->suppress)
    var2 = victim->barrier;
    else
    var2 = victim->suppress;
}

    if (IS_NPC(ch))
    var1 = ch->exp;
    else if (!IS_NPC(ch) && !xIS_SET(ch->act, PLR_SUPPRESS))
    var1 = ch->exp * ch->mod;
    else if (!IS_NPC(ch) && xIS_SET(ch->act, PLR_SUPPRESS))
    var1 = ch->suppress; 

/*    else if (!IS_NPC(ch) && xIS_SET(ch->act, PLR_SUPPRESS))
{
    if ( xIS_SET(ch->act, PLR_EBAR) && ch->barrier > ch->suppress)
    var1 = ch->barrier;
    else
    var1 = ch->suppress;
} */

    if(var2 != 0) 
    extra = (var1 / var2);
    else 
    extra = 0;
    
    if (extra < 0) 
     {
    extra = 0;
     } 

    /*
     * Can't beat a dead char!
     * Guard against weird room-leavings.
     */
    if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
	return rVICT_DIED;

    if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
    {
        if(dt != TYPE_KAME) return rVICT_DIED;
    }

    used_weapon = NULL;
    /*
     * Figure out the weapon doing the damage			-Thoric
     * Dual wield support -- switch weapons each attack
     */
    if ( (wield = get_eq_char( ch, WEAR_DUAL_WIELD )) != NULL )
    {
	if ( dual_flip == FALSE )
	{
	    dual_flip = TRUE;
	    wield = get_eq_char( ch, WEAR_WIELD );
	}
	else
	    dual_flip = FALSE;
    }
    else
	wield = get_eq_char( ch, WEAR_WIELD );

    used_weapon = wield;

/*    if ( wield )
        prof_bonus = weapon_prof_bonus_check( ch, wield, &prof_gsn );
    else
	prof_bonus = 0; */

    if ( ch->fighting		/* make sure fight is already started */
    &&   dt == TYPE_UNDEFINED
    &&   IS_NPC(ch)
    &&  !xIS_EMPTY(ch->attacks) )
    {
	cnt = 0;
	for ( ;; )
	{
	    attacktype = number_range( 0, 6 );
	    if ( xIS_SET( ch->attacks, attacktype ) )
		break;
	    if ( cnt++ > 16 )
 	    {
		attacktype = -1;
		break;
	    }
	}
	if ( attacktype == ATCK_BACKSTAB )
	    attacktype = -1;
	if ( wield && number_percent( ) > 25 )
	    attacktype = -1;
	if ( !wield && number_percent( ) > 50 )
	    attacktype = -1;

	switch ( attacktype )
	{
	    default:
		break;
	    case ATCK_BITE:
		do_bite( ch, "" );
		retcode = global_retcode;
		break;
	    case ATCK_CLAWS:
		do_claw( ch, "" );
		retcode = global_retcode;
		break;
            case ATCK_FINGERBEAM:
                do_fingerbeam( ch, "" );
                retcode = global_retcode;
                break;
	    case ATCK_TAIL:
		do_tail( ch, "" );
		retcode = global_retcode;
		break;
	    case ATCK_STING:
		do_sting( ch, "" );
		retcode = global_retcode;
		break;
	    case ATCK_PUNCH:
		do_punch( ch, "" );
		retcode = global_retcode;
		break;
	    case ATCK_KICK:
		do_kick( ch, "" );
		retcode = global_retcode;
		break;
	    case ATCK_TRIP:
		attacktype = 0;
		break;
	}
	if ( attacktype >= 0 )
	    return retcode;
    }

    if ( dt == TYPE_UNDEFINED )
    {
	dt = TYPE_HIT;
	if ( wield && wield->item_type == ITEM_WEAPON )
	    dt += wield->value[3];
    }

    if ( dt == TYPE_EYE ) { dt = TYPE_EYE;}
    if ( dt == TYPE_KAME ) { dt = TYPE_KAME;}
    if ( dt == TYPE_FKAME ) { dt = TYPE_FKAME;}
    if ( dt == TYPE_MASENKO ) { dt = TYPE_MASENKO;}
    if ( dt == TYPE_MENTALTHROW ) { dt = TYPE_MENTALTHROW;}
    if ( dt == TYPE_TRIBEAM ) { dt = TYPE_TRIBEAM;}
    if ( dt == TYPE_NBLAST ) { dt = TYPE_NBLAST;}
    if ( dt == TYPE_SCATTERSHOT ) { dt = TYPE_SCATTERSHOT;}
    if ( dt == TYPE_KICK)   { dt = TYPE_KICK;}
    if ( dt == TYPE_PUNCH)   { dt = TYPE_PUNCH;}
    if ( dt == TYPE_GALIC ) { dt = TYPE_GALIC;}
    if ( dt == TYPE_FINGER ) { dt = TYPE_FINGER;} 
    if ( dt == TYPE_DDD ) { dt = TYPE_DDD; charge_dam += ch->charge/15; }
    if ( dt == TYPE_BURN) { dt = TYPE_BURN; charge_dam += ch->charge/15;}
    if ( dt == TYPE_BURN2) { dt = TYPE_BURN; charge_dam += ch->charge/15;}
    if ( dt == TYPE_DOUBLEKICK ) { dt = TYPE_DOUBLEKICK;}
    if ( dt == TYPE_DOUBLEPUNCH ) { dt = TYPE_DOUBLEPUNCH;}
    if ( dt == TYPE_CLAW ) { dt = TYPE_CLAW;}
    if ( dt == TYPE_SBC ) { dt = TYPE_SBC;}
    if ( dt == TYPE_DESTRUCTO ) { dt = TYPE_DESTRUCTO; charge_dam += ch->charge/15;}

   if ( DAM_SLASH )
    dt == TYPE_HIT;


 chaextra = 0;

/* Cha Damage */
    if (ch->leader && (ch->in_room == ch->leader->in_room))
    {
      if (victim->leader && get_curr_cha(victim->leader) > get_curr_cha(victim))
      chaextra = get_curr_cha(ch->leader)/3.5 - get_curr_cha(victim->leader)/3.5;
      else
      chaextra = get_curr_cha(ch->leader)/3.5 - get_curr_cha(victim)/3.5;
    }

    dam += chaextra;


    /*
     * Calculate to-hit-armor-class-0 versus armor.
     */
    if ( IS_NPC(ch) )
    {
	thac0_00 = ch->mobthac0;
	thac0_32 =  0;
    }
    else
    {
	thac0_00 = class_table[ch->class]->thac0_00;
	thac0_32 = class_table[ch->class]->thac0_32;
    }
    thac0     = interpolate( ch->level, thac0_00, thac0_32 ) /* - GET_HITROLL(ch) */;
    victim_ac = UMAX( -19, (int) (GET_AC(victim) / 10) );

  /*  if ( wield && !can_see_obj( victim, wield) )
	victim_ac += 1;
    if ( !can_see( ch, victim ) )
	victim_ac -= 4;   */

    /*
     * "learning" between combatants.  Takes the intelligence difference,
     * and multiplies by the times killed to make up a learning bonus
     * given to whoever is more intelligent		-Thoric
     * (basically the more intelligent one "learns" the other's fighting style)
     */
/*    if ( ch->fighting && ch->fighting->who == victim )
    {
	sh_int times = ch->fighting->timeskilled;

	if ( times )
	{
	    sh_int intdiff = get_curr_int(ch) - get_curr_int(victim);

	    if ( intdiff != 0 )
		victim_ac += (intdiff*times)/10;
	}
    } */

    /* Weapon proficiency bonus */
/*    victim_ac += prof_bonus; */

    /*
     * The moment of excitement!
     */
/*    while ( ( diceroll = number_bits( 5 ) ) >= 20 ) ; */

/*           if ( dexdown < 5 && dexdown > 0 )
        diceroll = number_range(1,7);
  else if ( dexdown < 10 && dexdown >= 5 )
        diceroll = number_range(1,5);
  else if ( dexdown < 15 && dexdown >= 10 )
        diceroll = number_range(1,4);
  else if ( dexdown < 20 && dexdown >= 15 )
        diceroll = number_range(1,3);
  else  */
        diceroll = number_range(1,9);

    if ( diceroll == 2 && dt == TYPE_HIT )
    {
	/* Miss. */
	if ( prof_gsn != -1 )
	    learn_from_failure( ch, prof_gsn );
	damage( ch, victim, 0, dt );
	tail_chain( );
	return rNONE;
    }


    /*
     * Hit.
     * Calc damage.
     */

     if ( !wield )       
	dam = number_range( ch->barenumdie, ch->baresizedie * extra );
    else 
        dam = number_range( ch->barenumdie, ch->baresizedie * extra + 1 ); 

    if ( dam  > 500000 )
                dam = 500000;

/*Extra PL Damage*/
    dam += extra;
    dam += chaextra;

if ( !IS_NPC(victim) )

{

    if ( victim->armor > 125 )
   weapondam = 0;

  else if ( victim->armor > 100 && victim->armor < 125 )
   weapondam = 1;

  else if ( victim->armor < 75 && victim->armor < 100 )
   weapondam = 2;

   else
   weapondam = 3;

}

  if ( IS_NPC(victim ) )
   weapondam = 0;




 if ( IS_NPC(ch) && !IS_NPC(victim) )
{

    if ( victim->armor > 109 )
   armordam = 0;

  else if ( victim->armor > 107 && victim->armor < 109 )
   armordam = 1;

  else if ( victim->armor < 101 && victim->armor < 107 )
   armordam = 2;

   else
   armordam = 3;

   if ( extra == 1 )
    extra = 0;

    if ( get_curr_str(ch) > 29 )
    dam = 8 + extra + chaextra + armordam;
    else if ( get_curr_str(ch) > 26 )
    dam = 7 + extra + chaextra + armordam;
    else if ( get_curr_str(ch) > 24 )
    dam = 6 + extra + chaextra + armordam;
    else if ( get_curr_str(ch) > 20 )
    dam = 5 + extra + chaextra + armordam;
    else if ( get_curr_str(ch) >= 15 )
    dam = 4 + extra + chaextra + armordam;
    else if ( get_curr_str(ch) >= 12 )
    dam = 3 + extra + chaextra + armordam;
    else if ( get_curr_str(ch) >= 9 )
    dam = 2 + extra + chaextra + armordam;
    else
    dam = 1 + extra + chaextra + armordam;

}


 if ( !IS_NPC(ch) )
{

  if ( IS_NPC(victim) )
  {

     obj=get_eq_char(ch, WEAR_WIELD);

     if ( !wield )
        altdam = 0;
    else
        altdam = number_range( 0,  obj->value[1] / 10);

  }
      else
        altdam = 0;



   if ( extra == 1 )
    extra = 0;

    if ( get_curr_str(ch) > 34 )
    dam = 5;
    else if ( get_curr_str(ch) > 24 )
    dam = 4;
    else if ( get_curr_str(ch) > 20 )
    dam = 3;
    else if ( get_curr_str(ch) >= 15 )
    dam = 2;
    else if ( get_curr_str(ch) >= 12 )
    dam = 1;
    else if ( get_curr_str(ch) >= 9 )
    dam = 1;
    else
    dam = 1; 

    if ( dam == 6 )
     {
     if ( number_range( 1, 2) == 1 )
     dam = 11 + extra + chaextra + weapondam + altdam;
     else
     dam = 6 + extra + chaextra + weapondam + altdam;
     }

    if ( dam == 5 )
     {
     if ( number_range( 1, 2) == 1 )
     dam = 10 + extra + chaextra + weapondam + altdam;
     else
     dam = 8 + extra + chaextra + weapondam + altdam;
     } 

 else if ( dam == 4 )
     {
     if ( number_range( 1, 2) == 1 )
     dam = 9 + extra + chaextra + weapondam + altdam;
     else
     dam = 7 + extra + chaextra + weapondam + altdam;
     }

 else if ( dam == 3 )
     {
     if ( number_range( 1, 2) == 1 )
     dam = 8 + extra + chaextra + weapondam + altdam;
     else
     dam = 6 + extra + chaextra + weapondam + altdam;
     }

 else if ( dam == 2 )
     {
     if ( number_range( 1, 2) == 1 )
     dam = 7 + extra + chaextra + weapondam + altdam;
     else
     dam = 5 + extra + chaextra + weapondam + altdam;
     }

 else if ( dam == 1 )
     {
     if ( number_range( 1, 2) == 1 )
     dam = 4 + extra + chaextra + weapondam + altdam;
     else
     dam = 2 + extra + chaextra + weapondam + altdam;
     } 

    for ( pobj = victim->first_carrying; pobj; pobj = pobj->next_content )
    {
        if ( pobj->pIndexData->vnum == 3703 )
        dam *= 2.2;
     else if ( pobj->pIndexData->vnum == 3704 )
        dam *= 2.2;
    }


}    

    /*
     * Bonuses.
     */

    if ( IS_NPC(victim) )
//    dam += GET_DAMROLL(ch); 

    /*
     * Calculate Damage Modifiers from Victim's Fighting Style
     */
/*    if ( victim->position == POS_BERSERK )
       dam = 1 * dam;
    else if ( victim->position == POS_AGGRESSIVE )
       dam = 1 * dam;
    else if ( victim->position == POS_DEFENSIVE )
       dam = 1 * dam;
    else if ( victim->position == POS_EVASIVE )
       dam = 1 * dam; */

    /*
     * Calculate Damage Modifiers from Attacker's Fighting Style
     */
/*    if ( ch->position == POS_BERSERK )
       dam = 1 * dam;
    else if ( ch->position == POS_AGGRESSIVE )
       dam = 1 * dam;
    else if ( ch->position == POS_DEFENSIVE )
       dam = 1 * dam;
    else if ( ch->position == POS_EVASIVE )
       dam = 1 * dam; */

/* SBC damage */
/*    sbcdam = number_range(15, 24);
    sbcextra = get_curr_int(ch) - get_curr_int(victim);
    sbcdam += sbcextra;
    if (dt == TYPE_SBC)
    dam = sbcdam + extra; */

    sbcint = get_curr_int(ch) - get_curr_int(victim);
    sbccon = get_curr_con(ch) - get_curr_con(victim);
    sbcdam = number_range(10, 20);
    sbcextra = sbccon + sbcint / 2;
    sbcdam += sbcextra;
    if (dt == TYPE_SBC)
    dam = sbcdam + extra;


/* Kame Damage */
    kamedex = get_curr_dex(ch) - get_curr_dex(victim);
    kamestr = get_curr_str(ch) - get_curr_str(victim);
    kamedam = number_range(10, 20);
    kameextra = kamedex + kamestr / 2;
    kamedam += kameextra;
    if (dt == TYPE_KAME)
    dam = kamedam + extra;

/* Blast Damage */
    blastdam = number_range(2, 6);
    if ( dt == TYPE_NBLAST)
    dam = blastdam + extra;

/* Tribeam Damage */
    if ( dt == TYPE_TRIBEAM )
    dam = number_range(17, 28) + extra;

/* Scattershot Damage */
    if (IS_NAMEK(ch) || IS_BIODROID(ch) )
    scattdam = number_range(12, 20);
    else if (IS_MUTANT(ch) && xIS_SET(ch->act, PLR_SECONDARY_CORTEX) )
    scattdam = number_range( get_curr_dex(ch) + 10, 44 );
    else 
    scattdam = number_range( get_curr_dex(ch)/1.5, 29 );
    if ( dt == TYPE_SCATTERSHOT) 
    dam = scattdam + extra;

/* Galic Damage */
   if ( ch->mana < ch->max_mana / 1.4 )
    loss = 8;
 else if ( ch->mana < ch->max_mana / 1.3 )
    loss = 6;
 else if ( ch->mana < ch->max_mana / 1.2 )
    loss = 4;
 else if ( ch->mana < ch->max_mana / 1.1 )
    loss = 2;
 else if ( ch->mana < ch->max_mana / 1 )
    loss = 0;
    else
    loss = 0;
 

    if ( dt == TYPE_GALIC && ch == victim )
    galicdam = 0;
    else
    galicdam = number_range(30, 50 );

    if ( dt == TYPE_GALIC && ch != victim )
    dam = galicdam + extra - loss;
    if ( dt == TYPE_GALIC && ch == victim )
    dam = galicdam;

/* Claw Damage */
    clawdam = number_range( dam + 1, dam + 3 );
    if ( dt == TYPE_CLAW )
    dam = clawdam + extra + chaextra;

/* Doublepunch Damage */
    if ( dt == TYPE_DOUBLEPUNCH )
    {
    value1 = get_curr_str(ch) + get_curr_int(ch);
    if ( number_range( 1, 3 ) == 1 )
    dam = number_range( value1/6.4, value1/5 ) + extra + chaextra;
if ( number_range( 1, 3 ) == 2 )
    dam = number_range( value1/6.4, value1/5 ) + extra + chaextra;
if ( number_range( 1, 3 ) == 3 )
    dam = number_range( value1/6.4, value1/4.4 ) + extra + chaextra;
    dam = dam*2;
    }

/* Punch / Kick Damage */
    if ( dt == TYPE_PUNCH )
    dam = dam + extra;
    if ( dt == TYPE_KICK )
    dam = dam + extra;

/* Doublekick Damage */
    if ( dt == TYPE_DOUBLEKICK )
    {
    value1 = get_curr_str(ch) + get_curr_int(ch);
    if ( number_range( 1, 3 ) == 1 )
    dam = number_range( value1/6.4, value1/5 ) + extra + chaextra;
if ( number_range( 1, 3 ) == 2 )
    dam = number_range( value1/6.4, value1/5 ) + extra + chaextra;
if ( number_range( 1, 3 ) == 3 )
    dam = number_range( value1/6.4, value1/4.4 ) + extra + chaextra;
    dam = dam*2;
    }

/* Mental Damage */
       mentaldam = number_range( 24+get_curr_int(ch)/2, 54);
    if ( dt == TYPE_MENTALTHROW)
    dam = mentaldam;

/* Fingerbeam Damage */
    if ( dt == TYPE_FINGER )
    {
/*    value1 = get_curr_str(ch) + get_curr_int(ch);
    dam = number_range( value1 / 8, value1 / 4 );  */
    dam = dam+2;
    }

/* Masenko Damage */
    masdam = number_range(12, 21);
    if ( dt == TYPE_MASENKO )
    dam = masdam + extra;

/* Destructo Damage */
    if ( dt == TYPE_DESTRUCTO )
    {
    charge_dam = ch->charge/7;
    dam = dam + extra + charge_dam;
    dam += get_curr_con(ch) / 5;
    }

/* Energy Sphere Damage */
    if ( dt == TYPE_BURN )
    {
    charge_dam = ch->charge/10;
    dam = dam + extra + charge_dam;
    dam = number_range( dam-2, dam+2 );
    }

/* Energy Ball Damage */
    if ( dt == TYPE_BURN2 )
    {
    charge_dam = ch->charge/14;
    dam = dam + extra + charge_dam;
    dam = number_range( dam, dam+3 );
    }

/* Dual Destructo damage */
    if ( dt == TYPE_DDD )
    {
    charge_dam = ch->charge/number_range(3, 4);
    dam = dam + extra + charge_dam;
    dam += get_curr_con(ch) / 5 + 2;
    }

/* Eyebeam Damage */
    if ( dt == TYPE_EYE )
    {
    value1 = get_curr_str(ch) + get_curr_int(ch);
    if ( number_range( 1, 5 ) == 1 )
    dam = number_range( value1/6.4, value1/5 ) + extra + chaextra;
if ( number_range( 1, 5 ) == 2 )
    dam = number_range( value1/6.4, value1/5 ) + extra + chaextra;
if ( number_range( 1, 5 ) == 3 )
    dam = number_range( value1/6.4, value1/5 ) + extra + chaextra;
if ( number_range( 1, 5 ) == 4 )
    dam = number_range( value1/6.4, value1/5 ) + extra + chaextra;
if ( number_range( 1, 5 ) == 5 )
    dam = number_range( value1/6.4, value1/4.4 ) + extra + chaextra + get_curr_lck(ch)/10;
    dam = dam*2;
    }

     if ( chance( ch, dexdown ) && ( (dt >= TYPE_HIT) ) )
     {
       act( AT_GREEN, "You dodge $n's attack.", ch, NULL, victim, TO_VICT);
       act( AT_GREEN, "$N dodges your attack.", ch, NULL, victim, TO_CHAR);
       act( AT_GREEN, "$N dodges $n's attack.", ch, NULL, victim, TO_NOTVICT );

       dam = 0;
       damage( ch, victim, 0, dt );
       return rNONE;
     }

   else if ( chance( ch, intdown/2 ) && (dt >= TYPE_HIT) )
     {
       act( AT_GREEN, "You anticipate $n's attack.", ch, NULL, victim, TO_VICT);
       act( AT_GREEN, "$N anticipates your attack.", ch, NULL, victim, TO_CHAR);
       act( AT_GREEN, "$N anticipates $n's attack.", ch, NULL, victim, TO_NOTVICT );
       dam = 0;
       damage( ch, victim, 0, dt );
       return rNONE;
     }

/*    else if ( chance ( ch, lckdown*2 ) &&  ( ( dt == TYPE_HIT) || (dt > TYPE_HIT) || (dt == TYPE_PUNCH) || (dt == 
TYPE_KICK) ))
    {
       act( AT_GREEN, "$N hits you in the right place." , victim, NULL, ch, TO_CHAR );
       act( AT_GREEN, "You hit $N in the right place.", ch, NULL, victim, TO_CHAR );
       act( AT_GREEN, "$n hits $N in the right place.", ch, NULL, victim, TO_NOTVICT );
       dam *= 1.5;
    } */

    else if ( chance ( ch, 10 ) && get_curr_lck(ch) > get_curr_lck(victim) && ( ( dt == TYPE_HIT) || (dt > TYPE_HIT)   || (dt == TYPE_PUNCH) || (dt ==TYPE_KICK) ))
    {
       act( AT_GREEN, "$N hits you in the right place." , victim, NULL, ch, TO_CHAR );
       act( AT_GREEN, "You hit $N in the right place.", ch, NULL, victim, TO_CHAR );
       act( AT_GREEN, "$n hits $N in the right place.", ch, NULL, victim, TO_NOTVICT );
       dam += lckdown/5;
    } 

    else if ( chance ( victim, strdown ) &&  ( ( dt == TYPE_HIT) || (dt > TYPE_HIT) || (dt == TYPE_PUNCH) || (dt ==TYPE_KICK) ))
    {
       act( AT_GREEN, "$N's attack loses power on your well built body." , victim, NULL, ch, TO_CHAR );
       act( AT_GREEN, "Your attack loses power on $N's well built body.", ch, NULL, victim, TO_CHAR );
       act( AT_GREEN, "$n's attack loses power on $N's well built body.", ch, NULL, victim, TO_NOTVICT );
       dam -= 1;
    }

   else if ( victim->style == STYLE_DEFENSIVE && dt >= TYPE_HIT )
   {
       act( AT_GREEN, "You block $N's attack." , victim, NULL, ch, TO_CHAR );
       act( AT_GREEN, "$N blocks your attack.", ch, NULL, victim, TO_CHAR );
       act( AT_GREEN, "$N blocks $n's attack.", ch, NULL, victim, TO_NOTVICT );
       if ( !IS_NPC(victim) )
       dam -= 1;
       else
       dam /= 2;

       if ( IS_NPC(ch) && dt >= TYPE_HIT )
       glowloss = 10;
       if ( IS_NPC(ch) && ch->exp >= 50000000 )
       glowloss = 450;

       victim->mana -= glowloss;

      if (victim->mana <= 0 && !IS_NPC(victim))
         {
      act( AT_ACTION, "$n loses conciousness as their energy is drained.", victim, NULL, NULL, TO_ROOM );
      act( AT_HURT, "You lose conciousness as your energy is drained.", victim, NULL, NULL, TO_CHAR );
      victim->hit = -1;
      victim->mana = 0;
      update_pos( ch );

         }

   }


    else if ( chance ( ch, lckdown*2 ) && ( (dt == TYPE_CLAW) || (dt == TYPE_EYE) || (dt ==TYPE_FINGER) ) || (dt ==TYPE_DOUBLEPUNCH) || (dt == TYPE_DOUBLEKICK) )
    {
       dam *= 1.3;
    } 

    if ( IS_MUTANT(ch) && xIS_SET(ch->act, PLR_SECONDARY_SPIKES) && ( ( dt == TYPE_HIT) || (dt > TYPE_HIT) || (dt > TYPE_CLAW) ))
    {

      dam += 1;
    }

    if ( IS_MUTANT(victim) && xIS_SET(victim->act, PLR_SECONDARY_ULTRABODY) && ( (dt >= TYPE_HIT) ||  (dt == TYPE_DOUBLEKICK) || (dt == TYPE_CLAW) || (dt == TYPE_EYE) || (dt == TYPE_FINGER) ))
    {
       dam -= 1;
    }

/*    if ( IS_MUTANT(ch) && xIS_SET(ch->act, PLR_SECONDARY_ULTRABODY) && ( (dt >= TYPE_HIT) ||  (dt ==TYPE_DOUBLEKICK)    
|| (dt == TYPE_CLAW) || (dt == TYPE_EYE) || (dt == TYPE_FINGER) ))
    {
       dam += .8;
    } */

    if ( IS_MUTANT(victim) && xIS_SET(victim->act, PLR_PRIMARY_STONESKIN) && (dt >= TYPE_HIT || dt == TYPE_EYE || dt == TYPE_FINGER || dt == TYPE_DOUBLEKICK || dt == TYPE_DOUBLEPUNCH || dt == TYPE_CLAW  || dt == TYPE_PUNCH || dt == TYPE_KICK ) )
    {
       dam -= 2;
    }

    if ( IS_MUTANT(victim) && xIS_SET(victim->act, PLR_SECONDARY_KICONTROL) && (dt == TYPE_KAME || dt == TYPE_GALIC || dt == TYPE_BURN || dt == TYPE_DDD || dt == TYPE_MENTALTHROW || dt == TYPE_SCATTERSHOT  || dt == TYPE_TRIBEAM || dt == TYPE_MASENKO || dt == TYPE_SBC ) )
    {
       dam -= number_range( 5, get_curr_int(victim)/2 );
    }

    if ( IS_MUTANT(victim) && xIS_SET(victim->act, PLR_SECONDARY_IMPROVEDSKIN) && (dt >= TYPE_HIT || dt == TYPE_EYE || dt == TYPE_FINGER || dt == TYPE_DOUBLEKICK || dt == TYPE_DOUBLEPUNCH || dt == TYPE_CLAW || dt == TYPE_PUNCH || dt == TYPE_KICK ) )
    {
//       dam /= 1.1;
         dam -= 1;
    } 
 
    if ( IS_NPC(victim) &&  (dt != TYPE_HIT && dt != TYPE_KICK && dt != TYPE_PUNCH && dt != TYPE_CLAW && dt != TYPE_FINGER && dt != TYPE_DOUBLEKICK && dt != TYPE_DOUBLEPUNCH && dt != TYPE_EYE ) )
    {
      dam /= 2;
    }

       if ( victim->hit < 20 && !IS_NPC(victim) )
        {
if ( number_range( 1, 6 ) == 1 )
    dam += 1;
if ( number_range( 1, 6 ) == 2 )
    dam += 0;
if ( number_range( 1, 6 ) == 3 )
    dam += 2;
if ( number_range( 1, 6 ) == 4 )
    dam += 0;
if ( number_range( 1, 6 ) == 5 )
    dam += 0;
if ( number_range( 1, 6 ) == 6 )
    dam += 1;
         }

    if ( xIS_SET(victim->act, PLR_EBAR) && (dt >= TYPE_HIT || dt == TYPE_CLAW || dt == TYPE_EYE || dt == TYPE_DOUBLEPUNCH || dt == TYPE_DOUBLEKICK )  )
    {
       act( AT_RED, "$N's attack damages your energy barrier." , victim, NULL, ch, TO_CHAR );
       act( AT_RED, "Your attack damages $N's energy barrier.", ch, NULL, victim, TO_CHAR );
       act( AT_RED, "$n's attack damages $N's energy barrier.", ch, NULL, victim, TO_NOTVICT );
       if ( victim->barrier >= victim->maxbarrier / 1.5 )
//       dam /= 1.4;
       
         dam -= 2;
       else if ( victim->barrier >= victim->maxbarrier / 2.2 )
         dam -= 1;
//       dam /= 1.2;
       else
       dam -= 0;
       victim->barrier -= victim->maxbarrier / 25;

       if ( victim->barrier <= 0 )
       {
       act( AT_RED, "$N's attack SHATTERS your energy barrier!" , victim, NULL, ch, TO_CHAR );
       act( AT_RED, "Your attack SHATTERS $N's energy barrier!", ch, NULL, victim, TO_CHAR );
       act( AT_RED, "$n's attack SHATTERS $N's energy barrier!", ch, NULL, victim, TO_NOTVICT );
       xREMOVE_BIT(victim->act, PLR_EBAR);
       victim->barrier = 0;
       }
       
    }


      if (number_percent() < 91 && ( obj = get_obj_wear( victim, "Blue Barrier B1" ) ) && ((dt == TYPE_DDD) || (dt == 
TYPE_KAME ) || (dt == TYPE_TRIBEAM) || (dt == TYPE_MASENKO) || (dt == TYPE_GALIC ) || (dt == TYPE_MENTALTHROW) || (dt 
== TYPE_SBC) || (dt == TYPE_NBLAST) || (dt == TYPE_BURN) || (dt == TYPE_SCATTERSHOT) || (dt == TYPE_BURN2) ) )
{
       act( AT_BLUE, "Your blue barrier partially absorbs $N's attack." , victim, NULL, ch, TO_CHAR );
       act( AT_BLUE, "$N's blue barrier partially absorbs your attack.", ch, NULL, victim, TO_CHAR );
       act( AT_BLUE, "$N's blue barrier partially absorbs $n's attack.", ch, NULL, victim, TO_NOTVICT );
       dam = dam/2.2;
    }
    else if ( obj = get_obj_wear( victim, "Blue Barrier B1" ) && ((dt == TYPE_DDD) || (dt == TYPE_KAME ) || (dt == 
TYPE_TRIBEAM) || (dt == TYPE_MASENKO) || (dt == TYPE_GALIC ) || (dt == TYPE_MENTALTHROW) || (dt == TYPE_SBC) || (dt == 
TYPE_NBLAST) || (dt == TYPE_BURN) || (dt == TYPE_SCATTERSHOT) || (dt == TYPE_BURN2) )  )
    {
       act( AT_BLUE, "$N's attack pierces your blue barrier." , victim, NULL, ch, TO_CHAR );
       act( AT_BLUE, "Your attack pierces $N's blue barrier.", ch, NULL, victim, TO_CHAR );
       act( AT_BLUE, "$n's attack pierces $N's blue barrier.", ch, NULL, victim, TO_NOTVICT );
    }


   if ( xIS_SET(victim->act, PLR_SUPPRESS ))
    victexp = victim->suppress;
    else
    victexp = victim->exp * victim->mod;

   if ( xIS_SET(ch->act, PLR_SUPPRESS ) )
    charexp = ch->suppress;
    else
    charexp = ch->exp * ch->mod;

    if ( !IS_NPC(victim) && !IS_NPC(ch) )
      {

          if ( charexp < victexp / 5 )
            dam -= 14;
     else if ( charexp < victexp / 4 )
            dam -= 10;
     else if ( charexp < victexp / 3.5 )
            dam -= 8;
     else if ( charexp < victexp / 3 )
            dam -= 6;
     else if ( charexp < victexp / 2 )
            dam -= 4;
     else if ( charexp < victexp / 1.4 )
            dam -= 3;
     else if ( charexp < victexp / 1.3 )
            dam -= 2;
     else if ( charexp < victexp / 1.2 )
            dam -= 1;
          else
            dam -= 0;
       }

/*    if ( !IS_NPC(victim) && !IS_NPC(ch) )
      {

          if ( charexp < victexp / 5 )
            dam -= 14;
     else if ( charexp < victexp / 4 )
            dam -= 10;
     else if ( charexp < victexp / 3.5 )
            dam -= 8;
     else if ( charexp < victexp / 3 )
            dam -= 6;
     else if ( charexp < victexp / 2 )
            dam -= 4;
     else if ( charexp < victexp / 1.4 )
            dam -= 3;
     else if ( charexp < victexp / 1.3 )
            dam -= 2;
     else if ( charexp < victexp / 1.2 )
            dam -= 1;
          else
            dam -= 0;
       } */

     if ( IS_SAIYAN(ch) )
       {
       dam += 1;
       }

     if ( IS_BIODROID(ch) )
       {
       dam += 1;
       }

//   if ( ch->style == STYLE_DEFENSIVE && (( dt >= TYPE_HIT) || (dt == TYPE_CLAW) || (dt == TYPE_FINGER) || (dt == TYPE_PUNCH) ) )
//    {
//       dam /= 1.2;
//         dam -= 1;
//    }


   if ( victim->style == STYLE_DEFENSIVE && victexp < charexp && ((dt == TYPE_DDD) || (dt == TYPE_KAME ) || (dt == TYPE_TRIBEAM) || (dt == TYPE_MASENKO) || (dt == TYPE_GALIC ) || (dt == TYPE_MENTALTHROW) || (dt == TYPE_SBC) || (dt == TYPE_SCATTERSHOT)) )
    {
       dam /= 1.7;
    }


   if ( victim->style == STYLE_DEFENSIVE && victexp < charexp && ((dt == TYPE_PUNCH) || (dt == TYPE_KICK ) || (dt ==TYPE_CLAW) || (dt == TYPE_DOUBLEKICK) || (dt == TYPE_DOUBLEPUNCH) || (dt == TYPE_EYE) || (dt == TYPE_FINGER)  ) )
    {
       dam /= 1.2;
    }

   if ( victim->style == STYLE_DEFENSIVE && dt >= TYPE_HIT && victexp < charexp )
    {
/*       act( AT_GREEN, "You glow up and block $N's attack." , victim, NULL, ch, TO_CHAR );
       act( AT_GREEN, "$N glows up and blocks your attack.", ch, NULL, victim, TO_CHAR );
       act( AT_GREEN, "$N glows up and blocks $n's attack.", ch, NULL, victim, TO_NOTVICT ); */
       victim->mana -= victim->max_mana / 200;

      if (victim->mana <= 0 && !IS_NPC(victim))
         {
      act( AT_ACTION, "$n loses conciousness as their energy is drained.", victim, NULL, NULL, TO_ROOM );
      act( AT_HURT, "You lose conciousness as your energy is drained.", victim, NULL, NULL, TO_CHAR );
      victim->hit = -1;
      victim->mana = 0;
      update_pos( ch );

         }

    }

   else if ( victim->style == STYLE_DEFENSIVE && dt != TYPE_HIT && victexp > charexp )
    {
//       if ( dt >= TYPE_HIT )
//       dam /= 1.5;
//       dam -= 1;
       if ( dt == TYPE_DOUBLEKICK )
       dam /= 2;
       else if ( dt == TYPE_DOUBLEKICK )
       dam /= 2;
       else if ( dt == TYPE_PUNCH )
       dam -= 2;
       else if ( dt == TYPE_PUNCH )
       dam -= 2;
       else
       dam /= 3;

       if ( IS_NPC(ch) && dt >= TYPE_HIT )
       glowloss = 10;
       if ( IS_NPC(ch) && ch->exp >= 50000000 )
       glowloss = 450;

       if ( dt == TYPE_NBLAST )
       glowloss = victim->max_mana / 49;
       if ( dt == TYPE_SCATTERSHOT )
       glowloss = victim->max_mana / 12;
       if ( dt == TYPE_SCATTERSHOT && xIS_SET(ch->act, PLR_SECONDARY_CORTEX) )
       glowloss = victim->max_mana / 10;
       if ( dt == TYPE_KICK )
       glowloss = victim->max_mana / 58;
       if ( dt == TYPE_PUNCH )
       glowloss = victim->max_mana / 58;
       if ( dt == TYPE_FINGER )
       glowloss = victim->max_mana / 58;
       if ( dt == TYPE_DOUBLEPUNCH )
       glowloss = victim->max_mana / 32;
       if ( dt == TYPE_DOUBLEKICK )
       glowloss = victim->max_mana / 32;
       if ( dt == TYPE_EYE )
       glowloss = victim->max_mana / 32;
       if ( dt >= TYPE_HIT && !IS_NPC(ch) )
       glowloss = victim->max_mana / 58;


       act( AT_GREEN, "You glow up and block $N's attack." , victim, NULL, ch, TO_CHAR );
       act( AT_GREEN, "$N glows up and blocks your attack.", ch, NULL, victim, TO_CHAR );
       act( AT_GREEN, "$N glows up and blocks $n's attack.", ch, NULL, victim, TO_NOTVICT );
       victim->mana -= glowloss;

      if (victim->mana <= 0 && !IS_NPC(victim))
         {
      act( AT_ACTION, "$n loses conciousness as their energy is drained.", victim, NULL, NULL, TO_ROOM );
      act( AT_HURT, "You lose conciousness as your energy is drained.", victim, NULL, NULL, TO_CHAR );
      victim->hit = -1;
      victim->mana = 0;
      update_pos( ch );

         }
}

    if ( !IS_NPC(ch) && ch->pcdata->learned[gsn_enhanced_damage] > 0 )
    {
	dam += (int) (dam * LEARNED(ch, gsn_enhanced_damage) / 120);
	learn_from_success( ch, gsn_enhanced_damage );
    }


    if ( victim->position == POS_SLEEPING )
        dam *= 2;
    if ( victim->position == POS_RESTING )
        dam *= 1.5;
    if ( !IS_AWAKE(victim) )
	dam *= 1;
    if ( dt == gsn_backstab )
	dam *= (2 + URANGE( 2, ch->level - (victim->level/4), 30 ) / 8);
 
    if ( dt == gsn_circle )
 	dam *= (2 + URANGE( 2, ch->level - (victim->level/4), 30 ) / 16); 

    if ( dam <= 0 )
	dam = 1;

    plusris = 0;


/*    if ( wield )
    {
	if ( IS_OBJ_STAT(wield, ITEM_MAGIC) )
 	    dam = ris_damage( victim, dam, RIS_MAGIC );
	else
	    dam = ris_damage( victim, dam, RIS_NONMAGIC );

	plusris = obj_hitroll( wield );
    }
    else
	dam = ris_damage( victim, dam, RIS_NONMAGIC );  */

    /* check for RIS_PLUSx 					-Thoric */
    if ( dam )
    {
	int x, res, imm, sus, mod;

	if ( plusris )
	   plusris = RIS_PLUS1 << UMIN(plusris, 7);

	/* initialize values to handle a zero plusris */
	imm = res = -1;  sus = 1;

	/* find high ris */
	for ( x = RIS_PLUS1; x <= RIS_PLUS6; x <<= 1 )
	{
	    if ( IS_SET( victim->immune, x ) )
		imm = x;
	    if ( IS_SET( victim->resistant, x ) )
		res = x;
	    if ( IS_SET( victim->susceptible, x ) )
		sus = x;
	}
	mod = 10;
	if ( imm >= plusris )
	    mod -= 10;
	if ( res >= plusris )
	    mod -= 2;
	if ( sus <= plusris )
	    mod += 2;

	/* check if immune */
	if ( mod <= 0 )
	    dam = -1;
	if ( mod != 10 )
	    dam = (dam * mod) / 10;
    }

    if ( prof_gsn != -1 )
    {
	if ( dam > 0 )
	    learn_from_success( ch, prof_gsn );
	else
	    learn_from_failure( ch, prof_gsn );
    }

    /* immune to damage */
    if ( dam == -1 )
    {
	if ( dt >= 0 && dt < top_sn )
	{
	    SKILLTYPE *skill = skill_table[dt];
	    bool found = FALSE;

	    if ( skill->imm_char && skill->imm_char[0] != '\0' )
	    {
		act( AT_HIT, skill->imm_char, ch, NULL, victim, TO_CHAR );
		found = TRUE;
	    }
	    if ( skill->imm_vict && skill->imm_vict[0] != '\0' )
	    {
		act( AT_HITME, skill->imm_vict, ch, NULL, victim, TO_VICT );
		found = TRUE;
	    }
	    if ( skill->imm_room && skill->imm_room[0] != '\0' )
	    {
		act( AT_ACTION, skill->imm_room, ch, NULL, victim, TO_NOTVICT );
		found = TRUE;
	    }
	    if ( found )
	      return rNONE;
	}
	dam = 0;
    }
    if ( (retcode = damage( ch, victim, dam, dt )) != rNONE )
	return retcode;
    if ( char_died(ch) )
	return rCHAR_DIED;
    if ( char_died(victim) )
	return rVICT_DIED;

    retcode = rNONE;
    if ( dam == 0 )
	return retcode;

    /*
     * Weapon spell support				-Thoric
     * Each successful hit casts a spell
     */
    if ( wield
    &&  !IS_SET(victim->immune, RIS_MAGIC)
    &&  !xIS_SET(victim->in_room->room_flags, ROOM_NO_MAGIC) )
    {
	AFFECT_DATA *aff;
	
	for ( aff = wield->pIndexData->first_affect; aff; aff = aff->next )
	   if ( aff->location == APPLY_WEAPONSPELL
	   &&   IS_VALID_SN(aff->modifier)
	   &&   skill_table[aff->modifier]->spell_fun )
		retcode = (*skill_table[aff->modifier]->spell_fun) ( aff->modifier, (wield->level+3)/3, ch, victim );
	if ( retcode != rNONE || char_died(ch) || char_died(victim) )
		return retcode;
	for ( aff = wield->first_affect; aff; aff = aff->next )
	   if ( aff->location == APPLY_WEAPONSPELL
	   &&   IS_VALID_SN(aff->modifier)
	   &&   skill_table[aff->modifier]->spell_fun )
		retcode = (*skill_table[aff->modifier]->spell_fun) ( aff->modifier, (wield->level+3)/3, ch, victim );
	if ( retcode != rNONE || char_died(ch) || char_died(victim) )
		return retcode;
    }

    /*
     * magic shields that retaliate				-Thoric
     */
    if ( IS_AFFECTED( victim, AFF_FIRESHIELD )
    &&  !IS_AFFECTED( ch, AFF_FIRESHIELD ) )
	retcode = spell_smaug( skill_lookup( "flare" ), off_shld_lvl(victim, ch), victim, ch );
    if ( retcode != rNONE || char_died(ch) || char_died(victim) )
      return retcode;

    if ( IS_AFFECTED( victim, AFF_ICESHIELD )
    &&  !IS_AFFECTED( ch, AFF_ICESHIELD ) )
         retcode = spell_smaug( skill_lookup( "iceshard" ), off_shld_lvl(victim, ch), victim, ch );
    if ( retcode != rNONE || char_died(ch) || char_died(victim) )
      return retcode;

    if ( IS_AFFECTED( victim, AFF_SHOCKSHIELD )
    &&  !IS_AFFECTED( ch, AFF_SHOCKSHIELD ) )
	retcode = spell_smaug( skill_lookup( "torrent" ), off_shld_lvl(victim, ch), victim, ch );
    if ( retcode != rNONE || char_died(ch) || char_died(victim) )
      return retcode;

    if ( IS_AFFECTED( victim, AFF_ACIDMIST )
    &&  !IS_AFFECTED( ch, AFF_ACIDMIST ) )
	retcode = spell_smaug( skill_lookup( "acidshot" ), off_shld_lvl(victim, ch), victim, ch );
    if ( retcode != rNONE || char_died(ch) || char_died(victim) )
	return retcode;

    if ( IS_AFFECTED( victim, AFF_VENOMSHIELD )
    &&  !IS_AFFECTED( ch, AFF_VENOMSHIELD ) )
        retcode = spell_smaug( skill_lookup( "venomshot" ), off_shld_lvl(victim, ch), victim, ch );
    if ( retcode != rNONE || char_died(ch) || char_died(victim) )
        return retcode;    

    tail_chain( );
    return retcode;
}

/*
 * Hit one guy with a projectile.
 * Handles use of missile weapons (wield = missile weapon)
 * or thrown items/weapons
 */
ch_ret projectile_hit( CHAR_DATA *ch, CHAR_DATA *victim, OBJ_DATA *wield,
		       OBJ_DATA *projectile, sh_int dist )
{
    int victim_ac;
    int thac0;
    int thac0_00;
    int thac0_32;
    int plusris;
    int dam;
    int diceroll;
    int	prof_bonus;
    int	prof_gsn = -1;
    int proj_bonus;
    int dt;
    ch_ret retcode;

    if ( !projectile )
	return rNONE;

    if ( projectile->item_type == ITEM_PROJECTILE 
    ||   projectile->item_type == ITEM_WEAPON )
    {
	dt = TYPE_HIT + projectile->value[3];
	proj_bonus = number_range(projectile->value[1], projectile->value[2]);
    }
    else
    {
	dt = TYPE_UNDEFINED;
	proj_bonus = number_range(1, URANGE(2, get_obj_weight(projectile), 100) );
    }

    /*
     * Can't beat a dead char!
     */
    if ( victim->position == POS_DEAD || char_died(victim) )
    {
	extract_obj(projectile);
	return rVICT_DIED;
    }

/*    if ( wield )
        prof_bonus = weapon_prof_bonus_check( ch, wield, &prof_gsn );
    else
        prof_bonus = 0; */

    if ( dt == TYPE_UNDEFINED )
    {
	dt = TYPE_HIT;
	if ( wield && wield->item_type == ITEM_MISSILE_WEAPON )
	    dt += wield->value[3];
    }

    /*
     * Calculate to-hit-armor-class-0 versus armor.
     */
    if ( IS_NPC(ch) )
    {
	thac0_00 = ch->mobthac0;
	thac0_32 =  0;
    }
    else
    {
	thac0_00 = class_table[ch->class]->thac0_00;
	thac0_32 = class_table[ch->class]->thac0_32;
    }
   thac0     = interpolate( ch->level, thac0_00, thac0_32 ) /* - GET_HITROLL(ch) */ + (dist*2);
    victim_ac = UMAX( -19, (int) (GET_AC(victim) / 10) ); 

    /* if you can't see what's coming... */
    if ( !can_see_obj( victim, projectile) )
	victim_ac += 1;
    if ( !can_see( ch, victim ) )
	victim_ac -= 4;

    /* Weapon proficiency bonus */
//    victim_ac += prof_bonus;

    /*
     * The moment of excitement!
     */
    while ( ( diceroll = number_bits( 5 ) ) >= 20 )
	;

    if ( diceroll == 0
    || ( diceroll != 19 && diceroll < thac0 - victim_ac ) )
    {
	/* Miss. */
	if ( prof_gsn != -1 )
	    learn_from_failure( ch, prof_gsn );

	/* Do something with the projectile */
	if ( number_percent() < 50 )
	    extract_obj(projectile);
	else
	{
	    if ( projectile->in_obj )
		obj_from_obj(projectile);
	    if ( projectile->carried_by )
		obj_from_char(projectile);
	    obj_to_room(projectile, victim->in_room);
	}
	damage( ch, victim, 0, dt );
	tail_chain( );
	return rNONE;
    }

        dam = GET_DAMROLL(ch);


    /*
     * Bonuses.
     */
//    dam += GET_DAMROLL(ch);

/*    if ( prof_bonus )
        dam += prof_bonus / 4; */

    /*
     * Calculate Damage Modifiers from Victim's Fighting Style
     */
    if ( victim->position == POS_BERSERK )
       dam = 1.2 * dam;
    else if ( victim->position == POS_AGGRESSIVE )
       dam = 1.1 * dam;
    else if ( victim->position == POS_DEFENSIVE )
       dam = .2 * dam;
    else if ( victim->position == POS_EVASIVE )
       dam = .8 * dam;

    if ( !IS_NPC(ch) && ch->pcdata->learned[gsn_enhanced_damage] > 0 )
    {
	dam += (int) (dam * LEARNED(ch, gsn_enhanced_damage) / 120);
	learn_from_success( ch, gsn_enhanced_damage );
    }

    if ( !IS_AWAKE(victim) )
	dam *= 2;

    if ( dam <= 0 )
	dam = 1;

    plusris = 0;

    if ( IS_OBJ_STAT(projectile, ITEM_MAGIC) )
	dam = ris_damage( victim, dam, RIS_MAGIC );
    else
	dam = ris_damage( victim, dam, RIS_NONMAGIC );

    /*
     * Handle PLUS1 - PLUS6 ris bits vs. weapon hitroll	-Thoric
     */
    if ( wield )
	plusris = obj_hitroll( wield );

    /* check for RIS_PLUSx 					-Thoric */
    if ( dam )
    {
	int x, res, imm, sus, mod;

	if ( plusris )
	   plusris = RIS_PLUS1 << UMIN(plusris, 7);

	/* initialize values to handle a zero plusris */
	imm = res = -1;  sus = 1;

	/* find high ris */
	for ( x = RIS_PLUS1; x <= RIS_PLUS6; x <<= 1 )
	{
	   if ( IS_SET( victim->immune, x ) )
		imm = x;
	   if ( IS_SET( victim->resistant, x ) )
		res = x;
	   if ( IS_SET( victim->susceptible, x ) )
		sus = x;
	}
	mod = 10;
	if ( imm >= plusris )
	  mod -= 10;
	if ( res >= plusris )
	  mod -= 2;
	if ( sus <= plusris )
	  mod += 2;

	/* check if immune */
	if ( mod <= 0 )
	  dam = -1;
	if ( mod != 10 )
	  dam = (dam * mod) / 10;
    }

    if ( prof_gsn != -1 )
    {
      if ( dam > 0 )
        learn_from_success( ch, prof_gsn );
      else
        learn_from_failure( ch, prof_gsn );
    }

    /* immune to damage */
    if ( dam == -1 )
    {
	if ( dt >= 0 && dt < top_sn )
	{
	    SKILLTYPE *skill = skill_table[dt];
	    bool found = FALSE;

	    if ( skill->imm_char && skill->imm_char[0] != '\0' )
	    {
		act( AT_HIT, skill->imm_char, ch, NULL, victim, TO_CHAR );
		found = TRUE;
	    }
	    if ( skill->imm_vict && skill->imm_vict[0] != '\0' )
	    {
		act( AT_HITME, skill->imm_vict, ch, NULL, victim, TO_VICT );
		found = TRUE;
	    }
	    if ( skill->imm_room && skill->imm_room[0] != '\0' )
	    {
		act( AT_ACTION, skill->imm_room, ch, NULL, victim, TO_NOTVICT );
		found = TRUE;
	    }
	    if ( found )
	    {
		if ( number_percent() < 50 )
		    extract_obj(projectile);
		else
		{
		    if ( projectile->in_obj )
			obj_from_obj(projectile);
		    if ( projectile->carried_by )
			obj_from_char(projectile);
		    obj_to_room(projectile, victim->in_room);
		}
		return rNONE;
	    }
	}
	dam = 0;
    }
    if ( (retcode = damage( ch, victim, dam, dt )) != rNONE )
    {
	extract_obj(projectile);
	return retcode;
    }
    if ( char_died(ch) )
    {
	extract_obj(projectile);
	return rCHAR_DIED;
    }
    if ( char_died(victim) )
    {
	extract_obj(projectile);
	return rVICT_DIED;
    }

    retcode = rNONE;
    if ( dam == 0 )
    {
	if ( number_percent() < 50 )
	    extract_obj(projectile);
	else
	{
	    if ( projectile->in_obj )
		obj_from_obj(projectile);
	    if ( projectile->carried_by )
		obj_from_char(projectile);
	    obj_to_room(projectile, victim->in_room);
	}
	return retcode;
    }

/* weapon spells	-Thoric */
    if ( wield
    &&  !IS_SET(victim->immune, RIS_MAGIC)
    &&  !xIS_SET(victim->in_room->room_flags, ROOM_NO_MAGIC) )
    {
	AFFECT_DATA *aff;
	
	for ( aff = wield->pIndexData->first_affect; aff; aff = aff->next )
	   if ( aff->location == APPLY_WEAPONSPELL
	   &&   IS_VALID_SN(aff->modifier)
	   &&   skill_table[aff->modifier]->spell_fun )
		retcode = (*skill_table[aff->modifier]->spell_fun) ( aff->modifier, (wield->level+3)/3, ch, victim );
	if ( retcode != rNONE || char_died(ch) || char_died(victim) )
	{
	    extract_obj(projectile);
	    return retcode;
	}
	for ( aff = wield->first_affect; aff; aff = aff->next )
	   if ( aff->location == APPLY_WEAPONSPELL
	   &&   IS_VALID_SN(aff->modifier)
	   &&   skill_table[aff->modifier]->spell_fun )
		retcode = (*skill_table[aff->modifier]->spell_fun) ( aff->modifier, (wield->level+3)/3, ch, victim );
	if ( retcode != rNONE || char_died(ch) || char_died(victim) )
	{
	    extract_obj(projectile);
	    return retcode;
	}
    }

    extract_obj(projectile);

    tail_chain( );
    return retcode;
}

/*
 * Calculate damage based on resistances, immunities and suceptibilities
 *					-Thoric
 */
sh_int ris_damage( CHAR_DATA *ch, int dam, int ris )
{
   sh_int modifier;

   modifier = 10;
   if ( IS_SET(ch->immune, ris )  && !IS_SET(ch->no_immune, ris) )
     modifier -= 10;
   if ( IS_SET(ch->resistant, ris ) && !IS_SET(ch->no_resistant, ris) )
     modifier -= 2;
   if ( IS_SET(ch->susceptible, ris ) && !IS_SET(ch->no_susceptible, ris) )
   {
     if ( IS_NPC( ch )
     &&   IS_SET( ch->immune, ris ) )
	modifier += 0;
     else
	modifier += 2;
   }
   if ( modifier <= 0 )
     return -1;
   if ( modifier == 10 )
     return dam;
   return (dam * modifier) / 10;
}


/*
 * Inflict damage from a hit.   This is one damn big function.
 */
ch_ret damage( CHAR_DATA *ch, CHAR_DATA *victim, long int dam, int dt )
{
          OBJ_DATA *obj;
    char buf[MAX_STRING_LENGTH];
    char buf1[MAX_STRING_LENGTH];
    char filename[256]; 
    int dameq;
    long int maxdam;
    bool npcvict;
    bool loot;
    int  xp_gain;
    int chance;
    OBJ_DATA *damobj;
    ch_ret retcode;
    int dampmod;
    CHAR_DATA *gch /*, *lch */;
    int init_gold, new_gold, gold_diff;
    int anopc = 0;  /* # of (non-pkill) pc in a (ch) */
    int bnopc = 0;  /* # of (non-pkill) pc in b (victim) */

    retcode = rNONE;

    if ( !ch )
    {
	bug( "Damage: null ch!", 0 );
	return rERROR;
    }
    if ( !victim )
    {
	bug( "Damage: null victim!", 0 );
	return rVICT_DIED;
    }

    if ( victim->position == POS_DEAD )
	return rVICT_DIED;

    npcvict = IS_NPC(victim);

    /*
     * Check damage types for RIS				-Thoric
     */
    if ( dam && dt != TYPE_UNDEFINED )
    {
	if ( IS_FIRE(dt) )
	  dam = ris_damage(victim, dam, RIS_FIRE);
	else
	if ( IS_COLD(dt) )
	  dam = ris_damage(victim, dam, RIS_COLD);
	else
	if ( IS_ACID(dt) )
	  dam = ris_damage(victim, dam, RIS_ACID);
	else
	if ( IS_ELECTRICITY(dt) )
	  dam = ris_damage(victim, dam, RIS_ELECTRICITY);
	else
	if ( IS_ENERGY(dt) )
	  dam = ris_damage(victim, dam, RIS_ENERGY);
	else
	if ( IS_DRAIN(dt) )
	  dam = ris_damage(victim, dam, RIS_DRAIN);
	else
	if ( dt == gsn_poison || IS_POISON(dt) )
	  dam = ris_damage(victim, dam, RIS_POISON);
	else
	if ( dt == (TYPE_HIT + DAM_POUND) || dt == (TYPE_HIT + DAM_CRUSH)
	||   dt == (TYPE_HIT + DAM_STONE) || dt == (TYPE_HIT + DAM_PEA) )
	  dam = ris_damage(victim, dam, RIS_BLUNT);
	else
	if ( dt == (TYPE_HIT + DAM_STAB) || dt == (TYPE_HIT + DAM_PIERCE)
	||   dt == (TYPE_HIT + DAM_BITE) || dt == (TYPE_HIT + DAM_BOLT)
	||   dt == (TYPE_HIT + DAM_DART) || dt == (TYPE_HIT + DAM_ARROW) )
	  dam = ris_damage(victim, dam, RIS_PIERCE);
	else
	if ( dt == (TYPE_HIT + DAM_SLICE) || dt == (TYPE_HIT + DAM_SLASH)
	||   dt == (TYPE_HIT + DAM_WHIP)  || dt == (TYPE_HIT + DAM_CLAW) )
	  dam = ris_damage(victim, dam, RIS_SLASH);

	if ( dam == -1 )
	{
	    if ( dt >= 0 && dt < top_sn )
	    {
		bool found = FALSE;
		SKILLTYPE *skill = skill_table[dt];

		if ( skill->imm_char && skill->imm_char[0] != '\0' )
		{
		   act( AT_HIT, skill->imm_char, ch, NULL, victim, TO_CHAR );
		   found = TRUE;
		}
		if ( skill->imm_vict && skill->imm_vict[0] != '\0' )
		{
		   act( AT_HITME, skill->imm_vict, ch, NULL, victim, TO_VICT );
		   found = TRUE;
		}
		if ( skill->imm_room && skill->imm_room[0] != '\0' )
		{
		   act( AT_ACTION, skill->imm_room, ch, NULL, victim, TO_NOTVICT );
		   found = TRUE;
		}
		if ( found )
		   return rNONE;
	    }
	    dam = 0;
	}
    }

    /*
     * Precautionary step mainly to prevent people in Hell from finding
     * a way out. --Shaddai
     */
    if ( xIS_SET(victim->in_room->room_flags, ROOM_SAFE) )
	dam = 0;

    if ( dam && npcvict && ch != victim )
    {
	if ( !xIS_SET( victim->act, ACT_SENTINEL ) )
 	{
	    if ( victim->hunting )
	    {
		if ( victim->hunting->who != ch )	
		{
		    STRFREE( victim->hunting->name );
		    victim->hunting->name = QUICKLINK( ch->name );
		    victim->hunting->who  = ch;
		}
            }
	    else
            if ( !xIS_SET(victim->act, ACT_PACIFIST)  ) /* Gorog */
		start_hunting( victim, ch );
	}

	if ( victim->hating )
	{
   	    if ( victim->hating->who != ch )
 	    {
		STRFREE( victim->hating->name );
		victim->hating->name = QUICKLINK( ch->name );
		victim->hating->who  = ch;
	    }
	}
	else
	if ( !xIS_SET(victim->act, ACT_PACIFIST)  ) /* Gorog */
	    start_hating( victim, ch );
    }

    /*
     * Stop up any residual loopholes.
     */


      maxdam = 700000000;

   if ( dam > maxdam )
    { 
/*	sprintf( buf, "Damage: %d more than %d points!", dam, maxdam );
	bug( buf, dam );
	sprintf(buf, "** %s (lvl %d) -> %s **",
		ch->name,
		ch->level,
	        victim->name);
	bug( buf, 0 );  */
	dam = maxdam;
    } 

    if (victim != ch)
    {
	/*
	 * Certain attacks are forbidden.
	 * Most other attacks are returned.
	 */
	if (is_safe(ch, victim, TRUE))
	    return rNONE;
	check_attacker(ch, victim);

	if (victim->position > POS_STUNNED)
	{
	    if (!victim->fighting && victim->in_room == ch->in_room)
		set_fighting(victim, ch);

            /*
               vwas: victim->position = POS_FIGHTING;
             */
            if ( IS_NPC(victim) && victim->fighting )
                victim->position = POS_FIGHTING;
            else if (victim->fighting)
                victim->position = POS_FIGHTING; 

/*	    else if (victim->fighting)
	    {

		switch (victim->style)
		{
		    case (STYLE_EVASIVE):
			victim->position = POS_EVASIVE;
			break;
		    case (STYLE_DEFENSIVE):
			victim->position = POS_DEFENSIVE;
			break;
		    case (STYLE_AGGRESSIVE):
			victim->position = POS_AGGRESSIVE;
			break;
		    case (STYLE_BERSERK):
			victim->position = POS_BERSERK;
			break;
		    default:
			victim->position = POS_FIGHTING;
		} 

	    } */

	}

	if (victim->position > POS_STUNNED)
	{
	    if (!ch->fighting && victim->in_room == ch->in_room)
		set_fighting(ch, victim);

	    /*
	     * If victim is charmed, ch might attack victim's master.
	     */
	    if (IS_NPC(ch)
		&& npcvict
		&& IS_AFFECTED(victim, AFF_CHARM)
		&& victim->master
		&& victim->master->in_room == ch->in_room
		&& number_bits(3) == 0)
	    {
		stop_fighting(ch, FALSE);
		retcode = multi_hit(ch, victim->master, TYPE_UNDEFINED);
		return retcode;
	    }
	}


	/*
	 * More charm stuff.
	 */
 	if (victim->master == ch && !xIS_SET(ch->act, PLR_SPLIT_FORM) )
	    stop_follower(victim);

	/*
	 * Pkill stuff.  If a deadly attacks another deadly or is attacked by
	 * one, then ungroup any nondealies.  Disabled untill I can figure out
	 * the right way to do it.
	 */


	/*
	   count the # of non-pkill pc in a ( not including == ch ) 
	 */
	for (gch = ch->in_room->first_person; gch; gch = gch->next_in_room)
	    if (is_same_group(ch, gch) && !IS_NPC(gch)
		&& !IS_PKILL(gch) && (ch != gch))
		anopc++;

	/*
	   count the # of non-pkill pc in b ( not including == victim ) 
	 */
	for (gch = victim->in_room->first_person; gch; gch = gch->next_in_room)
	    if (is_same_group(victim, gch) && !IS_NPC(gch)
		&& !IS_PKILL(gch) && (victim != gch))
		bnopc++;


	/*
	   only consider disbanding if both groups have 1(+) non-pk pc,
	   or when one participant is pc, and the other group has 1(+)
	   pk pc's (in the case that participant is only pk pc in group) 
	 */
	if ((bnopc > 0 && anopc > 0)
	    || (bnopc > 0 && !IS_NPC(ch))
	    || (anopc > 0 && !IS_NPC(victim)))
	{
	    /*
	       Disband from same group first 
	     */
	    if (is_same_group(ch, victim))
	    {
		/*
		   Messages to char and master handled in stop_follower 
		 */
		act(AT_ACTION, "$n disbands from $N's group.",
		    (ch->leader == victim) ? victim : ch, NULL,
		    (ch->leader == victim) ? victim->master : ch->master,
		    TO_NOTVICT);
		if (ch->leader == victim)
		    stop_follower(victim);
		else
		    stop_follower(ch);
	    }
	    /*
	       if leader isnt pkill, leave the group and disband ch 
	     */
	    if (ch->leader != NULL && !IS_NPC(ch->leader) &&
		!IS_PKILL(ch->leader))
	    {
		act(AT_ACTION, "$n disbands from $N's group.", ch, NULL,
		    ch->master, TO_NOTVICT);
		stop_follower(ch);
	    }
	    else
	    {
		for (gch = ch->in_room->first_person; gch; gch = gch->next_in_room)
		    if (is_same_group(gch, ch) && !IS_NPC(gch) &&
			!IS_PKILL(gch) && gch != ch)
		    {
			act(AT_ACTION, "$n disbands from $N's group.", ch, NULL,
			    gch->master, TO_NOTVICT);
			stop_follower(gch);
		    }
	    }
	    /*
	       if leader isnt pkill, leave the group and disband victim 
	     */
	    if (victim->leader != NULL && !IS_NPC(victim->leader) &&
		!IS_PKILL(victim->leader))
	    {
		act(AT_ACTION, "$n disbands from $N's group.", victim, NULL,
		    victim->master, TO_NOTVICT);
		stop_follower(victim);
	    }
	    else
	    {
		for (gch = victim->in_room->first_person; gch; gch = gch->next_in_room)
		    if (is_same_group(gch, victim) && !IS_NPC(gch) &&
			!IS_PKILL(gch) && gch != victim)
		    {
			act(AT_ACTION, "$n disbands from $N's group.", gch, NULL,
			    gch->master, TO_NOTVICT);
			stop_follower(gch);
		    }
	    }
	}

	/*
	 * Inviso attacks ... not.
	 */
	if (IS_AFFECTED(ch, AFF_INVISIBLE))
	{
	    affect_strip(ch, gsn_invis);
	    affect_strip(ch, gsn_mass_invis);
	    xREMOVE_BIT(ch->affected_by, AFF_INVISIBLE);
	    act(AT_MAGIC, "$n fades into existence.", ch, NULL, NULL, TO_ROOM);
	}

	/* Take away Hide */
	if (IS_AFFECTED(ch, AFF_HIDE))
	    xREMOVE_BIT(ch->affected_by, AFF_HIDE);
	/*
	 * Damage modifiers.
	 */
	if (IS_AFFECTED(victim, AFF_SANCTUARY))
	    dam /= 2;

        if (IS_AFFECTED(victim, AFF_SHELL))
            dam /= 1.5;

	if (IS_AFFECTED(victim, AFF_PROTECT) && IS_EVIL(ch))
	    dam -= (int) (dam / 4);

	if (dam < 0)
	    dam = number_range(10000, 20000); 


	/*
	 * Check for disarm, trip, parry, dodge and tumble.
	 */
	if (dt >= TYPE_HIT && ch->in_room == victim->in_room)
	{
	    if (IS_NPC(ch)
		&& xIS_SET(ch->defenses, DFND_DISARM)
		&& ch->level > 9
		&& number_percent() < ch->level / 3) /* Was 2 try this --Shaddai*/
		disarm(ch, victim);

	    if (IS_NPC(ch)
		&& xIS_SET(ch->attacks, ATCK_TRIP)
		&& ch->level > 5
		&& number_percent() < ch->level / 2)
		trip(ch, victim);

/*	    if (check_parry(ch, victim))
		return rNONE;
	    if (check_dodge(ch, victim))
		return rNONE;
	    if (check_tumble(ch, victim))
		return rNONE; */
	}

	/*
	 * Check control panel settings and modify damage
	 */
	if (IS_NPC(ch))
	{
	    if (npcvict)
		dampmod = sysdata.dam_mob_vs_mob;
	    else
		dampmod = sysdata.dam_mob_vs_plr;
	}
	else
	{
	    if (npcvict)
		dampmod = sysdata.dam_plr_vs_mob;
	    else
		dampmod = sysdata.dam_plr_vs_plr;
	}
	if (dampmod > 0 && dampmod != 100 )
	    dam = (dam * dampmod) / 100;

	dam_message(ch, victim, dam, dt);
    }

    /*
     * Code to handle equipment getting damaged, and also support  -Thoric
     * bonuses/penalties for having or not having equipment where hit
     */
/*    if (dam > 10 && dt != TYPE_UNDEFINED)
   {
	dameq  = number_range(WEAR_LIGHT, WEAR_EYES);
	damobj = get_eq_char(victim, dameq);
	if ( damobj )
	{
	    if ( dam > get_obj_resistance(damobj)
	    &&   number_bits(1) == 0 )
	    {
		set_cur_obj(damobj);
		damage_obj(damobj);
	    }
	    dam -= 0;
	}
	else
	    dam += 0; 
    } */

    /*
     * Hurt the victim.
     * Inform the victim of his new state.
     */
    victim->hit -= dam;

    /*
     * Get experience based on % of damage done			-Thoric
     */
/*
    if ( dam && ch != victim
    &&  !IS_NPC(ch) && ch->fighting && ch->fighting->xp )
    {
	if ( ch->fighting->who == victim )
	    xp_gain = (int) (ch->fighting->xp * dam) / victim->max_hit;
	else
	    xp_gain = (int) (xp_compute( ch, victim ) * 0.85 * dam) / victim->max_hit;
	if ( dt == gsn_backstab || dt == gsn_circle )
	    xp_gain = 0;
	gain_exp( ch, xp_gain );
    }

*/

    if ( !IS_NPC(victim)
    &&   victim->level >= LEVEL_IMMORTAL
    && !xIS_SET(victim->act, PLR_SEMI)
    &&   victim->hit < 1)
       victim->hit = 1;

    /* Make sure newbies dont die */

    if (!IS_NPC(victim) && NOT_AUTHED(victim) && victim->hit < 1)
	victim->hit = 1;

    if ( victim->hit < 1 && !IS_NPC(victim) && xIS_SET(victim->in_room->room_flags, ROOM_KOTH))
    {
        stop_fighting( victim, TRUE );
        victim->hit = -1;
        act( AT_ACTION, "$n is stunned, but will probably recover.", victim, NULL, NULL, TO_ROOM );
        act( AT_HURT, "You are stunned, but will probably recover.", victim, NULL, NULL, TO_CHAR );
        update_pos( victim );
        char_from_room( victim );
        char_to_room( victim, get_room_index( KOTH_LOSER_ROOM ));
        sprintf( buf, "&C[&cGameinfo&C]&Y %s&B has been stunned by&Y %s&B in the King of the Hill!", victim->name, ch->name);
        victim->hit = victim->max_hit;
        ch->hit = victim->max_hit;
        update_pos(victim);
        talk_games( AT_BLUE, buf);
        return rNONE;
    }

    if ( victim->hit < 1 && !IS_NPC(victim) && xIS_SET(victim->in_room->room_flags, ROOM_KOTH2))
    {
        stop_fighting( victim, TRUE );
        victim->hit = -1;
        act( AT_ACTION, "$n is stunned, but will probably recover.", victim, NULL, NULL, TO_ROOM );
        act( AT_HURT, "You are stunned, but will probably recover.", victim, NULL, NULL, TO_CHAR );
        update_pos( victim );
        char_from_room( victim );
        char_to_room( victim, get_room_index( 3401 ));
        sprintf( buf, "&C[&cGameinfo&C]&Y %s&B has been knocked off the hill by&Y %s&B!", victim->name, ch->name);
        talk_games( AT_BLUE, buf);
        return rNONE;
    }

    if ( victim->hit < 1 && !IS_NPC(victim) && xIS_SET(victim->in_room->room_flags, ROOM_TOURNY))
    {
        stop_fighting( victim, TRUE );
        victim->hit = -1;
        act( AT_ACTION, "$n is stunned, but will probably recover.", victim, NULL, NULL, TO_ROOM );
        act( AT_HURT, "You are stunned, but will probably recover.", victim, NULL, NULL, TO_CHAR );
        update_pos( victim );
        char_from_room( victim );
        char_to_room( victim, get_room_index( 40 ));
        sprintf( buf, "&C[&cGameinfo&C]&Y %s&B moves on to the next round&B!", ch->name);
        victim->hit = 100;
        update_pos( victim );
        talk_games( AT_BLUE, buf);
        return rNONE;
    }

      if ( ( carrying_dball(victim) || carrying_dball(ch) ) && !IS_NPC(victim) &&  victim->hit < 1 )
    {

        do_drop( victim, "dragonball" );
        do_drop( victim, "dragonball" );
        do_drop( victim, "dragonball" );
        do_drop( victim, "dragonball" );
        do_drop( victim, "dragonball" );
        do_drop( victim, "dragonball" );
        do_drop( victim, "dragonball" );

        stop_fighting( victim, TRUE );
        victim->hit = -1;
        act( AT_ACTION, "$n is stunned, but will probably recover.", victim, NULL, NULL, TO_ROOM );
        act( AT_HURT, "You are stunned, but will probably recover.", victim, NULL, NULL, TO_CHAR );
        update_pos(victim);

     }

    if ( victim->hit < -4 && !IS_NPC(victim) && xIS_SET(victim->in_room->room_flags, ROOM_HBTC))
    {
        int chance;

        char_from_room( ch );
        char_to_room( ch, get_room_index( 1107 ) );
        chance = number_range( 0, 5 );
        if ( chance == 0 )
        sprintf( buf1, "shown no mercy on" );
        else if ( chance = 1 )
        sprintf( buf1, "&zslaughtered&D" );
        else if ( chance = 2 )
        sprintf( buf1, "shown no mercy on" );
        else if ( chance = 3 )
        sprintf( buf1, "destroyed" );
        else if ( chance = 4 )
        sprintf( buf1, "OWNED" );
        else
        sprintf( buf1, "&Rann&rihil&Rated&D" );

        sprintf( buf, "&z[&WInfo&z]&C %s&W has %s&C %s&W inside the HBTC!&D", ch->name, buf1, victim->name);
        talk_info( AT_BLUE, buf);
        game_state = HBTC_NONE;
    }

    if ( victim->hit < 1 && !IS_NPC(victim) && xIS_SET(victim->in_room->room_flags, ROOM_CTF))
    {
        stop_fighting( victim, TRUE );
        victim->hit = -1;
        int vnum;
        vnum = 3700;
        if ( ( obj = get_eq_char( victim, WEAR_LIGHT ) ) != NULL )
        {
            int objvnum;

            objvnum = obj->pIndexData->vnum;
            if ( objvnum != 3701 && objvnum != 3702 )
            vnum = 3700;
            else if ( objvnum == 3701 )
            {
              vnum = 3701;
              do_drop( victim, "red flag" );
            }
            else if ( objvnum == 3702 )
            {
              vnum = 3723;
              do_drop(victim, "blue flag" );
            }
        }
        else 
        vnum = 3700;
        act( AT_ACTION, "$n is stunned, but will probably recover.", victim, NULL, NULL, TO_ROOM );
        act( AT_HURT, "You are stunned, but will probably recover.", victim, NULL, NULL, TO_CHAR );
        update_pos( victim );
        char_from_room( victim );
        char_to_room( victim, get_room_index( vnum ));
        victim->hit = 100;
        ch->hit = 100;
        update_pos(victim);
        return rNONE;
    }

    if ( dam > 0 && dt > TYPE_HIT
    &&  !IS_AFFECTED( victim, AFF_POISON )
    &&   is_wielding_poisoned( ch )
    &&  !IS_SET( victim->immune, RIS_POISON )
    &&  !saves_poison_death( ch->level, victim ) )
    {
	AFFECT_DATA af;

	af.type      = gsn_poison;
	af.duration  = 20;
	af.location  = APPLY_STR;
	af.modifier  = -2;
	af.bitvector = meb(AFF_POISON);
	affect_join( victim, &af );
	victim->mental_state = URANGE( 20, ch->mental_state + (IS_PKILL(ch) ? 1 : 2), 100 );
    }

    /*
     * Vampire self preservation				-Thoric
     */
    if ( IS_VAMPIRE(victim) )
    {
      if ( dam >= (victim->max_hit / 10) )	/* get hit hard, lose blood */
	gain_condition(victim, COND_BLOODTHIRST, -1 - (victim->level / 20));
      if ( victim->hit <= (victim->max_hit / 8)
      && victim->pcdata->condition[COND_BLOODTHIRST]>5 )
      {
	gain_condition(victim, COND_BLOODTHIRST,
		-URANGE(3, victim->level / 10, 8) );
	victim->hit += URANGE( 4, (victim->max_hit / 30), 15);
	set_char_color(AT_BLOOD, victim);
	send_to_char("You howl with rage as the beast within stirs!\n\r", victim);
      }
    }

     if ( victim->hit < 1 && !IS_NPC(victim) && xIS_SET(ch->act, PLR_SPAR) && xIS_SET(victim->in_room->room_flags,ROOM_SPAR))
     {
      act( AT_ACTION, "$n is stunned, but will probably recover.", victim, NULL, NULL, TO_ROOM );
      act( AT_HURT, "You are stunned, but will probably recover.", victim, NULL, NULL, TO_CHAR );
      ch_printf(ch, "You knock %s on his ass, KNOCK OUT!\n\r", victim->name);
      sprintf(buf, "%s smacks you on your ass, KNOCK OUT!\n\r", ch->name);
      send_to_char(buf, victim);
      xREMOVE_BIT(ch->act, PLR_SPAR);
      xREMOVE_BIT(victim->act, PLR_SPAR);
      stop_fighting( victim, TRUE );
      victim->hit = -1;
      update_pos( victim );
      return rNONE;
     }

       if ( victim->hit < 1 && !IS_NPC(victim) && xIS_SET(ch->act, PLR_TOGGLE) )
    {
      act( AT_ACTION, "$n is stunned, but will probably recover.", victim, NULL, NULL, TO_ROOM );
      act( AT_HURT, "You are stunned, but will probably recover.", victim, NULL, NULL, TO_CHAR );
      stop_fighting( victim, TRUE );
      victim->hit = -1;
      update_pos( victim );
      return rNONE;
     }

    if ( !npcvict
    &&   get_trust(victim) >= LEVEL_IMMORTAL
    &&	 get_trust(ch)	   >= LEVEL_IMMORTAL
    && !xIS_SET(victim->act, PLR_SEMI)
    &&   victim->hit < 1 )
	victim->hit = 1;
    update_pos( victim );

    switch( victim->position )
    {
    case POS_MORTAL:
	act( AT_DYING, "$n is mortally wounded, and will die soon, if not aided.",
	    victim, NULL, NULL, TO_ROOM );
	act( AT_DANGER, "You are mortally wounded, and will die soon, if not aided.",
	victim, NULL, NULL, TO_CHAR );
	break;

    case POS_INCAP:
	act( AT_DYING, "$n is incapacitated and will slowly die, if not aided.",
	    victim, NULL, NULL, TO_ROOM );
	act( AT_DANGER, "You are incapacitated and will slowly die, if not aided.",
	victim, NULL, NULL, TO_CHAR );
	break;

    case POS_STUNNED:
        if ( victim->hit == -4)
        give_nd( victim, ch );
        if ( !IS_AFFECTED( victim, AFF_PARALYSIS ) )
        {
	  act( AT_ACTION, "$n is stunned, but will probably recover.",
	    victim, NULL, NULL, TO_ROOM );
	  act( AT_HURT, "You are stunned, but will probably recover.",
	    victim, NULL, NULL, TO_CHAR );
	}
	break;

    case POS_DEAD:
	if ( dt >= 0 && dt < top_sn )
	{
	    SKILLTYPE *skill = skill_table[dt];

	    if ( skill->die_char && skill->die_char[0] != '\0' )
	      act( AT_DEAD, skill->die_char, ch, NULL, victim, TO_CHAR );
	    if ( skill->die_vict && skill->die_vict[0] != '\0' )
	      act( AT_DEAD, skill->die_vict, ch, NULL, victim, TO_VICT );
	    if ( skill->die_room && skill->die_room[0] != '\0' )
	      act( AT_DEAD, skill->die_room, ch, NULL, victim, TO_NOTVICT );
	}
	act( AT_DEAD, "&R$n is DEAD!!&D", victim, 0, 0, TO_ROOM );
	act( AT_DEAD, "You have been KILLED!!\n\r", victim, 0, 0, TO_CHAR );
	break;

    default:
	/*
	 * Victim mentalstate affected, not attacker -- oops ;)
	 * Thanks to gfinello@mail.karmanet.it for finding this bug
	 */
	if ( dam > victim->max_hit / 4 )
	{
/*	   act( AT_HURT, "That really did HURT!", victim, 0, 0, TO_CHAR ); */
	   if ( number_bits(3) == 0 )
		worsen_mental_state( victim, 0 );
	}
	if ( victim->hit < victim->max_hit / 4 )

	{
	   act( AT_RED, "You wish that your wounds would stop BLEEDING so much!",
		victim, 0, 0, TO_CHAR );
           if (victim->exp > 5000000 && victim->rage <= 2000 )
                {
               if ( IS_NPC(ch) )
               victim->rage += 1;
               
               else if ( !IS_NPC(ch) && xIS_SET( ch->act, PLR_TOGGLE ) )
               victim->rage += 1;
               else
               victim->rage += 0;
                }

if (victim->exp >= 5000000  && victim->rage == 150 && ( IS_SAIYAN(victim) || IS_HALFBREED(victim)) )
  {
        if (number_range( 1, 4 ) == 1 )
        {
         victim->suppress = 0;
         xREMOVE_BIT(victim->act, PLR_SUPPRESS);
         xREMOVE_BIT(victim->act, PLR_KAIOKEN);
         xREMOVE_BIT(victim->act, PLR_OOZARU);
         xREMOVE_BIT(victim->act, PLR_GOLDEN);
         victim->mod = 1;
         do_ssj ( victim, "1" );
        }
        else if (number_range( 1, 4 ) == 2 )
        {
         victim->suppress = 0;
         xREMOVE_BIT(victim->act, PLR_SUPPRESS);
         xREMOVE_BIT(victim->act, PLR_KAIOKEN);
         xREMOVE_BIT(victim->act, PLR_OOZARU);
         xREMOVE_BIT(victim->act, PLR_GOLDEN);
         victim->mod = 1;
         do_ssj ( victim, "1" );
        }
        else if (number_range( 1, 4 ) == 3 )
        {
         victim->suppress = 0;
         xREMOVE_BIT(victim->act, PLR_SUPPRESS);
         xREMOVE_BIT(victim->act, PLR_KAIOKEN);
         xREMOVE_BIT(victim->act, PLR_OOZARU);
         xREMOVE_BIT(victim->act, PLR_GOLDEN);
         victim->mod = 1;
         do_ssj ( victim, "1" );
        }
        else if (number_range( 1, 4 ) == 4 )
        {
         victim->suppress = 0;
         xREMOVE_BIT(victim->act, PLR_SUPPRESS);
         xREMOVE_BIT(victim->act, PLR_KAIOKEN);
         xREMOVE_BIT(victim->act, PLR_OOZARU);
         xREMOVE_BIT(victim->act, PLR_GOLDEN);
         victim->mod = 1;
         do_ssj ( victim, "1" );
/*         xSET_BIT(victim->act, PLR_LEGENDARY);
           act( AT_RED, "As the rage stirs within, you drop to the ground in agony, flashbacks of your childhood fill 
your head.\n\rYou let out a feral scream as you can no longer control your power. The ground around you cracks and 
shatters.\n\rThe planet begins to shake violently. After harnessing your new found power, a Legendary Aura starts 
emitting from your body.\n\r&YYou are a Legendary Saiyan!!!!!!",
                victim, 0, 0, TO_CHAR ); */
        }
           else
           do_ssj ( victim, "1" );
  }

if (victim->exp >= 10000000  && victim->rage == 250)
{
         victim->suppress = 0;
         xREMOVE_BIT(victim->act, PLR_SUPPRESS);
         xREMOVE_BIT(victim->act, PLR_KAIOKEN);
         xREMOVE_BIT(victim->act, PLR_OOZARU);
         xREMOVE_BIT(victim->act, PLR_GOLDEN);
         victim->mod = 1;
           do_ssj ( victim, "2" );
}
if (victim->exp >= 25000000  && victim->rage == 350)
{
         victim->suppress = 0;
         xREMOVE_BIT(victim->act, PLR_SUPPRESS);
         xREMOVE_BIT(victim->act, PLR_KAIOKEN);
         xREMOVE_BIT(victim->act, PLR_OOZARU);
         xREMOVE_BIT(victim->act, PLR_GOLDEN);
         victim->mod = 1;
           do_ssj ( victim, "3" );
}
	   if ( number_bits(2) == 0 )
		worsen_mental_state( victim, 0 );
	}
	break;
    }

    /*
     * Sleep spells and extremely wounded folks.
     */
    if ( !IS_AWAKE(victim)		/* lets make NPC's not slaughter PC's */
    &&   !IS_AFFECTED( victim, AFF_PARALYSIS ) )
    {
	if ( victim->fighting
	&&   victim->fighting->who->hunting
	&&   victim->fighting->who->hunting->who == victim )
	   stop_hunting( victim->fighting->who );

	if ( victim->fighting
	&&   victim->fighting->who->hating
	&&   victim->fighting->who->hating->who == victim )
	   stop_hating( victim->fighting->who );

	if (!npcvict && IS_NPC(ch))
	  stop_fighting( victim, TRUE );
	else
	  stop_fighting( victim, FALSE );
    }

    /*
     * Payoff for killing things.
     */
    if ( victim->position == POS_DEAD )
    {
	group_gain( ch, victim );

	if ( !npcvict )
	{
	    sprintf( log_buf, "%s (%d) killed by %s at %d",
		victim->name,
		victim->level,
		(IS_NPC(ch) ? ch->short_descr : ch->name),
		victim->in_room->vnum );
	    log_string( log_buf );
	    to_channel( log_buf, CHANNEL_MONITOR, "Monitor", LEVEL_IMMORTAL );

            if (!IS_NPC( ch ) && !IS_IMMORTAL( ch ) && ch->pcdata->clan
	    &&   ch->pcdata->clan->clan_type != CLAN_ORDER
            &&   ch->pcdata->clan->clan_type != CLAN_GUILD
            &&   victim != ch )
            {
                sprintf( filename, "%s%s.record", CLAN_DIR, ch->pcdata->clan->name );
                sprintf( log_buf, "&P(%2d) %-12s &wvs &P(%2d) %s &P%s ... &w%s",
		  ch->level,
                  ch->name,
		  victim->level,
		  !CAN_PKILL( victim ) ? "&W<Peaceful>" :
		    victim->pcdata->clan ? victim->pcdata->clan->badge :
		      "&P(&WUnclanned&P)",
		  victim->name,
                  ch->in_room->area->name );
		if ( victim->pcdata->clan &&
		     victim->pcdata->clan->name == ch->pcdata->clan->name)
		;
		else
		  append_to_file( filename, log_buf );
            }

	    /*
	     * Dying penalty:
	     * 1/2 way back to previous level.
	     */
/*	    if ( victim->exp > exp_level(victim, victim->level) )
		gain_exp( victim, (exp_level(victim, victim->level) - victim->exp)/2 ); */

	    /*
	     * New penalty... go back to the beginning of current level.
	     victim->exp = exp_level( victim, victim->level );
	     */
	}
	else
	if ( !IS_NPC(ch) )		/* keep track of mob vnum killed */
	    add_kill( ch, victim );

	check_killer( ch, victim );

	if ( ch->in_room == victim->in_room )
	    loot = legal_loot( ch, victim );
	else
	    loot = FALSE;

	set_cur_char(victim);
	raw_kill( ch, victim );
	victim = NULL;

	if ( !IS_NPC(ch) && loot )
	{
	   /* Autogold by Scryn 8/12 */
	    if ( xIS_SET(ch->act, PLR_AUTOGOLD) )
	    {
		init_gold = ch->gold;
		do_get( ch, "coins corpse" );
		new_gold = ch->gold;
		gold_diff = (new_gold - init_gold);
		if (gold_diff > 0)
                {
                  sprintf(buf1,"%d",gold_diff);
		  do_split( ch, buf1 );
		} 
	    }
	    if ( xIS_SET(ch->act, PLR_AUTOLOOT)
	    &&   victim != ch )  /* prevent nasty obj problems -- Blodkai */
		do_get( ch, "all corpse" );
	    else
		do_look( ch, "in corpse" );

	    if ( xIS_SET(ch->act, PLR_AUTOSAC) )
		do_sacrifice( ch, "corpse" );

           }

	if ( IS_SET( sysdata.save_flags, SV_KILL ) )
	   save_char_obj( ch );
	return rVICT_DIED;
    }

    if ( victim == ch )
	return rNONE;

    /*
     * Take care of link dead people.
     */
    if ( !npcvict && !victim->desc  
    && !IS_SET( victim->pcdata->flags, PCFLAG_NORECALL ) )
    {
	if ( number_range( 0, victim->wait ) == 0)
	{
	    do_recall( victim, "" );
	    return rNONE;
	}
    }

    /*
     * Wimp out?
     */
    if ( npcvict && dam > 0 )
    {
	if ( ( xIS_SET(victim->act, ACT_WIMPY) && number_bits( 1 ) == 0
	&&   victim->hit < victim->max_hit / 2 )
	||   ( IS_AFFECTED(victim, AFF_CHARM) && victim->master
	&&     victim->master->in_room != victim->in_room ) )
	{
	    start_fearing( victim, ch );
	    stop_hunting( victim );
	    do_flee( victim, "" );
	}
    }

    if ( !npcvict
    &&   victim->hit > 0
    &&   victim->hit <= victim->wimpy
    &&   victim->wait == 0 )
	do_flee( victim, "" );
    else
    if ( !npcvict && xIS_SET( victim->act, PLR_FLEE ) )
	do_flee( victim, "" );

    tail_chain( );
    return rNONE;
}


ch_ret sensedamage( CHAR_DATA *ch, CHAR_DATA *victim, int dam, int dt )
{
    char buf[MAX_STRING_LENGTH];
    char filename[256];
          OBJ_DATA *obj;
    long int maxdam, kamedam, kameextra, sbcdam, sbcextra, masdam, kamedex, kamestr, sbcint, sbccon;
    bool npcvict;
    bool loot;
    int location;
    ch_ret retcode;
    int charexp;
    int victexp;
    int glowloss;
    int deflect;

    glowloss = 0;

   if ( xIS_SET(victim->act, PLR_SUPPRESS ))
    victexp = victim->suppress;
    else
    victexp = victim->exp * victim->mod;

   if ( xIS_SET(ch->act, PLR_SUPPRESS ) )
    charexp = ch->suppress;
    else
    charexp = ch->exp * ch->mod;

    location = 152;
    retcode = rNONE;

    if ( dt == TYPE_KAME ) { dt = TYPE_KAME;}
    if ( dt == TYPE_SBC ) { dt = TYPE_SBC;}
    if ( dt == TYPE_MASENKO ) { dt = TYPE_MASENKO;}
    if ( dt == TYPE_TRIBEAM ) { dt = TYPE_TRIBEAM;}

    if ( !ch )
    {
        bug( "SenseDamage: null ch!", 0 );
        return rERROR;
    }

    if ( !victim )
    {
        bug( "SenseDamage: null victim!", 0 );
        return rVICT_DIED;
    }

    if ( victim->position == POS_DEAD )
        return rVICT_DIED;

    npcvict = IS_NPC(victim); 

    /*
     * Precautionary step mainly to prevent people in Hell from finding
     * a way out. --Shaddai
     */
    if ( xIS_SET(victim->in_room->room_flags, ROOM_SAFE) )
        dam = 0;

       if ( xIS_SET( victim->act, ACT_DEFLECT ) && IS_NPC(victim) )
       {
       deflect = number_range( 25, 40 );
       act( AT_BLUE, "$N's attack damages your blue barrier." , victim, NULL, ch, TO_CHAR );
       act( AT_YELLOW, "$N stretches $s arm, smashing into your energy attack, deflecting it back 

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

Site Stats

Snippets: 1791
Codebases: 571