fight_location.c
src/fight_location.c · 2.5 KB
From the archive cyhawk_mud.tar.gz
Download the archive « Back to the archive contents
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "merc.h"
#include "interp.h"
#include "magic.h"
#include "recycle.h"
#include "tables.h"
#define LOCATION_BODY 1
#define LOCATION_HEAD 2
#define LOCATION_LEGS 3
/*
* location_hit()
*
* Determines location of the hit, and deals approprite damage,
* and damages the armor and applies various effects.
* Also takes care of dodge/parry/etc
*/
int location_hit(CHAR_DATA * ch, CHAR_DATA * victim, int dam_type, int dam)
{
int chance = number_range(1, 100);
OBJ_DATA * armor;
int actype;
char buf[MSL];
char buf2[MSL];
if (chance <= 10)
{
/* Ok check if armor exists, if not, no damage reduction */
if ((armor = get_eq_char (victim, WEAR_HEAD)) == NULL)
return dam *= 1.5;
sprintf(buf2, "high strike");
}
else if (chance <= 25)
{
/* Ok check if armor exists, if not, no damage reduction */
if ((armor = get_eq_char (victim, WEAR_LEGS)) == NULL)
return dam *= .5;
sprintf(buf2, "low strike");
}
else
{
/* Ok check if armor exists, if not, no damage reduction */
if ((armor = get_eq_char (victim, WEAR_BODY)) == NULL)
return dam;
sprintf(buf2, "strike");
}
/* Find value num for dam type */
switch(dam_type)
{
default:
actype = 3;
break;
case DAM_PIERCE:
actype = 0;
break;
case DAM_BASH:
actype = 1;
break;
case DAM_SLASH:
actype = 2;
break;
}
if (armor->value[actype] >= 1)
{
armor->value[actype] -= dam / 10;
dam = 0;
sprintf (buf, "%s's %s glances off %s's %s.\n",
ch->name,
buf2,
victim->name,
armor->short_descr);
stc(buf, ch);
stc(buf, victim);
act (buf, NULL, NULL, NULL, TO_ROOM);
if (armor->value[actype] <= 0)
{
sprintf (buf, "{C%s has been broken!{x\n",
armor->short_descr);
stc(buf, ch);
stc(buf, victim);
act (buf, NULL, NULL, NULL, TO_ROOM);
armor->value[actype] = 0;
}
}
return dam;
}