Exemple #1
0
void weather_change(void)
{
	int diff = 0, sky_change, temp_change, i,
			   grainlevel = 0, gsnowlevel = 0, icelevel = 0, snowdec = 0,
											raincast = 0, snowcast = 0, avg_day_temp, avg_week_temp, cweather_type = 0, temp;

	weather_info.hours_go++;
	if (weather_info.hours_go > HOURS_PER_DAY)
	{
		weather_info.press_last_day = weather_info.press_last_day * (HOURS_PER_DAY - 1) / HOURS_PER_DAY;
		weather_info.temp_last_day = weather_info.temp_last_day * (HOURS_PER_DAY - 1) / HOURS_PER_DAY;
	}
	// Average pressure and temperature per 24 hours
	weather_info.press_last_day += weather_info.pressure;
	weather_info.temp_last_day += weather_info.temperature;
	if (weather_info.hours_go > (DAYS_PER_WEEK * HOURS_PER_DAY))
	{
		weather_info.press_last_week =
			weather_info.press_last_week * (DAYS_PER_WEEK * HOURS_PER_DAY -
											1) / (DAYS_PER_WEEK * HOURS_PER_DAY);
		weather_info.temp_last_week =
			weather_info.temp_last_week * (DAYS_PER_WEEK * HOURS_PER_DAY - 1) / (DAYS_PER_WEEK * HOURS_PER_DAY);
	}
	// Average pressure and temperature per week
	weather_info.press_last_week += weather_info.pressure;
	weather_info.temp_last_week += weather_info.temperature;
	avg_day_temp = average_day_temp();
	avg_week_temp = average_week_temp();

	calc_basic(weather_info.weather_type, weather_info.sky, &grainlevel, &gsnowlevel);

	// Ice and show change by temperature
	if (!(time_info.hours % 6) && weather_info.hours_go)
	{
		if (avg_day_temp < -15)
			icelevel += 4;
		else if (avg_day_temp < -10)
			icelevel += 3;
		else if (avg_day_temp < -5)
			icelevel += 2;
		else if (avg_day_temp < -1)
			icelevel += 1;
		else if (avg_day_temp < 1)
		{
			icelevel += 0;
			gsnowlevel -= 1;
			snowdec += 1;
		}
		else if (avg_day_temp < 5)
		{
			icelevel -= 1;
			gsnowlevel -= 2;
			snowdec += 2;
		}
		else if (avg_day_temp < 10)
		{
			icelevel -= 2;
			gsnowlevel -= 3;
			snowdec += 3;
		}
		else
		{
			icelevel -= 3;
			gsnowlevel -= 4;
			snowdec += 4;
		}
	}

	weather_info.icelevel = MAX(0, MIN(100, weather_info.icelevel + icelevel));
	if (gsnowlevel < -1 && weather_info.rainlevel < 20)
		weather_info.rainlevel -= (gsnowlevel / 2);
	weather_info.snowlevel = MAX(0, MIN(120, weather_info.snowlevel + gsnowlevel));
	weather_info.rainlevel = MAX(0, MIN(80, weather_info.rainlevel + grainlevel));


	// Change some values for world
	for (i = FIRST_ROOM; i <= top_of_world; i++)
	{
		raincast = snowcast = 0;
		if (ROOM_FLAGGED(i, ROOM_NOWEATHER))
			continue;
		if (world[i]->weather.duration)
		{
			calc_basic(world[i]->weather.weather_type, world[i]->weather.sky, &raincast, &snowcast);
			snowcast -= snowdec;
		}
		else
		{
			raincast = grainlevel;
			snowcast = gsnowlevel;
		}
		if (world[i]->weather.duration <= 0)
			world[i]->weather.duration = 0;
		else
			world[i]->weather.duration--;

		world[i]->weather.icelevel = MAX(0, MIN(100, world[i]->weather.icelevel + icelevel));
		if (snowcast < -1 && world[i]->weather.rainlevel < 20)
			world[i]->weather.rainlevel -= (snowcast / 2);
		world[i]->weather.snowlevel = MAX(0, MIN(120, world[i]->weather.snowlevel + snowcast));
		world[i]->weather.rainlevel = MAX(0, MIN(80, world[i]->weather.rainlevel + raincast));
	}


	switch (time_info.month)
	{
	case 0:		// Jan
		diff = (weather_info.pressure > 985 ? -2 : 2);
		break;
	case 1:		// Feb
		diff = (weather_info.pressure > 985 ? -2 : 2);
		break;
	case 2:		// Mar
		diff = (weather_info.pressure > 985 ? -2 : 2);
		break;
	case 3:		// Apr
		diff = (weather_info.pressure > 985 ? -2 : 2);
		break;
	case 4:		// May
		diff = (weather_info.pressure > 1015 ? -2 : 2);
		break;
	case 5:		// Jun
		diff = (weather_info.pressure > 1015 ? -2 : 2);
		break;
	case 6:		// Jul
		diff = (weather_info.pressure > 1015 ? -2 : 2);
		break;
	case 7:		// Aug
		diff = (weather_info.pressure > 1015 ? -2 : 2);
		break;
	case 8:		// Sep
		diff = (weather_info.pressure > 1015 ? -2 : 2);
		break;
	case 9:		// Oct
		diff = (weather_info.pressure > 1015 ? -2 : 2);
		break;
	case 10:		// Nov
		diff = (weather_info.pressure > 985 ? -2 : 2);
		break;
	case 11:		// Dec
		diff = (weather_info.pressure > 985 ? -2 : 2);
		break;
	default:
		break;
	}

	// if ((time_info.month >= 9) && (time_info.month <= 16))
	//    diff = (weather_info.pressure > 985 ? -2 : 2);
	// else
	//    diff = (weather_info.pressure > 1015 ? -2 : 2);

	weather_info.change += (dice(1, 4) * diff + dice(2, 6) - dice(2, 6));

	weather_info.change = MIN(weather_info.change, 12);
	weather_info.change = MAX(weather_info.change, -12);

	weather_info.pressure += weather_info.change;

	weather_info.pressure = MIN(weather_info.pressure, 1040);
	weather_info.pressure = MAX(weather_info.pressure, 960);

	if (time_info.month == MONTH_MAY)
		weather_info.season = SEASON_SPRING;
	else if (time_info.month >= MONTH_JUNE && time_info.month <= MONTH_AUGUST)
		weather_info.season = SEASON_SUMMER;
	else if (time_info.month >= MONTH_SEPTEMBER && time_info.month <= MONTH_OCTOBER)
		weather_info.season = SEASON_AUTUMN;
	else if (time_info.month >= MONTH_DECEMBER || time_info.month <= MONTH_FEBRUARY)
		weather_info.season = SEASON_WINTER;


	switch (weather_info.season)
	{
	case SEASON_WINTER:
		if ((time_info.month == MONTH_MART && avg_week_temp > 5
				&& weather_info.snowlevel == 0) || (time_info.month == MONTH_APRIL && weather_info.snowlevel == 0))
			weather_info.season = SEASON_SPRING;
	case SEASON_AUTUMN:
		if (time_info.month == MONTH_NOVEMBER && (avg_week_temp < 2 || weather_info.snowlevel >= 5))
			weather_info.season = SEASON_WINTER;
	}

	sky_change = 0;
	temp_change = 0;

	switch (weather_info.sky)
	{
	case SKY_CLOUDLESS:
		if (weather_info.pressure < 990)
			sky_change = 1;
		else if (weather_info.pressure < 1010)
			if (dice(1, 4) == 1)
				sky_change = 1;
		break;
	case SKY_CLOUDY:
		if (weather_info.pressure < 970)
			sky_change = 2;
		else if (weather_info.pressure < 990)
		{
			if (dice(1, 4) == 1)
				sky_change = 2;
			else
				sky_change = 0;
		}
		else if (weather_info.pressure > 1030)
			if (dice(1, 4) == 1)
				sky_change = 3;

		break;
	case SKY_RAINING:
		if (weather_info.pressure < 970)
		{
			if (dice(1, 4) == 1)
				sky_change = 4;
			else
				sky_change = 0;
		}
		else if (weather_info.pressure > 1030)
			sky_change = 5;
		else if (weather_info.pressure > 1010)
			if (dice(1, 4) == 1)
				sky_change = 5;

		break;
	case SKY_LIGHTNING:
		if (weather_info.pressure > 1010)
			sky_change = 6;
		else if (weather_info.pressure > 990)
			if (dice(1, 4) == 1)
				sky_change = 6;

		break;
	default:
		sky_change = 0;
		weather_info.sky = SKY_CLOUDLESS;
		break;
	}

	switch (sky_change)
	{
	case 1:		// CLOUDLESS -> CLOUDY
		if (time_info.month >= MONTH_MAY && time_info.month <= MONTH_AUGUST)
		{
			if (time_info.hours >= 8 && time_info.hours <= 16)
				temp_change += number(-3, -1);
			else if (time_info.hours >= 5 && time_info.hours <= 20)
				temp_change += number(-1, 0);

		}
		else
			temp_change += number(-2, + 2);
		break;
	case 2:		// CLOUDY -> RAINING
		if (time_info.month >= MONTH_MAY && time_info.month <= MONTH_AUGUST)
			temp_change += number(-1, + 1);
		else
			temp_change += number(-2, + 2);
		break;
	case 3:		// CLOUDY -> CLOUDLESS
		if (time_info.month >= MONTH_MAY && time_info.month <= MONTH_AUGUST)
		{
			if (time_info.hours >= 7 && time_info.hours <= 19)
				temp_change += number( + 1, + 2);
			else
				temp_change += number(0, + 1);
		}
		else
			temp_change += number(-1, + 1);
		break;
	case 4:		// RAINING -> LIGHTNING
		if (time_info.month >= MONTH_MAY && time_info.month <= MONTH_AUGUST)
		{
			if (time_info.hours >= 10 && time_info.hours <= 18)
				temp_change += number( + 1, + 3);
			else
				temp_change += number(0, + 2);
		}
		else
			temp_change += number(-3, + 3);
		break;
	case 5:		// RAINING -> CLOUDY
		if (time_info.month >= MONTH_JUNE && time_info.month <= MONTH_AUGUST)
			temp_change += number(0, + 1);
		else
			temp_change += number(-1, + 1);
		break;
	case 6:		// LIGHTNING -> RAINING
		if (time_info.month >= MONTH_MAY && time_info.month <= MONTH_AUGUST)
		{
			if (time_info.hours >= 10 && time_info.hours <= 17)
				temp_change += number(-3, + 1);
			else
				temp_change += number(-1, + 2);
		}
		else
			temp_change += number( + 1, + 3);
		break;
	case 0:
	default:
		if (dice(1, 4) == 1)
			temp_change += number(-1, + 1);
		break;
	}

	temp_change += day_temp_change[time_info.hours][weather_info.sky];
	if (time_info.day >= 22)
	{
		temp = weather_info.temperature +
			   (time_info.month >= MONTH_DECEMBER ? year_temp[0].med : year_temp[time_info.month + 1].med);
		temp /= 2;
	}
	else if (time_info.day <= 8)
	{
		temp = weather_info.temperature + year_temp[time_info.month].med;
		temp /= 2;
	}
	else
		temp = weather_info.temperature;

	temp += temp_change;
	cweather_type = 0;
	*buf = '\0';
	if (weather_info.temperature - temp > 6)
	{
		strcat(buf, "Резкое похолодание.\r\n");
		SET_BIT(cweather_type, WEATHER_QUICKCOOL);
	}
	else if (weather_info.temperature - temp < -6)
	{
		strcat(buf, "Резкое потепление.\r\n");
		SET_BIT(cweather_type, WEATHER_QUICKHOT);
	}
	weather_info.temperature = MIN(year_temp[time_info.month].max, MAX(year_temp[time_info.month].min, temp));


	if (weather_info.change >= 10 || weather_info.change <= -10)
	{
		strcat(buf, "Сильный ветер.\r\n");
		SET_BIT(cweather_type, WEATHER_BIGWIND);
	}
	else if (weather_info.change >= 6 || weather_info.change <= -6)
	{
		strcat(buf, "Умеренный ветер.\r\n");
		SET_BIT(cweather_type, WEATHER_MEDIUMWIND);
	}
	else if (weather_info.change >= 2 || weather_info.change <= -2)
	{
		strcat(buf, "Слабый ветер.\r\n");
		SET_BIT(cweather_type, WEATHER_LIGHTWIND);
	}
	else if (IS_SET(weather_info.weather_type, WEATHER_BIGWIND | WEATHER_MEDIUMWIND | WEATHER_LIGHTWIND))
	{
		strcat(buf, "Ветер утих.\r\n");
		if (IS_SET(weather_info.weather_type, WEATHER_BIGWIND))
			SET_BIT(cweather_type, WEATHER_MEDIUMWIND);
		else if (IS_SET(weather_info.weather_type, WEATHER_MEDIUMWIND))
			SET_BIT(cweather_type, WEATHER_LIGHTWIND);
	}

	switch (sky_change)
	{
	case 1:		// CLOUDLESS -> CLOUDY
		strcat(buf, "Небо затянуло тучами.\r\n");
		weather_info.sky = SKY_CLOUDY;
		break;
	case 2:		// CLOUDY -> RAINING
		switch (time_info.month)
		{
		case MONTH_MAY:
		case MONTH_JUNE:
		case MONTH_JULY:
		case MONTH_AUGUST:
		case MONTH_SEPTEMBER:
			strcat(buf, "Начался дождь.\r\n");
			create_rainsnow(&cweather_type, WEATHER_LIGHTRAIN, 30, 40, 30);
			break;
		case MONTH_DECEMBER:
		case MONTH_JANUARY:
		case MONTH_FEBRUARY:
			strcat(buf, "Пошел снег.\r\n");
			create_rainsnow(&cweather_type, WEATHER_LIGHTSNOW, 30, 40, 30);
			break;
		case MONTH_OCTOBER:
		case MONTH_APRIL:
			if (IS_SET(cweather_type, WEATHER_QUICKCOOL)
					&& weather_info.temperature <= 5)
			{
				strcat(buf, "Пошел снег.\r\n");
				SET_BIT(cweather_type, WEATHER_LIGHTSNOW);
			}
			else
			{
				strcat(buf, "Начался дождь.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTRAIN, 40, 60, 0);
			}
			break;
		case MONTH_NOVEMBER:
			if (avg_day_temp <= 3 || IS_SET(cweather_type, WEATHER_QUICKCOOL))
			{
				strcat(buf, "Пошел снег.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTSNOW, 40, 60, 0);
			}
			else
			{
				strcat(buf, "Начался дождь.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTRAIN, 40, 60, 0);
			}
			break;
		case MONTH_MART:
			if (avg_day_temp >= 3 || IS_SET(cweather_type, WEATHER_QUICKHOT))
			{
				strcat(buf, "Начался дождь.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTRAIN, 80, 20, 0);
			}
			else
			{
				strcat(buf, "Пошел снег.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTSNOW, 60, 30, 10);
			}
			break;
		}
		weather_info.sky = SKY_RAINING;
		break;
	case 3:		// CLOUDY -> CLOUDLESS
		strcat(buf, "Начало проясняться.\r\n");
		weather_info.sky = SKY_CLOUDLESS;
		break;
	case 4:		// RAINING -> LIGHTNING
		strcat(buf, "Налетевший ветер разогнал тучи.\r\n");
		weather_info.sky = SKY_LIGHTNING;
		break;
	case 5:		// RAINING -> CLOUDY
		if (IS_SET(weather_info.weather_type, WEATHER_LIGHTRAIN | WEATHER_MEDIUMRAIN | WEATHER_BIGRAIN))
			strcat(buf, "Дождь прекратился.\r\n");
		else if (IS_SET(weather_info.weather_type, WEATHER_LIGHTSNOW | WEATHER_MEDIUMSNOW | WEATHER_BIGSNOW))
			strcat(buf, "Снегопад прекратился.\r\n");
		else if (IS_SET(weather_info.weather_type, WEATHER_GRAD))
			strcat(buf, "Град прекратился.\r\n");
		weather_info.sky = SKY_CLOUDY;
		break;
	case 6:		// LIGHTNING -> RAINING
		switch (time_info.month)
		{
		case MONTH_MAY:
		case MONTH_JUNE:
		case MONTH_JULY:
		case MONTH_AUGUST:
		case MONTH_SEPTEMBER:
			if (IS_SET(cweather_type, WEATHER_QUICKCOOL))
			{
				strcat(buf, "Начался град.\r\n");
				SET_BIT(cweather_type, WEATHER_GRAD);
			}
			else
			{
				strcat(buf, "Полил дождь.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTRAIN, 10, 40, 50);
			}
			break;
		case MONTH_DECEMBER:
		case MONTH_JANUARY:
		case MONTH_FEBRUARY:
			strcat(buf, "Повалил снег.\r\n");
			create_rainsnow(&cweather_type, WEATHER_LIGHTSNOW, 10, 40, 50);
			break;
		case MONTH_OCTOBER:
		case MONTH_APRIL:
			if (IS_SET(cweather_type, WEATHER_QUICKCOOL)
					&& weather_info.temperature <= 5)
			{
				strcat(buf, "Повалил снег.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTSNOW, 40, 60, 0);
			}
			else
			{
				strcat(buf, "Начался дождь.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTRAIN, 40, 60, 0);
			}
			break;
		case MONTH_NOVEMBER:
			if (avg_day_temp <= 3 || IS_SET(cweather_type, WEATHER_QUICKCOOL))
			{
				strcat(buf, "Повалил снег.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTSNOW, 40, 60, 0);
			}
			else
			{
				strcat(buf, "Начался дождь.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTRAIN, 40, 60, 0);
			}
			break;
		case MONTH_MART:
			if (avg_day_temp >= 3 || IS_SET(cweather_type, WEATHER_QUICKHOT))
			{
				strcat(buf, "Начался дождь.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTRAIN, 80, 20, 0);
			}
			else
			{
				strcat(buf, "Пошел снег.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTSNOW, 60, 30, 10);
			}
			break;
		}
		weather_info.sky = SKY_RAINING;
		break;
	case 0:
	default:
		if (IS_SET(weather_info.weather_type, WEATHER_GRAD))
		{
			strcat(buf, "Град прекратился.\r\n");
			create_rainsnow(&cweather_type, WEATHER_LIGHTRAIN, 10, 40, 50);
		}
		else if (IS_SET(weather_info.weather_type, WEATHER_BIGRAIN))
		{
			if (weather_info.change >= 5)
			{
				strcat(buf, "Дождь утих.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTRAIN, 20, 80, 0);
			}
			else
				SET_BIT(cweather_type, WEATHER_BIGRAIN);
		}
		else if (IS_SET(weather_info.weather_type, WEATHER_MEDIUMRAIN))
		{
			if (weather_info.change <= -5)
			{
				strcat(buf, "Дождь усилился.\r\n");
				SET_BIT(cweather_type, WEATHER_BIGRAIN);
			}
			else if (weather_info.change >= 5)
			{
				strcat(buf, "Дождь утих.\r\n");
				SET_BIT(cweather_type, WEATHER_LIGHTRAIN);
			}
			else
				SET_BIT(cweather_type, WEATHER_MEDIUMRAIN);
		}
		else if (IS_SET(weather_info.weather_type, WEATHER_LIGHTRAIN))
		{
			if (weather_info.change <= -5)
			{
				strcat(buf, "Дождь усилился.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTRAIN, 0, 70, 30);
			}
			else
				SET_BIT(cweather_type, WEATHER_LIGHTRAIN);
		}
		else if (IS_SET(weather_info.weather_type, WEATHER_BIGSNOW))
		{
			if (weather_info.change >= 5)
			{
				strcat(buf, "Снегопад утих.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTSNOW, 20, 80, 0);
			}
			else
				SET_BIT(cweather_type, WEATHER_BIGSNOW);
		}
		else if (IS_SET(weather_info.weather_type, WEATHER_MEDIUMSNOW))
		{
			if (weather_info.change <= -5)
			{
				strcat(buf, "Снегопад усилился.\r\n");
				SET_BIT(cweather_type, WEATHER_BIGSNOW);
			}
			else if (weather_info.change >= 5)
			{
				strcat(buf, "Снегопад утих.\r\n");
				SET_BIT(cweather_type, WEATHER_LIGHTSNOW);
			}
			else
				SET_BIT(cweather_type, WEATHER_MEDIUMSNOW);
		}
		else if (IS_SET(weather_info.weather_type, WEATHER_LIGHTSNOW))
		{
			if (weather_info.change <= -5)
			{
				strcat(buf, "Снегопад усилился.\r\n");
				create_rainsnow(&cweather_type, WEATHER_LIGHTSNOW, 0, 70, 30);
			}
			else
				SET_BIT(cweather_type, WEATHER_LIGHTSNOW);
		}
		break;
	}

	if (*buf)
		send_to_outdoor(buf, WEATHER_CONTROL);
	weather_info.weather_type = cweather_type;
}
Exemple #2
0
// Hitpoint gain pr. game hour
int hit_gain(CHAR_DATA * ch)
{
	int gain = 0, restore = MAX(10, GET_REAL_CON(ch) * 3 / 2), percent = 100;

	if (IS_NPC(ch))
		gain = GET_LEVEL(ch) + GET_REAL_CON(ch);
	else
	{
		if (!ch->desc || STATE(ch->desc) != CON_PLAYING)
			return (0);

		if (!AFF_FLAGGED(ch, AFF_NOOB_REGEN))
		{
			gain = graf(age(ch)->year, restore - 3, restore, restore, restore - 2,
				restore - 3, restore - 5, restore - 7);
		}
		else
		{
			const double base_hp = std::max(1, PlayerSystem::con_total_hp(ch));
			const double rest_time = 80 + 10 * GET_LEVEL(ch);
			gain = base_hp / rest_time * 60;
		}

		// Room specification    //
		if (LIKE_ROOM(ch))
			percent += 25;
		// Weather specification //
		if (average_day_temp() < -20)
			percent -= 15;
		else if (average_day_temp() < -10)
			percent -= 10;
	}

	if (world[IN_ROOM(ch)]->fires)
		percent += MAX(50, 10 + world[IN_ROOM(ch)]->fires * 5);

	// Skill/Spell calculations //

	// Position calculations    //
	switch (GET_POS(ch))
	{
	case POS_SLEEPING:
		percent += 25;
		break;
	case POS_RESTING:
		percent += 15;
		break;
	case POS_SITTING:
		percent += 10;
		break;
	}

	if (!IS_NPC(ch))
	{
		if (GET_COND(ch, FULL) == 0)
			percent -= 50;
		if (GET_COND(ch, THIRST) == 0)
			percent -= 25;
	}

	percent += GET_HITREG(ch);

	// TODO: перевоткнуть на apply_аффект
	if (AFF_FLAGGED(ch, AFF_POISON) && percent > 0)
		percent /= 4;

	percent = MAX(0, MIN(250, percent));
	gain = gain * percent / 100;
	if (!IS_NPC(ch))
	{
		if (GET_POS(ch) == POS_INCAP || GET_POS(ch) == POS_MORTALLYW)
			gain = 0;
	}
	return (gain);
}
Exemple #3
0
// move gain pr. game hour //
int move_gain(CHAR_DATA * ch)
{
	int gain = 0, restore = GET_REAL_CON(ch) / 2, percent = 100;

	if (IS_NPC(ch))
		gain = GET_LEVEL(ch);
	else
	{
		if (!ch->desc || STATE(ch->desc) != CON_PLAYING)
			return (0);
		gain =
			graf(age(ch)->year, 15 + restore, 20 + restore, 25 + restore,
				 20 + restore, 16 + restore, 12 + restore, 8 + restore);
		// Room specification    //
		if (LIKE_ROOM(ch))
			percent += 25;
		// Weather specification //
		if (average_day_temp() < -20)
			percent -= 10;
		else if (average_day_temp() < -10)
			percent -= 5;
	}

	if (world[IN_ROOM(ch)]->fires)
		percent += MAX(50, 10 + world[IN_ROOM(ch)]->fires * 5);

	// Class/Level calculations //

	// Skill/Spell calculations //


	// Position calculations    //
	switch (GET_POS(ch))
	{
	case POS_SLEEPING:
		percent += 25;
		break;
	case POS_RESTING:
		percent += 15;
		break;
	case POS_SITTING:
		percent += 10;
		break;
	}

	if (!IS_NPC(ch))
	{
		if (GET_COND(ch, FULL) == 0)
			percent -= 50;
		if (GET_COND(ch, THIRST) == 0)
			percent -= 25;
		if (!IS_IMMORTAL(ch) && affected_by_spell(ch, SPELL_HIDE))
			percent -= 20;
		if (!IS_IMMORTAL(ch) && affected_by_spell(ch, SPELL_CAMOUFLAGE))
			percent -= 30;
	}

	percent += GET_MOVEREG(ch);
	if (AFF_FLAGGED(ch, AFF_POISON) && percent > 0)
		percent /= 4;
	percent = MAX(0, MIN(250, percent));
	gain = gain * percent / 100;
	return (gain);
}
Exemple #4
0
// manapoint gain pr. game hour
int mana_gain(CHAR_DATA * ch)
{
	int gain = 0, restore = int_app[GET_REAL_INT(ch)].mana_per_tic, percent = 100;
	int stopmem = FALSE;

	if (IS_NPC(ch))
	{
		gain = GET_LEVEL(ch);
	}
	else
	{
		if (!ch->desc || STATE(ch->desc) != CON_PLAYING)
			return (0);

		if (!IS_MANA_CASTER(ch))
			gain =
				graf(age(ch)->year, restore - 8, restore - 4, restore,
					 restore + 5, restore, restore - 4, restore - 8);
		else
			gain = mana_gain_cs[GET_REAL_INT(ch)];

		// Room specification
		if (LIKE_ROOM(ch))
			percent += 25;
		// Weather specification
		if (average_day_temp() < -20)
			percent -= 10;
		else if (average_day_temp() < -10)
			percent -= 5;
	}

	if (world[IN_ROOM(ch)]->fires)
		percent += MAX(50, 10 + world[IN_ROOM(ch)]->fires * 5);

	if (AFF_FLAGGED(ch, AFF_DEAFNESS))
		percent += 15;

	// Skill/Spell calculations


	// Position calculations
	if (ch->get_fighting())
		percent -= 90;
	else
		switch (GET_POS(ch))
		{
		case POS_SLEEPING:
			if (IS_MANA_CASTER(ch))
			{
				percent += 80;
			}
			else
			{
				stopmem = TRUE;
				percent = 0;
			}
			break;
		case POS_RESTING:
			percent += 45;
			break;
		case POS_SITTING:
			percent += 30;
			break;
		case POS_STANDING:
			break;
		default:
			stopmem = TRUE;
			percent = 0;
			break;
		}

	if (!IS_MANA_CASTER(ch) &&
			(AFF_FLAGGED(ch, AFF_HOLD) ||
			 AFF_FLAGGED(ch, AFF_BLIND) ||
			 AFF_FLAGGED(ch, AFF_SLEEP) ||
			 ((IN_ROOM(ch) != NOWHERE) && IS_DARK(IN_ROOM(ch)) && !can_use_feat(ch, DARK_READING_FEAT))))
	{
		stopmem = TRUE;
		percent = 0;
	}
	if (!IS_NPC(ch))
	{
		if (GET_COND(ch, FULL) == 0)
			percent -= 50;
		if (GET_COND(ch, THIRST) == 0)
			percent -= 25;
		if (GET_COND(ch, DRUNK) >= CHAR_DRUNKED)
			percent -= 10;
	}

	if (!IS_MANA_CASTER(ch))
		percent += GET_MANAREG(ch);
	if (AFF_FLAGGED(ch, AFF_POISON) && percent > 0)
		percent /= 4;
	percent = MAX(0, MIN(250, percent));
	gain = gain * percent / 100;
	return (stopmem ? 0 : gain);
}