Welcome to the Builder Academy

Question Item Durability

More
16 May 2013 22:19 #2332 by thomas
Replied by thomas on topic Item Durability
I, for one, don't feel you're just "filling up space".

And there's a guide to gdb here: www.tbamud.com/forum/4-development/6-debugging-tutorial-for-gdb

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

More
17 May 2013 05:15 #2340 by Papaya Pete
Replied by Papaya Pete on topic Item Durability
Ah that came in handy! I followed the tutorial and managed to get some info on this crash.

Seems the crash occurs when damage is supposed to occur to a worn item, but the problem is there is no item worn on that location! Here is what gdb came up with.
Code:
(gdb) bt #0 0x00482052 in hit (ch=0x80f107b0, victim=0x80adf088, type=-1) at fight.c:1137 #1 0x00482e0d in perform_violence () at fight.c:1230 #2 0x004fa2aa in heartbeat (heart_pulse=180) at comm.c:991 #3 0x004fdd15 in game_loop (local_mother_desc=3) at comm.c:938 #4 0x004fee86 in init_game (local_port=4000) at comm.c:533 #5 main (argc=2, argv=0x28ac50) at comm.c:353 (gdb) list 1142 send_to_char(victim, "\trWith that final blow, %s that you were wearing fall apart!\tn\n", GET_OBJ_SHORT(headarm)); 1143 send_to_room(IN_ROOM(victim), "\tr%s is less protected as %s falls apart after that last blow!\tn\n", GET_NAME(victim), GET_OBJ_SHORT(headarm)); 1144 obj_to_char(unequip_char(victim, WEAR_HEAD), victim); 1145 } 1146 } 1147 break; 1148 default: 1149 break; 1150 } 1151 (gdb) info local wielded = <optimized out> bodyarm = 0x0 neckarm1 = 0x0 neckarm2 = 0x0 headarm = 0x0 shield = 0x0 legarmor = 0x0 feetarm = 0x0 handarm = 0x0 armarmor = 0x0 aboutarm = 0x0 waistarm = 0x0 rwristarm = 0x0 lwristarm = 0x0 w_type = 303 victim_ac = <optimized out> calc_thaco = 0 dam = 12 diceroll = 5 wpnprof = <optimized out> location = <optimized out> (gdb) up #1 0x00482e0d in perform_violence () at fight.c:1230 1230 hit(ch, FIGHTING(ch), TYPE_UNDEFINED); (gdb) list 1225 /* have to implement a better way for number of attacks for mobs */ 1226 num_of_attacks += ((int) GET_LEVEL(ch) / 5) - 1; 1227 } 1228 1229 for (loop_attacks = 1; loop_attacks < num_of_attacks && ch && FIGHTING(ch); loop_attacks++) 1230 hit(ch, FIGHTING(ch), TYPE_UNDEFINED); 1231 1232 if (GROUP(ch)) { 1233 while ((tch = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL) { 1234 if (tch == ch) (gdb) info local ch = 0x80f107b0 tch = <optimized out> wielded = <optimized out> num_of_attacks = 4 loop_attacks = <optimized out> (gdb) up #2 0x004fa2aa in heartbeat (heart_pulse=180) at comm.c:991 991 perform_violence(); (gdb) list 986 987 if (!(heart_pulse % PULSE_MOBILE)) 988 mobile_activity(); 989 990 if (!(heart_pulse % PULSE_VIOLENCE)) 991 perform_violence(); 992 993 if (!(heart_pulse % (SECS_PER_MUD_HOUR * PASSES_PER_SEC))) { /* Tick ! */ 994 next_tick = SECS_PER_MUD_HOUR; /* Reset tick coundown */ 995 weather_and_time(1);

