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

📄 fight.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 3 页
字号:
    /* fill up the rest of the structure */    Curmonster.m_o_strength = Curmonster.m_strength;    Curmonster.m_o_speed = Curmonster.m_maxspeed = Curmonster.m_speed;    Curmonster.m_o_energy = Curmonster.m_energy;    Curmonster.m_melee = Curmonster.m_skirmish = 0.0;}/**//************************************************************************// FUNCTION NAME: awardtreasure()// FUNCTION: select a treasure// AUTHOR: E. A. Estes, 12/4/85// ARGUMENTS: none// RETURN VALUE: none// MODULES CALLED: pickmonster(), collecttaxes(), more(), cursedtreasure(), /	floor(), wmove(), drandom(), sscanf(), printw(), altercoordinates(), /	longjmp(), infloat(), waddstr(), getanswer(), getstring(), wclrtobot()// GLOBAL INPUTS: Somebetter[], Curmonster, Whichmonster, Circle, Player, /	*stdscr, Databuf[], *Statptr, Fightenv[]// GLOBAL OUTPUTS: Whichmonster, Shield, Player// DESCRIPTION:/	Roll up a treasure based upon monster type and size, and/	certain player statistics./	Handle cursed treasure.//************************************************************************/awardtreasure(){register int	whichtreasure;		/* calculated treasure to grant */int	temp;				/* temporary */int	ch;				/* input */double	treasuretype;			/* monster's treasure type */double	gold = 0.0;			/* gold awarded */double	gems = 0.0;			/* gems awarded */double	dtemp;				/* for temporary calculations */    whichtreasure = (int) ROLL(1.0, 3.0);	/* pick a treasure */    treasuretype = (double) Curmonster.m_treasuretype;    move(4, 0);    clrtobot();    move(6, 0);    if (drandom() > 0.65)	/* gold and gems */	{	if (Curmonster.m_treasuretype > 7)	    /* gems */	    {	    gems = ROLL(1.0, (treasuretype - 7.0)		* (treasuretype - 7.0) * (Circle - 1.0) / 4.0);	    printw("You have discovered %.0f gems!", gems);	    }	else	    /* gold */	    {	    gold = ROLL(treasuretype * 10.0, treasuretype		* treasuretype * 10.0 * (Circle - 1.0));	    printw("You have found %.0f gold pieces.", gold);	    }	addstr("  Do you want to pick them up ? ");	ch = getanswer("NY", FALSE);	addstr("\n\n");	if (ch == 'Y')	    if (drandom() < treasuretype / 35.0 + 0.04)		/* cursed */		{		addstr("They were cursed!\n");		cursedtreasure();		}	    else		collecttaxes(gold, gems);	return;	}    else   	/* other treasures */	{	addstr("You have found some treasure.  Do you want to inspect it ? ");	ch = getanswer("NY", FALSE);	addstr("\n\n");	if (ch != 'Y')	    return;	else	    if (drandom() < 0.08 && Curmonster.m_treasuretype != 4)		{		addstr("It was cursed!\n");		cursedtreasure();		return;		}	    else		switch (Curmonster.m_treasuretype)		    {		    case 1:	/* treasure type 1 */			switch (whichtreasure)			    {			    case 1:				addstr("You've discovered a power booster!\n");				Player.p_mana += ROLL(Circle * 4.0, Circle * 30.0);				break;			    case 2:				addstr("You have encountered a druid.\n");				Player.p_experience +=				    ROLL(0.0, 2000.0 + Circle * 400.0);				break;			    case 3:				addstr("You have found a holy orb.\n");				Player.p_sin = MAX(0.0, Player.p_sin - 0.25);				break;			    }			break;		    /* end treasure type 1 */		    case 2:	/* treasure type 2 */			switch (whichtreasure)			    {			    case 1:				addstr("You have found an amulet.\n");				++Player.p_amulets;				break;			    case 2:				addstr("You've found some holy water!\n");				++Player.p_holywater;				break;			    case 3:				addstr("You've met a hermit!\n");				Player.p_sin *= 0.75;				Player.p_mana += 12.0 * Circle;				break;			    }			break;		    /* end treasure type 2 */		    case 3:	/* treasure type 3 */			switch (whichtreasure)			    {			    case 1:				dtemp = ROLL(7.0, 30.0 + Circle / 10.0);				printw("You've found a +%.0f shield!\n", dtemp);				if (dtemp >= Player.p_shield)				    Player.p_shield = dtemp;				else				    SOMEBETTER();				break;			    case 2:				addstr("You have rescued a virgin.  Will you be honorable ? ");				ch = getanswer("NY", FALSE);				addstr("\n\n");				if (ch == 'Y')				    Player.p_virgin = TRUE;				else				    {				    Player.p_experience += 2000.0 * Circle;				    ++Player.p_sin;				    }				break;			    case 3:				addstr("You've discovered some athelas!\n");				--Player.p_poison;				break;			    }			break;		    /* end treasure type 3 */		    case 4:	/* treasure type 4 */			addstr("You've found a scroll.  Will you read it ? ");			ch = getanswer("NY", FALSE);			addstr("\n\n");			if (ch == 'Y')			    switch ((int) ROLL(1, 6))				{				case 1:				    addstr("It throws up a shield for you next monster.\n");				    getyx(stdscr, whichtreasure, ch);				    more(whichtreasure);				    Shield =					(Player.p_maxenergy + Player.p_energy) * 5.5 + Circle * 50.0;				    Whichmonster = pickmonster();				    longjmp(Fightenv, 0);				    /*NOTREACHED*/				case 2:				    addstr("It makes you invisible for you next monster.\n");				    getyx(stdscr, whichtreasure, ch);				    more(whichtreasure);				    Player.p_speed = 1e6;				    Whichmonster = pickmonster();				    longjmp(Fightenv, 0);				    /*NOTREACHED*/				case 3:				    addstr("It increases your strength ten fold to fight your next monster.\n");				    getyx(stdscr, whichtreasure, ch);				    more(whichtreasure);				    Player.p_might *= 10.0;				    Whichmonster = pickmonster();				    longjmp(Fightenv, 0);				    /*NOTREACHED*/				case 4:				    addstr("It is a general knowledge scroll.\n");				    Player.p_brains += ROLL(2.0, Circle);				    Player.p_magiclvl += ROLL(1.0, Circle / 2.0);				    break;				case 5:				    addstr("It tells you how to pick your next monster.\n");				    addstr("Which monster do you want [0-99] ? ");				    Whichmonster = (int) infloat();				    Whichmonster = MIN(99, MAX(0, Whichmonster));				    longjmp(Fightenv, 0);				case 6:				    addstr("It was cursed!\n");				    cursedtreasure();				    break;				}			    break;		    /* end treasure type 4 */		    case 5:	/* treasure type 5 */			switch (whichtreasure)			    {			    case 1:				dtemp = ROLL(Circle / 4.0 + 5.0, Circle / 2.0 + 9.0);				printw("You've discovered a +%.0f dagger.\n", dtemp);				if (dtemp >= Player.p_sword)				    Player.p_sword = dtemp;				else				    SOMEBETTER();				break;			    case 2:				dtemp = ROLL(7.5 + Circle * 3.0, Circle * 2.0 + 160.0);				printw("You have found some +%.0f armour!\n", dtemp);				if (dtemp >= Player.p_shield)				    Player.p_shield = dtemp;				else				    SOMEBETTER();				break;			    case 3:				addstr("You've found a tablet.\n");				Player.p_brains += 4.5 * Circle;				break;			    }			break;		    /* end treasure type 5 */		    case 6:	/* treasure type 6 */			switch (whichtreasure)			    {			    case 1:				addstr("You've found a priest.\n");				Player.p_energy = Player.p_maxenergy + Player.p_shield;				Player.p_sin /= 2.0;				Player.p_mana += 24.0 * Circle;				Player.p_brains += Circle;				break;			    case 2:				addstr("You have come upon Robin Hood!\n");				Player.p_shield += Circle * 2.0;				Player.p_strength += Circle / 2.5 + 1.0;				break;			    case 3:				dtemp = ROLL(2.0 + Circle / 4.0, Circle / 1.2 + 10.0);				printw("You have found a +%.0f axe!\n", dtemp);				if (dtemp >= Player.p_sword)				    Player.p_sword = dtemp;				else				    SOMEBETTER();				break;			    }			break;		    /* end treasure type 6 */		    case 7:	/* treasure type 7 */			switch (whichtreasure)			    {			    case 1:				addstr("You've discovered a charm!\n");				++Player.p_charms;				break;			    case 2:				addstr("You have encountered Merlyn!\n");				Player.p_brains += Circle + 5.0;				Player.p_magiclvl += Circle / 3.0 + 5.0;				Player.p_mana += Circle * 10.0;				break;			    case 3:				dtemp = ROLL(5.0 + Circle / 3.0, Circle / 1.5 + 20.0);				printw("You have found a +%.0f war hammer!\n", dtemp);				if (dtemp >= Player.p_sword)				    Player.p_sword = dtemp;				else				    SOMEBETTER();				break;			    }			break;		    /* end treasure type 7 */		    case 8:	/* treasure type 8 */			switch (whichtreasure)			    {			    case 1:				addstr("You have found a healing potion.\n");				Player.p_poison = MIN(-2.0, Player.p_poison - 2.0);				break;			    case 2:				addstr("You have discovered a transporter.  Do you wish to go anywhere ? ");				ch = getanswer("NY", FALSE);				addstr("\n\n");				if (ch == 'Y')				    {				    double x, y;				    addstr("X Y Coordinates ? ");				    getstring(Databuf, SZ_DATABUF);				    sscanf(Databuf, "%lf %lf", &x, &y);				    altercoordinates(x, y, A_FORCED);				    }				break;			    case 3:				dtemp = ROLL(10.0 + Circle / 1.2, Circle * 3.0 + 30.0);				printw("You've found a +%.0f sword!\n", dtemp);				if (dtemp >= Player.p_sword)				    Player.p_sword = dtemp;				else				    SOMEBETTER();				break;			    }			break;		    /* end treasure type 8 */		    case 10:		    case 11:		    case 12:		    case 13:	/* treasure types 10 - 13 */			if (drandom() < 0.33)			    {			    if (Curmonster.m_treasuretype == 10)				{				addstr("You've found a pair of elven boots!\n");				Player.p_quickness += 2.0;				break;				}			    else if (Curmonster.m_treasuretype == 11				&& !Player.p_palantir)				{				addstr("You've acquired Saruman's palantir.\n");				Player.p_palantir = TRUE;				break;				}			    else if (Player.p_ring.ring_type == R_NONE				&& Player.p_specialtype < SC_COUNCIL				&& (Curmonster.m_treasuretype == 12				|| Curmonster.m_treasuretype == 13))				/* roll up a ring */				{				if (drandom() < 0.8)				    /* regular rings */				    {				    if (Curmonster.m_treasuretype == 12)					{					whichtreasure = R_NAZREG;					temp = 35;					}				    else					{					whichtreasure = R_DLREG;					temp = 0;					}				    }				else				    /* bad rings */				    {				    whichtreasure = R_BAD;				    temp = 15 + Statptr->c_ringduration + (int) ROLL(0,5);				    }				addstr("You've discovered a ring.  Will you pick it up ? ");				ch = getanswer("NY", FALSE);				addstr("\n\n");				if (ch == 'Y')				    {				    Player.p_ring.ring_type = whichtreasure;				    Player.p_ring.ring_duration = temp;				    }				break;				}			    }			/* end treasure types 10 - 13 */			/* fall through to treasure type 9 if no treasure from above */			case 9:	/* treasure type 9 */			    switch (whichtreasure)				{				case 1:				    if (Player.p_level <= 1000.0					&& Player.p_crowns <= 3					&& Player.p_level >= 10.0)					{					addstr("You have found a golden crown!\n");					++Player.p_crowns;					break;					}				    /* fall through otherwise */				case 2:				    addstr("You've been blessed!\n");				    Player.p_blessing = TRUE;				    Player.p_sin /= 3.0;				    Player.p_energy = Player.p_maxenergy + Player.p_shield;				    Player.p_mana += 100.0 * Circle;				    break;				case 3:				    dtemp = ROLL(1.0, Circle / 5.0 + 5.0);				    dtemp = MIN(dtemp, 99.0);				    printw("You have discovered some +%.0f quicksilver!\n",dtemp);				    if (dtemp >= Player.p_quksilver)					Player.p_quksilver = dtemp;				    else					SOMEBETTER();				    break;				}			    break;		    /* end treasure type 9 */		    }	}}/**//************************************************************************// FUNCTION NAME: cursedtreasure()// FUNCTION: take care of cursed treasure// AUTHOR: E. A. Estes, 12/4/85// ARGUMENTS: none// RETURN VALUE: none// MODULES CALLED: waddstr()// GLOBAL INPUTS: Player, *stdscr// GLOBAL OUTPUTS: Player// DESCRIPTION:/	Handle cursed treasure.  Look for amulets and charms to save/	the player from the curse.//************************************************************************/cursedtreasure(){    if (Player.p_charms > 0)	{	addstr("But your charm saved you!\n");	--Player.p_charms;	}    else if (Player.p_amulets > 0)	{	addstr("But your amulet saved you!\n");	--Player.p_amulets;	}    else	{	Player.p_energy = (Player.p_maxenergy + Player.p_shield) / 10.0;	Player.p_poison += 0.25;	}}/**//************************************************************************// FUNCTION NAME: scramblestats()// FUNCTION: scramble some selected statistics// AUTHOR: E. A. Estes, 12/4/85// ARGUMENTS: none// RETURN VALUE: none// MODULES CALLED: floor(), drandom()// GLOBAL INPUTS: Player// GLOBAL OUTPUTS: Player// DESCRIPTION:/	Swap a few player statistics randomly.//************************************************************************/scramblestats(){double	dbuf[6];		/* to put statistic in */double	dtemp1, dtemp2;		/* for swapping values */register int	first, second;	/* indices for swapping */register double  *dptr;		/* pointer for filling and emptying buf[] */    /* fill buffer */    dptr = &dbuf[0];    *dptr++ = Player.p_strength;    *dptr++ = Player.p_mana;    *dptr++ = Player.p_brains;    *dptr++ = Player.p_magiclvl;    *dptr++ = Player.p_energy;    *dptr = Player.p_sin;    /* pick values to swap */    first = (int) ROLL(0, 5);    second = (int) ROLL(0, 5);    /* swap values */    dptr = &dbuf[0];    dtemp1 = dptr[first];    /* this expression is split to prevent a compiler loop on some compilers */    dtemp2 = dptr[second];    dptr[first] = dtemp2;    dptr[second] = dtemp1;    /* empty buffer */    Player.p_strength = *dptr++;    Player.p_mana = *dptr++;    Player.p_brains = *dptr++;    Player.p_magiclvl = *dptr++;    Player.p_energy = *dptr++;    Player.p_sin = *dptr;}

⌨️ 快捷键说明

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