Welcome to the Builder Academy

Loved New OLC Craft System

More
23 Jun 2012 06:55 - 23 Jun 2012 06:55 #208 by Halenbane
Replied by Halenbane on topic Re: New OLC Craft System
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.

Result:

-- Craftedit Menu : [1]
1) Craft Name : Finely Crafted Staff
2) Craft Timer : 20 seconds
3) Craft Item : "a Finely Crafted Staff "
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."
S) Craft Skill : craft (5)
F) Flags : Needs Recipe
R) Requirements :
[5931] 1 , "a thick oak branch" [NOBITS ]
[5932] 1 , "a sharp lathe chisel" [!REMOVE SAVEonFAIL ]
[5933] 1 , "a large wood lathe" [INROOM !REMOVE SAVEonFAIL ]
X) Delete
Q) Quit
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 -----------------------------------
Last edit: 23 Jun 2012 06:55 by Halenbane.

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

More
23 Jun 2012 13:50 #210 by Vatiken
Replied by Vatiken on topic Re: New OLC Craft System
Code:
+ 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;
Should be "craft_fail_msg_self ="right?
Other than that, everything looks good. Nice work.

tbaMUD developer/programmer

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

More
23 Jun 2012 15:19 #211 by Halenbane
Replied by Halenbane on topic Re: New OLC Craft System
Yah must have not noticed that last night :) Thanks.

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

More
23 Jun 2012 15:35 - 23 Jun 2012 16:08 #212 by Halenbane
Replied by Halenbane on topic Re: New OLC Craft System
Seems I may have missed something else. My fail messages are not saving through a copyover. Any ideas?

Seems I had another small mistake, gonna change it and check then.

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;

+ free (OLC_CRAFT(d)->craft_fail_msg_self);

Hmm still not saving during copyover... weird.

It just sets them back to "NULL"
Last edit: 23 Jun 2012 16:08 by Halenbane.

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

More
23 Jun 2012 16:35 #213 by Liko
Replied by Liko on topic Re: New OLC Craft System

Halenbane wrote: Seems I may have missed something else. My fail messages are not saving through a copyover. Any ideas?

Seems I had another small mistake, gonna change it and check then.

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;

+ free (OLC_CRAFT(d)->craft_fail_msg_self);

Hmm still not saving during copyover... weird.

It just sets them back to "NULL"


Just glancing thru looks like you didn't add them to the save function.

Randian(0.0.0)
Owner/Developer

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

More
23 Jun 2012 17:19 - 23 Jun 2012 17:20 #214 by Halenbane
Replied by Halenbane on topic Re: New OLC Craft System
craftedit_fail_msg_self
and craftedit_fail_msg_room can be found everywhere craftedit_msg_self etc is found. Not sure what I am overlooking.

It saves after you exit the editor, and will stick around. Until a copyover.
Then the success messages stick, but the fail messages go back to NULL.
Last edit: 23 Jun 2012 17:20 by Halenbane.

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

Time to create page: 0.357 seconds