Thread: Stat Caps.
View Single Post
  #14  
Old 02-23-2013, 08:31 PM
Zamthos
Discordant
 
Join Date: Jan 2013
Posts: 284
Default

I just stumbled upon this in the same code.

EDIT: With this new find, the first change is not necessary.

REPLACE client_mods.cpp
Code:
int16 Client::CalcSTR() {
	int16 val = m_pp.STR + itembonuses.STR + spellbonuses.STR + CalcAlcoholPhysicalEffect();
	
	int16 mod = aabonuses.STR;
	
	if(val>255 && GetLevel() <= 60)
		val = 255;
	STR = val + mod;
	
	if(STR < 1)
		STR = 1;

	int m = GetMaxSTR();
	if(STR > m)
		STR = m;
	
	return(STR);
}

int16 Client::CalcSTA() {
	int16 val = m_pp.STA + itembonuses.STA + spellbonuses.STA + CalcAlcoholPhysicalEffect();;
	
	int16 mod = aabonuses.STA;
	
	if(val>255 && GetLevel() <= 60)
		val = 255;
	STA = val + mod;
	
	if(STA < 1)
		STA = 1;

	int m = GetMaxSTA();
	if(STA > m)
		STA = m;
	
	return(STA);
}

int16 Client::CalcAGI() {
	int16 val = m_pp.AGI + itembonuses.AGI + spellbonuses.AGI - CalcAlcoholPhysicalEffect();;
	int16 mod = aabonuses.AGI;

	if(val>255 && GetLevel() <= 60)
		val = 255;

	int16 str = GetSTR();
	
	//Encumbered penalty
	if(weight > (str * 10)) {
		//AGI is halved when we double our weight, zeroed (defaults to 1) when we triple it. this includes AGI from AAs
		float total_agi = float(val + mod);
		float str_float = float(str);
		AGI = (int16)(((-total_agi) / (str_float * 2)) * (((float)weight / 10) - str_float) + total_agi);	//casting to an int assumes this will be floor'd. without using floats & casting to int16, the calculation doesn't work right
	} else
		AGI = val + mod;

	if(AGI < 1)
		AGI = 1;

	int m = GetMaxAGI();
	if(AGI > m)
		AGI = m;
	
	return(AGI);
}

int16 Client::CalcDEX() {
	int16 val = m_pp.DEX + itembonuses.DEX + spellbonuses.DEX - CalcAlcoholPhysicalEffect();;
	
	int16 mod = aabonuses.DEX;
	
	if(val>255 && GetLevel() <= 60)
		val = 255;
	DEX = val + mod;
	
	if(DEX < 1)
		DEX = 1;

	int m = GetMaxDEX();
	if(DEX > m)
		DEX = m;
	
	return(DEX);
}

int16 Client::CalcINT() {
	int16 val = m_pp.INT + itembonuses.INT + spellbonuses.INT;

	int16 mod = aabonuses.INT;
	
	if(val>255 && GetLevel() <= 60)
		val = 255;
	INT = val + mod;
	
	if(m_pp.intoxication)
	{
		int16 AlcINT  = INT - (int16)((float)m_pp.intoxication / 200.0f * (float)INT) - 1;

		if((AlcINT < (int)(0.2 * INT)))
			INT = (int)(0.2f * (float)INT);
		else
			INT = AlcINT;
	}

	if(INT < 1)
		INT = 1;

	int m = GetMaxINT();
	if(INT > m)
		INT = m;
	
	return(INT);
}

int16 Client::CalcWIS() {
	int16 val = m_pp.WIS + itembonuses.WIS + spellbonuses.WIS;
	
	int16 mod = aabonuses.WIS;
	
	if(val>255 && GetLevel() <= 60)
		val = 255;
	WIS = val + mod;

	if(m_pp.intoxication)
	{
		int16 AlcWIS  = WIS - (int16)((float)m_pp.intoxication / 200.0f * (float)WIS) - 1;

		if((AlcWIS < (int)(0.2 * WIS)))
			WIS = (int)(0.2f * (float)WIS);
		else
			WIS = AlcWIS;
	}

	if(WIS < 1)
		WIS = 1;

	int m = GetMaxWIS();
	if(WIS > m)
		WIS = m;
	
	return(WIS);
}

