Small snip I put together to maybe take a pinch of the burden off of Vatiken. This will enable you to also make custom fail messages within the crafting olc.
If you have any questions don't hesitate to ask.
4) Success Self : "Wood shavings fly as you work the foot pump that brings the lathe to life. The end result is $p."
5) Success Room : "Wood shavings fly as $n works the foot pump of the lathe. Shortly after, $n holds up a $p for you to admire."
6) Failure Self : "You can't control the speed of the lathe and your oak branch is destroyed in the process."
7) Failure Room : "$n can't control the speed of the lathe resulting in nothing more than splintered wood."
Code:
In crafts.c
new_craft->craft_msg_room = NULL;
new_craft->craft_msg_self = NULL;
+ new_craft->craft_fail_msg_room = NULL;
+ new_craft->craft_fail_msg_self = NULL;
--------------------------
if (craft->craft_name)
free(craft->craft_name);
if (craft->craft_msg_self)
free(craft->craft_msg_self);
if (craft->craft_msg_room)
free(craft->craft_msg_room);
+ if (craft->craft_fail_msg_self)
+ free(craft->craft_fail_msg_self);
+
+ if (craft->craft_fail_msg_room)
+ free(craft->craft_fail_msg_room);
+
if (craft->requirements->iSize) {
for(r = (struct requirement_data *) merge_iterator(&Iterator, craft->requirements);
----------------------------
case 'F':
if (!strcmp(tag, "Flag")) craft->craft_flags = atoi(line);
break;
case 'M':
if (!strcmp(tag, "Mroo")) craft->craft_msg_room = strdup(line);
else if (!strcmp(tag, "Mslf")) craft->craft_msg_self = strdup(line);
break;
+ case 'L':
+ if (!strcmp(tag, "Froo")) craft->craft_fail_msg_room = strdup(line);
+ else if (!strcmp(tag, "Fslf")) craft->craft_msg_self = strdup(line);
+ break;
case 'N':
if (!strcmp(tag, "Name")) craft->craft_name = strdup(line);
break;
-----------------------------
fprintf(fp, "Mslf: %s\n", CRAFT_MSG_SELF(c));
fprintf(fp, "Mroo: %s\n", CRAFT_MSG_ROOM(c));
+ fprintf(fp, "Fslf: %s\n", CRAFT_FAIL_MSG_SELF(c));
+ fprintf(fp, "Froo: %s\n", CRAFT_FAIL_MSG_ROOM(c));
-----------------------------
- } else if (skill > (rand / 2)) {
- act("You struggle in your attempt to craft, but you continue on.", TRUE, ch, 0, 0, TO_CHAR);
- act("$n struggles in $s attempt to craft.", TRUE, ch, 0, 0, TO_NOTVICT);
- return (CRAFT_TIMER(craft) * PASSES_PER_SEC);
- } else {
- remove_components(ch, craft, FALSE);
- act("You mess up your attempt to craft.", TRUE, ch, 0, 0, TO_CHAR);
- act("$n messes up $s attempt to craft.", TRUE, ch, 0, 0, TO_NOTVICT);
- }
+ } else if (skill > (rand / 2)) {
+ act("You struggle in your attempt to craft, but you continue on.", TRUE, ch, 0, 0, TO_CHAR);
+ act("$n struggles in $s attempt to craft.", TRUE, ch, 0, 0, TO_NOTVICT);
+ return (CRAFT_TIMER(craft) * PASSES_PER_SEC);
+ } else {
+ remove_components(ch, craft, FALSE);
+ act(CRAFT_FAIL_MSG_SELF(craft), TRUE, ch, 0, 0, TO_CHAR);
+ act(CRAFT_FAIL_MSG_ROOM(craft), TRUE, ch, 0, 0, TO_NOTVICT);
+ }
-------------------------------
if (CRAFT_MSG_SELF(from))
to->craft_msg_self = strdup(CRAFT_MSG_SELF(from));
if (CRAFT_MSG_ROOM(from))
to->craft_msg_room = strdup(CRAFT_MSG_ROOM(from));
+ if (CRAFT_FAIL_MSG_SELF(from))
+ to->craft_fail_msg_self = strdup(CRAFT_FAIL_MSG_SELF(from));
+
+ if (CRAFT_FAIL_MSG_ROOM(from))
+ to->craft_fail_msg_room = strdup(CRAFT_FAIL_MSG_ROOM(from));
-------------------------------
static void craftedit_setup_new(struct descriptor_data *d)
{
OLC_CRAFT(d) = create_craft();
CRAFT_ID(OLC_CRAFT(d)) = OLC_NUM(d);
OLC_CRAFT(d)->craft_msg_self = strdup("You craft $p.");
OLC_CRAFT(d)->craft_msg_room = strdup("$n crafts $p.");
+ OLC_CRAFT(d)->craft_fail_msg_self = strdup("You fail to craft $p.");
+ OLC_CRAFT(d)->craft_fail_msg_room = strdup("$n fails to craft $p.");
OLC_VAL(d) = 0;
}
--------------------------------
write_to_output(d, "\t1-- Craftedit Menu\t1 : \t2[\t3%d\t2]\tn\r\n"
"\t21\t3) Craft Name : \t1%s\tn\r\n"
"\t22\t3) Craft Timer : \t1%d seconds\tn\r\n"
"\t23\t3) Craft Item : \t1\"\tn%s\t1\"\tn\r\n"
+ "\t24\t3) Success Self : \t1\"\tn%s\t1\"\tn\r\n"
+ "\t25\t3) Success Room : \t1\"\tn%s\t1\"\tn\r\n"
+ "\t26\t3) Failure Self : \t1\"\tn%s\t1\"\tn\r\n"
+ "\t27\t3) Failure Room : \t1\"\tn%s\t1\"\tn\r\n",
CRAFT_ID(c),
CRAFT_NAME(c),
CRAFT_TIMER(c),
((vnum = real_object(CRAFT_OBJVNUM(c))) != NOTHING) ? obj_proto[vnum].short_description : "None",
CRAFT_MSG_SELF(c),
CRAFT_MSG_ROOM(c),
+ CRAFT_FAIL_MSG_SELF(c),
+ CRAFT_FAIL_MSG_ROOM(c));
---------------------------------
// Change cases 4 and 5 to reflect the style of 6 and 7
case '5':
write_to_output(d, "Enter success message to room: ");
OLC_MODE(d) = CRAFTEDIT_MSG_ROOM;
break;
+ case '6':
+ write_to_output(d, "Enter failure message to self: ");
+ OLC_MODE(d) = CRAFTEDIT_FAIL_MSG_SELF;
+ break;
+ case '7':
+ write_to_output(d, "Enter failure message to room: ");
+ OLC_MODE(d) = CRAFTEDIT_FAIL_MSG_ROOM;
+ break;
----------------------------------
case CRAFTEDIT_MSG_ROOM:
if (!genolc_checkstring(d, arg))
break;
if (OLC_CRAFT(d)->craft_msg_room)
free(OLC_CRAFT(d)->craft_msg_room);
delete_doubledollar(arg);
OLC_CRAFT(d)->craft_msg_room = strdup(arg);
break;
+ case CRAFTEDIT_FAIL_MSG_SELF:
+ if (!genolc_checkstring(d, arg))
+ break;
+ if (OLC_CRAFT(d)->craft_fail_msg_self)
+ free(OLC_CRAFT(d)->craft_msg_self);
+ delete_doubledollar(arg);
+ OLC_CRAFT(d)->craft_fail_msg_self = strdup(arg);
+ break;
+ case CRAFTEDIT_FAIL_MSG_ROOM:
+ if (!genolc_checkstring(d, arg))
+ break;
+ if (OLC_CRAFT(d)->craft_fail_msg_room)
+ free(OLC_CRAFT(d)->craft_fail_msg_room);
+ delete_doubledollar(arg);
+ OLC_CRAFT(d)->craft_fail_msg_room = strdup(arg);
+ break;
-----------------------------------
** In crafts.h **
char * craft_msg_self;
char * craft_msg_room;
+ char * craft_fail_msg_self;
+ char * craft_fail_msg_room;
-----------------------------------
#define CRAFT_MSG_SELF(craft) (craft->craft_msg_self)
#define CRAFT_MSG_ROOM(craft) (craft->craft_msg_room)
+ #define CRAFT_FAIL_MSG_SELF(craft) (craft->craft_fail_msg_self)
+ #define CRAFT_FAIL_MSG_ROOM(craft) (craft->craft_fail_msg_room)
-----------------------------------
#define CRAFTEDIT_MSG_SELF 14
#define CRAFTEDIT_MSG_ROOM 15
+ #define CRAFTEDIT_FAIL_MSG_SELF 16
+ #define CRAFTEDIT_FAIL_MSG_ROOM 17
-----------------------------------