void one_hit args ((CHAR_DATA * ch, CHAR_DATA * victim, int dt));
void mob_hit args ((CHAR_DATA * ch, CHAR_DATA * victim, int dt));
void one_hit (CHAR_DATA * ch, CHAR_DATA * victim, int dt)
{
OBJ_DATA *wield;
int victim_ac;
int thac0;
int thac0_00;
int thac0_32;
int dam;
int diceroll;
int sn, skill;
int dam_type;
bool result;
sn = -1;
/* just in case */
if (victim == ch || ch == NULL || victim == NULL)
return;
/*
* Can't beat a dead char!
* Guard against weird room-leavings.
*/
if (victim->position == POS_DEAD || ch->in_room != victim->in_room)
return;
/*
* Figure out the type of damage message.
*/
wield = get_eq_char (ch, WEAR_WIELD);
if (dt == TYPE_UNDEFINED)
{
dt = TYPE_HIT;
if (wield != NULL && wield->item_type == ITEM_WEAPON)
dt += wield->value[3];
else
dt += ch->dam_type;
}
if (dt < TYPE_HIT)
if (wield != NULL)
dam_type = attack_table[wield->value[3]].damage;
else
dam_type = attack_table[ch->dam_type].damage;
else
dam_type = attack_table[dt - TYPE_HIT].damage;
if (dam_type == -1)
dam_type = DAM_BASH;
/* get the weapon skill */
sn = get_weapon_sn (ch);
skill = 20 + get_weapon_skill (ch, sn);
/*
* Calculate to-hit-armor-class-0 versus armor.
*/
if (IS_NPC (ch))
{
thac0_00 = 20;
thac0_32 = -4; /* as good as a thief */
if (IS_SET (ch->act, ACT_WARRIOR))
thac0_32 = -10;
else if (IS_SET (ch->act, ACT_THIEF))
thac0_32 = -4;
else if (IS_SET (ch->act, ACT_CLERIC))
thac0_32 = 2;
else if (IS_SET (ch->act, ACT_MAGE))
thac0_32 = 6;
}
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);
if (thac0 < 0)
thac0 = thac0 / 2;
if (thac0 < -5)
thac0 = -5 + (thac0 + 5) / 2;
thac0 -= GET_HITROLL (ch) * skill / 100;
thac0 += 5 * (100 - skill) / 100;
if (dt == gsn_backstab)
thac0 -= 10 * (100 - get_skill (ch, gsn_backstab));
if (dt == gsn_circle)
thac0 -= 10 * (100 - get_skill (ch, gsn_circle));
if ( dt == gsn_backstab && wield != NULL)
if ( wield->value[0] != 2 )
dam *= 2 + (ch->level / 10);
else
dam *= 2 + (ch->level / 8);
if ( dt == gsn_circle && wield != NULL)
if ( wield->value[0] != 2 )
dam *= 2 + (ch->level / 10);
else
dam *= 2 + (ch->level / 8);
switch (dam_type)
{
case (DAM_PIERCE):
victim_ac = GET_AC (victim, AC_PIERCE) / 10;
break;
case (DAM_BASH):
victim_ac = GET_AC (victim, AC_BASH) / 10;
break;
case (DAM_SLASH):
victim_ac = GET_AC (victim, AC_SLASH) / 10;
break;
default:
victim_ac = GET_AC (victim, AC_EXOTIC) / 10;
break;
};
if (victim_ac < -15)
victim_ac = (victim_ac + 15) / 5 - 15;
if (!can_see (ch, victim))
victim_ac -= 4;
if (victim->position < POS_FIGHTING)
victim_ac += 4;
if (victim->position < POS_RESTING)
victim_ac += 6;
/*
* The moment of excitement!
*/
while ((diceroll = number_bits (5)) >= 20);
if (diceroll == 0 || (diceroll != 19 && diceroll < thac0 - victim_ac))
if (IS_SET (ch->off_flags, OFF_AREA_ATTACK))
{
for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
{
vch_next = vch->next;
if ((vch != victim && vch->fighting == ch))
one_hit (ch, vch, dt);
}
}
if (IS_SET (ch->off_flags, OFF_AREA_ATTACK))
{
for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
{
vch_next = vch->next;
if ((vch != victim && vch->fighting == ch))
mob_hit( ch, victim, dt, FALSE );
if (get_eq_char (ch, WEAR_SECONDARY))
{
mob_hit( ch, victim, dt, TRUE );
if ( ch->fighting != victim )
return;
}
}
}
the part that confuses me is do i seriously change every single reference to one_hit, or what? cause theres void one_hit there and there are a few others in there that look like they should remain as they are. also the snippet refers to void do_attack which isn't in the code in ANY file. basically this looks like it was written for a different code base cause it also refers to sendch instead of send_to_char. i'm just looking for someone who can make this snippet make sense to me.
[edit] i posted this question here because there is no contact info for the author of the snippet in the file