Welcome to the Builder Academy

Question Stat Roller Snippet Problem

More
12 Nov 2024 02:15 #10434 by wlessard1
I found this snippet in the Google Drive. Followed it exactly. 

Problem is it compiles fine and when a new player logs in, they can spin the roller constantly until they get what they want. Thought I am going to look deeper and maybe just weight it a bit. After all players are basically heroes and should have some fair to good stats. When they say N to rolling more, it goes fine into the Start Screen. 

When I choose 1 to enter game, it crashes. 

Any help to figure out the reason would be nice. 

It doesn't matter too much as I am just puttering around with code. I don't see myself publishing a MUD again. I left that long ago. For me it is more like whittling a stick, it is fun to try and solve problem if I can. Like puttering in the garage working on something for no reason. Keeps me busy and my mind agile.

Thanks Folks for any help.


Anyways here is the snippet

diff -BbuprN -x '*.o' /home/zizazat/tmp/glimblade/gen/src/class.c gen/src/class.c
--- /home/zizazat/tmp/glimblade/gen/src/class.c 2004-02-29 12:40:35.000000000 -0600
+++ gen/src/class.c 2004-05-10 19:31:02.000000000 -0500
@@ -1472,7 +1472,7 @@ void do_start(struct char_data *ch)
    SET_BIT_AR(AFF_FLAGS(ch), AFF_INFRAVISION);

  set_title(ch, NULL);
-  roll_real_abils(ch);
+  /* roll_real_abils(ch); */

  GET_MAX_HIT(ch)  = 10;
  GET_MAX_MANA(ch) = 100;
diff -BbuprN -x '*.o' /home/zizazat/tmp/glimblade/gen/src/constants.c gen/src/constants.c
--- /home/zizazat/tmp/glimblade/gen/src/constants.c 2004-05-01 18:16:18.000000000 -0500
+++ gen/src/constants.c 2004-05-10 19:16:21.000000000 -0500
@@ -342,6 +342,7 @@ const char *connected_types[] = {
  "Race help",
  "Class help",
  "Guild edit",
+  "Reroll stats",
  "\n"
};

diff -BbuprN -x '*.o' /home/zizazat/tmp/glimblade/gen/src/db.c gen/src/db.c
--- /home/zizazat/tmp/glimblade/gen/src/db.c 2004-03-30 19:59:52.000000000 -0600
+++ gen/src/db.c 2004-05-10 19:40:44.000000000 -0500
@@ -3777,13 +3777,13 @@ void init_char(struct char_data *ch)
  for (i = 0; i < 5; i++)
    GET_SAVE(ch, i) = 0;

-  ch->real_abils.intel = 25;
+/*  ch->real_abils.intel = 25;
  ch->real_abils.wis = 25;
  ch->real_abils.dex = 25;
  ch->real_abils.str = 25;
  ch->real_abils.str_add = 100;
  ch->real_abils.con = 25;
-  ch->real_abils.cha = 25;
+  ch->real_abils.cha = 25; */

  for (i = 0; i < 3; i++)
    GET_COND(ch, i) = (GET_LEVEL(ch) == LVL_IMPL ? -1 : 24);
diff -BbuprN -x '*.o' /home/zizazat/tmp/glimblade/gen/src/interpreter.c gen/src/interpreter.c
--- /home/zizazat/tmp/glimblade/gen/src/interpreter.c 2004-05-01 18:16:04.000000000 -0500
+++ gen/src/interpreter.c 2004-05-10 19:34:53.000000000 -0500
@@ -72,6 +72,7 @@ extern const char *class_display[];
extern const char *race_display[];
void gedit_disp_menu(struct descriptor_data *d);
void gedit_parse(struct descriptor_data *d, char *arg);
+void roll_real_abils(struct char_data *ch);

/* local functions */
int perform_dupe_check(struct descriptor_data *d);
@@ -1876,6 +1877,29 @@ void nanny(struct descriptor_data *d, ch
    } else
      GET_CLASS(d->character) = load_result;

