Przeglądaj źródła

Add a max concentration base and allow support of the DB entry for players, try to restrict the concentration from overflowing the integer

Emagi 6 miesięcy temu
rodzic
commit
60a9c87312

+ 6 - 5
EQ2/source/WorldServer/Entity.cpp

@@ -87,6 +87,9 @@ Entity::Entity(){
 	m_petSpellID = 0;
 	m_petSpellTier = 0;
 	m_petDismissing = false;
+	
+	if (!IsPlayer() && GetInfoStruct()->get_max_concentration_base() == 0)
+		GetInfoStruct()->set_max_concentration_base(5);
 }
 
 Entity::~Entity(){
@@ -180,6 +183,7 @@ void Entity::MapInfoStruct()
 	get_int16_funcs["tradeskill_max_level"] = l::bind(&InfoStruct::get_tradeskill_max_level, &info_struct);
 	get_int8_funcs["cur_concentration"] = l::bind(&InfoStruct::get_cur_concentration, &info_struct);
 	get_int8_funcs["max_concentration"] = l::bind(&InfoStruct::get_max_concentration, &info_struct);
+	get_int8_funcs["max_concentration_base"] = l::bind(&InfoStruct::get_max_concentration_base, &info_struct);
 	get_int16_funcs["cur_attack"] = l::bind(&InfoStruct::get_cur_attack, &info_struct);
 	get_int16_funcs["attack_base"] = l::bind(&InfoStruct::get_attack_base, &info_struct);
 	get_int16_funcs["cur_mitigation"] = l::bind(&InfoStruct::get_cur_mitigation, &info_struct);
@@ -382,6 +386,7 @@ void Entity::MapInfoStruct()
 	set_int16_funcs["tradeskill_max_level"] = l::bind(&InfoStruct::set_tradeskill_max_level, &info_struct, l::_1);
 	set_int8_funcs["cur_concentration"] = l::bind(&InfoStruct::set_cur_concentration, &info_struct, l::_1);
 	set_int8_funcs["max_concentration"] = l::bind(&InfoStruct::set_max_concentration, &info_struct, l::_1);
+	set_int8_funcs["max_concentration_base"] = l::bind(&InfoStruct::set_max_concentration_base, &info_struct, l::_1);
 	set_int16_funcs["cur_attack"] = l::bind(&InfoStruct::set_cur_attack, &info_struct, l::_1);
 	set_int16_funcs["attack_base"] = l::bind(&InfoStruct::set_attack_base, &info_struct, l::_1);
 	set_int16_funcs["cur_mitigation"] = l::bind(&InfoStruct::set_cur_mitigation, &info_struct, l::_1);
@@ -1495,7 +1500,7 @@ void Entity::CalculateBonuses(){
 
 	info->add_poison(values->vs_poison);
 
-	info->add_max_concentration(values->concentration);
+	info->set_max_concentration(info->get_max_concentration_base() + values->concentration);
 
 	info->add_cold(values->vs_cold);
 
@@ -1532,7 +1537,6 @@ void Entity::CalculateBonuses(){
 	
 	float full_pct_hit = 100.0f;
 
-	//info->cur_concentration = 0;
 	MStats.lock();
 	float parryStat = stats[ITEM_STAT_PARRY];
 	MStats.unlock();
@@ -1590,7 +1594,6 @@ void Entity::CalculateBonuses(){
 	}
 	else
 	{
-		//info->cur_concentration = 0;
 		MStats.lock();
 		float deflectionStat = stats[ITEM_STAT_DEFLECTION];
 		MStats.unlock();
@@ -1605,8 +1608,6 @@ void Entity::CalculateBonuses(){
 	info->set_block(block_actual);
 	full_pct_hit -= block_actual;
 
-
-	//info->cur_concentration = 0;
 	MStats.lock();
 	float defenseStat = stats[ITEM_STAT_DEFENSE];
 	MStats.unlock();

+ 3 - 0
EQ2/source/WorldServer/Entity.h

@@ -499,6 +499,7 @@ struct InfoStruct{
 
 	int8	 get_cur_concentration() { std::lock_guard<std::mutex> lk(classMutex); return cur_concentration_; }
 	int8	 get_max_concentration() { std::lock_guard<std::mutex> lk(classMutex); return max_concentration_; }
+	int8	 get_max_concentration_base() { std::lock_guard<std::mutex> lk(classMutex); return max_concentration_base_; }
 	int16	 get_cur_attack() { std::lock_guard<std::mutex> lk(classMutex); return cur_attack_; }
 	int16	 get_attack_base() { std::lock_guard<std::mutex> lk(classMutex); return attack_base_; }
 	int16	 get_cur_mitigation() { std::lock_guard<std::mutex> lk(classMutex); return cur_mitigation_; }
@@ -720,6 +721,7 @@ struct InfoStruct{
 
 	void	set_cur_concentration(int8 value) { std::lock_guard<std::mutex> lk(classMutex); cur_concentration_ = value; }
 	void	set_max_concentration(int8 value) { std::lock_guard<std::mutex> lk(classMutex); max_concentration_ = value; }
+	void	set_max_concentration_base(int8 value) { std::lock_guard<std::mutex> lk(classMutex); max_concentration_base_ = value; }
 
 	void	add_cur_concentration(int8 value) { std::lock_guard<std::mutex> lk(classMutex); cur_concentration_ += value; }
 	void	add_max_concentration(int8 value) { std::lock_guard<std::mutex> lk(classMutex); max_concentration_ += value; }
@@ -1043,6 +1045,7 @@ private:
 	
 	int8			cur_concentration_;
 	int8			max_concentration_;
+	int8			max_concentration_base_;
 	int16			cur_attack_;
 	int16			attack_base_;
 	int16			cur_mitigation_;

+ 20 - 4
EQ2/source/WorldServer/SpellProcess.cpp

@@ -829,7 +829,15 @@ bool SpellProcess::TakeHP(LuaSpell* spell, int32 custom_hp_req) {
 bool SpellProcess::CheckConcentration(LuaSpell* spell) {
 	if (spell && spell->caster) {
 		int8 req = spell->spell->GetSpellData()->req_concentration;
-		int8 current_avail = 5 - spell->caster->GetConcentrationCurrent();
+		if(spell->caster->GetConcentrationCurrent() >= spell->caster->GetConcentrationMax()) {
+			if(req) {
+				return false; // req needed, no concentration or beyond our concentration
+			}
+			else {
+				 return true; // no req set
+			}
+		}
+		int8 current_avail = spell->caster->GetConcentrationMax() - spell->caster->GetConcentrationCurrent();
 		if (current_avail >= req)
 			return true;
 	}
@@ -839,10 +847,18 @@ bool SpellProcess::CheckConcentration(LuaSpell* spell) {
 bool SpellProcess::AddConcentration(LuaSpell* spell) {
 	if (spell && spell->caster) {
 		int8 req = spell->spell->GetSpellData()->req_concentration;
-		int8 curConcentration = spell->caster->GetInfoStruct()->get_cur_concentration();
-		int8 current_avail = 5 - curConcentration;
+		
+		if(spell->caster->GetConcentrationCurrent() >= spell->caster->GetConcentrationMax()) {
+			if(req) {
+				return false; // req needed, no concentration or beyond our concentration
+			}
+			else {
+				 return true; // no req set
+			}
+		}
+		int8 current_avail = spell->caster->GetConcentrationMax() - spell->caster->GetConcentrationCurrent();
 		if (current_avail >= req) {
-			spell->caster->GetInfoStruct()->set_cur_concentration(curConcentration + req);
+			spell->caster->GetInfoStruct()->set_cur_concentration(spell->caster->GetConcentrationCurrent() + req);
 			if (spell->caster->IsPlayer() && spell->caster->GetZone())
 				spell->caster->GetZone()->TriggerCharSheetTimer();
 			LogWrite(SPELL__DEBUG, 0, "Spell", "Concentration is now %u on %s (Spell %s)", spell->caster->GetInfoStruct()->get_cur_concentration(), spell->caster->GetName(), spell->spell->GetName());

+ 3 - 3
EQ2/source/WorldServer/WorldDatabase.cpp

@@ -1662,10 +1662,10 @@ bool WorldDatabase::LoadCharacterStats(int32 id, int32 account_id, Client* clien
 			
 			client->GetPlayer()->SetHP(result.GetSInt32Str("hp"));
 			client->GetPlayer()->SetPower(result.GetSInt32Str("power"));
-			info->set_max_concentration(result.GetInt8Str("max_concentration"));
+			info->set_max_concentration_base(result.GetInt8Str("max_concentration"));
 			
-			if (info->get_max_concentration() == 0)
-				info->set_max_concentration(5);
+			if (info->get_max_concentration_base() == 0)
+				info->set_max_concentration_base(5);
 
 			info->set_attack_base(result.GetInt16Str("attack"));
 			info->set_mitigation_base(result.GetInt16Str("mitigation"));