Welcome to the Builder Academy

Question Skill tan wont load objects

More
19 Nov 2017 01:12 - 19 Nov 2017 01:13 #7113 by JTP
Hi

Im trying to make a tan skill, but it wont load the objects iwe set.
And if i try to tan corpse ring, that isnt on my define list, it still says i make the obj, but should get the Illigal object message.
Code:
#define TAN_SHIELD 3095 #define TAN_JACKET 3043 #define TAN_BOOTS 3084 #define TAN_GLOVES 3071 #define TAN_LEGGINGS 3081 #define TAN_SLEEVES 3086 #define TAN_HELMET 3076 #define TAN_BAG 3032 ..... else if (!strcmp(itemtype, "bag")) { if ((r_num = real_object(TAN_BAG)) >= 0) { hide = read_object(r_num, VIRTUAL); obj_to_char(hide, ch); } } else { send_to_char("Illegal type of equipment!\n\r",ch); return; } }

Anyone know why ?
Last edit: 19 Nov 2017 01:13 by JTP.

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

More
19 Nov 2017 01:57 - 19 Nov 2017 22:47 #7115 by JTP
Replied by JTP on topic Skill tan wont load objects
Code:
#define TAN_SHIELD 3095 #define TAN_JACKET 3043 #define TAN_BOOTS 3084 #define TAN_GLOVES 3071 #define TAN_LEGGINGS 3081 #define TAN_SLEEVES 3086 #define TAN_HELMET 3076 #define TAN_BAG 3032 ACMD(do_tan) { struct obj_data *corpse, *hide; char buf[MAX_STRING_LENGTH]; char itemname[MAX_INPUT_LENGTH], itemtype[MAX_INPUT_LENGTH]; int r_num = 0; if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_TAN)) { send_to_char(ch, "You haven't learned how to tan.\r\n"); return; } two_arguments(argument, itemname, itemtype); if (!*itemname) { send_to_char(ch, "Tan what?\r\n"); return; } if (!*itemtype) { send_to_char(ch, "I see that, but what do you wanna make?\r\n"); return; } if (!(corpse = get_obj_in_list_vis(ch, itemname, NULL, world[IN_ROOM(ch)].contents))) { send_to_char(ch, "Where did that corpse go?\r\n"); return; } else { if(rand_number(1,150) > GET_SKILL(ch, SKILL_TAN)) { sprintf(buf, "You hack at %s but manage to only destroy the hide.\r\n", corpse->short_description); send_to_char(ch, buf); sprintf(buf,"%s tries to skins %s for it's hide, but destroys it.", GET_NAME(ch), corpse->short_description); act(buf, TRUE, ch, 0, 0, TO_ROOM); improve_skill(ch, SKILL_TAN); extract_obj(corpse); WAIT_STATE(ch, PULSE_VIOLENCE*3); return; } else { sprintf(buf, "You hack at the %s and finally make the %s.\r\n", corpse->short_description, itemtype); send_to_char(ch, buf); sprintf(buf, "%s skins %s for it's hide.", GET_NAME(ch), corpse->short_description); act(buf, TRUE, ch, 0, 0, TO_ROOM); extract_obj(corpse); WAIT_STATE(ch, PULSE_VIOLENCE*1); return; } if (!strcmp(itemtype, "shield")) { if ((r_num = real_object(TAN_SHIELD)) >= 0) { hide = read_object(r_num, VIRTUAL); obj_to_char(hide, ch); } } else if (!strcmp(itemtype, "jacket")) { if ((r_num = real_object(TAN_JACKET)) >= 0) { hide = read_object(r_num, VIRTUAL); obj_to_char(hide, ch); } } else if (!strcmp(itemtype, "boots")) { if ((r_num = real_object(TAN_BOOTS)) >= 0) { hide = read_object(r_num, VIRTUAL); obj_to_char(hide, ch); } } else if (!strcmp(itemtype, "gloves")) { if ((r_num = real_object(TAN_GLOVES)) >= 0) { hide = read_object(r_num, VIRTUAL); obj_to_char(hide, ch); } } else if (!strcmp(itemtype, "leggings")) { if ((r_num = real_object(TAN_LEGGINGS)) >= 0) { hide = read_object(r_num, VIRTUAL); obj_to_char(hide, ch); } } else if (!strcmp(itemtype, "sleeves")) { if ((r_num = real_object(TAN_SLEEVES)) >= 0) { hide = read_object(r_num, VIRTUAL); obj_to_char(hide, ch); } } else if (!strcmp(itemtype, "helmet")) { if ((r_num = real_object(TAN_HELMET)) >= 0) { hide = read_object(r_num, VIRTUAL); obj_to_char(hide, ch); } } else if (!strcmp(itemtype, "bag")) { if ((r_num = real_object(TAN_BAG)) >= 0) { hide = read_object(r_num, VIRTUAL); obj_to_char(hide, ch); } } else { send_to_char(ch, "Illegal type of equipment!\r\n"); return; } } }