+    write_to_output(d, "\r\nPress enter to roll your stats.");
+    STATE(d) = CON_QROLLSTATS;
+    break;
+
+  case CON_QROLLSTATS:
+    switch (*arg) {
+      case 'y':
+      case 'Y':
+        break;
+      case 'n':
+      case 'N':
+      default:
+        roll_real_abils(d->character);
+        write_to_output(d, "\r\nStr: [%d/%d] Int: [%d] Wis: [%d] Dex:"
+          " [%d] Con: [%d] Cha: [%d]",
+          GET_STR(d->character), GET_ADD(d->character),
+          GET_INT(d->character), GET_WIS(d->character),
+          GET_DEX(d->character), GET_CON(d->character),
+          GET_CHA(d->character));
+        write_to_output(d, "\r\n\r\nKeep these stats? (y/N)");
+        return;
+    }
+
    if (GET_PFILEPOS(d->character) < 0)
      GET_PFILEPOS(d->character) = create_entry(GET_PC_NAME(d->character));
    /* Now GET_NAME() will work properly. */
diff -BbuprN -x '*.o' /home/zizazat/tmp/glimblade/gen/src/structs.h gen/src/structs.h
--- /home/zizazat/tmp/glimblade/gen/src/structs.h 2004-05-01 18:10:59.000000000 -0500
+++ gen/src/structs.h 2004-05-10 19:16:02.000000000 -0500
@@ -321,6 +321,7 @@
#define CON_CLASS_HELP  30 /* Class Help */
#define CON_QANSI 31 /* Ask for ANSI support    */
#define CON_GEDIT 32 /* OLC mode - guild editor */
+#define CON_QROLLSTATS 33 /* OLC mode - guild editor */

/* Character equipment positions: used as index for char_data.equipment[] */
/* NOTE: Don't confuse these constants with the ITEM_ bitvectors
reroll.patch
Displaying reroll.patch.









diff -BbuprN -x '*.o' /home/zizazat/tmp/glimblade/gen/src/class.c gen/src/class.c
--- /home/zizazat/tmp/glimblade/gen/src/class.c 2004-02-29 12:40:35.000000000 -0600
+++ gen/src/class.c 2004-05-10 19:31:02.000000000 -0500
@@ -1472,7 +1472,7 @@ void do_start(struct char_data *ch)
    SET_BIT_AR(AFF_FLAGS(ch), AFF_INFRAVISION);

  set_title(ch, NULL);
-  roll_real_abils(ch);
+  /* roll_real_abils(ch); */

  GET_MAX_HIT(ch)  = 10;
  GET_MAX_MANA(ch) = 100;
diff -BbuprN -x '*.o' /home/zizazat/tmp/glimblade/gen/src/constants.c gen/src/constants.c
--- /home/zizazat/tmp/glimblade/gen/src/constants.c 2004-05-01 18:16:18.000000000 -0500
+++ gen/src/constants.c 2004-05-10 19:16:21.000000000 -0500
@@ -342,6 +342,7 @@ const char *connected_types[] = {
  "Race help",
  "Class help",
  "Guild edit",
+  "Reroll stats",
  "\n"
};

diff -BbuprN -x '*.o' /home/zizazat/tmp/glimblade/gen/src/db.c gen/src/db.c
--- /home/zizazat/tmp/glimblade/gen/src/db.c 2004-03-30 19:59:52.000000000 -0600
+++ gen/src/db.c 2004-05-10 19:40:44.000000000 -0500
@@ -3777,13 +3777,13 @@ void init_char(struct char_data *ch)
  for (i = 0; i < 5; i++)
    GET_SAVE(ch, i) = 0;

