dam2.c

./mudd/src/dam2.c · 9.3 KB

From the archive emlen.tar.gz

Download the archive   « Back to the archive contents

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

// some damage code from other codebase

char you_hit[STD_LENGTH];		/* You hit ... */
char other_hit[STD_LENGTH];		/* ... hit ... */
char hit_you[STD_LENGTH];		/* ... hit YOU. */

bool nocolor;

void 
general_hit (int dam, CHAR_DATA * ch, CHAR_DATA * victim)
{
  int i; 
  if (dam < 2)
    {
      if (dam == 0)
	{
	  switch (number_range(1,4))
	    {
	    case 1:
	      strcpy (you_hit, "You circle around $N, but you find no opening.");
	      strcpy (other_hit, "$n circles $N, looking for an opening.");
	      strcpy (hit_you, "$n can't find an opening in your defenses.");
	      break;
	    case 4:
	      strcpy (you_hit, "You miss $N with your attack.");
	      strcpy (other_hit, "$n swings at $N and misses.");
	      strcpy (hit_you, "$n attacks you, but misses.");
	      break;
	    case 2:
	      strcpy (you_hit, "You swing at $N, and miss wide.");
	      strcpy (other_hit, "$n swings at $N, and misses wide.");
	      strcpy (hit_you, "$n attacks you, but misses wide.");
	      break;
	    case 3:
	    default:
	      strcpy (you_hit, "You attack $N, but miss your target.");
	      strcpy (other_hit, "$n attacks $N, but misses the target.");
	      strcpy (hit_you, "$n attacks and misses.");
	      break;
	    }
	  return;
	}
      else if (dam <= 1)
	{
	  switch (number_range(1,3))
	    {
	    case 1:
	      strcpy (you_hit, "Your %s is absorbed completely by $N's armor.");
	      strcpy (other_hit, "$n's %s is completely absorbed by $N's armor.");
	      strcpy (hit_you, "Your armor protects you from $n's %s.");
	      break;
	    case 2:
	      strcpy (you_hit, "$N is hardly even bruised by your puny attack!");
	      strcpy (other_hit, "$N is lightly bruised by $n's puny attack.");
	      strcpy (hit_you, "You hardly notice $n's puny %s.");
	      break;
	    case 3:
	    default:
	      strcpy (you_hit, "You glancing blow barely touches $N!");
	      strcpy (other_hit, "$N is slightly nicked by a glancing blow from $n.");
	      strcpy (hit_you, "$n's %s bounces off of your armor.");
	      break;
	    } 
	  return;
	}
    }
  for (i = 0; i < 20; i++)
    {
      if (dam >= dmsg.generic_range[i][0] && dam <= dmsg.generic_range[i][1])
	{
	  strcpy (you_hit, dmsg.gen_m[i]);
	  strcpy (other_hit, dmsg.gen_m1[i]);
	  strcpy (hit_you, dmsg.gen_m2[i]);
	  return;
	}

    }
  return;
}


