rage.c
MuD/src/rage.c · 37.6 KB
From the archive AEternity.zip
Download the archive « Back to the archive contents
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "merc.h"
#include "interp.h"
#include "recycle.h"
/*int hit(CharData * ch, CharData * victim, int type, int times)
{
}
void
rage_hit (CHAR_DATA * ch, CHAR_DATA *victim,OBJ_DATA *weapon, int type,int hits, bool hit_stack, bool change_pos)
{
bool flat_foot;
OBJ_DATA *obj, *obj_next;
char *spell;
int iHit, damage,c_damage, dt;
if (victim == ch || ch == NULL || victim == NULL)
return;
if (victim->position == POS_DEAD || ch->in_room != victim->in_room)
check_ranged_attack(weapon);
return;
//Replace at a later time with a check to hit.
if (!can_see(ch, victim))
return;
if (ch->position <= POS_RESTING)
{
send_to_char("You are on the ground, get up fast!\n\r", ch);
return;
}
if (ch->position == POS_STANDING && change_pos == TRUE)
{
ch->position = POS_FIGHTING;
}
if (weapon != NULL)
{
dt = weapon->value[3];
}
else
{
dt = NULL;
}
if (dt == TYPE_UNDEFINED || dt == NULL)
{
dt = TYPE_HIT;
if (weapon != NULL && weapon->item_type == ITEM_WEAPON)
dt += weapon->value[3];
else
dt += ch->dam_type;
}
if (weapon != NULL)
{
spell = check_spell_bind(weapon);
}
pre_skill_check(victim, FALSE);
pre_skill_check(ch, TRUE);
for (iHit = hits;iHit != 0; --iHit)
{
if (land_attack(ch, victim, weapon))
{
damage = calc_damage(ch, victim, weapon);
if (hit_stack = FALSE)
attack_message(weapon, damage);
else
c_damage += damage;
}
else
attack_message(weapon, 0);
}
if (hit_stack = TRUE)
attack_message(weapon, c_damage, hits);
post_skill_check(victim, FALSE);
post_skill_check(ch, TRUE);
tail_chain(); damage
}*/
void
rage_hits (CHAR_DATA * ch, CHAR_DATA * victim, int dt, int hits, bool secondary)
{
OBJ_DATA *wield;
// char buf[MSL];
int victim_ac = 0;
int dam, thac0 = 0;
int diceroll;
int sn, skill = 0;
int dam_type;
bool result = FALSE;
sn = -1;
if (victim == ch || ch == NULL || victim == NULL
|| victim->position == POS_DEAD || ch->in_room != victim->in_room)
return;
if (!secondary)
wield = get_eq_char (ch, WEAR_WIELD);
else
wield = get_eq_char (ch, WEAR_SECONDARY);
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;
/*
* The moment of excitement!
*/
while ((diceroll = number_bits (5)) >= 20);
if (diceroll == 0 || (diceroll != 19 && diceroll < thac0 - victim_ac))
{
/* Miss. */
damage (ch, victim, 0, dt, dam_type, TRUE);
tail_chain ();
return;
}
/*
* Hit.
* Calc damage.
*/
if (IS_NPC (ch) && (!ch->pIndexData->new_format || wield == NULL))
if (!ch->pIndexData->new_format)
{
dam = number_range (ch->level / 2, ch->level * 3 / 2);
if (wield != NULL)
dam += dam / 2;
}
else
dam = dice (ch->damage[DICE_NUMBER], ch->damage[DICE_TYPE]);
else
{
if (sn != -1)
check_improve (ch, sn, TRUE, 5);
if (wield != NULL)
{
if (wield->pIndexData->new_format)
dam = dice (wield->value[1], wield->value[2]) * skill / 100;
else
dam = number_range (wield->value[1] * skill / 100,
wield->value[2] * skill / 100);
if (get_eq_char (ch, WEAR_SHIELD) == NULL) /* no shield = more */
dam = dam * 11 / 10;
/* sharpness! */
if (IS_WEAPON_STAT (wield, WEAPON_SHARP))
{
int percent;
if ((percent = number_percent ()) <= (skill / 8))
dam = 2 * dam + (dam * 2 * percent / 100);
}
}
else
dam =
number_range (1 + 4 * skill / 100, 2 * ch->level / 3 * skill / 100);
}
/*
* Bonuses.
*/
if (get_skill (ch, gsn_enhanced_damage) > 0)
{
diceroll = number_percent ();
if (diceroll <= get_skill (ch, gsn_enhanced_damage))
{
check_improve (ch, gsn_enhanced_damage, TRUE, 6);
dam += 2 * (dam * diceroll / 300);
}
}
if (!IS_AWAKE (victim))
dam *= 2;
else if (victim->position < POS_FIGHTING)
dam = dam * 3 / 2;
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_assassinate && wield != NULL)
{
if (ch->pcdata->learned[sn] == 100)
{
if (wield->value[0] != 2)
dam *= 2 + (ch->level);
else
dam *= 2 + (ch->level + 40);
}
else
{
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);
}
/* but do we have a funky weapon? */
if (result && wield != NULL)
{
int dam;
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_POISON))
{
int level;
AFFECT_DATA *poison, af;
if ((poison = affect_find (wield->affected, gsn_poison)) == NULL)
level = wield->level;
else
level = poison->level;
if (!saves_spell (level / 2, victim, DAM_POISON))
{
send_to_char ("You feel poison coursing through your veins.",
victim);
act ("$n is poisoned by the venom on $p.",
victim, wield, NULL, TO_ROOM);
af.where = TO_AFFECTS;
af.type = gsn_poison;
af.level = level * 3 / 4;
af.duration = level / 2;
af.location = APPLY_STR;
af.modifier = -1;
af.bitvector = AFF_POISON;
affect_join (victim, &af);
}
/* weaken the poison if it's temporary */
if (poison != NULL)
{
poison->level = UMAX (0, poison->level - 2);
poison->duration = UMAX (0, poison->duration - 1);
if (poison->level == 0 || poison->duration == 0)
act ("The poison on $p has worn off.", ch, wield, NULL,
TO_CHAR);
}
}
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_VAMPIRIC))
{
dam = number_range (1, wield->level / 5 + 1);
act ("$p draws life from $n.", victim, wield, NULL, TO_ROOM);
act ("You feel $p drawing your life away.",
victim, wield, NULL, TO_CHAR);
damage (ch, victim, dam, 0, DAM_NEGATIVE, FALSE);
ch->alignment = UMAX (-1000, ch->alignment - 1);
ch->hit += dam / 2;
}
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_FLAMING))
{
dam = number_range (1, wield->level / 4 + 1);
act ("$n is burned by $p.", victim, wield, NULL, TO_ROOM);
act ("$p sears your flesh.", victim, wield, NULL, TO_CHAR);
fire_effect ((void *) victim, wield->level / 2, dam, TARGET_CHAR);
damage (ch, victim, dam, 0, DAM_FIRE, FALSE);
}
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_FROST))
{
dam = number_range (1, wield->level / 6 + 2);
act ("$p freezes $n.", victim, wield, NULL, TO_ROOM);
act ("The cold touch of $p surrounds you with ice.",
victim, wield, NULL, TO_CHAR);
cold_effect (victim, wield->level / 2, dam, TARGET_CHAR);
damage (ch, victim, dam, 0, DAM_COLD, FALSE);
}
if (ch->fighting == victim && IS_WEAPON_STAT (wield, WEAPON_SHOCKING))
{
dam = number_range (1, wield->level / 5 + 2);
act ("$n is struck by lightning from $p.", victim, wield, NULL,
TO_ROOM);
act ("You are shocked by $p.", victim, wield, NULL, TO_CHAR);
shock_effect (victim, wield->level / 2, dam, TARGET_CHAR);
damage (ch, victim, dam, 0, DAM_LIGHTNING, FALSE);
}
}
tail_chain ();
return;
}
void do_check_chance(CHAR_DATA *ch, char *argument)
{
OBJ_DATA * wield;
CHAR_DATA *victim = NULL;
char arg[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH];
int report, dt = -1, dam_type, hit_roll;
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;
argument = one_argument (argument, arg);
if ((victim = get_char_world (ch, arg)) == NULL)
{
send_to_char ("{RThey aren't here.{x\n\r", ch);
return;
}
hit_roll = hit_roller(ch,victim, FALSE, 10,dam_type);
report = check_hit(ch, victim, WEAR_WIELD);
if (victim != NULL)
{
sprintf(buf, "There is a %i chance of hitting them.\n\r", report);
send_to_char(buf,ch);
}
else
{
send_to_char("Victim == NULL", ch);
}
if( hit_roll > 0 ){
sprintf(buf, "You would hit %i times out of 10. (randomly)\n\r", hit_roll);
send_to_char(buf,ch);
}
else
{
sprintf(buf, "You would miss. (randomly)\n\r");
send_to_char(buf,ch);
}
return;
}
int hit_roller (CHAR_DATA *ch, CHAR_DATA *victim, bool secondary, int hits, int dam_type)
{
int rolls, hit_check, hit_dump, hit_dump2 = 0;
//replace with function that determines how many real hits.
hits -= 1;
if (hits <= 0)
hits = 0;
hit_check = GET_HITROLL(ch);
if (hit_check <= 0)
hit_check = 1;
rolls = hits;
hits = 0;
for (;;)
{
hit_check = GET_HITROLL(ch);
if (hit_check <= 0)
hit_check = 1;
for (;;)
{
if (hit_check <= 0)
break;
hit_check -= 1;
hit_dump = check_hit(ch, victim, WEAR_WIELD);
if (hit_dump > hit_dump2)
hit_dump2 = hit_dump;
}
if (hit_dump2 >= number_range(1, 100))
hits += 1;
if (rolls == 0)
break;
rolls -= 1;
}
return (hits);
}
int check_hit (CHAR_DATA *ch, CHAR_DATA *victim, int wear_loc)
{
int skill = 1, sn = -1, stats = 3, victim_ac = 100, chance = 0;
int pointer2, num, num2, dam_type, dt;
OBJ_DATA *wield, *wield2;
if (wear_loc <= -1)
wield = NULL;
wield2 = get_eq_char (ch, wear_loc);
dt = TYPE_HIT;
if (wield2 != NULL && wield2->item_type == ITEM_WEAPON)
dt += wield2->value[3];
else
dt += ch->dam_type;
if (dt < TYPE_HIT)
if (wield2 != NULL)
dam_type = attack_table[wield2->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;
wield = get_eq_char (ch, wear_loc);
if (wield == NULL)
pointer2 = ch->level;
else
{
pointer2 = wield->level;
if (wield->item_type != ITEM_WEAPON)
pointer2 = ch->level;
}
sn = get_weapon_sn (ch);
skill = 20 + get_weapon_skill (ch, sn);
chance = ((((skill + ch->level) + pointer2) - (victim->level + 21)) + 101);
chance = (((chance / 8) +/*Increase or decrease this number for signifigant changes ->*/ 11) - 1);
stats = ((get_curr_stat(ch, STAT_DEX) + (get_curr_stat(ch, STAT_SPI))) / 2);
chance += stats;
chance *= 10;
switch (dam_type)
{
case (DAM_PIERCE):
victim_ac = (GET_AC (victim, AC_PIERCE));
break;
case (DAM_BASH):
victim_ac = (GET_AC (victim, AC_BASH));
break;
case (DAM_SLASH):
victim_ac = (GET_AC (victim, AC_SLASH));
break;
default:
victim_ac = (GET_AC (victim, AC_EXOTIC));
break;
};
if (victim_ac < -900)
victim_ac = -900;
if (victim_ac > 100)
victim_ac = 100;
if (!can_see (ch, victim))
victim_ac -= 40;
if (victim->position < POS_FIGHTING)
victim_ac += 40;
if (victim->position < POS_RESTING)
victim_ac += 60;
//chance is anywhere from 50 - 100 at this point, desired is 25-75
//Meaning victim AC cannot drop chance more than 25(250), so I'm making 1000 top AC.
victim_ac -= 101;
if (victim_ac == 0)
victim_ac -= 1;
victim_ac /= 10;
if (chance <= 0)
{
bug("Check_hit: value returned less than 0.", 0);
return 0;
}
else
{
num = ((ch->size - victim->size) - 6);
num = num - (num * 2);
num = (1.50 - (num / 2));
chance += (victim_ac * num); //Figuring in size.
chance /= 10;
}
//put in function for how much weight they are carrying.
//quick math to make either REALLY low or high extremes much harder.
//revolves around 50%
if (chance > 50)
{
num2 = (chance - 50);
num2 /= 1.75;
chance -= num2;
}
else if (chance < 50)
{
num2 = (chance - 50);
num2 -= (num2 + num2);
num2 /= 1.75;
chance += num2;
}
return chance;
}
/*
bool rage_damage (CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt, int dam_type, bool show, int hits)
{
OBJ_DATA *corpse;
bool immune;
if (victim->position == POS_DEAD)
return FALSE;
// damage reduction
if (dam > 35)
dam = (dam - 35) / 2 + 35;
if (dam > 80)
dam = (dam - 80) / 2 + 80;
// Stop up any residual loopholes.
if (dam > 3600 && dt >= TYPE_HIT)
{
bug ("Damage: %d: more than 3600 points!", dam);
dam = 3600;
if (!IS_IMMORTAL (ch))
{
OBJ_DATA *obj;
obj = get_eq_char (ch, WEAR_WIELD);
send_to_char ("You really shouldn't cheat.\n\r", ch);
if (obj != NULL)
extract_obj (obj);
}
}
if (victim != ch)
{
// Certain attacks are forbidden.
// Most other attacks are returned.
if (is_safe (ch, victim))
return FALSE;
check_killer (ch, victim);
if (victim->position > POS_STUNNED)
{
if (victim->fighting == NULL)
{
set_fighting (victim, ch);
if (IS_NPC (victim) && HAS_TRIGGER_MOB (victim, TRIG_KILL))
p_percent_trigger (victim, NULL, NULL, ch, NULL, NULL,
TRIG_KILL);
}
if (victim->timer <= 4)
victim->position = POS_FIGHTING;
}
if (victim->position > POS_STUNNED)
{
if (ch->fighting == NULL)
set_fighting (ch, victim);
}
// More charm stuff.
if (victim->master == ch)
stop_follower (victim);
}
// Inviso attacks ... not.
if (IS_AFFECTED (ch, AFF_INVISIBLE))
{
affect_strip (ch, gsn_invis);
affect_strip (ch, gsn_mass_invis);
REMOVE_BIT (ch->affected_by, AFF_INVISIBLE);
act ("$n fades into existence.", ch, NULL, NULL, TO_ROOM);
}
//////////////////////////////////////////////////////
// Damage modifiers.
if (dam > 1 && !IS_NPC (victim)
&& victim->pcdata->condition[COND_DRUNK] > 10)
dam = 9 * dam / 10;
if (dam > 1 && IS_AFFECTED (victim, AFF_SANCTUARY))
dam /= 2;
if (dam > 1 && ((IS_AFFECTED (victim, AFF_PROTECT_EVIL) && IS_EVIL (ch))
|| (IS_AFFECTED (victim, AFF_PROTECT_GOOD) && IS_GOOD (ch))))
dam -= dam / 4;
immune = FALSE;
// Check for parry, and dodge.
if (dt >= TYPE_HIT && ch != victim)
{
if (check_parry (ch, victim))
return FALSE;
if (check_dodge (ch, victim))
return FALSE;
if (check_shield_block (ch, victim))
return FALSE;
}
switch (check_immune (victim, dam_type))
{
case (IS_IMMUNE):
immune = TRUE;
dam = 0;
break;
case (IS_RESISTANT):
dam -= dam / 3;
break;
case (IS_VULNERABLE):
dam += dam / 2;
break;
}
if (show){
// dam_message (ch, victim, dam, dt, immune);
multi_dam_message(dam, ch, victim, dt, hits, immune);}
if (dam == 0)
return FALSE;
// Hurt the victim.
// Inform the victim of his new state.
victim->hit -= dam;
if (!IS_NPC (victim) && victim->level >= LEVEL_IMMORTAL && victim->hit < 1)
victim->hit = 1;
update_pos (victim);
switch (victim->position)
{
case POS_MORTAL:
act ("$n is mortally wounded, and will die soon, if not aided.",
victim, NULL, NULL, TO_ROOM);
send_to_char
("You are mortally wounded, and will die soon, if not aided.\n\r",
victim);
break;
case POS_INCAP:
act ("$n is incapacitated and will slowly die, if not aided.",
victim, NULL, NULL, TO_ROOM);
send_to_char
("You are incapacitated and will slowly die, if not aided.\n\r",
victim);
break;
case POS_STUNNED:
act ("$n is stunned, but will probably recover.",
victim, NULL, NULL, TO_ROOM);
send_to_char ("You are stunned, but will probably recover.\n\r",
victim);
break;
case POS_DEAD:
act ("$n is DEAD!!", victim, 0, 0, TO_ROOM);
send_to_char ("You have been KILLED!!\n\r\n\r", victim);
break;
default:
if (dam > victim->max_hit / 4)
send_to_char ("That really did HURT!\n\r", victim);
if (victim->hit < victim->max_hit / 4)
send_to_char ("You sure are BLEEDING!\n\r", victim);
break;
}
// Sleep spells and extremely wounded folks.
if (!IS_AWAKE (victim))
stop_fighting (victim, FALSE);
// * Payoff for killing things.
if (victim->position == POS_DEAD)
{
group_gain (ch, victim);
if (!IS_NPC (victim))
{
sprintf (log_buf, "%s killed by %s at %ld",
victim->name,
(IS_NPC (ch) ? ch->short_descr : ch->name),
ch->in_room->vnum);
log_string (log_buf);
// Dying penalty:
// 2/3 way back to previous level.
if (victim->exp > exp_per_level (victim, victim->pcdata->points)
* victim->level)
gain_exp (victim,
(2 *
(exp_per_level (victim, victim->pcdata->points) *
victim->level - victim->exp) / 3) + 50);
}
sprintf (log_buf, "%s got toasted by %s at %s [room %ld]",
(IS_NPC (victim) ? victim->short_descr : victim->name),
(IS_NPC (ch) ? ch->short_descr : ch->name),
ch->in_room->name, ch->in_room->vnum);
if (IS_NPC (victim))
wiznet (log_buf, NULL, NULL, WIZ_MOBDEATHS, 0, 0);
else
wiznet (log_buf, NULL, NULL, WIZ_DEATHS, 0, 0);
// Death trigger
if (IS_NPC (victim) && HAS_TRIGGER_MOB (victim, TRIG_DEATH))
{
victim->position = POS_STANDING;
p_percent_trigger (victim, NULL, NULL, ch, NULL, NULL, TRIG_DEATH);
}
raw_kill (victim);
// dump the flags
if (ch != victim && !IS_NPC (ch) && !is_same_clan (ch, victim))
{
if (IS_SET (victim->act, PLR_KILLER))
REMOVE_BIT (victim->act, PLR_KILLER);
else
REMOVE_BIT (victim->act, PLR_THIEF);
}
// RT new auto commands
if (!IS_NPC (ch)
&& (corpse =
get_obj_list (ch, "corpse", ch->in_room->contents)) != NULL
&& corpse->item_type == ITEM_CORPSE_NPC && can_see_obj (ch, corpse))
{
OBJ_DATA *coins;
corpse = get_obj_list (ch, "corpse", ch->in_room->contents);
if (IS_SET (ch->act, PLR_AUTOLOOT) && corpse && corpse->contains)
{ // exists and not empty
do_function (ch, &do_get, "all corpse");
}
if (IS_SET (ch->act, PLR_AUTOGOLD) && corpse && corpse->contains &&
!IS_SET (ch->act, PLR_AUTOLOOT))
{
if ((coins = get_obj_list (ch, "gcash", corpse->contains))
!= NULL)
{
do_function (ch, &do_get, "all.gcash corpse");
}
}
if (IS_SET (ch->act, PLR_AUTOCONSUME))
{
if (IS_SET (ch->act, PLR_AUTOLOOT) && corpse
&& corpse->contains)
return TRUE; // leave if corpse has treasure
else
do_consume (ch, "corpse");
}
if (IS_SET (ch->act, PLR_AUTOSAC
&& !IS_SET(ch->act, PLR_AUTOCONSUME)))
{
if (IS_SET (ch->act, PLR_AUTOLOOT) && corpse
&& corpse->contains)
{
return TRUE; // leave if corpse has treasure
}
else
{
do_function (ch, &do_sacrifice, "corpse");
}
}
}
return TRUE;
}
if (victim == ch)
return TRUE;
// * Take care of link dead people.
if (!IS_NPC (victim) && victim->desc == NULL)
{
if (number_range (0, victim->wait) == 0)
{
do_function (victim, &do_recall, "");
return TRUE;
}
}
// Wimp out?
if (IS_NPC (victim) && dam > 0 && victim->wait < PULSE_VIOLENCE / 2)
{
if ((IS_SET (victim->act, ACT_WIMPY) && number_bits (2) == 0
&& victim->hit < victim->max_hit / 5)
|| (IS_AFFECTED (victim, AFF_CHARM) && victim->master != NULL
&& victim->master->in_room != victim->in_room))
{
do_function (victim, &do_flee, "");
}
}
//Set a mob to aggressive if it is attacked.
if (IS_NPC (victim) && !IS_SET(victim->act, ACT_AGGRESSIVE))
{
SET_BIT(victim, ACT_AGGRESSIVE);
}
tail_chain ();
return TRUE;
}*/
/*
#define PRE_SKILL_ATTACK
#define PRE_SKILL_DEFENSE
#define POST_SKILL_ATTACK
#define POST_SKILL_DEFENSE
//Make the skill tables.
struct rage_table
{
char *name;
int base_chance;
int damage_dice;
int type_dice;
int damage_absorb;
int position;
bool evasive; //defensive or attack?
bool passive; //user defined?
bool set;
int round;
int speed; //speed of the attack
}
const struct rage_table rage_skills_table[] = {
{NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
};
bool
check_ranged_attack(CHAR_DATA *ch, CHAR_DATA *victim,OBJ_DATA *weapon)
{
if (ch->in_room == victim->in_room)
return FALSE;
else
return TRUE;
return 0;
}
void
check_spell_bind(CHAR_DATA *ch, CHAR_DATA *vict, OBJ_DATA *weapon)
{
}
bool
land_attack(CHAR_DATA *ch, CHAR_DATA *victim, OBJ_DATA *weapon)
{
}
void
pre_skill_check(CHAR_DATA *ch, bool attacker)
{
}
void
post_skill_check(CHAR_DATA *ch, bool attacker)
{
}
void
skill_initialize(CHAR_DATA *ch, int skill)
{
}
*/
/*
#include "structs.h"
#include "utils.h"
#include "buffer.h"
#include "comm.h"
#include "scripts.h"
#include "handler.h"
#include "find.h"
#include "interpreter.h"
#include "db.h"
#include "spells.h"
#include "event.h"
#include "affects.h"
#include "track.h"
*/
typedef unsigned char UInt8;
typedef signed char SInt8;
typedef unsigned short UInt16;
typedef signed short SInt16;
typedef unsigned int UInt32;
typedef signed int SInt32;
typedef void * Ptr;
typedef struct char_data CharData;
typedef struct obj_data ObjData;
struct msg_type {
char * attacker_msg; // message to attacker
char * victim_msg; // message to victim
char * room_msg; // message to room
};
struct message_type {
struct msg_type die_msg; // messages when death
struct msg_type miss_msg; // messages when miss
struct msg_type hit_msg; // messages when hit
struct msg_type god_msg; // messages when hit on god
};
struct message_list {
int a_type; // Attack type
int number_of_attacks; // How many attack messages to chose from.
char * msg; // List of messages.
};
struct DamMesgType {
char * to_room;
char * to_char;
char * to_vict;
char * to_self;
};
#define MAX_MESSAGES 60
#define ACMD(name) void name(CHAR_DATA *ch, char *argument, int cmd, char *command, int subcmd)
#define EVENT(name) void (name)(Ptr causer, Ptr victim, long info)
/* External structures */
struct message_list fight_messages[MAX_MESSAGES];
extern int pk_allowed; /* see config.c */
extern int auto_save; /* see config.c */
extern char *dirs[];
extern char *from_dir[];
extern int rev_dirs[];
extern int max_npc_corpse_time, max_pc_corpse_time;
extern int thaco[102][2];
extern char *times_string[];
extern char * dir_text_2[];
/* External procedures */
char *fread_action(FILE * fl, int nr);
//ACMD(do_flee);
//ACMD(do_get);
void forget(CHAR_DATA * ch, CHAR_DATA * victim);
void remember(CHAR_DATA * ch, CHAR_DATA * victim);
int ok_damage_shopkeeper(CHAR_DATA * ch, CHAR_DATA * victim);
void mprog_hitprcnt_trigger(CHAR_DATA * mob, CHAR_DATA * ch);
void mprog_fight_trigger(CHAR_DATA * mob, CHAR_DATA * ch);
int combat_delay(CHAR_DATA *ch);
EVENT(combat_event);
void AlterHit(CHAR_DATA *ch, int amount);
/* local functions */
void appear(CharData * ch);
void load_messages(void);
void check_killer(CharData * ch, CharData * vict);
void make_corpse(CharData * ch);
void death_cry(CharData * ch);
void group_gain(CharData * ch, CharData * victim);
char *replace_string(char *str, char *weapon_singular, char *weapon_plural);
void perform_violence(void);
void dam_message(int dam, CharData * ch, CharData * victim, int w_type);
void multi_dam_message (int damage, CharData *ch, CharData *vict, int dt, int times, bool immune);
void explosion(CharData * ch, int dice_num, int dice_size, int room, int shrapnel);
void acidblood(CharData *ch, int dam);
void acidspray(int room, int dam);
void announce(char *buf);
int skill_roll(CharData *ch, int skill_num);
int strike_missile(CharData *ch, CharData *tch,
ObjData *missile, int dir, int attacktype);
void miss_missile(CharData *ch, CharData *tch,
ObjData *missile, int dir, int attacktype);
void mob_reaction(CharData *ch, CharData *vict, int dir);
int fire_missile(CharData *ch, char *arg1, ObjData *missile, SInt32 pos, SInt32 range, SInt32 dir, SInt32 skill);
UInt32 calc_reward(CharData *ch, CharData *victim);
bool kill_valid(CharData *ch, CharData *vict);
void ExtractNoKeep(ObjData *obj, ObjData *corpse, CharData *ch);
char *replace_string args ((char *str, char *weapon_singular, char *weapon_plural));
struct attack_hit_type {
char *singular;
char *plural;
};
typedef SInt16 VNum;
typedef SInt16 RNum;
typedef UInt32 Flags;
typedef UInt8 Type;
/* Weapon attack texts */
static struct DamMesgType dam_weapon[] = {
// use #w for singular (i.e. "slash") and #W for plural (i.e. "slashes")
{ "$n tries to #w $N", // 0: 0
"You try to #w $N",
"$n tries to #w you",
"You try to #w yourself"},
{ "$n grazes $N with $s #w", // 1: 1-10
"You graze $N with your #w",
"$n grazes you with $s #w" ,
"You graze yourself with your #w"},
{ "$n barely #W $N", // 2: 11-25
"You barely #w $N",
"$n barely #W you" ,
"You barely #w yourself"},
{ "$n #W $N", // 3: 26-50
"You #w $N",
"$n #W you" ,
"You #w yourself"},
{ "$n #W $N hard", // 4: 51-75
"You #w $N hard",
"$n #W you hard" ,
"You #w yourself hard"},
{ "$n #W $N rather hard", // 5: 76-125
"You #w $N rather hard",
"$n #W you rather hard" ,
"You #w yourself rather hard"},
{ "$n #W $N very hard", // 6: 126-250
"You #w $N very hard",
"$n #W you very hard" ,
"You #w yourself very hard"},
{ "$n #W $N extremely hard", // 7: 251-500
"You #w $N extremely hard",
"$n #W you extremely hard" ,
"You #w yourself extremely hard"},
{ "$n massacres $N with $s #wing", // 8: 501-999
"You massacre $N with your #wing",
"$n massacres you with $s #wing" ,
"You massacre yourself with your #wing"},
{ "$n annihilates $N with $s #wing", // 9: > 1000
"You annihilate $N with your #wing",
"$n annihilates you with $s #wing",
"You annihilate youself with your #wing"}
};
char *times_string[] = {
"not at all", // 0
"once", // 1
"a couple times", // 2
"a few times", // 3
"several times", // 4
"five times", // 5
"six times", // 6
"seven times", // 7
"eight times", // 8
"nine times", // 9
"ten times", // 10
"over and over", // 11
"so much you can't remember", // 12
"\n"
};
char *replace_string(char *str, char *weapon_singular, char *weapon_plural) {
static char buf[256];
char *cp;
cp = buf;
for (; *str; str++) {
if (*str == '#') {
switch (*(++str)) {
case 'W':
for (; *weapon_plural; *(cp++) = *(weapon_plural++));
break;
case 'w':
for (; *weapon_singular; *(cp++) = *(weapon_singular++));
break;
default:
*(cp++) = '#';
break;
}
} else
*(cp++) = *str;
*cp = 0;
}
return (buf);
}
void multi_dam_message (int damage, CharData *ch, CharData *vict, int dt, int times, bool immune)
{
char message[MAX_INPUT_LENGTH];
char *adj1 = "", *punct;
char adj2[MAX_INPUT_LENGTH];
char adj3[MAX_INPUT_LENGTH];
char adj0[MAX_INPUT_LENGTH];
char autodam[MAX_INPUT_LENGTH] = "";
const char *vs = "";
const char *vp = "";
char *attack;
char *attack2 = 0;
int amount_index, weapon_index, percent, pain_percent;
check_stats (ch);
check_stats (vict);
// dt -= TYPE_HIT; // Change to base of table with text
pain_percent = 1000 * damage / vict->max_hit;
punct = (pain_percent <= 90) ? "." : "!!";
percent = (damage * 100 / (vict->max_hit));
if (percent <= 1) amount_index = 0;
else if (percent <= 2) amount_index = 1;
else if (percent <= 5) amount_index = 2;
else if (percent <= 10) amount_index = 3;
else if (percent <= 20) amount_index = 4;
else if (percent <= 30) amount_index = 5;
else if (percent <= 45) amount_index = 6;
else if (percent <= 60) amount_index = 7;
else if (percent <= 80) amount_index = 8;
else amount_index = 9;
if (damage <= 0) weapon_index = 0;
else if (damage <= 10) weapon_index = 1;
else if (damage <= 25) weapon_index = 2;
else if (damage <= 50) weapon_index = 3;
else if (damage <= 75) weapon_index = 4;
else if (damage <= 125) weapon_index = 5;
else if (damage <= 250) weapon_index = 6;
else if (damage <= 500) weapon_index = 7;
else if (damage < 1000) weapon_index = 8;
else weapon_index = 9;
if (damage == 0)
{
vs = "{BMISS{x";
vp = "{BMISSES{x";
}
else if (pain_percent <= 5)
{
vs = "barely nick";
vp = "barely nicks";
}
else if (pain_percent <= 10)
{
vs = "nick";
vp = "nicks";
}
else if (pain_percent <= 15)
{
vs = "bruise";
vp = "bruises";
}
else if (pain_percent <= 20)
{
vs = "barely graze";
vp = "barely grazes";
}
else if (pain_percent <= 30)
{
vs = "graze";
vp = "grazes";
}
else if (pain_percent <= 40)
{
vs = "ravage";
vp = "ravages";
}
else if (pain_percent <= 50)
{
vs = "rupture";
vp = "ruptures";
}
else if (pain_percent <= 60)
{
vs = "agonize";
vp = "agonizes";
}
else if (pain_percent <= 70)
{
vs = "devastate";
vp = "devastates";
}
else if (pain_percent <= 80)
{
vs = "eviscerate";
vp = "eviscerates";
}
else if (pain_percent <= 90)
{
vs = "decimate";
vp = "decimates";
}
else if (pain_percent <= 100)
{
vs = "DISFIGURE";
vp = "DISFIGURES";
}
else if (pain_percent <= 150)
{
vs = "{cMUTILATE{x";
vp = "{cMUTILATES{x";
}
else if (pain_percent <= 200)
{
vs = "{WDISEMBOWEL{x";
vp = "{WDISEMBOWELS{x";
}
else if (pain_percent <= 250)
{
vs = "{RDISMEMBER{x";
vp = "{RDISMEMBERS{x";
}
else if (pain_percent <= 300)
{
vs = "{CMASSACRE{x";
vp = "{CMASSACRES{x";
}
else if (pain_percent <= 350)
{
vs = "{W<< {GMANGLE{x {W>>{x";
vp = "{W<< {GMANGLES{x {W>>{x";
}
else if (pain_percent <= 400)
{
vs = "{b*** {BDEMOLISH {b***{x";
vp = "{b*** {BDEMOLISHES {b***{x";
}
else if (pain_percent <= 450)
{
vs = "{c*** {CDEVASTATE {c***{x";
vp = "{c*** {CDEVASTATES {c***{x";
}
else if (pain_percent <= 600)
{
vs = "{M={W={M= {GO{gB{GL{gI{GT{gE{GR{gA{GT{gE {M={W={M={x";
vp = "{M={W={M= {GO{gB{GL{gI{GT{gE{GR{gA{GT{gE{GS {M={W={M={x";
}
else if (pain_percent <= 650)
{
vs = "{G>{W>{G> {YA{yN{YN{yI{YH{yI{YL{yA{YT{yE {G<{W<{G<{x";
vp = "{G>{W>{G> {YA{yN{YN{yI{YH{yI{YL{yA{YT{yE{YS {G<{W<{G<{x";
}
else if (pain_percent <= 700)
{
vs = "{Y<{W<{Y< {CE{cR{CA{cD{CI{cC{CA{cT{CE {Y>{W>{Y>{x";
vp = "{Y<{W<{Y< {CE{cR{CA{cD{CI{cC{CA{cT{CE{cS {Y>{W>{Y>{x";
}
else if (pain_percent <= 750)
{
vs = "{R ¤ {W¤ {R¤ {DS{wL{WA{rU{RG{rH{WT{wE{DR{R ¤ {W¤ {R¤ {x";
vp = "{R ¤ {W¤ {R¤ {DS{wL{WA{rU{RGH{rT{WE{wR{DS{R ¤ {W¤ {R¤ {x";
}
else if (pain_percent <= 800)
{
vs =
"{W>{B-{W>{B-{W>{B-{R({WS{wH{WA{GT{WT{wE{WR{R){B-{W<{B-{W<{B-{W<{x";
vp =
"{W>{B-{W>{B-{W>{B-{R({WS{wH{WA{GT{WT{wE{WR{wS{R){B-{W<{B-{W<{B-{W<{x";
}
else if (pain_percent <= 850)
{
vs = "{B<<<{W¤{B>>> {rS{RMIT{rE {B<<<{W¤{B>>>{x";
vp = "{B<<<{W¤{B>>> {rS{RMITE{rS {B<<<{W¤{B>>>{x";
}
else if (pain_percent <= 1000)
{
vs =
"{B<{W-{B<{W-{B<{W-{DD{wIS{rI{RN{WTE{RG{rR{wAT{DE{W-{B>{W-{B>{W-{B>{x";
vp =
"{B<{W-{B<{W-{B<{W-{DD{wIS{rI{RN{WTEG{RR{rA{wTE{DS{W-{B>{W-{B>{W-{B>{x";
}
else
{
vs = "{W<<<{i---{B({RSLAY{x{B){i---{W>>>{x";
vp = "{W<<<{i---{B({RSLAYS{x{B){i---{W>>>{x";
}
if (IS_SET (ch->act, PLR_AUTODAMAGE))
sprintf(autodam, "{D[{w%i{D] {x", damage);
if (dt >= 0 && dt < MAX_SKILL)
{
attack = skill_table[dt].noun_damage;
attack2 = skill_table[dt].noun_damage;
}
else
if (dt >= TYPE_HIT && dt < TYPE_HIT + MAX_DAMAGE_MESSAGE)
{
attack = attack_table[dt - TYPE_HIT].noun;
attack2 = attack_table[dt - TYPE_HIT].plural;
}
else
{
bug ("Rage.c, line 903: multi_dam_message: bad dt %d.", dt);
dt = TYPE_HIT;
attack = attack_table[0].noun;
attack2 = attack_table[0].plural;
}
if (immune)
{
if (ch == vict)
{
sprintf(adj0, "{3$n is unaffected by $s own %s.{x", attack);
sprintf(adj2, "{5Luckily, you are immune to that.{x");
act_new(adj1, ch, NULL, NULL, TO_ROOM, POS_RESTING);
act_new(adj2, ch, NULL, NULL, TO_CHAR, POS_RESTING);
}
else
{
sprintf(adj0, "{3$N is unaffected by $n's %s!{x", attack);
sprintf(adj2, "{5$N is unaffected by your %s!{x", attack);
sprintf(adj3, "{4$n's %s is powerless against you.{x", attack);
act_new(adj0, ch, NULL, vict, TO_NOTVICT, POS_RESTING);
act_new(adj2, ch, NULL, vict, TO_CHAR, POS_RESTING);
act_new(adj3, ch, NULL, vict, TO_VICT, POS_RESTING);
}
return;
}
times = weapon_index;
// w_type = 1;
//to_self
if (ch == vict)
{
adj1 = (replace_string (dam_weapon[weapon_index].to_self, attack, attack2));
if (weapon_index > 0)
{
sprintf(adj0,"{Rhits{x");
sprintf(adj2,"which");
// sprintf(adj3,"%s",dam_amount[amount_index].to_char);
sprintf(adj3,"%s",vp);
}
else
{
sprintf(adj0,"{Wmisses{x");
sprintf(adj2,"but");
sprintf(adj3,"miss");
}
sprintf(message,"%s{R({D%d {W%s{R){w %s{w %s{w, %s{w {R%s{w you%s{x",autodam, times, adj0, adj1, times_string[times], adj2, adj3,punct);
act_new (message, ch, NULL, vict, TO_CHAR, POS_RESTING);
}
//to everyone but victim and char.
{
adj1 = (replace_string (dam_weapon[weapon_index].to_room, attack, attack2));
if (weapon_index > 0)
{
sprintf(adj0,"{Rhits{x");
sprintf(adj2,"which");
// sprintf(adj3,"%s",dam_amount[amount_index].to_room);
sprintf(adj3,"%s",vp);
}
else
{
sprintf(adj0,"{Wmisses{x");
sprintf(adj2,"but");
sprintf(adj3,"misses");
}
sprintf(message,"{R({D%d {W%s{R){w %s{w %s{w, %s{w {R%s{w $m%s{x", times, adj0, adj1, times_string[times], adj2, adj3,punct);
act_new (message, ch, NULL, vict, TO_NOTVICT, POS_RESTING);
if (ch == vict)
return;
}
//to_char
{
adj1 = (replace_string (dam_weapon[weapon_index].to_char, attack, attack2));
if (weapon_index > 0)
{
sprintf(adj0,"{Rhits{x");
sprintf(adj2,"which");
// sprintf(adj3,"%s",dam_amount[amount_index].to_char);
sprintf(adj3,"%s",vp);
}
else
{
sprintf(adj0,"{Wmisses{x");
sprintf(adj2,"but");
sprintf(adj3,"misses");
}
sprintf(message,"%s{R({D%d {W%s{R){w %s{w %s{w, %s{w {R%s{w $m%s{x",autodam, times, adj0, adj1, times_string[times], adj2, adj3,punct);
act_new (message, ch, NULL, vict, TO_CHAR, POS_RESTING);
}
//to_vict
{
adj1 = (replace_string (dam_weapon[weapon_index].to_vict, attack, attack2));
if (weapon_index > 0)
{
sprintf(adj0,"{Rhits{x");
sprintf(adj2,"which");
// sprintf(adj3,"%s",dam_amount[amount_index].to_vict);
sprintf(adj3,"%s",vp);
}
else
{
sprintf(adj0,"{Wmisses{x");
sprintf(adj2,"but");
sprintf(adj3,"misses");
}
sprintf(message,"{R({D%d {W%s{R){w %s{w %s{w, %s{w {R%s{w you%s{x", times, adj0, adj1, times_string[times], adj2, adj3,punct);
act_new (message, ch, NULL, vict, TO_VICT, POS_RESTING);
}
return;
}