Welcome to the Builder Academy

Question do_examine

More
28 Mar 2014 22:47 #4783 by bakarus
do_examine was created by bakarus
I want to remove the identify spell or alter it to show more info, but apart from that I want to make do_examine do what identify does currently, minus a few things, for the sake of this, lets assume I want do_examine to mimic ASPELL(Identify).

I tried simple copy/paste into do_examine and got an errors which is to be expected.

The error was 'obj' undeclared, in do_examine, here is the code,
Code:
ACMD(do_examine) { int i, found; size_t len; if (obj) { char bitbuf[MAX_STRING_LENGTH]; sprinttype(GET_OBJ_TYPE(obj), item_types, bitbuf, sizeof(bitbuf)); send_to_char(ch, "You feel informed:\r\nObject '%s', Item type: %s\r\n", obj->short_description, bitbuf); if (GET_OBJ_AFFECT(obj)) { sprintbitarray(GET_OBJ_AFFECT(obj), affected_bits, AF_ARRAY_MAX, bitbuf); send_to_char(ch, "Item will give you following abilities: %s\r\n", bitbuf); } sprintbitarray(GET_OBJ_EXTRA(obj), extra_bits, EF_ARRAY_MAX, bitbuf); send_to_char(ch, "Item is: %s\r\n", bitbuf); send_to_char(ch, "Weight: %d, Value: %d, Rent: %d, Min. level: %d\r\n", GET_OBJ_WEIGHT(obj), GET_OBJ_COST(obj), GET_OBJ_RENT(obj), GET_OBJ_LEVEL(obj)); switch (GET_OBJ_TYPE(obj)) { case ITEM_SCROLL: case ITEM_POTION: len = i = 0; if (GET_OBJ_VAL(obj, 1) >= 1) { i = snprintf(bitbuf + len, sizeof(bitbuf) - len, " %s", skill_name(GET_OBJ_VAL(obj, 1))); if (i >= 0) len += i; } if (GET_OBJ_VAL(obj, 2) >= 1 && len < sizeof(bitbuf)) { i = snprintf(bitbuf + len, sizeof(bitbuf) - len, " %s", skill_name(GET_OBJ_VAL(obj, 2))); if (i >= 0) len += i; } if (GET_OBJ_VAL(obj, 3) >= 1 && len < sizeof(bitbuf)) { i = snprintf(bitbuf + len, sizeof(bitbuf) - len, " %s", skill_name(GET_OBJ_VAL(obj, 3))); if (i >= 0) len += i; } send_to_char(ch, "This %s casts: %s\r\n", item_types[(int) GET_OBJ_TYPE(obj)], bitbuf); break; case ITEM_WAND: case ITEM_STAFF: send_to_char(ch, "This %s casts: %s\r\nIt has %d maximum charge%s and %d remaining.\r\n", item_types[(int) GET_OBJ_TYPE(obj)], skill_name(GET_OBJ_VAL(obj, 3)), GET_OBJ_VAL(obj, 1), GET_OBJ_VAL(obj, 1) == 1 ? "" : "s", GET_OBJ_VAL(obj, 2)); break; case ITEM_WEAPON: send_to_char(ch, "Damage Dice is '%dD%d' for an average per-round damage of %.1f.\r\n", GET_OBJ_VAL(obj, 1), GET_OBJ_VAL(obj, 2), ((GET_OBJ_VAL(obj, 2) + 1) / 2.0) * GET_OBJ_VAL(obj, 1)); break; case ITEM_ARMOR: send_to_char(ch, "AC-apply is %d\r\n", GET_OBJ_VAL(obj, 0)); break; } found = FALSE; for (i = 0; i < MAX_OBJ_AFFECT; i++) { if ((obj->affected[i].location != APPLY_NONE) && (obj->affected[i].modifier != 0)) { if (!found) { send_to_char(ch, "Can affect you as :\r\n"); found = TRUE; } sprinttype(obj->affected[i].location, apply_types, bitbuf, sizeof(bitbuf)); send_to_char(ch, " Affects: %s By %d\r\n", bitbuf, obj->affected[i].modifier); } } } }

do i need to simply declare obj above, like "struct obj_data *obj;" ?

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

More
28 Mar 2014 23:40 - 28 Mar 2014 23:42 #4784 by bakarus
Replied by bakarus on topic do_examine
I went ahead and added the struct statement at the top, and now the mud crashes at,
Code:
sprinttype(GET_OBJ_TYPE(obj), item_types, bitbuf, sizeof(bitbuf)); send_to_char(ch, "You feel informed:\r\nObject '%s', Item type: %s\r\n", obj->short_description, bitbuf);

is this because the obj reference isn't passed to do_examine?
Last edit: 28 Mar 2014 23:42 by bakarus.

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

Time to create page: 0.163 seconds