Fix #520 add hate-threat messages to dof client, fix modify hp and power to not reset on calculatebonuses for spells

This commit is contained in:
Emagi 2024-04-13 19:51:58 -04:00
parent d1af2ec649
commit 02f6f2a1af
6 changed files with 54 additions and 16 deletions

View file

@ -1092,10 +1092,12 @@ bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const c
break;
}
case SPAWN_SET_VALUE_HP:{
target->SetTotalHPBase(val);
target->SetHP(val, send_update);
break;
}
case SPAWN_SET_VALUE_POWER:{
target->SetTotalPowerBase(val);
target->SetPower(val, send_update);
break;
}

View file

@ -1489,8 +1489,8 @@ void Entity::CalculateBonuses(){
}
prim_power_bonus = floor(float(prim_power_bonus));
sta_hp_bonus = floor(float(sta_hp_bonus));
SetTotalHP(GetTotalHPBase() + values->health + sta_hp_bonus);
SetTotalPower(GetTotalPowerBase() + values->power + prim_power_bonus);
SetTotalHP(GetTotalHPBaseInstance() + values->health + sta_hp_bonus);
SetTotalPower(GetTotalPowerBaseInstance() + values->power + prim_power_bonus);
if(GetHP() > GetTotalHP())
SetHP(GetTotalHP());
if(GetPower() > GetTotalPower())

View file

@ -2094,8 +2094,8 @@ int EQ2Emu_lua_ModifyMaxPower(lua_State* state) {
sint32 value = lua_interface->GetSInt32Value(state, 2);
lua_interface->ResetFunctionStack(state);
if (spawn && value != 0) {
if (value > spawn->GetTotalHPBase())
spawn->SetTotalPower(spawn->GetTotalPower() + value);
spawn->SetTotalPower(value);
spawn->SetTotalPowerBaseInstance(value);
}
return 0;
}
@ -2106,8 +2106,8 @@ int EQ2Emu_lua_ModifyMaxHP(lua_State* state) {
sint32 value = lua_interface->GetSInt32Value(state, 2);
lua_interface->ResetFunctionStack(state);
if (spawn && value != 0) {
if (value > spawn->GetTotalHPBase())
spawn->SetTotalHP(spawn->GetTotalHP() + value);
spawn->SetTotalHP(value);
spawn->SetTotalHPBaseInstance(value);
}
return 0;
}

View file

@ -1474,12 +1474,18 @@ void Spawn::SetTotalHP(sint32 new_val){
void Spawn::SetTotalHPBase(sint32 new_val)
{
SetInfo(&basic_info.hp_base, new_val);
if(GetZone() && basic_info.cur_hp > 0 && basic_info.cur_hp < basic_info.max_hp)
GetZone()->AddDamagedSpawn(this);
SendGroupUpdate();
}
void Spawn::SetTotalHPBaseInstance(sint32 new_val)
{
SetInfo(&basic_info.hp_base_instance, new_val);
}
sint32 Spawn::GetHP()
{
return basic_info.cur_hp;
@ -1492,6 +1498,14 @@ sint32 Spawn::GetTotalHPBase()
{
return basic_info.hp_base;
}
sint32 Spawn::GetTotalHPBaseInstance()
{
return basic_info.hp_base_instance;
}
sint32 Spawn::GetTotalPowerBaseInstance()
{
return basic_info.power_base_instance;
}
/*** POWER ***/
@ -1546,12 +1560,18 @@ void Spawn::SetTotalPower(sint32 new_val)
void Spawn::SetTotalPowerBase(sint32 new_val)
{
SetInfo(&basic_info.power_base, new_val);
if(GetZone() && basic_info.cur_power < basic_info.max_power)
GetZone()->AddDamagedSpawn(this);
SendGroupUpdate();
}
void Spawn::SetTotalPowerBaseInstance(sint32 new_val)
{
SetInfo(&basic_info.power_base_instance, new_val);
}
sint32 Spawn::GetPower()
{
return basic_info.cur_power;

View file

@ -205,9 +205,11 @@ struct BasicInfoStruct{
sint32 cur_hp;
sint32 max_hp;
sint32 hp_base;
sint32 hp_base_instance;
sint32 cur_power;
sint32 max_power;
sint32 power_base;
sint32 power_base_instance;
sint32 cur_savagery;
sint32 max_savagery;
sint32 savagery_base;
@ -703,7 +705,9 @@ public:
sint32 GetTotalHP();
sint32 GetHP();
sint32 GetTotalHPBase();
sint32 GetTotalHPBaseInstance();
sint32 GetTotalPowerBase();
sint32 GetTotalPowerBaseInstance();
float GetHPRatio() { return GetHP() == 0 || GetTotalHP() == 0 ? 0 : ((float) GetHP() / GetTotalHP() * 100); }
int GetIntHPRatio() { return GetTotalHP() == 0 ? 0 : static_cast<int>(GetHPRatio()); }
@ -728,7 +732,9 @@ public:
void SetTotalSavagery(sint32 new_val);
void SetTotalDissonance(sint32 new_val);
void SetTotalPowerBase(sint32 new_val);
void SetTotalPowerBaseInstance(sint32 new_val);
void SetTotalHPBase(sint32 new_val);
void SetTotalHPBaseInstance(sint32 new_val);
void SetTotalSavageryBase(sint32 new_val);
void SetTotalDissonanceBase(sint32 new_val);
void SetPower(sint32 power, bool setUpdateFlags = true);

View file

@ -5356,16 +5356,26 @@ void ZoneServer::SendThreatPacket(Spawn* caster, Spawn* target, int32 threat_amt
if(target && target->GetDistance(client->GetPlayer()) > 50)
continue;
PacketStruct* packet = configReader.getStruct("WS_HearThreatCmd", client->GetVersion());
if (packet) {
packet->setDataByName("spell_name", spell_name);
packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(caster));
packet->setDataByName("target", client->GetPlayer()->GetIDWithPlayerSpawn(target));
packet->setDataByName("threat_amount", threat_amt);
if(client->GetVersion() <= 547) {
int8 channel = 46;
client->QueuePacket(packet->serialize());
if(client->GetPlayer() == caster || client->GetPlayer() == target)
channel = 42;
client->Message(channel, "%s increases %s hate with %s for %u threat.", spell_name, (client->GetPlayer() == caster) ? "YOUR" : caster->GetName(), (client->GetPlayer() == target) ? "YOU" : target->GetName(), threat_amt);
}
else {
PacketStruct* packet = configReader.getStruct("WS_HearThreatCmd", client->GetVersion());
if (packet) {
packet->setDataByName("spell_name", spell_name);
packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(caster));
packet->setDataByName("target", client->GetPlayer()->GetIDWithPlayerSpawn(target));
packet->setDataByName("threat_amount", threat_amt);
client->QueuePacket(packet->serialize());
}
safe_delete(packet);
}
safe_delete(packet);
}
MClientList.releasereadlock(__FUNCTION__, __LINE__);
}