-  ch->real_abils.intel = 25;
+/*  ch->real_abils.intel = 25;
  ch->real_abils.wis = 25;
  ch->real_abils.dex = 25;
  ch->real_abils.str = 25;
  ch->real_abils.str_add = 100;
  ch->real_abils.con = 25;
-  ch->real_abils.cha = 25;
+  ch->real_abils.cha = 25; */

  for (i = 0; i < 3; i++)
    GET_COND(ch, i) = (GET_LEVEL(ch) == LVL_IMPL ? -1 : 24);
diff -BbuprN -x '*.o' /home/zizazat/tmp/glimblade/gen/src/interpreter.c gen/src/interpreter.c
--- /home/zizazat/tmp/glimblade/gen/src/interpreter.c 2004-05-01 18:16:04.000000000 -0500
+++ gen/src/interpreter.c 2004-05-10 19:34:53.000000000 -0500
@@ -72,6 +72,7 @@ extern const char *class_display[];
extern const char *race_display[];
void gedit_disp_menu(struct descriptor_data *d);
void gedit_parse(struct descriptor_data *d, char *arg);
+void roll_real_abils(struct char_data *ch);

/* local functions */
int perform_dupe_check(struct descriptor_data *d);
@@ -1876,6 +1877,29 @@ void nanny(struct descriptor_data *d, ch
    } else
      GET_CLASS(d->character) = load_result;

+    write_to_output(d, "\r\nPress enter to roll your stats.");
+    STATE(d) = CON_QROLLSTATS;
+    break;
+
+  case CON_QROLLSTATS:
+    switch (*arg) {
+      case 'y':
+      case 'Y':
+        break;
+      case 'n':
+      case 'N':
+      default:
+        roll_real_abils(d->character);
+        write_to_output(d, "\r\nStr: [%d/%d] Int: [%d] Wis: [%d] Dex:"
+          " [%d] Con: [%d] Cha: [%d]",
+          GET_STR(d->character), GET_ADD(d->character),
+          GET_INT(d->character), GET_WIS(d->character),
+          GET_DEX(d->character), GET_CON(d->character),
+          GET_CHA(d->character));
+        write_to_output(d, "\r\n\r\nKeep these stats? (y/N)");
+        return;
+    }
+
    if (GET_PFILEPOS(d->character) < 0)
      GET_PFILEPOS(d->character) = create_entry(GET_PC_NAME(d->character));
    /* Now GET_NAME() will work properly. */
diff -BbuprN -x '*.o' /home/zizazat/tmp/glimblade/gen/src/structs.h gen/src/structs.h
--- /home/zizazat/tmp/glimblade/gen/src/structs.h 2004-05-01 18:10:59.000000000 -0500
+++ gen/src/structs.h 2004-05-10 19:16:02.000000000 -0500
@@ -321,6 +321,7 @@
#define CON_CLASS_HELP  30 /* Class Help */
#define CON_QANSI 31 /* Ask for ANSI support    */
#define CON_GEDIT 32 /* OLC mode - guild editor */
+#define CON_QROLLSTATS 33 /* OLC mode - guild editor */

/* Character equipment positions: used as index for char_data.equipment[] */
/* NOTE: Don't confuse these constants with the ITEM_ bitvectors

reroll.patch





Open with





[color=rgba(255, 255, 255, 0.87)] Share


32x32



[/color]
Displaying reroll.patch.

Please Log in or Create an account to join the conversation.

More
01 Jun 2025 15:06 #10745 by Salty
Replied by Salty on topic Stat Roller Snippet Problem
While I can’t currently help with your issue, I can post a snippet of my stat roller in about 12 hours from now. I’ll also provide instructions on how to implement it, not just a diff.

Please Log in or Create an account to join the conversation.

More
02 Jun 2025 20:57 #10747 by thomas
Replied by thomas on topic Stat Roller Snippet Problem
I think the reroll code here is incomplete (it looks like some of the code is duplicated and some is missing).

Please Log in or Create an account to join the conversation.

Time to create page: 0.240 seconds