This attempt still tries to make an item name not in list:
You hack at the the corpse of a little white mouse and finally make the
necklace.
Illegal type of equipment!

And if i try with one of the names from the list, it now loads a letter.

Think brackets are wrongly placed, but not my strong side, might also just be something else that i cant see...Any idea ?

File error shows: Nov 18 20:06:11 :: SYSERR: NULL obj ((nil)) or char (0x9c34958) passed to obj_to_char.
Last edit: 19 Nov 2017 22:47 by JTP.

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

More
19 Nov 2017 22:29 #7118 by WhiskyTest
There isn't any way for us to tell without seeing the whole function.

From what you've posted there are too many brackets and an old send_to_char which wouldn't even compile

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

More
19 Nov 2017 22:45 #7119 by JTP
Replied by JTP on topic Skill tan wont load objects
Had changed the last send_to when i compiled, just forgot to update here.

Updated above post with entire code

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

More
20 Nov 2017 03:24 - 20 Nov 2017 03:30 #7122 by WhiskyTest
Cool thanks.
You've done some good work there.

I've corrected a couple of problems with the flow, which is why we were getting unexpected messages and the objects not loading in.

Rather than using an ever growing collection of 'if-else' statements, I've put the names and vnmus into a table. To add items just add a new entry in the table and increase the NUM_TAN_TYPES. If the object doesn't exist in-game the player will get an error message. Maybe change that to be a syslog call?

Oh and one other thing - there is no checks to see if the target object is actually a corpse. And I couldn't see any obvious way to do it. You may need to add a new object flag into the game via the make_corpse() function or something like that.
Code:
struct tan_data { const char *name; int vnum; }; struct tan_data tan_table[] = { /* Name, VNUM */ {"shield", 3095}, {"jacket", 3043}, {"boots", 3084}, {"gloves", 3071}, {"leggings", 3081}, {"sleeves", 3086}, {"helmet", 3076}, {"bag", 3032}, }; #define NUM_TAN_TYPES 8 ACMD(do_tan) { struct obj_data *corpse, *hide; char buf[MAX_STRING_LENGTH]; char itemname[MAX_INPUT_LENGTH], itemtype[MAX_INPUT_LENGTH]; obj_rnum r_num = 0; int i; bool found = FALSE; if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_TAN)) { send_to_char(ch, "You haven't learned how to tan.\r\n"); return; } two_arguments(argument, itemname, itemtype); if (!*itemname) { send_to_char(ch, "Tan what?\r\n"); return; } if (!*itemtype) { send_to_char(ch, "I see that, but what do you wanna make?\r\n"); return; } corpse = get_obj_in_list_vis(ch, itemname, NULL, world[IN_ROOM(ch)].contents); if (!corpse) { send_to_char(ch, "Where did that corpse go?\r\n"); return; } /* Insert check here to see if the object is actually a corpse - not just any object */ /* Check the tan_table to see if this is a valid item the player is attempting to make (abbreviations OK) */ for (i = 0; !found && i < NUM_TAN_TYPES; i++) if (is_abbrev(itemtype, tan_table[i].name)) { if ((r_num = real_object(tan_table[i].vnum)) == NOTHING) { send_to_char(ch, "Error: There is no object with that number.\r\n"); return; } found = TRUE; } /* If the player didn't make a valid entry from the tan_table OR they fail their skill test */ if(!found || rand_number(1,150) > GET_SKILL(ch, SKILL_TAN) ) { snprintf(buf, sizeof(buf), "You hack at %s but manage to only destroy the hide.\r\n", corpse->short_description); send_to_char(ch, buf); snprintf(buf, sizeof(buf), "%s tries to skins %s for it's hide, but destroys it.", GET_NAME(ch), corpse->short_description); act(buf, TRUE, ch, 0, 0, TO_ROOM); improve_skill(ch, SKILL_TAN); extract_obj(corpse); WAIT_STATE(ch, PULSE_VIOLENCE*3); return; } /* Player is successful */ hide = read_object(r_num, REAL); snprintf(buf, sizeof(buf), "You hack at the %s and finally make the %s.\r\n", corpse->short_description, hide->short_description); send_to_char(ch, buf); snprintf(buf, sizeof(buf), "%s skins %s for it's hide.", GET_NAME(ch), corpse->short_description); act(buf, TRUE, ch, 0, 0, TO_ROOM); obj_to_char(hide, ch); extract_obj(corpse); WAIT_STATE(ch, PULSE_VIOLENCE*1); return; }
Last edit: 20 Nov 2017 03:30 by WhiskyTest. Reason: formatting

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

More
20 Nov 2017 13:09 #7124 by JTP
Replied by JTP on topic Skill tan wont load objects
Thanks, i did my best.

There is a !corpse part in the code to check for no corpse it works.

Your Line: send_to_char(ch, "Error: There is no object with that number.\r\n");

I cant Seem to get that in game ?

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

Time to create page: 0.246 seconds