/* * message for doing damage with a spell or skill * C3.0: Also used for weapon damage on miss and death blows */ int skill_message(int dam, struct char_data * ch, struct char_data * vict, int attacktype) { int i, j, nr; struct message_type *msg; struct obj_data *weap = GET_EQ(ch, WEAR_WIELD); for (i = 0; i < MAX_MESSAGES; i++) { if (fight_messages[i].a_type == attacktype) { nr = dice(1, fight_messages[i].number_of_attacks); for (j = 1, msg = fight_messages[i].msg; (j < nr) && msg; j++) msg = msg->next; if (!IS_NPC(vict) && (GET_LEVEL(vict) >= LVL_IMMORT)) { act(msg->god_msg.attacker_msg, FALSE, ch, weap, vict, TO_CHAR); act(msg->god_msg.victim_msg, FALSE, ch, weap, vict, TO_VICT); act(msg->god_msg.room_msg, FALSE, ch, weap, vict, TO_NOTVICT); } else if (dam != 0) { if (GET_POS(vict) == POS_DEAD) { send_to_char(CCYEL(ch, C_CMP), ch); act(msg->die_msg.attacker_msg, FALSE, ch, weap, vict, TO_CHAR); send_to_char(CCNRM(ch, C_CMP), ch); send_to_char(CCRED(vict, C_CMP), vict); act(msg->die_msg.victim_msg, FALSE, ch, weap, vict, TO_VICT | TO_SLEEP); send_to_char(CCNRM(vict, C_CMP), vict); act(msg->die_msg.room_msg, FALSE, ch, weap, vict, TO_NOTVICT); } else { send_to_char(CCYEL(ch, C_CMP), ch); act(msg->hit_msg.attacker_msg, FALSE, ch, weap, vict, TO_CHAR); send_to_char(CCNRM(ch, C_CMP), ch); send_to_char(CCRED(vict, C_CMP), vict); act(msg->hit_msg.victim_msg, FALSE, ch, weap, vict, TO_VICT | TO_SLEEP); send_to_char(CCNRM(vict, C_CMP), vict); act(msg->hit_msg.room_msg, FALSE, ch, weap, vict, TO_NOTVICT); } } else if (ch != vict) { /* Dam == 0 */ send_to_char(CCYEL(ch, C_CMP), ch); act(msg->miss_msg.attacker_msg, FALSE, ch, weap, vict, TO_CHAR); send_to_char(CCNRM(ch, C_CMP), ch); send_to_char(CCRED(vict, C_CMP), vict); act(msg->miss_msg.victim_msg, FALSE, ch, weap, vict, TO_VICT | TO_SLEEP); send_to_char(CCNRM(vict, C_CMP), vict); act(msg->miss_msg.room_msg, FALSE, ch, weap, vict, TO_NOTVICT); } return (1); } } return (0); }
void check_thief(struct creature *ch, struct creature *victim) { struct creature *perp; // First we need to find the perp perp = find_responsible_party(ch, victim); int gain = pk_reputation_gain(perp, victim); if (!gain) return; gain = MAX(1, gain / 10); gain_reputation(perp, gain); send_to_char(perp, "%sYou have gained %d reputation for stealing from %s.%s\r\n", CCRED(perp, C_NRM), gain, GET_NAME(victim), CCNRM(perp, C_NRM)); send_to_char(victim, "%s%s has gained %d reputation for stealing from you.%s\r\n", CCYEL(victim, C_NRM), GET_NAME(perp), gain, CCNRM(victim, C_NRM)); mudlog(LVL_IMMORT, CMP, true, "%s gained %d reputation for stealing from %s", GET_NAME(perp), gain, GET_NAME(victim)); create_grievance(victim, perp, gain, THEFT); if (is_arena_combat(ch, victim)) mudlog(LVL_POWER, CMP, true, "%s pstealing from %s in arena", GET_NAME(perp), GET_NAME(victim)); }
void count_pkill(struct creature *killer, struct creature *victim) { bool award_bounty(struct creature *, struct creature *); struct creature *perp; if (is_arena_combat(killer, victim)) return; perp = find_responsible_party(killer, victim); GET_PKILLS(perp)++; if (award_bounty(perp, victim)) return; int gain = pk_reputation_gain(perp, victim); if (!gain) return; gain_reputation(perp, gain); send_to_char(perp, "%sYou have gained %d reputation for heinously murdering %s.%s\r\n", CCRED(killer, C_NRM), gain, GET_NAME(victim), CCNRM(perp, C_NRM)); send_to_char(victim, "%s%s has gained %d reputation for heinously murdering you.%s\r\n", CCYEL(killer, C_NRM), GET_NAME(perp), gain, CCNRM(victim, C_NRM)); mudlog(LVL_IMMORT, CMP, true, "%s gained %d reputation for murdering %s", GET_NAME(perp), gain, GET_NAME(victim)); create_grievance(victim, perp, gain, MURDER); }
void check_attack(struct creature *attacker, struct creature *victim) { bool is_bountied(struct creature *hunter, struct creature *vict); struct creature *perp; // No reputation for attacking in arena if (is_arena_combat(attacker, victim)) return; perp = find_responsible_party(attacker, victim); // no reputation for attacking a bountied person if (is_bountied(perp, victim)) return; int gain = pk_reputation_gain(perp, victim); if (!gain) return; gain = MAX(1, gain / 5); gain_reputation(perp, gain); send_to_char(perp, "%sYou have gained %d reputation for viciously attacking %s.%s\r\n", CCRED(perp, C_NRM), gain, GET_NAME(victim), CCNRM(perp, C_NRM)); send_to_char(victim, "%s%s has gained %d reputation for viciously attacking you.%s\r\n", CCYEL(victim, C_NRM), GET_NAME(perp), gain, CCNRM(victim, C_NRM)); mudlog(LVL_IMMORT, CMP, true, "%s gained %d reputation for attacking %s", GET_NAME(perp), gain, GET_NAME(victim)); create_grievance(victim, perp, gain, ATTACK); }
void gen_board_list(struct board_data *board, struct creature *ch) { PGresult *res; char time_buf[30]; int idx, count; time_t post_time; res = sql_query ("select extract(epoch from post_time), name, subject from board_messages where board='%s' order by idnum desc", tmp_sqlescape(board->name)); count = PQntuples(res); if (count == 0) { send_to_char(ch, "This board is empty.\r\n"); return; } acc_string_clear(); acc_sprintf ("This is a bulletin board. Usage: READ/REMOVE <messg #>, WRITE <header>\r\n%sThere %s %d message%s on the board.%s\r\n", CCGRN(ch, C_NRM), (count == 1) ? "is" : "are", count, (count == 1) ? "" : "s", CCNRM(ch, C_NRM)); for (idx = 0; idx < count; idx++) { post_time = atol(PQgetvalue(res, idx, 0)); strftime(time_buf, 30, "%b %e, %Y", localtime(&post_time)); acc_sprintf("%s%-2d %s:%s %s %-12s :: %s\r\n", CCGRN(ch, C_NRM), count - idx, CCRED(ch, C_NRM), CCNRM(ch, C_NRM), time_buf, tmp_sprintf("(%s)", PQgetvalue(res, idx, 1)), PQgetvalue(res, idx, 2)); } page_string(ch->desc, acc_get_string()); }
/* * Set the colour string pointers for that which this char will * see at color level NRM. Changing the entries here will change * the colour scheme throughout the OLC. */ void get_char_colors(struct char_data *ch) { nrm = CCNRM(ch, C_NRM); grn = CCGRN(ch, C_NRM); cyn = CCCYN(ch, C_NRM); yel = CCYEL(ch, C_NRM); red = CCRED(ch, C_NRM); }
void perform_tell(struct char_data *ch, struct char_data *vict, char *arg) { struct descriptor_data *i; send_to_char(CCRED(vict, C_NRM), vict); sprintf(buf, "$n tells you, '%s'", arg); if (GET_LEVEL(ch) >= LVL_IMMORT) sprintf(buf1, "%s tells you, '%s'", CAN_SEE(vict, ch) ? GET_NAME(ch) : "An Immortal", arg); else sprintf(buf1, "%s tells you, '%s'", CAN_SEE(vict, ch) ? GET_NAME(ch) : "Someone", arg); logthistory(buf1, vict); act(buf, FALSE, ch, 0, vict, TO_VICT | TO_SLEEP); send_to_char(CCNRM(vict, C_NRM), vict); if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT)) send_to_char(OK, ch); else { send_to_char(CCRED(ch, C_CMP), ch); sprintf(buf, "You tell $N, '%s'", arg); if (GET_LEVEL(vict) < LVL_IMMORT) sprintf(buf1, "You tell %s, '%s'", CAN_SEE(ch, vict) ? GET_NAME(vict) : "Someone",arg); else sprintf(buf1, "You tell %s, '%s'", CAN_SEE(ch, vict) ? GET_NAME(vict) : "An Immortal",arg); logthistory(buf1, ch); act(buf, FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP); send_to_char(CCNRM(ch, C_CMP), ch); } for (i = descriptor_list; i; i = i->next) if (STATE(i) == CON_PLAYING && i != ch->desc && i != vict->desc && PRF_FLAGGED2(i->character, PRF2_HEARALLTELL) && GET_LEVEL(i->character) == LVL_IMPL && !IS_NPC(ch) && !IS_NPC(vict)) { send_to_char(CCRED(i->character, C_CMP), i->character); sprintf(buf, ">> %s tells %s, '%s'\r\n", GET_NAME(ch), GET_NAME(vict), arg); send_to_char(buf, i->character); send_to_char(CCNRM(i->character, C_CMP), i->character); } if (!IS_NPC(vict) && !IS_NPC(ch)) GET_LAST_TELL(vict) = GET_IDNUM(ch); }
static void perform_tell(struct char_data *ch, struct char_data *vict, char *arg) { char buf[MAX_STRING_LENGTH], *msg; snprintf(buf, sizeof(buf), "%s$n tells you, '%s'%s", CCRED(vict, C_NRM), arg, CCNRM(vict, C_NRM)); msg = act(buf, FALSE, ch, 0, vict, TO_VICT | TO_SLEEP); add_history(vict, msg, HIST_TELL); if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT)) send_to_char(ch, "%s", CONFIG_OK); else { snprintf(buf, sizeof(buf), "%sYou tell $N, '%s'%s", CCRED(ch, C_NRM), arg, CCNRM(ch, C_NRM)); msg = act(buf, FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP); add_history(ch, msg, HIST_TELL); } if (!IS_NPC(vict) && !IS_NPC(ch)) GET_LAST_TELL(vict) = GET_IDNUM(ch); }
void perform_tell(struct char_data *ch, struct char_data *vict, char *arg) { char buf[MAX_STRING_LENGTH]; send_to_char(vict, "%s", CCRED(vict, C_NRM)); snprintf(buf, sizeof(buf), "$n tells you, '%s'", arg); act(buf, FALSE, ch, 0, vict, TO_VICT | TO_SLEEP); send_to_char(vict, "%s", CCNRM(vict, C_NRM)); if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT)) send_to_char(ch, "%s", OK); else { send_to_char(ch, "%s", CCRED(ch, C_CMP)); snprintf(buf, sizeof(buf), "You tell $N, '%s'", arg); act(buf, FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP); send_to_char(ch, "%s", CCNRM(ch, C_CMP)); } if (!IS_NPC(vict) && !IS_NPC(ch)) GET_LAST_TELL(vict) = GET_IDNUM(ch); }
// Returns a tmpstr allocated char* containing an appropriate ANSI // color code for the given target struct creature (tch) with the given // recipient struct creature(ch)'s color settings in mind. const char * get_char_class_color_code(struct creature *ch, struct creature *tch, int char_class) { switch (char_class) { case CLASS_MAGIC_USER: return CCMAG(ch, C_NRM); case CLASS_CLERIC: if (IS_GOOD(tch)) { return CCBLU_BLD(ch, C_NRM); } else if (IS_EVIL(tch)) { return CCRED_BLD(ch, C_NRM); } else { return CCYEL(ch, C_NRM); } case CLASS_KNIGHT: if (IS_GOOD(tch)) { return CCBLU_BLD(ch, C_NRM); } else if (IS_EVIL(tch)) { return CCRED(ch, C_NRM); } else { return CCYEL(ch, C_NRM); } case CLASS_RANGER: return CCGRN(ch, C_NRM); case CLASS_BARB: return CCCYN(ch, C_NRM); case CLASS_THIEF: return CCNRM_BLD(ch, C_NRM); case CLASS_CYBORG: return CCCYN(ch, C_NRM); case CLASS_PSIONIC: return CCMAG(ch, C_NRM); case CLASS_PHYSIC: return CCNRM_BLD(ch, C_NRM); case CLASS_BARD: return CCYEL_BLD(ch, C_NRM); case CLASS_MONK: return CCGRN(ch, C_NRM); case CLASS_MERCENARY: return CCYEL(ch, C_NRM); default: return CCNRM(ch, C_NRM); } }
/* * Alert: As of bpl14, this function returns the following codes: * < 0 Victim died. * = 0 No damage. * > 0 How much damage done. */ int damage(struct char_data *ch, struct char_data *victim, int dam, int attacktype) { if (GET_POS(victim) <= POS_DEAD) { /* This is "normal"-ish now with delayed extraction. -gg 3/15/2001 */ if (PLR_FLAGGED(victim, PLR_NOTDEADYET) || MOB_FLAGGED(victim, MOB_NOTDEADYET)) return (-1); log("SYSERR: Attempt to damage corpse '%s' in room #%d by '%s'.", GET_NAME(victim), GET_ROOM_VNUM(IN_ROOM(victim)), GET_NAME(ch)); die(victim); return (-1); /* -je, 7/7/92 */ } /* peaceful rooms */ if (ch != victim && ROOM_FLAGGED(IN_ROOM(ch), ROOM_PEACEFUL)) { send_to_char(ch, "This room just has such a peaceful, easy feeling...\r\n"); return (0); } /* shopkeeper protection */ if (!ok_damage_shopkeeper(ch, victim)) return (0); /* You can't damage an immortal! */ if (!IS_NPC(victim) && (GET_LEVEL(victim) >= LVL_IMMORT)) dam = 0; if (victim != ch) { /* Start the attacker fighting the victim */ if (GET_POS(ch) > POS_STUNNED && (FIGHTING(ch) == NULL)) set_fighting(ch, victim); /* Start the victim fighting the attacker */ if (GET_POS(victim) > POS_STUNNED && (FIGHTING(victim) == NULL)) { set_fighting(victim, ch); if (MOB_FLAGGED(victim, MOB_MEMORY) && !IS_NPC(ch)) remember(victim, ch); } } /* If you attack a pet, it hates your guts */ if (victim->master == ch) stop_follower(victim); /* If the attacker is invisible, he becomes visible */ if (AFF_FLAGGED(ch, AFF_INVISIBLE | AFF_HIDE)) appear(ch); /* Cut damage in half if victim has sanct, to a minimum 1 */ if (AFF_FLAGGED(victim, AFF_SANCTUARY) && dam >= 2) dam /= 2; /* Check for PK if this is not a PK MUD */ if (!pk_allowed) { check_killer(ch, victim); if (PLR_FLAGGED(ch, PLR_KILLER) && (ch != victim)) dam = 0; } /* Set the maximum damage per round and subtract the hit points */ dam = MAX(MIN(dam, 100), 0); GET_HIT(victim) -= dam; /* Gain exp for the hit */ if (ch != victim) gain_exp(ch, GET_LEVEL(victim) * dam); update_pos(victim); /* * skill_message sends a message from the messages file in lib/misc. * dam_message just sends a generic "You hit $n extremely hard.". * skill_message is preferable to dam_message because it is more * descriptive. * * If we are _not_ attacking with a weapon (i.e. a spell), always use * skill_message. If we are attacking with a weapon: If this is a miss or a * death blow, send a skill_message if one exists; if not, default to a * dam_message. Otherwise, always send a dam_message. */ if (!IS_WEAPON(attacktype)) skill_message(dam, ch, victim, attacktype); else { if (GET_POS(victim) == POS_DEAD || dam == 0) { if (!skill_message(dam, ch, victim, attacktype)) dam_message(dam, ch, victim, attacktype); } else { dam_message(dam, ch, victim, attacktype); } } /* Use send_to_char -- act() doesn't send message if you are DEAD. */ switch (GET_POS(victim)) { case POS_MORTALLYW: act("$n is mortally wounded, and will die soon, if not aided.", TRUE, victim, 0, 0, CommTarget::TO_ROOM); send_to_char(victim, "You are mortally wounded, and will die soon, if not aided.\r\n"); break; case POS_INCAP: act("$n is incapacitated and will slowly die, if not aided.", TRUE, victim, 0, 0, CommTarget::TO_ROOM); send_to_char(victim, "You are incapacitated an will slowly die, if not aided.\r\n"); break; case POS_STUNNED: act("$n is stunned, but will probably regain consciousness again.", TRUE, victim, 0, 0, CommTarget::TO_ROOM); send_to_char(victim, "You're stunned, but will probably regain consciousness again.\r\n"); break; case POS_DEAD: act("$n is dead! R.I.P.", FALSE, victim, 0, 0, CommTarget::TO_ROOM); send_to_char(victim, "You are dead! Sorry...\r\n"); break; default: /* >= POSITION SLEEPING */ if (dam > (GET_MAX_HIT(victim) / 4)) send_to_char(victim, "That really did HURT!\r\n"); if (GET_HIT(victim) < (GET_MAX_HIT(victim) / 4)) { send_to_char(victim, "%sYou wish that your wounds would stop BLEEDING so much!%s\r\n", CCRED(victim, C_SPR), CCNRM(victim, C_SPR)); if (ch != victim && MOB_FLAGGED(victim, MOB_WIMPY)) do_flee(victim, NULL, 0, 0); } if (!IS_NPC(victim) && GET_WIMP_LEV(victim) && (victim != ch) && GET_HIT(victim) < GET_WIMP_LEV(victim) && GET_HIT(victim) > 0) { send_to_char(victim, "You wimp out, and attempt to flee!\r\n"); do_flee(victim, NULL, 0, 0); } break; } /* Help out poor linkless people who are attacked */ if (!IS_NPC(victim) && !(victim->desc) && GET_POS(victim) > POS_STUNNED) { do_flee(victim, NULL, 0, 0); if (!FIGHTING(victim)) { act("$n is rescued by divine forces.", FALSE, victim, 0, 0, CommTarget::TO_ROOM); GET_WAS_IN(victim) = IN_ROOM(victim); char_from_room(victim); char_to_room(victim, 0); } } /* stop someone from fighting if they're stunned or worse */ if (GET_POS(victim) <= POS_STUNNED && FIGHTING(victim) != NULL) stop_fighting(victim); /* Uh oh. Victim died. */ if (GET_POS(victim) == POS_DEAD) { if (ch != victim && (IS_NPC(victim) || victim->desc)) { if (AFF_FLAGGED(ch, AFF_GROUP)) group_gain(ch, victim); else solo_gain(ch, victim); } if (!IS_NPC(victim)) { mudlog(BRF, LVL_IMMORT, TRUE, "%s killed by %s at %s", GET_NAME(victim), GET_NAME(ch), world[IN_ROOM(victim)].name); if (MOB_FLAGGED(ch, MOB_MEMORY)) forget(ch, victim); } die(victim); return (-1); } return (dam); }
/* message for doing damage with a weapon */ void dam_message(int dam, struct char_data *ch, struct char_data *victim, int w_type) { char *buf; int msgnum; static struct dam_weapon_type { const char *to_room; const char *to_char; const char *to_victim; } dam_weapons[] = { /* use #w for singular (i.e. "slash") and #W for plural (i.e. "slashes") */ { "$n tries to #w $N, but misses.", /* 0: 0 */ "You try to #w $N, but miss.", "$n tries to #w you, but misses." }, { "$n tickles $N as $e #W $M.", /* 1: 1..2 */ "You tickle $N as you #w $M.", "$n tickles you as $e #W you." }, { "$n barely #W $N.", /* 2: 3..4 */ "You barely #w $N.", "$n barely #W you." }, { "$n #W $N.", /* 3: 5..6 */ "You #w $N.", "$n #W you." }, { "$n #W $N hard.", /* 4: 7..10 */ "You #w $N hard.", "$n #W you hard." }, { "$n #W $N very hard.", /* 5: 11..14 */ "You #w $N very hard.", "$n #W you very hard." }, { "$n #W $N extremely hard.", /* 6: 15..19 */ "You #w $N extremely hard.", "$n #W you extremely hard." }, { "$n massacres $N to small fragments with $s #w.", /* 7: 19..23 */ "You massacre $N to small fragments with your #w.", "$n massacres you to small fragments with $s #w." }, { "$n OBLITERATES $N with $s deadly #w!!", /* 8: > 23 */ "You OBLITERATE $N with your deadly #w!!", "$n OBLITERATES you with $s deadly #w!!" } }; w_type -= TYPE_HIT; /* Change to base of table with text */ if (dam == 0) msgnum = 0; else if (dam <= 2) msgnum = 1; else if (dam <= 4) msgnum = 2; else if (dam <= 6) msgnum = 3; else if (dam <= 10) msgnum = 4; else if (dam <= 14) msgnum = 5; else if (dam <= 19) msgnum = 6; else if (dam <= 23) msgnum = 7; else msgnum = 8; /* damage message to onlookers */ buf = replace_string(dam_weapons[msgnum].to_room, attack_hit_text[w_type].singular, attack_hit_text[w_type].plural); act(buf, FALSE, ch, NULL, victim, CommTarget::TO_NOTVICT); /* damage message to damager */ send_to_char(ch, CCYEL(ch, C_CMP)); buf = replace_string(dam_weapons[msgnum].to_char, attack_hit_text[w_type].singular, attack_hit_text[w_type].plural); act(buf, FALSE, ch, NULL, victim, CommTarget::TO_CHAR); send_to_char(ch, CCNRM(ch, C_CMP)); /* damage message to damagee */ send_to_char(victim, CCRED(victim, C_CMP)); buf = replace_string(dam_weapons[msgnum].to_victim, attack_hit_text[w_type].singular, attack_hit_text[w_type].plural); act(buf, FALSE, ch, NULL, victim, CommTarget::TO_VICT | CommTarget::TO_SLEEP); send_to_char(victim, CCNRM(victim, C_CMP)); }