
Pages:<< prev 1 next >>


Apprentice

GroupMembers
Posts57
JoinedNov 24, 2016
Hey guys I need a fresh set of eyes to look at this. I am missing something simple I guess. For some reason my obj_from_char call is having NULL ch a few times in the loop and screwing up my obj_to_obj call numbers. What the intent of this code was, is to bundle up crafted items that players do, so that I can have a player craft 20 odd things for a quest mob, and carry it as 1 object giving a bundle of 20 crafted things to the mob to activate the act_prog.
Current Results of the code are
You are carrying:
[35548] a dragonic saddle bag
[41002] (Sharp) a pair of talons, legendary produced from meteor (11)
Vladaar::[30000/30000hp 2990/2990m 7411/7411mv] bundle 8 talons
Log: [*****] BUG: do_bundle: 1 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: 2 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: 3 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: 4 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: 5 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: 6 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: 7 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: 8 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: inventory_total 11 count2
Log: [*****] BUG: obj_from_char null ch for object a pair of talons, legendary produced from meteor.
Log: [*****] BUG: obj_from_char null ch for object a pair of talons, legendary produced from meteor.
Log: [*****] BUG: obj_from_char null ch for object a pair of talons, legendary produced from meteor.
Log: [*****] BUG: obj_from_char null ch for object a pair of talons, legendary produced from meteor.
Log: [*****] BUG: do_bundle: -1 count2 when 8 number
You bundle up the a pair of talons, legendary produced from meteor wih leather lashings.
Vladaar::[30000/30000hp 2990/2990m 7411/7411mv] i
You are carrying:
[35548] a dragonic saddle bag
[41002] (Sharp) a pair of talons, legendary produced from meteor (6)
[25] a bundle of 8 talons
Vladaar::[30000/30000hp 2990/2990m 7411/7411mv] l in bundle
A bundle of 8 talons contains:
[41002] (Sharp) a pair of talons, legendary produced from meteor (5)
/* too many damn loops in one command just simplifing it hopefully - Vladaar */ short inventory_total(CHAR_DATA *ch) { OBJ_DATA *check; short total = 0; for(check = ch->last_carrying; check; check = check->prev_content) { total++; } return total; } /* Allow players to bundle together up to 50 items of same vnum for ease in carrying - Vladaar */ void do_bundle(CHAR_DATA *ch, char *argument ) { char arg1[MIL], arg2[MIL]; OBJ_DATA *obj, *check, *bundle; short number = 0; char buf[MSL]; if(!ch) return; argument = one_argument(argument, arg1); if(arg1[0] == '\0') { send_to_char("Bundle how many what?\r\n", ch); return; } if(is_number(arg1)) { number = atoi(arg1); if(number < 2) { send_to_char("There must be at least 2 items to bundle.\r\n", ch); return; } } else { send_to_char("Bundle how many what?\r\n", ch); return; } int jackpot = 0; argument = one_argument(argument, arg2); if((obj = get_obj_carry(ch, arg2)) == NULL) { send_to_char("You don't have any of those to bundle.\r\n", ch ); return; } jackpot = obj->pIndexData->vnum; short count = 0; // Check to see if player has correct number to bundle for(check = ch->last_carrying; check; check = check->prev_content) { if ( check->pIndexData->vnum == jackpot && count != number ) { count++; bug( "%s: %d count %d number of %s with vnum %d found", __FUNCTION__, count, number, check->name, jackpot ); } } if ( count < number ) { bug( "%s: %d count less than %d number", __FUNCTION__, count, number ); send_to_char("You don't have enough to bundle.\r\n", ch ); return; } bundle = create_object(get_obj_index(OBJ_VNUM_SHOPPING_BAG), 0); snprintf(buf, MSL, "bundle %s", obj->name); STRFREE(bundle->name); bundle->name = STRALLOC(buf); snprintf(buf, MSL, "a bundle of %d %s", number, obj->name); STRFREE(bundle->short_descr); bundle->short_descr = STRALLOC(buf); snprintf(buf, MSL, "A bundle of %d %s has been left here.", number, obj->name); STRFREE(bundle->description); bundle->description = STRALLOC(buf); bundle->value[0] = bundle->weight + (obj->weight * number); short count2 = 0; count2 = inventory_total(ch); bug( "%s: inventory_total %d count2", __FUNCTION__, count2 ); count = 0; while ( count2 != -1 && count != number ) { for(check = ch->last_carrying; check; check = check->prev_content) { if ( check->pIndexData->vnum == jackpot && count <= number ) { if ( ch ) count++; separate_obj(check); obj_from_char(check); obj_to_obj( check, bundle ); } } count2--; } bug( "%s: %d count2 when %d number", __FUNCTION__, count2, number ); obj_to_char(bundle, ch); xREMOVE_BIT(bundle->extra_flags, ITEM_GROUNDROT); act(AT_ACTION, "You bundle up the $p wih leather lashings.", ch, obj, NULL, TO_CHAR); act(AT_ACTION, "$n bundles up $p together with leather lashings.", ch, obj, NULL, TO_ROOM); return; }
Current Results of the code are
You are carrying:
[35548] a dragonic saddle bag
[41002] (Sharp) a pair of talons, legendary produced from meteor (11)
Vladaar::[30000/30000hp 2990/2990m 7411/7411mv] bundle 8 talons
Log: [*****] BUG: do_bundle: 1 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: 2 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: 3 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: 4 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: 5 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: 6 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: 7 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: 8 count 8 number of talons with vnum 41002 found
Log: [*****] BUG: do_bundle: inventory_total 11 count2
Log: [*****] BUG: obj_from_char null ch for object a pair of talons, legendary produced from meteor.
Log: [*****] BUG: obj_from_char null ch for object a pair of talons, legendary produced from meteor.
Log: [*****] BUG: obj_from_char null ch for object a pair of talons, legendary produced from meteor.
Log: [*****] BUG: obj_from_char null ch for object a pair of talons, legendary produced from meteor.
Log: [*****] BUG: do_bundle: -1 count2 when 8 number
You bundle up the a pair of talons, legendary produced from meteor wih leather lashings.
Vladaar::[30000/30000hp 2990/2990m 7411/7411mv] i
You are carrying:
[35548] a dragonic saddle bag
[41002] (Sharp) a pair of talons, legendary produced from meteor (6)
[25] a bundle of 8 talons
Vladaar::[30000/30000hp 2990/2990m 7411/7411mv] l in bundle
A bundle of 8 talons contains:
[41002] (Sharp) a pair of talons, legendary produced from meteor (5)



Fledgling

GroupMembers
Posts24
JoinedJul 8, 2012
Try this:
OBJ_DATA *check_prev; while ( count2 != -1 && count != number ) { for(check = ch->last_carrying; check; check = check_prev) { check_prev = check->prev_content; if ( check->pIndexData->vnum == jackpot && count < number ) { if ( ch ) count++; separate_obj(check); obj_from_char(check); obj_to_obj( check, bundle ); } } count2--; }


Apprentice

GroupMembers
Posts57
JoinedNov 24, 2016
Leia that solved the problem with it not putting the proper amount in the bundle, but now my total_inventory is jacked up.
This is my current working total_inventory function
However, my results are coming up almost half total of what I actually have in my inventory.
Vladaar::[30000/30000hp 2990/2990m 7123/7411mv] i
You are carrying:
[35548] a dragonic saddle bag
[41002] (Sharp) a pair of talons, legendary produced from meteor (33)
Vladaar::[30000/30000hp 2990/2990m 7123/7411mv] save
Vladaar::[30000/30000hp 2990/2990m 7123/7411mv] bundle 19 meteor
You don't have any of those to bundle.
Vladaar::[30000/30000hp 2990/2990m 7359/7411mv] bundle 19 talons
Log: [*****] BUG: inventory_total total 17
Log: [*****] BUG: do_bundle: 16 count less than 19 number
You don't have enough to bundle.
A matter of fact it is exactly 1/2 number I actually have in inventory. If I do total *=2 before the return, the function works perfectly, but why in the world would I have to do that? LoL, it's crazy.
This is my current working total_inventory function
short inventory_total(CHAR_DATA *ch) { OBJ_DATA *findobj, *findobj_next; short total = 0; for(findobj = ch->first_carrying; findobj != NULL; findobj = findobj_next) { findobj_next = findobj->next_content; total++; } bug( "%s total %d", __FUNCTION__, total ); return total; }
However, my results are coming up almost half total of what I actually have in my inventory.
Vladaar::[30000/30000hp 2990/2990m 7123/7411mv] i
You are carrying:
[35548] a dragonic saddle bag
[41002] (Sharp) a pair of talons, legendary produced from meteor (33)
Vladaar::[30000/30000hp 2990/2990m 7123/7411mv] save
Vladaar::[30000/30000hp 2990/2990m 7123/7411mv] bundle 19 meteor
You don't have any of those to bundle.
Vladaar::[30000/30000hp 2990/2990m 7359/7411mv] bundle 19 talons
Log: [*****] BUG: inventory_total total 17
Log: [*****] BUG: do_bundle: 16 count less than 19 number
You don't have enough to bundle.
A matter of fact it is exactly 1/2 number I actually have in inventory. If I do total *=2 before the return, the function works perfectly, but why in the world would I have to do that? LoL, it's crazy.



Fledgling

GroupMembers
Posts24
JoinedJul 8, 2012
Your mud "groups objects" with the group_object() function?
If so, it's counting only the objects that have different affects.
If this is the problem, the code isn't considering it in the do_bundle() function either.
If so, it's counting only the objects that have different affects.
short inventory_total(CHAR_DATA *ch) { OBJ_DATA *findobj, *findobj_next; short total = 0; for(findobj = ch->first_carrying; findobj != NULL; findobj = findobj_next) { findobj_next = findobj->next_content; total += findobj->count; <-------------------- That should solve it. } bug( "%s total %d", __FUNCTION__, total ); return total; }
If this is the problem, the code isn't considering it in the do_bundle() function either.



Apprentice

GroupMembers
Posts57
JoinedNov 24, 2016
That's got to be it. Thanks!



Apprentice

GroupMembers
Posts57
JoinedNov 24, 2016
Leia said:
Your mud "groups objects" with the group_object() function?
If so, it's counting only the objects that have different affects.
short inventory_total(CHAR_DATA *ch) { OBJ_DATA *findobj, *findobj_next; short total = 0; for(findobj = ch->first_carrying; findobj != NULL; findobj = findobj_next) { findobj_next = findobj->next_content; total += findobj->count; <-------------------- That should solve it. } bug( "%s total %d", __FUNCTION__, total ); return total; }
If this is the problem, the code isn't considering it in the do_bundle() function either.
I put a split_obj call in the loop for total_inventory and solved the issue. Thanks for pointing out the group_obj thing.
Pages:<< prev 1 next >>