» SmaugMuds » Bugfix Lists » AFKMud Bugfix List » AFKMud Bug Archive » [Bug] autogold/sac/loot/etc. ...
Pages:<< prev 1 next >>
#1 Sep 23, 2006 7:26 pm
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002
Bug: autogold/sac/loot/etc. do not work correctly
Danger: Low - Mainly an annoyance issue
Discovered in: AFKMud 1.77
Found by: Valcados
Fixed by: Valcados
---
fight.c
Below:
Add:
fight.c, damage
Locate and remove:
Locate:
Change to:
Locate:
Change to:
fight.c, raw_kill
Replace the entire function with:
fight.c
Locate:
Change to:
Locate:
Change to:
Danger: Low - Mainly an annoyance issue
Discovered in: AFKMud 1.77
Found by: Valcados
Fixed by: Valcados
---
fight.c
Below:
void trip( CHAR_DATA * ch, CHAR_DATA * victim ); void make_scraps( OBJ_DATA * obj );
Add:
bool loot_coins_from_corpse( CHAR_DATA *ch, OBJ_DATA *corpse ) { OBJ_DATA *content, *content_next; int new_gold, gold_diff, old_gold = ch->gold; for( content = corpse->first_content; content; content = content_next ) { content_next = content->next_content; if( content->item_type != ITEM_MONEY ) continue; if( !can_see_obj( ch, content, true ) ) continue; if( !CAN_WEAR( content, ITEM_TAKE ) && ch->level < sysdata.level_getobjnotake ) continue; if( IS_OBJ_FLAG( content, ITEM_PROTOTYPE ) && !can_take_proto( ch ) ) continue; act( AT_ACTION, "You get $p from $P", ch, content, corpse, TO_CHAR ); act( AT_ACTION, "$n gets $p from $P", ch, content, corpse, TO_ROOM ); obj_from_obj( content ); check_for_trap( ch, content, TRAP_GET ); if( char_died( ch ) ) return FALSE; oprog_get_trigger( ch, content ); if( char_died( ch ) ) return FALSE; ch->gold += content->value[0] * content->count; extract_obj( content ); } new_gold = ch->gold; gold_diff = ( new_gold - old_gold ); if( IS_PLR_FLAG( ch, PLR_GUILDSPLIT ) && ch->position > POS_SLEEPING && ch->pcdata->clan && ch->pcdata->clan->bank ) { int split = 0; if( gold_diff > 0 ) { float xx = ( float )( ch->pcdata->clan->tithe ) / 100; float pct = ( float )( gold_diff ) * xx; split = ( int )( gold_diff - pct ); ch->pcdata->clan->balance += split; save_clan( ch->pcdata->clan ); ch_printf( ch, "The Wedgy comes to collect %d gold on behalf of your %s.\n\r", split, ch->pcdata->clan->clan_type == CLAN_ORDER ? "guild" : "clan" ); gold_diff -= split; ch->gold -= split; } } if( gold_diff > 0 && IS_PLR_FLAG( ch, PLR_GROUPSPLIT ) && ch->position > POS_SLEEPING ) cmdf( ch, "split %d", gold_diff ); return TRUE; }
fight.c, damage
Locate and remove:
char buf1[MAX_STRING_LENGTH]; int init_gold, new_gold, gold_diff;
Locate:
/* * Payoff for killing things. */ if( victim->position == POS_DEAD ) { if( !in_arena( victim ) ) group_gain( ch, victim );
Change to:
/* * Payoff for killing things. */ if( victim->position == POS_DEAD ) { OBJ_DATA *new_corpse; if( !in_arena( victim ) ) group_gain( ch, victim );
Locate:
raw_kill( ch, victim ); victim = NULL; if( !IS_NPC( ch ) && loot ) { /* * Autogold by Scryn 8/12 */ if( xIS_SET( ch->act, PLR_AUTOGOLD ) ) { init_gold = ch->gold; do_get( ch, "coins corpse" ); new_gold = ch->gold; gold_diff = ( new_gold - init_gold ); if( gold_diff > 0 ) { snprintf( buf1, MAX_STRING_LENGTH, "%d", gold_diff ); do_split( ch, buf1 ); } } if( xIS_SET( ch->act, PLR_AUTOLOOT ) && victim != ch ) /* prevent nasty obj problems -- Blodkai */ do_get( ch, "all corpse" ); else do_look( ch, "in corpse" ); if( xIS_SET( ch->act, PLR_AUTOSAC ) ) do_sacrifice( ch, "corpse" ); }
Change to:
new_corpse = raw_kill( ch, victim ); victim = NULL; if( !IS_NPC( ch ) && loot && new_corpse && new_corpse->item_type == ITEM_CORPSE_NPC && new_corpse->in_room == ch->in_room && can_see_obj( ch, new_corpse ) && ch->position > POS_SLEEPING ) { /* * Autogold by Scryn 8/12 */ if( IS_PLR_FLAG( ch, PLR_AUTOGOLD ) && !loot_coins_from_corpse( ch, new_corpse ) ) return rBOTH_DIED; if( !obj_extracted(new_corpse) ) { if( IS_PLR_FLAG( ch, PLR_AUTOLOOT ) && victim != ch ) /* prevent nasty obj problems -- Blodkai */ interpret( ch, "get all corpse" ); if( IS_PLR_FLAG( ch, PLR_SMARTSAC ) ) { OBJ_DATA *corpse; if( ( corpse = get_obj_here( ch, "corpse" ) ) != NULL ) { if( !corpse->first_content ) interpret( ch, "sacrifice corpse" ); else interpret( ch, "look in corpse" ); } } else if( IS_PLR_FLAG( ch, PLR_AUTOSAC ) && !IS_PLR_FLAG( ch, PLR_SMARTSAC ) ) interpret( ch, "sacrifice corpse" ); } }
fight.c, raw_kill
Replace the entire function with:
OBJ_DATA *raw_kill( CHAR_DATA * ch, CHAR_DATA * victim ) { OBJ_DATA *corpse_to_return = NULL; if( !victim ) { bug( "%s: null victim! CH: %s", __FUNCTION__, ch->name ); return NULL; } /* * backup in case hp goes below 1 */ if( !IS_NPC( victim ) && victim->level == 1 ) { bug( "%s: killing level 1", __FUNCTION__ ); return NULL; } stop_fighting( victim, TRUE ); if( in_arena( victim ) ) { ROOM_INDEX_DATA *location = NULL; log_printf_plus( LOG_INFO, LEVEL_IMMORTAL, "%s bested %s in the arena.", ch->name, victim->name ); ch_printf( ch, "You bested %s in arena combat!\n\r", victim->name ); ch_printf( victim, "%s bested you in arena combat!\n\r", ch->name ); victim->hit = 1; victim->position = POS_RESTING; location = check_room( victim, victim->in_room ); /* added check to see what continent PC is on - Samson 3-29-98 */ if( !location ) location = get_room_index( ROOM_VNUM_LIMBO ); char_from_room( victim ); if( !char_to_room( victim, location ) ) log_printf( "char_to_room: %s:%s, line %d.", __FILE__, __FUNCTION__, __LINE__ ); if( IS_AFFECTED( victim, AFF_PARALYSIS ) ) REMOVE_AFFECTED( victim, AFF_PARALYSIS ); return NULL; } /* * Take care of morphed characters */ if( victim->morph ) { do_unmorph_char( victim ); return raw_kill( ch, victim ); } /* * Deal with switched imms */ if( victim->desc && victim->desc->original ) { CHAR_DATA *temp = victim; interpret( victim, "return" ); return raw_kill( ch, temp ); } mprog_death_trigger( ch, victim ); if( char_died( victim ) ) return NULL; rprog_death_trigger( ch, victim ); if( char_died( victim ) ) return NULL; death_cry( victim ); corpse_to_return = make_corpse( victim, ch ); if( victim->in_room->sector_type == SECT_OCEANFLOOR || victim->in_room->sector_type == SECT_UNDERWATER || victim->in_room->sector_type == SECT_WATER_SWIM || victim->in_room->sector_type == SECT_WATER_NOSWIM || victim->in_room->sector_type == SECT_RIVER ) act( AT_BLOOD, "$n's blood slowly clouds the surrounding water.", victim, NULL, NULL, TO_ROOM ); else if( victim->in_room->sector_type == SECT_AIR ) act( AT_BLOOD, "$n's blood sprays wildly through the air.", victim, NULL, NULL, TO_ROOM ); else make_blood( victim ); if( IS_NPC( victim ) ) { victim->pIndexData->killed++; extract_char( victim, TRUE ); victim = NULL; return corpse_to_return; } set_char_color( AT_DIEMSG, victim ); if( victim->pcdata->mdeaths + victim->pcdata->pdeaths < 3 ) interpret( victim, "help new_death" ); else interpret( victim, "help _DIEMSG_" ); extract_char( victim, FALSE ); if( !victim ) { bug( "oops! %s: extract_char destroyed pc char", __FUNCTION__ ); return corpse_to_return; } while( victim->first_affect ) affect_remove( victim, victim->first_affect ); victim->affected_by = race_table[victim->race]->affected; xCLEAR_BITS( victim->resistant ); xCLEAR_BITS( victim->susceptible ); xCLEAR_BITS( victim->immune ); xCLEAR_BITS( victim->absorb ); victim->carry_weight = 0; victim->armor = 100; victim->armor += race_table[victim->race]->ac_plus; victim->attacks = race_table[victim->race]->attacks; victim->defenses = race_table[victim->race]->defenses; victim->mod_str = 0; victim->mod_dex = 0; victim->mod_wis = 0; victim->mod_int = 0; victim->mod_con = 0; victim->mod_cha = 0; victim->mod_lck = 0; victim->damroll = 0; victim->hitroll = 0; victim->mental_state = -10; victim->alignment = URANGE( -1000, victim->alignment, 1000 ); victim->saving_poison_death = race_table[victim->race]->saving_poison_death; victim->saving_wand = race_table[victim->race]->saving_wand; victim->saving_para_petri = race_table[victim->race]->saving_para_petri; victim->saving_breath = race_table[victim->race]->saving_breath; victim->saving_spell_staff = race_table[victim->race]->saving_spell_staff; victim->position = POS_RESTING; victim->hit = UMAX( 1, victim->hit ); victim->mana = UMAX( 1, victim->mana ); victim->move = UMAX( 1, victim->move ); if( victim->pcdata->condition[COND_FULL] != -1 ) victim->pcdata->condition[COND_FULL] = sysdata.maxcondval / 2; if( victim->pcdata->condition[COND_THIRST] != -1 ) victim->pcdata->condition[COND_THIRST] = sysdata.maxcondval / 2; if( IS_SAVE_FLAG( SV_DEATH ) ) save_char_obj( victim ); return corpse_to_return; }
fight.c
Locate:
void make_corpse( CHAR_DATA *ch, CHAR_DATA *killer ) { OBJ_DATA *corpse, *obj, *obj_next; char *name; if( IS_NPC( ch ) ) { name = ch->short_descr; if( !( corpse = create_object( get_obj_index( OBJ_VNUM_CORPSE_NPC ), ch->level ) ) ) { log_printf( "create_object: %s:%s, line %d.", __FILE__, __FUNCTION__, __LINE__ ); return; }
Change to:
OBJ_DATA *make_corpse( CHAR_DATA *ch, CHAR_DATA *killer ) { OBJ_DATA *corpse, *obj, *obj_next; char *name; if( IS_NPC( ch ) ) { name = ch->short_descr; if( !( corpse = create_object( get_obj_index( OBJ_VNUM_CORPSE_NPC ), ch->level ) ) ) { log_printf( "create_object: %s:%s, line %d.", __FILE__, __FUNCTION__, __LINE__ ); return NULL; }
Locate:
obj_to_room( corpse, ch->in_room ); return;
Change to:
return obj_to_room( corpse, ch->in_room );
Valcados said:
First, autogold fails to loot "1 gold coin" if that's all the mob has. Second, the code for doing these various corpse related things could be more robust, if you added a slaying get prog to the "%d gold coins" object, autogold might very well crash the MUD. Third, absolutely no checks are made to see that the corpse exists, that it's in the same room as the player, that the player can see it, or that the player is conscious enough to rifle through its pockets. Fourth, weight/inventory problems prevent players from autogolding, even though gold is weightless and spaceless.
Pages:<< prev 1 next >>