⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 object.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * object.c * * This source herein may be modified and/or distributed by anybody who * so desires, with the following restrictions: *    1.)  No portion of this notice shall be removed. *    2.)  Credit shall not be taken for the creation of this source. *    3.)  This code is not to be traded, sold, or used for personal *         gain or profit. * */#ifndef lintstatic char sccsid[] = "@(#)object.c	5.1 (Berkeley) 11/25/87";#endif /* not lint */#include "rogue.h"object level_objects;unsigned short dungeon[DROWS][DCOLS];short foods = 0;object *free_list = (object *) 0;char *fruit = (char *) 0;fighter rogue = {	INIT_AW,	/* armor, weapon */	INIT_RINGS,	/* rings */	INIT_HP,	/* Hp current,max */	INIT_STR,	/* Str current,max */	INIT_PACK,	/* pack */	INIT_GOLD,	/* gold */	INIT_EXP,	/* exp level,points */	0, 0,		/* row, col */	INIT_CHAR,	/* char */	INIT_MOVES	/* moves */};struct id id_potions[POTIONS] = {{100, "blue \0                           ", "of increase strength ", 0},{250, "red \0                            ", "of restore strength ", 0},{100, "green \0                          ", "of healing ", 0},{200, "grey \0                           ", "of extra healing ", 0}, {10, "brown \0                          ", "of poison ", 0},{300, "clear \0                          ", "of raise level ", 0}, {10, "pink \0                           ", "of blindness ", 0}, {25, "white \0                          ", "of hallucination ", 0},{100, "purple \0                         ", "of detect monster ", 0},{100, "black \0                          ", "of detect things ", 0}, {10, "yellow \0                         ", "of confusion ", 0}, {80, "plaid \0                          ", "of levitation ", 0},{150, "burgundy \0                       ", "of haste self ", 0},{145, "beige \0                          ", "of see invisible ", 0}};struct id id_scrolls[SCROLS] = {{505, "                                   ", "of protect armor ", 0},{200, "                                   ", "of hold monster ", 0},{235, "                                   ", "of enchant weapon ", 0},{235, "                                   ", "of enchant armor ", 0},{175, "                                   ", "of identify ", 0},{190, "                                   ", "of teleportation ", 0}, {25, "                                   ", "of sleep ", 0},{610, "                                   ", "of scare monster ", 0},{210, "                                   ", "of remove curse ", 0}, {80, "                                   ", "of create monster ",0}, {25, "                                   ", "of aggravate monster ",0},{180, "                                   ", "of magic mapping ", 0}, {90, "                                   ", "of confuse monster ", 0}};struct id id_weapons[WEAPONS] = {	{150, "short bow ", "", 0},	  {8, "darts ", "", 0},	 {15, "arrows ", "", 0},	 {27, "daggers ", "", 0},	 {35, "shurikens ", "", 0},	{360, "mace ", "", 0},	{470, "long sword ", "", 0},	{580, "two-handed sword ", "", 0}};struct id id_armors[ARMORS] = {	{300, "leather armor ", "", (UNIDENTIFIED)},	{300, "ring mail ", "", (UNIDENTIFIED)},	{400, "scale mail ", "", (UNIDENTIFIED)},	{500, "chain mail ", "", (UNIDENTIFIED)},	{600, "banded mail ", "", (UNIDENTIFIED)},	{600, "splint mail ", "", (UNIDENTIFIED)},	{700, "plate mail ", "", (UNIDENTIFIED)}};struct id id_wands[WANDS] = {	 {25, "                                 ", "of teleport away ",0},	 {50, "                                 ", "of slow monster ", 0},	  {8, "                                 ", "of invisibility ",0},	 {55, "                                 ", "of polymorph ",0},	  {2, "                                 ", "of haste monster ",0},	 {20, "                                 ", "of magic missile ",0},	 {20, "                                 ", "of cancellation ",0},	  {0, "                                 ", "of do nothing ",0},	 {35, "                                 ", "of drain life ",0},	 {20, "                                 ", "of cold ",0},	 {20, "                                 ", "of fire ",0}};struct id id_rings[RINGS] = {	 {250, "                                 ", "of stealth ",0},	 {100, "                                 ", "of teleportation ", 0},	 {255, "                                 ", "of regeneration ",0},	 {295, "                                 ", "of slow digestion ",0},	 {200, "                                 ", "of add strength ",0},	 {250, "                                 ", "of sustain strength ",0},	 {250, "                                 ", "of dexterity ",0},	  {25, "                                 ", "of adornment ",0},	 {300, "                                 ", "of see invisible ",0},	 {290, "                                 ", "of maintain armor ",0},	 {270, "                                 ", "of searching ",0},};extern short cur_level, max_level;extern short party_room;extern char *error_file;extern boolean is_wood[];put_objects(){	short i, n;	object *obj;	if (cur_level < max_level) {		return;	}	n = coin_toss() ? get_rand(2, 4) : get_rand(3, 5);	while (rand_percent(33)) {		n++;	}	if (party_room != NO_ROOM) {		make_party();	}	for (i = 0; i < n; i++) {		obj = gr_object();		rand_place(obj);	}	put_gold();}put_gold(){	short i, j;	short row,col;	boolean is_maze, is_room;	for (i = 0; i < MAXROOMS; i++) {		is_maze = (rooms[i].is_room & R_MAZE) ? 1 : 0;		is_room = (rooms[i].is_room & R_ROOM) ? 1 : 0;		if (!(is_room || is_maze)) {			continue;		}		if (is_maze || rand_percent(GOLD_PERCENT)) {			for (j = 0; j < 50; j++) {				row = get_rand(rooms[i].top_row+1,				rooms[i].bottom_row-1);				col = get_rand(rooms[i].left_col+1,				rooms[i].right_col-1);				if ((dungeon[row][col] == FLOOR) ||					(dungeon[row][col] == TUNNEL)) {					plant_gold(row, col, is_maze);					break;				}			}		}	}}plant_gold(row, col, is_maze)short row, col;boolean is_maze;{	object *obj;	obj = alloc_object();	obj->row = row; obj->col = col;	obj->what_is = GOLD;	obj->quantity = get_rand((2 * cur_level), (16 * cur_level));	if (is_maze) {		obj->quantity += obj->quantity / 2;	}	dungeon[row][col] |= OBJECT;	(void) add_to_pack(obj, &level_objects, 0);}place_at(obj, row, col)object *obj;{	obj->row = row;	obj->col = col;	dungeon[row][col] |= OBJECT;	(void) add_to_pack(obj, &level_objects, 0);}object *object_at(pack, row, col)register object *pack;short row, col;{	object *obj = (object *) 0;	if (dungeon[row][col] & (MONSTER | OBJECT)) {		obj = pack->next_object;		while (obj && ((obj->row != row) || (obj->col != col))) {			obj = obj->next_object;		}		if (!obj) {			message("object_at(): inconsistent", 1);		}	}	return(obj);}object *get_letter_object(ch){	object *obj;	obj = rogue.pack.next_object;	while (obj && (obj->ichar != ch)) {		obj = obj->next_object;	}	return(obj);}free_stuff(objlist)object *objlist;{	object *obj;	while (objlist->next_object) {		obj = objlist->next_object;		objlist->next_object =			objlist->next_object->next_object;		free_object(obj);	}}char *name_of(obj)object *obj;{	char *retstring;	switch(obj->what_is) {	case SCROL:		retstring = obj->quantity > 1 ? "scrolls " : "scroll ";		break;	case POTION:		retstring = obj->quantity > 1 ? "potions " : "potion ";		break;	case FOOD:		if (obj->which_kind == RATION) {			retstring = "food ";		} else {			retstring = fruit;		}		break;	case WAND:		retstring = is_wood[obj->which_kind] ? "staff " : "wand ";		break;	case WEAPON:		switch(obj->which_kind) {		case DART:			retstring=obj->quantity > 1 ? "darts " : "dart ";			break;		case ARROW:			retstring=obj->quantity > 1 ? "arrows " : "arrow ";			break;		case DAGGER:			retstring=obj->quantity > 1 ? "daggers " : "dagger ";			break;		case SHURIKEN:			retstring=obj->quantity > 1?"shurikens ":"shuriken ";			break;		default:			retstring = id_weapons[obj->which_kind].title;		}		break;	case ARMOR:		retstring = "armor ";		break;	case RING:			retstring = "ring ";		break;	case AMULET:		retstring = "amulet ";		break;	default:		retstring = "unknown ";		break;	}	return(retstring);}object *gr_object(){	object *obj;	obj = alloc_object();	if (foods < (cur_level / 3)) {		obj->what_is = FOOD;		foods++;	} else {		obj->what_is = gr_what_is();	}	switch(obj->what_is) {	case SCROL:		gr_scroll(obj);		break;	case POTION:		gr_potion(obj);		break;	case WEAPON:		gr_weapon(obj, 1);		break;	case ARMOR:		gr_armor(obj);		break;	case WAND:		gr_wand(obj);		break;	case FOOD:		get_food(obj, 0);		break;	case RING:		gr_ring(obj, 1);		break;	}	return(obj);}unsigned shortgr_what_is(){	short percent;	unsigned short what_is;	percent = get_rand(1, 91);	if (percent <= 30) {		what_is = SCROL;	} else if (percent <= 60) {		what_is = POTION;	} else if (percent <= 64) {		what_is = WAND;	} else if (percent <= 74) {		what_is = WEAPON;	} else if (percent <= 83) {		what_is = ARMOR;	} else if (percent <= 88) {		what_is = FOOD;	} else {		what_is = RING;	}	return(what_is);}gr_scroll(obj)object *obj;{	short percent;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -