/* This is my version of weapons and armor advancing level. It makes it so that when you * mobs your weapons, and armor will gain levels and will be given stats each time they * level up. I really don't like math, so i'm sure the values could be changed around, or * be more randomized. If you do something like this please send me a copy of the changes * so i can post them, and benefit from them as well. My email address is * synch23@titan.kyndig.com. If you have any comments for me feel free to email me as well. * Anyway here is the code! */ Changes for update.c ******************** Below: void char_update args( ( void ) ); Add: void gain_object_exp args( ( CHAR_DATA *ch, OBJ_DATA *obj, int gain ) ); void advance_level_object args( ( CHAR_DATA *ch, OBJ_DATA *obj ) ); void gain_object_exp( CHAR_DATA *ch, OBJ_DATA *obj, int gain ) { int leftover = 0; if ( IS_NPC(ch) || obj->plevel >= MOBJLEVEL || IS_WEREWOLF(ch) ) return; printf_to_char( ch, "%s has gained %d exp.\n\r", capitalize( obj->short_descr ), gain ); obj->exp += gain; obj->xp_tolevel -= gain; if(obj->xp_tolevel <= 0 ) { obj->exp += obj->xp_tolevel; advance_level_object(ch,obj); leftover = ( obj->xp_tolevel * 1 ); obj->plevel++; printf_to_char( ch, "%s has raised to level %d. To see your objects stats lore or identify it.\n\r", capitalize( obj->short_descr ), obj->plevel ); obj->xp_tolevel = 1500 + ( obj->plevel * 150 ); obj->xp_tolevel -= leftover; return; } return; } void advance_level_object( CHAR_DATA *ch, OBJ_DATA *obj ) { int pbonus = number_range( 5, 10 ); int bonus = number_range( 4, 8 ); pbonus = pbonus * 9/10; bonus = bonus * 8/10; pbonus = UMAX( 6, pbonus ); bonus = UMAX( 1, bonus ); add_apply(obj, APPLY_DAMROLL, pbonus, TO_OBJECT, 0, -1, 0, obj->plevel * 5); add_apply(obj, APPLY_HITROLL, pbonus, TO_OBJECT, 0, -1, 0, obj->plevel * 5); add_apply(obj, APPLY_HIT, pbonus, TO_OBJECT, 0, -1, 0, obj->plevel * 5); add_apply(obj, APPLY_MANA, pbonus, TO_OBJECT, 0, -1, 0, obj->plevel * 5); add_apply(obj, APPLY_MOVE, pbonus, TO_OBJECT, 0, -1, 0, obj->plevel * 5); if (obj->item_type == ITEM_WEAPON) { obj->value[1] += bonus/4; obj->value[2] += bonus/5; } else if (obj->item_type == ITEM_ARMOR) { obj->value[0] -= UMAX(1, obj->plevel); obj->value[1] -= UMAX(1, obj->plevel); obj->value[2] -= UMAX(1, obj->plevel); obj->value[3] -= (5 * UMAX(1, obj->plevel)) / 10; } return; } Changes for handler.c ********************* At the end of the file add this: void add_apply(OBJ_DATA * obj, int loc, int mod, int where, int type, int dur,int vector, int level) { AFFECT_DATA pAf; if (obj == NULL) return; if (!obj->enchanted) affect_enchant(obj); pAf.location = loc; pAf.modifier = mod; pAf.where = where; pAf.type = type; pAf.duration = dur; pAf.bitvector = vector; pAf.level = level; affect_join_obj(obj, &pAf); return; } Changes for merc.h ****************** Below: void gain_exp args( ( CHAR_DATA *ch, int gain ) ); Add: void gain_object_exp args( ( CHAR_DATA *ch, OBJ_DATA *obj, int gain ) ); In struct obj_index_data: Below: sh_int size; Add: sh_int plevel; int xp_tolevel; int exp; In struct obj_data: Below: sh_int level; Add: int exp; sh_int plevel; int xp_tolevel; At the end of the file add this: void add_apply args((OBJ_DATA * obj, int loc, int mod, int where, int type, int dur, int vector, int level)); Add this to your item defines with a free bitvector: #define ITEM_RELIC (XXX) Changes for act_wiz.c ********************* void do_mrelic (CHAR_DATA *ch, char *argument) { OBJ_DATA *obj; int i = 1500; if ( argument[0] == '\0' ) { send_to_char( "Make a relic item of what?\n\r", ch ); return; } if ( ( obj = get_obj_carry( ch, argument, ch ) ) == NULL ) { send_to_char( "You do not have that item.\n\r", ch ); return; } if (IS_OBJ_STAT(obj,ITEM_RELIC)) { REMOVE_BIT(obj->extra_flags,ITEM_RELIC); act("$p is no longer a relic item.",ch,obj,NULL,TO_CHAR); } else { SET_BIT(obj->extra_flags,ITEM_RELIC); if ( obj->xp_tolevel <= 0 ) obj->xp_tolevel = i; act("$p is now a relic item.",ch,obj,NULL,TO_CHAR); } return; } in do_ostat add this somewhere with the other values: if ( IS_OBJ_STAT(obj, ITEM_RELIC)) { printf_to_char(ch, "Exp TNL: %d\n\r", obj->xp_tolevel ); printf_to_char(ch, "Exp: %d\n\r", obj->exp ); } Changes for db.c **************** In OBJ_DATA * create_object Below: obj->condition = pObjIndex->condition; Add: if(IS_OBJ_STAT(obj, ITEM_RELIC) ) obj->xp_tolevel = 1500; Changes for save.c ****************** in void fwrite_obj Below: fprintf( fp, "Wear %d\n", obj->wear_loc ); Add: if ( obj->plevel > 0 ) fprintf( fp, "Plev %d\n", obj->plevel ); if ( obj->exp > 0 ) fprintf( fp, "Exp %d\n", obj->exp ); if ( obj->xp_tolevel > 0 ) fprintf( fp, "Xptolevel %d\n", obj->xp_tolevel ); in fread_obj make a case 'P' like this: case 'P': KEY("Plevel", obj->plevel, fread_number( fp ) ); break; In case 'E': Above: KEY( "ExtraFlags", obj->extra_flags, fread_number( fp ) ); Add: KEY( "Exp", obj->exp, fread_number( fp ) ); make a case 'X' like this: case 'X': KEY( "Xptolevel", obj->xp_tolevel, fread_number( fp ) ); break; in file handler.c ***************** below: if ( extra_flags & ITEM_ROT_DEATH ) strcat( buf, " rot_death" ); add: if ( extra_flags & ITEM_RELIC ) strcat( buf, " relic" ); in file tables.c **************** below: { "rotdeath", ITEM_ROT_DEATH, TRUE }, add: { "relic", ITEM_RELIC, TRUE }, in file interp.h **************** at the bottom of the file add: DECLARE_DO_FUN( do_mrelic ); in file interp.c **************** in the immortal commands add: {"mrelic", do_mrelic, POS_DEAD, L3, LOG_NORMAL, 1}, in file fight.c *************** in void group_gain Below: obj_next = obj->next_content; if ( obj->wear_loc == WEAR_NONE ) continue; Add: if ( IS_OBJ_STAT(obj, ITEM_RELIC) && obj->xp_tolevel > 0 ) { gain_object_exp( ch, obj, xp ); } in file olc.c ************* in the oedit table below: { "show", oedit_show }, put: { "xptolevel", oedit_xptolevel }, in file olc_act.c ***************** in oedit_show below: sprintf( buf, "Weight: [%5d]\n\rCost: [%5d]\n\r", pObj->weight, pObj->cost ); send_to_char( buf, ch ); put: sprintf( buf, "Xp to level: [%5d]\n\r", /* ROM */ pObj->xp_tolevel ); send_to_char( buf, ch ); at the end of olc_act.c put this: OEDIT( oedit_xptolevel ) { OBJ_INDEX_DATA *pObj; int amount; EDIT_OBJ(ch, pObj); if ( argument[0] == '\0' || !is_number( argument ) ) { send_to_char( "Syntax: xptolevel [number]\n\r", ch ); return FALSE; } amount = *argument; if ( amount < 0 || amount > 5000 ) { send_to_char( "Please choose an amount between 0 and 5000\n\r", ch ); return FALSE; } pObj->xp_tolevel = atoi( argument ); send_to_char( "Exp to level set.\n\r", ch); return TRUE; } in file olc.h ************* below: DECLARE_OLC_FUN( oedit_level ); /* ROM */ add: DECLARE_OLC_FUN( oedit_xptolevel ); Make sure that if your builders are adding relic flags to their objects that they set the exp as well. Otherwise those items will not level. If some objects to end up on the mud that don't level youc an set and remove the mrelic flag on each individual item and that will set the exp for it. Ok that should be it. If I left out anything then be sure and let me know. Just make clean, compile and copyover and you should be good to go.