void Character::spell_charm_person (int sn, int lvl, void *vo) { Character *victim = (Character *) vo; Affect af; if (victim == this) { send_to_char ("You like yourself even better!\r\n"); return; } if (victim->is_affected (AFF_CHARM) || is_affected (AFF_CHARM) || lvl < victim->level || victim->saves_spell (lvl)) return; if (victim->master) victim->stop_follower(); victim->add_follower(this); af.type = sn; af.duration = number_fuzzy (lvl / 4); af.location = 0; af.modifier = 0; af.bitvector = AFF_CHARM; victim->affect_to_char(&af); act ("Isn't $n just so nice?", NULL, victim, TO_VICT); if (this != victim) send_to_char ("Ok.\r\n"); return; }
/* * Make a fire. */ void make_fire( ROOM_INDEX_DATA * in_room, short timer ) { OBJ_DATA *fire; fire = create_object( get_obj_index( OBJ_VNUM_FIRE ), 0 ); fire->timer = number_fuzzy( timer ); obj_to_room( fire, in_room ); return; }
/* * Make a campfire. */ void make_campfire( room_index * in_room, char_data * ch, short timer ) { obj_data *fire; if( !( fire = get_obj_index( OBJ_VNUM_CAMPFIRE )->create_object( 1 ) ) ) { log_printf( "create_object: %s:%s, line %d.", __FILE__, __FUNCTION__, __LINE__ ); return; } fire->timer = number_fuzzy( timer ); fire->to_room( in_room, ch ); }
/* * Create an instance of a mobile. */ CHAR_DATA *create_mobile( MOB_INDEX_DATA *pMobIndex ) { CHAR_DATA *mob; if ( pMobIndex == NULL ) { bug( "Create_mobile: NULL pMobIndex.", 0 ); exit( 1 ); } if ( char_free == NULL ) { mob = alloc_perm( sizeof(*mob) ); } else { mob = char_free; char_free = char_free->next; } clear_char( mob ); mob->pIndexData = pMobIndex; mob->name = pMobIndex->player_name; mob->short_descr = pMobIndex->short_descr; mob->long_descr = pMobIndex->long_descr; mob->description = pMobIndex->description; mob->spec_fun = pMobIndex->spec_fun; mob->level = number_fuzzy( pMobIndex->level ); mob->act = pMobIndex->act; mob->affected_by = pMobIndex->affected_by; mob->alignment = pMobIndex->alignment; mob->sex = pMobIndex->sex; mob->armor = interpolate( mob->level, 100, -100 ); mob->max_hit = mob->level * 8 + number_range( mob->level * mob->level / 4, mob->level * mob->level ); mob->hit = mob->max_hit; /* * Insert in list. */ mob->next = char_list; char_list = mob; pMobIndex->count++; return mob; }
void Character::spell_sanctuary (int sn, int lvl, void *vo) { Character *victim = (Character *) vo; Affect af; if (victim->is_affected (AFF_SANCTUARY)) return; af.type = sn; af.duration = number_fuzzy (lvl / 8); af.location = APPLY_NONE; af.modifier = 0; af.bitvector = AFF_SANCTUARY; victim->affect_to_char(&af); victim->act ("$n is surrounded by a white aura.", NULL, NULL, TO_ROOM); victim->send_to_char ("You are surrounded by a white aura.\r\n"); return; }
void Character::spell_pass_door (int sn, int lvl, void *vo) { Character *victim = (Character *) vo; Affect af; if (victim->is_affected (AFF_PASS_DOOR)) return; af.type = sn; af.duration = number_fuzzy (lvl / 4); af.location = APPLY_NONE; af.modifier = 0; af.bitvector = AFF_PASS_DOOR; victim->affect_to_char(&af); victim->act ("$n turns translucent.", NULL, NULL, TO_ROOM); victim->send_to_char ("You turn translucent.\r\n"); return; }
void Character::spell_enchant_weapon (int sn, int lvl, void *vo) { Object *obj = (Object *) vo; Affect *paf; if (obj->item_type != ITEM_WEAPON || obj->is_obj_stat(ITEM_MAGIC) || !obj->affected.empty()) return; paf = new Affect(); paf->type = sn; paf->duration = -1; paf->location = APPLY_HITROLL; paf->modifier = lvl / 5; paf->bitvector = 0; obj->affected.push_back(paf); paf = new Affect(); paf->type = -1; paf->duration = -1; paf->location = APPLY_DAMROLL; paf->modifier = lvl / 10; paf->bitvector = 0; obj->affected.push_back(paf); obj->level = number_fuzzy (level - 5); if (is_good ()) { SET_BIT (obj->extra_flags, ITEM_ANTI_EVIL); act ("$p glows blue.", obj, NULL, TO_CHAR); } else if (is_evil ()) { SET_BIT (obj->extra_flags, ITEM_ANTI_GOOD); act ("$p glows red.", obj, NULL, TO_CHAR); } else { SET_BIT (obj->extra_flags, ITEM_ANTI_EVIL); SET_BIT (obj->extra_flags, ITEM_ANTI_GOOD); act ("$p glows yellow.", obj, NULL, TO_CHAR); } send_to_char ("Ok.\r\n"); return; }
/* * Reset one room. */ void reset_room( ROOM_INDEX_DATA * room ) { RESET_DATA *pReset, *tReset, *gReset; OBJ_DATA *nestmap[MAX_NEST]; CHAR_DATA *mob; OBJ_DATA *obj, *lastobj, *to_obj; ROOM_INDEX_DATA *pRoomIndex = NULL; MOB_INDEX_DATA *pMobIndex = NULL; OBJ_INDEX_DATA *pObjIndex = NULL, *pObjToIndex; EXIT_DATA *pexit; const char *filename = room->area->filename; int level = 0, n, num = 0, lastnest, onreset = 0; mob = NULL; obj = NULL; lastobj = NULL; if ( !room->first_reset ) return; level = 0; for ( pReset = room->first_reset; pReset; pReset = pReset->next ) { ++onreset; switch ( pReset->command ) { default: bug( "%s: %s: bad command %c.", __FUNCTION__, filename, pReset->command ); break; case 'M': if ( !( pMobIndex = get_mob_index( pReset->arg1 ) ) ) { bug( "%s: %s: 'M': bad mob vnum %d.", __FUNCTION__, filename, pReset->arg1 ); continue; } if ( !( pRoomIndex = get_room_index( pReset->arg3 ) ) ) { bug( "%s: %s: 'M': bad room vnum %d.", __FUNCTION__, filename, pReset->arg3 ); continue; } if ( !pReset->sreset ) { mob = NULL; break; } mob = create_mobile( pMobIndex ); { ROOM_INDEX_DATA *pRoomPrev = get_room_index( pReset->arg3 - 1 ); if ( pRoomPrev && xIS_SET( pRoomPrev->room_flags, ROOM_PET_SHOP ) ) xSET_BIT( mob->act, ACT_PET ); } if ( room_is_dark( pRoomIndex ) ) xSET_BIT( mob->affected_by, AFF_INFRARED ); mob->resetvnum = pRoomIndex->vnum; mob->resetnum = onreset; pReset->sreset = false; char_to_room( mob, pRoomIndex ); level = URANGE( 0, mob->level - 2, LEVEL_AVATAR ); if ( pReset->first_reset ) { for ( tReset = pReset->first_reset; tReset; tReset = tReset->next_reset ) { ++onreset; switch ( tReset->command ) { case 'G': case 'E': if ( !( pObjIndex = get_obj_index( tReset->arg1 ) ) ) { bug( "%s: %s: 'E' or 'G': bad obj vnum %d.", __FUNCTION__, filename, tReset->arg1 ); continue; } if ( !mob ) { lastobj = NULL; break; } if ( mob->pIndexData->pShop ) { int olevel = generate_itemlevel( room->area, pObjIndex ); obj = create_object( pObjIndex, olevel ); xSET_BIT( obj->extra_flags, ITEM_INVENTORY ); } else obj = create_object( pObjIndex, number_fuzzy( level ) ); obj->level = URANGE( 0, obj->level, LEVEL_AVATAR ); obj = obj_to_char( obj, mob ); if ( tReset->command == 'E' ) { if ( obj->carried_by != mob ) { bug( "'E' reset: can't give object %d to mob %d.", obj->pIndexData->vnum, mob->pIndexData->vnum ); break; } equip_char( mob, obj, tReset->arg3 ); } for ( n = 0; n < MAX_NEST; n++ ) nestmap[n] = NULL; nestmap[0] = obj; lastobj = nestmap[0]; lastnest = 0; if ( tReset->first_reset ) { for ( gReset = tReset->first_reset; gReset; gReset = gReset->next_reset ) { int iNest; to_obj = lastobj; ++onreset; switch ( gReset->command ) { case 'H': if ( !lastobj ) break; xSET_BIT( lastobj->extra_flags, ITEM_HIDDEN ); break; case 'P': if ( !( pObjIndex = get_obj_index( gReset->arg1 ) ) ) { bug( "%s: %s: 'P': bad obj vnum %d.", __FUNCTION__, filename, gReset->arg1 ); continue; } iNest = gReset->extra; if ( !( pObjToIndex = get_obj_index( gReset->arg3 ) ) ) { bug( "%s: %s: 'P': bad objto vnum %d.", __FUNCTION__, filename, gReset->arg3 ); continue; } if ( iNest >= MAX_NEST ) { bug( "%s: %s: 'P': Exceeded nesting limit of %d", __FUNCTION__, filename, MAX_NEST ); obj = NULL; break; } if ( count_obj_list( pObjIndex, to_obj->first_content ) > 0 ) { obj = NULL; break; } if ( iNest < lastnest ) to_obj = nestmap[iNest]; else if ( iNest == lastnest ) to_obj = nestmap[lastnest]; else to_obj = lastobj; obj = create_object( pObjIndex, number_fuzzy( UMAX( generate_itemlevel( room->area, pObjIndex ), to_obj->level ) ) ); if ( num > 1 ) pObjIndex->count += ( num - 1 ); obj->count = gReset->arg2; obj->level = UMIN( obj->level, LEVEL_AVATAR ); obj->count = gReset->arg2; obj_to_obj( obj, to_obj ); if ( iNest > lastnest ) { nestmap[iNest] = to_obj; lastnest = iNest; } lastobj = obj; /* * Hackish fix for nested puts */ if ( gReset->arg3 == OBJ_VNUM_MONEY_ONE ) gReset->arg3 = to_obj->pIndexData->vnum; break; } } } break; } } } break; case 'O': if ( !( pObjIndex = get_obj_index( pReset->arg1 ) ) ) { bug( "%s: %s: 'O': bad obj vnum %d.", __FUNCTION__, filename, pReset->arg1 ); continue; } if ( !( pRoomIndex = get_room_index( pReset->arg3 ) ) ) { bug( "%s: %s: 'O': bad room vnum %d.", __FUNCTION__, filename, pReset->arg3 ); continue; } if ( count_obj_list( pObjIndex, pRoomIndex->first_content ) < 1 ) { obj = create_object( pObjIndex, number_fuzzy( generate_itemlevel( room->area, pObjIndex ) ) ); if ( num > 1 ) pObjIndex->count += ( num - 1 ); obj->count = pReset->arg2; obj->level = UMIN( obj->level, LEVEL_AVATAR ); obj->cost = 0; obj_to_room( obj, pRoomIndex ); } else { int x; if ( !( obj = get_obj_room( pObjIndex, pRoomIndex ) ) ) { obj = NULL; lastobj = NULL; break; } obj->extra_flags = pObjIndex->extra_flags; for ( x = 0; x < 6; ++x ) obj->value[x] = pObjIndex->value[x]; } for ( n = 0; n < MAX_NEST; n++ ) nestmap[n] = NULL; nestmap[0] = obj; lastobj = nestmap[0]; lastnest = 0; if ( pReset->first_reset ) { for ( tReset = pReset->first_reset; tReset; tReset = tReset->next_reset ) { int iNest; to_obj = lastobj; ++onreset; switch ( tReset->command ) { case 'H': if ( !lastobj ) break; xSET_BIT( lastobj->extra_flags, ITEM_HIDDEN ); break; case 'T': if ( !IS_SET( tReset->extra, TRAP_OBJ ) ) { bug( "%s: Room reset found on object reset list", __FUNCTION__ ); break; } else { /* * We need to preserve obj for future 'T' checks */ OBJ_DATA *pobj; if ( tReset->arg3 > 0 ) { if ( !( pObjToIndex = get_obj_index( tReset->arg3 ) ) ) { bug( "%s: %s: 'T': bad objto vnum %d.", __FUNCTION__, filename, tReset->arg3 ); continue; } if ( room->area->nplayer > 0 || !( to_obj = get_obj_type( pObjToIndex ) ) || ( to_obj->carried_by && !IS_NPC( to_obj->carried_by ) ) || is_trapped( to_obj ) ) break; } else { if ( !lastobj || !obj ) break; to_obj = obj; } pobj = make_trap( tReset->arg2, tReset->arg1, number_fuzzy( to_obj->level ), tReset->extra ); obj_to_obj( pobj, to_obj ); } break; case 'P': if ( !( pObjIndex = get_obj_index( tReset->arg1 ) ) ) { bug( "%s: %s: 'P': bad obj vnum %d.", __FUNCTION__, filename, tReset->arg1 ); continue; } iNest = tReset->extra; if ( !( pObjToIndex = get_obj_index( tReset->arg3 ) ) ) { bug( "%s: %s: 'P': bad objto vnum %d.", __FUNCTION__, filename, tReset->arg3 ); continue; } if ( iNest >= MAX_NEST ) { bug( "%s: %s: 'P': Exceeded nesting limit of %d. Room %d.", __FUNCTION__, filename, MAX_NEST, room->vnum ); obj = NULL; break; } if ( count_obj_list( pObjIndex, to_obj->first_content ) > 0 ) { obj = NULL; break; } if ( iNest < lastnest ) to_obj = nestmap[iNest]; else if ( iNest == lastnest ) to_obj = nestmap[lastnest]; else to_obj = lastobj; obj = create_object( pObjIndex, number_fuzzy( UMAX( generate_itemlevel( room->area, pObjIndex ), to_obj->level ) ) ); if ( num > 1 ) pObjIndex->count += ( num - 1 ); obj->count = tReset->arg2; obj->level = UMIN( obj->level, LEVEL_AVATAR ); obj->count = tReset->arg2; obj_to_obj( obj, to_obj ); if ( iNest > lastnest ) { nestmap[iNest] = to_obj; lastnest = iNest; } lastobj = obj; /* * Hackish fix for nested puts */ if ( tReset->arg3 == OBJ_VNUM_MONEY_ONE ) tReset->arg3 = to_obj->pIndexData->vnum; break; } } } break; case 'T': if ( IS_SET( pReset->extra, TRAP_OBJ ) ) { bug( "%s: Object trap found in room %d reset list", __FUNCTION__, room->vnum ); break; } else { if ( !( pRoomIndex = get_room_index( pReset->arg3 ) ) ) { bug( "%s: %s: 'T': bad room %d.", __FUNCTION__, filename, pReset->arg3 ); continue; } if ( room->area->nplayer > 0 || count_obj_list( get_obj_index( OBJ_VNUM_TRAP ), pRoomIndex->first_content ) > 0 ) break; to_obj = make_trap( pReset->arg1, pReset->arg1, 10, pReset->extra ); obj_to_room( to_obj, pRoomIndex ); } break; case 'D': if ( !( pRoomIndex = get_room_index( pReset->arg1 ) ) ) { bug( "%s: %s: 'D': bad room vnum %d.", __FUNCTION__, filename, pReset->arg1 ); continue; } if ( !( pexit = get_exit( pRoomIndex, pReset->arg2 ) ) ) break; switch ( pReset->arg3 ) { case 0: REMOVE_BIT( pexit->exit_info, EX_CLOSED ); REMOVE_BIT( pexit->exit_info, EX_LOCKED ); break; case 1: SET_BIT( pexit->exit_info, EX_CLOSED ); REMOVE_BIT( pexit->exit_info, EX_LOCKED ); if ( IS_SET( pexit->exit_info, EX_xSEARCHABLE ) ) SET_BIT( pexit->exit_info, EX_SECRET ); break; case 2: SET_BIT( pexit->exit_info, EX_CLOSED ); SET_BIT( pexit->exit_info, EX_LOCKED ); if ( IS_SET( pexit->exit_info, EX_xSEARCHABLE ) ) SET_BIT( pexit->exit_info, EX_SECRET ); break; } break; case 'R': if ( !( pRoomIndex = get_room_index( pReset->arg1 ) ) ) { bug( "%s: %s: 'R': bad room vnum %d.", __FUNCTION__, filename, pReset->arg1 ); continue; } randomize_exits( pRoomIndex, pReset->arg2 - 1 ); break; } } }
/* * Snarf a mob section. */ void load_mobiles( FILE *fp ) { MOB_INDEX_DATA *pMobIndex; for ( ; ; ) { sh_int vnum; char letter; int iHash; letter = fread_letter( fp ); if ( letter != '#' ) { bug( "Load_mobiles: # not found.", 0 ); exit( 1 ); } vnum = fread_number( fp ); if ( vnum == 0 ) break; fBootDb = FALSE; if ( get_mob_index( vnum ) != NULL ) { bug( "Load_mobiles: vnum %d duplicated.", vnum ); exit( 1 ); } fBootDb = TRUE; pMobIndex = alloc_perm( sizeof(*pMobIndex) ); pMobIndex->vnum = vnum; pMobIndex->player_name = fread_string( fp ); pMobIndex->short_descr = fread_string( fp ); pMobIndex->long_descr = fread_string( fp ); pMobIndex->description = fread_string( fp ); pMobIndex->long_descr[0] = UPPER(pMobIndex->long_descr[0]); pMobIndex->description[0] = UPPER(pMobIndex->description[0]); pMobIndex->act = fread_number( fp ) | ACT_IS_NPC; pMobIndex->affected_by = fread_number( fp ); pMobIndex->pShop = NULL; pMobIndex->alignment = fread_number( fp ); letter = fread_letter( fp ); pMobIndex->level = number_fuzzy( fread_number( fp ) ); /* * The unused stuff is for imps who want to use the old-style * stats-in-files method. */ pMobIndex->hitroll = fread_number( fp ); /* Unused */ pMobIndex->ac = fread_number( fp ); /* Unused */ pMobIndex->hitnodice = fread_number( fp ); /* Unused */ /* 'd' */ fread_letter( fp ); /* Unused */ pMobIndex->hitsizedice = fread_number( fp ); /* Unused */ /* '+' */ fread_letter( fp ); /* Unused */ pMobIndex->hitplus = fread_number( fp ); /* Unused */ pMobIndex->damnodice = fread_number( fp ); /* Unused */ /* 'd' */ fread_letter( fp ); /* Unused */ pMobIndex->damsizedice = fread_number( fp ); /* Unused */ /* '+' */ fread_letter( fp ); /* Unused */ pMobIndex->damplus = fread_number( fp ); /* Unused */ pMobIndex->gold = fread_number( fp ); /* Unused */ /* xp can't be used! */ fread_number( fp ); /* Unused */ /* position */ fread_number( fp ); /* Unused */ /* start pos */ fread_number( fp ); /* Unused */ /* * Back to meaningful values. */ pMobIndex->sex = fread_number( fp ); if ( letter != 'S' ) { bug( "Load_mobiles: vnum %d non-S.", vnum ); exit( 1 ); } iHash = vnum % MAX_KEY_HASH; pMobIndex->next = mob_index_hash[iHash]; mob_index_hash[iHash] = pMobIndex; top_mob_index++; kill_table[URANGE(0, pMobIndex->level, MAX_LEVEL-1)].number++; } return; }
/* * Create an instance of an object. */ OBJ_DATA *create_object( OBJ_INDEX_DATA *pObjIndex, int level ) { static OBJ_DATA obj_zero; OBJ_DATA *obj; if ( pObjIndex == NULL ) { bug( "Create_object: NULL pObjIndex.", 0 ); exit( 1 ); } if ( obj_free == NULL ) { obj = alloc_perm( sizeof(*obj) ); } else { obj = obj_free; obj_free = obj_free->next; } *obj = obj_zero; obj->pIndexData = pObjIndex; obj->in_room = NULL; obj->level = level; obj->wear_loc = -1; obj->name = pObjIndex->name; obj->short_descr = pObjIndex->short_descr; obj->description = pObjIndex->description; obj->item_type = pObjIndex->item_type; obj->extra_flags = pObjIndex->extra_flags; obj->wear_flags = pObjIndex->wear_flags; obj->value[0] = pObjIndex->value[0]; obj->value[1] = pObjIndex->value[1]; obj->value[2] = pObjIndex->value[2]; obj->value[3] = pObjIndex->value[3]; obj->weight = pObjIndex->weight; obj->cost = number_fuzzy( 10 ) * number_fuzzy( level ) * number_fuzzy( level ); /* * Mess with object properties. */ switch ( obj->item_type ) { default: bug( "Read_object: vnum %d bad type.", pObjIndex->vnum ); break; case ITEM_LIGHT: case ITEM_TREASURE: case ITEM_FURNITURE: case ITEM_TRASH: case ITEM_CONTAINER: case ITEM_DRINK_CON: case ITEM_KEY: case ITEM_FOOD: case ITEM_BOAT: case ITEM_CORPSE_NPC: case ITEM_CORPSE_PC: case ITEM_FOUNTAIN: break; case ITEM_SCROLL: obj->value[0] = number_fuzzy( obj->value[0] ); break; case ITEM_WAND: case ITEM_STAFF: obj->value[0] = number_fuzzy( obj->value[0] ); obj->value[1] = number_fuzzy( obj->value[1] ); obj->value[2] = obj->value[1]; break; case ITEM_WEAPON: obj->value[1] = number_fuzzy( number_fuzzy( 1 * level / 4 + 2 ) ); obj->value[2] = number_fuzzy( number_fuzzy( 3 * level / 4 + 6 ) ); break; case ITEM_ARMOR: obj->value[0] = number_fuzzy( level / 4 + 2 ); break; case ITEM_POTION: case ITEM_PILL: obj->value[0] = number_fuzzy( number_fuzzy( obj->value[0] ) ); break; case ITEM_MONEY: obj->value[0] = obj->cost; break; } obj->next = object_list; object_list = obj; pObjIndex->count++; return obj; }
/* * Reset one area. */ void reset_area( AREA_DATA *pArea ) { RESET_DATA *pReset; CHAR_DATA *mob; bool last; int level; mob = NULL; last = TRUE; level = 0; for ( pReset = pArea->reset_first; pReset != NULL; pReset = pReset->next ) { ROOM_INDEX_DATA *pRoomIndex; MOB_INDEX_DATA *pMobIndex; OBJ_INDEX_DATA *pObjIndex; OBJ_INDEX_DATA *pObjToIndex; EXIT_DATA *pexit; OBJ_DATA *obj; OBJ_DATA *obj_to; switch ( pReset->command ) { default: bug( "Reset_area: bad command %c.", pReset->command ); break; case 'M': if ( ( pMobIndex = get_mob_index( pReset->arg1 ) ) == NULL ) { bug( "Reset_area: 'M': bad vnum %d.", pReset->arg1 ); continue; } if ( ( pRoomIndex = get_room_index( pReset->arg3 ) ) == NULL ) { bug( "Reset_area: 'R': bad vnum %d.", pReset->arg3 ); continue; } level = URANGE( 0, pMobIndex->level - 2, LEVEL_HERO ); if ( pMobIndex->count >= pReset->arg2 ) { last = FALSE; break; } mob = create_mobile( pMobIndex ); /* * Check for pet shop. */ { ROOM_INDEX_DATA *pRoomIndexPrev; pRoomIndexPrev = get_room_index( pRoomIndex->vnum - 1 ); if ( pRoomIndexPrev != NULL && IS_SET(pRoomIndexPrev->room_flags, ROOM_PET_SHOP) ) SET_BIT(mob->act, ACT_PET); } if ( room_is_dark( pRoomIndex ) ) SET_BIT(mob->affected_by, AFF_INFRARED); char_to_room( mob, pRoomIndex ); level = URANGE( 0, mob->level - 2, LEVEL_HERO ); last = TRUE; break; case 'O': if ( ( pObjIndex = get_obj_index( pReset->arg1 ) ) == NULL ) { bug( "Reset_area: 'O': bad vnum %d.", pReset->arg1 ); continue; } if ( ( pRoomIndex = get_room_index( pReset->arg3 ) ) == NULL ) { bug( "Reset_area: 'R': bad vnum %d.", pReset->arg3 ); continue; } if ( pArea->nplayer > 0 || count_obj_list( pObjIndex, pRoomIndex->contents ) > 0 ) { last = FALSE; break; } obj = create_object( pObjIndex, number_fuzzy( level ) ); obj->cost = 0; obj_to_room( obj, pRoomIndex ); last = TRUE; break; case 'P': if ( ( pObjIndex = get_obj_index( pReset->arg1 ) ) == NULL ) { bug( "Reset_area: 'P': bad vnum %d.", pReset->arg1 ); continue; } if ( ( pObjToIndex = get_obj_index( pReset->arg3 ) ) == NULL ) { bug( "Reset_area: 'P': bad vnum %d.", pReset->arg3 ); continue; } if ( pArea->nplayer > 0 || ( obj_to = get_obj_type( pObjToIndex ) ) == NULL || obj_to->in_room == NULL || count_obj_list( pObjIndex, obj_to->contains ) > 0 ) { last = FALSE; break; } obj = create_object( pObjIndex, number_fuzzy( obj_to->level ) ); obj_to_obj( obj, obj_to ); last = TRUE; break; case 'G': case 'E': if ( ( pObjIndex = get_obj_index( pReset->arg1 ) ) == NULL ) { bug( "Reset_area: 'E' or 'G': bad vnum %d.", pReset->arg1 ); continue; } if ( !last ) break; if ( mob == NULL ) { bug( "Reset_area: 'E' or 'G': null mob for vnum %d.", pReset->arg1 ); last = FALSE; break; } if ( mob->pIndexData->pShop != NULL ) { int olevel; switch ( pObjIndex->item_type ) { default: olevel = 0; break; case ITEM_PILL: olevel = number_range( 0, 10 ); break; case ITEM_POTION: olevel = number_range( 0, 10 ); break; case ITEM_SCROLL: olevel = number_range( 5, 15 ); break; case ITEM_WAND: olevel = number_range( 10, 20 ); break; case ITEM_STAFF: olevel = number_range( 15, 25 ); break; case ITEM_ARMOR: olevel = number_range( 5, 15 ); break; case ITEM_WEAPON: olevel = number_range( 5, 15 ); break; } obj = create_object( pObjIndex, olevel ); SET_BIT( obj->extra_flags, ITEM_INVENTORY ); } else { obj = create_object( pObjIndex, number_fuzzy( level ) ); } obj_to_char( obj, mob ); if ( pReset->command == 'E' ) equip_char( mob, obj, pReset->arg3 ); last = TRUE; break; case 'D': if ( ( pRoomIndex = get_room_index( pReset->arg1 ) ) == NULL ) { bug( "Reset_area: 'D': bad vnum %d.", pReset->arg1 ); continue; } if ( ( pexit = pRoomIndex->exit[pReset->arg2] ) == NULL ) break; switch ( pReset->arg3 ) { case 0: REMOVE_BIT( pexit->exit_info, EX_CLOSED ); REMOVE_BIT( pexit->exit_info, EX_LOCKED ); break; case 1: SET_BIT( pexit->exit_info, EX_CLOSED ); REMOVE_BIT( pexit->exit_info, EX_LOCKED ); break; case 2: SET_BIT( pexit->exit_info, EX_CLOSED ); SET_BIT( pexit->exit_info, EX_LOCKED ); break; } last = TRUE; break; case 'R': if ( ( pRoomIndex = get_room_index( pReset->arg1 ) ) == NULL ) { bug( "Reset_area: 'R': bad vnum %d.", pReset->arg1 ); continue; } { int d0; int d1; for ( d0 = 0; d0 < pReset->arg2 - 1; d0++ ) { d1 = number_range( d0, pReset->arg2-1 ); pexit = pRoomIndex->exit[d0]; pRoomIndex->exit[d0] = pRoomIndex->exit[d1]; pRoomIndex->exit[d1] = pexit; } } break; } } return; }
OBJ_DATA *generate_token(CHAR_DATA *ch) { char buf[MIL]; OBJ_DATA *obj; int i, token; CHAR_DATA *to, *to_next; obj = create_object(get_obj_index(OBJ_VNUM_TOKEN),0); //for randomizing tokens for( i=0; i < MAX_TOKEN; i++) { if(ch->inserted->value[0] < 4 && (chance(7))) //we win an exp token { obj->value[0] = token_lookup("experience"); obj->value[1] = 100; obj->value[2] = number_fuzzy(token_table[obj->value[0]].max_win); obj->value[3] = number_fuzzy(token_table[obj->value[0]].min_win); obj->value[4] = 0; obj->name = str_dup(token_table[obj->value[0]].name); free_string(obj->short_descr); obj->short_descr = str_dup(token_table[obj->value[0]].short_descr); free_string(obj->description); obj->description = str_dup(token_table[obj->value[0]].long_descr); obj_to_char(obj,ch); if(ch->inserted->value[0] < 4) { send_to_one(ch,"WooHoo!!! You won an experience token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to != ch && to->in_room == ch->in_room) { send_to_one(to,"%s just won an experience token.",PERS(ch,to)); } } } else send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name); return obj; } else if(ch->inserted->value[0] != 3 && (chance(20)))//20 percent chance you get a quest token { obj->value[0] = token_lookup("quest"); obj->value[1] = number_range(0,100); obj->value[2] = number_fuzzy(token_table[obj->value[0]].max_win); obj->value[3] = number_fuzzy(token_table[obj->value[0]].min_win); obj->value[4] = 0; obj->name = str_dup(token_table[obj->value[0]].name); free_string(obj->short_descr); obj->short_descr = str_dup(token_table[obj->value[0]].short_descr); free_string(obj->description); obj->description = str_dup(token_table[obj->value[0]].long_descr); obj_to_char(obj,ch); if(ch->inserted->value[0] < 3) { send_to_one(ch,"Hot Damn! You won a quest token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just won a quest token.",PERS(ch,to)); } } } else if( ch->inserted->value[0] > 3) { send_to_one(ch,"Damn you just won back a quest token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just won a quest token.",PERS(ch,to)); } } } else send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name); return obj; } else if(ch->inserted->value[0] != 2 && (chance(25))) //25 percent chance you get a train token { //we win a train token obj->value[0] = token_lookup("train"); obj->value[1] = number_range(0,100); obj->value[2] = number_fuzzy(token_table[obj->value[0]].max_win); obj->value[3] = number_fuzzy(token_table[obj->value[0]].min_win); obj->value[4] = 0; obj->name = str_dup(token_table[obj->value[0]].name); free_string(obj->short_descr); obj->short_descr = str_dup(token_table[obj->value[0]].short_descr); free_string(obj->description); obj->description = str_dup(token_table[obj->value[0]].long_descr); obj_to_char(obj,ch); if(ch->inserted->value[0] < 2) { send_to_one(ch,"Nifty, you won a train token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just won a train token.",PERS(ch,to)); } } } else if( ch->inserted->value[0] > 2) { send_to_one(ch,"Shit you just won back a train token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just won a train token.",PERS(ch,to)); } } } else send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name); return obj; } else if(ch->inserted->value[0] != 1 && (chance(35))) //35 percent chance you get a practice token { //we win a prac token obj->value[0] = token_lookup("practice"); obj->value[1] = number_range(0,100); obj->value[2] = number_fuzzy(token_table[obj->value[0]].max_win); obj->value[3] = number_fuzzy(token_table[obj->value[0]].min_win); obj->value[4] = 0; obj->name = str_dup(token_table[obj->value[0]].name); free_string(obj->short_descr); obj->short_descr = str_dup(token_table[obj->value[0]].short_descr); free_string(obj->description); obj->description = str_dup(token_table[obj->value[0]].long_descr); obj_to_char(obj,ch); if(ch->inserted->value[0] < 1 ) { send_to_one(ch,"You won a practice token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just won a practice token.",PERS(ch,to)); } } } else if (ch->inserted->value[0] > 1) { send_to_one(ch,"Bah, you won back a practice token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just won a practice token.",PERS(ch,to)); } } } else send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name); return obj; } else if(ch->inserted->value[0] !=0 && (chance(15))) { //win back a normal token obj->value[0] = token_lookup("normal"); obj->value[1] = number_range(0,100); obj->value[2] = number_range(250,400); obj->value[3] = number_range(25,249); obj->value[4] = 0; obj->name = str_dup(token_table[obj->value[0]].name); free_string(obj->short_descr); obj->short_descr = str_dup(token_table[obj->value[0]].short_descr); free_string(obj->description); obj->description = str_dup(token_table[obj->value[0]].long_descr); obj_to_char(obj,ch); if(ch->inserted->value[0] > 1) { send_to_one(ch,"You just won back a normal token."); for(to = ch->in_room->people; to; to = to_next) { to_next = to->next_in_room; if(to->in_room == ch->in_room && to != ch) { send_to_one(to,"%s just won a normal token.",PERS(ch,to)); } } } else send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name); return obj; } } return NULL; }
void do_crusade(CHAR_DATA *ch, char *argument) { DESCRIPTOR_DATA* d; CHAR_DATA *questman; CHAR_DATA *boss; char buf [MAX_STRING_LENGTH]; char arg1 [MAX_INPUT_LENGTH]; char arg2 [MAX_INPUT_LENGTH]; argument = one_argument(argument, arg1); argument = one_argument(argument, arg2); if (arg1[0] == '\0') { send_to_char(AT_WHITE, "CRUSADE commands: POINTS INFO TIME REQUEST COMPLETE LIST BUY ADVANCE.\n\r",ch); send_to_char(AT_WHITE, "For more information, type 'HELP CRUSADE'.\n\r",ch); return; } if (!str_cmp(arg1, "time")) { if (IS_SET(ch->act2, PLR_RELQUEST)) { sprintf(buf, "You have %d minutes left on your crusade!\n\r", ch->rcountdown); } else { if (ch->rnextquest > 0) { sprintf(buf, "You have %d minutes left before your next crusade!\n\r", ch->rnextquest); } else { strcpy(buf, "You are free to do a crusade right now!\n\r"); } } send_to_char(AT_WHITE, buf, ch); return; } else if (!str_cmp(arg1, "points")) { sprintf(buf, "You have %d relgion points.\n\r", ch->rquestpoints); send_to_char(AT_WHITE, buf, ch); return; } else if (!str_cmp(arg1, "info")) { OBJ_INDEX_DATA* oinfo; MOB_INDEX_DATA* minfo; if (!IS_SET(ch->act2, PLR_RELQUEST)) { send_to_char(AT_WHITE, "You are not on a crusade!\n\r", ch); return; } if (ch->rquestobj[ch->relquest_level]==0 && ch->rquestmob[ch->relquest_level]==0) { if (ch->in_room->vnum <= REL_VNUM_UPPER && ch->in_room->vnum >= REL_VNUM_LOWER) { send_to_char(AT_WHITE, "You are almost finished your crusade.\n\rFind the portal to the next level!\n\r", ch); return; } else { send_to_char(AT_WHITE, "You are almost finished your crusade!\n\rFind your DEITY and COMPLETE you quest!\n\r",ch); return; } } if (ch->rquestmob[ch->relquest_level]) { if (ch->rquestmob[ch->relquest_level] == -1) { send_to_char(AT_WHITE, "You are almost done your crusade!\n\rFind the boss and ADVANCE!\n\r", ch); return; } else { minfo = get_mob_index( ch->rquestmob[ch->relquest_level] ); sprintf(buf, "You are on a crusade to slay the dreaded %s!\n\r", minfo->short_descr); } } else { oinfo = get_obj_index( ch->rquestobj[ch->relquest_level] ); sprintf(buf, "You are on a crusade to retrieve the fabled %s!\n\r", oinfo->short_descr); } send_to_char(AT_WHITE, buf, ch); return; } for ( questman = ch->in_room->people; questman != NULL; questman = questman->next_in_room) { if (!IS_NPC(questman)) continue; if (IS_SET(questman->act, ACT_IS_DEITY)) break; } for (boss = ch->in_room->people; boss; boss = boss->next_in_room) { if (!IS_NPC(boss)) continue; if (IS_SET(boss->act, ACT_RELBOSS)) break; } if (!str_cmp(arg1, "request")) { int member_count = 0; CHAR_DATA* group[MAX_GROUP]; if (questman==NULL) { send_to_char(AT_WHITE, "Your deity is not here!\n\r", ch); return; } if (IS_SET(ch->act2, PLR_RELQUEST)) { send_to_char(AT_WHITE, "You are already ON a crusade!\n\r",ch); return; } if (relquest) { send_to_char(AT_WHITE, "The gods have already set a crusade to be finished!\n\r",ch); return; } if (ch->master) { send_to_char(AT_WHITE, "Only your group leader can ask for a crusade!\n\r", ch); return; } if (ch->alignment > -500 && ch->alignment < 500) /* || (ch->religion == TIME_AND_FATE */ { send_to_char(AT_WHITE, "You are neutral. You cannot go upon a crusade!\n\r",ch); return; } if (ch->leader) { send_to_char(AT_WHITE, "Only the leader of your group can request a crusade!\n\r", ch); return; } for ( d = descriptor_list; d; d = d->next ) { RELIGION_DATA* rd = NULL; CHAR_DATA* gch = NULL; if ( d->connected != CON_PLAYING ) continue; gch = d->character; if ( !is_same_group(gch , ch ) ) continue; if ( gch->in_room != ch->in_room ) { send_to_char(AT_WHITE, "Your must gather your party before venturing forth!\n\r", ch); return; } if ( gch->rnextquest > 0 ) { sprintf(buf, "%s must wait before doing another crusade!\n\r", gch->name); send_to_char(AT_WHITE, "You must wait before your next Crusade!\n\r", gch); send_to_char(AT_WHITE, buf, ch); return; } if ( gch->level < REL_QUEST_MIN ) { sprintf(buf, "%s is not high enough level to do a Crusade!\n\r", gch->name); send_to_char(AT_WHITE, "You are not high enough level to complete a Crusade!\n\r", gch); send_to_char(AT_WHITE, buf, ch); return; } rd = get_religion_index( ch->religion ); /* Quest Restriction to Deities Out for debug if (!strstr(questman->short_descr, rd->deity ) ) { sprintf(buf, "%s would not appreciate you devoting your crusades to %s!\n\rFind your own Deity!\n\r", rd->deity, questman->short_descr); send_to_char(AT_WHITE, buf, ch); return; } */ group[member_count] = gch; member_count++; if (ch->alignment >= 500) { if (gch->alignment <= -500) /* || gch->religion == EVIL */ { sprintf(buf, "Your deity will not accept %s upon your crusade!\n\r", gch->name); send_to_char(AT_WHITE, buf, ch); return; } } else if (ch->alignment <= -500) { if (gch->alignment >= 500) /* || gch->religion == GOOD */ { sprintf(buf, "Your deity will not accept %s upon your crusade!\n\r", gch->name); send_to_char(AT_WHITE, buf, ch); return; } } } if (member_count < 2) { send_to_char(AT_WHITE, "You need 2 or more heroes for a crusade!\n\r", ch); return; } if (ch->alignment >= 500) { int levels = (((((ch->level > LEVEL_DEMIGOD) ? LEVEL_DEMIGOD : ch->level )) - REL_QUEST_MIN)/(14))+1; if(rel_quest_gen(ch, ALIGN_GOOD, levels)) { int qtime = number_range(15, 45); int curmemb; relquest=TRUE; /* Made it... let's go! */ rel_quest_goals(ch, levels, ALIGN_GOOD); for ( curmemb = 0; curmemb < member_count; curmemb++) { int i; for (i = 0; i < levels; i++) { group[curmemb]->rquestobj[i] = ch->rquestobj[i]; group[curmemb]->rquestmob[i] = ch->rquestmob[i]; } group[curmemb]->relquest_level = 0; group[curmemb]->rcountdown = qtime; SET_BIT(group[curmemb]->act2, PLR_RELQUEST); char_from_room(group[curmemb]); char_to_room (group[curmemb], get_room_index( REL_VNUM_UPPER ) ); send_to_char( AT_WHITE, "The smell of honey and sweet perfume fills your nose!\n\r", group[curmemb]); interpret( group[curmemb], "look" ); interpret( group[curmemb], "crusade info" ); } return; } else { bug("rel_quest_gen: Failed to create quest!",0); } } else if (ch->alignment <= -500) { int levels = (((((ch->level > LEVEL_DEMIGOD) ? LEVEL_DEMIGOD : ch->level )) - REL_QUEST_MIN)/( 14 ))+1; if(rel_quest_gen(ch, ALIGN_EVIL, levels)) { int qtime = number_range(15, 45); int curmemb; relquest=TRUE; /* Made it... let's go! */ rel_quest_goals(ch, levels, ALIGN_EVIL); for ( curmemb=0; curmemb < member_count; curmemb++) { int i; for (i = 0; i < levels; i++) { group[curmemb]->rquestobj[i] = ch->rquestobj[i]; group[curmemb]->rquestmob[i] = ch->rquestmob[i]; } group[curmemb]->relquest_level = 0; group[curmemb]->rcountdown = qtime; SET_BIT(group[curmemb]->act2, PLR_RELQUEST); char_from_room(group[curmemb]); char_to_room (group[curmemb], get_room_index( REL_VNUM_LOWER ) ); send_to_char( AT_RED, "The flames of hell singe your armor!\n\r", group[curmemb]); interpret( group[curmemb], "look" ); interpret( group[curmemb], "crusade info" ); } return; } else { bug("rel_quest_gen: Failed to create quest!",0); } } } else if (!str_cmp(arg1,"complete")) { if (questman==NULL) { send_to_char(AT_WHITE, "Your deity is not here!\n\r", ch); return; } if (IS_SET(ch->act2, PLR_RELQUEST) && ch->rcountdown > 0) { CHAR_DATA* gch = NULL; int qp; qp = number_range( ch->level/4, ch->level/2); if (ch->leader || ch->master) { send_to_char(AT_WHITE, "Only the group leader can complete a crusade!\n\r", ch); return; } for (d=descriptor_list; d; d = d->next) { if ( d->connected != CON_PLAYING ) continue; if (is_same_group(d->character, ch)) { if (d->character->in_room != ch->in_room) { send_to_char(AT_WHITE, "You must gather your party before completing a crusade!\n\r", ch); return; } } } // the whole party is in the room for (gch=ch->in_room->people; gch; gch=gch->next_in_room) { if (is_same_group(ch, gch)) { int gqp = number_fuzzy(qp); sprintf(buf, "You have gained %d religion points for your service!\n\r", gqp); send_to_char(AT_WHITE, "YAY! You completed your crusade!\n\r",gch); gch->rquestpoints += gqp; gch->rnextquest = number_range(10, 30); gch->rcountdown = 0; send_to_char(AT_WHITE, buf, gch); REMOVE_BIT(gch->act2, PLR_RELQUEST); } } relquest=FALSE; return; } else { send_to_char(AT_WHITE, "You are not on a religious crusade!\n\r",ch); return; } } else if(!str_cmp(arg1, "list")) { if (questman==NULL) { send_to_char(AT_WHITE, "Your deity is not here!\n\r", ch); return; } send_to_char(AT_WHITE, "Nothing to list yet.\n\r", ch); return; } else if(!str_cmp(arg1, "buy")) { if (questman==NULL) { send_to_char(AT_WHITE, "Your deity is not here!\n\r", ch); return; } send_to_char(AT_WHITE, "Nothing to buy quite yet.\n\r", ch); return; } else if(!str_cmp(arg1, "advance")) { DESCRIPTOR_DATA* d; if(!IS_SET(ch->act2, PLR_RELQUEST)) { send_to_char(AT_WHITE, "You cannot advance a crusade if you are not on one!\n\r", ch); return; } if(ch->leader || ch->master) { send_to_char(AT_WHITE, "Only the group leader can advance a crusade!\n\r", ch); return; } if (!boss) { send_to_char(AT_WHITE, "You need to find the boss of this level before you can advance!\n\r", ch); return; } if (ch->rquestmob[ch->relquest_level] > 0 && ch->rcountdown > 0) { send_to_char(AT_WHITE, "You have not completed this section of your crusade!\n\r", ch); return; } else if (ch->rquestobj[ch->relquest_level] > 0 && ch->rcountdown > 0) { bool found = FALSE; OBJ_DATA* obj; for (obj = ch->carrying; obj; obj = obj->next) { if (obj->pIndexData->vnum == ch->rquestobj[ch->relquest_level]) { found = TRUE; extract_obj(obj); } } if (!found) { send_to_char(AT_WHITE, "You have not completed this section of your crusade!\n\r", ch); return; } } ch->rquestobj[ch->relquest_level]=0; ch->rquestmob[ch->relquest_level]=0; for (d=descriptor_list; d; d = d->next) { if ( d->connected != CON_PLAYING ) continue; if (is_same_group(d->character, ch)) { d->character->rquestmob[ch->relquest_level] = 0; d->character->rquestobj[ch->relquest_level] = 0; send_to_char(AT_WHITE, "You feel free to pursue the next part of your crusade!\n\r", d->character); } } } else { send_to_char(AT_WHITE, "CRUSADE commands: POINTS INFO TIME REQUEST COMPLETE LIST BUY ADVANCE.\n\r",ch); send_to_char(AT_WHITE, "For more information, type 'HELP CRUSADE'.\n\r",ch); return; } }