Here's an example also of the variables I defined, and a little bit of the location code to boot.
Code:
struct obj_data *wielded = GET_EQ(ch, WEAR_WIELD); struct obj_data *bodyarm = GET_EQ(victim, WEAR_BODY); struct obj_data *neckarm1 = GET_EQ(victim, WEAR_NECK_1); struct obj_data *neckarm2 = GET_EQ(victim, WEAR_NECK_2); struct obj_data *headarm = GET_EQ(victim, WEAR_HEAD); struct obj_data *shield = GET_EQ(victim, WEAR_SHIELD); struct obj_data *legarmor = GET_EQ(victim, WEAR_LEGS); struct obj_data *feetarm = GET_EQ(victim, WEAR_FEET); struct obj_data *handarm = GET_EQ(victim, WEAR_HANDS); struct obj_data *armarmor = GET_EQ(victim, WEAR_ARMS); struct obj_data *aboutarm = GET_EQ(victim, WEAR_ABOUT); struct obj_data *waistarm = GET_EQ(victim, WEAR_WAIST); struct obj_data *rwristarm = GET_EQ(victim, WEAR_WRIST_R); struct obj_data *lwristarm = GET_EQ(victim, WEAR_WRIST_L);
Code:
switch (location) { case 1: // Feet Location case 2: if ((feetarm) && (GET_OBJ_MAX_DURAB(feetarm) != 0)) diceroll = rand_number(1, 100); if (diceroll <= 10) { send_to_char(ch, "\tRWith that blow, %s has been damaged!\tn\n", GET_OBJ_SHORT(feetarm)); GET_OBJ_DURABILITY(feetarm) -= rand_number(1, 6); if (GET_OBJ_DURABILITY(feetarm) < 0) GET_OBJ_DURABILITY(feetarm) = 0; if (GET_OBJ_DURABILITY(feetarm) == 0) { send_to_char(victim, "\trWith that final blow, %s that you were wearing fall apart!\tn\n", GET_OBJ_SHORT(feetarm)); send_to_room(IN_ROOM(victim), "\tr%s is less protected as %s falls apart after that last blow!\tn\n", GET_NAME(victim), GET_OBJ_SHORT(feetarm)); obj_to_char(unequip_char(victim, WEAR_FEET), victim); } } break; case 3: // Leg location case 4: case 5: if ((legarmor) && (GET_OBJ_MAX_DURAB(legarmor) != 0)) diceroll = rand_number(1, 100); if (diceroll <= 10) { send_to_char(ch, "\tRWith that blow, %s has been damaged!\tn\n", GET_OBJ_SHORT(legarmor)); GET_OBJ_DURABILITY(legarmor) -= rand_number(1, 6); if (GET_OBJ_DURABILITY(legarmor) < 0) GET_OBJ_DURABILITY(legarmor) = 0; if (GET_OBJ_DURABILITY(legarmor) == 0) { send_to_char(victim, "\trWith that final blow, %s that you were wearing fall apart!\tn\n", GET_OBJ_SHORT(legarmor)); send_to_room(IN_ROOM(victim), "\tr%s is less protected as %s falls apart after that last blow!\tn\n", GET_NAME(victim), GET_OBJ_SHORT(legarmor)); obj_to_char(unequip_char(victim, WEAR_LEGS), victim); } } break;

Thanks for showing me that link, I'll finish trying to find out what the problem is. I think the issue is when I check to see whether something is located on a wear slot; it shouldn't even be reaching the send_to_char reporting to the player that the non-existing item is damaged.

Very educational!

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

More
17 May 2013 16:42 #2355 by Papaya Pete
Replied by Papaya Pete on topic Item Durability
So after a night of rest I'm coming back to this problem. I did some testing, and tried putting in more checking... but for some reason, the logic just isn't working. The strange thing is that I've used the same logic before and it worked fine! The only difference: before, it was on the attacker. Here's the snippet for when a weapon is damaged.
Code:
/* Figuring out amount of wear and tear on equipment involved First, starting with weapons, if any */ if (wielded && GET_OBJ_TYPE(wielded) == ITEM_WEAPON && (GET_OBJ_MAX_DURAB(wielded) != 0)) { diceroll = rand_number(1, 100); if (diceroll <= 100) { // Base 10% chance per hit of wearing weapon down act("\tRYour weapon, $p, has been slightly damaged!\tn\n", FALSE, ch, wielded, 0, TO_CHAR); GET_OBJ_DURABILITY(wielded) -= rand_number(1, 6); if (GET_OBJ_DURABILITY(wielded) < 0) GET_OBJ_DURABILITY(wielded) = 0; if (GET_OBJ_DURABILITY(wielded) == 0) { send_to_char(ch, "\trYou're shocked as %s breaks after that last blow!\tn", GET_OBJ_SHORT(wielded)); send_to_room(IN_ROOM(ch), "\tr%s is shocked as %s breaks after that last blow!\tn", GET_NAME(ch), GET_OBJ_SHORT(wielded)); obj_to_char(unequip_char(ch, WEAR_WIELD), ch); } } }

Now here is one case from the armor wear and tear. I know I've posted one before, but figured this would be for easier to refer to. Not to mention I've changed the if statement to practically match what happens in the weapon checking.
Code:
switch (location) { case 1: // Feet Location case 2: if ((feetarm) && GET_OBJ_TYPE(feetarm) == ITEM_ARMOR && (GET_OBJ_MAX_DURAB(feetarm) != 0)) diceroll = rand_number(1, 100); if (diceroll <= 10) { send_to_char(ch, "\tRWith that blow, %s has been damaged!\tn\n", GET_OBJ_SHORT(feetarm)); GET_OBJ_DURABILITY(feetarm) -= rand_number(1, 6); if (GET_OBJ_DURABILITY(feetarm) < 0) GET_OBJ_DURABILITY(feetarm) = 0; if (GET_OBJ_DURABILITY(feetarm) == 0) { send_to_char(victim, "\trWith that final blow, %s that you were wearing fall apart!\tn\n", GET_OBJ_SHORT(feetarm)); send_to_room(IN_ROOM(victim), "\tr%s is less protected as %s falls apart after that last blow!\tn\n", GET_NAME(victim), GET_OBJ_SHORT(feetarm)); obj_to_char(unequip_char(victim, WEAR_FEET), victim); } } break;

I'm sure I'm just missing something simple, but for some reason when your target is not wearing something it still goes right through that if statement as if there was something there.

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

More
17 May 2013 18:33 #2360 by thomas
Replied by thomas on topic Item Durability
Where is "feetarm" populated?

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

More
17 May 2013 19:17 #2363 by Papaya Pete
Replied by Papaya Pete on topic Item Durability
Right at the beginning of the hit function, same place where "wielded" is populated.
Code:
struct obj_data *wielded = GET_EQ(ch, WEAR_WIELD); struct obj_data *feetarm = GET_EQ(victim, WEAR_FEET);

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

More
17 May 2013 22:03 #2368 by thomas
Replied by thomas on topic Item Durability
Are there any possiblity that the item is removed twice? I see the loop is around the hit function, so I'd guess not, but doublecheck :)

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

Time to create page: 0.296 seconds