From 837112476535466e1eab744d1a8a7f6b7ea16d36 Mon Sep 17 00:00:00 2001 From: kinther Date: Tue, 30 Sep 2025 20:28:33 -0700 Subject: [PATCH] Godcmds logging --- lib/text/help/help.hlp | 37 ++++------------- src/interpreter.c | 90 ++++++++++++++++++++++++------------------ src/utils.c | 11 ++++++ src/utils.h | 4 ++ 4 files changed, 74 insertions(+), 68 deletions(-) diff --git a/lib/text/help/help.hlp b/lib/text/help/help.hlp index 31b9414..923b259 100644 --- a/lib/text/help/help.hlp +++ b/lib/text/help/help.hlp @@ -3926,16 +3926,6 @@ all channels. See also: CHANNELS, MUD-HISTORY #0 -HITROLL - - A bonus added to your armor and weapons that increases your chances of -hitting a creature while in battle. This does not affect how hard you hit, -just how often. - A player at level fifteen with a Hitroll of +25 will hit a creature more -often than a level fifteen player would with a Hitroll of +10. - -See also: DAMROLL, AC, STATS, DAMAGE -#0 HOLYLIGHT LIGHTING LIGHTS TORCHES HOLY-LIGHTING Usage: holylight @@ -4623,7 +4613,6 @@ OBJECT STANDARDS: |Experience | Do not use. | |Armor Class Values | 10 | -10 | |Armor Class Applies^ | 10 | -10 | -|Hitroll & Damroll | 5 | -5 | |Saving_throws^ | 2 | -2 | |Weapon Damage | 50 | 1 | |================================================== @@ -4995,13 +4984,7 @@ objects and quests. See also: AUTOROLL #31 -MEDIT-HITROLL MEDIT-DAMROLL MEDIT-NUMDAMDICE MEDIT-SIZEDAMDICE MEDIT-BHD - -(8) DamRoll: [ 5] - Damroll determines how much damage a mob does per hit when fighting. - -(D) Hitroll: [ 11] - Hitroll determines how often a mob lands a direct hit when fighting. +MEDIT-NUMDAMDICE MEDIT-SIZEDAMDICE MEDIT-BHD Bare Hand Damage (xdy+z): (6) BHD NumDice: [ 5] @@ -5066,8 +5049,6 @@ Here is our autoroll standard, entering mob level will calculate the following: GET_BONUS(OLC_MOB(d)) = mob_lev*10; /* hit point bonus */ GET_HIT(OLC_MOB(d)) = mob_lev/5; /* number of hitpoint dice */ GET_MANA(OLC_MOB(d)) = mob_lev/5; /* size of hitpoint dice */ - GET_HITROLL(OLC_MOB(d)) = mob_lev/3; /* hitroll 0-10 */ - GET_DAMROLL(OLC_MOB(d)) = mob_lev/6; /* damroll 0-5 */ GET_AC(OLC_MOB(d)) = (100-(mob_lev*6)); /* AC 94 to -80 */ GET_NDD(OLC_MOB(d)) = MAX(1, mob_lev/6); /* number damage dice 1-5 */ GET_SDD(OLC_MOB(d)) = MAX(2, mob_lev/6); /* size of damage dice 2-5 */ @@ -5896,13 +5877,11 @@ applies. Suggested object standards are displayed at the end of each apply 16) GOLD Unimplemented. Do not use. 17) EXP Unimplemented. Do not use. 18) ARMOR Apply to armor class (AC). negative is better. -19) HITROLL Apply to hitroll. -20) DAMROLL Apply to damage roll bonus. -21) SAVING_PARA Apply to save throw: paralysis. negative is better. -22) SAVING_ROD Apply to save throw: rods. negative is better. -23) SAVING_PETRI Apply to save throw: petrify. negative is better. -24) SAVING_BREATH Apply to save throw: breathe. negative is better. -25) SAVING_SPELL Apply to save throw: spells. negative is better. +19) SAVING_PARA Apply to save throw: paralysis. negative is better. +20) SAVING_ROD Apply to save throw: rods. negative is better. +21) SAVING_PETRI Apply to save throw: petrify. negative is better. +22) SAVING_BREATH Apply to save throw: breathe. negative is better. +23) SAVING_SPELL Apply to save throw: spells. negative is better. See also: STANDARDS #31 @@ -8574,7 +8553,6 @@ cha Imm BOTH NUMBER class Imm BOTH MISC color God PC BINARY con Imm BOTH NUMBER -damroll Imm BOTH NUMBER deleted IMP PC BINARY dex Imm BOTH NUMBER drunk Imm BOTH MISC @@ -8583,7 +8561,6 @@ frozen GrGod PC BINARY gold Imm BOTH NUMBER height Imm BOTH NUMBER hitpoints Imm BOTH NUMBER -hitroll Imm BOTH NUMBER hunger Imm BOTH MISC int Imm BOTH NUMBER invis God PC NUMBER @@ -9261,7 +9238,7 @@ Intelligence - How smart you are. Determines how much mana you gain per level, opponent and hit him more often, and if you're undead, helps control your followers. -See also: HITROLL, DAMROLL, AC +See also: AC #0 STEAL diff --git a/src/interpreter.c b/src/interpreter.c index 0234489..8762d44 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -497,20 +497,20 @@ void command_interpreter(struct char_data *ch, char *argument) } /* Allow IMPLs to switch into mobs to test the commands. */ - if (IS_NPC(ch) && ch->desc && GET_LEVEL(ch->desc->original) >= LVL_IMPL) { - if (script_command_interpreter(ch, argument)) - return; - } + if (IS_NPC(ch) && ch->desc && GET_LEVEL(ch->desc->original) >= LVL_IMPL) { + if (script_command_interpreter(ch, argument)) + return; + } for (length = strlen(arg), cmd = 0; *complete_cmd_info[cmd].command != '\n'; cmd++) - if(complete_cmd_info[cmd].command_pointer != do_action && - !strncmp(complete_cmd_info[cmd].command, arg, length)) + if (complete_cmd_info[cmd].command_pointer != do_action && + !strncmp(complete_cmd_info[cmd].command, arg, length)) if (GET_LEVEL(ch) >= complete_cmd_info[cmd].minimum_level) break; /* it's not a 'real' command, so it's a social */ - if(*complete_cmd_info[cmd].command == '\n') + if (*complete_cmd_info[cmd].command == '\n') for (length = strlen(arg), cmd = 0; *complete_cmd_info[cmd].command != '\n'; cmd++) if (complete_cmd_info[cmd].command_pointer == do_action && !strncmp(complete_cmd_info[cmd].command, arg, length)) @@ -521,17 +521,14 @@ void command_interpreter(struct char_data *ch, char *argument) int found = 0; send_to_char(ch, "%s", CONFIG_HUH); - for (cmd = 0; *cmd_info[cmd].command != '\n'; cmd++) - { + for (cmd = 0; *cmd_info[cmd].command != '\n'; cmd++) { if (*arg != *cmd_info[cmd].command || cmd_info[cmd].minimum_level > GET_LEVEL(ch)) continue; /* Only apply levenshtein counts if the command is not a trigger command. */ - if ( (levenshtein_distance(arg, cmd_info[cmd].command) <= 2) && - (cmd_info[cmd].minimum_level >= 0) ) - { - if (!found) - { + if ((levenshtein_distance(arg, cmd_info[cmd].command) <= 2) && + (cmd_info[cmd].minimum_level >= 0)) { + if (!found) { send_to_char(ch, "\r\nDid you mean:\r\n"); found = 1; } @@ -547,30 +544,47 @@ void command_interpreter(struct char_data *ch, char *argument) send_to_char(ch, "You can't use immortal commands while switched.\r\n"); else if (GET_POS(ch) < complete_cmd_info[cmd].minimum_position) switch (GET_POS(ch)) { - case POS_DEAD: - send_to_char(ch, "Lie still; you are DEAD!!! :-(\r\n"); - break; - case POS_INCAP: - case POS_MORTALLYW: - send_to_char(ch, "You are in a pretty bad shape, unable to do anything!\r\n"); - break; - case POS_STUNNED: - send_to_char(ch, "All you can do right now is think about the stars!\r\n"); - break; - case POS_SLEEPING: - send_to_char(ch, "In your dreams, or what?\r\n"); - break; - case POS_RESTING: - send_to_char(ch, "Nah... You feel too relaxed to do that..\r\n"); - break; - case POS_SITTING: - send_to_char(ch, "Maybe you should get on your feet first?\r\n"); - break; - case POS_FIGHTING: - send_to_char(ch, "No way! You're fighting for your life!\r\n"); - break; - } else if (no_specials || !special(ch, cmd, line)) - ((*complete_cmd_info[cmd].command_pointer) (ch, line, cmd, complete_cmd_info[cmd].subcmd)); + case POS_DEAD: + send_to_char(ch, "Lie still; you are DEAD!!! :-(\r\n"); + break; + case POS_INCAP: + case POS_MORTALLYW: + send_to_char(ch, "You are in a pretty bad shape, unable to do anything!\r\n"); + break; + case POS_STUNNED: + send_to_char(ch, "All you can do right now is think about the stars!\r\n"); + break; + case POS_SLEEPING: + send_to_char(ch, "In your dreams, or what?\r\n"); + break; + case POS_RESTING: + send_to_char(ch, "Nah... You feel too relaxed to do that..\r\n"); + break; + case POS_SITTING: + send_to_char(ch, "Maybe you should get on your feet first?\r\n"); + break; + case POS_FIGHTING: + send_to_char(ch, "No way! You're fighting for your life!\r\n"); + break; + } + else if (no_specials || !special(ch, cmd, line)) { + /* Execute the command */ + ((*complete_cmd_info[cmd].command_pointer)(ch, line, cmd, complete_cmd_info[cmd].subcmd)); + + /* After successful execution, log any immortal command to log/godcmds. */ + if (!IS_NPC(ch) && GET_LEVEL(ch) >= LVL_IMMORT) { + int rvnum = (IN_ROOM(ch) != NOWHERE) ? world[IN_ROOM(ch)].number : -1; + const char *line_safe = (line && *line) ? line : ""; + godcmd_log("%s (lev %d, invis %d) in room %d: %s%s%s", + GET_NAME(ch), + GET_LEVEL(ch), + GET_INVIS_LEV(ch), + rvnum, + complete_cmd_info[cmd].command, + *line_safe ? " " : "", + line_safe); + } + } } /* Routines to handle aliasing. */ diff --git a/src/utils.c b/src/utils.c index 44c2530..cd5099f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -24,6 +24,17 @@ #include "class.h" #include "constants.h" +/* Log immortal commands */ +void godcmd_log(const char *fmt, ...) +{ + FILE *fp = fopen(GODCMDS_FILE, "a"); + if (!fp) { perror("godcmds"); return; } + va_list ap; va_start(ap, fmt); + vfprintf(fp, fmt, ap); fputc('\n', fp); + va_end(ap); + fclose(fp); +} + /** Aportable random number function. * @param from The lower bounds of the random number. * @param to The upper bounds of the random number. */ diff --git a/src/utils.h b/src/utils.h index 8ef5d68..543a9ea 100644 --- a/src/utils.h +++ b/src/utils.h @@ -33,6 +33,9 @@ /** direct all log() references to basic_mud_log() function. */ #define log basic_mud_log +/* Immortal command log */ +#define GODCMDS_FILE "../log/godcmds" + /** Standard line size, used for many string limits. */ #define READ_SIZE 256 @@ -40,6 +43,7 @@ * are made available with the function definition. */ void basic_mud_log(const char *format, ...) __attribute__ ((format (printf, 1, 2))); void basic_mud_vlog(const char *format, va_list args); +void godcmd_log(const char *fmt, ...) __attribute__((format(printf,1,2))); int touch(const char *path); void mudlog(int type, int level, int file, const char *str, ...) __attribute__ ((format (printf, 4, 5))); int rand_number(int from, int to);