void 
dam_message (CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt, int p)
{
  char buf[SML_LENGTH], buf1[SML_LENGTH], buf2[SML_LENGTH], buf3[SML_LENGTH];
  char *s, *tt, *r, *t;
  int i;
  char attack[SML_LENGTH];
  char hit_you_far[2000];
  char other_hit_far[2000];
  char tempbuf[STD_LENGTH];
  SINGLE_OBJECT *obj = NULL;
  you_hit[0] = '\0';
  attack[0] = '\0';
  other_hit[0] = '\0';
  hit_you[0] = '\0';
  hit_you_far[0] = '\0';
  other_hit_far[0] = '\0';
 
  general_hit (dam, ch, victim);

  
  if (dt >= 0 && dt < SKILL_COUNT)
    {
      if (dt == 280)
	strcpy (attack, "shield");
      else if (dt == gsn_circle)
	{
	  if ((obj = get_item_held (ch, ITEM_WEAPON)) == NULL)
	    return;
	  if (dam > 0)
	    {
	      sprintf (buf1, "\x1B[1;37mm$n\x1B[0;37m sneaks up on $N... $n thrusts $p\x1B[0;37m into $S back!");
	      if (dam < 20)
		sprintf (buf2, "You circle and thrust $p\x1B[0;37m into \x1B[1;37m$N\x1B[0;37m's back.");
	      if ((dam > 19) && (dam < 50))
		sprintf (buf2, "You circle and thrust $p\x1B[0;37m into \x1B[1;37m$N\x1B[0;37m's back, causing cries of agony and pain.");
	      if ((dam > 49) && (dam < 99))
		sprintf (buf2, "You circle your opponent.... $p\x1B[0;37m finds its mark in \x1B[1;37m$N\x1B[0;37m's back, causing $S body to spasm in pain.");
	      if ((dam > 98) && (dam < 190))
		sprintf (buf2, "You circle your opponent.... $p\x1B[0;37m sinks deeply into \x1B[1;37m$N\x1B[0;37m's back, and blood runs over your hands.");
	      if ((dam > 189) && (dam < 320))
		sprintf (buf2, "You circle your opponent.... $p\x1B[0;37m has struck a pressure point in \x1B[1;37m$N\x1B[0;37m's back!\n\rThat's gotta hurt!");
	      if ((dam > 319) && (dam < 464))
		sprintf (buf2, "You circle around and twist $p\x1B[0;37m around several times in \x1B[1;37m$N\x1B[0;37m's back! That's gotta hurt!");
	      if (dam > 463)
		sprintf(buf2, "Your $p\x1B[0;37m penetrates the base of \x1B[1;37m$N\x1B[0;37m's neck spraying spinal fluid onto your armor!");
	      sprintf (buf3, "\x1B[1;37m$n\x1B[0;37m is behind you before you know it, and slips $p\x1B[0;37m into your back.\n\r");
	    }
	  else
	    {
	      send_to_char ("You miss your circle!\n\r", ch);
	      return;
	    }
	}
      else if (dt == gsn_backstab)
	{
	  if ((obj = get_item_held (ch, ITEM_WEAPON)) == NULL)
	    return;
	  if (dam > 2)
	    {
	      sprintf (buf1, "\x1B[1;37m$n\x1B[0;37m thrusts $p\x1B[0;37m into \x1B[1;37m$N\x1B[0;37m's back.\n\r");
	      if (dam < 20)
		sprintf (buf2, "You thrust $p\x1B[0;37m into \x1B[1;37m$N\x1B[0;37m's back.");
	      if ((dam > 19) && (dam < 50))
		sprintf (buf2, "You thrust $p\x1B[0;37m into \x1B[1;37m$N\x1B[0;37m's back, causing cries of agony and pain.");
	      if ((dam > 49) && (dam < 99))
		sprintf (buf2, "$p\x1B[0;37m finds its mark in \x1B[1;37m$N\x1B[0;37m's back, causing $s body to spasm.");
	      if ((dam > 98) && (dam < 190))
		sprintf (buf2, "$p\x1B[0;37m sinks deeply into \x1B[1;37m$N\x1B[0;37m's back, and blood runs over your hands.");
	      if ((dam > 189) && (dam < 320))
		sprintf (buf2, "$p\x1B[0;37m has struck a pressure point in \x1B[1;37m$N\x1B[0;37m's back! That's gotta hurt!");
	      if ((dam > 319) && (dam < 464))
		sprintf (buf2, "You twist $p\x1B[0;37m around several times in \x1B[1;37m$N\x1B[0;37m's back!\n\rThat's gotta hurt!");
	      if (dam > 463)
		sprintf(buf2, "Your $p\x1B[0;37m penetrates the base of \x1B[1;37m$N\x1B[0;37m's neck spraying spinal fluid onto your armor!");
	      sprintf (buf3, "Before you know what's going on, \x1B[1;37m$n\x1B[0;37m\n\ris behind you, and you suddenly feel $p\x1B[0;37m\n\rbeing thrust into your back.\n\r");
	    }
	  else
	    {
	      sprintf (buf1, "\x1B[1;37m$n\x1B[0;37m fails to lunge $p\x1B[0;37m in \x1B[1;37m$N\x1B[0;37m's back.");
	      sprintf (buf2, "You fail to place $p\x1B[0;37m into \x1B[1;37m$N\x1B[0;37m's back.");
	      sprintf (buf3, "\x1B[1;37m$n\x1B[0;37m's \x1B[1;30;37mbackstab\x1B[0;37m just barely misses you.");
	    }
	}
      else
	{
	  SPELL_DATA *spell;
	  if ((spell = skill_lookup (NULL, dt)) == NULL)
	    return;
	  strcpy (attack, spell->noun_damage);
	  sprintf (buf, "%s", you_hit);
	  sprintf (buf2, buf, attack);
	  sprintf (buf, "%s", other_hit);
	  sprintf (buf1, buf, attack);
	  sprintf (buf, "%s", hit_you);
	  sprintf (buf3, buf, attack);
	} 
    }
  else
    {
      if (dt > TYPE_HIT && ((dt - TYPE_HIT) < MAX_ATTACK))
	strcpy (attack, attack_table[dt - TYPE_HIT].name);
      else
	{
	  if (IS_MOB (ch))
	    {
	      if (!ch->pIndexData->attackname || !str_cmp ("(null)", ch->pIndexData->attackname) || !str_cmp ("N/A", ch->pIndexData->attackname) || ch->pIndexData->attackname == NULL || ch->pIndexData->attackname[0] == ' ')
		{
		  if (!str_cmp (mob_type_attack (ch->pIndexData->mobtype), "punch") && FIGHTING (ch) != NULL &&
		      FIGHTING (ch)->position == POSITION_GROUNDFIGHTING)
		    strcpy (attack, "stomp");
		  else
		    strcpy (attack, mob_type_attack (ch->pIndexData->mobtype));
		}
	      else
		{
		  if (!str_cmp (ch->pIndexData->attackname, "punch") && FIGHTING (ch) != NULL && FIGHTING (ch)->position == POSITION_GROUNDFIGHTING)
		    strcpy (attack, "stomp");
		  else
		    strcpy (attack, ch->pIndexData->attackname);
		}
	    }
	  else
	    {
	      if (FIGHTING (ch) != NULL && FIGHTING (ch)->position ==POSITION_GROUNDFIGHTING)
		strcpy (attack, "stomp");
	      else
		strcpy (attack, "punch");
	    }
	}
      sprintf (buf, "%s", you_hit);
      sprintf (buf2, buf, attack);
      sprintf (buf, "%s", other_hit);
      sprintf (buf1, buf, attack);
      sprintf (buf, "%s", hit_you);
      sprintf (buf3, buf, attack);
    }
  
  for (i = 0; i < 3; i++)
    {
      if (i == 0)
	r = buf1;
      else if (i == 1)
	r = buf2;
      else r = buf3;
      s = r;
      t = r;
      tempbuf[0] = '\0';
      for (; *s; s++)
	{
	  if (*s == 'h' && *(s + 1) == 's')
	    {
	      s++;
	      *s = '\0';
	      strcat(tempbuf, r);
	      strcat (tempbuf, "es");
	      s++;
	      r = s;
	    }
	}
      strcat (tempbuf, r);
      strcpy (t , tempbuf);
    }
	      

  if (dam <= 1)
    {
      act(buf1, ch, obj, victim, TO_NOTVICT_SPAM);
      act(buf2, ch, obj, victim, TO_CHAR_SPAM);
      act(buf3, ch, obj, victim, TO_VICT_SPAM);
    }
  else
    {
      act(buf1, ch, obj, victim, TO_NOTVICT);
      act(buf2, ch, obj, victim, TO_CHAR);
      act(buf3, ch, obj, victim, TO_VICT);
      if (victim->in_room != ch->in_room)
	{
	  for (i = 0; i < 2; i++)
	    {
	      for (tt = (i == 0 ? buf1 : buf3); *tt; tt++)
		{
		  if (*tt == '$')
		    {
		      tt++;
		      switch(UPPER(*tt))
			{
			case 'N':
			  if (*tt == 'N')
			    *tt = 'n';
			  else
			    *tt = 'N';
			  break;
			case 'E':
			  if (*tt == 'E')
			    *tt = 'e';
			  else
			    *tt = 'E';
			  break;
			case 'S':
			  if (*tt == 'S')
			    *tt = 's';
			  else
			    *tt = 'S';
			  break;
			}
		    }
		}
	    }
	  act(buf1, victim, obj, ch, TO_NOTVICT + 1000);
	  act(buf3, victim, obj, ch, TO_CHAR + 1000);
	}
    }
  if (dt == gsn_backstab && dam > 0)
    check_social (victim, "wince", "");
  return;
}

Site Stats

Snippets: 1791
Codebases: 571