Welcome to the Builder Academy

Loved New OLC Craft System

More
26 Jun 2012 20:37 - 26 Jun 2012 20:38 #279 by Halenbane
Replied by Halenbane on topic Re: New OLC Craft System
Well I see how the regular success has it initialized, but I'm not sure how it needs to be initialized for the crit chance.

if (skill > rand) {
if ((obj = read_object(CRAFT_OBJVNUM(craft), VIRTUAL)) == NULL) {
send_to_char(ch, "You seem to have an issue with your crafting.\r\n");
mudlog(CMP, LVL_GOD, TRUE, "SYSERR: Event Craft called without created object.");
return (0);
}

remove_components(ch, craft, TRUE);
obj_to_char(obj, ch);

I understand the above, but the way my statement is written for critical craft , I can't initialize it the same way.

if (rand < crit) {
if (real_object(CRAFT_CRIT_OBJVNUM(craft)) != NOTHING && rand > crit) {
remove_components(ch, craft, TRUE);
obj_to_char(obj, ch);
act(CRAFT_CRIT_MSG_SELF(craft), TRUE, ch, obj, 0, TO_CHAR);
act(CRAFT_CRIT_MSG_ROOM(craft), TRUE, ch, obj, 0, TO_NOTVICT);
}
Last edit: 26 Jun 2012 20:38 by Halenbane.

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

More
26 Jun 2012 20:42 #280 by Vatiken
Replied by Vatiken on topic Re: New OLC Craft System
Code:
if (rand < crit) { if (real_object(CRAFT_CRIT_OBJVNUM(craft)) != NOTHING && rand > crit) { if ((obj = read_object(CRAFT_CRIT_OBJVNUM(craft), VIRTUAL)) == NULL) { send_to_char(ch, "You seem to have an issue with your crafting.\r\n"); mudlog(CMP, LVL_GOD, TRUE, "SYSERR: Event Craft called without critical created object."); return (0); } remove_components(ch, craft, TRUE); obj_to_char(obj, ch); act(CRAFT_CRIT_MSG_SELF(craft), TRUE, ch, obj, 0, TO_CHAR); act(CRAFT_CRIT_MSG_ROOM(craft), TRUE, ch, obj, 0, TO_NOTVICT); }

tbaMUD developer/programmer
The following user(s) said Thank You: Halenbane

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

More
26 Jun 2012 20:46 #281 by Halenbane
Replied by Halenbane on topic Re: New OLC Craft System
Once again many thanks Vat. I seem to over-complicate things sometimes.

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

More
26 Jun 2012 20:48 #282 by Vatiken
Replied by Vatiken on topic Re: New OLC Craft System
Just be careful not to the object initialized twice,
ie: first if successful, second if crit successful
Or else you'll be leaking memory.

tbaMUD developer/programmer

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

More
26 Jun 2012 21:00 - 26 Jun 2012 21:05 #283 by Halenbane
Replied by Halenbane on topic Re: New OLC Craft System
So the way I have it written now, is going to cause a memory leak?
Code:
skill = GET_SKILL(ch, CRAFT_SKILL(craft)) - (CRAFT_SKILL_LEVEL(craft) / 2); rand = rand_number(1, 100); crit = rand_number(1, 10); if (rand < crit) { if (real_object(CRAFT_CRIT_OBJVNUM(craft)) != NOTHING && rand < crit) { if ((obj = read_object(CRAFT_CRIT_OBJVNUM(craft), VIRTUAL)) == NULL) { send_to_char(ch, "You seem to have an issue with your crafting.\r\n"); mudlog(CMP, LVL_GOD, TRUE, "SYSERR: Event Craft called without critical created object."); return (0); } remove_components(ch, craft, TRUE); obj_to_char(obj, ch); act(CRAFT_CRIT_MSG_SELF(craft), TRUE, ch, obj, 0, TO_CHAR); act(CRAFT_CRIT_MSG_ROOM(craft), TRUE, ch, obj, 0, TO_NOTVICT); } } else { if (skill > rand) { if ((obj = read_object(CRAFT_OBJVNUM(craft), VIRTUAL)) == NULL) { send_to_char(ch, "You seem to have an issue with your crafting.\r\n"); mudlog(CMP, LVL_GOD, TRUE, "SYSERR: Event Craft called without created object."); return (0); } remove_components(ch, craft, TRUE); obj_to_char(obj, ch); if (!CRAFT_MSG_SELF(craft)) send_to_char(ch, "You have created %s.\r\n", obj->short_description); else act(CRAFT_MSG_SELF(craft), TRUE, ch, obj, 0, TO_CHAR); if (CRAFT_MSG_ROOM(craft)) act(CRAFT_MSG_ROOM(craft), TRUE, ch, obj, 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); } } return (0); }

That may be part of the reason I'm seeing another issue, or not.
When I copyover, the craft item is setting itself to vnum obj 2 (a fireball)
If a critical craft item is set, it resets to none
Last edit: 26 Jun 2012 21:05 by Halenbane.

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

More
26 Jun 2012 21:25 - 26 Jun 2012 21:26 #284 by Vatiken
Replied by Vatiken on topic Re: New OLC Craft System
No memory leaks I can see.
Code:
if (rand < crit) { if (real_object(CRAFT_CRIT_OBJVNUM(craft)) != NOTHING && rand < crit) {
You will activate the call to create a critical item whether one exists or not..

Does the variable save correctly? load correctly?
Code:
Vatiken hates it when the forums time out and his original more in-depth response gets lost in the netherword.

tbaMUD developer/programmer
Last edit: 26 Jun 2012 21:26 by Vatiken.

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

Time to create page: 0.206 seconds