Loading...   


void NPC::LevelScale() {

	uint8 random_level = (MakeRandomInt(level, maxlevel));
	float scaling = (((random_level / (float)level) - 1) * (scalerate / 100.0f));
	uint8 scale_adjust = 1;

	if(scalerate == 0 || maxlevel <= 25)
	{
		if (npctype_id < 202000)
		{
			max_hp += (random_level - level) * 20;
			base_hp += (random_level - level) * 20;
		}
		else
		{
			max_hp += (random_level - level) * 100;
			base_hp += (random_level - level) * 100;
		}

		cur_hp = max_hp;

		max_dmg += (random_level - level) * 2;
	}
	else
	{
		base_hp += (int)(base_hp * scaling);
		max_hp += (int)(max_hp * scaling);
		cur_hp = max_hp;

		if (max_dmg)
		{
			max_dmg += (int)(max_dmg * scaling / scale_adjust);
			min_dmg += (int)(min_dmg * scaling / scale_adjust);
		}
	}

	STR += (int)(STR * scaling / scale_adjust);
	STA += (int)(STA * scaling / scale_adjust);
	AGI += (int)(AGI * scaling / scale_adjust);
	DEX += (int)(DEX * scaling / scale_adjust);
	INT += (int)(INT * scaling / scale_adjust);
	WIS += (int)(WIS * scaling / scale_adjust);
	CHA += (int)(CHA * scaling / scale_adjust);
	if (MR)
		MR += (int)(MR * scaling / scale_adjust);
	if (CR)
		CR += (int)(CR * scaling / scale_adjust);
	if (DR)
		DR += (int)(DR * scaling / scale_adjust);
	if (FR)
		FR += (int)(FR * scaling / scale_adjust);
	if (PR)
		PR += (int)(PR * scaling / scale_adjust);

	level = random_level;

	return;
}

Raw Paste Data