int16 Client::CalcCHA() {
	int16 val = m_pp.CHA + itembonuses.CHA + spellbonuses.CHA;
	
	int16 mod = aabonuses.CHA;
	
	if(val>255 && GetLevel() <= 60)
		val = 255;
	CHA = val + mod;
	
	if(CHA < 1)
		CHA = 1;

	int m = GetMaxCHA();
	if(CHA > m)
		CHA = m;
	
	return(CHA);
}
WITH client_mods.cpp:
Code:
int16 Client::CalcSTR() {
	int16 val = m_pp.STR + itembonuses.STR + spellbonuses.STR + CalcAlcoholPhysicalEffect();
	
	int16 mod = aabonuses.STR;
	
	STR = val + mod;
	
	if(STR < 1)
		STR = 1;

	int m = GetMaxSTR();
	if(STR > m)
		STR = m;
	
	return(STR);
}

int16 Client::CalcSTA() {
	int16 val = m_pp.STA + itembonuses.STA + spellbonuses.STA + CalcAlcoholPhysicalEffect();;
	
	int16 mod = aabonuses.STA;
	
	STA = val + mod;
	
	if(STA < 1)
		STA = 1;

	int m = GetMaxSTA();
	if(STA > m)
		STA = m;
	
	return(STA);
}

int16 Client::CalcAGI() {
	int16 val = m_pp.AGI + itembonuses.AGI + spellbonuses.AGI - CalcAlcoholPhysicalEffect();;
	int16 mod = aabonuses.AGI;

	int16 str = GetSTR();
	
	//Encumbered penalty
	if(weight > (str * 10)) {
		//AGI is halved when we double our weight, zeroed (defaults to 1) when we triple it. this includes AGI from AAs
		float total_agi = float(val + mod);
		float str_float = float(str);
		AGI = (int16)(((-total_agi) / (str_float * 2)) * (((float)weight / 10) - str_float) + total_agi);	//casting to an int assumes this will be floor'd. without using floats & casting to int16, the calculation doesn't work right
	} else
		AGI = val + mod;

	if(AGI < 1)
		AGI = 1;

	int m = GetMaxAGI();
	if(AGI > m)
		AGI = m;
	
	return(AGI);
}

int16 Client::CalcDEX() {
	int16 val = m_pp.DEX + itembonuses.DEX + spellbonuses.DEX - CalcAlcoholPhysicalEffect();;
	
	int16 mod = aabonuses.DEX;
	
	DEX = val + mod;
	
	if(DEX < 1)
		DEX = 1;

	int m = GetMaxDEX();
	if(DEX > m)
		DEX = m;
	
	return(DEX);
}

int16 Client::CalcINT() {
	int16 val = m_pp.INT + itembonuses.INT + spellbonuses.INT;

	int16 mod = aabonuses.INT;
	
	INT = val + mod;
	
	if(m_pp.intoxication)
	{
		int16 AlcINT  = INT - (int16)((float)m_pp.intoxication / 200.0f * (float)INT) - 1;

		if((AlcINT < (int)(0.2 * INT)))
			INT = (int)(0.2f * (float)INT);
		else
			INT = AlcINT;
	}

	if(INT < 1)
		INT = 1;

	int m = GetMaxINT();
	if(INT > m)
		INT = m;
	
	return(INT);
}

int16 Client::CalcWIS() {
	int16 val = m_pp.WIS + itembonuses.WIS + spellbonuses.WIS;
	
	int16 mod = aabonuses.WIS;
	
	WIS = val + mod;

	if(m_pp.intoxication)
	{
		int16 AlcWIS  = WIS - (int16)((float)m_pp.intoxication / 200.0f * (float)WIS) - 1;

		if((AlcWIS < (int)(0.2 * WIS)))
			WIS = (int)(0.2f * (float)WIS);
		else
			WIS = AlcWIS;
	}

	if(WIS < 1)
		WIS = 1;

	int m = GetMaxWIS();
	if(WIS > m)
		WIS = m;
	
	return(WIS);
}

int16 Client::CalcCHA() {
	int16 val = m_pp.CHA + itembonuses.CHA + spellbonuses.CHA;
	
	int16 mod = aabonuses.CHA;
	
	CHA = val + mod;
	
	if(CHA < 1)
		CHA = 1;

	int m = GetMaxCHA();
	if(CHA > m)
		CHA = m;
	
	return(CHA);
}
Reply With Quote