From b22a88ecccdadec3b259027aedc9469996b90de5 Mon Sep 17 00:00:00 2001 From: JJ Date: Sat, 19 Aug 2017 16:40:49 -0400 Subject: [PATCH 01/97] Fix sql in manifest [skip ci] --- utils/sql/db_update_manifest.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/sql/db_update_manifest.txt b/utils/sql/db_update_manifest.txt index faccf9e48..e385b9f9e 100644 --- a/utils/sql/db_update_manifest.txt +++ b/utils/sql/db_update_manifest.txt @@ -357,7 +357,7 @@ 9101|2016_12_01_pcnpc_only.sql|SHOW COLUMNS FROM `spells_new` LIKE 'pcnpc_only_flag'|empty| 9102|2017_01_10_book_languages.sql|SHOW COLUMNS FROM `books` LIKE 'language'|empty| 9103|2017_01_30_book_languages_fix.sql|SELECT `language` from `books` WHERE `language` IS NULL|not_empty| -9104|2017_02_09_npc_spells_entries_type_update.sql|SHOW COLUMNS IN `npc_spells_entries` LIKE `type`|contains|smallint(5) unsigned +9104|2017_02_09_npc_spells_entries_type_update.sql|SHOW COLUMNS IN `npc_spells_entries` LIKE 'type'|contains|smallint(5) unsigned 9105|2017_02_15_bot_spells_entries.sql|SELECT `id` FROM `npc_spells_entries` WHERE `npc_spells_id` >= 701 AND `npc_spells_id` <= 712|not_empty| 9106|2017_02_26_npc_spells_update_for_bots.sql|SELECT * FROM `npc_spells` WHERE `id` = '701' AND `name` = 'Cleric Bot'|not_empty| 9107|2017_03_09_inventory_version.sql|SHOW TABLES LIKE 'inventory_version'|empty| From b0a3e9205fa1268f9cbe58ab16f269c0bf959b44 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 21 Aug 2017 02:42:50 -0500 Subject: [PATCH 02/97] [FixZ] Smooth out close combat npc/pet hopping --- zone/mob_ai.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 14e9337ac..ef82527f9 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1001,10 +1001,9 @@ void Mob::AI_Process() { if (this->GetTarget()) { /* If we are engaged, moving and following client, let's look for best Z more often */ float target_distance = DistanceNoZ(this->GetPosition(), this->GetTarget()->GetPosition()); - if (target_distance >= 25) { - this->FixZ(); - } - else if (!this->CheckLosFN(this->GetTarget())) { + this->FixZ(); + + if (target_distance <= 15 && !this->CheckLosFN(this->GetTarget())) { Mob* target = this->GetTarget(); m_Position.x = target->GetX(); From 0663e9cb6fabaa23ff0c727fc372cefdb215f59b Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 21 Aug 2017 19:49:19 -0500 Subject: [PATCH 03/97] [HP Updates] Resolve issue where clicking self in raid window would make characters health bar go down significantly --- zone/client_packet.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 95c9013b2..64d56a3a6 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -13368,10 +13368,9 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) } QueuePacket(app); - EQApplicationPacket hp_app; + GetTarget()->IsTargeted(1); - GetTarget()->CreateHPPacket(&hp_app); - QueuePacket(&hp_app, false); + SendHPUpdate(); } else { From ad7dfc31a9d75798bd932b8723f11f25de37162b Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 21 Aug 2017 21:01:35 -0500 Subject: [PATCH 04/97] [HP Updates] Resolved an issue when a player is swapped to a group in a raid - mana and endurance shows empty to group members --- zone/client_packet.cpp | 993 +++++++++++++++++++++-------------------- zone/mob.cpp | 4 +- zone/raids.cpp | 4 +- zone/raids.h | 2 +- 4 files changed, 508 insertions(+), 495 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 64d56a3a6..f9de65fd9 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -10951,142 +10951,196 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) RaidGeneral_Struct *ri = (RaidGeneral_Struct*)app->pBuffer; switch (ri->action) { - case RaidCommandInviteIntoExisting: - case RaidCommandInvite: { - Client *i = entity_list.GetClientByName(ri->player_name); - if (!i) - break; - Group *g = i->GetGroup(); - // These two messages should be generated by the client I think, just do this for now - if (i->HasRaid()) { - Message(13, "%s is already in a raid.", i->GetName()); - break; - } - if (g && !g->IsLeader(i)) { - Message(13, "You can only invite an ungrouped player or group leader to join your raid."); - break; - } - //This sends an "invite" to the client in question. - auto outapp = new EQApplicationPacket(OP_RaidUpdate, sizeof(RaidGeneral_Struct)); - RaidGeneral_Struct *rg = (RaidGeneral_Struct*)outapp->pBuffer; - strn0cpy(rg->leader_name, ri->leader_name, 64); - strn0cpy(rg->player_name, ri->player_name, 64); - - rg->parameter = 0; - rg->action = 20; - i->QueuePacket(outapp); - safe_delete(outapp); - break; - } - case RaidCommandAcceptInvite: { - Client *i = entity_list.GetClientByName(ri->player_name); - if (i) { - if (IsRaidGrouped()) { - i->Message_StringID(0, ALREADY_IN_RAID, GetName()); //group failed, must invite members not in raid... - return; + case RaidCommandInviteIntoExisting: + case RaidCommandInvite: { + Client *i = entity_list.GetClientByName(ri->player_name); + if (!i) + break; + Group *g = i->GetGroup(); + // These two messages should be generated by the client I think, just do this for now + if (i->HasRaid()) { + Message(13, "%s is already in a raid.", i->GetName()); + break; } - Raid *r = entity_list.GetRaidByClient(i); - if (r) { - r->VerifyRaid(); - Group *g = GetGroup(); - if (g) { - if (g->GroupCount() + r->RaidCount() > MAX_RAID_MEMBERS) - { - i->Message(13, "Invite failed, group invite would create a raid larger than the maximum number of members allowed."); - return; - } - } - else { - if (1 + r->RaidCount() > MAX_RAID_MEMBERS) - { - i->Message(13, "Invite failed, member invite would create a raid larger than the maximum number of members allowed."); - return; - } - } - if (g) {//add us all - uint32 freeGroup = r->GetFreeGroup(); - Client *addClient = nullptr; - for (int x = 0; x < 6; x++) - { - if (g->members[x]) { - Client *c = nullptr; - if (g->members[x]->IsClient()) - c = g->members[x]->CastToClient(); - else - continue; + if (g && !g->IsLeader(i)) { + Message(13, "You can only invite an ungrouped player or group leader to join your raid."); + break; + } + //This sends an "invite" to the client in question. + auto outapp = new EQApplicationPacket(OP_RaidUpdate, sizeof(RaidGeneral_Struct)); + RaidGeneral_Struct *rg = (RaidGeneral_Struct*)outapp->pBuffer; + strn0cpy(rg->leader_name, ri->leader_name, 64); + strn0cpy(rg->player_name, ri->player_name, 64); - if (!addClient) - { - addClient = c; - r->SetGroupLeader(addClient->GetName()); - } - - r->SendRaidCreate(c); - r->SendMakeLeaderPacketTo(r->leadername, c); - if (g->IsLeader(g->members[x])) - r->AddMember(c, freeGroup, false, true); - else - r->AddMember(c, freeGroup); - r->SendBulkRaid(c); - if (r->IsLocked()) { - r->SendRaidLockTo(c); - } + rg->parameter = 0; + rg->action = 20; + i->QueuePacket(outapp); + safe_delete(outapp); + break; + } + case RaidCommandAcceptInvite: { + Client *i = entity_list.GetClientByName(ri->player_name); + if (i) { + if (IsRaidGrouped()) { + i->Message_StringID(0, ALREADY_IN_RAID, GetName()); //group failed, must invite members not in raid... + return; + } + Raid *r = entity_list.GetRaidByClient(i); + if (r) { + r->VerifyRaid(); + Group *g = GetGroup(); + if (g) { + if (g->GroupCount() + r->RaidCount() > MAX_RAID_MEMBERS) + { + i->Message(13, "Invite failed, group invite would create a raid larger than the maximum number of members allowed."); + return; } } - g->JoinRaidXTarget(r); - g->DisbandGroup(true); - r->GroupUpdate(freeGroup); - } - else { - r->SendRaidCreate(this); - r->SendMakeLeaderPacketTo(r->leadername, this); - r->AddMember(this); - r->SendBulkRaid(this); - if (r->IsLocked()) { - r->SendRaidLockTo(this); + else { + if (1 + r->RaidCount() > MAX_RAID_MEMBERS) + { + i->Message(13, "Invite failed, member invite would create a raid larger than the maximum number of members allowed."); + return; + } } - } - } - else - { - Group *ig = i->GetGroup(); - Group *g = GetGroup(); - if (g) //if our target has a group - { - r = new Raid(i); - entity_list.AddRaid(r); - r->SetRaidDetails(); - - uint32 groupFree = r->GetFreeGroup(); //get a free group - if (ig) { //if we already have a group then cycle through adding us... - Client *addClientig = nullptr; + if (g) {//add us all + uint32 freeGroup = r->GetFreeGroup(); + Client *addClient = nullptr; for (int x = 0; x < 6; x++) { - if (ig->members[x]) { - if (!addClientig) { - if (ig->members[x]->IsClient()) { - addClientig = ig->members[x]->CastToClient(); - r->SetGroupLeader(addClientig->GetName()); + if (g->members[x]) { + Client *c = nullptr; + if (g->members[x]->IsClient()) + c = g->members[x]->CastToClient(); + else + continue; + + if (!addClient) + { + addClient = c; + r->SetGroupLeader(addClient->GetName()); + } + + r->SendRaidCreate(c); + r->SendMakeLeaderPacketTo(r->leadername, c); + if (g->IsLeader(g->members[x])) + r->AddMember(c, freeGroup, false, true); + else + r->AddMember(c, freeGroup); + r->SendBulkRaid(c); + if (r->IsLocked()) { + r->SendRaidLockTo(c); + } + } + } + g->JoinRaidXTarget(r); + g->DisbandGroup(true); + r->GroupUpdate(freeGroup); + } + else { + r->SendRaidCreate(this); + r->SendMakeLeaderPacketTo(r->leadername, this); + r->AddMember(this); + r->SendBulkRaid(this); + if (r->IsLocked()) { + r->SendRaidLockTo(this); + } + } + } + else + { + Group *ig = i->GetGroup(); + Group *g = GetGroup(); + if (g) //if our target has a group + { + r = new Raid(i); + entity_list.AddRaid(r); + r->SetRaidDetails(); + + uint32 groupFree = r->GetFreeGroup(); //get a free group + if (ig) { //if we already have a group then cycle through adding us... + Client *addClientig = nullptr; + for (int x = 0; x < 6; x++) + { + if (ig->members[x]) { + if (!addClientig) { + if (ig->members[x]->IsClient()) { + addClientig = ig->members[x]->CastToClient(); + r->SetGroupLeader(addClientig->GetName()); + } + } + if (ig->IsLeader(ig->members[x])) { + Client *c = nullptr; + if (ig->members[x]->IsClient()) + c = ig->members[x]->CastToClient(); + else + continue; + r->SendRaidCreate(c); + r->SendMakeLeaderPacketTo(r->leadername, c); + r->AddMember(c, groupFree, true, true, true); + r->SendBulkRaid(c); + if (r->IsLocked()) { + r->SendRaidLockTo(c); + } + } + else { + Client *c = nullptr; + if (ig->members[x]->IsClient()) + c = ig->members[x]->CastToClient(); + else + continue; + r->SendRaidCreate(c); + r->SendMakeLeaderPacketTo(r->leadername, c); + r->AddMember(c, groupFree); + r->SendBulkRaid(c); + if (r->IsLocked()) { + r->SendRaidLockTo(c); + } } } - if (ig->IsLeader(ig->members[x])) { + } + ig->JoinRaidXTarget(r, true); + ig->DisbandGroup(true); + r->GroupUpdate(groupFree); + groupFree = r->GetFreeGroup(); + } + else { //else just add the inviter + r->SendRaidCreate(i); + r->AddMember(i, 0xFFFFFFFF, true, false, true); + } + + Client *addClient = nullptr; + //now add the existing group + for (int x = 0; x < 6; x++) + { + if (g->members[x]) { + if (!addClient) + { + if (g->members[x]->IsClient()) { + addClient = g->members[x]->CastToClient(); + r->SetGroupLeader(addClient->GetName()); + } + } + if (g->IsLeader(g->members[x])) + { Client *c = nullptr; - if (ig->members[x]->IsClient()) - c = ig->members[x]->CastToClient(); + if (g->members[x]->IsClient()) + c = g->members[x]->CastToClient(); else continue; r->SendRaidCreate(c); r->SendMakeLeaderPacketTo(r->leadername, c); - r->AddMember(c, groupFree, true, true, true); + r->AddMember(c, groupFree, false, true); r->SendBulkRaid(c); if (r->IsLocked()) { r->SendRaidLockTo(c); } } - else { + else + { Client *c = nullptr; - if (ig->members[x]->IsClient()) - c = ig->members[x]->CastToClient(); + if (g->members[x]->IsClient()) + c = g->members[x]->CastToClient(); else continue; r->SendRaidCreate(c); @@ -11099,264 +11153,275 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) } } } - ig->JoinRaidXTarget(r, true); - ig->DisbandGroup(true); + g->JoinRaidXTarget(r); + g->DisbandGroup(true); r->GroupUpdate(groupFree); - groupFree = r->GetFreeGroup(); } - else { //else just add the inviter - r->SendRaidCreate(i); - r->AddMember(i, 0xFFFFFFFF, true, false, true); - } - - Client *addClient = nullptr; - //now add the existing group - for (int x = 0; x < 6; x++) + else // target does not have a group { - if (g->members[x]) { - if (!addClient) + if (ig) { + r = new Raid(i); + entity_list.AddRaid(r); + r->SetRaidDetails(); + Client *addClientig = nullptr; + for (int x = 0; x < 6; x++) { - if (g->members[x]->IsClient()) { - addClient = g->members[x]->CastToClient(); - r->SetGroupLeader(addClient->GetName()); - } - } - if (g->IsLeader(g->members[x])) - { - Client *c = nullptr; - if (g->members[x]->IsClient()) - c = g->members[x]->CastToClient(); - else - continue; - r->SendRaidCreate(c); - r->SendMakeLeaderPacketTo(r->leadername, c); - r->AddMember(c, groupFree, false, true); - r->SendBulkRaid(c); - if (r->IsLocked()) { - r->SendRaidLockTo(c); - } - } - else - { - Client *c = nullptr; - if (g->members[x]->IsClient()) - c = g->members[x]->CastToClient(); - else - continue; - r->SendRaidCreate(c); - r->SendMakeLeaderPacketTo(r->leadername, c); - r->AddMember(c, groupFree); - r->SendBulkRaid(c); - if (r->IsLocked()) { - r->SendRaidLockTo(c); - } - } - } - } - g->JoinRaidXTarget(r); - g->DisbandGroup(true); - r->GroupUpdate(groupFree); - } - else // target does not have a group - { - if (ig) { - r = new Raid(i); - entity_list.AddRaid(r); - r->SetRaidDetails(); - Client *addClientig = nullptr; - for (int x = 0; x < 6; x++) - { - if (ig->members[x]) - { - if (!addClientig) { - if (ig->members[x]->IsClient()) { - addClientig = ig->members[x]->CastToClient(); - r->SetGroupLeader(addClientig->GetName()); - } - } - if (ig->IsLeader(ig->members[x])) + if (ig->members[x]) { - Client *c = nullptr; - if (ig->members[x]->IsClient()) - c = ig->members[x]->CastToClient(); - else - continue; - - r->SendRaidCreate(c); - r->SendMakeLeaderPacketTo(r->leadername, c); - r->AddMember(c, 0, true, true, true); - r->SendBulkRaid(c); - if (r->IsLocked()) { - r->SendRaidLockTo(c); + if (!addClientig) { + if (ig->members[x]->IsClient()) { + addClientig = ig->members[x]->CastToClient(); + r->SetGroupLeader(addClientig->GetName()); + } } - } - else - { - Client *c = nullptr; - if (ig->members[x]->IsClient()) - c = ig->members[x]->CastToClient(); - else - continue; + if (ig->IsLeader(ig->members[x])) + { + Client *c = nullptr; + if (ig->members[x]->IsClient()) + c = ig->members[x]->CastToClient(); + else + continue; - r->SendRaidCreate(c); - r->SendMakeLeaderPacketTo(r->leadername, c); - r->AddMember(c, 0); - r->SendBulkRaid(c); - if (r->IsLocked()) { - r->SendRaidLockTo(c); + r->SendRaidCreate(c); + r->SendMakeLeaderPacketTo(r->leadername, c); + r->AddMember(c, 0, true, true, true); + r->SendBulkRaid(c); + if (r->IsLocked()) { + r->SendRaidLockTo(c); + } + } + else + { + Client *c = nullptr; + if (ig->members[x]->IsClient()) + c = ig->members[x]->CastToClient(); + else + continue; + + r->SendRaidCreate(c); + r->SendMakeLeaderPacketTo(r->leadername, c); + r->AddMember(c, 0); + r->SendBulkRaid(c); + if (r->IsLocked()) { + r->SendRaidLockTo(c); + } } } } + r->SendRaidCreate(this); + r->SendMakeLeaderPacketTo(r->leadername, this); + r->SendBulkRaid(this); + ig->JoinRaidXTarget(r, true); + r->AddMember(this); + ig->DisbandGroup(true); + r->GroupUpdate(0); + if (r->IsLocked()) { + r->SendRaidLockTo(this); + } } - r->SendRaidCreate(this); - r->SendMakeLeaderPacketTo(r->leadername, this); - r->SendBulkRaid(this); - ig->JoinRaidXTarget(r, true); - r->AddMember(this); - ig->DisbandGroup(true); - r->GroupUpdate(0); - if (r->IsLocked()) { - r->SendRaidLockTo(this); - } - } - else { // neither has a group - r = new Raid(i); - entity_list.AddRaid(r); - r->SetRaidDetails(); - r->SendRaidCreate(i); - r->SendRaidCreate(this); - r->SendMakeLeaderPacketTo(r->leadername, this); - r->AddMember(i, 0xFFFFFFFF, true, false, true); - r->SendBulkRaid(this); - r->AddMember(this); - if (r->IsLocked()) { - r->SendRaidLockTo(this); + else { // neither has a group + r = new Raid(i); + entity_list.AddRaid(r); + r->SetRaidDetails(); + r->SendRaidCreate(i); + r->SendRaidCreate(this); + r->SendMakeLeaderPacketTo(r->leadername, this); + r->AddMember(i, 0xFFFFFFFF, true, false, true); + r->SendBulkRaid(this); + r->AddMember(this); + if (r->IsLocked()) { + r->SendRaidLockTo(this); + } } } } } + break; } - break; - } - case RaidCommandDisband: { - Raid *r = entity_list.GetRaidByClient(this); - if (r) { - //if(this == r->GetLeader()){ - uint32 grp = r->GetGroup(ri->leader_name); + case RaidCommandDisband: { + Raid *r = entity_list.GetRaidByClient(this); + if (r) { + //if(this == r->GetLeader()){ + uint32 grp = r->GetGroup(ri->leader_name); - if (grp < 12) { - uint32 i = r->GetPlayerIndex(ri->leader_name); - if (r->members[i].IsGroupLeader) { //assign group leader to someone else - for (int x = 0; x < MAX_RAID_MEMBERS; x++) { - if (strlen(r->members[x].membername) > 0 && i != x) { - if (r->members[x].GroupNumber == grp) { - r->SetGroupLeader(ri->leader_name, false); - r->SetGroupLeader(r->members[x].membername); - r->UpdateGroupAAs(grp); + if (grp < 12) { + uint32 i = r->GetPlayerIndex(ri->leader_name); + if (r->members[i].IsGroupLeader) { //assign group leader to someone else + for (int x = 0; x < MAX_RAID_MEMBERS; x++) { + if (strlen(r->members[x].membername) > 0 && i != x) { + if (r->members[x].GroupNumber == grp) { + r->SetGroupLeader(ri->leader_name, false); + r->SetGroupLeader(r->members[x].membername); + r->UpdateGroupAAs(grp); + break; + } + } + } + + } + if (r->members[i].IsRaidLeader) { + for (int x = 0; x < MAX_RAID_MEMBERS; x++) { + if (strlen(r->members[x].membername) > 0 && strcmp(r->members[x].membername, r->members[i].membername) != 0) + { + r->SetRaidLeader(r->members[i].membername, r->members[x].membername); + r->UpdateRaidAAs(); + r->SendAllRaidLeadershipAA(); break; } } } - } - if (r->members[i].IsRaidLeader) { - for (int x = 0; x < MAX_RAID_MEMBERS; x++) { - if (strlen(r->members[x].membername) > 0 && strcmp(r->members[x].membername, r->members[i].membername) != 0) - { - r->SetRaidLeader(r->members[i].membername, r->members[x].membername); - r->UpdateRaidAAs(); - r->SendAllRaidLeadershipAA(); - break; - } - } - } - } - r->RemoveMember(ri->leader_name); - Client *c = entity_list.GetClientByName(ri->leader_name); - if (c) - r->SendGroupDisband(c); - else { - auto pack = - new ServerPacket(ServerOP_RaidGroupDisband, sizeof(ServerRaidGeneralAction_Struct)); - ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - rga->rid = GetID(); - rga->zoneid = zone->GetZoneID(); - rga->instance_id = zone->GetInstanceID(); - strn0cpy(rga->playername, ri->leader_name, 64); - worldserver.SendPacket(pack); - safe_delete(pack); + r->RemoveMember(ri->leader_name); + Client *c = entity_list.GetClientByName(ri->leader_name); + if (c) + r->SendGroupDisband(c); + else { + auto pack = + new ServerPacket(ServerOP_RaidGroupDisband, sizeof(ServerRaidGeneralAction_Struct)); + ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; + rga->rid = GetID(); + rga->zoneid = zone->GetZoneID(); + rga->instance_id = zone->GetInstanceID(); + strn0cpy(rga->playername, ri->leader_name, 64); + worldserver.SendPacket(pack); + safe_delete(pack); + } + //r->SendRaidGroupRemove(ri->leader_name, grp); + r->GroupUpdate(grp);// break + //} } - //r->SendRaidGroupRemove(ri->leader_name, grp); - r->GroupUpdate(grp);// break - //} + break; } - break; - } - case RaidCommandMoveGroup: - { - Raid *r = entity_list.GetRaidByClient(this); - if (r) + case RaidCommandMoveGroup: { - if (ri->parameter < 12) //moving to a group + Raid *r = entity_list.GetRaidByClient(this); + if (r) { - uint8 grpcount = r->GroupCount(ri->parameter); - - if (grpcount < 6) + if (ri->parameter < 12) //moving to a group { - Client *c = entity_list.GetClientByName(ri->leader_name); - uint32 oldgrp = r->GetGroup(ri->leader_name); - if (ri->parameter == oldgrp) //don't rejoin grp if we order to join same group. - break; + uint8 grpcount = r->GroupCount(ri->parameter); - if (r->members[r->GetPlayerIndex(ri->leader_name)].IsGroupLeader) + if (grpcount < 6) { - r->SetGroupLeader(ri->leader_name, false); - if (oldgrp < 12) { //we were the leader of our old grp - for (int x = 0; x < MAX_RAID_MEMBERS; x++) //assign a new grp leader if we can - { - if (r->members[x].GroupNumber == oldgrp) + Client *c = entity_list.GetClientByName(ri->leader_name); + uint32 oldgrp = r->GetGroup(ri->leader_name); + if (ri->parameter == oldgrp) //don't rejoin grp if we order to join same group. + break; + + if (r->members[r->GetPlayerIndex(ri->leader_name)].IsGroupLeader) + { + r->SetGroupLeader(ri->leader_name, false); + if (oldgrp < 12) { //we were the leader of our old grp + for (int x = 0; x < MAX_RAID_MEMBERS; x++) //assign a new grp leader if we can { - if (strcmp(ri->leader_name, r->members[x].membername) != 0 && strlen(ri->leader_name) > 0) + if (r->members[x].GroupNumber == oldgrp) { - r->SetGroupLeader(r->members[x].membername); - r->UpdateGroupAAs(oldgrp); - Client *cgl = entity_list.GetClientByName(r->members[x].membername); - if (cgl) { - r->SendRaidRemove(r->members[x].membername, cgl); - r->SendRaidCreate(cgl); - r->SendMakeLeaderPacketTo(r->leadername, cgl); - r->SendRaidAdd(r->members[x].membername, cgl); - r->SendBulkRaid(cgl); - if (r->IsLocked()) { - r->SendRaidLockTo(cgl); + if (strcmp(ri->leader_name, r->members[x].membername) != 0 && strlen(ri->leader_name) > 0) + { + r->SetGroupLeader(r->members[x].membername); + r->UpdateGroupAAs(oldgrp); + Client *cgl = entity_list.GetClientByName(r->members[x].membername); + if (cgl) { + r->SendRaidRemove(r->members[x].membername, cgl); + r->SendRaidCreate(cgl); + r->SendMakeLeaderPacketTo(r->leadername, cgl); + r->SendRaidAdd(r->members[x].membername, cgl); + r->SendBulkRaid(cgl); + if (r->IsLocked()) { + r->SendRaidLockTo(cgl); + } } + else { + auto pack = new ServerPacket( + ServerOP_RaidChangeGroup, + sizeof( + ServerRaidGeneralAction_Struct)); + ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; + rga->rid = r->GetID(); + strn0cpy(rga->playername, r->members[x].membername, 64); + rga->zoneid = zone->GetZoneID(); + rga->instance_id = zone->GetInstanceID(); + worldserver.SendPacket(pack); + safe_delete(pack); + } + break; } - else { - auto pack = new ServerPacket( - ServerOP_RaidChangeGroup, - sizeof( - ServerRaidGeneralAction_Struct)); - ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - rga->rid = r->GetID(); - strn0cpy(rga->playername, r->members[x].membername, 64); - rga->zoneid = zone->GetZoneID(); - rga->instance_id = zone->GetInstanceID(); - worldserver.SendPacket(pack); - safe_delete(pack); - } - break; } } } } - } - if (grpcount == 0) { - r->SetGroupLeader(ri->leader_name); - r->UpdateGroupAAs(ri->parameter); - } + if (grpcount == 0) { + r->SetGroupLeader(ri->leader_name); + r->UpdateGroupAAs(ri->parameter); + } - r->MoveMember(ri->leader_name, ri->parameter); + r->MoveMember(ri->leader_name, ri->parameter); + if (c) { + r->SendGroupDisband(c); + } + else { + auto pack = new ServerPacket(ServerOP_RaidGroupDisband, + sizeof(ServerRaidGeneralAction_Struct)); + ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; + rga->rid = r->GetID(); + rga->zoneid = zone->GetZoneID(); + rga->instance_id = zone->GetInstanceID(); + strn0cpy(rga->playername, ri->leader_name, 64); + worldserver.SendPacket(pack); + safe_delete(pack); + } + //r->SendRaidGroupAdd(ri->leader_name, ri->parameter); + //r->SendRaidGroupRemove(ri->leader_name, oldgrp); + //r->SendGroupUpdate(c); + //break + r->GroupUpdate(ri->parameter); //send group update to our new group + if (oldgrp < 12) //if our old was a group send update there too + r->GroupUpdate(oldgrp); + + //r->SendMakeGroupLeaderPacketAll(); + } + } + else //moving to ungrouped + { + Client *c = entity_list.GetClientByName(ri->leader_name); + uint32 oldgrp = r->GetGroup(ri->leader_name); + if (r->members[r->GetPlayerIndex(ri->leader_name)].IsGroupLeader) { + r->SetGroupLeader(ri->leader_name, false); + for (int x = 0; x < MAX_RAID_MEMBERS; x++) + { + if (r->members[x].GroupNumber == oldgrp && strlen(r->members[x].membername) > 0 && strcmp(r->members[x].membername, ri->leader_name) != 0) + { + r->SetGroupLeader(r->members[x].membername); + r->UpdateGroupAAs(oldgrp); + Client *cgl = entity_list.GetClientByName(r->members[x].membername); + if (cgl) { + r->SendRaidRemove(r->members[x].membername, cgl); + r->SendRaidCreate(cgl); + r->SendMakeLeaderPacketTo(r->leadername, cgl); + r->SendRaidAdd(r->members[x].membername, cgl); + r->SendBulkRaid(cgl); + if (r->IsLocked()) { + r->SendRaidLockTo(cgl); + } + } + else { + auto pack = new ServerPacket( + ServerOP_RaidChangeGroup, + sizeof(ServerRaidGeneralAction_Struct)); + ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; + rga->rid = r->GetID(); + strn0cpy(rga->playername, r->members[x].membername, 64); + rga->zoneid = zone->GetZoneID(); + rga->instance_id = zone->GetInstanceID(); + worldserver.SendPacket(pack); + safe_delete(pack); + } + break; + } + } + } + r->MoveMember(ri->leader_name, 0xFFFFFFFF); if (c) { r->SendGroupDisband(c); } @@ -11371,169 +11436,117 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) worldserver.SendPacket(pack); safe_delete(pack); } - //r->SendRaidGroupAdd(ri->leader_name, ri->parameter); //r->SendRaidGroupRemove(ri->leader_name, oldgrp); - //r->SendGroupUpdate(c); - //break - r->GroupUpdate(ri->parameter); //send group update to our new group - if (oldgrp < 12) //if our old was a group send update there too - r->GroupUpdate(oldgrp); - + r->GroupUpdate(oldgrp); //r->SendMakeGroupLeaderPacketAll(); } } - else //moving to ungrouped - { - Client *c = entity_list.GetClientByName(ri->leader_name); - uint32 oldgrp = r->GetGroup(ri->leader_name); - if (r->members[r->GetPlayerIndex(ri->leader_name)].IsGroupLeader) { - r->SetGroupLeader(ri->leader_name, false); - for (int x = 0; x < MAX_RAID_MEMBERS; x++) - { - if (r->members[x].GroupNumber == oldgrp && strlen(r->members[x].membername) > 0 && strcmp(r->members[x].membername, ri->leader_name) != 0) - { - r->SetGroupLeader(r->members[x].membername); - r->UpdateGroupAAs(oldgrp); - Client *cgl = entity_list.GetClientByName(r->members[x].membername); - if (cgl) { - r->SendRaidRemove(r->members[x].membername, cgl); - r->SendRaidCreate(cgl); - r->SendMakeLeaderPacketTo(r->leadername, cgl); - r->SendRaidAdd(r->members[x].membername, cgl); - r->SendBulkRaid(cgl); - if (r->IsLocked()) { - r->SendRaidLockTo(cgl); - } - } - else { - auto pack = new ServerPacket( - ServerOP_RaidChangeGroup, - sizeof(ServerRaidGeneralAction_Struct)); - ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - rga->rid = r->GetID(); - strn0cpy(rga->playername, r->members[x].membername, 64); - rga->zoneid = zone->GetZoneID(); - rga->instance_id = zone->GetInstanceID(); - worldserver.SendPacket(pack); - safe_delete(pack); - } - break; - } - } - } - r->MoveMember(ri->leader_name, 0xFFFFFFFF); - if (c) { - r->SendGroupDisband(c); - } - else { - auto pack = new ServerPacket(ServerOP_RaidGroupDisband, - sizeof(ServerRaidGeneralAction_Struct)); - ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - rga->rid = r->GetID(); - rga->zoneid = zone->GetZoneID(); - rga->instance_id = zone->GetInstanceID(); - strn0cpy(rga->playername, ri->leader_name, 64); - worldserver.SendPacket(pack); - safe_delete(pack); - } - //r->SendRaidGroupRemove(ri->leader_name, oldgrp); - r->GroupUpdate(oldgrp); - //r->SendMakeGroupLeaderPacketAll(); + + Client *client_moved = entity_list.GetClientByName(ri->leader_name); + + if (client_moved) { + client_moved->GetRaid()->SendHPManaEndPacketsTo(client_moved); + client_moved->GetRaid()->SendHPManaEndPacketsFrom(client_moved); + + Log(Logs::General, Logs::HP_Update, + "Client::Handle_OP_RaidCommand :: %s sending and recieving HP/Mana/End updates", + client_moved->GetCleanName() + ); } - } - break; - } - case RaidCommandRaidLock: - { - Raid *r = entity_list.GetRaidByClient(this); - if (r) - { - if (!r->IsLocked()) - r->LockRaid(true); - else - r->SendRaidLockTo(this); - } - break; - } - case RaidCommandRaidUnlock: - { - Raid *r = entity_list.GetRaidByClient(this); - if (r) - { - if (r->IsLocked()) - r->LockRaid(false); - else - r->SendRaidUnlockTo(this); - } - break; - } - case RaidCommandLootType2: - case RaidCommandLootType: - { - Raid *r = entity_list.GetRaidByClient(this); - if (r) - { - Message(15, "Loot type changed to: %d.", ri->parameter); - r->ChangeLootType(ri->parameter); - } - break; - } - case RaidCommandAddLooter2: - case RaidCommandAddLooter: - { - Raid *r = entity_list.GetRaidByClient(this); - if (r) - { - Message(15, "Adding %s as a raid looter.", ri->leader_name); - r->AddRaidLooter(ri->leader_name); - } - break; - } - - case RaidCommandRemoveLooter2: - case RaidCommandRemoveLooter: - { - Raid *r = entity_list.GetRaidByClient(this); - if (r) - { - Message(15, "Removing %s as a raid looter.", ri->leader_name); - r->RemoveRaidLooter(ri->leader_name); - } - break; - } - - case RaidCommandMakeLeader: - { - Raid *r = entity_list.GetRaidByClient(this); - if (r) - { - if (strcmp(r->leadername, GetName()) == 0) { - r->SetRaidLeader(GetName(), ri->leader_name); - r->UpdateRaidAAs(); - r->SendAllRaidLeadershipAA(); - } - } - break; - } - - case RaidCommandSetMotd: - { - Raid *r = entity_list.GetRaidByClient(this); - if (!r) break; - // we don't use the RaidGeneral here! - RaidMOTD_Struct *motd = (RaidMOTD_Struct *)app->pBuffer; - r->SetRaidMOTD(std::string(motd->motd)); - r->SaveRaidMOTD(); - r->SendRaidMOTDToWorld(); - break; - } + } + case RaidCommandRaidLock: + { + Raid *r = entity_list.GetRaidByClient(this); + if (r) + { + if (!r->IsLocked()) + r->LockRaid(true); + else + r->SendRaidLockTo(this); + } + break; + } + case RaidCommandRaidUnlock: + { + Raid *r = entity_list.GetRaidByClient(this); + if (r) + { + if (r->IsLocked()) + r->LockRaid(false); + else + r->SendRaidUnlockTo(this); + } + break; + } + case RaidCommandLootType2: + case RaidCommandLootType: + { + Raid *r = entity_list.GetRaidByClient(this); + if (r) + { + Message(15, "Loot type changed to: %d.", ri->parameter); + r->ChangeLootType(ri->parameter); + } + break; + } - default: { - Message(13, "Raid command (%d) NYI", ri->action); - break; - } + case RaidCommandAddLooter2: + case RaidCommandAddLooter: + { + Raid *r = entity_list.GetRaidByClient(this); + if (r) + { + Message(15, "Adding %s as a raid looter.", ri->leader_name); + r->AddRaidLooter(ri->leader_name); + } + break; + } + + case RaidCommandRemoveLooter2: + case RaidCommandRemoveLooter: + { + Raid *r = entity_list.GetRaidByClient(this); + if (r) + { + Message(15, "Removing %s as a raid looter.", ri->leader_name); + r->RemoveRaidLooter(ri->leader_name); + } + break; + } + + case RaidCommandMakeLeader: + { + Raid *r = entity_list.GetRaidByClient(this); + if (r) + { + if (strcmp(r->leadername, GetName()) == 0) { + r->SetRaidLeader(GetName(), ri->leader_name); + r->UpdateRaidAAs(); + r->SendAllRaidLeadershipAA(); + } + } + break; + } + + case RaidCommandSetMotd: + { + Raid *r = entity_list.GetRaidByClient(this); + if (!r) + break; + // we don't use the RaidGeneral here! + RaidMOTD_Struct *motd = (RaidMOTD_Struct *)app->pBuffer; + r->SetRaidMOTD(std::string(motd->motd)); + r->SaveRaidMOTD(); + r->SendRaidMOTDToWorld(); + break; + } + + default: { + Message(13, "Raid command (%d) NYI", ri->action); + break; + } } } diff --git a/zone/mob.cpp b/zone/mob.cpp index 33863081a..924f26b69 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -1383,7 +1383,7 @@ void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= fal if(IsClient()){ Raid *raid = entity_list.GetRaidByClient(CastToClient()); if (raid) - raid->SendHPPacketsFrom(this); + raid->SendHPManaEndPacketsFrom(this); } /* Pet - Update master - group and raid if exists */ @@ -1396,7 +1396,7 @@ void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= fal Raid *raid = entity_list.GetRaidByClient(GetOwner()->CastToClient()); if(raid) - raid->SendHPPacketsFrom(this); + raid->SendHPManaEndPacketsFrom(this); } /* Send to pet */ diff --git a/zone/raids.cpp b/zone/raids.cpp index 26845910c..7496d3686 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -149,7 +149,7 @@ void Raid::AddMember(Client *c, uint32 group, bool rleader, bool groupleader, bo raid_update = c->GetRaid(); if (raid_update) { raid_update->SendHPManaEndPacketsTo(c); - raid_update->SendHPPacketsFrom(c); + raid_update->SendHPManaEndPacketsFrom(c); } auto pack = new ServerPacket(ServerOP_RaidAdd, sizeof(ServerRaidGeneralAction_Struct)); @@ -1591,7 +1591,7 @@ void Raid::SendHPManaEndPacketsTo(Client *client) } } -void Raid::SendHPPacketsFrom(Mob *mob) +void Raid::SendHPManaEndPacketsFrom(Mob *mob) { if(!mob) return; diff --git a/zone/raids.h b/zone/raids.h index df43d7755..068a876ac 100644 --- a/zone/raids.h +++ b/zone/raids.h @@ -174,7 +174,7 @@ public: void VerifyRaid(); void MemberZoned(Client *c); void SendHPManaEndPacketsTo(Client *c); - void SendHPPacketsFrom(Mob *mob); + void SendHPManaEndPacketsFrom(Mob *mob); void SendManaPacketFrom(Mob *mob); void SendEndurancePacketFrom(Mob *mob); void RaidSay(const char *msg, Client *c); From 7a263c032de96a6a2d7b7f191215708a6aeaeb3c Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 21 Aug 2017 21:44:28 -0500 Subject: [PATCH 05/97] [Readability] Clean up some of the raid command code to be more understandable --- zone/client_packet.cpp | 691 +++++++++++++++++++++-------------------- 1 file changed, 350 insertions(+), 341 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index f9de65fd9..a81e0ac85 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -10948,289 +10948,307 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) return; } - RaidGeneral_Struct *ri = (RaidGeneral_Struct*)app->pBuffer; - switch (ri->action) + RaidGeneral_Struct *raid_command_packet = (RaidGeneral_Struct*)app->pBuffer; + switch (raid_command_packet->action) { case RaidCommandInviteIntoExisting: case RaidCommandInvite: { - Client *i = entity_list.GetClientByName(ri->player_name); - if (!i) + + Client *player_to_invite = entity_list.GetClientByName(raid_command_packet->player_name); + + if (!player_to_invite) break; - Group *g = i->GetGroup(); - // These two messages should be generated by the client I think, just do this for now - if (i->HasRaid()) { - Message(13, "%s is already in a raid.", i->GetName()); + + Group *player_to_invite_group = player_to_invite->GetGroup(); + + if (player_to_invite->HasRaid()) { + Message(13, "%s is already in a raid.", player_to_invite->GetName()); break; } - if (g && !g->IsLeader(i)) { + + if (player_to_invite_group && !player_to_invite_group->IsLeader(player_to_invite)) { Message(13, "You can only invite an ungrouped player or group leader to join your raid."); break; } - //This sends an "invite" to the client in question. + + /* Send out invite to the client */ auto outapp = new EQApplicationPacket(OP_RaidUpdate, sizeof(RaidGeneral_Struct)); - RaidGeneral_Struct *rg = (RaidGeneral_Struct*)outapp->pBuffer; - strn0cpy(rg->leader_name, ri->leader_name, 64); - strn0cpy(rg->player_name, ri->player_name, 64); + RaidGeneral_Struct *raid_command = (RaidGeneral_Struct*)outapp->pBuffer; - rg->parameter = 0; - rg->action = 20; - i->QueuePacket(outapp); + strn0cpy(raid_command->leader_name, raid_command_packet->leader_name, 64); + strn0cpy(raid_command->player_name, raid_command_packet->player_name, 64); + + raid_command->parameter = 0; + raid_command->action = 20; + + player_to_invite->QueuePacket(outapp); + safe_delete(outapp); + break; } case RaidCommandAcceptInvite: { - Client *i = entity_list.GetClientByName(ri->player_name); - if (i) { + Client *player_accepting_invite = entity_list.GetClientByName(raid_command_packet->player_name); + if (player_accepting_invite) { if (IsRaidGrouped()) { - i->Message_StringID(0, ALREADY_IN_RAID, GetName()); //group failed, must invite members not in raid... + player_accepting_invite->Message_StringID(0, ALREADY_IN_RAID, GetName()); //group failed, must invite members not in raid... return; } - Raid *r = entity_list.GetRaidByClient(i); - if (r) { - r->VerifyRaid(); - Group *g = GetGroup(); - if (g) { - if (g->GroupCount() + r->RaidCount() > MAX_RAID_MEMBERS) - { - i->Message(13, "Invite failed, group invite would create a raid larger than the maximum number of members allowed."); + Raid *raid = entity_list.GetRaidByClient(player_accepting_invite); + if (raid) { + raid->VerifyRaid(); + Group *group = GetGroup(); + if (group) { + if (group->GroupCount() + raid->RaidCount() > MAX_RAID_MEMBERS) { + player_accepting_invite->Message(13, "Invite failed, group invite would create a raid larger than the maximum number of members allowed."); return; } } else { - if (1 + r->RaidCount() > MAX_RAID_MEMBERS) - { - i->Message(13, "Invite failed, member invite would create a raid larger than the maximum number of members allowed."); + if (1 + raid->RaidCount() > MAX_RAID_MEMBERS) { + player_accepting_invite->Message(13, "Invite failed, member invite would create a raid larger than the maximum number of members allowed."); return; } } - if (g) {//add us all - uint32 freeGroup = r->GetFreeGroup(); + if (group) {//add us all + uint32 free_group_id = raid->GetFreeGroup(); Client *addClient = nullptr; - for (int x = 0; x < 6; x++) - { - if (g->members[x]) { + for (int x = 0; x < 6; x++) { + if (group->members[x]) { Client *c = nullptr; - if (g->members[x]->IsClient()) - c = g->members[x]->CastToClient(); + if (group->members[x]->IsClient()) + c = group->members[x]->CastToClient(); else continue; if (!addClient) { addClient = c; - r->SetGroupLeader(addClient->GetName()); + raid->SetGroupLeader(addClient->GetName()); } - r->SendRaidCreate(c); - r->SendMakeLeaderPacketTo(r->leadername, c); - if (g->IsLeader(g->members[x])) - r->AddMember(c, freeGroup, false, true); + raid->SendRaidCreate(c); + raid->SendMakeLeaderPacketTo(raid->leadername, c); + if (group->IsLeader(group->members[x])) + raid->AddMember(c, free_group_id, false, true); else - r->AddMember(c, freeGroup); - r->SendBulkRaid(c); - if (r->IsLocked()) { - r->SendRaidLockTo(c); + raid->AddMember(c, free_group_id); + raid->SendBulkRaid(c); + if (raid->IsLocked()) { + raid->SendRaidLockTo(c); } } } - g->JoinRaidXTarget(r); - g->DisbandGroup(true); - r->GroupUpdate(freeGroup); + group->JoinRaidXTarget(raid); + group->DisbandGroup(true); + raid->GroupUpdate(free_group_id); } else { - r->SendRaidCreate(this); - r->SendMakeLeaderPacketTo(r->leadername, this); - r->AddMember(this); - r->SendBulkRaid(this); - if (r->IsLocked()) { - r->SendRaidLockTo(this); + raid->SendRaidCreate(this); + raid->SendMakeLeaderPacketTo(raid->leadername, this); + raid->AddMember(this); + raid->SendBulkRaid(this); + if (raid->IsLocked()) { + raid->SendRaidLockTo(this); } } } else { - Group *ig = i->GetGroup(); - Group *g = GetGroup(); - if (g) //if our target has a group + Group *player_invited_group = player_accepting_invite->GetGroup(); + Group *group = GetGroup(); + if (group) //if our target has a group { - r = new Raid(i); - entity_list.AddRaid(r); - r->SetRaidDetails(); + raid = new Raid(player_accepting_invite); + entity_list.AddRaid(raid); + raid->SetRaidDetails(); - uint32 groupFree = r->GetFreeGroup(); //get a free group - if (ig) { //if we already have a group then cycle through adding us... - Client *addClientig = nullptr; - for (int x = 0; x < 6; x++) - { - if (ig->members[x]) { - if (!addClientig) { - if (ig->members[x]->IsClient()) { - addClientig = ig->members[x]->CastToClient(); - r->SetGroupLeader(addClientig->GetName()); + uint32 raid_free_group_id = raid->GetFreeGroup(); + + /* If we already have a group then cycle through adding us... */ + if (player_invited_group) { + Client *client_to_be_leader = nullptr; + for (int x = 0; x < 6; x++) { + if (player_invited_group->members[x]) { + if (!client_to_be_leader) { + if (player_invited_group->members[x]->IsClient()) { + client_to_be_leader = player_invited_group->members[x]->CastToClient(); + raid->SetGroupLeader(client_to_be_leader->GetName()); } } - if (ig->IsLeader(ig->members[x])) { + if (player_invited_group->IsLeader(player_invited_group->members[x])) { Client *c = nullptr; - if (ig->members[x]->IsClient()) - c = ig->members[x]->CastToClient(); + + if (player_invited_group->members[x]->IsClient()) + c = player_invited_group->members[x]->CastToClient(); else continue; - r->SendRaidCreate(c); - r->SendMakeLeaderPacketTo(r->leadername, c); - r->AddMember(c, groupFree, true, true, true); - r->SendBulkRaid(c); - if (r->IsLocked()) { - r->SendRaidLockTo(c); + + raid->SendRaidCreate(c); + raid->SendMakeLeaderPacketTo(raid->leadername, c); + raid->AddMember(c, raid_free_group_id, true, true, true); + raid->SendBulkRaid(c); + + if (raid->IsLocked()) { + raid->SendRaidLockTo(c); } } else { Client *c = nullptr; - if (ig->members[x]->IsClient()) - c = ig->members[x]->CastToClient(); + + if (player_invited_group->members[x]->IsClient()) + c = player_invited_group->members[x]->CastToClient(); else continue; - r->SendRaidCreate(c); - r->SendMakeLeaderPacketTo(r->leadername, c); - r->AddMember(c, groupFree); - r->SendBulkRaid(c); - if (r->IsLocked()) { - r->SendRaidLockTo(c); + + raid->SendRaidCreate(c); + raid->SendMakeLeaderPacketTo(raid->leadername, c); + raid->AddMember(c, raid_free_group_id); + raid->SendBulkRaid(c); + + if (raid->IsLocked()) { + raid->SendRaidLockTo(c); } } } } - ig->JoinRaidXTarget(r, true); - ig->DisbandGroup(true); - r->GroupUpdate(groupFree); - groupFree = r->GetFreeGroup(); + player_invited_group->JoinRaidXTarget(raid, true); + player_invited_group->DisbandGroup(true); + raid->GroupUpdate(raid_free_group_id); + raid_free_group_id = raid->GetFreeGroup(); } - else { //else just add the inviter - r->SendRaidCreate(i); - r->AddMember(i, 0xFFFFFFFF, true, false, true); + else { + raid->SendRaidCreate(player_accepting_invite); + raid->AddMember(player_accepting_invite, 0xFFFFFFFF, true, false, true); } - Client *addClient = nullptr; - //now add the existing group - for (int x = 0; x < 6; x++) - { - if (g->members[x]) { - if (!addClient) - { - if (g->members[x]->IsClient()) { - addClient = g->members[x]->CastToClient(); - r->SetGroupLeader(addClient->GetName()); + Client *client_to_add = nullptr; + /* Add client to an existing group */ + for (int x = 0; x < 6; x++) { + if (group->members[x]) { + if (!client_to_add) { + if (group->members[x]->IsClient()) { + client_to_add = group->members[x]->CastToClient(); + raid->SetGroupLeader(client_to_add->GetName()); } } - if (g->IsLeader(g->members[x])) - { + if (group->IsLeader(group->members[x])) { Client *c = nullptr; - if (g->members[x]->IsClient()) - c = g->members[x]->CastToClient(); + + if (group->members[x]->IsClient()) + c = group->members[x]->CastToClient(); else continue; - r->SendRaidCreate(c); - r->SendMakeLeaderPacketTo(r->leadername, c); - r->AddMember(c, groupFree, false, true); - r->SendBulkRaid(c); - if (r->IsLocked()) { - r->SendRaidLockTo(c); + + raid->SendRaidCreate(c); + raid->SendMakeLeaderPacketTo(raid->leadername, c); + raid->AddMember(c, raid_free_group_id, false, true); + raid->SendBulkRaid(c); + + if (raid->IsLocked()) { + raid->SendRaidLockTo(c); } } else { Client *c = nullptr; - if (g->members[x]->IsClient()) - c = g->members[x]->CastToClient(); + + if (group->members[x]->IsClient()) + c = group->members[x]->CastToClient(); else continue; - r->SendRaidCreate(c); - r->SendMakeLeaderPacketTo(r->leadername, c); - r->AddMember(c, groupFree); - r->SendBulkRaid(c); - if (r->IsLocked()) { - r->SendRaidLockTo(c); + + raid->SendRaidCreate(c); + raid->SendMakeLeaderPacketTo(raid->leadername, c); + raid->AddMember(c, raid_free_group_id); + raid->SendBulkRaid(c); + + if (raid->IsLocked()) { + raid->SendRaidLockTo(c); } } } } - g->JoinRaidXTarget(r); - g->DisbandGroup(true); - r->GroupUpdate(groupFree); + group->JoinRaidXTarget(raid); + group->DisbandGroup(true); + + raid->GroupUpdate(raid_free_group_id); } - else // target does not have a group - { - if (ig) { - r = new Raid(i); - entity_list.AddRaid(r); - r->SetRaidDetails(); + /* Target does not have a group */ + else { + if (player_invited_group) { + + raid = new Raid(player_accepting_invite); + + entity_list.AddRaid(raid); + raid->SetRaidDetails(); Client *addClientig = nullptr; - for (int x = 0; x < 6; x++) - { - if (ig->members[x]) - { + for (int x = 0; x < 6; x++) { + if (player_invited_group->members[x]) { if (!addClientig) { - if (ig->members[x]->IsClient()) { - addClientig = ig->members[x]->CastToClient(); - r->SetGroupLeader(addClientig->GetName()); + if (player_invited_group->members[x]->IsClient()) { + addClientig = player_invited_group->members[x]->CastToClient(); + raid->SetGroupLeader(addClientig->GetName()); } } - if (ig->IsLeader(ig->members[x])) - { + if (player_invited_group->IsLeader(player_invited_group->members[x])) { Client *c = nullptr; - if (ig->members[x]->IsClient()) - c = ig->members[x]->CastToClient(); + + if (player_invited_group->members[x]->IsClient()) + c = player_invited_group->members[x]->CastToClient(); else continue; - r->SendRaidCreate(c); - r->SendMakeLeaderPacketTo(r->leadername, c); - r->AddMember(c, 0, true, true, true); - r->SendBulkRaid(c); - if (r->IsLocked()) { - r->SendRaidLockTo(c); + raid->SendRaidCreate(c); + raid->SendMakeLeaderPacketTo(raid->leadername, c); + raid->AddMember(c, 0, true, true, true); + raid->SendBulkRaid(c); + + if (raid->IsLocked()) { + raid->SendRaidLockTo(c); } } else { Client *c = nullptr; - if (ig->members[x]->IsClient()) - c = ig->members[x]->CastToClient(); + if (player_invited_group->members[x]->IsClient()) + c = player_invited_group->members[x]->CastToClient(); else continue; - r->SendRaidCreate(c); - r->SendMakeLeaderPacketTo(r->leadername, c); - r->AddMember(c, 0); - r->SendBulkRaid(c); - if (r->IsLocked()) { - r->SendRaidLockTo(c); + raid->SendRaidCreate(c); + raid->SendMakeLeaderPacketTo(raid->leadername, c); + raid->AddMember(c, 0); + raid->SendBulkRaid(c); + if (raid->IsLocked()) { + raid->SendRaidLockTo(c); } } } } - r->SendRaidCreate(this); - r->SendMakeLeaderPacketTo(r->leadername, this); - r->SendBulkRaid(this); - ig->JoinRaidXTarget(r, true); - r->AddMember(this); - ig->DisbandGroup(true); - r->GroupUpdate(0); - if (r->IsLocked()) { - r->SendRaidLockTo(this); + raid->SendRaidCreate(this); + raid->SendMakeLeaderPacketTo(raid->leadername, this); + raid->SendBulkRaid(this); + player_invited_group->JoinRaidXTarget(raid, true); + raid->AddMember(this); + player_invited_group->DisbandGroup(true); + raid->GroupUpdate(0); + if (raid->IsLocked()) { + raid->SendRaidLockTo(this); } } else { // neither has a group - r = new Raid(i); - entity_list.AddRaid(r); - r->SetRaidDetails(); - r->SendRaidCreate(i); - r->SendRaidCreate(this); - r->SendMakeLeaderPacketTo(r->leadername, this); - r->AddMember(i, 0xFFFFFFFF, true, false, true); - r->SendBulkRaid(this); - r->AddMember(this); - if (r->IsLocked()) { - r->SendRaidLockTo(this); + raid = new Raid(player_accepting_invite); + entity_list.AddRaid(raid); + raid->SetRaidDetails(); + raid->SendRaidCreate(player_accepting_invite); + raid->SendRaidCreate(this); + raid->SendMakeLeaderPacketTo(raid->leadername, this); + raid->AddMember(player_accepting_invite, 0xFFFFFFFF, true, false, true); + raid->SendBulkRaid(this); + raid->AddMember(this); + if (raid->IsLocked()) { + raid->SendRaidLockTo(this); } } } @@ -11239,43 +11257,42 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) break; } case RaidCommandDisband: { - Raid *r = entity_list.GetRaidByClient(this); - if (r) { - //if(this == r->GetLeader()){ - uint32 grp = r->GetGroup(ri->leader_name); + Raid *raid = entity_list.GetRaidByClient(this); + if (raid) { + uint32 group = raid->GetGroup(raid_command_packet->leader_name); - if (grp < 12) { - uint32 i = r->GetPlayerIndex(ri->leader_name); - if (r->members[i].IsGroupLeader) { //assign group leader to someone else + if (group < 12) { + uint32 i = raid->GetPlayerIndex(raid_command_packet->leader_name); + if (raid->members[i].IsGroupLeader) { //assign group leader to someone else for (int x = 0; x < MAX_RAID_MEMBERS; x++) { - if (strlen(r->members[x].membername) > 0 && i != x) { - if (r->members[x].GroupNumber == grp) { - r->SetGroupLeader(ri->leader_name, false); - r->SetGroupLeader(r->members[x].membername); - r->UpdateGroupAAs(grp); + if (strlen(raid->members[x].membername) > 0 && i != x) { + if (raid->members[x].GroupNumber == group) { + raid->SetGroupLeader(raid_command_packet->leader_name, false); + raid->SetGroupLeader(raid->members[x].membername); + raid->UpdateGroupAAs(group); break; } } } } - if (r->members[i].IsRaidLeader) { + if (raid->members[i].IsRaidLeader) { for (int x = 0; x < MAX_RAID_MEMBERS; x++) { - if (strlen(r->members[x].membername) > 0 && strcmp(r->members[x].membername, r->members[i].membername) != 0) + if (strlen(raid->members[x].membername) > 0 && strcmp(raid->members[x].membername, raid->members[i].membername) != 0) { - r->SetRaidLeader(r->members[i].membername, r->members[x].membername); - r->UpdateRaidAAs(); - r->SendAllRaidLeadershipAA(); + raid->SetRaidLeader(raid->members[i].membername, raid->members[x].membername); + raid->UpdateRaidAAs(); + raid->SendAllRaidLeadershipAA(); break; } } } } - r->RemoveMember(ri->leader_name); - Client *c = entity_list.GetClientByName(ri->leader_name); + raid->RemoveMember(raid_command_packet->leader_name); + Client *c = entity_list.GetClientByName(raid_command_packet->leader_name); if (c) - r->SendGroupDisband(c); + raid->SendGroupDisband(c); else { auto pack = new ServerPacket(ServerOP_RaidGroupDisband, sizeof(ServerRaidGeneralAction_Struct)); @@ -11283,66 +11300,64 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) rga->rid = GetID(); rga->zoneid = zone->GetZoneID(); rga->instance_id = zone->GetInstanceID(); - strn0cpy(rga->playername, ri->leader_name, 64); + strn0cpy(rga->playername, raid_command_packet->leader_name, 64); worldserver.SendPacket(pack); safe_delete(pack); } //r->SendRaidGroupRemove(ri->leader_name, grp); - r->GroupUpdate(grp);// break + raid->GroupUpdate(group);// break //} } break; } case RaidCommandMoveGroup: { - Raid *r = entity_list.GetRaidByClient(this); - if (r) - { - if (ri->parameter < 12) //moving to a group - { - uint8 grpcount = r->GroupCount(ri->parameter); + Raid *raid = entity_list.GetRaidByClient(this); + if (raid) { + /* Moving to group */ + if (raid_command_packet->parameter < 12) { + uint8 group_count = raid->GroupCount(raid_command_packet->parameter); - if (grpcount < 6) - { - Client *c = entity_list.GetClientByName(ri->leader_name); - uint32 oldgrp = r->GetGroup(ri->leader_name); - if (ri->parameter == oldgrp) //don't rejoin grp if we order to join same group. + if (group_count < 6) { + Client *c = entity_list.GetClientByName(raid_command_packet->leader_name); + uint32 old_group = raid->GetGroup(raid_command_packet->leader_name); + if (raid_command_packet->parameter == old_group) //don't rejoin grp if we order to join same group. break; - if (r->members[r->GetPlayerIndex(ri->leader_name)].IsGroupLeader) - { - r->SetGroupLeader(ri->leader_name, false); - if (oldgrp < 12) { //we were the leader of our old grp - for (int x = 0; x < MAX_RAID_MEMBERS; x++) //assign a new grp leader if we can - { - if (r->members[x].GroupNumber == oldgrp) - { - if (strcmp(ri->leader_name, r->members[x].membername) != 0 && strlen(ri->leader_name) > 0) - { - r->SetGroupLeader(r->members[x].membername); - r->UpdateGroupAAs(oldgrp); - Client *cgl = entity_list.GetClientByName(r->members[x].membername); - if (cgl) { - r->SendRaidRemove(r->members[x].membername, cgl); - r->SendRaidCreate(cgl); - r->SendMakeLeaderPacketTo(r->leadername, cgl); - r->SendRaidAdd(r->members[x].membername, cgl); - r->SendBulkRaid(cgl); - if (r->IsLocked()) { - r->SendRaidLockTo(cgl); + if (raid->members[raid->GetPlayerIndex(raid_command_packet->leader_name)].IsGroupLeader) { + raid->SetGroupLeader(raid_command_packet->leader_name, false); + + /* We were the leader of our old group */ + if (old_group < 12) { + /* Assign new group leader if we can */ + for (int x = 0; x < MAX_RAID_MEMBERS; x++) { + if (raid->members[x].GroupNumber == old_group) { + if (strcmp(raid_command_packet->leader_name, raid->members[x].membername) != 0 && strlen(raid_command_packet->leader_name) > 0) { + raid->SetGroupLeader(raid->members[x].membername); + raid->UpdateGroupAAs(old_group); + + Client *client_to_update = entity_list.GetClientByName(raid->members[x].membername); + if (client_to_update) { + raid->SendRaidRemove(raid->members[x].membername, client_to_update); + raid->SendRaidCreate(client_to_update); + raid->SendMakeLeaderPacketTo(raid->leadername, client_to_update); + raid->SendRaidAdd(raid->members[x].membername, client_to_update); + raid->SendBulkRaid(client_to_update); + if (raid->IsLocked()) { + raid->SendRaidLockTo(client_to_update); } } else { - auto pack = new ServerPacket( - ServerOP_RaidChangeGroup, - sizeof( - ServerRaidGeneralAction_Struct)); - ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - rga->rid = r->GetID(); - strn0cpy(rga->playername, r->members[x].membername, 64); - rga->zoneid = zone->GetZoneID(); - rga->instance_id = zone->GetInstanceID(); + auto pack = new ServerPacket(ServerOP_RaidChangeGroup, sizeof(ServerRaidGeneralAction_Struct)); + ServerRaidGeneralAction_Struct *raid_command_packet = (ServerRaidGeneralAction_Struct*)pack->pBuffer; + + raid_command_packet->rid = raid->GetID(); + raid_command_packet->zoneid = zone->GetZoneID(); + raid_command_packet->instance_id = zone->GetInstanceID(); + strn0cpy(raid_command_packet->playername, raid->members[x].membername, 64); + worldserver.SendPacket(pack); + safe_delete(pack); } break; @@ -11351,69 +11366,67 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) } } } - if (grpcount == 0) { - r->SetGroupLeader(ri->leader_name); - r->UpdateGroupAAs(ri->parameter); + if (group_count == 0) { + raid->SetGroupLeader(raid_command_packet->leader_name); + raid->UpdateGroupAAs(raid_command_packet->parameter); } - r->MoveMember(ri->leader_name, ri->parameter); + raid->MoveMember(raid_command_packet->leader_name, raid_command_packet->parameter); if (c) { - r->SendGroupDisband(c); + raid->SendGroupDisband(c); } else { - auto pack = new ServerPacket(ServerOP_RaidGroupDisband, - sizeof(ServerRaidGeneralAction_Struct)); - ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - rga->rid = r->GetID(); - rga->zoneid = zone->GetZoneID(); - rga->instance_id = zone->GetInstanceID(); - strn0cpy(rga->playername, ri->leader_name, 64); + auto pack = new ServerPacket(ServerOP_RaidGroupDisband, sizeof(ServerRaidGeneralAction_Struct)); + ServerRaidGeneralAction_Struct* raid_command = (ServerRaidGeneralAction_Struct*)pack->pBuffer; + raid_command->rid = raid->GetID(); + raid_command->zoneid = zone->GetZoneID(); + raid_command->instance_id = zone->GetInstanceID(); + strn0cpy(raid_command->playername, raid_command_packet->leader_name, 64); worldserver.SendPacket(pack); safe_delete(pack); } - //r->SendRaidGroupAdd(ri->leader_name, ri->parameter); - //r->SendRaidGroupRemove(ri->leader_name, oldgrp); - //r->SendGroupUpdate(c); - //break - r->GroupUpdate(ri->parameter); //send group update to our new group - if (oldgrp < 12) //if our old was a group send update there too - r->GroupUpdate(oldgrp); - //r->SendMakeGroupLeaderPacketAll(); + /* Send group update to our new group */ + raid->GroupUpdate(raid_command_packet->parameter); + + /* If our old was a group send update there too */ + if (old_group < 12) + raid->GroupUpdate(old_group); + } } - else //moving to ungrouped - { - Client *c = entity_list.GetClientByName(ri->leader_name); - uint32 oldgrp = r->GetGroup(ri->leader_name); - if (r->members[r->GetPlayerIndex(ri->leader_name)].IsGroupLeader) { - r->SetGroupLeader(ri->leader_name, false); - for (int x = 0; x < MAX_RAID_MEMBERS; x++) - { - if (r->members[x].GroupNumber == oldgrp && strlen(r->members[x].membername) > 0 && strcmp(r->members[x].membername, ri->leader_name) != 0) - { - r->SetGroupLeader(r->members[x].membername); - r->UpdateGroupAAs(oldgrp); - Client *cgl = entity_list.GetClientByName(r->members[x].membername); - if (cgl) { - r->SendRaidRemove(r->members[x].membername, cgl); - r->SendRaidCreate(cgl); - r->SendMakeLeaderPacketTo(r->leadername, cgl); - r->SendRaidAdd(r->members[x].membername, cgl); - r->SendBulkRaid(cgl); - if (r->IsLocked()) { - r->SendRaidLockTo(cgl); + /* Move player to ungrouped bank */ + else { + Client *c = entity_list.GetClientByName(raid_command_packet->leader_name); + uint32 oldgrp = raid->GetGroup(raid_command_packet->leader_name); + if (raid->members[raid->GetPlayerIndex(raid_command_packet->leader_name)].IsGroupLeader) { + raid->SetGroupLeader(raid_command_packet->leader_name, false); + for (int x = 0; x < MAX_RAID_MEMBERS; x++) { + if (raid->members[x].GroupNumber == oldgrp && strlen(raid->members[x].membername) > 0 && strcmp(raid->members[x].membername, raid_command_packet->leader_name) != 0){ + + raid->SetGroupLeader(raid->members[x].membername); + raid->UpdateGroupAAs(oldgrp); + + Client *client_leaving_group = entity_list.GetClientByName(raid->members[x].membername); + if (client_leaving_group) { + raid->SendRaidRemove(raid->members[x].membername, client_leaving_group); + raid->SendRaidCreate(client_leaving_group); + raid->SendMakeLeaderPacketTo(raid->leadername, client_leaving_group); + raid->SendRaidAdd(raid->members[x].membername, client_leaving_group); + raid->SendBulkRaid(client_leaving_group); + if (raid->IsLocked()) { + raid->SendRaidLockTo(client_leaving_group); } } else { - auto pack = new ServerPacket( - ServerOP_RaidChangeGroup, - sizeof(ServerRaidGeneralAction_Struct)); - ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - rga->rid = r->GetID(); - strn0cpy(rga->playername, r->members[x].membername, 64); - rga->zoneid = zone->GetZoneID(); - rga->instance_id = zone->GetInstanceID(); + auto pack = new ServerPacket( ServerOP_RaidChangeGroup, sizeof(ServerRaidGeneralAction_Struct)); + ServerRaidGeneralAction_Struct *raid_command = (ServerRaidGeneralAction_Struct*)pack->pBuffer; + + raid_command->rid = raid->GetID(); + strn0cpy(raid_command->playername, raid->members[x].membername, 64); + raid_command->zoneid = zone->GetZoneID(); + raid_command->instance_id = zone->GetInstanceID(); + worldserver.SendPacket(pack); safe_delete(pack); } @@ -11421,28 +11434,29 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) } } } - r->MoveMember(ri->leader_name, 0xFFFFFFFF); + raid->MoveMember(raid_command_packet->leader_name, 0xFFFFFFFF); if (c) { - r->SendGroupDisband(c); + raid->SendGroupDisband(c); } else { - auto pack = new ServerPacket(ServerOP_RaidGroupDisband, - sizeof(ServerRaidGeneralAction_Struct)); - ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - rga->rid = r->GetID(); - rga->zoneid = zone->GetZoneID(); - rga->instance_id = zone->GetInstanceID(); - strn0cpy(rga->playername, ri->leader_name, 64); + auto pack = new ServerPacket(ServerOP_RaidGroupDisband, sizeof(ServerRaidGeneralAction_Struct)); + ServerRaidGeneralAction_Struct* raid_command = (ServerRaidGeneralAction_Struct*)pack->pBuffer; + + raid_command->rid = raid->GetID(); + raid_command->zoneid = zone->GetZoneID(); + raid_command->instance_id = zone->GetInstanceID(); + strn0cpy(raid_command->playername, raid_command_packet->leader_name, 64); + worldserver.SendPacket(pack); + safe_delete(pack); } - //r->SendRaidGroupRemove(ri->leader_name, oldgrp); - r->GroupUpdate(oldgrp); - //r->SendMakeGroupLeaderPacketAll(); + + raid->GroupUpdate(oldgrp); } } - Client *client_moved = entity_list.GetClientByName(ri->leader_name); + Client *client_moved = entity_list.GetClientByName(raid_command_packet->leader_name); if (client_moved) { client_moved->GetRaid()->SendHPManaEndPacketsTo(client_moved); @@ -11458,36 +11472,34 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) } case RaidCommandRaidLock: { - Raid *r = entity_list.GetRaidByClient(this); - if (r) - { - if (!r->IsLocked()) - r->LockRaid(true); + Raid *raid = entity_list.GetRaidByClient(this); + if (raid) { + if (!raid->IsLocked()) + raid->LockRaid(true); else - r->SendRaidLockTo(this); + raid->SendRaidLockTo(this); } break; } case RaidCommandRaidUnlock: { - Raid *r = entity_list.GetRaidByClient(this); - if (r) + Raid *raid = entity_list.GetRaidByClient(this); + if (raid) { - if (r->IsLocked()) - r->LockRaid(false); + if (raid->IsLocked()) + raid->LockRaid(false); else - r->SendRaidUnlockTo(this); + raid->SendRaidUnlockTo(this); } break; } case RaidCommandLootType2: case RaidCommandLootType: { - Raid *r = entity_list.GetRaidByClient(this); - if (r) - { - Message(15, "Loot type changed to: %d.", ri->parameter); - r->ChangeLootType(ri->parameter); + Raid *raid = entity_list.GetRaidByClient(this); + if (raid) { + Message(15, "Loot type changed to: %d.", raid_command_packet->parameter); + raid->ChangeLootType(raid_command_packet->parameter); } break; } @@ -11495,11 +11507,10 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) case RaidCommandAddLooter2: case RaidCommandAddLooter: { - Raid *r = entity_list.GetRaidByClient(this); - if (r) - { - Message(15, "Adding %s as a raid looter.", ri->leader_name); - r->AddRaidLooter(ri->leader_name); + Raid *raid = entity_list.GetRaidByClient(this); + if (raid) { + Message(15, "Adding %s as a raid looter.", raid_command_packet->leader_name); + raid->AddRaidLooter(raid_command_packet->leader_name); } break; } @@ -11507,24 +11518,22 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) case RaidCommandRemoveLooter2: case RaidCommandRemoveLooter: { - Raid *r = entity_list.GetRaidByClient(this); - if (r) - { - Message(15, "Removing %s as a raid looter.", ri->leader_name); - r->RemoveRaidLooter(ri->leader_name); + Raid *raid = entity_list.GetRaidByClient(this); + if (raid) { + Message(15, "Removing %s as a raid looter.", raid_command_packet->leader_name); + raid->RemoveRaidLooter(raid_command_packet->leader_name); } break; } case RaidCommandMakeLeader: { - Raid *r = entity_list.GetRaidByClient(this); - if (r) - { - if (strcmp(r->leadername, GetName()) == 0) { - r->SetRaidLeader(GetName(), ri->leader_name); - r->UpdateRaidAAs(); - r->SendAllRaidLeadershipAA(); + Raid *raid = entity_list.GetRaidByClient(this); + if (raid) { + if (strcmp(raid->leadername, GetName()) == 0) { + raid->SetRaidLeader(GetName(), raid_command_packet->leader_name); + raid->UpdateRaidAAs(); + raid->SendAllRaidLeadershipAA(); } } break; @@ -11532,19 +11541,19 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) case RaidCommandSetMotd: { - Raid *r = entity_list.GetRaidByClient(this); - if (!r) + Raid *raid = entity_list.GetRaidByClient(this); + if (!raid) break; // we don't use the RaidGeneral here! RaidMOTD_Struct *motd = (RaidMOTD_Struct *)app->pBuffer; - r->SetRaidMOTD(std::string(motd->motd)); - r->SaveRaidMOTD(); - r->SendRaidMOTDToWorld(); + raid->SetRaidMOTD(std::string(motd->motd)); + raid->SaveRaidMOTD(); + raid->SendRaidMOTDToWorld(); break; } default: { - Message(13, "Raid command (%d) NYI", ri->action); + Message(13, "Raid command (%d) NYI", raid_command_packet->action); break; } } From bb2d8f6a4d1c98b492e357e3a8dc6f7592ac1b08 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Tue, 22 Aug 2017 00:48:55 -0500 Subject: [PATCH 06/97] [Position Updates] Always send position updates to group members - even when in raid --- common/ruletypes.h | 1 + zone/client_packet.cpp | 14 +++++++++++++- zone/groups.cpp | 27 +++++++++++++++++++++++++++ zone/groups.h | 1 + zone/raids.cpp | 39 +++++++++++++++++++++++++++++++++++++++ zone/raids.h | 2 ++ 6 files changed, 83 insertions(+), 1 deletion(-) diff --git a/common/ruletypes.h b/common/ruletypes.h index a51a224b0..b0ca0acfa 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -563,6 +563,7 @@ RULE_INT(Range, DamageMessages, 50) RULE_INT(Range, SpellMessages, 75) RULE_INT(Range, SongMessages, 75) RULE_INT(Range, MobPositionUpdates, 600) +RULE_INT(Range, ClientPositionUpdates, 300) RULE_INT(Range, CriticalDamage, 80) RULE_INT(Range, ClientNPCScan, 300) RULE_CATEGORY_END() diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index a81e0ac85..78dac9410 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4634,7 +4634,19 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) entity_list.QueueClientsStatus(this, outapp, true, Admin(), 250); } else { - entity_list.QueueCloseClients(this, outapp, true, 300, nullptr, true); + entity_list.QueueCloseClients(this, outapp, true, RuleI(Range, ClientPositionUpdates), nullptr, true); + } + + + /* Always send position updates to group - send when beyond normal ClientPositionUpdate range */ + Group *group = this->GetGroup(); + Raid *raid = this->GetRaid(); + + if (raid) { + raid->QueueClients(this, outapp, true, true, (RuleI(Range, ClientPositionUpdates) * -1)); + } + else if (group) { + group->QueueClients(this, outapp, true, true, (RuleI(Range, ClientPositionUpdates) * -1)); } safe_delete(outapp); diff --git a/zone/groups.cpp b/zone/groups.cpp index c6fa6a978..d72b71c30 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -2464,3 +2464,30 @@ bool Group::HasRole(Mob *m, uint8 Role) return false; } +void Group::QueueClients(Mob *sender, const EQApplicationPacket *app, bool ack_required /*= true*/, bool ignore_sender /*= true*/, float distance /*= 0*/) { + if (sender && sender->IsClient()) { + for (uint32 i = 0; i < MAX_GROUP_MEMBERS; i++) { + + if (!members[i]) + continue; + + if (ignore_sender && members[i] == sender) + continue; + + /* If we don't have a distance requirement - send to all members */ + if (distance == 0) { + members[i]->CastToClient()->QueuePacket(app, ack_required); + } + else { + /* If negative distance - we check if current distance is greater than X */ + if (distance <= 0 && DistanceSquared(sender->GetPosition(), members[i]->GetPosition()) >= (distance * distance)) { + members[i]->CastToClient()->QueuePacket(app, ack_required); + } + /* If positive distance - we check if current distance is less than X */ + else if (distance >= 0 && DistanceSquared(sender->GetPosition(), members[i]->GetPosition()) <= (distance * distance)) { + members[i]->CastToClient()->QueuePacket(app, ack_required); + } + } + } + } +} \ No newline at end of file diff --git a/zone/groups.h b/zone/groups.h index 79fb0d8b6..913a6c169 100644 --- a/zone/groups.h +++ b/zone/groups.h @@ -140,6 +140,7 @@ public: inline int GetLeadershipAA(int AAID) { return LeaderAbilities.ranks[AAID]; } void ClearAllNPCMarks(); void QueueHPPacketsForNPCHealthAA(Mob* sender, const EQApplicationPacket* app); + void QueueClients(Mob *sender, const EQApplicationPacket *app, bool ack_required = true, bool ignore_sender = true, float distance = 0); void ChangeLeader(Mob* newleader); const char *GetClientNameByIndex(uint8 index); void UpdateXTargetMarkedNPC(uint32 Number, Mob *m); diff --git a/zone/raids.cpp b/zone/raids.cpp index 7496d3686..9b33056c0 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -1779,3 +1779,42 @@ void Raid::SetDirtyAutoHaters() } +void Raid::QueueClients(Mob *sender, const EQApplicationPacket *app, bool ack_required /*= true*/, bool ignore_sender /*= true*/, float distance /*= 0*/, bool group_only /*= true*/) { + if (sender && sender->IsClient()) { + + uint32 group_id = this->GetGroup(sender->CastToClient()); + + /* If this is a group only packet and we're not in a group -- return */ + if (!group_id == 0xFFFFFFFF && group_only) + return; + + for (uint32 i = 0; i < MAX_RAID_MEMBERS; i++) { + if (!members[i].member) + continue; + + if (!members[i].member->IsClient()) + continue; + + if (ignore_sender && members[i].member == sender) + continue; + + if (group_only && members[i].GroupNumber != group_id) + continue; + + /* If we don't have a distance requirement - send to all members */ + if (distance == 0) { + members[i].member->CastToClient()->QueuePacket(app, ack_required); + } + else { + /* If negative distance - we check if current distance is greater than X */ + if (distance <= 0 && DistanceSquared(sender->GetPosition(), members[i].member->GetPosition()) >= (distance * distance)) { + members[i].member->CastToClient()->QueuePacket(app, ack_required); + } + /* If positive distance - we check if current distance is less than X */ + else if (distance >= 0 && DistanceSquared(sender->GetPosition(), members[i].member->GetPosition()) <= (distance * distance)) { + members[i].member->CastToClient()->QueuePacket(app, ack_required); + } + } + } + } +} \ No newline at end of file diff --git a/zone/raids.h b/zone/raids.h index 068a876ac..9ed9bc11c 100644 --- a/zone/raids.h +++ b/zone/raids.h @@ -237,6 +237,8 @@ public: void SetDirtyAutoHaters(); inline XTargetAutoHaters *GetXTargetAutoMgr() { return &m_autohatermgr; } + void QueueClients(Mob *sender, const EQApplicationPacket *app, bool ack_required = true, bool ignore_sender = true, float distance = 0, bool group_only = true); + RaidMember members[MAX_RAID_MEMBERS]; char leadername[64]; protected: From 808654743c0076fa8cb760c86eadb81c3c0de3e0 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Tue, 22 Aug 2017 02:13:56 -0500 Subject: [PATCH 07/97] [Position Updates] Bulk updates when player has moved far enough - eliminates client ghosting on rez/gates/summon as well as npc ghosting --- common/ruletypes.h | 1 + zone/client.h | 4 +++- zone/client_process.cpp | 18 ++++++++++++++---- zone/mob.cpp | 14 ++++++++++++++ zone/mob.h | 1 + 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/common/ruletypes.h b/common/ruletypes.h index b0ca0acfa..529c7d239 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -564,6 +564,7 @@ RULE_INT(Range, SpellMessages, 75) RULE_INT(Range, SongMessages, 75) RULE_INT(Range, MobPositionUpdates, 600) RULE_INT(Range, ClientPositionUpdates, 300) +RULE_INT(Range, ClientForceSpawnUpdateRange, 1000) RULE_INT(Range, CriticalDamage, 80) RULE_INT(Range, ClientNPCScan, 300) RULE_CATEGORY_END() diff --git a/zone/client.h b/zone/client.h index 952c98333..ca43d6c91 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1489,7 +1489,9 @@ private: Timer hp_self_update_throttle_timer; /* This is to prevent excessive packet sending under trains/fast combat */ Timer hp_other_update_throttle_timer; /* This is to keep clients from DOSing the server with macros that change client targets constantly */ Timer position_update_timer; /* Timer used when client hasn't updated within a 10 second window */ - glm::vec3 m_Proximity; + + glm::vec3 m_Proximity; + glm::vec4 last_major_update_position; void BulkSendInventoryItems(); diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 3e08c1fba..a0961038e 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -243,15 +243,21 @@ bool Client::Process() { /* Build a close range list of NPC's */ if (npc_close_scan_timer.Check()) { - close_mobs.clear(); - auto &mob_list = entity_list.GetMobList(); - float scan_range = (RuleI(Range, ClientNPCScan) * RuleI(Range, ClientNPCScan)); - float client_update_range = (RuleI(Range, MobPositionUpdates) * RuleI(Range, MobPositionUpdates)); + /* Force spawn updates when traveled far */ + bool force_spawn_updates = false; + float client_update_range = (RuleI(Range, ClientForceSpawnUpdateRange) * RuleI(Range, ClientForceSpawnUpdateRange)); + if (DistanceSquared(last_major_update_position, m_Position) >= client_update_range) { + last_major_update_position = m_Position; + force_spawn_updates = true; + } + float scan_range = (RuleI(Range, ClientNPCScan) * RuleI(Range, ClientNPCScan)); + auto &mob_list = entity_list.GetMobList(); for (auto itr = mob_list.begin(); itr != mob_list.end(); ++itr) { Mob* mob = itr->second; + float distance = DistanceSquared(m_Position, mob->GetPosition()); if (mob->IsNPC()) { if (distance <= scan_range) { @@ -261,6 +267,10 @@ bool Client::Process() { close_mobs.insert(std::pair(mob, distance)); } } + + if (force_spawn_updates && mob != this && distance <= client_update_range) + mob->SendPositionUpdateToClient(this); + } } diff --git a/zone/mob.cpp b/zone/mob.cpp index 924f26b69..342626078 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -1455,6 +1455,20 @@ void Mob::SendPosition() { safe_delete(app); } +void Mob::SendPositionUpdateToClient(Client *client) { + auto app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); + PlayerPositionUpdateServer_Struct* spawn_update = (PlayerPositionUpdateServer_Struct*)app->pBuffer; + + if(this->IsMoving()) + MakeSpawnUpdate(spawn_update); + else + MakeSpawnUpdateNoDelta(spawn_update); + + client->QueuePacket(app, false); + + safe_delete(app); +} + /* Position updates for mobs on the move */ void Mob::SendPositionUpdate(uint8 iSendToSelf) { auto app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); diff --git a/zone/mob.h b/zone/mob.h index bdc1e7c3a..16e73ba77 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -543,6 +543,7 @@ public: virtual void GMMove(float x, float y, float z, float heading = 0.01, bool SendUpdate = true); void SetDelta(const glm::vec4& delta); void SetTargetDestSteps(uint8 target_steps) { tar_ndx = target_steps; } + void SendPositionUpdateToClient(Client *client); void SendPositionUpdate(uint8 iSendToSelf = 0); void MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct* spu); void MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu); From 00604722bb8463a225e0c7d23ec41755ce29b0a2 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Thu, 24 Aug 2017 04:13:52 -0500 Subject: [PATCH 08/97] [Perl] Fix perl for later Linux releases v5.24.1 --- zone/embperl.cpp | 10 ++++++---- zone/embxs.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/zone/embperl.cpp b/zone/embperl.cpp index 71338c05a..bc20bd4ef 100644 --- a/zone/embperl.cpp +++ b/zone/embperl.cpp @@ -119,7 +119,7 @@ void Embperl::DoInit() { perl_run(my_perl); //a little routine we use a lot. - eval_pv("sub my_eval {eval $_[0];}", TRUE); //dies on error + eval_pv("sub my_eval { eval $_[0];}", TRUE); //dies on error //ruin the perl exit and command: eval_pv("sub my_exit {}",TRUE); @@ -149,7 +149,7 @@ void Embperl::DoInit() { //make a tieable class to capture IO and pass it into EQEMuLog eval_pv( "package EQEmuIO; " - "sub TIEHANDLE { my $me = bless {}, $_[0]; $me->PRINT('Creating '.$me); return($me); } " + "sub TIEHANDLE { my $me = bless {}, $_[0]; $me->PRINT('Creating '. $me); return($me); } " "sub WRITE { } " //dunno why I need to shift off fmt here, but it dosent like without it "sub PRINTF { my $me = shift; my $fmt = shift; $me->PRINT(sprintf($fmt, @_)); } " @@ -237,6 +237,7 @@ void Embperl::init_eval_file(void) { eval_pv( "our %Cache;" + "no warnings;" "use Symbol qw(delete_package);" "sub eval_file {" "my($package, $filename) = @_;" @@ -246,8 +247,9 @@ void Embperl::init_eval_file(void) "if(defined $Cache{$package}{mtime}&&$Cache{$package}{mtime} <= $mtime && !($package eq 'plugin')){" " return;" "} else {" - //we 'my' $filename,$mtime,$package,$sub to prevent them from changing our state up here. - " eval(\"package $package; my(\\$filename,\\$mtime,\\$package,\\$sub); \\$isloaded = 1; require '$filename'; \");" + // we 'my' $filename,$mtime,$package,$sub to prevent them from changing our state up here. + " eval(\"package $package; my(\\$filename,\\$mtime,\\$package,\\$sub); \\$isloaded = 1; require './$filename'; \");" + // " print $@ if $@;" /* "local *FH;open FH, $filename or die \"open '$filename' $!\";" "local($/) = undef;my $sub = ;close FH;" "my $eval = qq{package $package; sub handler { $sub; }};" diff --git a/zone/embxs.cpp b/zone/embxs.cpp index fe4a12aee..82f3cc4f2 100644 --- a/zone/embxs.cpp +++ b/zone/embxs.cpp @@ -99,12 +99,17 @@ XS(XS_EQEmuIO_PRINT) /* Strip newlines from log message 'str' */ *std::remove(str, str + strlen(str), '\n') = '\0'; + std::string log_string = str; + if (log_string.find("did not return a true") != std::string::npos) + return;; + int i; int pos = 0; int len = 0; for(i = 0; *cur != '\0'; i++, cur++) { if(*cur == '\n') { - Log(Logs::General, Logs::Quests, str); + std::string string = StringFormat("%s - bitch", str); + Log(Logs::General, Logs::Quests, string.c_str()); len = 0; pos = i+1; } else { From c37e83e23553899d4d27013dc6e76f46e7c627b1 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Thu, 24 Aug 2017 04:15:55 -0500 Subject: [PATCH 09/97] Remove some leftover debugging XD --- zone/embxs.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zone/embxs.cpp b/zone/embxs.cpp index 82f3cc4f2..3816850db 100644 --- a/zone/embxs.cpp +++ b/zone/embxs.cpp @@ -108,8 +108,7 @@ XS(XS_EQEmuIO_PRINT) int len = 0; for(i = 0; *cur != '\0'; i++, cur++) { if(*cur == '\n') { - std::string string = StringFormat("%s - bitch", str); - Log(Logs::General, Logs::Quests, string.c_str()); + Log(Logs::General, Logs::Quests, str); len = 0; pos = i+1; } else { From ca32e35ef60655835cffd549a620bd4f36c887d9 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 26 Aug 2017 00:12:34 -0400 Subject: [PATCH 10/97] More Zone struct commments --- common/patches/rof2_structs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/patches/rof2_structs.h b/common/patches/rof2_structs.h index 976753bb2..41fc9528a 100644 --- a/common/patches/rof2_structs.h +++ b/common/patches/rof2_structs.h @@ -617,7 +617,7 @@ struct NewZone_Struct { /*0704*/ char zone_short_name2[32]; //zone file name? excludes instance number which can be in previous version. /*0736*/ char WeatherString[32]; /*0768*/ char SkyString2[32]; - /*0800*/ int32 SkyRelated2; //seen -1 + /*0800*/ int32 SkyRelated2; //seen -1 -- maybe some default sky time? /*0804*/ char WeatherString2[32]; // /*0836*/ float WeatherChangeTime; // not sure :P /*0840*/ uint32 Climate; From 3746128014fe5835924cc14c25e72b3374b2cc06 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 26 Aug 2017 00:12:47 -0400 Subject: [PATCH 11/97] Fix SE_IncreaseBlockChance stacking --- zone/bonuses.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index 4406508fe..ade72a0c6 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -2495,7 +2495,12 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses *ne break; case SE_IncreaseBlockChance: - new_bonus->IncreaseBlockChance += effect_value; + if (AdditiveWornBonus) + new_bonus->IncreaseBlockChance += effect_value; + else if (effect_value < 0 && new_bonus->IncreaseBlockChance > effect_value) + new_bonus->IncreaseBlockChance = effect_value; + else if (new_bonus->IncreaseBlockChance < effect_value) + new_bonus->IncreaseBlockChance = effect_value; break; case SE_PersistantCasting: From 21464897401cf0c3f72d486aca30d2316c478969 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 26 Aug 2017 00:15:01 -0400 Subject: [PATCH 12/97] Add rest of the avoidance skills to AA bonus --- zone/bonuses.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index ade72a0c6..098de9eb9 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -1003,6 +1003,15 @@ void Mob::ApplyAABonuses(const AA::Rank &rank, StatBonuses *newbon) case SE_RiposteChance: newbon->RiposteChance += base1; break; + case SE_DodgeChance: + newbon->DodgeChance += base1; + break; + case SE_ParryChance: + newbon->ParryChance += base1; + break; + case SE_IncreaseBlockChance: + newbon->IncreaseBlockChance += base1; + break; case SE_Flurry: newbon->FlurryChance += base1; break; From 487dcc445937129ab9b99c7dcf045b9ca956774c Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Wed, 30 Aug 2017 14:35:01 -0400 Subject: [PATCH 13/97] Tweak down spellend_timer for delaytimer 400 ms is far too aggressive for normal game play Set to 10 ms to hopefully not get in the way of legitimate game play Also, why do we even do this? As far as I can tell, we need this to be less than the users ping to not cause issues. What are the actual reasons we do this and what can we do differently to solve them? --- zone/spells.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zone/spells.cpp b/zone/spells.cpp index 8e7d6721a..0bc897912 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -1427,8 +1427,10 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo ZeroCastingVars(); // set the rapid recast timer for next time around + // Why do we have this? It mostly just causes issues when things are working correctly + // It also needs to be Date: Wed, 30 Aug 2017 15:17:02 -0400 Subject: [PATCH 14/97] Don't set reuse timer in UseDiscipline in case CastSpell fails --- zone/effects.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/effects.cpp b/zone/effects.cpp index adc7b16b2..2741a924b 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -613,7 +613,7 @@ bool Client::UseDiscipline(uint32 spell_id, uint32 target) { //Check the disc timer pTimerType DiscTimer = pTimerDisciplineReuseStart + spell.EndurTimerIndex; - if(!p_timers.Expired(&database, DiscTimer)) { + if(!p_timers.Expired(&database, DiscTimer, false)) { // lets not set the reuse timer in case CastSpell fails (or we would have to turn off the timer, but CastSpell will set it as well) /*char val1[20]={0};*/ //unused /*char val2[20]={0};*/ //unused uint32 remain = p_timers.GetRemainingTime(DiscTimer); From 7e3fdee86ceda1893609ec5f8600146b25c44e5f Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 3 Sep 2017 02:04:25 -0400 Subject: [PATCH 15/97] Fix Life Burn from killing you --- zone/spell_effects.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 6a50ab142..69a5b232b 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -277,8 +277,9 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove caster->SetMana(0); } else if (spell_id == 2755 && caster) //Lifeburn { - dmg = -1 * caster->GetHP(); // just your current HP or should it be Max HP? + dmg = caster->GetHP(); // just your current HP caster->SetHP(dmg / 4); // 2003 patch notes say ~ 1/4 HP. Should this be 1/4 your current HP or do 3/4 max HP dmg? Can it kill you? + dmg = -dmg; } //do any AAs apply to these spells? From 7b4c130e0a26a4d2d0b997786bad2232d7f98c62 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 3 Sep 2017 15:02:36 -0400 Subject: [PATCH 16/97] Switch local saved "animation" to signed This variable is really the SpeedRun but packed as an int ... --- zone/mob.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/mob.h b/zone/mob.h index 16e73ba77..1e6ae6194 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -1222,7 +1222,7 @@ protected: glm::vec4 m_Position; /* Used to determine when an NPC has traversed so many units - to send a zone wide pos update */ glm::vec4 last_major_update_position; - uint16 animation; + int animation; // this is really what MQ2 calls SpeedRun just packed like (int)(SpeedRun * 40.0f) float base_size; float size; float runspeed; From 240f04eda7e21c846d65380935a6af14d19cd756 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Mon, 4 Sep 2017 02:10:10 -0400 Subject: [PATCH 17/97] Implement fleeing stun --- zone/attack.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/zone/attack.cpp b/zone/attack.cpp index 4b480f580..a87f504b7 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -1262,6 +1262,7 @@ int Client::DoDamageCaps(int base_damage) return std::min(cap, base_damage); } +// other is the defender, this is the attacker void Mob::DoAttack(Mob *other, DamageHitInfo &hit, ExtraAttackOptions *opts) { if (!other) @@ -1288,6 +1289,20 @@ void Mob::DoAttack(Mob *other, DamageHitInfo &hit, ExtraAttackOptions *opts) if (hit.damage_done >= 0) { if (other->CheckHitChance(this, hit)) { + if (IsNPC() && other->IsClient() && other->animation > 0 && GetLevel() >= 5 && BehindMob(other, GetX(), GetY())) { + // ~ 12% chance + if (zone->random.Roll(12)) { + int stun_resist2 = other->spellbonuses.FrontalStunResist + other->itembonuses.FrontalStunResist + other->aabonuses.FrontalStunResist; + int stun_resist = other->spellbonuses.StunResist + other->itembonuses.StunResist + other->aabonuses.StunResist; + if (zone->random.Roll(stun_resist2)) { + other->Message_StringID(MT_Stun, AVOID_STUNNING_BLOW); + } else if (zone->random.Roll(stun_resist)) { + other->Message_StringID(MT_Stun, SHAKE_OFF_STUN); + } else { + other->Stun(3000); // yuck -- 3 seconds + } + } + } other->MeleeMitigation(this, hit, opts); if (hit.damage_done > 0) { ApplyDamageTable(hit); From b71f3031bcfb95a6bee9e9e4c8b904e9c423f54d Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sun, 17 Sep 2017 05:34:44 -0500 Subject: [PATCH 18/97] [Windows] World process window title now updates with server name and amount of clients connected --- world/net.cpp | 28 ++++++++++++---------------- world/net.h | 1 - 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/world/net.cpp b/world/net.cpp index 599f01c8f..b6e7babcc 100644 --- a/world/net.cpp +++ b/world/net.cpp @@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include #include +#include "../common/string_util.h" #include "../common/eqemu_logsys.h" #include "../common/queue.h" #include "../common/timer.h" @@ -104,6 +105,12 @@ WebInterfaceList web_interface; void CatchSignal(int sig_num); +inline void UpdateWindowTitle(std::string new_title) { +#ifdef _WINDOWS + SetConsoleTitle(new_title.c_str()); +#endif +} + int main(int argc, char** argv) { RegisterExecutablePlatform(ExePlatformWorld); LogSys.LoadLogSettingsDefaults(); @@ -527,8 +534,7 @@ int main(int argc, char** argv) { database.PurgeExpiredInstances(); } - if (EQTimeTimer.Check()) - { + if (EQTimeTimer.Check()) { TimeOfDay_Struct tod; zoneserver_list.worldclock.GetCurrentEQTimeOfDay(time(0), &tod); if (!database.SaveTime(tod.minute, tod.hour, tod.day, tod.month, tod.year)) @@ -545,6 +551,9 @@ int main(int argc, char** argv) { if (InterserverTimer.Check()) { InterserverTimer.Start(); database.ping(); + + std::string window_title = StringFormat("World: %s Clients: %i", Config->LongName.c_str(), client_list.GetClientCount()); + UpdateWindowTitle(window_title); } EQ::EventLoop::Get().Process(); @@ -563,17 +572,4 @@ int main(int argc, char** argv) { void CatchSignal(int sig_num) { Log(Logs::General, Logs::World_Server, "Caught signal %d", sig_num); RunLoops = false; -} - -void UpdateWindowTitle(char* iNewTitle) { -#ifdef _WINDOWS - char tmp[500]; - if (iNewTitle) { - snprintf(tmp, sizeof(tmp), "World: %s", iNewTitle); - } - else { - snprintf(tmp, sizeof(tmp), "World"); - } - SetConsoleTitle(tmp); -#endif -} +} \ No newline at end of file diff --git a/world/net.h b/world/net.h index 5af1ef96a..06e918a5c 100644 --- a/world/net.h +++ b/world/net.h @@ -31,7 +31,6 @@ #endif void CatchSignal(int sig_num); -void UpdateWindowTitle(char* iNewTitle); #define EQ_WORLD_PORT 9000 //mandated by the client #define LOGIN_PORT 5997 From e88cd61097ff92be7cca4836866360416a4927e0 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sun, 17 Sep 2017 09:48:10 -0500 Subject: [PATCH 19/97] Fix 95% of food/water consumption issues, if there are additional modifiers for race/class combos - those will need to be applied Mods properly calculated Stages should be put in place if not already: https://wiki.project1999.com/Food_and_drink#Stages_of_Hunger_and_Thirst Values stored in the database are 0-6000, previously we capped it at 6000 but previous math would have normal values in the 60k+ range in order for food to be consumed at a reasonable rate. We are now using more native logic where 1 = 1 minute, following logic: (Minutes) 0 - 5 - This is a snack. 6 - 20 - This is a meal. 21 - 30 - This is a hearty meal. 31 - 40 - This is a banquet size meal. 41 - 50 - This meal is a feast! 51 - 60 - This is an enduring meal! 61 - X - This is a miraculous meal! --- common/eqemu_logsys.h | 4 ++- zone/client.cpp | 73 ++++++++++++++++++++++++++--------------- zone/client.h | 3 +- zone/client_packet.cpp | 14 +++++--- zone/client_process.cpp | 31 +++++++++++------ 5 files changed, 81 insertions(+), 44 deletions(-) diff --git a/common/eqemu_logsys.h b/common/eqemu_logsys.h index 56542c07d..10d9e460c 100644 --- a/common/eqemu_logsys.h +++ b/common/eqemu_logsys.h @@ -88,6 +88,7 @@ enum LogCategory { Headless_Client, HP_Update, FixZ, + Food, MaxCategoryID /* Don't Remove this*/ }; @@ -140,7 +141,8 @@ static const char* LogCategoryName[LogCategory::MaxCategoryID] = { "Client Login", "Headless Client", "HP Update", - "FixZ" + "FixZ", + "Food" }; } diff --git a/zone/client.cpp b/zone/client.cpp index 4866013a3..7a7c57861 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -124,6 +124,7 @@ Client::Client(EQStreamInterface* ieqs) camp_timer(29000), process_timer(100), stamina_timer(40000), + consume_food_timer(60000), zoneinpacket_timer(1000), linkdead_timer(RuleI(Zone,ClientLinkdeadMS)), dead_timer(2000), @@ -658,13 +659,18 @@ bool Client::Save(uint8 iCommitNow) { m_pp.tribute_time_remaining = 0xFFFFFFFF; m_pp.tribute_active = 0; } + if (m_pp.hunger_level < 0) + m_pp.hunger_level = 0; + + if (m_pp.thirst_level < 0) + m_pp.thirst_level = 0; + p_timers.Store(&database); database.SaveCharacterTribute(this->CharacterID(), &m_pp); SaveTaskState(); /* Save Character Task */ - m_pp.hunger_level = EQEmu::Clamp(m_pp.hunger_level, 0, 50000); - m_pp.thirst_level = EQEmu::Clamp(m_pp.thirst_level, 0, 50000); + Log(Logs::General, Logs::Food, "Client::Save - hunger_level: %i thirst_level: %i", m_pp.hunger_level, m_pp.thirst_level); // perform snapshot before SaveCharacterData() so that m_epp will contain the updated time if (RuleB(Character, ActiveInvSnapshots) && time(nullptr) >= GetNextInvSnapshotTime()) { @@ -8585,50 +8591,63 @@ void Client::SetConsumption(int32 in_hunger, int32 in_thirst) void Client::Consume(const EQEmu::ItemData *item, uint8 type, int16 slot, bool auto_consume) { - if(!item) { return; } + if(!item) { return; } - uint32 cons_mod = 180; + /* + Spell Bonuses 2 digit form - 10, 20, 25 etc. (10%, 20%, 25%) + AA Bonus Ranks, 110, 125, 150 etc. (10%, 25%, 50%) + */ - int32 metabolism_bonus = spellbonuses.Metabolism + itembonuses.Metabolism + aabonuses.Metabolism; + float aa_bonus = ((float) aabonuses.Metabolism - 100) / 100; + float item_bonus = (float) itembonuses.Metabolism / 100; + float spell_bonus = (float) spellbonuses.Metabolism / 100; - if (metabolism_bonus) - cons_mod = cons_mod * metabolism_bonus * RuleI(Character, ConsumptionMultiplier) / 10000; - else - cons_mod = cons_mod * RuleI(Character, ConsumptionMultiplier) / 100; + float metabolism_mod = 1 + spell_bonus + item_bonus + aa_bonus; - if (type == EQEmu::item::ItemTypeFood) - { - int hchange = item->CastTime_ * cons_mod; - hchange = mod_food_value(item, hchange); + Log(Logs::General, Logs::Food, "Client::Consume() Metabolism bonuses spell_bonus: (%.2f) item_bonus: (%.2f) aa_bonus: (%.2f) final: (%.2f)", + spell_bonus, + item_bonus, + aa_bonus, + metabolism_mod + ); - if(hchange < 0) { return; } + if (type == EQEmu::item::ItemTypeFood) { + int hunger_change = item->CastTime_ * metabolism_mod; + hunger_change = mod_food_value(item, hunger_change); + + if(hunger_change < 0) + return; + + m_pp.hunger_level += hunger_change; + + Log(Logs::General, Logs::Food, "Consuming food, points added to hunger_level: %i - current_hunger: %i", hunger_change, m_pp.hunger_level); - m_pp.hunger_level += hchange; DeleteItemInInventory(slot, 1, false); if(!auto_consume) //no message if the client consumed for us entity_list.MessageClose_StringID(this, true, 50, 0, EATING_MESSAGE, GetName(), item->Name); -#if EQDEBUG >= 5 - Log(Logs::General, Logs::None, "Eating from slot:%i", (int)slot); -#endif + Log(Logs::General, Logs::Food, "Eating from slot: %i", (int)slot); + } - else - { - int tchange = item->CastTime_ * cons_mod; - tchange = mod_drink_value(item, tchange); + else { + int thirst_change = item->CastTime_ * metabolism_mod; + thirst_change = mod_drink_value(item, thirst_change); - if(tchange < 0) { return; } + if(thirst_change < 0) + return; + + m_pp.thirst_level += thirst_change; - m_pp.thirst_level += tchange; DeleteItemInInventory(slot, 1, false); + Log(Logs::General, Logs::Food, "Consuming drink, points added to thirst_level: %i current_thirst: %i", thirst_change, m_pp.thirst_level); + if(!auto_consume) //no message if the client consumed for us entity_list.MessageClose_StringID(this, true, 50, 0, DRINKING_MESSAGE, GetName(), item->Name); -#if EQDEBUG >= 5 - Log(Logs::General, Logs::None, "Drinking from slot:%i", (int)slot); -#endif + Log(Logs::General, Logs::Food, "Drinking from slot: %i", (int)slot); + } } diff --git a/zone/client.h b/zone/client.h index ca43d6c91..b6098c6b3 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1351,7 +1351,7 @@ private: uint32 GetClassHPFactor(); void DoHPRegen(); void DoManaRegen(); - void DoStaminaUpdate(); + void DoStaminaHungerUpdate(); void CalcRestState(); uint32 pLastUpdate; @@ -1459,6 +1459,7 @@ private: Timer camp_timer; Timer process_timer; Timer stamina_timer; + Timer consume_food_timer; Timer zoneinpacket_timer; Timer linkdead_timer; Timer dead_timer; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 78dac9410..b72760e4f 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -8702,6 +8702,8 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) } else { + + /* //This is food/drink - consume it if (item->ItemType == EQEmu::item::ItemTypeFood && m_pp.hunger_level < 5000) { @@ -8723,19 +8725,21 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) //CheckIncreaseSkill(ALCOHOL_TOLERANCE, nullptr, 25); } - if (m_pp.hunger_level > 6000) - m_pp.hunger_level = 6000; - if (m_pp.thirst_level > 6000) - m_pp.thirst_level = 6000; - EQApplicationPacket *outapp2 = nullptr; outapp2 = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct)); Stamina_Struct* sta = (Stamina_Struct*)outapp2->pBuffer; + + if (m_pp.hunger_level > 6000) + sta->food = 6000; + if (m_pp.thirst_level > 6000) + sta->water = 6000; + sta->food = m_pp.hunger_level; sta->water = m_pp.thirst_level; QueuePacket(outapp2); safe_delete(outapp2); + */ } } diff --git a/zone/client_process.cpp b/zone/client_process.cpp index a0961038e..5ab5db7a8 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -38,6 +38,7 @@ #include #endif +#include "../common/data_verification.h" #include "../common/rulesys.h" #include "../common/skills.h" #include "../common/spdat.h" @@ -523,6 +524,11 @@ bool Client::Process() { DoEnduranceUpkeep(); } + if (consume_food_timer.Check()) { + m_pp.hunger_level = m_pp.hunger_level - 1; + m_pp.thirst_level = m_pp.thirst_level - 1; + } + if (tic_timer.Check() && !dead) { CalcMaxHP(); CalcMaxMana(); @@ -533,7 +539,7 @@ bool Client::Process() { DoManaRegen(); DoEnduranceRegen(); BuffProcess(); - DoStaminaUpdate(); + DoStaminaHungerUpdate(); if (tribute_timer.Check()) { ToggleTribute(true); //re-activate the tribute. @@ -1828,28 +1834,33 @@ void Client::DoManaRegen() { CheckManaEndUpdate(); } - -void Client::DoStaminaUpdate() { +void Client::DoStaminaHungerUpdate() { if(!stamina_timer.Check()) return; auto outapp = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct)); Stamina_Struct* sta = (Stamina_Struct*)outapp->pBuffer; - if(zone->GetZoneID() != 151) { - int loss = RuleI(Character, FoodLossPerUpdate); - if (m_pp.hunger_level > 0) - m_pp.hunger_level-=loss; - if (m_pp.thirst_level > 0) - m_pp.thirst_level-=loss; + Log(Logs::General, Logs::Food, "Client::DoStaminaHungerUpdate() hunger_level: %i thirst_level: %i before loss", m_pp.hunger_level, m_pp.thirst_level); + + if (zone->GetZoneID() != 151) { sta->food = m_pp.hunger_level > 6000 ? 6000 : m_pp.hunger_level; - sta->water = m_pp.thirst_level> 6000 ? 6000 : m_pp.thirst_level; + sta->water = m_pp.thirst_level > 6000 ? 6000 : m_pp.thirst_level; } else { // No auto food/drink consumption in the Bazaar sta->food = 6000; sta->water = 6000; } + + Log(Logs::General, Logs::Food, + "Client::DoStaminaHungerUpdate() Current hunger_level: %i = (%i minutes left) thirst_level: %i = (%i minutes left) - after loss", + m_pp.hunger_level, + m_pp.hunger_level, + m_pp.thirst_level, + m_pp.thirst_level + ); + FastQueuePacket(&outapp); } From 6d8b96068d97428e66b66c9f94164663a8754ec1 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sun, 17 Sep 2017 09:55:42 -0500 Subject: [PATCH 20/97] Add model/race offset to FixZ calc (KLS) --- changelog.txt | 18 ++++++++ zone/mob.h | 1 + zone/waypoints.cpp | 109 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 127 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 9568f8392..9d3535d62 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,24 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 9/17/2017 == +Akkadius: Add model/race offset to FixZ calc (KLS) +Akkadius: Fix 95% of food/water consumption issues, if there are additional modifiers for race/class combos - those will need to be applied + +Stages should be put in place if not already: +https://wiki.project1999.com/Food_and_drink#Stages_of_Hunger_and_Thirst + +Values stored in the database are 0-6000, previously we capped it at 6000 but previous math would have normal values in the 60k+ range in order for food to be consumed at a reasonable rate. We are now using more native logic where 1 = 1 minute, following logic: + +(Minutes) +0 - 5 - This is a snack. +6 - 20 - This is a meal. +21 - 30 - This is a hearty meal. +31 - 40 - This is a banquet size meal. +41 - 50 - This meal is a feast! +51 - 60 - This is an enduring meal! +61 - X - This is a miraculous meal! + == 7/14/2017 == Akkadius: HP Update tuning - HP Updates are now forced when a client is targeted Akkadius: Client position updates should be smoother (granted the client has a good connection) diff --git a/zone/mob.h b/zone/mob.h index 1e6ae6194..270836f89 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -950,6 +950,7 @@ public: float GetGroundZ(float new_x, float new_y, float z_offset=0.0); void SendTo(float new_x, float new_y, float new_z); void SendToFixZ(float new_x, float new_y, float new_z); + float GetZOffset() const; void FixZ(); void NPCSpecialAttacks(const char* parse, int permtag, bool reset = true, bool remove = false); inline uint32 DontHealMeBefore() const { return pDontHealMeBefore; } diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index c1997af59..4efefe198 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -850,7 +850,7 @@ void Mob::FixZ() { { /* Any more than 5 in the offset makes NPC's hop/snap to ceiling in small corridors */ float new_z = this->FindGroundZ(m_Position.x, m_Position.y, 5); - new_z += (this->GetSize() / 1.55); + new_z += this->GetZOffset(); auto duration = timer.elapsed(); @@ -884,6 +884,113 @@ void Mob::FixZ() { } } +float Mob::GetZOffset() const { + float offset = 3.125f; + + switch (race) { + case 436: + offset = 0.577f; + break; + case 430: + offset = 0.5f; + break; + case 432: + offset = 1.9f; + break; + case 435: + offset = 0.93f; + break; + case 450: + offset = 0.938f; + break; + case 479: + offset = 0.8f; + break; + case 451: + offset = 0.816f; + break; + case 437: + offset = 0.527f; + break; + case 439: + offset = 1.536f; + break; + case 415: + offset = 1.0f; + break; + case 438: + offset = 0.776f; + break; + case 452: + offset = 0.776f; + break; + case 441: + offset = 0.816f; + break; + case 440: + offset = 0.938f; + break; + case 468: + offset = 1.0f; + break; + case 459: + offset = 1.0f; + break; + case 462: + offset = 1.5f; + break; + case 530: + offset = 1.2f; + break; + case 549: + offset = 0.5f; + break; + case 548: + offset = 0.5f; + break; + case 547: + offset = 0.5f; + break; + case 604: + offset = 1.2f; + break; + case 653: + offset = 5.9f; + break; + case 658: + offset = 4.0f; + break; + case 323: + offset = 5.0f; + break; + case 663: + offset = 5.0f; + break; + case 664: + offset = 4.0f; + break; + case 703: + offset = 9.0f; + break; + case 688: + offset = 5.0f; + break; + case 669: + offset = 7.0f; + break; + case 687: + offset = 2.0f; + break; + case 686: + offset = 2.0f; + break; + default: + offset = 3.125f; + } + + return 0.2 * GetSize() * offset; +} + int ZoneDatabase::GetHighestGrid(uint32 zoneid) { std::string query = StringFormat("SELECT COALESCE(MAX(id), 0) FROM grid WHERE zoneid = %i", zoneid); From 2a4d6523b14ddde7ac98a2a6cd897b4bb2e09aeb Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sun, 17 Sep 2017 10:12:41 -0500 Subject: [PATCH 21/97] Fix some zone entrance ghosting --- zone/entity.cpp | 2 +- zone/mob.h | 2 +- zone/waypoints.cpp | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 03b4ccf5a..a06a67092 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -648,7 +648,7 @@ void EntityList::AddNPC(NPC *npc, bool SendSpawnPacket, bool dontqueue) parse->EventNPC(EVENT_SPAWN, npc, nullptr, "", 0); - npc->FixZ(); + npc->FixZ(1); uint16 emoteid = npc->GetEmoteID(); if (emoteid != 0) diff --git a/zone/mob.h b/zone/mob.h index 270836f89..ccf92014b 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -951,7 +951,7 @@ public: void SendTo(float new_x, float new_y, float new_z); void SendToFixZ(float new_x, float new_y, float new_z); float GetZOffset() const; - void FixZ(); + void FixZ(int32 z_find_offset = 5); void NPCSpecialAttacks(const char* parse, int permtag, bool reset = true, bool remove = false); inline uint32 DontHealMeBefore() const { return pDontHealMeBefore; } inline uint32 DontBuffMeBefore() const { return pDontBuffMeBefore; } diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 4efefe198..9ed7c46f9 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -838,7 +838,8 @@ void Mob::SendToFixZ(float new_x, float new_y, float new_z) { } } -void Mob::FixZ() { +void Mob::FixZ(int32 z_find_offset /*= 5*/) +{ BenchTimer timer; timer.reset(); @@ -849,7 +850,7 @@ void Mob::FixZ() { (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) { /* Any more than 5 in the offset makes NPC's hop/snap to ceiling in small corridors */ - float new_z = this->FindGroundZ(m_Position.x, m_Position.y, 5); + float new_z = this->FindGroundZ(m_Position.x, m_Position.y, z_find_offset); new_z += this->GetZOffset(); auto duration = timer.elapsed(); From e3972cc9e6f783461e102b56031d60872465f833 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sun, 17 Sep 2017 10:16:13 -0500 Subject: [PATCH 22/97] Update another Z Offset location for pathing --- zone/mob_ai.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index ef82527f9..58c856d77 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1536,8 +1536,7 @@ void NPC::AI_DoMovement() { Log(Logs::Detail, Logs::AI, "Roam Box: d=%.3f (%.3f->%.3f,%.3f->%.3f): Go To (%.3f,%.3f)", roambox_distance, roambox_min_x, roambox_max_x, roambox_min_y, roambox_max_y, roambox_movingto_x, roambox_movingto_y); - float new_z = this->FindGroundZ(m_Position.x, m_Position.y, 5); - new_z += (this->GetSize() / 1.55); + float new_z = this->FindGroundZ(m_Position.x, m_Position.y, 5) + this->GetZOffset(); if (!CalculateNewPosition2(roambox_movingto_x, roambox_movingto_y, new_z, walksp, true)) { From 59152a9d7740d49c4abb0d652ee3891f0f72d7e6 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Sun, 17 Sep 2017 12:11:02 -0400 Subject: [PATCH 23/97] Fix some constants. --- zone/command.cpp | 2 +- zone/fearpath.cpp | 2 +- zone/mob.cpp | 8 ++++---- zone/waypoints.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index 829588ca7..15b09b9dc 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -7257,7 +7257,7 @@ void command_bestz(Client *c, const Seperator *sep) { float best_z = zone->zonemap->FindBestZ(me, &hit); - if (best_z != -999999) + if (best_z != BEST_Z_INVALID) { c->Message(0, "Z is %.3f at (%.3f, %.3f).", best_z, me.x, me.y); } diff --git a/zone/fearpath.cpp b/zone/fearpath.cpp index c2ce95fbe..6f3580406 100644 --- a/zone/fearpath.cpp +++ b/zone/fearpath.cpp @@ -163,7 +163,7 @@ void Mob::CalculateNewFearpoint() ranx = GetX()+zone->random.Int(0, ran-1)-zone->random.Int(0, ran-1); rany = GetY()+zone->random.Int(0, ran-1)-zone->random.Int(0, ran-1); ranz = FindGroundZ(ranx,rany); - if (ranz == -999999) + if (ranz == BEST_Z_INVALID) continue; float fdist = ranz - GetZ(); if (fdist >= -12 && fdist <= 12 && CheckCoordLosNoZLeaps(GetX(),GetY(),GetZ(),ranx,rany,ranz)) diff --git a/zone/mob.cpp b/zone/mob.cpp index 342626078..0bb043bc5 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3441,7 +3441,7 @@ void Mob::SetTarget(Mob* mob) { float Mob::FindGroundZ(float new_x, float new_y, float z_offset) { - float ret = -999999; + float ret = BEST_Z_INVALID; if (zone->zonemap != nullptr) { glm::vec3 me; @@ -3450,7 +3450,7 @@ float Mob::FindGroundZ(float new_x, float new_y, float z_offset) me.z = m_Position.z + z_offset; glm::vec3 hit; float best_z = zone->zonemap->FindBestZ(me, &hit); - if (best_z != -999999) + if (best_z != BEST_Z_INVALID) { ret = best_z; } @@ -3461,7 +3461,7 @@ float Mob::FindGroundZ(float new_x, float new_y, float z_offset) // Copy of above function that isn't protected to be exported to Perl::Mob float Mob::GetGroundZ(float new_x, float new_y, float z_offset) { - float ret = -999999; + float ret = BEST_Z_INVALID; if (zone->zonemap != 0) { glm::vec3 me; @@ -3470,7 +3470,7 @@ float Mob::GetGroundZ(float new_x, float new_y, float z_offset) me.z = m_Position.z+z_offset; glm::vec3 hit; float best_z = zone->zonemap->FindBestZ(me, &hit); - if (best_z != -999999) + if (best_z != BEST_Z_INVALID) { ret = best_z; } diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 9ed7c46f9..ca0d24175 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -867,7 +867,7 @@ void Mob::FixZ(int32 z_find_offset /*= 5*/) duration ); - if ((new_z > -2000) && new_z != -999999) { + if ((new_z > -2000) && new_z != BEST_Z_INVALID) { if (RuleB(Map, MobZVisualDebug)) this->SendAppearanceEffect(78, 0, 0, 0, 0); From 9634bef7fc9d1bcca1b761c9de562a4df66d1b9b Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 17 Sep 2017 21:33:58 -0400 Subject: [PATCH 24/97] Identify Stackable and Lore in OP_AdventureMerchantResponse Thanks eqmule! --- zone/client_packet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index b72760e4f..733250700 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -2139,8 +2139,8 @@ void Client::Handle_OP_AdventureMerchantRequest(const EQApplicationPacket *app) ss << item->ID << "|"; ss << item->LDoNPrice << "|"; ss << theme << "|"; - ss << "0|"; - ss << "1|"; + ss << (item->Stackable ? 1 : 0) << "|"; + ss << (item->LoreFlag ? 1 : 0) << "|"; ss << item->Races << "|"; ss << item->Classes; count++; From 8c9b8525864c1c7ffce1691ef03205d2a0ea86fb Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Tue, 19 Sep 2017 02:01:06 -0400 Subject: [PATCH 25/97] Fix food/drink to match live --- common/features.h | 5 +++ common/ruletypes.h | 2 +- zone/bonuses.cpp | 11 ++++++ zone/client.cpp | 81 +++++++++++++++++------------------------ zone/client.h | 1 - zone/client_packet.cpp | 4 ++ zone/client_process.cpp | 49 +++++++++++++------------ zone/common.h | 1 + zone/spell_effects.cpp | 10 ----- 9 files changed, 82 insertions(+), 82 deletions(-) diff --git a/common/features.h b/common/features.h index 550c3fa7b..486255f28 100644 --- a/common/features.h +++ b/common/features.h @@ -276,6 +276,11 @@ enum { #define SAYLINK_ITEM_ID 0xFFFFF +// consumption timers for food/drink here instead of rules because the client +// uses these. Times in ms. +#define CONSUMPTION_TIMER 46000 +#define CONSUMPTION_MNK_TIMER 92000 + /* Developer configuration diff --git a/common/ruletypes.h b/common/ruletypes.h index 529c7d239..20bdce740 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -117,7 +117,7 @@ RULE_BOOL(Character, EnableDiscoveredItems, true) // If enabled, it enables EVEN RULE_BOOL(Character, EnableXTargetting, true) // Enable Extended Targetting Window, for users with UF and later clients. RULE_BOOL(Character, EnableAggroMeter, true) // Enable Aggro Meter, for users with RoF and later clients. RULE_BOOL(Character, KeepLevelOverMax, false) // Don't delevel a character that has somehow gone over the level cap -RULE_INT(Character, FoodLossPerUpdate, 35) // How much food/water you lose per stamina update +RULE_INT(Character, FoodLossPerUpdate, 32) // How much food/water you lose per stamina update RULE_INT(Character, BaseInstrumentSoftCap, 36) // Softcap for instrument mods, 36 commonly referred to as "3.6" as well. RULE_BOOL(Character, UseSpellFileSongCap, true) // When they removed the AA that increased the cap they removed the above and just use the spell field RULE_INT(Character, BaseRunSpeedCap, 158) // Base Run Speed Cap, on live it's 158% which will give you a runspeed of 1.580 hard capped to 225. diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index 098de9eb9..acf604cf1 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -120,6 +120,13 @@ void Client::CalcBonuses() if (GetMaxXTargets() != 5 + aabonuses.extra_xtargets) SetMaxXTargets(5 + aabonuses.extra_xtargets); + + // hmm maybe a better way to do this + int metabolism = spellbonuses.Metabolism + itembonuses.Metabolism + aabonuses.Metabolism; + int timer = GetClass() == MONK ? CONSUMPTION_MNK_TIMER : CONSUMPTION_TIMER; + timer = timer * (100 + metabolism) / 100; + if (timer != consume_food_timer.GetTimerTime()) + consume_food_timer.SetTimer(timer); } int Client::CalcRecommendedLevelBonus(uint8 level, uint8 reclevel, int basestat) @@ -2503,6 +2510,10 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses *ne new_bonus->MagicWeapon = true; break; + case SE_Hunger: + new_bonus->hunger = true; + break; + case SE_IncreaseBlockChance: if (AdditiveWornBonus) new_bonus->IncreaseBlockChance += effect_value; diff --git a/zone/client.cpp b/zone/client.cpp index 7a7c57861..da95a0ad7 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -123,8 +123,7 @@ Client::Client(EQStreamInterface* ieqs) hpupdate_timer(2000), camp_timer(29000), process_timer(100), - stamina_timer(40000), - consume_food_timer(60000), + consume_food_timer(CONSUMPTION_TIMER), zoneinpacket_timer(1000), linkdead_timer(RuleI(Zone,ClientLinkdeadMS)), dead_timer(2000), @@ -8591,64 +8590,52 @@ void Client::SetConsumption(int32 in_hunger, int32 in_thirst) void Client::Consume(const EQEmu::ItemData *item, uint8 type, int16 slot, bool auto_consume) { - if(!item) { return; } + if (!item) + return; - /* - Spell Bonuses 2 digit form - 10, 20, 25 etc. (10%, 20%, 25%) - AA Bonus Ranks, 110, 125, 150 etc. (10%, 25%, 50%) - */ + int increase = item->CastTime_ * 100; + if (!auto_consume) // force feeding is half as effective + increase /= 2; - float aa_bonus = ((float) aabonuses.Metabolism - 100) / 100; - float item_bonus = (float) itembonuses.Metabolism / 100; - float spell_bonus = (float) spellbonuses.Metabolism / 100; - - float metabolism_mod = 1 + spell_bonus + item_bonus + aa_bonus; - - Log(Logs::General, Logs::Food, "Client::Consume() Metabolism bonuses spell_bonus: (%.2f) item_bonus: (%.2f) aa_bonus: (%.2f) final: (%.2f)", - spell_bonus, - item_bonus, - aa_bonus, - metabolism_mod - ); + if (increase < 0) // wasn't food? oh well + return; if (type == EQEmu::item::ItemTypeFood) { - int hunger_change = item->CastTime_ * metabolism_mod; - hunger_change = mod_food_value(item, hunger_change); + increase = mod_food_value(item, increase); - if(hunger_change < 0) - return; + if (increase < 0) + return; - m_pp.hunger_level += hunger_change; + m_pp.hunger_level += increase; - Log(Logs::General, Logs::Food, "Consuming food, points added to hunger_level: %i - current_hunger: %i", hunger_change, m_pp.hunger_level); - - DeleteItemInInventory(slot, 1, false); - - if(!auto_consume) //no message if the client consumed for us - entity_list.MessageClose_StringID(this, true, 50, 0, EATING_MESSAGE, GetName(), item->Name); - - Log(Logs::General, Logs::Food, "Eating from slot: %i", (int)slot); - - } - else { - int thirst_change = item->CastTime_ * metabolism_mod; - thirst_change = mod_drink_value(item, thirst_change); - - if(thirst_change < 0) - return; - - m_pp.thirst_level += thirst_change; + Log(Logs::General, Logs::Food, "Consuming food, points added to hunger_level: %i - current_hunger: %i", + increase, m_pp.hunger_level); DeleteItemInInventory(slot, 1, false); - Log(Logs::General, Logs::Food, "Consuming drink, points added to thirst_level: %i current_thirst: %i", thirst_change, m_pp.thirst_level); + if (!auto_consume) // no message if the client consumed for us + entity_list.MessageClose_StringID(this, true, 50, 0, EATING_MESSAGE, GetName(), item->Name); - if(!auto_consume) //no message if the client consumed for us + Log(Logs::General, Logs::Food, "Eating from slot: %i", (int)slot); + + } else { + increase = mod_drink_value(item, increase); + + if (increase < 0) + return; + + m_pp.thirst_level += increase; + + DeleteItemInInventory(slot, 1, false); + + Log(Logs::General, Logs::Food, "Consuming drink, points added to thirst_level: %i current_thirst: %i", + increase, m_pp.thirst_level); + + if (!auto_consume) // no message if the client consumed for us entity_list.MessageClose_StringID(this, true, 50, 0, DRINKING_MESSAGE, GetName(), item->Name); - Log(Logs::General, Logs::Food, "Drinking from slot: %i", (int)slot); - - } + Log(Logs::General, Logs::Food, "Drinking from slot: %i", (int)slot); + } } void Client::SendMarqueeMessage(uint32 type, uint32 priority, uint32 fade_in, uint32 fade_out, uint32 duration, std::string msg) diff --git a/zone/client.h b/zone/client.h index b6098c6b3..051d433e4 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1458,7 +1458,6 @@ private: Timer hpupdate_timer; Timer camp_timer; Timer process_timer; - Timer stamina_timer; Timer consume_food_timer; Timer zoneinpacket_timer; Timer linkdead_timer; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 733250700..7b48b207b 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1410,6 +1410,10 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) drakkin_tattoo = m_pp.drakkin_tattoo; drakkin_details = m_pp.drakkin_details; + // we know our class now, so we might have to fix our consume timer! + if (class_ == MONK) + consume_food_timer.SetTimer(CONSUMPTION_MNK_TIMER); + /* If GM not set in DB, and does not meet min status to be GM, reset */ if (m_pp.gm && admin < minStatusToBeGM) m_pp.gm = 0; diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 5ab5db7a8..4802c24a9 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -524,10 +524,9 @@ bool Client::Process() { DoEnduranceUpkeep(); } - if (consume_food_timer.Check()) { - m_pp.hunger_level = m_pp.hunger_level - 1; - m_pp.thirst_level = m_pp.thirst_level - 1; - } + // this is independent of the tick timer + if (consume_food_timer.Check()) + DoStaminaHungerUpdate(); if (tic_timer.Check() && !dead) { CalcMaxHP(); @@ -539,7 +538,6 @@ bool Client::Process() { DoManaRegen(); DoEnduranceRegen(); BuffProcess(); - DoStaminaHungerUpdate(); if (tribute_timer.Check()) { ToggleTribute(true); //re-activate the tribute. @@ -1834,32 +1832,37 @@ void Client::DoManaRegen() { CheckManaEndUpdate(); } -void Client::DoStaminaHungerUpdate() { - if(!stamina_timer.Check()) - return; - +void Client::DoStaminaHungerUpdate() +{ auto outapp = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct)); - Stamina_Struct* sta = (Stamina_Struct*)outapp->pBuffer; + Stamina_Struct *sta = (Stamina_Struct *)outapp->pBuffer; - Log(Logs::General, Logs::Food, "Client::DoStaminaHungerUpdate() hunger_level: %i thirst_level: %i before loss", m_pp.hunger_level, m_pp.thirst_level); + Log(Logs::General, Logs::Food, "Client::DoStaminaHungerUpdate() hunger_level: %i thirst_level: %i before loss", + m_pp.hunger_level, m_pp.thirst_level); - if (zone->GetZoneID() != 151) { - sta->food = m_pp.hunger_level > 6000 ? 6000 : m_pp.hunger_level; - sta->water = m_pp.thirst_level > 6000 ? 6000 : m_pp.thirst_level; - } - else { + if (zone->GetZoneID() != 151 && !GetGM()) { + int loss = RuleI(Character, FoodLossPerUpdate); + if (GetHorseId() != 0) + loss *= 3; + + m_pp.hunger_level = EQEmu::Clamp(m_pp.hunger_level - loss, 0, 6000); + m_pp.thirst_level = EQEmu::Clamp(m_pp.thirst_level - loss, 0, 6000); + if (spellbonuses.hunger) { + m_pp.hunger_level = EQEmu::ClampLower(m_pp.hunger_level, 3500); + m_pp.thirst_level = EQEmu::ClampLower(m_pp.thirst_level, 3500); + } + sta->food = m_pp.hunger_level; + sta->water = m_pp.thirst_level; + } else { // No auto food/drink consumption in the Bazaar sta->food = 6000; sta->water = 6000; } - Log(Logs::General, Logs::Food, - "Client::DoStaminaHungerUpdate() Current hunger_level: %i = (%i minutes left) thirst_level: %i = (%i minutes left) - after loss", - m_pp.hunger_level, - m_pp.hunger_level, - m_pp.thirst_level, - m_pp.thirst_level - ); + Log(Logs::General, Logs::Food, + "Client::DoStaminaHungerUpdate() Current hunger_level: %i = (%i minutes left) thirst_level: %i = (%i " + "minutes left) - after loss", + m_pp.hunger_level, m_pp.hunger_level, m_pp.thirst_level, m_pp.thirst_level); FastQueuePacket(&outapp); } diff --git a/zone/common.h b/zone/common.h index 7b6382a20..bcc9ff305 100644 --- a/zone/common.h +++ b/zone/common.h @@ -550,6 +550,7 @@ struct StatBonuses { int FeignedMinionChance; // SPA 281 base1 = chance, just like normal FD int aura_slots; int trap_slots; + bool hunger; // Song of Sustenance -- min caps to 3500 }; typedef struct diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 69a5b232b..46b44fb3a 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -3656,16 +3656,6 @@ void Mob::DoBuffTic(const Buffs_Struct &buff, int slot, Mob *caster) break; } - case SE_Hunger: { - // this procedure gets called 7 times for every once that the stamina update occurs so we add - // 1/7 of the subtraction. - // It's far from perfect, but works without any unnecessary buff checks to bog down the server. - if (IsClient()) { - CastToClient()->m_pp.hunger_level += 5; - CastToClient()->m_pp.thirst_level += 5; - } - break; - } case SE_Invisibility: case SE_InvisVsAnimals: case SE_InvisVsUndead: { From 48b674a13dc51850e65b30bec695de8facca985c Mon Sep 17 00:00:00 2001 From: Michael Linder Date: Wed, 20 Sep 2017 19:04:59 -0500 Subject: [PATCH 26/97] During bot spawn, set bot to targetable. Fixes issue #657. --- zone/bot.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zone/bot.cpp b/zone/bot.cpp index c78c41d62..a2e7a2fec 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -2841,6 +2841,8 @@ void Bot::Spawn(Client* botCharacterOwner) { FaceTarget(botCharacterOwner); UpdateEquipmentLight(); UpdateActiveLight(); + + this->m_targetable = true; entity_list.AddBot(this, true, true); // Load pet LoadPet(); From 78759add4ae85ff4047620de5b6c449539c3a733 Mon Sep 17 00:00:00 2001 From: Michael Linder Date: Wed, 20 Sep 2017 19:06:09 -0500 Subject: [PATCH 27/97] Ignore bots during group position update. Fixes zone.exe crash when a client gets too far away from their bots. --- zone/groups.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zone/groups.cpp b/zone/groups.cpp index d72b71c30..a7e05bf49 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -2471,6 +2471,9 @@ void Group::QueueClients(Mob *sender, const EQApplicationPacket *app, bool ack_r if (!members[i]) continue; + if (!members[i]->IsClient()) + continue; + if (ignore_sender && members[i] == sender) continue; From c7ad873581aca1371357f08e95002885782dee93 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Sun, 24 Sep 2017 16:33:08 -0400 Subject: [PATCH 28/97] Rule to dictate if you can teach yourself lang. --- common/ruletypes.h | 1 + zone/client.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/common/ruletypes.h b/common/ruletypes.h index 20bdce740..67591d402 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -186,6 +186,7 @@ RULE_INT(Skills, MaxTrainSpecializations, 50) // Max level a GM trainer will tra RULE_INT(Skills, SwimmingStartValue, 100) RULE_BOOL(Skills, TrainSenseHeading, false) RULE_INT(Skills, SenseHeadingStartValue, 200) +RULE_BOOL(Skills, SelfLanguageLearning, true) RULE_CATEGORY_END() RULE_CATEGORY(Pets) diff --git a/zone/client.cpp b/zone/client.cpp index da95a0ad7..19dfeb711 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -1225,9 +1225,14 @@ void Client::ChannelMessageSend(const char* from, const char* to, uint8 chan_num strcpy(&cm->message[0], buffer); QueuePacket(&app); - if ((chan_num == 2) && (ListenerSkill < 100)) { // group message in unmastered language, check for skill up - if (m_pp.languages[language] <= lang_skill) - CheckLanguageSkillIncrease(language, lang_skill); + bool senderCanTrainSelf = RuleB(Client, SelfLanguageLearning); + bool weAreNotSender = strcmp(this->GetCleanName(), cm->sender); + + if (senderCanTrainSelf || weAreNotSender) { + if ((chan_num == 2) && (ListenerSkill < 100)) { // group message in unmastered language, check for skill up + if (m_pp.languages[language] <= lang_skill) + CheckLanguageSkillIncrease(language, lang_skill); + } } } From 5285e8a16326e15bc643a2455afb54195e1b1ed8 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Mon, 2 Oct 2017 14:40:21 -0400 Subject: [PATCH 29/97] Rooted mobs cast spells instead of doing nothing. --- zone/mob_ai.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 58c856d77..8efdba38c 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -57,7 +57,11 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes) { if(AI_HasSpells() == false) return false; - if (iChance < 100) { + // Rooted mobs were just standing around when tar out of range. + // Any sane mob would cast if they can. + bool cast_only_option = (IsRooted() && !CombatRange(tar)); + + if (!cast_only_option && iChance < 100) { if (zone->random.Int(0, 100) >= iChance) return false; } From f8571a57dd212a1cbb12407288dacf9c4c18e597 Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Fri, 6 Oct 2017 17:50:57 -0500 Subject: [PATCH 30/97] Create LICENSE --- LICENSE | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..65c5ca88a --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. From bb2a6dce23aa53f6cd366639d2bfbc58310344f0 Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Fri, 6 Oct 2017 17:57:42 -0500 Subject: [PATCH 31/97] Delete LICENSE.md --- LICENSE.md | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index fd134ec9e..000000000 --- a/LICENSE.md +++ /dev/null @@ -1,12 +0,0 @@ -The server code and utilities are released under GPLv3. - -We also include some small libraries for convienence that may be under different licensing: - -SocketLib - GPL -LibXML - ZLib License -StackWalker - New BSD License -ZLib - ZLib License -MySQL - GPL -Perl - GPL / ActiveState (under the assumption that this is a free project). -CPPUnit - GLP -StringUtilities - Apache \ No newline at end of file From 6c2f554a31a853b1274aba6745cf72dd0e42592a Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Fri, 6 Oct 2017 18:04:12 -0500 Subject: [PATCH 32/97] Update README.md --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index f99b17975..4e32a8ede 100644 --- a/README.md +++ b/README.md @@ -57,3 +57,14 @@ Resources --- - [EQEmulator Forums](http://www.eqemulator.org/forums) - [EQEmulator Wiki](http://wiki.eqemulator.org/i?M=Wiki) + +## Other License Info + +* The server code and utilities are released under **GPLv3** +* We also include some small libraries for convienence that may be under different licensing + * SocketLib - GPL LibXML + * zlib - zlib license + * MariaDB/MySQL - GPL + * GPL Perl - GPL / ActiveState (under the assumption that this is a free project) + * CPPUnit - GLP StringUtilities - Apache + * LUA - MIT From e352171efa6c2fac06c81192669ca7d2c155f6f1 Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Fri, 6 Oct 2017 18:21:37 -0500 Subject: [PATCH 33/97] Delete GPL.txt --- GPL.txt | 339 -------------------------------------------------------- 1 file changed, 339 deletions(-) delete mode 100644 GPL.txt diff --git a/GPL.txt b/GPL.txt deleted file mode 100644 index d511905c1..000000000 --- a/GPL.txt +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. From 43f459b1945cca30c365505ea55a3a074f133510 Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Fri, 6 Oct 2017 20:13:35 -0500 Subject: [PATCH 34/97] Update README.md --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4e32a8ede..baac6618e 100644 --- a/README.md +++ b/README.md @@ -53,11 +53,16 @@ forum, although pull requests will be much quicker and easier on all parties. - **User Discord Channel**: `#general` - **Developer Discord Channel**: `#eqemucoders` -Resources ---- +## Resources - [EQEmulator Forums](http://www.eqemulator.org/forums) - [EQEmulator Wiki](http://wiki.eqemulator.org/i?M=Wiki) +## Related Repositories +* [ProjectEQ Quests](https://github.com/ProjectEQ/projecteqquests) +* [Maps](https://github.com/Akkadius/EQEmuMaps) +* [Installer Resources](https://github.com/Akkadius/EQEmuInstall) +* [Zone Utilities](https://github.com/EQEmu/zone-utilities) - Various utilities and libraries for parsing, rendering and manipulating EQ Zone files. + ## Other License Info * The server code and utilities are released under **GPLv3** From 8400994c57c085379971a709e8c1dbade603316b Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 8 Oct 2017 00:13:53 -0400 Subject: [PATCH 35/97] Rework regens to match modern clients --- changelog.txt | 9 + common/base_data.h | 4 +- common/eq_packet_structs.h | 4 +- common/patches/rof.cpp | 6 +- common/patches/rof2.cpp | 6 +- common/patches/rof2_structs.h | 5 +- common/patches/rof_structs.h | 5 +- common/patches/sod.cpp | 1 + common/patches/sod_structs.h | 4 +- common/patches/sof.cpp | 1 + common/patches/sof_structs.h | 4 +- common/patches/titanium.cpp | 1 + common/patches/titanium_structs.h | 4 +- common/patches/uf.cpp | 1 + common/patches/uf_structs.h | 4 +- common/ruletypes.h | 9 +- common/shareddb.cpp | 4 +- common/spdat.h | 5 + .../2017_10_07_new_default_rule_values.sql | 3 + zone/bonuses.cpp | 2 +- zone/bot.cpp | 9 +- zone/client.cpp | 216 +++++++++++++++- zone/client.h | 50 +++- zone/client_mods.cpp | 239 +++++++++++++++--- zone/client_packet.cpp | 4 + zone/client_process.cpp | 26 +- zone/horse.cpp | 1 + zone/merc.cpp | 9 +- zone/mob.h | 1 + zone/spell_effects.cpp | 3 + zone/spells.cpp | 13 + 31 files changed, 558 insertions(+), 95 deletions(-) create mode 100644 utils/sql/git/optional/2017_10_07_new_default_rule_values.sql diff --git a/changelog.txt b/changelog.txt index 9d3535d62..72434e602 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,14 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 10/08/2017 == +Mackal: Rework regens + +Regen will now match whats reported by modern clients, besides where they lie due to known bugs + +HP and END regens are now based on the BaseData.txt values allowing easy customization +Those cases: + - The client always applies hunger penalties, it appears they don't exist anymore on live you can turn them on with a rule + - The way the client gets buff mana/end regen benefits incorrectly applies the bard mod making these values lie sometimes == 9/17/2017 == Akkadius: Add model/race offset to FixZ calc (KLS) diff --git a/common/base_data.h b/common/base_data.h index fb2766f45..4d8cf4a9f 100644 --- a/common/base_data.h +++ b/common/base_data.h @@ -24,8 +24,8 @@ struct BaseDataStruct double base_hp; double base_mana; double base_end; - double unk1; - double unk2; + double hp_regen; + double end_regen; double hp_factor; double mana_factor; double endurance_factor; diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index 79b8f7250..46aade124 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -854,6 +854,7 @@ static const uint32 MAX_PP_REF_SPELLBOOK = 480; // Set for Player Profile size r static const uint32 MAX_PP_REF_MEMSPELL = 9; // Set for Player Profile size retain static const uint32 MAX_PP_SKILL = PACKET_SKILL_ARRAY_SIZE; // 100 - actual skills buffer size +static const uint32 MAX_PP_INNATE_SKILL = 25; static const uint32 MAX_PP_AA_ARRAY = 240; static const uint32 MAX_GROUP_MEMBERS = 6; static const uint32 MAX_RECAST_TYPES = 20; @@ -993,7 +994,8 @@ struct PlayerProfile_Struct /*4768*/ int32 platinum_shared; // Platinum shared between characters /*4772*/ uint8 unknown4808[24]; /*4796*/ uint32 skills[MAX_PP_SKILL]; // [400] List of skills // 100 dword buffer -/*5196*/ uint8 unknown5132[184]; +/*5196*/ uint32 InnateSkills[MAX_PP_INNATE_SKILL]; +/*5296*/ uint8 unknown5132[84]; /*5380*/ uint32 pvp2; // /*5384*/ uint32 unknown5420; // /*5388*/ uint32 pvptype; // diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index 7ce6f900f..1df8d1aa5 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -2184,11 +2184,11 @@ namespace RoF outapp->WriteUInt32(emu->skills[r]); } - outapp->WriteUInt32(25); // Unknown count + outapp->WriteUInt32(structs::MAX_PP_INNATE_SKILL); // Innate Skills count - for (uint32 r = 0; r < 25; r++) + for (uint32 r = 0; r < structs::MAX_PP_INNATE_SKILL; r++) { - outapp->WriteUInt32(0); // Unknown + outapp->WriteUInt32(emu->InnateSkills[r]); // Innate Skills (regen, slam, etc) } outapp->WriteUInt32(structs::MAX_PP_DISCIPLINES); // Discipline count diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index afb994526..57a8d9eb6 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -2261,11 +2261,11 @@ namespace RoF2 outapp->WriteUInt32(emu->skills[r]); } - outapp->WriteUInt32(25); // Unknown count + outapp->WriteUInt32(structs::MAX_PP_INNATE_SKILL); // Innate Skills count - for (uint32 r = 0; r < 25; r++) + for (uint32 r = 0; r < structs::MAX_PP_INNATE_SKILL; r++) { - outapp->WriteUInt32(0); // Unknown + outapp->WriteUInt32(emu->InnateSkills[r]); // Innate Skills (regen, slam, etc) } outapp->WriteUInt32(structs::MAX_PP_DISCIPLINES); // Discipline count diff --git a/common/patches/rof2_structs.h b/common/patches/rof2_structs.h index 41fc9528a..28905dd4a 100644 --- a/common/patches/rof2_structs.h +++ b/common/patches/rof2_structs.h @@ -131,6 +131,7 @@ static const uint32 MAX_PP_LANGUAGE = 32; // was 25 static const uint32 MAX_PP_SPELLBOOK = 720; // was 480 static const uint32 MAX_PP_MEMSPELL = 16; // was 12 static const uint32 MAX_PP_SKILL = PACKET_SKILL_ARRAY_SIZE; // 100 - actual skills buffer size +static const uint32 MAX_PP_INNATE_SKILL = 25; static const uint32 MAX_PP_AA_ARRAY = 300; static const uint32 MAX_PP_DISCIPLINES = 300; // was 200 static const uint32 MAX_GROUP_MEMBERS = 6; @@ -1155,8 +1156,8 @@ union /*01012*/ AA_Array aa_array[MAX_PP_AA_ARRAY]; // [300] 3600 bytes - AAs 12 bytes each /*04612*/ uint32 skill_count; // Seen 100 /*04616*/ uint32 skills[MAX_PP_SKILL]; // [100] 400 bytes - List of skills -/*05016*/ uint32 unknown15_count; // Seen 25 -/*05020*/ uint32 unknown_rof15[25]; // Most are 255 or 0 +/*05016*/ uint32 InnateSkills_count; // Seen 25 +/*05020*/ uint32 InnateSkills[MAX_PP_INNATE_SKILL]; // Most are 255 or 0 /*05120*/ uint32 discipline_count; // Seen 200 /*05124*/ Disciplines_Struct disciplines; // [200] 800 bytes Known disciplines /*05924*/ uint32 timestamp_count; // Seen 20 diff --git a/common/patches/rof_structs.h b/common/patches/rof_structs.h index 24439d7f0..8de4fb9ab 100644 --- a/common/patches/rof_structs.h +++ b/common/patches/rof_structs.h @@ -131,6 +131,7 @@ static const uint32 MAX_PP_LANGUAGE = 32; // was 25 static const uint32 MAX_PP_SPELLBOOK = 720; // was 480 static const uint32 MAX_PP_MEMSPELL = 16; // was 12 static const uint32 MAX_PP_SKILL = PACKET_SKILL_ARRAY_SIZE; // 100 - actual skills buffer size +static const uint32 MAX_PP_INNATE_SKILL = 25; static const uint32 MAX_PP_AA_ARRAY = 300; static const uint32 MAX_PP_DISCIPLINES = 200; // was 100 static const uint32 MAX_GROUP_MEMBERS = 6; @@ -1096,8 +1097,8 @@ union /*01012*/ AA_Array aa_array[MAX_PP_AA_ARRAY]; // [300] 3600 bytes - AAs 12 bytes each /*04612*/ uint32 skill_count; // Seen 100 /*04616*/ uint32 skills[MAX_PP_SKILL]; // [100] 400 bytes - List of skills -/*05016*/ uint32 unknown15_count; // Seen 25 -/*05020*/ uint32 unknown_rof15[25]; // Most are 255 or 0 +/*05016*/ uint32 InnateSkills_count; // Seen 25 +/*05020*/ uint32 InnateSkills[MAX_PP_INNATE_SKILL]; // Most are 255 or 0 /*05120*/ uint32 discipline_count; // Seen 200 /*05124*/ Disciplines_Struct disciplines; // [200] 800 bytes Known disciplines /*05924*/ uint32 timestamp_count; // Seen 20 diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index 276f939e5..a77feedbc 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -1605,6 +1605,7 @@ namespace SoD OUT(copper_cursor); OUT_array(skills, structs::MAX_PP_SKILL); // 1:1 direct copy (100 dword) + OUT_array(InnateSkills, structs::MAX_PP_INNATE_SKILL); // 1:1 direct copy (25 dword) // OUT(unknown04760[236]); OUT(toxicity); diff --git a/common/patches/sod_structs.h b/common/patches/sod_structs.h index af449f758..88ccd7788 100644 --- a/common/patches/sod_structs.h +++ b/common/patches/sod_structs.h @@ -818,6 +818,7 @@ static const uint32 MAX_PP_LANGUAGE = 25; // static const uint32 MAX_PP_SPELLBOOK = 480; // Confirmed 60 pages on Live now static const uint32 MAX_PP_MEMSPELL = 10; //was 9 now 10 on Live static const uint32 MAX_PP_SKILL = PACKET_SKILL_ARRAY_SIZE; // 100 - actual skills buffer size +static const uint32 MAX_PP_INNATE_SKILL = 25; static const uint32 MAX_PP_AA_ARRAY = 300; //was 299 static const uint32 MAX_GROUP_MEMBERS = 6; static const uint32 MAX_RECAST_TYPES = 20; @@ -923,7 +924,8 @@ struct PlayerProfile_Struct /*06488*/ uint32 silver_cursor; // Silver Pieces on cursor /*06492*/ uint32 copper_cursor; // Copper Pieces on cursor /*06496*/ uint32 skills[MAX_PP_SKILL]; // [400] List of skills // 100 dword buffer -/*06896*/ uint8 unknown04760[136]; +/*06896*/ uint32 InnateSkills[MAX_PP_SKILL]; +/*06996*/ uint8 unknown04760[36]; /*07032*/ uint32 toxicity; // Potion Toxicity (15=too toxic, each potion adds 3) /*07036*/ uint32 thirst_level; // Drink (ticks till next drink) /*07040*/ uint32 hunger_level; // Food (ticks till next eat) diff --git a/common/patches/sof.cpp b/common/patches/sof.cpp index 77d65ce16..9df6ca1df 100644 --- a/common/patches/sof.cpp +++ b/common/patches/sof.cpp @@ -1276,6 +1276,7 @@ namespace SoF OUT(copper_cursor); OUT_array(skills, structs::MAX_PP_SKILL); // 1:1 direct copy (100 dword) + OUT_array(InnateSkills, structs::MAX_PP_INNATE_SKILL); // 1:1 direct copy (25 dword) // OUT(unknown04760[236]); OUT(toxicity); diff --git a/common/patches/sof_structs.h b/common/patches/sof_structs.h index 00fcd4ecf..2a1eab3f0 100644 --- a/common/patches/sof_structs.h +++ b/common/patches/sof_structs.h @@ -799,6 +799,7 @@ static const uint32 MAX_PP_LANGUAGE = 25; // static const uint32 MAX_PP_SPELLBOOK = 480; // Confirmed 60 pages on Live now static const uint32 MAX_PP_MEMSPELL = 10; //was 9 now 10 on Live static const uint32 MAX_PP_SKILL = PACKET_SKILL_ARRAY_SIZE; // 100 - actual skills buffer size +static const uint32 MAX_PP_INNATE_SKILL = 25; static const uint32 MAX_PP_AA_ARRAY = 300; //was 299 static const uint32 MAX_GROUP_MEMBERS = 6; static const uint32 MAX_RECAST_TYPES = 20; @@ -903,7 +904,8 @@ struct PlayerProfile_Struct //23576 Octets /*06488*/ uint32 silver_cursor; // Silver Pieces on cursor /*06492*/ uint32 copper_cursor; // Copper Pieces on cursor /*06496*/ uint32 skills[MAX_PP_SKILL]; // [400] List of skills // 100 dword buffer -/*06896*/ uint8 unknown04760[136]; +/*06896*/ uint32 InnateSkills[MAX_PP_INNATE_SKILL]; +/*06996*/ uint8 unknown04760[36]; /*07032*/ uint32 toxicity; // Potion Toxicity (15=too toxic, each potion adds 3) /*07036*/ uint32 thirst_level; // Drink (ticks till next drink) /*07040*/ uint32 hunger_level; // Food (ticks till next eat) diff --git a/common/patches/titanium.cpp b/common/patches/titanium.cpp index e9679dc06..45f267223 100644 --- a/common/patches/titanium.cpp +++ b/common/patches/titanium.cpp @@ -1020,6 +1020,7 @@ namespace Titanium OUT(copper_cursor); OUT_array(skills, structs::MAX_PP_SKILL); // 1:1 direct copy (100 dword) + OUT_array(InnateSkills, structs::MAX_PP_INNATE_SKILL); // 1:1 direct copy (25 dword) // OUT(unknown04760[236]); OUT(toxicity); diff --git a/common/patches/titanium_structs.h b/common/patches/titanium_structs.h index 69988dd7c..56213854a 100644 --- a/common/patches/titanium_structs.h +++ b/common/patches/titanium_structs.h @@ -740,6 +740,7 @@ static const uint32 MAX_PP_LANGUAGE = 28; static const uint32 MAX_PP_SPELLBOOK = 400; static const uint32 MAX_PP_MEMSPELL = 9; static const uint32 MAX_PP_SKILL = PACKET_SKILL_ARRAY_SIZE; // 100 - actual skills buffer size +static const uint32 MAX_PP_INNATE_SKILL = 25; static const uint32 MAX_PP_AA_ARRAY = 240; static const uint32 MAX_GROUP_MEMBERS = 6; static const uint32 MAX_RECAST_TYPES = 20; @@ -844,7 +845,8 @@ struct PlayerProfile_Struct /*04452*/ uint32 silver_cursor; // Silver Pieces on cursor /*04456*/ uint32 copper_cursor; // Copper Pieces on cursor /*04460*/ uint32 skills[MAX_PP_SKILL]; // [400] List of skills // 100 dword buffer -/*04860*/ uint8 unknown04760[136]; +/*04860*/ uint32 InnateSkills[MAX_PP_INNATE_SKILL]; +/*04960*/ uint8 unknown04760[36]; /*04996*/ uint32 toxicity; // Potion Toxicity (15=too toxic, each potion adds 3) /*05000*/ uint32 thirst_level; // Drink (ticks till next drink) /*05004*/ uint32 hunger_level; // Food (ticks till next eat) diff --git a/common/patches/uf.cpp b/common/patches/uf.cpp index 8b0c86cc5..87cd6c700 100644 --- a/common/patches/uf.cpp +++ b/common/patches/uf.cpp @@ -1850,6 +1850,7 @@ namespace UF OUT(copper_cursor); OUT_array(skills, structs::MAX_PP_SKILL); // 1:1 direct copy (100 dword) + OUT_array(InnateSkills, structs::MAX_PP_INNATE_SKILL); // 1:1 direct copy (25 dword) // OUT(unknown04760[236]); OUT(toxicity); diff --git a/common/patches/uf_structs.h b/common/patches/uf_structs.h index b187f9f82..cc5564e11 100644 --- a/common/patches/uf_structs.h +++ b/common/patches/uf_structs.h @@ -848,6 +848,7 @@ static const uint32 MAX_PP_LANGUAGE = 25; // static const uint32 MAX_PP_SPELLBOOK = 720; // Confirmed 60 pages on Underfoot now static const uint32 MAX_PP_MEMSPELL = 12; //was 9 now 10 on Underfoot static const uint32 MAX_PP_SKILL = PACKET_SKILL_ARRAY_SIZE; // 100 - actual skills buffer size +static const uint32 MAX_PP_INNATE_SKILL = 25; static const uint32 MAX_PP_AA_ARRAY = 300; //was 299 static const uint32 MAX_GROUP_MEMBERS = 6; static const uint32 MAX_RECAST_TYPES = 20; @@ -954,7 +955,8 @@ struct PlayerProfile_Struct /*07336*/ uint32 silver_cursor; // Silver Pieces on cursor /*07340*/ uint32 copper_cursor; // Copper Pieces on cursor /*07344*/ uint32 skills[MAX_PP_SKILL]; // [400] List of skills // 100 dword buffer -/*07744*/ uint8 unknown07644[136]; +/*07744*/ uint32 InnateSkills[MAX_PP_INNATE_SKILL]; +/*07844*/ uint8 unknown07644[36]; /*07880*/ uint32 toxicity; // Potion Toxicity (15=too toxic, each potion adds 3) /*07884*/ uint32 thirst_level; // Drink (ticks till next drink) /*07888*/ uint32 hunger_level; // Food (ticks till next eat) diff --git a/common/ruletypes.h b/common/ruletypes.h index 67591d402..e1475fa79 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -70,7 +70,7 @@ RULE_INT(Character, ConsumptionMultiplier, 100) //item's hunger restored = this RULE_BOOL(Character, HealOnLevel, false) RULE_BOOL(Character, FeignKillsPet, false) RULE_INT(Character, ItemManaRegenCap, 15) -RULE_INT(Character, ItemHealthRegenCap, 35) +RULE_INT(Character, ItemHealthRegenCap, 30) RULE_INT(Character, ItemDamageShieldCap, 30) RULE_INT(Character, ItemAccuracyCap, 150) RULE_INT(Character, ItemAvoidanceCap, 100) @@ -91,10 +91,12 @@ RULE_INT(Character, HasteCap, 100) // Haste cap for non-v3(overhaste) haste. RULE_INT(Character, SkillUpModifier, 100) //skill ups are at 100% RULE_BOOL(Character, SharedBankPlat, false) //off by default to prevent duping for now RULE_BOOL(Character, BindAnywhere, false) -RULE_INT(Character, RestRegenPercent, 0) // Set to >0 to enable rest state bonus HP and mana regen. +RULE_BOOL(Character, RestRegenEnabled, true) // Enable OOC Regen +RULE_INT(Character, RestRegenHP, 180) // seconds until full from 0. this is actually zone setable, but most or all zones are 180 +RULE_INT(Character, RestRegenMana, 180) // seconds until full from 0. this is actually zone setable, but most or all zones are 180 +RULE_INT(Character, RestRegenEnd, 180) // seconds until full from 0. this is actually zone setable, but most or all zones are 180 RULE_INT(Character, RestRegenTimeToActivate, 30) // Time in seconds for rest state regen to kick in. RULE_INT(Character, RestRegenRaidTimeToActivate, 300) // Time in seconds for rest state regen to kick in with a raid target. -RULE_BOOL(Character, RestRegenEndurance, false) // Whether rest regen will work for endurance or not. RULE_INT(Character, KillsPerGroupLeadershipAA, 250) // Number of dark blues or above per Group Leadership AA RULE_INT(Character, KillsPerRaidLeadershipAA, 250) // Number of dark blues or above per Raid Leadership AA RULE_INT(Character, MaxFearDurationForPlayerCharacter, 4) //4 tics, each tic calculates every 6 seconds. @@ -118,6 +120,7 @@ RULE_BOOL(Character, EnableXTargetting, true) // Enable Extended Targetting Wind RULE_BOOL(Character, EnableAggroMeter, true) // Enable Aggro Meter, for users with RoF and later clients. RULE_BOOL(Character, KeepLevelOverMax, false) // Don't delevel a character that has somehow gone over the level cap RULE_INT(Character, FoodLossPerUpdate, 32) // How much food/water you lose per stamina update +RULE_BOOL(Character, EnableHungerPenalties, false) // being hungry/thirsty has negative effects -- it does appear normal live servers do not have penalties RULE_INT(Character, BaseInstrumentSoftCap, 36) // Softcap for instrument mods, 36 commonly referred to as "3.6" as well. RULE_BOOL(Character, UseSpellFileSongCap, true) // When they removed the AA that increased the cap they removed the above and just use the spell field RULE_INT(Character, BaseRunSpeedCap, 158) // Base Run Speed Cap, on live it's 158% which will give you a runspeed of 1.580 hard capped to 225. diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 331826ef2..09c936425 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -1817,8 +1817,8 @@ void SharedDatabase::LoadBaseData(void *data, int max_level) { bd->base_hp = atof(row[2]); bd->base_mana = atof(row[3]); bd->base_end = atof(row[4]); - bd->unk1 = atof(row[5]); - bd->unk2 = atof(row[6]); + bd->hp_regen = atof(row[5]); + bd->end_regen = atof(row[6]); bd->hp_factor = atof(row[7]); bd->mana_factor = atof(row[8]); bd->endurance_factor = atof(row[9]); diff --git a/common/spdat.h b/common/spdat.h index 605e9a6cf..0f9e7a47a 100644 --- a/common/spdat.h +++ b/common/spdat.h @@ -131,6 +131,11 @@ enum SpellAffectIndex { SAI_NPC_Special_80 = 80, SAI_Trap_Lock = 88 }; + +enum class GlobalGroup { + Lich = 46, +}; + enum RESISTTYPE { RESIST_NONE = 0, diff --git a/utils/sql/git/optional/2017_10_07_new_default_rule_values.sql b/utils/sql/git/optional/2017_10_07_new_default_rule_values.sql new file mode 100644 index 000000000..47ebcf913 --- /dev/null +++ b/utils/sql/git/optional/2017_10_07_new_default_rule_values.sql @@ -0,0 +1,3 @@ +UPDATE `rule_values` SET `rule_value` = '32' WHERE `rule_name` = 'Character:FoodLossPerUpdate'; +UPDATE `rule_values` SET `rule_value` = '30' WHERE `rule_name` = 'Character:ItemHealthRegenCap'; + diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index acf604cf1..c444ff9dd 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -915,7 +915,7 @@ void Mob::ApplyAABonuses(const AA::Rank &rank, StatBonuses *newbon) newbon->GivePetGroupTarget = true; break; case SE_ItemHPRegenCapIncrease: - newbon->ItemHPRegenCap = +base1; + newbon->ItemHPRegenCap += base1; break; case SE_Ambidexterity: newbon->Ambidexterity += base1; diff --git a/zone/bot.cpp b/zone/bot.cpp index a2e7a2fec..6a1521d6b 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -6727,7 +6727,7 @@ int32 Bot::CalcATK() { } void Bot::CalcRestState() { - if(!RuleI(Character, RestRegenPercent)) + if(!RuleB(Character, RestRegenEnabled)) return; RestRegenHP = RestRegenMana = RestRegenEndurance = 0; @@ -6743,10 +6743,9 @@ void Bot::CalcRestState() { } } - RestRegenHP = (GetMaxHP() * RuleI(Character, RestRegenPercent) / 100); - RestRegenMana = (GetMaxMana() * RuleI(Character, RestRegenPercent) / 100); - if(RuleB(Character, RestRegenEndurance)) - RestRegenEndurance = (GetMaxEndurance() * RuleI(Character, RestRegenPercent) / 100); + RestRegenHP = 6 * (GetMaxHP() / RuleI(Character, RestRegenHP)); + RestRegenMana = 6 * (GetMaxMana() / RuleI(Character, RestRegenMana)); + RestRegenEndurance = 6 * (GetMaxEndurance() / RuleI(Character, RestRegenEnd)); } int32 Bot::LevelRegen() { diff --git a/zone/client.cpp b/zone/client.cpp index 19dfeb711..f72d510d5 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -160,7 +160,8 @@ Client::Client(EQStreamInterface* ieqs) npc_close_scan_timer(6000), hp_self_update_throttle_timer(300), hp_other_update_throttle_timer(500), - position_update_timer(10000) + position_update_timer(10000), + tmSitting(0) { for (int client_filter = 0; client_filter < _FilterCount; client_filter++) @@ -270,9 +271,10 @@ Client::Client(EQStreamInterface* ieqs) m_ClientVersion = EQEmu::versions::ClientVersion::Unknown; m_ClientVersionBit = 0; AggroCount = 0; - RestRegenHP = 0; - RestRegenMana = 0; - RestRegenEndurance = 0; + ooc_regen = false; + AreaHPRegen = 1.0f; + AreaManaRegen = 1.0f; + AreaEndRegen = 1.0f; XPRate = 100; current_endurance = 0; @@ -329,6 +331,9 @@ Client::Client(EQStreamInterface* ieqs) interrogateinv_flag = false; + for (int i = 0; i < InnateSkillMax; ++i) + m_pp.InnateSkills[i] = InnateDisabled; + AI_Init(); } @@ -4598,7 +4603,7 @@ void Client::IncrementAggroCount() { // AggroCount++; - if(!RuleI(Character, RestRegenPercent)) + if(!RuleB(Character, RestRegenEnabled)) return; // If we already had aggro before this method was called, the combat indicator should already be up for SoF clients, @@ -4635,7 +4640,7 @@ void Client::DecrementAggroCount() { AggroCount--; - if(!RuleI(Character, RestRegenPercent)) + if(!RuleB(Character, RestRegenEnabled)) return; // Something else is still aggro on us, can't rest yet. @@ -6722,7 +6727,7 @@ void Client::SendStatsWindow(Client* client, bool use_window) cap_regen_field = itoa(CalcHPRegenCap()); spell_regen_field = itoa(spellbonuses.HPRegen); aa_regen_field = itoa(aabonuses.HPRegen); - total_regen_field = itoa(CalcHPRegen()); + total_regen_field = itoa(CalcHPRegen(true)); break; } case 1: { @@ -6735,7 +6740,7 @@ void Client::SendStatsWindow(Client* client, bool use_window) cap_regen_field = itoa(CalcManaRegenCap()); spell_regen_field = itoa(spellbonuses.ManaRegen); aa_regen_field = itoa(aabonuses.ManaRegen); - total_regen_field = itoa(CalcManaRegen()); + total_regen_field = itoa(CalcManaRegen(true)); } else { continue; } break; @@ -6749,7 +6754,7 @@ void Client::SendStatsWindow(Client* client, bool use_window) cap_regen_field = itoa(CalcEnduranceRegenCap()); spell_regen_field = itoa(spellbonuses.EnduranceRegen); aa_regen_field = itoa(aabonuses.EnduranceRegen); - total_regen_field = itoa(CalcEnduranceRegen()); + total_regen_field = itoa(CalcEnduranceRegen(true)); break; } default: { break; } @@ -9066,3 +9071,196 @@ void Client::SetPetCommandState(int button, int state) FastQueuePacket(&app); } +bool Client::CanMedOnHorse() +{ + // no horse is false + if (GetHorseId() == 0) + return false; + + // can't med while attacking + if (auto_attack) + return false; + + return animation == 0 && m_Delta.x == 0.0f && m_Delta.y == 0.0f; // TODO: animation is SpeedRun +} + +void Client::EnableAreaHPRegen(int value) +{ + AreaHPRegen = value * 0.001f; + SendAppearancePacket(AT_AreaHPRegen, value); // does this send to whole zone? + // send test and particles? +} + +void Client::DisableAreaHPRegen() +{ + AreaHPRegen = 1.0f; + SendAppearancePacket(AT_AreaHPRegen, 1000); +} + +void Client::EnableAreaManaRegen(int value) +{ + AreaManaRegen = value * 0.001f; + SendAppearancePacket(AT_AreaManaRegen, value); // does this send to whole zone? + // send test and particles? +} + +void Client::DisableAreaManaRegen() +{ + AreaManaRegen = 1.0f; + SendAppearancePacket(AT_AreaManaRegen, 1000); +} + +void Client::EnableAreaEndRegen(int value) +{ + AreaEndRegen = value * 0.001f; + SendAppearancePacket(AT_AreaEndRegen, value); // does this send to whole zone? + // send test and particles? +} + +void Client::DisableAreaEndRegen() +{ + AreaEndRegen = 1.0f; + SendAppearancePacket(AT_AreaEndRegen, 1000); +} + +void Client::EnableAreaRegens(int value) +{ + EnableAreaHPRegen(value); + EnableAreaManaRegen(value); + EnableAreaEndRegen(value); +} + +void Client::DisableAreaRegens() +{ + DisableAreaHPRegen(); + DisableAreaManaRegen(); + DisableAreaEndRegen(); +} + +void Client::InitInnates() +{ + // this function on the client also inits the level one innate skills (like swimming, hide, etc) + // we won't do that here, lets just do the InnateSkills for now. Basically translation of what the client is doing + // A lot of these we could probably have ignored because they have no known use or are 100% client side + // but I figured just in case we'll do them all out + // + // The client calls this in a few places. When you remove a vision buff and in SetHeights, which is called in + // illusions, mounts, and a bunch of other cases. All of the calls to InitInnates are wrapped in restoring regen + // besides the call initializing the first time + auto race = GetRace(); + auto class_ = GetClass(); + + for (int i = 0; i < InnateSkillMax; ++i) + m_pp.InnateSkills[i] = InnateDisabled; + + m_pp.InnateSkills[InnateInspect] = InnateEnabled; + m_pp.InnateSkills[InnateOpen] = InnateEnabled; + if (race >= RT_FROGLOK_3) { + if (race == RT_SKELETON_2 || race == RT_FROGLOK_3) + m_pp.InnateSkills[InnateUltraVision] = InnateEnabled; + else + m_pp.InnateSkills[InnateInfravision] = InnateEnabled; + } + switch (race) { + case RT_BARBARIAN: + case RT_BARBARIAN_2: + m_pp.InnateSkills[InnateSlam] = InnateEnabled; + break; + case RT_ERUDITE: + case RT_ERUDITE_2: + m_pp.InnateSkills[InnateLore] = InnateEnabled; + break; + case RT_WOOD_ELF: + case RT_GUARD_3: + m_pp.InnateSkills[InnateInfravision] = InnateEnabled; + break; + case RT_HIGH_ELF: + case RT_GUARD_2: + m_pp.InnateSkills[InnateInfravision] = InnateEnabled; + m_pp.InnateSkills[InnateLore] = InnateEnabled; + break; + case RT_DARK_ELF: + case RT_DARK_ELF_2: + case RT_VAMPIRE_2: + m_pp.InnateSkills[InnateUltraVision] = InnateEnabled; + break; + case RT_TROLL: + case RT_TROLL_2: + m_pp.InnateSkills[InnateRegen] = InnateEnabled; + m_pp.InnateSkills[InnateSlam] = InnateEnabled; + m_pp.InnateSkills[InnateInfravision] = InnateEnabled; + break; + case RT_DWARF: + case RT_DWARF_2: + m_pp.InnateSkills[InnateInfravision] = InnateEnabled; + break; + case RT_OGRE: + case RT_OGRE_2: + m_pp.InnateSkills[InnateInfravision] = InnateEnabled; + m_pp.InnateSkills[InnateSlam] = InnateEnabled; + m_pp.InnateSkills[InnateNoBash] = InnateEnabled; + m_pp.InnateSkills[InnateBashDoor] = InnateEnabled; + break; + case RT_HALFLING: + case RT_HALFLING_2: + m_pp.InnateSkills[InnateInfravision] = InnateEnabled; + break; + case RT_GNOME: + m_pp.InnateSkills[InnateInfravision] = InnateEnabled; + m_pp.InnateSkills[InnateLore] = InnateEnabled; + break; + case RT_IKSAR: + m_pp.InnateSkills[InnateRegen] = InnateEnabled; + m_pp.InnateSkills[InnateInfravision] = InnateEnabled; + break; + case RT_VAH_SHIR: + m_pp.InnateSkills[InnateInfravision] = InnateEnabled; + break; + case RT_FROGLOK_2: + case RT_GHOST: + case RT_GHOUL: + case RT_SKELETON: + case RT_VAMPIRE: + case RT_WILL_O_WISP: + case RT_ZOMBIE: + case RT_SPECTRE: + case RT_GHOST_2: + case RT_GHOST_3: + case RT_DRAGON_2: + case RT_INNORUUK: + m_pp.InnateSkills[InnateUltraVision] = InnateEnabled; + break; + case RT_HUMAN: + case RT_GUARD: + case RT_BEGGAR: + case RT_HUMAN_2: + case RT_HUMAN_3: + case RT_FROGLOK_3: // client does froglok weird, but this should work out fine + break; + default: + m_pp.InnateSkills[InnateInfravision] = InnateEnabled; + break; + } + + switch (class_) { + case DRUID: + m_pp.InnateSkills[InnateHarmony] = InnateEnabled; + break; + case BARD: + m_pp.InnateSkills[InnateReveal] = InnateEnabled; + break; + case ROGUE: + m_pp.InnateSkills[InnateSurprise] = InnateEnabled; + m_pp.InnateSkills[InnateReveal] = InnateEnabled; + break; + case RANGER: + m_pp.InnateSkills[InnateAwareness] = InnateEnabled; + break; + case MONK: + m_pp.InnateSkills[InnateSurprise] = InnateEnabled; + m_pp.InnateSkills[InnateAwareness] = InnateEnabled; + default: + break; + } +} + diff --git a/zone/client.h b/zone/client.h index 051d433e4..e334f8fd9 100644 --- a/zone/client.h +++ b/zone/client.h @@ -199,6 +199,27 @@ struct RespawnOption float heading; }; +// do not ask what all these mean because I have no idea! +// named from the client's CEverQuest::GetInnateDesc, they're missing some +enum eInnateSkill { + InnateEnabled = 0, + InnateAwareness = 1, + InnateBashDoor = 2, + InnateBreathFire = 3, + InnateHarmony = 4, + InnateInfravision = 6, + InnateLore = 8, + InnateNoBash = 9, + InnateRegen = 10, + InnateSlam = 11, + InnateSurprise = 12, + InnateUltraVision = 13, + InnateInspect = 14, + InnateOpen = 15, + InnateReveal = 16, + InnateSkillMax = 25, // size of array in client + InnateDisabled = 255 +}; const uint32 POPUPID_UPDATE_SHOWSTATSWINDOW = 1000000; @@ -406,6 +427,16 @@ public: const int32& SetMana(int32 amount); int32 CalcManaRegenCap(); + // guild pool regen shit. Sends a SpawnAppearance with a value that regens to value * 0.001 + void EnableAreaHPRegen(int value); + void DisableAreaHPRegen(); + void EnableAreaManaRegen(int value); + void DisableAreaManaRegen(); + void EnableAreaEndRegen(int value); + void DisableAreaEndRegen(); + void EnableAreaRegens(int value); + void DisableAreaRegens(); + void ServerFilter(SetServerFilter_Struct* filter); void BulkSendTraderInventory(uint32 char_id); void SendSingleTraderItem(uint32 char_id, int uniqueid); @@ -540,7 +571,7 @@ public: /*Endurance and such*/ void CalcMaxEndurance(); //This calculates the maximum endurance we can have int32 CalcBaseEndurance(); //Calculates Base End - int32 CalcEnduranceRegen(); //Calculates endurance regen used in DoEnduranceRegen() + int32 CalcEnduranceRegen(bool bCombat = false); //Calculates endurance regen used in DoEnduranceRegen() int32 GetEndurance() const {return current_endurance;} //This gets our current endurance int32 GetMaxEndurance() const {return max_end;} //This gets our endurance from the last CalcMaxEndurance() call int32 CalcEnduranceRegenCap(); @@ -719,6 +750,7 @@ public: void SendTradeskillDetails(uint32 recipe_id); bool TradeskillExecute(DBTradeskillRecipe_Struct *spec); void CheckIncreaseTradeskill(int16 bonusstat, int16 stat_modifier, float skillup_modifier, uint16 success_modifier, EQEmu::skills::SkillType tradeskill); + void InitInnates(); void GMKill(); inline bool IsMedding() const {return medding;} @@ -760,6 +792,9 @@ public: void SummonHorse(uint16 spell_id); void SetHorseId(uint16 horseid_in); uint16 GetHorseId() const { return horseId; } + bool CanMedOnHorse(); + + bool CanFastRegen() const { return ooc_regen; } void NPCSpawn(NPC *target_npc, const char *identifier, uint32 extra = 0); @@ -862,6 +897,7 @@ public: void SetHunger(int32 in_hunger); void SetThirst(int32 in_thirst); void SetConsumption(int32 in_hunger, int32 in_thirst); + bool IsStarved() const { if (GetGM() || !RuleB(Character, EnableHungerPenalties)) return false; return m_pp.hunger_level == 0 || m_pp.thirst_level == 0; } bool CheckTradeLoreConflict(Client* other); bool CheckTradeNonDroppable(); @@ -1345,8 +1381,8 @@ private: int32 CalcCorrup(); int32 CalcMaxHP(); int32 CalcBaseHP(); - int32 CalcHPRegen(); - int32 CalcManaRegen(); + int32 CalcHPRegen(bool bCombat = false); + int32 CalcManaRegen(bool bCombat = false); int32 CalcBaseManaRegen(); uint32 GetClassHPFactor(); void DoHPRegen(); @@ -1410,6 +1446,7 @@ private: std::string BuyerWelcomeMessage; bool AbilityTimer; int Haste; //precalced value + uint32 tmSitting; // time stamp started sitting, used for HP regen bonus added on MAY 5, 2004 int32 max_end; int32 current_endurance; @@ -1513,9 +1550,10 @@ private: unsigned int AggroCount; // How many mobs are aggro on us. - unsigned int RestRegenHP; - unsigned int RestRegenMana; - unsigned int RestRegenEndurance; + bool ooc_regen; + float AreaHPRegen; + float AreaManaRegen; + float AreaEndRegen; bool EngagedRaidTarget; uint32 SavedRaidRestTimer; diff --git a/zone/client_mods.cpp b/zone/client_mods.cpp index 6db0437c5..541454a58 100644 --- a/zone/client_mods.cpp +++ b/zone/client_mods.cpp @@ -22,6 +22,8 @@ #include "../common/rulesys.h" #include "../common/spdat.h" +#include "../common/data_verification.h" + #include "client.h" #include "mob.h" @@ -231,16 +233,81 @@ int32 Client::LevelRegen() return hp; } -int32 Client::CalcHPRegen() +int32 Client::CalcHPRegen(bool bCombat) { - int32 regen = LevelRegen() + itembonuses.HPRegen + spellbonuses.HPRegen; - regen += aabonuses.HPRegen + GroupLeadershipAAHealthRegeneration(); + int item_regen = itembonuses.HPRegen; // worn spells and +regen, already capped + item_regen += GetHeroicSTA() / 20; + + item_regen += aabonuses.HPRegen; + + int base = 0; + auto base_data = database.GetBaseData(GetLevel(), GetClass()); + if (base_data) + base = static_cast(base_data->hp_regen); + + auto level = GetLevel(); + bool skip_innate = false; + + if (IsSitting()) { + if (level >= 50) { + base++; + if (level >= 65) + base++; + } + + if ((Timer::GetCurrentTime() - tmSitting) > 60000) { + if (!IsAffectedByBuffByGlobalGroup(GlobalGroup::Lich)) { + auto tic_diff = std::min((Timer::GetCurrentTime() - tmSitting) / 60000, static_cast(9)); + if (tic_diff != 1) { // starts at 2 mins + int tic_bonus = tic_diff * 1.5 * base; + if (m_pp.InnateSkills[InnateRegen] != InnateDisabled) + tic_bonus = tic_bonus * 1.2; + base = tic_bonus; + skip_innate = true; + } else if (m_pp.InnateSkills[InnateRegen] == InnateDisabled) { // no innate regen gets first tick + int tic_bonus = base * 1.5; + base = tic_bonus; + } + } + } + } + + if (!skip_innate && m_pp.InnateSkills[InnateRegen] != InnateDisabled) { + if (level >= 50) { + ++base; + if (level >= 55) + ++base; + } + base *= 2; + } + + if (IsStarved()) + base = 0; + + base += GroupLeadershipAAHealthRegeneration(); + // some IsKnockedOut that sets to -1 + base = base * 100.0f * AreaHPRegen * 0.01f + 0.5f; + // another check for IsClient && !(base + item_regen) && Cur_HP <= 0 do --base; do later + + if (!bCombat && CanFastRegen() && (IsSitting() || CanMedOnHorse())) { + auto fast_mod = RuleI(Character, RestRegenHP); // TODO: this is actually zone based + auto max_hp = GetMaxHP(); + int fast_regen = 6 * (max_hp / fast_mod); + if (base < fast_regen) // weird, but what the client is doing + base = fast_regen; + } + + int regen = base + item_regen + spellbonuses.HPRegen; // TODO: client does this in buff tick return (regen * RuleI(Character, HPRegenMultiplier) / 100); } int32 Client::CalcHPRegenCap() { - int cap = RuleI(Character, ItemHealthRegenCap) + itembonuses.HeroicSTA / 25; + int cap = RuleI(Character, ItemHealthRegenCap); + if (GetLevel() > 60) + cap = std::max(cap, GetLevel() - 30); // if the rule is set greater than normal I guess + if (GetLevel() > 65) + cap += GetLevel() - 65; cap += aabonuses.ItemHPRegenCap + spellbonuses.ItemHPRegenCap + itembonuses.ItemHPRegenCap; return (cap * RuleI(Character, HPRegenMultiplier) / 100); } @@ -1169,43 +1236,72 @@ int32 Client::CalcBaseManaRegen() return regen; } -int32 Client::CalcManaRegen() +int32 Client::CalcManaRegen(bool bCombat) { - uint8 clevel = GetLevel(); - int32 regen = 0; - //this should be changed so we dont med while camping, etc... - if (IsSitting() || (GetHorseId() != 0)) { - BuffFadeBySitModifier(); - if (HasSkill(EQEmu::skills::SkillMeditate)) { - this->medding = true; - regen = (((GetSkill(EQEmu::skills::SkillMeditate) / 10) + (clevel - (clevel / 4))) / 4) + 4; - regen += spellbonuses.ManaRegen + itembonuses.ManaRegen; - CheckIncreaseSkill(EQEmu::skills::SkillMeditate, nullptr, -5); - } - else { - regen = 2 + spellbonuses.ManaRegen + itembonuses.ManaRegen; + int regen = 0; + auto level = GetLevel(); + if (!IsStarved()) { + // client does some base regen for shrouds here + if (IsSitting() || CanMedOnHorse()) { + // kind of weird to do it here w/e + // client does some base medding regen for shrouds here + if (GetClass() != BARD) { + auto skill = GetSkill(EQEmu::skills::SkillMeditate); + if (skill > 0) { + regen++; + if (skill > 1) + regen++; + if (skill >= 15) + regen += skill / 15; + } + } } } - else { - this->medding = false; - regen = 2 + spellbonuses.ManaRegen + itembonuses.ManaRegen; + + if (level > 61) { + regen++; + if (level > 63) + regen++; } - //AAs + regen += aabonuses.ManaRegen; + // add in + 1 bonus for SE_CompleteHeal, but we don't do anything for it yet? + + int item_bonus = itembonuses.ManaRegen; // this is capped already + int heroic_bonus = 0; + + switch (GetCasterClass()) { + case 'W': + heroic_bonus = GetHeroicWIS(); + break; + default: + heroic_bonus = GetHeroicINT(); + break; + } + + item_bonus += heroic_bonus / 25; + regen += item_bonus; + + if (level <= 70 && regen > 65) + regen = 65; + + regen = regen * 100.0f * AreaManaRegen * 0.01f + 0.5f; + + if (!bCombat && CanFastRegen() && (IsSitting() || CanMedOnHorse())) { + auto fast_mod = RuleI(Character, RestRegenMana); // TODO: this is actually zone based + auto max_mana = GetMaxMana(); + int fast_regen = 6 * (max_mana / fast_mod); + if (regen < fast_regen) // weird, but what the client is doing + regen = fast_regen; + } + + regen += spellbonuses.ManaRegen; // TODO: live does this in buff tick return (regen * RuleI(Character, ManaRegenMultiplier) / 100); } int32 Client::CalcManaRegenCap() { int32 cap = RuleI(Character, ItemManaRegenCap) + aabonuses.ItemManaRegenCap; - switch (GetCasterClass()) { - case 'I': - cap += (itembonuses.HeroicINT / 25); - break; - case 'W': - cap += (itembonuses.HeroicWIS / 25); - break; - } return (cap * RuleI(Character, ManaRegenMultiplier) / 100); } @@ -2091,16 +2187,91 @@ int32 Client::CalcBaseEndurance() return base_end; } -int32 Client::CalcEnduranceRegen() +int32 Client::CalcEnduranceRegen(bool bCombat) { - int32 regen = int32(GetLevel() * 4 / 10) + 2; - regen += aabonuses.EnduranceRegen + spellbonuses.EnduranceRegen + itembonuses.EnduranceRegen; + int base = 0; + if (!IsStarved()) { + auto base_data = database.GetBaseData(GetLevel(), GetClass()); + if (base_data) { + base = static_cast(base_data->end_regen); + if (!auto_attack && base > 0) + base += base / 2; + } + } + + // so when we are mounted, our local client SpeedRun is always 0, so this is always false, but the packets we process it to our own shit :P + bool is_running = runmode && animation != 0 && GetHorseId() == 0; // TODO: animation is really what MQ2 calls SpeedRun + + int weight_limit = GetSTR(); + auto level = GetLevel(); + if (GetClass() == MONK) { + if (level > 99) + weight_limit = 58; + else if (level > 94) + weight_limit = 57; + else if (level > 89) + weight_limit = 56; + else if (level > 84) + weight_limit = 55; + else if (level > 79) + weight_limit = 54; + else if (level > 64) + weight_limit = 53; + else if (level > 63) + weight_limit = 50; + else if (level > 61) + weight_limit = 47; + else if (level > 59) + weight_limit = 45; + else if (level > 54) + weight_limit = 40; + else if (level > 50) + weight_limit = 38; + else if (level > 44) + weight_limit = 36; + else if (level > 29) + weight_limit = 34; + else if (level > 14) + weight_limit = 32; + else + weight_limit = 30; + } + + bool encumbered = (CalcCurrentWeight() / 10) >= weight_limit; + + if (is_running) + base += level / -15; + + if (encumbered) + base += level / -15; + + auto item_bonus = GetHeroicAGI() + GetHeroicDEX() + GetHeroicSTA() + GetHeroicSTR(); + item_bonus = item_bonus / 4 / 50; + item_bonus += itembonuses.EnduranceRegen; // this is capped already + base += item_bonus; + + base = base * AreaEndRegen + 0.5f; + + auto aa_regen = aabonuses.EnduranceRegen; + + int regen = base; + if (!bCombat && CanFastRegen() && (IsSitting() || CanMedOnHorse())) { + auto fast_mod = RuleI(Character, RestRegenEnd); // TODO: this is actually zone based + auto max_end = GetMaxEndurance(); + int fast_regen = 6 * (max_end / fast_mod); + if (aa_regen < fast_regen) // weird, but what the client is doing + aa_regen = fast_regen; + } + + regen += aa_regen; + regen += spellbonuses.EnduranceRegen; // TODO: client does this in buff tick + return (regen * RuleI(Character, EnduranceRegenMultiplier) / 100); } int32 Client::CalcEnduranceRegenCap() { - int cap = (RuleI(Character, ItemEnduranceRegenCap) + itembonuses.HeroicSTR / 25 + itembonuses.HeroicDEX / 25 + itembonuses.HeroicAGI / 25 + itembonuses.HeroicSTA / 25); + int cap = RuleI(Character, ItemEnduranceRegenCap); return (cap * RuleI(Character, EnduranceRegenMultiplier) / 100); } diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 7b48b207b..fe5ab8d92 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1414,6 +1414,8 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) if (class_ == MONK) consume_food_timer.SetTimer(CONSUMPTION_MNK_TIMER); + InitInnates(); + /* If GM not set in DB, and does not meet min status to be GM, reset */ if (m_pp.gm && admin < minStatusToBeGM) m_pp.gm = 0; @@ -13054,6 +13056,8 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) InterruptSpell(); SetFeigned(false); BindWound(this, false, true); + tmSitting = Timer::GetCurrentTime(); + BuffFadeBySitModifier(); } else if (sa->parameter == ANIM_CROUCH) { if (!UseBardSpellLogic()) diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 4802c24a9..a0bdeead2 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -1820,7 +1820,7 @@ void Client::OPGMSummon(const EQApplicationPacket *app) } void Client::DoHPRegen() { - SetHP(GetHP() + CalcHPRegen() + RestRegenHP); + SetHP(GetHP() + CalcHPRegen()); SendHPUpdate(); } @@ -1828,7 +1828,10 @@ void Client::DoManaRegen() { if (GetMana() >= max_mana && spellbonuses.ManaRegen >= 0) return; - SetMana(GetMana() + CalcManaRegen() + RestRegenMana); + if (GetMana() < max_mana && (IsSitting() || CanMedOnHorse()) && HasSkill(EQEmu::skills::SkillMeditate)) + CheckIncreaseSkill(EQEmu::skills::SkillMeditate, nullptr, -5); + + SetMana(GetMana() + CalcManaRegen()); CheckManaEndUpdate(); } @@ -1869,10 +1872,11 @@ void Client::DoStaminaHungerUpdate() void Client::DoEnduranceRegen() { - if(GetEndurance() >= GetMaxEndurance()) - return; + // endurance has some negative mods that could result in a negative regen when starved + int regen = CalcEnduranceRegen(); - SetEndurance(GetEndurance() + CalcEnduranceRegen() + RestRegenEndurance); + if (regen < 0 || (regen > 0 && GetEndurance() < GetMaxEndurance())) + SetEndurance(GetEndurance() + regen); } void Client::DoEnduranceUpkeep() { @@ -1921,12 +1925,12 @@ void Client::CalcRestState() { // The client must have been out of combat for RuleI(Character, RestRegenTimeToActivate) seconds, // must be sitting down, and must not have any detrimental spells affecting them. // - if(!RuleI(Character, RestRegenPercent)) + if(!RuleB(Character, RestRegenEnabled)) return; - RestRegenHP = RestRegenMana = RestRegenEndurance = 0; + ooc_regen = false; - if(AggroCount || !IsSitting()) + if(AggroCount || !(IsSitting() || CanMedOnHorse())) return; if(!rest_timer.Check(false)) @@ -1941,12 +1945,8 @@ void Client::CalcRestState() { } } - RestRegenHP = (GetMaxHP() * RuleI(Character, RestRegenPercent) / 100); + ooc_regen = true; - RestRegenMana = (GetMaxMana() * RuleI(Character, RestRegenPercent) / 100); - - if(RuleB(Character, RestRegenEndurance)) - RestRegenEndurance = (GetMaxEndurance() * RuleI(Character, RestRegenPercent) / 100); } void Client::DoTracking() diff --git a/zone/horse.cpp b/zone/horse.cpp index efe4fe898..fe5762d5a 100644 --- a/zone/horse.cpp +++ b/zone/horse.cpp @@ -151,6 +151,7 @@ void Client::SummonHorse(uint16 spell_id) { uint16 tmpID = horse->GetID(); SetHorseId(tmpID); + BuffFadeBySitModifier(); } diff --git a/zone/merc.cpp b/zone/merc.cpp index a3ff051f2..03e618881 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -1154,7 +1154,7 @@ void Merc::CalcRestState() { // The bot must have been out of combat for RuleI(Character, RestRegenTimeToActivate) seconds, // must be sitting down, and must not have any detrimental spells affecting them. // - if(!RuleI(Character, RestRegenPercent)) + if(!RuleB(Character, RestRegenEnabled)) return; RestRegenHP = RestRegenMana = RestRegenEndurance = 0; @@ -1174,12 +1174,11 @@ void Merc::CalcRestState() { } } - RestRegenHP = (GetMaxHP() * RuleI(Character, RestRegenPercent) / 100); + RestRegenHP = 6 * (GetMaxHP() / RuleI(Character, RestRegenHP)); - RestRegenMana = (GetMaxMana() * RuleI(Character, RestRegenPercent) / 100); + RestRegenMana = 6 * (GetMaxMana() / RuleI(Character, RestRegenMana)); - if(RuleB(Character, RestRegenEndurance)) - RestRegenEndurance = (GetMaxEndurance() * RuleI(Character, RestRegenPercent) / 100); + RestRegenEndurance = 6 * (GetMaxEndurance() / RuleI(Character, RestRegenEnd)); } bool Merc::HasSkill(EQEmu::skills::SkillType skill_id) const { diff --git a/zone/mob.h b/zone/mob.h index ccf92014b..e0aecb95b 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -336,6 +336,7 @@ public: void BuffFadeDetrimentalByCaster(Mob *caster); void BuffFadeBySitModifier(); bool IsAffectedByBuff(uint16 spell_id); + bool IsAffectedByBuffByGlobalGroup(GlobalGroup group); void BuffModifyDurationBySpellID(uint16 spell_id, int32 newDuration); int AddBuff(Mob *caster, const uint16 spell_id, int duration = 0, int32 level_override = -1); int CanBuffStack(uint16 spellid, uint8 caster_level, bool iFailIfOverwrite = false); diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 46b44fb3a..375572014 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -60,6 +60,9 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove const SPDat_Spell_Struct &spell = spells[spell_id]; + if (spell.disallow_sit && IsBuffSpell(spell_id) && IsClient() && (CastToClient()->IsSitting() || CastToClient()->GetHorseId() != 0)) + return false; + bool c_override = false; if (caster && caster->IsClient() && GetCastedSpellInvSlot() > 0) { const EQEmu::ItemInstance *inst = caster->CastToClient()->GetInv().GetItem(GetCastedSpellInvSlot()); diff --git a/zone/spells.cpp b/zone/spells.cpp index 0bc897912..877886757 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -4234,6 +4234,19 @@ bool Mob::IsAffectedByBuff(uint16 spell_id) return false; } +bool Mob::IsAffectedByBuffByGlobalGroup(GlobalGroup group) +{ + int buff_count = GetMaxTotalSlots(); + for (int i = 0; i < buff_count; ++i) { + if (buffs[i].spellid == SPELL_UNKNOWN) + continue; + if (spells[buffs[i].spellid].spell_category == static_cast(group)) + return true; + } + + return false; +} + // checks if 'this' can be affected by spell_id from caster // returns true if the spell should fail, false otherwise bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) From f566cba56ae8a40cf436330a3a8e4a46c89b1965 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 8 Oct 2017 21:43:16 -0400 Subject: [PATCH 36/97] Add Area Regen functions to Lua --- zone/lua_client.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++- zone/lua_client.h | 8 +++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/zone/lua_client.cpp b/zone/lua_client.cpp index 64bf2321c..45ea8472e 100644 --- a/zone/lua_client.cpp +++ b/zone/lua_client.cpp @@ -1440,6 +1440,54 @@ void Lua_Client::FilteredMessage(Mob *sender, uint32 type, int filter, const cha self->FilteredMessage(sender, type, (eqFilterType)filter, message); } +void Lua_Client::EnableAreaHPRegen(int value) +{ + Lua_Safe_Call_Void(); + self->EnableAreaHPRegen(value); +} + +void Lua_Client::DisableAreaHPRegen() +{ + Lua_Safe_Call_Void(); + self->DisableAreaHPRegen(); +} + +void Lua_Client::EnableAreaManaRegen(int value) +{ + Lua_Safe_Call_Void(); + self->EnableAreaManaRegen(value); +} + +void Lua_Client::DisableAreaManaRegen() +{ + Lua_Safe_Call_Void(); + self->DisableAreaManaRegen(); +} + +void Lua_Client::EnableAreaEndRegen(int value) +{ + Lua_Safe_Call_Void(); + self->EnableAreaEndRegen(value); +} + +void Lua_Client::DisableAreaEndRegen() +{ + Lua_Safe_Call_Void(); + self->DisableAreaEndRegen(); +} + +void Lua_Client::EnableAreaRegens(int value) +{ + Lua_Safe_Call_Void(); + self->EnableAreaRegens(value); +} + +void Lua_Client::DisableAreaRegens() +{ + Lua_Safe_Call_Void(); + self->DisableAreaRegens(); +} + luabind::scope lua_register_client() { return luabind::class_("Client") .def(luabind::constructor<>()) @@ -1712,7 +1760,15 @@ luabind::scope lua_register_client() { .def("IsDead", &Lua_Client::IsDead) .def("CalcCurrentWeight", &Lua_Client::CalcCurrentWeight) .def("CalcATK", &Lua_Client::CalcATK) - .def("FilteredMessage", &Lua_Client::FilteredMessage); + .def("FilteredMessage", &Lua_Client::FilteredMessage) + .def("EnableAreaHPRegen", &Lua_Client::EnableAreaHPRegen) + .def("DisableAreaHPRegen", &Lua_Client::DisableAreaHPRegen) + .def("EnableAreaManaRegen", &Lua_Client::EnableAreaManaRegen) + .def("DisableAreaManaRegen", &Lua_Client::DisableAreaManaRegen) + .def("EnableAreaEndRegen", &Lua_Client::EnableAreaEndRegen) + .def("DisableAreaEndRegen", &Lua_Client::DisableAreaEndRegen) + .def("EnableAreaRegens", &Lua_Client::EnableAreaRegens) + .def("DisableAreaRegens", &Lua_Client::DisableAreaRegens); } luabind::scope lua_register_inventory_where() { diff --git a/zone/lua_client.h b/zone/lua_client.h index f29e3b46f..10e766b5c 100644 --- a/zone/lua_client.h +++ b/zone/lua_client.h @@ -301,6 +301,14 @@ public: int CalcCurrentWeight(); int CalcATK(); void FilteredMessage(Mob *sender, uint32 type, int filter, const char* message); + void EnableAreaHPRegen(int value); + void DisableAreaHPRegen(); + void EnableAreaManaRegen(int value); + void DisableAreaManaRegen(); + void EnableAreaEndRegen(int value); + void DisableAreaEndRegen(); + void EnableAreaRegens(int value); + void DisableAreaRegens(); }; #endif From 414cafdbedb0bf882b350e8a95a5857978e81b1c Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Mon, 9 Oct 2017 00:04:43 -0400 Subject: [PATCH 37/97] Add OP_AddNimbusEffect --- common/emu_oplist.h | 1 + common/eq_packet_structs.h | 1 + utils/patches/patch_RoF.conf | 1 + utils/patches/patch_RoF2.conf | 1 + utils/patches/patch_SoD.conf | 1 + utils/patches/patch_SoF.conf | 1 + utils/patches/patch_UF.conf | 1 + zone/lua_mob.cpp | 6 ++++++ zone/lua_mob.h | 1 + zone/mob.cpp | 12 ++++++++++++ zone/mob.h | 1 + 11 files changed, 27 insertions(+) diff --git a/common/emu_oplist.h b/common/emu_oplist.h index 29a20cb14..319517499 100644 --- a/common/emu_oplist.h +++ b/common/emu_oplist.h @@ -9,6 +9,7 @@ N(OP_AcceptNewTask), N(OP_AckPacket), N(OP_Action), N(OP_Action2), +N(OP_AddNimbusEffect), N(OP_AdventureData), N(OP_AdventureDetails), N(OP_AdventureFinish), diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index 46aade124..4876b4211 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -551,6 +551,7 @@ struct BlockedBuffs_Struct /*86*/ uint16 Flags; }; +// same for adding struct RemoveNimbusEffect_Struct { /*00*/ uint32 spawnid; // Spawn ID diff --git a/utils/patches/patch_RoF.conf b/utils/patches/patch_RoF.conf index 339bfd800..f3d4249c0 100644 --- a/utils/patches/patch_RoF.conf +++ b/utils/patches/patch_RoF.conf @@ -341,6 +341,7 @@ OP_MobUpdate=0x6b5a OP_NPCMoveUpdate=0x5bd9 OP_CameraEffect=0x5712 OP_SpellEffect=0x72b6 +OP_AddNimbusEffect=0x2954 OP_RemoveNimbusEffect=0x3ba7 OP_AltCurrency=0x8fcb OP_AltCurrencyMerchantRequest=0x7e3e diff --git a/utils/patches/patch_RoF2.conf b/utils/patches/patch_RoF2.conf index e63e5e9e9..420fcec70 100644 --- a/utils/patches/patch_RoF2.conf +++ b/utils/patches/patch_RoF2.conf @@ -340,6 +340,7 @@ OP_MobUpdate=0x2c84 OP_NPCMoveUpdate=0x5892 OP_CameraEffect=0x127f OP_SpellEffect=0x5936 +OP_AddNimbusEffect=0xc693 OP_RemoveNimbusEffect=0x7b1e OP_AltCurrency=0x6b6d OP_AltCurrencyMerchantRequest=0x5409 diff --git a/utils/patches/patch_SoD.conf b/utils/patches/patch_SoD.conf index ed7a19715..0e8e36e02 100644 --- a/utils/patches/patch_SoD.conf +++ b/utils/patches/patch_SoD.conf @@ -345,6 +345,7 @@ OP_AltCurrencySell=0x7a21 OP_AltCurrencySellSelection=0x26d9 OP_AltCurrencyReclaim=0x712c OP_ShroudProgress=0x0296 +OP_AddNimbusEffect=0x6840 OP_RemoveNimbusEffect=0x5272 # C OP_Untargetable=0x5ea1 # 0x301d on UF? OP_IncreaseStats=0x71eb diff --git a/utils/patches/patch_SoF.conf b/utils/patches/patch_SoF.conf index 7ed41ff4a..cae177bfc 100644 --- a/utils/patches/patch_SoF.conf +++ b/utils/patches/patch_SoF.conf @@ -329,6 +329,7 @@ OP_AltCurrencyPurchase=0x3994 OP_AltCurrencySell=0x2ac3 OP_AltCurrencySellSelection=0x7d00 OP_AltCurrencyReclaim=0x1996 +OP_AddNimbusEffect=0x45e2 OP_RemoveNimbusEffect=0x5872 # C OP_InspectMessageUpdate=0x67e9 # C OP_OpenInventory=0x66c8 diff --git a/utils/patches/patch_UF.conf b/utils/patches/patch_UF.conf index af698d52a..6d8064029 100644 --- a/utils/patches/patch_UF.conf +++ b/utils/patches/patch_UF.conf @@ -346,6 +346,7 @@ OP_MobUpdate=0x4656 # Same as OP_SpawnPositionUpdate OP_NPCMoveUpdate=0x0f3e # OP_CameraEffect=0x6b0e # V OP_SpellEffect=0x57a3 # V +OP_AddNimbusEffect=0x6361 OP_RemoveNimbusEffect=0x2c77 # C OP_AltCurrency=0x659e OP_AltCurrencyMerchantRequest=0x214C diff --git a/zone/lua_mob.cpp b/zone/lua_mob.cpp index 18651edea..8b88ba12f 100644 --- a/zone/lua_mob.cpp +++ b/zone/lua_mob.cpp @@ -1686,6 +1686,11 @@ void Lua_Mob::DoKnockback(Lua_Mob caster, uint32 pushback, uint32 pushup) { self->DoKnockback(caster, pushback, pushup); } +void Lua_Mob::AddNimbusEffect(int effect_id) { + Lua_Safe_Call_Void(); + self->AddNimbusEffect(effect_id); +} + void Lua_Mob::RemoveNimbusEffect(int effect_id) { Lua_Safe_Call_Void(); self->RemoveNimbusEffect(effect_id); @@ -2367,6 +2372,7 @@ luabind::scope lua_register_mob() { .def("SetSlotTint", (void(Lua_Mob::*)(int,int,int,int))&Lua_Mob::SetSlotTint) .def("WearChange", (void(Lua_Mob::*)(int,int,uint32))&Lua_Mob::WearChange) .def("DoKnockback", (void(Lua_Mob::*)(Lua_Mob,uint32,uint32))&Lua_Mob::DoKnockback) + .def("AddNimbusEffect", (void(Lua_Mob::*)(int))&Lua_Mob::AddNimbusEffect) .def("RemoveNimbusEffect", (void(Lua_Mob::*)(int))&Lua_Mob::RemoveNimbusEffect) .def("IsFeared", (bool(Lua_Mob::*)(void))&Lua_Mob::IsFeared) .def("IsBlind", (bool(Lua_Mob::*)(void))&Lua_Mob::IsBlind) diff --git a/zone/lua_mob.h b/zone/lua_mob.h index c54deb6bc..493f5e1e8 100644 --- a/zone/lua_mob.h +++ b/zone/lua_mob.h @@ -323,6 +323,7 @@ public: void SetSlotTint(int material_slot, int red_tint, int green_tint, int blue_tint); void WearChange(int material_slot, int texture, uint32 color); void DoKnockback(Lua_Mob caster, uint32 pushback, uint32 pushup); + void AddNimbusEffect(int effect_id); void RemoveNimbusEffect(int effect_id); bool IsRunning(); void SetRunning(bool running); diff --git a/zone/mob.cpp b/zone/mob.cpp index 0bb043bc5..905ce2c4b 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -4994,6 +4994,18 @@ void Mob::SpreadVirus(uint16 spell_id, uint16 casterID) } } +void Mob::AddNimbusEffect(int effectid) +{ + SetNimbusEffect(effectid); + + auto outapp = new EQApplicationPacket(OP_AddNimbusEffect, sizeof(RemoveNimbusEffect_Struct)); + auto ane = (RemoveNimbusEffect_Struct *)outapp->pBuffer; + ane->spawnid = GetID(); + ane->nimbus_effect = effectid; + entity_list.QueueClients(this, outapp); + safe_delete(outapp); +} + void Mob::RemoveNimbusEffect(int effectid) { if (effectid == nimbus_effect1) diff --git a/zone/mob.h b/zone/mob.h index e0aecb95b..2642a96fb 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -377,6 +377,7 @@ public: inline virtual uint32 GetNimbusEffect1() const { return nimbus_effect1; } inline virtual uint32 GetNimbusEffect2() const { return nimbus_effect2; } inline virtual uint32 GetNimbusEffect3() const { return nimbus_effect3; } + void AddNimbusEffect(int effectid); void RemoveNimbusEffect(int effectid); inline const glm::vec3& GetTargetRingLocation() const { return m_TargetRing; } inline float GetTargetRingX() const { return m_TargetRing.x; } From 64d39134b97b4900b50c1129969b493c3390550c Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Mon, 9 Oct 2017 00:18:33 -0400 Subject: [PATCH 38/97] Fix issues with Mob::TryTriggerOnValueAmount --- zone/mob.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 905ce2c4b..efb2922f0 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3775,7 +3775,7 @@ void Mob::TryTriggerOnValueAmount(bool IsHP, bool IsMana, bool IsEndur, bool IsP if ((base2 >= 500 && base2 <= 520) && GetHPRatio() < (base2 - 500)*5) use_spell = true; - else if (base2 = 1004 && GetHPRatio() < 80) + else if (base2 == 1004 && GetHPRatio() < 80) use_spell = true; } @@ -3783,12 +3783,12 @@ void Mob::TryTriggerOnValueAmount(bool IsHP, bool IsMana, bool IsEndur, bool IsP if ( (base2 = 521 && GetManaRatio() < 20) || (base2 = 523 && GetManaRatio() < 40)) use_spell = true; - else if (base2 = 38311 && GetManaRatio() < 10) + else if (base2 == 38311 && GetManaRatio() < 10) use_spell = true; } else if (IsEndur){ - if (base2 = 522 && GetEndurancePercent() < 40){ + if (base2 == 522 && GetEndurancePercent() < 40){ use_spell = true; } } From 75e60b7f8efef0f0fe0dd012c70f37e995b0a085 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Mon, 9 Oct 2017 01:08:01 -0400 Subject: [PATCH 39/97] Area Regen functions shouldn't send to all --- zone/client.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index f72d510d5..ce084747a 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -9087,40 +9087,37 @@ bool Client::CanMedOnHorse() void Client::EnableAreaHPRegen(int value) { AreaHPRegen = value * 0.001f; - SendAppearancePacket(AT_AreaHPRegen, value); // does this send to whole zone? - // send test and particles? + SendAppearancePacket(AT_AreaHPRegen, value, false); } void Client::DisableAreaHPRegen() { AreaHPRegen = 1.0f; - SendAppearancePacket(AT_AreaHPRegen, 1000); + SendAppearancePacket(AT_AreaHPRegen, 1000, false); } void Client::EnableAreaManaRegen(int value) { AreaManaRegen = value * 0.001f; - SendAppearancePacket(AT_AreaManaRegen, value); // does this send to whole zone? - // send test and particles? + SendAppearancePacket(AT_AreaManaRegen, value, false); } void Client::DisableAreaManaRegen() { AreaManaRegen = 1.0f; - SendAppearancePacket(AT_AreaManaRegen, 1000); + SendAppearancePacket(AT_AreaManaRegen, 1000, false); } void Client::EnableAreaEndRegen(int value) { AreaEndRegen = value * 0.001f; - SendAppearancePacket(AT_AreaEndRegen, value); // does this send to whole zone? - // send test and particles? + SendAppearancePacket(AT_AreaEndRegen, value, false); } void Client::DisableAreaEndRegen() { AreaEndRegen = 1.0f; - SendAppearancePacket(AT_AreaEndRegen, 1000); + SendAppearancePacket(AT_AreaEndRegen, 1000, false); } void Client::EnableAreaRegens(int value) From 2ef5ade596aafa5de0e2c36fe05840c22a2e30c7 Mon Sep 17 00:00:00 2001 From: Joey Wendt Date: Thu, 12 Oct 2017 00:43:25 -0500 Subject: [PATCH 40/97] Change weapon proc req. level to Level2 property --- zone/attack.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index a87f504b7..a6baffc8d 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -3922,10 +3922,10 @@ void Mob::TryWeaponProc(const EQEmu::ItemInstance *inst, const EQEmu::ItemData * float WPC = ProcChance * (100.0f + // Proc chance for this weapon static_cast(weapon->ProcRate)) / 100.0f; if (zone->random.Roll(WPC)) { // 255 dex = 0.084 chance of proc. No idea what this number should be really. - if (weapon->Proc.Level > ourlevel) { + if (weapon->Proc.Level2 > ourlevel) { Log(Logs::Detail, Logs::Combat, "Tried to proc (%s), but our level (%d) is lower than required (%d)", - weapon->Name, ourlevel, weapon->Proc.Level); + weapon->Name, ourlevel, weapon->Proc.Level2); if (IsPet()) { Mob *own = GetOwner(); if (own) @@ -3962,7 +3962,7 @@ void Mob::TryWeaponProc(const EQEmu::ItemInstance *inst, const EQEmu::ItemData * float APC = ProcChance * (100.0f + // Proc chance for this aug static_cast(aug->ProcRate)) / 100.0f; if (zone->random.Roll(APC)) { - if (aug->Proc.Level > ourlevel) { + if (aug->Proc.Level2 > ourlevel) { if (IsPet()) { Mob *own = GetOwner(); if (own) From 0f1ca0856cee22d4fd02f481907e95ca638e6c16 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 15 Oct 2017 21:35:03 -0400 Subject: [PATCH 41/97] Fix mana regen issue with old skill progression --- common/ruletypes.h | 1 + zone/client_mods.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/common/ruletypes.h b/common/ruletypes.h index e1475fa79..c3a8fd5dc 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -66,6 +66,7 @@ RULE_INT(Character, AutosaveIntervalS, 300) //0=disabled RULE_INT(Character, HPRegenMultiplier, 100) RULE_INT(Character, ManaRegenMultiplier, 100) RULE_INT(Character, EnduranceRegenMultiplier, 100) +RULE_BOOL(Character, OldMinMana, false) // this is used for servers that want to follow older skill cap formulas so they can still have some regen w/o mediate RULE_INT(Character, ConsumptionMultiplier, 100) //item's hunger restored = this value * item's food level, 100 = normal, 50 = people eat 2x as fast, 200 = people eat 2x as slow RULE_BOOL(Character, HealOnLevel, false) RULE_BOOL(Character, FeignKillsPet, false) diff --git a/zone/client_mods.cpp b/zone/client_mods.cpp index 541454a58..696214113 100644 --- a/zone/client_mods.cpp +++ b/zone/client_mods.cpp @@ -1240,6 +1240,10 @@ int32 Client::CalcManaRegen(bool bCombat) { int regen = 0; auto level = GetLevel(); + // so the new formulas break down with older skill caps where you don't have the skill until 4 or 8 + // so for servers that want to use the old skill progression they can set this rule so they + // will get at least 1 for standing and 2 for sitting. + bool old = RuleB(Character, OldMinMana); if (!IsStarved()) { // client does some base regen for shrouds here if (IsSitting() || CanMedOnHorse()) { @@ -1255,6 +1259,10 @@ int32 Client::CalcManaRegen(bool bCombat) regen += skill / 15; } } + if (old) + regen = std::max(regen, 2); + } else if (old) { + regen = std::max(regen, 1); } } From 4e9c3e19d20f8962f511bd49d48774b056b3fa1c Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Mon, 16 Oct 2017 01:25:14 -0400 Subject: [PATCH 42/97] Fix some XTarget FD issues --- zone/aggro.cpp | 5 +++++ zone/entity.cpp | 23 ++++++++++++++--------- zone/mob.h | 1 + 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/zone/aggro.cpp b/zone/aggro.cpp index 06c78c999..340493578 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -1274,6 +1274,11 @@ void Mob::ClearFeignMemory() { AI_feign_remember_timer->Disable(); } +bool Mob::IsOnFeignMemory(Client *attacker) const +{ + return feign_memory_list.find(attacker->CharacterID()) != feign_memory_list.end(); +} + bool Mob::PassCharismaCheck(Mob* caster, uint16 spell_id) { /* diff --git a/zone/entity.cpp b/zone/entity.cpp index a06a67092..0ab10982a 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -1419,10 +1419,10 @@ void EntityList::RemoveFromTargets(Mob *mob, bool RemoveFromXTargets) continue; if (RemoveFromXTargets) { - if (m->IsClient() && mob->CheckAggro(m)) + if (m->IsClient() && (mob->CheckAggro(m) || mob->IsOnFeignMemory(m->CastToClient()))) m->CastToClient()->RemoveXTarget(mob, false); // FadingMemories calls this function passing the client. - else if (mob->IsClient() && m->CheckAggro(mob)) + else if (mob->IsClient() && (m->CheckAggro(mob) || m->IsOnFeignMemory(mob->CastToClient()))) mob->CastToClient()->RemoveXTarget(m, false); } @@ -1461,7 +1461,7 @@ void EntityList::RefreshAutoXTargets(Client *c) if (!m || m->GetHP() <= 0) continue; - if (m->CheckAggro(c) && !c->IsXTarget(m)) { + if ((m->CheckAggro(c) || m->IsOnFeignMemory(c)) && !c->IsXTarget(m)) { c->AddAutoXTarget(m, false); // we only call this before a bulk, so lets not send right away break; } @@ -2617,12 +2617,13 @@ void EntityList::RemoveFromHateLists(Mob *mob, bool settoone) auto it = npc_list.begin(); while (it != npc_list.end()) { if (it->second->CheckAggro(mob)) { - if (!settoone) + if (!settoone) { it->second->RemoveFromHateList(mob); - else + if (mob->IsClient()) + mob->CastToClient()->RemoveXTarget(it->second, false); // gotta do book keeping + } else { it->second->SetHateAmountOnEnt(mob, 1); - if (mob->IsClient()) - mob->CastToClient()->RemoveXTarget(it->second, false); // gotta do book keeping + } } ++it; } @@ -3079,7 +3080,10 @@ void EntityList::ClearAggro(Mob* targ) c->RemoveXTarget(it->second, false); it->second->RemoveFromHateList(targ); } - it->second->RemoveFromFeignMemory(targ->CastToClient()); //just in case we feigned + if (c && it->second->IsOnFeignMemory(c)) { + it->second->RemoveFromFeignMemory(c); //just in case we feigned + c->RemoveXTarget(it->second, false); + } ++it; } } @@ -3088,7 +3092,8 @@ void EntityList::ClearFeignAggro(Mob *targ) { auto it = npc_list.begin(); while (it != npc_list.end()) { - if (it->second->CheckAggro(targ)) { + // add Feign Memory check because sometimes weird stuff happens + if (it->second->CheckAggro(targ) || (targ->IsClient() && it->second->IsOnFeignMemory(targ->CastToClient()))) { if (it->second->GetSpecialAbility(IMMUNE_FEIGN_DEATH)) { ++it; continue; diff --git a/zone/mob.h b/zone/mob.h index 2642a96fb..058774c54 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -588,6 +588,7 @@ public: void AddFeignMemory(Client* attacker); void RemoveFromFeignMemory(Client* attacker); void ClearFeignMemory(); + bool IsOnFeignMemory(Client *attacker) const; void PrintHateListToClient(Client *who) { hate_list.PrintHateListToClient(who); } std::list& GetHateList() { return hate_list.GetHateList(); } bool CheckLosFN(Mob* other); From 90f6023f0f4a2f3fe8be5c3801e4317df7fd61f9 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Mon, 16 Oct 2017 09:25:26 -0400 Subject: [PATCH 43/97] I added this back when. I was wrong. --- zone/client_packet.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index fe5ab8d92..176efee98 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -12085,15 +12085,6 @@ void Client::Handle_OP_SenseHeading(const EQApplicationPacket *app) int chancemod = 0; - // The client seems to limit sense heading packets based on skill - // level. So if we're really low, we don't hit this routine very often. - // I think it's the GUI deciding when to skill you up. - // So, I'm adding a mod here which is larger at lower levels so - // very low levels get a much better chance to skill up when the GUI - // eventually sends a message. - if (GetLevel() <= 8) - chancemod += (9 - level) * 10; - CheckIncreaseSkill(EQEmu::skills::SkillSenseHeading, nullptr, chancemod); return; From 3bcfcc6308dca4c1df03a3690c1bc47de3a82d23 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 16 Oct 2017 12:56:00 -0500 Subject: [PATCH 44/97] ZoneDatabase::GetKarma crash fix --- zone/zonedb.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index bd28bcba3..a9a0c7042 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -2953,9 +2953,11 @@ uint32 ZoneDatabase::GetKarma(uint32 acct_id) if (!results.Success()) return 0; - auto row = results.begin(); + for (auto row = results.begin(); row != results.end(); ++row) { + return atoi(row[0]); + } - return atoi(row[0]); + return 0; } void ZoneDatabase::UpdateKarma(uint32 acct_id, uint32 amount) From a7d0251b7711a798103c35296e2407a3fb5c9c76 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 16 Oct 2017 13:15:03 -0500 Subject: [PATCH 45/97] Mob::TryFadeEffect sanity checks for potential crashing --- zone/mob.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zone/mob.cpp b/zone/mob.cpp index efb2922f0..d08804410 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3949,10 +3949,17 @@ int16 Mob::GetHealRate(uint16 spell_id, Mob* caster) { bool Mob::TryFadeEffect(int slot) { + if (!buffs[slot].spellid) + return false; + if(IsValidSpell(buffs[slot].spellid)) { for(int i = 0; i < EFFECT_COUNT; i++) { + + if (!spells[buffs[slot].spellid].effectid[i]) + continue; + if (spells[buffs[slot].spellid].effectid[i] == SE_CastOnFadeEffectAlways || spells[buffs[slot].spellid].effectid[i] == SE_CastOnRuneFadeEffect) { From e80f3c87e97e0f9ab9fa1b768f1da71166750077 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 16 Oct 2017 13:20:33 -0500 Subject: [PATCH 46/97] Zone: Main loop crash fix --- zone/net.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zone/net.cpp b/zone/net.cpp index eafdde807..80411af7b 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -542,8 +542,10 @@ int main(int argc, char** argv) { process_timer.Stop(); process_timer.Start(1000, true); - uint32 shutdown_timer = database.getZoneShutDownDelay(zone->GetZoneID(), zone->GetInstanceVersion()); - zone->StartShutdownTimer(shutdown_timer); + if (zone && zone->GetZoneID() && zone->GetInstanceVersion()) { + uint32 shutdown_timer = database.getZoneShutDownDelay(zone->GetZoneID(), zone->GetInstanceVersion()); + zone->StartShutdownTimer(shutdown_timer); + } } else if (!previous_loaded && current_loaded) { process_timer.Stop(); From f29fe17496ba34f4818e0a1812a903a5b79e75d7 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 16 Oct 2017 13:46:09 -0500 Subject: [PATCH 47/97] Potential pathing crash fix --- zone/mob_ai.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 8efdba38c..a6d6c992a 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1298,7 +1298,7 @@ void Mob::AI_Process() { if (AI_PursueCastCheck()) { //we did something, so do not process movement. } - else if (AI_movement_timer->Check()) + else if (AI_movement_timer->Check() && target) { if (!IsRooted()) { Log(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", target->GetName()); From 00b2debb3217ed13cd4924f8eebcddf681b9e497 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 16 Oct 2017 13:52:01 -0500 Subject: [PATCH 48/97] Raid::UpdateGroupAAs out of range crash in memset --- zone/raids.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zone/raids.cpp b/zone/raids.cpp index 9b33056c0..d86d6c3fc 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -323,6 +323,10 @@ void Raid::SaveRaidLeaderAA() void Raid::UpdateGroupAAs(uint32 gid) { + + if (gid <= 0 || gid > MAX_RAID_GROUPS) + return; + Client *gl = GetGroupLeader(gid); if (gl) From b9d2c1b9f61f9c2176396f22a3de98bf1dfd1ae1 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 16 Oct 2017 13:56:02 -0500 Subject: [PATCH 49/97] Client::Handle_OP_RaidCommand crash fix --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index fe5ab8d92..3b91a280c 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -11480,7 +11480,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) Client *client_moved = entity_list.GetClientByName(raid_command_packet->leader_name); - if (client_moved) { + if (client_moved && client_moved->GetRaid()) { client_moved->GetRaid()->SendHPManaEndPacketsTo(client_moved); client_moved->GetRaid()->SendHPManaEndPacketsFrom(client_moved); From 7dd904c8d12025658db6ff8911da152a145be488 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Mon, 16 Oct 2017 16:39:22 -0400 Subject: [PATCH 50/97] Roam Box code was changing z every loop through. --- zone/mob_ai.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 8efdba38c..72c81d374 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1535,15 +1535,17 @@ void NPC::AI_DoMovement() { roambox_movingto_x = zone->random.Real(roambox_min_x+1,roambox_max_x-1); if (roambox_movingto_y > roambox_max_y || roambox_movingto_y < roambox_min_y) roambox_movingto_y = zone->random.Real(roambox_min_y+1,roambox_max_y-1); + Log(Logs::Detail, Logs::AI, + "Roam Box: d=%.3f (%.3f->%.3f,%.3f->%.3f): Go To (%.3f,%.3f)", + roambox_distance, roambox_min_x, roambox_max_x, roambox_min_y, + roambox_max_y, roambox_movingto_x, roambox_movingto_y); } - Log(Logs::Detail, Logs::AI, "Roam Box: d=%.3f (%.3f->%.3f,%.3f->%.3f): Go To (%.3f,%.3f)", - roambox_distance, roambox_min_x, roambox_max_x, roambox_min_y, roambox_max_y, roambox_movingto_x, roambox_movingto_y); - - float new_z = this->FindGroundZ(m_Position.x, m_Position.y, 5) + this->GetZOffset(); - - if (!CalculateNewPosition2(roambox_movingto_x, roambox_movingto_y, new_z, walksp, true)) + // Keep calling with updates, using wherever we are in Z. + if (!MakeNewPositionAndSendUpdate(roambox_movingto_x, + roambox_movingto_y, m_Position.z, walksp)) { + this->FixZ(); // FixZ on final arrival point. roambox_movingto_x = roambox_max_x + 1; // force update pLastFightingDelayMoving = Timer::GetCurrentTime() + RandomTimer(roambox_min_delay, roambox_delay); SetMoving(false); From b10f5d374583053bda91e15ad3e0266051fcd50f Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 16 Oct 2017 15:52:59 -0500 Subject: [PATCH 51/97] Group ID can be zero --- zone/raids.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/raids.cpp b/zone/raids.cpp index d86d6c3fc..2bbd83064 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -324,7 +324,7 @@ void Raid::SaveRaidLeaderAA() void Raid::UpdateGroupAAs(uint32 gid) { - if (gid <= 0 || gid > MAX_RAID_GROUPS) + if (gid < 0 || gid > MAX_RAID_GROUPS) return; Client *gl = GetGroupLeader(gid); From 199dd7d6183728490b2373e8bb18ef4769b69fc1 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Fri, 20 Oct 2017 17:01:39 -0400 Subject: [PATCH 52/97] Fix missing round kick dmg calc --- zone/special_attacks.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 57ea1c781..03b144b5a 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -37,6 +37,7 @@ int Mob::GetBaseSkillDamage(EQEmu::skills::SkillType skill, Mob *target) case EQEmu::skills::SkillDragonPunch: case EQEmu::skills::SkillEagleStrike: case EQEmu::skills::SkillTigerClaw: + case EQEmu::skills::SkillRoundKick: if (skill_level >= 25) base++; if (skill_level >= 75) From c8b75e982ef24617c8ba99aff9fccd990d2f11b7 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Fri, 20 Oct 2017 18:36:11 -0500 Subject: [PATCH 53/97] Safeguard characters losing their account_id --- zone/zonedb.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index a9a0c7042..e23d534c5 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -1433,6 +1433,11 @@ bool ZoneDatabase::SaveCharacterInventorySnapshot(uint32 character_id){ } bool ZoneDatabase::SaveCharacterData(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp, ExtendedProfile_Struct* m_epp){ + + /* If this is ever zero - the client hasn't fully loaded and potentially crashed during zone */ + if (account_id <= 0) + return false; + clock_t t = std::clock(); /* Function timer start */ std::string query = StringFormat( "REPLACE INTO `character_data` (" From 9856df20fbf402208b0caf45cbf02f6cc603bba3 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 23 Oct 2017 17:24:18 -0500 Subject: [PATCH 54/97] Fix SQL syntax in Adventure::MoveCorpsesToGraveyard() --- world/adventure.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/world/adventure.cpp b/world/adventure.cpp index cbea9079c..c984fa831 100644 --- a/world/adventure.cpp +++ b/world/adventure.cpp @@ -380,7 +380,7 @@ void Adventure::MoveCorpsesToGraveyard() std::list dbid_list; std::list charid_list; - std::string query = StringFormat("SELECT id, charid FROM character_corpses WHERE instanceid=%d", GetInstanceID()); + std::string query = StringFormat("SELECT id, charid FROM character_corpses WHERE instance_id=%d", GetInstanceID()); auto results = database.QueryDatabase(query); if(!results.Success()) @@ -395,8 +395,8 @@ void Adventure::MoveCorpsesToGraveyard() float z = GetTemplate()->graveyard_z; query = StringFormat("UPDATE character_corpses " - "SET zoneid = %d, instanceid = 0, " - "x = %f, y = %f, z = %f WHERE instanceid = %d", + "SET zone_id = %d, instance_id = 0, " + "x = %f, y = %f, z = %f WHERE instance_id = %d", GetTemplate()->graveyard_zone_id, x, y, z, GetInstanceID()); database.QueryDatabase(query); From 50d5f3785c253fd4ca80e3885ba26464d5ca8bf8 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Tue, 24 Oct 2017 00:02:49 -0400 Subject: [PATCH 55/97] Send caster name in buff packets for UF+ Currently the names only show for inspecting via Target Window because we send buff packets in the wrong order and there is a dependency on them being correct for self that isn't present for target window. --- common/eq_packet_structs.h | 2 ++ common/patches/rof.cpp | 4 ++-- common/patches/rof2.cpp | 4 ++-- common/patches/uf.cpp | 4 ++-- zone/spell_effects.cpp | 17 +++++++++-------- zone/spells.cpp | 9 +++++++-- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index 4876b4211..8452813f5 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -4767,6 +4767,7 @@ struct BuffIconEntry_Struct uint32 spell_id; int32 tics_remaining; uint32 num_hits; + char caster[64]; }; struct BuffIcon_Struct @@ -4776,6 +4777,7 @@ struct BuffIcon_Struct uint16 count; uint8 type; // 0 = self buff window, 1 = self target window, 4 = group, 5 = PC, 7 = NPC int32 tic_timer; + int32 name_lengths; // so ahh we kind of do these packets hacky, this is the total length of all the names to make creating the real packets in the translators easier BuffIconEntry_Struct entries[0]; }; diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index 1df8d1aa5..b655cffb0 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -460,7 +460,7 @@ namespace RoF { SETUP_VAR_ENCODE(BuffIcon_Struct); - uint32 sz = 12 + (17 * emu->count); + uint32 sz = 12 + (17 * emu->count) + emu->name_lengths; // 17 includes nullterm __packet->size = sz; __packet->pBuffer = new unsigned char[sz]; memset(__packet->pBuffer, 0, sz); @@ -476,7 +476,7 @@ namespace RoF __packet->WriteUInt32(emu->entries[i].spell_id); __packet->WriteUInt32(emu->entries[i].tics_remaining); __packet->WriteUInt32(emu->entries[i].num_hits); // Unknown - __packet->WriteString(""); + __packet->WriteString(emu->entries[i].caster); } __packet->WriteUInt8(emu->type); // Unknown diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index 57a8d9eb6..baf6d6b09 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -528,7 +528,7 @@ namespace RoF2 { SETUP_VAR_ENCODE(BuffIcon_Struct); - uint32 sz = 12 + (17 * emu->count); + uint32 sz = 12 + (17 * emu->count) + emu->name_lengths; // 17 includes nullterm __packet->size = sz; __packet->pBuffer = new unsigned char[sz]; memset(__packet->pBuffer, 0, sz); @@ -544,7 +544,7 @@ namespace RoF2 __packet->WriteUInt32(emu->entries[i].spell_id); __packet->WriteUInt32(emu->entries[i].tics_remaining); __packet->WriteUInt32(emu->entries[i].num_hits); // Unknown - __packet->WriteString(""); + __packet->WriteString(emu->entries[i].caster); } __packet->WriteUInt8(emu->type); // Unknown diff --git a/common/patches/uf.cpp b/common/patches/uf.cpp index 87cd6c700..cf0c17176 100644 --- a/common/patches/uf.cpp +++ b/common/patches/uf.cpp @@ -391,7 +391,7 @@ namespace UF { SETUP_VAR_ENCODE(BuffIcon_Struct); - uint32 sz = 12 + (17 * emu->count); + uint32 sz = 12 + (17 * emu->count) + emu->name_lengths; // 17 includes nullterm __packet->size = sz; __packet->pBuffer = new unsigned char[sz]; memset(__packet->pBuffer, 0, sz); @@ -407,7 +407,7 @@ namespace UF __packet->WriteUInt32(emu->entries[i].spell_id); __packet->WriteUInt32(emu->entries[i].tics_remaining); __packet->WriteUInt32(emu->entries[i].num_hits); - __packet->WriteString(""); + __packet->WriteString(emu->entries[i].caster); } __packet->WriteUInt8(emu->type); diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 375572014..9f78cb35d 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -137,6 +137,15 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove buffs[buffslot].magic_rune = 0; buffs[buffslot].numhits = 0; + if (spells[spell_id].numhits > 0) { + + int numhit = spells[spell_id].numhits; + + numhit += numhit * caster->GetFocusEffect(focusFcLimitUse, spell_id) / 100; + numhit += caster->GetFocusEffect(focusIncreaseNumHits, spell_id); + buffs[buffslot].numhits = numhit; + } + if (spells[spell_id].EndurUpkeep > 0) SetEndurUpkeep(true); @@ -184,14 +193,6 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove } } - if(spells[spell_id].numhits > 0 && buffslot >= 0){ - - int numhit = spells[spell_id].numhits; - - numhit += numhit*caster->GetFocusEffect(focusFcLimitUse, spell_id)/100; - numhit += caster->GetFocusEffect(focusIncreaseNumHits, spell_id); - buffs[buffslot].numhits = numhit; - } if (!IsPowerDistModSpell(spell_id)) SetSpellPowerDistanceMod(0); diff --git a/zone/spells.cpp b/zone/spells.cpp index 877886757..c5a5a0b48 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -3309,8 +3309,8 @@ int Mob::AddBuff(Mob *caster, uint16 spell_id, int duration, int32 level_overrid buffs[emptyslot].spellid = spell_id; buffs[emptyslot].casterlevel = caster_level; - if (caster && caster->IsClient()) - strcpy(buffs[emptyslot].caster_name, caster->GetName()); + if (caster && !caster->IsAura()) // maybe some other things we don't want to ... + strcpy(buffs[emptyslot].caster_name, caster->GetCleanName()); else memset(buffs[emptyslot].caster_name, 0, 64); buffs[emptyslot].casterid = caster ? caster->GetID() : 0; @@ -5548,6 +5548,8 @@ void Client::SendBuffNumHitPacket(Buffs_Struct &buff, int slot) bi->entries[0].spell_id = buff.spellid; bi->entries[0].tics_remaining = buff.ticsremaining; bi->entries[0].num_hits = buff.numhits; + strn0cpy(bi->entries[0].caster, buff.caster_name, 64); + bi->name_lengths = strlen(bi->entries[0].caster); FastQueuePacket(&outapp); } @@ -5633,6 +5635,7 @@ EQApplicationPacket *Mob::MakeBuffsPacket(bool for_target) else buff->type = 0; + buff->name_lengths = 0; // hacky shit uint32 index = 0; for(int i = 0; i < buff_count; ++i) { @@ -5642,6 +5645,8 @@ EQApplicationPacket *Mob::MakeBuffsPacket(bool for_target) buff->entries[index].spell_id = buffs[i].spellid; buff->entries[index].tics_remaining = buffs[i].ticsremaining; buff->entries[index].num_hits = buffs[i].numhits; + strn0cpy(buff->entries[index].caster, buffs[i].caster_name, 64); + buff->name_lengths += strlen(buff->entries[index].caster); ++index; } } From ed98aa45d2677840bdb7566c358861dc96138e84 Mon Sep 17 00:00:00 2001 From: regneq Date: Fri, 27 Oct 2017 21:24:24 -0700 Subject: [PATCH 56/97] Traps overhaul. New functionality has been added, while preserving the old functionality. Numerous bug fixes occurred as well. Added column triggered_number. If this is set, then the trap will despawn after it has been triggered this number of times. If 0, the trap will never despawn on its own. Added group column. This allows developers to group traps together in a similar way as spawngroups for NPCs. When a trap that is grouped is despawned in anyway, a random trap in the group will take its place. Grouped traps do not have to be at the same coords or have the same type. This can allow for some spawning diversity if so required. If set to 0, the trap is not grouped and will always respawn. Added column despawn_when_triggered. If set to 1, then a trap will despawn when a player triggers it. If 0, then there will be a 5 second reset time and then the same trap will again be active. (Assuming triggered_number has not been reached.) The player that triggered the trap will not re-trigger it until they have left and re-enetered the trap's radius. Traps will no longer trigger on players that are currently zoning. This fixes some weirdness and at least one crash. The trap can trigger however after the connection is been completed. If a player camped out in a trap radius they can potentially still be hit. Alarm type traps were not using effectvalue2 to determine who should be aggroed. This is now fixed. Traps will no longer be broken by #repop, #depopzone, or #reloadworld. All 3 commands will now have the same effect on traps as they do for NPCs. Added command #reloadtraps. This reloads all of the traps in the zone. Added command #trapinfo. This gives some information about the traps currently spawned in the zone. Added Traps logsys category Required SQL: utils/sql/git/required/2017_10_26_traps.sql --- common/eqemu_logsys.h | 4 +- utils/sql/git/required/2017_10_28_traps.sql | 3 + zone/client.cpp | 2 + zone/client.h | 2 + zone/client_packet.cpp | 4 +- zone/command.cpp | 12 + zone/command.h | 2 + zone/entity.h | 4 + zone/trap.cpp | 271 ++++++++++++++++++-- zone/trap.h | 13 +- zone/zone.cpp | 7 +- zone/zonedb.h | 3 +- 12 files changed, 297 insertions(+), 30 deletions(-) create mode 100644 utils/sql/git/required/2017_10_28_traps.sql diff --git a/common/eqemu_logsys.h b/common/eqemu_logsys.h index 10d9e460c..a54edc234 100644 --- a/common/eqemu_logsys.h +++ b/common/eqemu_logsys.h @@ -89,6 +89,7 @@ enum LogCategory { HP_Update, FixZ, Food, + Traps, MaxCategoryID /* Don't Remove this*/ }; @@ -142,7 +143,8 @@ static const char* LogCategoryName[LogCategory::MaxCategoryID] = { "Headless Client", "HP Update", "FixZ", - "Food" + "Food", + "Traps" }; } diff --git a/utils/sql/git/required/2017_10_28_traps.sql b/utils/sql/git/required/2017_10_28_traps.sql new file mode 100644 index 000000000..20c249ede --- /dev/null +++ b/utils/sql/git/required/2017_10_28_traps.sql @@ -0,0 +1,3 @@ +alter table `traps` add column `triggered_number` tinyint(4) not null default 0; +alter table `traps` add column `group` tinyint(4) not null default 0; +alter table `traps` add column `despawn_when_triggered` tinyint(4) not null default 0; diff --git a/zone/client.cpp b/zone/client.cpp index ce084747a..893a6b51b 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -331,6 +331,8 @@ Client::Client(EQStreamInterface* ieqs) interrogateinv_flag = false; + trapid = 0; + for (int i = 0; i < InnateSkillMax; ++i) m_pp.InnateSkills[i] = InnateDisabled; diff --git a/zone/client.h b/zone/client.h index e334f8fd9..88622fcff 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1302,6 +1302,8 @@ public: int32 CalcATK(); + uint32 trapid; //ID of trap player has triggered. This is cleared when the player leaves the trap's radius, or it despawns. + protected: friend class Mob; void CalcItemBonuses(StatBonuses* newbon); diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 6710fdfec..4271ec33f 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -5337,8 +5337,8 @@ void Client::Handle_OP_DisarmTraps(const EQApplicationPacket *app) { Message(MT_Skills, "You disarm a trap."); trap->disarmed = true; - trap->chkarea_timer.Disable(); - trap->respawn_timer.Start((trap->respawn_time + zone->random.Int(0, trap->respawn_var)) * 1000); + Log(Logs::General, Logs::Traps, "Trap %d is disarmed.", trap->trap_id); + trap->UpdateTrap(); } else { diff --git a/zone/command.cpp b/zone/command.cpp index 15b09b9dc..a65f9005e 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -321,6 +321,7 @@ int command_init(void) command_add("reloadqst", " - Clear quest cache (any argument causes it to also stop all timers)", 150, command_reloadqst) || command_add("reloadrulesworld", "Executes a reload of all rules in world specifically.", 80, command_reloadworldrules) || command_add("reloadstatic", "- Reload Static Zone Data", 150, command_reloadstatic) || + command_add("reloadtraps", "- Repops all traps in the current zone.", 80, command_reloadtraps) || command_add("reloadtitles", "- Reload player titles from the database", 150, command_reloadtitles) || command_add("reloadworld", "[0|1] - Clear quest cache (0 - no repop, 1 - repop)", 255, command_reloadworld) || command_add("reloadzps", "- Reload zone points from database", 150, command_reloadzps) || @@ -382,6 +383,7 @@ int command_init(void) command_add("title", "[text] [1 = create title table row] - Set your or your player target's title", 50, command_title) || command_add("titlesuffix", "[text] [1 = create title table row] - Set your or your player target's title suffix", 50, command_titlesuffix) || command_add("traindisc", "[level] - Trains all the disciplines usable by the target, up to level specified. (may freeze client for a few seconds)", 150, command_traindisc) || + command_add("trapinfo", "- Gets infomation about the traps currently spawned in the zone.", 81, command_trapinfo) || command_add("tune", "Calculate ideal statical values related to combat.", 100, command_tune) || command_add("undyeme", "- Remove dye from all of your armor slots", 0, command_undyeme) || command_add("unfreeze", "- Unfreeze your target", 80, command_unfreeze) || @@ -10851,6 +10853,16 @@ void command_reloadperlexportsettings(Client *c, const Seperator *sep) } } +void command_trapinfo(Client *c, const Seperator *sep) +{ + entity_list.GetTrapInfo(c); +} + +void command_reloadtraps(Client *c, const Seperator *sep) +{ + entity_list.UpdateAllTraps(true, true); + c->Message(CC_Default, "Traps reloaded for %s.", zone->GetShortName()); +} // All new code added to command.cpp should be BEFORE this comment line. Do no append code to this file below the BOTS code block. #ifdef BOTS diff --git a/zone/command.h b/zone/command.h index 0a850fbca..dca70d767 100644 --- a/zone/command.h +++ b/zone/command.h @@ -228,6 +228,7 @@ void command_reloadperlexportsettings(Client *c, const Seperator *sep); void command_reloadqst(Client *c, const Seperator *sep); void command_reloadstatic(Client *c, const Seperator *sep); void command_reloadtitles(Client *c, const Seperator *sep); +void command_reloadtraps(Client* c, const Seperator *sep); void command_reloadworld(Client *c, const Seperator *sep); void command_reloadworldrules(Client *c, const Seperator *sep); void command_reloadzps(Client *c, const Seperator *sep); @@ -295,6 +296,7 @@ void command_timezone(Client *c, const Seperator *sep); void command_title(Client *c, const Seperator *sep); void command_titlesuffix(Client *c, const Seperator *sep); void command_traindisc(Client *c, const Seperator *sep); +void command_trapinfo(Client* c, const Seperator *sep); void command_tune(Client *c, const Seperator *sep); void command_undye(Client *c, const Seperator *sep); void command_undyeme(Client *c, const Seperator *sep); diff --git a/zone/entity.h b/zone/entity.h index 29075d9fe..996580aa6 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -473,6 +473,10 @@ public: void RefreshClientXTargets(Client *c); void SendAlternateAdvancementStats(); + void GetTrapInfo(Client* client); + bool IsTrapGroupSpawned(uint32 trap_id, uint8 group); + void UpdateAllTraps(bool respawn, bool repopnow = false); + void ClearTrapPointers(); protected: friend class Zone; void Depop(bool StartSpawnTimer = false); diff --git a/zone/trap.cpp b/zone/trap.cpp index 87000f940..f563048f8 100644 --- a/zone/trap.cpp +++ b/zone/trap.cpp @@ -52,10 +52,12 @@ CREATE TABLE traps ( Trap::Trap() : Entity(), respawn_timer(600000), - chkarea_timer(500), + chkarea_timer(1000), + reset_timer(5000), m_Position(glm::vec3()) { trap_id = 0; + db_id = 0; maxzdiff = 0; radius = 0; effect = 0; @@ -64,12 +66,19 @@ Trap::Trap() : skill = 0; level = 0; respawn_timer.Disable(); + reset_timer.Disable(); detected = false; disarmed = false; respawn_time = 0; respawn_var = 0; hiddenTrigger = nullptr; ownHiddenTrigger = false; + chance = 0; + triggered_number = 0; + times_triggered = 0; + group = 0; + despawn_when_triggered = false; + charid = 0; } Trap::~Trap() @@ -80,8 +89,7 @@ Trap::~Trap() bool Trap::Process() { - if (chkarea_timer.Enabled() && chkarea_timer.Check() - /*&& zone->GetClientCount() > 0*/ ) + if (chkarea_timer.Enabled() && chkarea_timer.Check() && !reset_timer.Enabled()) { Mob* trigger = entity_list.GetTrapTrigger(this); if (trigger && !(trigger->IsClient() && trigger->CastToClient()->GetGM())) @@ -89,6 +97,13 @@ bool Trap::Process() Trigger(trigger); } } + else if (reset_timer.Enabled() && reset_timer.Check()) + { + Log(Logs::General, Logs::Traps, "Reset timer disabled in Reset Check Process for trap %d.", trap_id); + reset_timer.Disable(); + charid = 0; + } + if (respawn_timer.Enabled() && respawn_timer.Check()) { detected = false; @@ -96,11 +111,15 @@ bool Trap::Process() chkarea_timer.Enable(); respawn_timer.Disable(); } + + return true; } void Trap::Trigger(Mob* trigger) { + Log(Logs::General, Logs::Traps, "Trap %d triggered by %s for the %d time!", trap_id, trigger->GetName(), times_triggered + 1); + int i = 0; const NPCType* tmp = 0; switch (effect) @@ -128,7 +147,7 @@ void Trap::Trigger(Mob* trigger) entity_list.MessageClose(trigger,false,effectvalue,13,"%s",message.c_str()); } - entity_list.SendAlarm(this,trigger,effectvalue); + entity_list.SendAlarm(this,trigger, effectvalue2); break; case trapTypeMysticSpawn: if (message.empty()) @@ -201,12 +220,41 @@ void Trap::Trigger(Mob* trigger) safe_delete(outapp); } } - respawn_timer.Start((respawn_time + zone->random.Int(0, respawn_var)) * 1000); - chkarea_timer.Disable(); - disarmed = true; + + if (trigger && trigger->IsClient()) + { + trigger->CastToClient()->trapid = trap_id; + charid = trigger->CastToClient()->CharacterID(); + } + + bool update = false; + if (despawn_when_triggered) + { + Log(Logs::General, Logs::Traps, "Trap %d is despawning after being triggered.", trap_id); + update = true; + } + else + { + reset_timer.Start(5000); + } + + if (triggered_number > 0) + ++times_triggered; + + if (triggered_number > 0 && triggered_number <= times_triggered) + { + Log(Logs::General, Logs::Traps, "Triggered number for trap %d reached. %d/%d", trap_id, times_triggered, triggered_number); + update = true; + } + + if (update) + { + UpdateTrap(); + } } -Trap* EntityList::FindNearbyTrap(Mob* searcher, float max_dist) { +Trap* EntityList::FindNearbyTrap(Mob* searcher, float max_dist) +{ float dist = 999999; Trap* current_trap = nullptr; @@ -231,45 +279,135 @@ Trap* EntityList::FindNearbyTrap(Mob* searcher, float max_dist) { return current_trap; } -Mob* EntityList::GetTrapTrigger(Trap* trap) { - Mob* savemob = 0; +Mob* EntityList::GetTrapTrigger(Trap* trap) +{ float maxdist = trap->radius * trap->radius; - - for (auto it = client_list.begin(); it != client_list.end(); ++it) { + for (auto it = client_list.begin(); it != client_list.end(); ++it) + { Client* cur = it->second; auto diff = glm::vec3(cur->GetPosition()) - trap->m_Position; diff.z = std::abs(diff.z); if ((diff.x*diff.x + diff.y*diff.y) <= maxdist - && diff.z < trap->maxzdiff) + && diff.z <= trap->maxzdiff) { - if (zone->random.Roll(trap->chance)) - return(cur); - else - savemob = cur; - } + //This prevents the trap from triggering on players while zoning. + if (strcmp(cur->GetName(), "No name") == 0) + continue; + if (cur->trapid == 0 && !cur->GetGM() && (trap->chance == 0 || zone->random.Roll(trap->chance))) + { + Log(Logs::General, Logs::Traps, "%s is about to trigger trap %d of chance %d. diff: %0.2f maxdist: %0.2f zdiff: %0.2f maxzdiff: %0.2f", cur->GetName(), trap->trap_id, trap->chance, (diff.x*diff.x + diff.y*diff.y), maxdist, diff.z, trap->maxzdiff); + return cur; + } + } + else + { + if (cur->trapid == trap->trap_id) + { + Log(Logs::General, Logs::Traps, "%s is clearing trapid for trap %d", cur->GetName(), trap->trap_id); + cur->trapid = 0; + } + } } - return savemob; + return nullptr; } -//todo: rewrite this to not need direct access to trap members. +bool EntityList::IsTrapGroupSpawned(uint32 trap_id, uint8 group) +{ + auto it = trap_list.begin(); + while (it != trap_list.end()) + { + Trap* cur = it->second; + if (cur->IsTrap() && cur->group == group && cur->trap_id != trap_id) + { + return true; + } + ++it; + } + + return false; +} + +void EntityList::UpdateAllTraps(bool respawn, bool repopnow) +{ + auto it = trap_list.begin(); + while (it != trap_list.end()) + { + Trap* cur = it->second; + if (cur->IsTrap()) + { + cur->UpdateTrap(respawn, repopnow); + } + ++it; + } + + Log(Logs::General, Logs::Traps, "All traps updated."); +} + +void EntityList::GetTrapInfo(Client* client) +{ + uint8 count = 0; + auto it = trap_list.begin(); + while (it != trap_list.end()) + { + Trap* cur = it->second; + if (cur->IsTrap()) + { + bool isset = (cur->chkarea_timer.Enabled() && !cur->reset_timer.Enabled()); + client->Message(CC_Default, " Trap: (%d) found at %0.2f,%0.2f,%0.2f. Times Triggered: %d Is Active: %d Group: %d Message: %s", cur->trap_id, cur->m_Position.x, cur->m_Position.y, cur->m_Position.z, cur->times_triggered, isset, cur->group, cur->message.c_str()); + ++count; + } + ++it; + } + + client->Message(CC_Default, "%d traps found.", count); +} + +void EntityList::ClearTrapPointers() +{ + auto it = trap_list.begin(); + while (it != trap_list.end()) + { + Trap* cur = it->second; + if (cur->IsTrap()) + { + cur->DestroyHiddenTrigger(); + } + ++it; + } +} + + bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) { std::string query = StringFormat("SELECT id, x, y, z, effect, effectvalue, effectvalue2, skill, " - "maxzdiff, radius, chance, message, respawn_time, respawn_var, level " - "FROM traps WHERE zone='%s' AND version=%u", zonename, version); + "maxzdiff, radius, chance, message, respawn_time, respawn_var, level, " + "`group`, triggered_number, despawn_when_triggered FROM traps WHERE zone='%s' AND version=%u", zonename, version); + auto results = QueryDatabase(query); if (!results.Success()) { return false; } for (auto row = results.begin(); row != results.end(); ++row) { + uint32 tid = atoi(row[0]); + uint8 grp = atoi(row[15]); + + if (grp > 0) + { + // If a member of our group is already spawned skip loading this trap. + if (entity_list.IsTrapGroupSpawned(tid, grp)) + { + continue; + } + } auto trap = new Trap(); - trap->trap_id = atoi(row[0]); + trap->trap_id = tid; + trap->db_id = tid; trap->m_Position = glm::vec3(atof(row[1]), atof(row[2]), atof(row[3])); trap->effect = atoi(row[4]); trap->effectvalue = atoi(row[5]); @@ -282,8 +420,12 @@ bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) { trap->respawn_time = atoi(row[12]); trap->respawn_var = atoi(row[13]); trap->level = atoi(row[14]); + trap->group = grp; + trap->triggered_number = atoi(row[16]); + trap->despawn_when_triggered = atoi(row[17]); entity_list.AddTrap(trap); trap->CreateHiddenTrigger(); + Log(Logs::General, Logs::Traps, "Trap %d successfully loaded.", trap->trap_id); } return true; @@ -318,3 +460,86 @@ void Trap::CreateHiddenTrigger() hiddenTrigger = npca; ownHiddenTrigger = true; } +bool ZoneDatabase::SetTrapData(Trap* trap, bool repopnow) { + + uint32 dbid = trap->db_id; + std::string query; + + if (trap->group > 0) + { + query = StringFormat("SELECT id, x, y, z, effect, effectvalue, effectvalue2, skill, " + "maxzdiff, radius, chance, message, respawn_time, respawn_var, level, " + "triggered_number, despawn_when_triggered FROM traps WHERE zone='%s' AND `group`=%d AND id != %d ORDER BY RAND() LIMIT 1", zone->GetShortName(), trap->group, dbid); + } + else + { + // We could just use the existing data here, but querying the DB is not expensive, and allows content developers to change traps without rebooting. + query = StringFormat("SELECT id, x, y, z, effect, effectvalue, effectvalue2, skill, " + "maxzdiff, radius, chance, message, respawn_time, respawn_var, level, " + "triggered_number, despawn_when_triggered FROM traps WHERE zone='%s' AND id = %d", zone->GetShortName(), dbid); + } + + auto results = QueryDatabase(query); + if (!results.Success()) { + return false; + } + + for (auto row = results.begin(); row != results.end(); ++row) { + + trap->db_id = atoi(row[0]); + trap->m_Position = glm::vec3(atof(row[1]), atof(row[2]), atof(row[3])); + trap->effect = atoi(row[4]); + trap->effectvalue = atoi(row[5]); + trap->effectvalue2 = atoi(row[6]); + trap->skill = atoi(row[7]); + trap->maxzdiff = atof(row[8]); + trap->radius = atof(row[9]); + trap->chance = atoi(row[10]); + trap->message = row[11]; + trap->respawn_time = atoi(row[12]); + trap->respawn_var = atoi(row[13]); + trap->level = atoi(row[14]); + trap->triggered_number = atoi(row[15]); + trap->despawn_when_triggered = atoi(row[16]); + trap->CreateHiddenTrigger(); + + if (repopnow) + { + trap->chkarea_timer.Enable(); + } + else + { + trap->respawn_timer.Start((trap->respawn_time + zone->random.Int(0, trap->respawn_var)) * 1000); + } + + if (trap->trap_id != trap->db_id) + Log(Logs::General, Logs::Traps, "Trap (%d) DBID has changed from %d to %d", trap->trap_id, dbid, trap->db_id); + + return true; + } + + return false; +} + +void Trap::UpdateTrap(bool respawn, bool repopnow) +{ + respawn_timer.Disable(); + chkarea_timer.Disable(); + reset_timer.Disable(); + if (hiddenTrigger) + { + hiddenTrigger->Depop(); + hiddenTrigger = nullptr; + } + times_triggered = 0; + Client* trigger = entity_list.GetClientByCharID(charid); + if (trigger) + { + trigger->trapid = 0; + } + charid = 0; + if (respawn) + { + database.SetTrapData(this, repopnow); + } +} \ No newline at end of file diff --git a/zone/trap.h b/zone/trap.h index 4adab320a..4c0d53106 100644 --- a/zone/trap.h +++ b/zone/trap.h @@ -49,11 +49,15 @@ public: NPC * GetHiddenTrigger() { return hiddenTrigger; } void SetHiddenTrigger(NPC* n) { hiddenTrigger = n; } void CreateHiddenTrigger(); - + void DestroyHiddenTrigger() { hiddenTrigger = nullptr; } + void SetTrapData(); + void UpdateTrap(bool respawn = true, bool repopnow = false); //Trap data, leave this unprotected Timer respawn_timer; //Respawn Time when Trap's been disarmed Timer chkarea_timer; - uint32 trap_id; //Database ID of trap + Timer reset_timer; //How long a trap takes to reset before triggering again. + uint32 trap_id; //Original ID of the trap from DB. This value never changes. + uint32 db_id; //The DB ID of the trap that currently is spawned. glm::vec3 m_Position; float maxzdiff; //maximum z diff to be triggerable float radius; //radius around trap to be triggerable @@ -67,6 +71,11 @@ public: bool disarmed; uint32 respawn_time; uint32 respawn_var; + uint8 triggered_number; + uint8 times_triggered; + uint8 group; + bool despawn_when_triggered; + uint32 charid; //ID of character that triggered trap. This is cleared when the trap despawns are resets. std::string message; protected: diff --git a/zone/zone.cpp b/zone/zone.cpp index 8441f7d82..3a8f1e938 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1428,7 +1428,8 @@ void Zone::StartShutdownTimer(uint32 set_time) { bool Zone::Depop(bool StartSpawnTimer) { std::map::iterator itr; entity_list.Depop(StartSpawnTimer); - + entity_list.ClearTrapPointers(); + entity_list.UpdateAllTraps(false); /* Refresh npctable (cache), getting current info from database. */ while(!npctable.empty()) { itr = npctable.begin(); @@ -1496,6 +1497,8 @@ void Zone::Repop(uint32 delay) { iterator.RemoveCurrent(); } + entity_list.ClearTrapPointers(); + quest_manager.ClearAllTimers(); if (!database.PopulateZoneSpawnList(zoneid, spawn2_list, GetInstanceVersion(), delay)) @@ -1503,6 +1506,8 @@ void Zone::Repop(uint32 delay) { initgrids_timer.Start(); + entity_list.UpdateAllTraps(true, true); + //MODDING HOOK FOR REPOP mod_repop(); } diff --git a/zone/zonedb.h b/zone/zonedb.h index a8ab3659f..c134dade3 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -16,6 +16,7 @@ class NPC; class Petition; class Spawn2; class SpawnGroupList; +class Trap; struct CharacterEventLog_Struct; struct Door; struct ExtendedProfile_Struct; @@ -478,7 +479,7 @@ public: /* Traps */ bool LoadTraps(const char* zonename, int16 version); - char* GetTrapMessage(uint32 trap_id); + bool SetTrapData(Trap* trap, bool repopnow = false); /* Time */ uint32 GetZoneTZ(uint32 zoneid, uint32 version); From cd748e7d8bb865298d9b58963a75a6766f11411b Mon Sep 17 00:00:00 2001 From: regneq Date: Sat, 28 Oct 2017 10:02:31 -0700 Subject: [PATCH 57/97] Fixed an issue that would cause traps to not function correctly if skill is 0 in the database. Added undetectable column, to allow content developers to make a trap undetectable and not able to be disarmed. Pets will no longer try to aggro traps its owner triggers. Traps will now use the radius column to determine disarm range, instead of using a hardcoded value which may not be appropriate in all cases. Decreased the scan range for traps to disarm. Fixed some typos, and removed some unused code. --- utils/sql/git/required/2017_10_28_traps.sql | 1 + zone/attack.cpp | 5 ++- zone/client_packet.cpp | 50 +++++++++++++-------- zone/common.h | 5 +++ zone/entity.h | 2 +- zone/string_ids.h | 5 +++ zone/trap.cpp | 31 +++++++++---- zone/trap.h | 2 +- 8 files changed, 71 insertions(+), 30 deletions(-) diff --git a/utils/sql/git/required/2017_10_28_traps.sql b/utils/sql/git/required/2017_10_28_traps.sql index 20c249ede..dddc00d1b 100644 --- a/utils/sql/git/required/2017_10_28_traps.sql +++ b/utils/sql/git/required/2017_10_28_traps.sql @@ -1,3 +1,4 @@ alter table `traps` add column `triggered_number` tinyint(4) not null default 0; alter table `traps` add column `group` tinyint(4) not null default 0; alter table `traps` add column `despawn_when_triggered` tinyint(4) not null default 0; +alter table `traps` add column `undetectable` tinyint(4) not null default 0; diff --git a/zone/attack.cpp b/zone/attack.cpp index a6baffc8d..d12d8d36c 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -2533,6 +2533,9 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b if (other == this) return; + if (other->IsTrap()) + return; + if (damage < 0) { hate = 1; } @@ -3364,7 +3367,7 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const // pets that have GHold will never automatically add NPCs // pets that have Hold and no Focus will add NPCs if they're engaged // pets that have Hold and Focus will not add NPCs - if (pet && !pet->IsFamiliar() && !pet->GetSpecialAbility(IMMUNE_AGGRO) && !pet->IsEngaged() && attacker && attacker != this && !attacker->IsCorpse() && !pet->IsGHeld()) + if (pet && !pet->IsFamiliar() && !pet->GetSpecialAbility(IMMUNE_AGGRO) && !pet->IsEngaged() && attacker && attacker != this && !attacker->IsCorpse() && !pet->IsGHeld() && !attacker->IsTrap()) { if (!pet->IsHeld()) { Log(Logs::Detail, Logs::Aggro, "Sending pet %s into battle due to attack.", pet->GetName()); diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 4271ec33f..8efe55f2b 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -5329,31 +5329,44 @@ void Client::Handle_OP_DisarmTraps(const EQApplicationPacket *app) p_timers.Start(pTimerDisarmTraps, reuse - 1); - Trap* trap = entity_list.FindNearbyTrap(this, 60); + uint8 success = SKILLUP_FAILURE; + float curdist = 0; + Trap* trap = entity_list.FindNearbyTrap(this, 250, curdist, true); if (trap && trap->detected) { - int uskill = GetSkill(EQEmu::skills::SkillDisarmTraps); - if ((zone->random.Int(0, 49) + uskill) >= (zone->random.Int(0, 49) + trap->skill)) + float max_radius = (trap->radius * 2) * (trap->radius * 2); // radius is used to trigger trap, so disarm radius should be a bit bigger. + Log(Logs::General, Logs::Traps, "%s is attempting to disarm trap %d. Curdist is %0.2f maxdist is %0.2f", GetName(), trap->trap_id, curdist, max_radius); + if (curdist <= max_radius) { - Message(MT_Skills, "You disarm a trap."); - trap->disarmed = true; - Log(Logs::General, Logs::Traps, "Trap %d is disarmed.", trap->trap_id); - trap->UpdateTrap(); + int uskill = GetSkill(EQEmu::skills::SkillDisarmTraps); + if ((zone->random.Int(0, 49) + uskill) >= (zone->random.Int(0, 49) + trap->skill)) + { + success = SKILLUP_SUCCESS; + Message_StringID(MT_Skills, DISARMED_TRAP); + trap->disarmed = true; + Log(Logs::General, Logs::Traps, "Trap %d is disarmed.", trap->trap_id); + trap->UpdateTrap(); + } + else + { + Message_StringID(MT_Skills, FAIL_DISARM_DETECTED_TRAP); + if (zone->random.Int(0, 99) < 25) { + trap->Trigger(this); + } + } + CheckIncreaseSkill(EQEmu::skills::SkillDisarmTraps, nullptr); + return; } else { - if (zone->random.Int(0, 99) < 25) { - Message(MT_Skills, "You set off the trap while trying to disarm it!"); - trap->Trigger(this); - } - else { - Message(MT_Skills, "You failed to disarm a trap."); - } + Message_StringID(MT_Skills, TRAP_TOO_FAR); } - CheckIncreaseSkill(EQEmu::skills::SkillDisarmTraps, nullptr); - return; } - Message(MT_Skills, "You did not find any traps close enough to disarm."); + else + { + Message_StringID(MT_Skills, LDON_SENSE_TRAP2); + } + return; } @@ -12107,7 +12120,8 @@ void Client::Handle_OP_SenseTraps(const EQApplicationPacket *app) p_timers.Start(pTimerSenseTraps, reuse - 1); - Trap* trap = entity_list.FindNearbyTrap(this, 800); + float trap_curdist = 0; + Trap* trap = entity_list.FindNearbyTrap(this, 800, trap_curdist); CheckIncreaseSkill(EQEmu::skills::SkillSenseTraps, nullptr); diff --git a/zone/common.h b/zone/common.h index bcc9ff305..f7b157115 100644 --- a/zone/common.h +++ b/zone/common.h @@ -604,6 +604,11 @@ enum { //type arguments to DoAnim }; +enum { + SKILLUP_UNKNOWN = 0, + SKILLUP_SUCCESS = 1, + SKILLUP_FAILURE = 2 +}; typedef enum { petFamiliar, //only listens to /pet get lost diff --git a/zone/entity.h b/zone/entity.h index 996580aa6..dccbb45b3 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -365,7 +365,7 @@ public: //trap stuff Mob* GetTrapTrigger(Trap* trap); void SendAlarm(Trap* trap, Mob* currenttarget, uint8 kos); - Trap* FindNearbyTrap(Mob* searcher, float max_dist); + Trap* FindNearbyTrap(Mob* searcher, float max_dist, float &curdist, bool detected = false); void AddHealAggro(Mob* target, Mob* caster, uint16 hate); Mob* FindDefenseNPC(uint32 npcid); diff --git a/zone/string_ids.h b/zone/string_ids.h index c8175c8b6..997858bed 100644 --- a/zone/string_ids.h +++ b/zone/string_ids.h @@ -19,6 +19,7 @@ #define PROC_TOOLOW 126 //Your will is not sufficient to command this weapon. #define PROC_PETTOOLOW 127 //Your pet's will is not sufficient to command its weapon. #define YOU_FLURRY 128 //You unleash a flurry of attacks. +#define FAILED_DISARM_TRAP 129 //You failed to disarm the trap. #define DOORS_LOCKED 130 //It's locked and you're not holding the key. #define DOORS_CANT_PICK 131 //This lock cannot be picked. #define DOORS_INSUFFICIENT_SKILL 132 //You are not sufficiently skilled to pick this lock. @@ -98,6 +99,7 @@ #define DUP_LORE 290 //Duplicate lore items are not allowed. #define TGB_ON 293 //Target other group buff is *ON*. #define TGB_OFF 294 //Target other group buff is *OFF*. +#define DISARMED_TRAP 305 //You have disarmed the trap. #define LDON_SENSE_TRAP1 306 //You do not Sense any traps. #define TRADESKILL_NOCOMBINE 334 //You cannot combine these items in this container type! #define TRADESKILL_FAILED 336 //You lacked the skills to fashion the items together. @@ -114,6 +116,8 @@ #define MEND_WORSEN 351 //You have worsened your wounds! #define MEND_FAIL 352 //You have failed to mend your wounds. #define LDON_SENSE_TRAP2 367 //You have not detected any traps. +#define TRAP_TOO_FAR 368 //You are too far away from that trap to affect it. +#define FAIL_DISARM_DETECTED_TRAP 370 //You fail to disarm the detected trap. #define LOOT_LORE_ERROR 371 //You cannot loot this Lore Item. You already have one. #define PICK_LORE 379 //You cannot pick up a lore item you already possess. #define CONSENT_DENIED 390 //You do not have consent to summon that corpse. @@ -421,6 +425,7 @@ #define SENSE_ANIMAL 12472 //You sense an animal in this direction. #define SENSE_SUMMONED 12473 //You sense a summoned being in this direction. #define SENSE_NOTHING 12474 //You don't sense anything. +#define SENSE_TRAP 12475 //You sense a trap in this direction. #define LDON_SENSE_TRAP3 12476 //You don't sense any traps. #define INTERRUPT_SPELL_OTHER 12478 //%1's casting is interrupted! #define YOU_HIT_NONMELEE 12481 //You were hit by non-melee for %1 damage. diff --git a/zone/trap.cpp b/zone/trap.cpp index f563048f8..d5bcfbeb8 100644 --- a/zone/trap.cpp +++ b/zone/trap.cpp @@ -79,6 +79,7 @@ Trap::Trap() : group = 0; despawn_when_triggered = false; charid = 0; + undetectable = false; } Trap::~Trap() @@ -253,7 +254,7 @@ void Trap::Trigger(Mob* trigger) } } -Trap* EntityList::FindNearbyTrap(Mob* searcher, float max_dist) +Trap* EntityList::FindNearbyTrap(Mob* searcher, float max_dist, float &trap_curdist, bool detected) { float dist = 999999; Trap* current_trap = nullptr; @@ -263,19 +264,29 @@ Trap* EntityList::FindNearbyTrap(Mob* searcher, float max_dist) for (auto it = trap_list.begin(); it != trap_list.end(); ++it) { cur = it->second; - if(cur->disarmed) + if(cur->disarmed || (detected && !cur->detected) || cur->undetectable) continue; auto diff = glm::vec3(searcher->GetPosition()) - cur->m_Position; - float curdist = diff.x * diff.x + diff.y * diff.y + diff.z * diff.z; + float curdist = diff.x*diff.x + diff.y*diff.y; + diff.z = std::abs(diff.z); - if (curdist < max_dist2 && curdist < dist) + if (curdist < max_dist2 && curdist < dist && diff.z <= cur->maxzdiff) { + Log(Logs::General, Logs::Traps, "Trap %d is curdist %0.1f", cur->db_id, curdist); dist = curdist; current_trap = cur; } } + if (current_trap != nullptr) + { + Log(Logs::General, Logs::Traps, "Trap %d is the closest trap.", current_trap->db_id); + trap_curdist = dist; + } + else + trap_curdist = INVALID_INDEX; + return current_trap; } @@ -386,7 +397,7 @@ bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) { std::string query = StringFormat("SELECT id, x, y, z, effect, effectvalue, effectvalue2, skill, " "maxzdiff, radius, chance, message, respawn_time, respawn_var, level, " - "`group`, triggered_number, despawn_when_triggered FROM traps WHERE zone='%s' AND version=%u", zonename, version); + "`group`, triggered_number, despawn_when_triggered, undetectable FROM traps WHERE zone='%s' AND version=%u", zonename, version); auto results = QueryDatabase(query); if (!results.Success()) { @@ -422,7 +433,8 @@ bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) { trap->level = atoi(row[14]); trap->group = grp; trap->triggered_number = atoi(row[16]); - trap->despawn_when_triggered = atoi(row[17]); + trap->despawn_when_triggered = atobool(row[17]); + trap->undetectable = atobool(row[18]); entity_list.AddTrap(trap); trap->CreateHiddenTrigger(); Log(Logs::General, Logs::Traps, "Trap %d successfully loaded.", trap->trap_id); @@ -469,14 +481,14 @@ bool ZoneDatabase::SetTrapData(Trap* trap, bool repopnow) { { query = StringFormat("SELECT id, x, y, z, effect, effectvalue, effectvalue2, skill, " "maxzdiff, radius, chance, message, respawn_time, respawn_var, level, " - "triggered_number, despawn_when_triggered FROM traps WHERE zone='%s' AND `group`=%d AND id != %d ORDER BY RAND() LIMIT 1", zone->GetShortName(), trap->group, dbid); + "triggered_number, despawn_when_triggered, undetectable FROM traps WHERE zone='%s' AND `group`=%d AND id != %d ORDER BY RAND() LIMIT 1", zone->GetShortName(), trap->group, dbid); } else { // We could just use the existing data here, but querying the DB is not expensive, and allows content developers to change traps without rebooting. query = StringFormat("SELECT id, x, y, z, effect, effectvalue, effectvalue2, skill, " "maxzdiff, radius, chance, message, respawn_time, respawn_var, level, " - "triggered_number, despawn_when_triggered FROM traps WHERE zone='%s' AND id = %d", zone->GetShortName(), dbid); + "triggered_number, despawn_when_triggered, undetectable FROM traps WHERE zone='%s' AND id = %d", zone->GetShortName(), dbid); } auto results = QueryDatabase(query); @@ -500,7 +512,8 @@ bool ZoneDatabase::SetTrapData(Trap* trap, bool repopnow) { trap->respawn_var = atoi(row[13]); trap->level = atoi(row[14]); trap->triggered_number = atoi(row[15]); - trap->despawn_when_triggered = atoi(row[16]); + trap->despawn_when_triggered = atobool(row[16]); + trap->undetectable = atobool(row[17]); trap->CreateHiddenTrigger(); if (repopnow) diff --git a/zone/trap.h b/zone/trap.h index 4c0d53106..e20e2314f 100644 --- a/zone/trap.h +++ b/zone/trap.h @@ -50,7 +50,6 @@ public: void SetHiddenTrigger(NPC* n) { hiddenTrigger = n; } void CreateHiddenTrigger(); void DestroyHiddenTrigger() { hiddenTrigger = nullptr; } - void SetTrapData(); void UpdateTrap(bool respawn = true, bool repopnow = false); //Trap data, leave this unprotected Timer respawn_timer; //Respawn Time when Trap's been disarmed @@ -76,6 +75,7 @@ public: uint8 group; bool despawn_when_triggered; uint32 charid; //ID of character that triggered trap. This is cleared when the trap despawns are resets. + bool undetectable; std::string message; protected: From 15f7440af24d0d52e381b707d5ad8b163ed0b56e Mon Sep 17 00:00:00 2001 From: regneq Date: Sat, 28 Oct 2017 10:48:22 -0700 Subject: [PATCH 58/97] Update version and manifest for traps.sql --- common/version.h | 2 +- utils/sql/db_update_manifest.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/common/version.h b/common/version.h index 52af87872..108ce784b 100644 --- a/common/version.h +++ b/common/version.h @@ -30,7 +30,7 @@ Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt */ -#define CURRENT_BINARY_DATABASE_VERSION 9114 +#define CURRENT_BINARY_DATABASE_VERSION 9115 #ifdef BOTS #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9017 #else diff --git a/utils/sql/db_update_manifest.txt b/utils/sql/db_update_manifest.txt index e385b9f9e..c9b6a7b78 100644 --- a/utils/sql/db_update_manifest.txt +++ b/utils/sql/db_update_manifest.txt @@ -368,6 +368,7 @@ 9112|2017_06_24_rule_values_expand.sql|SHOW COLUMNS FROM rule_values WHERE Field = 'rule_value' and Type = 'varchar(30)'|empty| 9113|2017_07_19_show_name.sql|SHOW COLUMNS FROM `npc_types` LIKE 'show_name'|empty| 9114|2017_07_22_aura.sql|SHOW TABLES LIKE 'auras'|empty| +9115|2017_10_28_traps.sql|SHOW COLUMNS FROM `traps` LIKE 'triggered_number'|empty| # Upgrade conditions: # This won't be needed after this system is implemented, but it is used database that are not From ceadb1325d1acfbb38640643c536be788a809bb8 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Sat, 28 Oct 2017 15:22:58 -0400 Subject: [PATCH 59/97] Added a #petname command for renaming only pets --- zone/command.cpp | 21 +++++++++++++++++++++ zone/command.h | 1 + 2 files changed, 22 insertions(+) diff --git a/zone/command.cpp b/zone/command.cpp index 15b09b9dc..d275c82fc 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -375,6 +375,7 @@ int command_init(void) command_add("task", "(subcommand) - Task system commands", 150, command_task) || command_add("tattoo", "- Change the tattoo of your target (Drakkin Only)", 80, command_tattoo) || command_add("tempname", "[newname] - Temporarily renames your target. Leave name blank to restore the original name.", 100, command_tempname) || + command_add("petname", "[newname] - Temporarily renames your pet. Leave name blank to restore the original name.", 100, command_petname) || command_add("texture", "[texture] [helmtexture] - Change your or your target's appearance, use 255 to show equipment", 10, command_texture) || command_add("time", "[HH] [MM] - Set EQ time", 90, command_time) || command_add("timers", "- Display persistent timers for target", 200, command_timers) || @@ -4157,6 +4158,26 @@ void command_tempname(Client *c, const Seperator *sep) } } +void command_petname(Client *c, const Seperator *sep) +{ + Mob *target; + target = c->GetTarget(); + + if(!target) + c->Message(0, "Usage: #petname newname (requires a target)"); + else if(target->IsPet() && (target->GetOwnerID() == c->GetID()) && strlen(sep->arg[1]) > 0) + { + char *oldname = strdup(target->GetName()); + target->TempName(sep->arg[1]); + c->Message(0, "Renamed %s to %s", oldname, sep->arg[1]); + free(oldname); + } + else { + target->TempName(); + c->Message(0, "Restored the original name"); + } +} + void command_npcspecialattk(Client *c, const Seperator *sep) { if (c->GetTarget()==0 || c->GetTarget()->IsClient() || strlen(sep->arg[1]) <= 0 || strlen(sep->arg[2]) <= 0) diff --git a/zone/command.h b/zone/command.h index 0a850fbca..084286e4a 100644 --- a/zone/command.h +++ b/zone/command.h @@ -286,6 +286,7 @@ void command_synctod(Client *c, const Seperator *sep); void command_task(Client *c, const Seperator *sep); void command_tattoo(Client *c, const Seperator *sep); void command_tempname(Client *c, const Seperator *sep); +void command_petname(Client *c, const Seperator *sep); void command_testspawn(Client *c, const Seperator *sep); void command_testspawnkill(Client *c, const Seperator *sep); void command_texture(Client *c, const Seperator *sep); From 7d1238233347e2a0ea955053e6ab41fa442fcbdc Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 4 Nov 2017 00:32:30 -0400 Subject: [PATCH 60/97] Fix NPC/Pet haste caps --- zone/mob.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index d08804410..782cb4d92 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3397,13 +3397,18 @@ int Mob::GetHaste() else // 1-25 h += itembonuses.haste > 10 ? 10 : itembonuses.haste; - // 60+ 100, 51-59 85, 1-50 level+25 - if (level > 59) // 60+ - cap = RuleI(Character, HasteCap); - else if (level > 50) // 51-59 - cap = 85; - else // 1-50 - cap = level + 25; + // mobs are different! + Mob *owner = nullptr; + if (IsPet()) + owner = GetOwner(); + else if (IsNPC() && CastToNPC()->GetSwarmTarget()) + owner = entity_list.GetMobID(CastToNPC()->GetSwarmOwner()); + if (owner) { + cap = 110; + cap += std::max(0, owner->GetLevel() - 39) + std::max(0, owner->GetLevel() - 60); + } else { + cap = 250; + } if(h > cap) h = cap; From 24e4730204b6f29f6c7fd9cef400519c15b78839 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 4 Nov 2017 00:39:54 -0400 Subject: [PATCH 61/97] Whoops, we do haste differently --- zone/mob.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 782cb4d92..31baf7ae6 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3404,10 +3404,10 @@ int Mob::GetHaste() else if (IsNPC() && CastToNPC()->GetSwarmTarget()) owner = entity_list.GetMobID(CastToNPC()->GetSwarmOwner()); if (owner) { - cap = 110; + cap = 10; cap += std::max(0, owner->GetLevel() - 39) + std::max(0, owner->GetLevel() - 60); } else { - cap = 250; + cap = 150; } if(h > cap) From df0004c1b09194b7cb9e1d4e26d2de0cdec236e9 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 4 Nov 2017 01:08:55 -0400 Subject: [PATCH 62/97] Another fix for GetHaste for pets --- zone/mob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 31baf7ae6..67a6ffa14 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3404,7 +3404,7 @@ int Mob::GetHaste() else if (IsNPC() && CastToNPC()->GetSwarmTarget()) owner = entity_list.GetMobID(CastToNPC()->GetSwarmOwner()); if (owner) { - cap = 10; + cap = 10 + level; cap += std::max(0, owner->GetLevel() - 39) + std::max(0, owner->GetLevel() - 60); } else { cap = 150; From 37bedfe9bab8cbb27cf392945b799dfd8432774a Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 4 Nov 2017 01:27:41 -0400 Subject: [PATCH 63/97] Move PetHoTT to NPC::SetTarget for charmed pets --- zone/npc.cpp | 20 ++++++++++++++++++++ zone/pets.cpp | 16 ---------------- zone/pets.h | 1 - 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/zone/npc.cpp b/zone/npc.cpp index a4e6c4214..c13841358 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -436,6 +436,26 @@ void NPC::SetTarget(Mob* mob) { //attack_timer.Disable(); attack_dw_timer.Disable(); } + + // either normal pet and owner is client or charmed pet and owner is client + Mob *owner = nullptr; + if (IsPet() && IsPetOwnerClient()) { + owner = GetOwner(); + } else if (IsCharmed()) { + owner = GetOwner(); + if (owner && !owner->IsClient()) + owner = nullptr; + } + + if (owner) { + auto client = owner->CastToClient(); + if (client->ClientVersionBit() & EQEmu::versions::bit_UFAndLater) { + auto app = new EQApplicationPacket(OP_PetHoTT, sizeof(ClientTarget_Struct)); + auto ct = (ClientTarget_Struct *)app->pBuffer; + ct->new_target = mob ? mob->GetID() : 0; + client->FastQueuePacket(&app); + } + } Mob::SetTarget(mob); } diff --git a/zone/pets.cpp b/zone/pets.cpp index 0c150f743..ef895410b 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -475,22 +475,6 @@ Pet::Pet(NPCType *type_data, Mob *owner, PetType type, uint16 spell_id, int16 po // Class should use npc constructor to set light properties } -void Pet::SetTarget(Mob *mob) -{ - if (mob == GetTarget()) - return; - - auto owner = GetOwner(); - if (owner && owner->IsClient() && owner->CastToClient()->ClientVersionBit() & EQEmu::versions::bit_UFAndLater) { - auto app = new EQApplicationPacket(OP_PetHoTT, sizeof(ClientTarget_Struct)); - auto ct = (ClientTarget_Struct *)app->pBuffer; - ct->new_target = mob ? mob->GetID() : 0; - owner->CastToClient()->QueuePacket(app); - safe_delete(app); - } - NPC::SetTarget(mob); -} - bool ZoneDatabase::GetPetEntry(const char *pet_type, PetRecord *into) { return GetPoweredPetEntry(pet_type, 0, into); } diff --git a/zone/pets.h b/zone/pets.h index edb6dbe95..1b9811149 100644 --- a/zone/pets.h +++ b/zone/pets.h @@ -7,7 +7,6 @@ struct NPCType; class Pet : public NPC { public: Pet(NPCType *type_data, Mob *owner, PetType type, uint16 spell_id, int16 power); - virtual void SetTarget(Mob *mob); virtual bool CheckSpellLevelRestriction(uint16 spell_id); }; From 3eaa0b4fb18c42752acd14b7082d63a083bcefe1 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Thu, 9 Nov 2017 13:31:04 -0500 Subject: [PATCH 64/97] Don't need to garble for language, client does Maybe older clients need it? --- zone/client.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index 893a6b51b..319752e36 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -1223,11 +1223,6 @@ void Client::ChannelMessageSend(const char* from, const char* to, uint8 chan_num EffSkill = 100; cm->skill_in_language = EffSkill; - // Garble the message based on listener skill - if (ListenerSkill < 100) { - GarbleMessage(buffer, (100 - ListenerSkill)); - } - cm->chan_num = chan_num; strcpy(&cm->message[0], buffer); QueuePacket(&app); From e928046a959d78d9aa5a284e1c9e40c0bb3cf371 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Fri, 10 Nov 2017 00:04:33 -0500 Subject: [PATCH 65/97] Add guild tribute slot for legacy stuff --- common/emu_legacy.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/emu_legacy.h b/common/emu_legacy.h index a624be883..0f3cf0a62 100644 --- a/common/emu_legacy.h +++ b/common/emu_legacy.h @@ -78,6 +78,8 @@ namespace EQEmu SLOT_CURSOR_BAG_END = 340, SLOT_TRIBUTE_BEGIN = 400, SLOT_TRIBUTE_END = 404, + SLOT_GUILD_TRIBUTE_BEGIN = 450, + SLOT_GUILD_TRIBUTE_END = 451, SLOT_BANK_BEGIN = 2000, SLOT_BANK_END = 2023, SLOT_BANK_BAGS_BEGIN = 2031, From da163be8dbe56a3d4ba95ed2c08143542dea6433 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Fri, 10 Nov 2017 00:06:50 -0500 Subject: [PATCH 66/97] Fix auto complete error --- zone/mob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 67a6ffa14..66e221b0b 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3401,7 +3401,7 @@ int Mob::GetHaste() Mob *owner = nullptr; if (IsPet()) owner = GetOwner(); - else if (IsNPC() && CastToNPC()->GetSwarmTarget()) + else if (IsNPC() && CastToNPC()->GetSwarmOwner()) owner = entity_list.GetMobID(CastToNPC()->GetSwarmOwner()); if (owner) { cap = 10 + level; From 5880593cb1242f4be858dba13de6aac4670f6011 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Fri, 17 Nov 2017 13:12:26 -0500 Subject: [PATCH 67/97] MoveTo while saving guard position no longer hops. --- zone/mob.cpp | 15 ++++++-- zone/mob.h | 6 ++-- zone/mob_ai.cpp | 18 ++++++---- zone/waypoints.cpp | 86 ++++++++++++++++++++++++++++------------------ 4 files changed, 79 insertions(+), 46 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index efb2922f0..28ee296ee 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -123,8 +123,6 @@ Mob::Mob(const char* in_name, tar_vector=0; currently_fleeing = false; - last_z = 0; - last_major_update_position = m_Position; AI_Init(); @@ -3439,6 +3437,19 @@ void Mob::SetTarget(Mob* mob) { this->GetTarget()->SendHPUpdate(false, true); } +// For when we want a Ground Z at a location we are not at yet +// Like MoveTo. +float Mob::FindDestGroundZ(glm::vec3 dest, float z_offset) +{ + float best_z = BEST_Z_INVALID; + if (zone->zonemap != nullptr) + { + dest.z += z_offset; + best_z = zone->zonemap->FindBestZ(dest, nullptr); + } + return best_z; +} + float Mob::FindGroundZ(float new_x, float new_y, float z_offset) { float ret = BEST_Z_INVALID; diff --git a/zone/mob.h b/zone/mob.h index 058774c54..812f54ca1 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -954,7 +954,8 @@ public: void SendTo(float new_x, float new_y, float new_z); void SendToFixZ(float new_x, float new_y, float new_z); float GetZOffset() const; - void FixZ(int32 z_find_offset = 5); + void FixZ(int32 z_find_offset = 5); + float GetFixedZ(glm::vec3 position, int32 z_find_offset = 5); void NPCSpecialAttacks(const char* parse, int permtag, bool reset = true, bool remove = false); inline uint32 DontHealMeBefore() const { return pDontHealMeBefore; } inline uint32 DontBuffMeBefore() const { return pDontBuffMeBefore; } @@ -1108,8 +1109,6 @@ public: int GetWeaponDamage(Mob *against, const EQEmu::ItemData *weapon_item); int GetWeaponDamage(Mob *against, const EQEmu::ItemInstance *weapon_item, uint32 *hate = nullptr); - float last_z; - // Bots HealRotation methods #ifdef BOTS bool IsHealRotationTarget() { return (m_target_of_heal_rotation.use_count() && m_target_of_heal_rotation.get()); } @@ -1267,6 +1266,7 @@ protected: virtual int16 GetFocusEffect(focusType type, uint16 spell_id) { return 0; } void CalculateNewFearpoint(); float FindGroundZ(float new_x, float new_y, float z_offset=0.0); + float FindDestGroundZ(glm::vec3 dest, float z_offset=0.0); glm::vec3 UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &WaypointChange, bool &NodeReached); void PrintRoute(); diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 72c81d374..eb045488d 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -503,7 +503,7 @@ void NPC::AI_Start(uint32 iMoveDelay) { AIautocastspell_timer->Disable(); } else { AIautocastspell_timer = std::unique_ptr(new Timer(750)); - AIautocastspell_timer->Start(RandomTimer(0, 15000), false); + AIautocastspell_timer->Start(RandomTimer(0, 300), false); } if (NPCTypedata) { @@ -1582,18 +1582,22 @@ void NPC::AI_DoMovement() { } this->FixZ(); - SendPosition(); //kick off event_waypoint arrive char temp[16]; sprintf(temp, "%d", cur_wp); parse->EventNPC(EVENT_WAYPOINT_ARRIVE, CastToNPC(), nullptr, temp, 0); - // start moving directly to next waypoint if we're at a 0 pause waypoint and we didn't get quest halted. - if (!AI_walking_timer->Enabled()) + // No need to move as we are there. Next loop will + // take care of normal grids, even at pause 0. + // We do need to call and setup a wp if we're cur_wp=-2 + // as that is where roamer is unset and we don't want + // the next trip through to move again based on grid stuff. + doMove = false; + if (cur_wp == -2) { AI_SetupNextWaypoint(); - else - doMove = false; + } + // wipe feign memory since we reached our first waypoint if(cur_wp == 1) ClearFeignMemory(); @@ -2593,7 +2597,7 @@ void NPC::AddSpellToNPCList(int16 iPriority, int16 iSpellID, uint32 iType, // If we're going from an empty list, we need to start the timer if (AIspells.size() == 1) - AIautocastspell_timer->Start(RandomTimer(0, 15000), false); + AIautocastspell_timer->Start(RandomTimer(0, 300), false); } void NPC::RemoveSpellFromNPCList(int16 spell_id) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index ca0d24175..967325fd8 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -176,9 +176,15 @@ void NPC::MoveTo(const glm::vec4& position, bool saveguardspot) cur_wp = -2; // flag as quest controlled w/no grid Log(Logs::Detail, Logs::AI, "MoveTo %s without a grid.", to_string(static_cast(position)).c_str()); } + + glm::vec3 dest(position); + + m_CurrentWayPoint = position; + m_CurrentWayPoint.z = GetFixedZ(dest); + if (saveguardspot) { - m_GuardPoint = position; + m_GuardPoint = m_CurrentWayPoint; if (m_GuardPoint.w == 0) m_GuardPoint.w = 0.0001; //hack to make IsGuarding simpler @@ -189,7 +195,6 @@ void NPC::MoveTo(const glm::vec4& position, bool saveguardspot) Log(Logs::Detail, Logs::AI, "Setting guard position to %s", to_string(static_cast(m_GuardPoint)).c_str()); } - m_CurrentWayPoint = position; cur_wp_pause = 0; pLastFightingDelayMoving = 0; if (AI_walking_timer->Enabled()) @@ -838,49 +843,62 @@ void Mob::SendToFixZ(float new_x, float new_y, float new_z) { } } -void Mob::FixZ(int32 z_find_offset /*= 5*/) +float Mob::GetFixedZ(glm::vec3 dest, int32 z_find_offset) { - BenchTimer timer; timer.reset(); + float new_z = dest.z; - if (zone->HasMap() && RuleB(Map, FixZWhenMoving) && (flymode != 1 && flymode != 2)) + if (zone->HasMap() && RuleB(Map, FixZWhenMoving) && + (flymode != 1 && flymode != 2)) { - if (!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) + if (!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() + || (zone->HasWaterMap() && + !zone->watermap->InWater(glm::vec3(m_Position)))) { /* Any more than 5 in the offset makes NPC's hop/snap to ceiling in small corridors */ - float new_z = this->FindGroundZ(m_Position.x, m_Position.y, z_find_offset); - new_z += this->GetZOffset(); + new_z = this->FindDestGroundZ(dest,z_find_offset); + if (new_z != BEST_Z_INVALID) + { + new_z += this->GetZOffset(); - auto duration = timer.elapsed(); - - Log( - Logs::Moderate, - Logs::FixZ, - "Mob::FixZ() (%s) returned %4.3f at %4.3f, %4.3f, %4.3f - Took %lf", - this->GetCleanName(), - new_z, - m_Position.x, - m_Position.y, - m_Position.z, - duration - ); - - if ((new_z > -2000) && new_z != BEST_Z_INVALID) { - if (RuleB(Map, MobZVisualDebug)) - this->SendAppearanceEffect(78, 0, 0, 0, 0); - - m_Position.z = new_z; + // If bad new Z restore old one + if (new_z < -2000) { + new_z = m_Position.z; + } } - else { - if (RuleB(Map, MobZVisualDebug)) - this->SendAppearanceEffect(103, 0, 0, 0, 0); + } - Log(Logs::General, Logs::FixZ, "%s is failing to find Z %f", this->GetCleanName(), std::abs(m_Position.z - new_z)); - } + auto duration = timer.elapsed(); - last_z = m_Position.z; + Log(Logs::Moderate, Logs::FixZ, + "Mob::FixZ() (%s) returned %4.3f at %4.3f, %4.3f, %4.3f - Took %lf", + this->GetCleanName(), new_z, m_Position.x, m_Position.y, + m_Position.z, duration); + } + + return new_z; +} + +void Mob::FixZ(int32 z_find_offset /*= 5*/) +{ + glm::vec3 current_loc(m_Position); + float new_z=GetFixedZ(current_loc, z_find_offset); + + if (new_z != m_Position.z) + { + if ((new_z > -2000) && new_z != BEST_Z_INVALID) { + if (RuleB(Map, MobZVisualDebug)) + this->SendAppearanceEffect(78, 0, 0, 0, 0); + + m_Position.z = new_z; + } + else { + if (RuleB(Map, MobZVisualDebug)) + this->SendAppearanceEffect(103, 0, 0, 0, 0); + + Log(Logs::General, Logs::FixZ, "%s is failing to find Z %f", + this->GetCleanName(), std::abs(m_Position.z - new_z)); } } } From a8427ca6107a921779eeb78f6ed730c0762b4caf Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Fri, 17 Nov 2017 14:09:19 -0500 Subject: [PATCH 68/97] Fixed Log message to have correct text and values --- zone/waypoints.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 967325fd8..d761c6a70 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -872,9 +872,8 @@ float Mob::GetFixedZ(glm::vec3 dest, int32 z_find_offset) auto duration = timer.elapsed(); Log(Logs::Moderate, Logs::FixZ, - "Mob::FixZ() (%s) returned %4.3f at %4.3f, %4.3f, %4.3f - Took %lf", - this->GetCleanName(), new_z, m_Position.x, m_Position.y, - m_Position.z, duration); + "Mob::GetFixedZ() (%s) returned %4.3f at %4.3f, %4.3f, %4.3f - Took %lf", + this->GetCleanName(), new_z, dest.x, dest.y, dest.z, duration); } return new_z; From 52d31a68467decee078bbe30b2517d501dc16166 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 19 Nov 2017 01:45:05 -0500 Subject: [PATCH 69/97] Make high STR race rez effects a rule They stopped using this one at some point it seems --- common/ruletypes.h | 1 + zone/client_process.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/common/ruletypes.h b/common/ruletypes.h index c3a8fd5dc..ed5ae8e23 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -44,6 +44,7 @@ RULE_INT(Character, DeathExpLossMaxLevel, 255) // Any level greater than this wi RULE_INT(Character, DeathItemLossLevel, 10) RULE_INT(Character, DeathExpLossMultiplier, 3) //Adjust how much exp is lost RULE_BOOL(Character, UseDeathExpLossMult, false) //Adjust to use the above multiplier or to use code default. +RULE_BOOL(Character, UseOldRaceRezEffects, false) // older clients had ID 757 for races with high starting STR, but it doesn't seem used anymore RULE_INT(Character, CorpseDecayTimeMS, 10800000) RULE_INT(Character, CorpseResTimeMS, 10800000) // time before cant res corpse(3 hours) RULE_BOOL(Character, LeaveCorpses, true) diff --git a/zone/client_process.cpp b/zone/client_process.cpp index a0bdeead2..ab694659b 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -1055,7 +1055,8 @@ void Client::OPRezzAnswer(uint32 Action, uint32 SpellID, uint16 ZoneID, uint16 I SetMana(0); SetHP(GetMaxHP()/5); int rez_eff = 756; - if (GetRace() == BARBARIAN || GetRace() == DWARF || GetRace() == TROLL || GetRace() == OGRE) + if (RuleB(Character, UseOldRaceRezEffects) && + (GetRace() == BARBARIAN || GetRace() == DWARF || GetRace() == TROLL || GetRace() == OGRE)) rez_eff = 757; SpellOnTarget(rez_eff, this); // Rezz effects } From b03e9af597e694a437b036fe9d80e7d76179484a Mon Sep 17 00:00:00 2001 From: Akkadius Date: Tue, 21 Nov 2017 21:25:20 -0600 Subject: [PATCH 70/97] Fix issues with NPC's ghosting who path for long distances, this should wrap up the small remainder of ghosting edge cases --- zone/client_process.cpp | 13 +++- zone/mob.cpp | 142 ++++++++++++++++++++-------------------- zone/mob.h | 7 +- 3 files changed, 88 insertions(+), 74 deletions(-) diff --git a/zone/client_process.cpp b/zone/client_process.cpp index ab694659b..355dd2c1f 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -269,8 +269,17 @@ bool Client::Process() { } } - if (force_spawn_updates && mob != this && distance <= client_update_range) - mob->SendPositionUpdateToClient(this); + if (force_spawn_updates && mob != this) { + + if (mob->is_distance_roamer) { + Log(Logs::General, Logs::Debug, "Updating distance roamer %s", mob->GetCleanName()); + mob->SendPositionUpdateToClient(this); + continue; + } + + if (distance <= client_update_range) + mob->SendPositionUpdateToClient(this); + } } } diff --git a/zone/mob.cpp b/zone/mob.cpp index 66e221b0b..af0bd97c8 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -75,7 +75,6 @@ Mob::Mob(const char* in_name, uint32 in_drakkin_tattoo, uint32 in_drakkin_details, EQEmu::TintProfile in_armor_tint, - uint8 in_aa_title, uint8 in_see_invis, // see through invis/ivu uint8 in_see_invis_undead, @@ -91,24 +90,24 @@ Mob::Mob(const char* in_name, uint8 in_handtexture, uint8 in_legtexture, uint8 in_feettexture - ) : + ) : attack_timer(2000), attack_dw_timer(2000), ranged_timer(2000), tic_timer(6000), mana_timer(2000), spellend_timer(0), - rewind_timer(30000), //Timer used for determining amount of time between actual player position updates for /rewind. + rewind_timer(30000), bindwound_timer(10000), stunned_timer(0), spun_timer(0), bardsong_timer(6000), gravity_timer(1000), viral_timer(0), - m_FearWalkTarget(-999999.0f,-999999.0f,-999999.0f), + m_FearWalkTarget(-999999.0f, -999999.0f, -999999.0f), m_TargetLocation(glm::vec3()), m_TargetV(glm::vec3()), - flee_timer(FLEE_CHECK_TIMER), + flee_timer(FLEE_CHECK_TIMER), m_Position(position), tmHidden(-1), mitigation_ac(0), @@ -119,47 +118,48 @@ Mob::Mob(const char* in_name, position_update_melee_push_timer(1000) { targeted = 0; - tar_ndx=0; - tar_vector=0; + tar_ndx = 0; + tar_vector = 0; currently_fleeing = false; last_z = 0; last_major_update_position = m_Position; + is_distance_roamer = false; AI_Init(); SetMoving(false); - moved=false; + moved = false; m_RewindLocation = glm::vec3(); _egnode = nullptr; - name[0]=0; - orig_name[0]=0; - clean_name[0]=0; - lastname[0]=0; - if(in_name) { - strn0cpy(name,in_name,64); - strn0cpy(orig_name,in_name,64); + name[0] = 0; + orig_name[0] = 0; + clean_name[0] = 0; + lastname[0] = 0; + if (in_name) { + strn0cpy(name, in_name, 64); + strn0cpy(orig_name, in_name, 64); } - if(in_lastname) - strn0cpy(lastname,in_lastname,64); - cur_hp = in_cur_hp; - max_hp = in_max_hp; - base_hp = in_max_hp; - gender = in_gender; - race = in_race; - base_gender = in_gender; - base_race = in_race; - class_ = in_class; - bodytype = in_bodytype; + if (in_lastname) + strn0cpy(lastname, in_lastname, 64); + cur_hp = in_cur_hp; + max_hp = in_max_hp; + base_hp = in_max_hp; + gender = in_gender; + race = in_race; + base_gender = in_gender; + base_race = in_race; + class_ = in_class; + bodytype = in_bodytype; orig_bodytype = in_bodytype; - deity = in_deity; - level = in_level; + deity = in_deity; + level = in_level; orig_level = in_level; - npctype_id = in_npctype_id; - size = in_size; - base_size = size; - runspeed = in_runspeed; + npctype_id = in_npctype_id; + size = in_size; + base_size = size; + runspeed = in_runspeed; // neotokyo: sanity check if (runspeed < 0 || runspeed > 20) runspeed = 1.25f; @@ -172,7 +172,8 @@ Mob::Mob(const char* in_name, fearspeed = 0.625f; base_fearspeed = 25; // npcs - } else { + } + else { base_walkspeed = base_runspeed * 100 / 265; walkspeed = ((float)base_walkspeed) * 0.025f; base_fearspeed = base_runspeed * 100 / 127; @@ -184,7 +185,7 @@ Mob::Mob(const char* in_name, current_speed = base_runspeed; - m_PlayerState = 0; + m_PlayerState = 0; // sanity check @@ -196,8 +197,8 @@ Mob::Mob(const char* in_name, m_Light.Type[EQEmu::lightsource::LightActive] = m_Light.Type[EQEmu::lightsource::LightInnate]; m_Light.Level[EQEmu::lightsource::LightActive] = m_Light.Level[EQEmu::lightsource::LightInnate]; - texture = in_texture; - helmtexture = in_helmtexture; + texture = in_texture; + helmtexture = in_helmtexture; armtexture = in_armtexture; bracertexture = in_bracertexture; handtexture = in_handtexture; @@ -205,21 +206,21 @@ Mob::Mob(const char* in_name, feettexture = in_feettexture; multitexture = (armtexture || bracertexture || handtexture || legtexture || feettexture); - haircolor = in_haircolor; - beardcolor = in_beardcolor; - eyecolor1 = in_eyecolor1; - eyecolor2 = in_eyecolor2; - hairstyle = in_hairstyle; - luclinface = in_luclinface; - beard = in_beard; - drakkin_heritage = in_drakkin_heritage; - drakkin_tattoo = in_drakkin_tattoo; - drakkin_details = in_drakkin_details; + haircolor = in_haircolor; + beardcolor = in_beardcolor; + eyecolor1 = in_eyecolor1; + eyecolor2 = in_eyecolor2; + hairstyle = in_hairstyle; + luclinface = in_luclinface; + beard = in_beard; + drakkin_heritage = in_drakkin_heritage; + drakkin_tattoo = in_drakkin_tattoo; + drakkin_details = in_drakkin_details; attack_speed = 0; attack_delay = 0; slow_mitigation = 0; - findable = false; - trackable = true; + findable = false; + trackable = true; has_shieldequiped = false; has_twohandbluntequiped = false; has_twohanderequipped = false; @@ -230,19 +231,19 @@ Mob::Mob(const char* in_name, SpellPowerDistanceMod = 0; last_los_check = false; - if(in_aa_title>0) - aa_title = in_aa_title; + if (in_aa_title > 0) + aa_title = in_aa_title; else - aa_title =0xFF; - AC = in_ac; - ATK = in_atk; - STR = in_str; - STA = in_sta; - DEX = in_dex; - AGI = in_agi; - INT = in_int; - WIS = in_wis; - CHA = in_cha; + aa_title = 0xFF; + AC = in_ac; + ATK = in_atk; + STR = in_str; + STA = in_sta; + DEX = in_dex; + AGI = in_agi; + INT = in_int; + WIS = in_wis; + CHA = in_cha; MR = CR = FR = DR = PR = Corrup = 0; ExtraHaste = 0; @@ -263,8 +264,8 @@ Mob::Mob(const char* in_name, hidden = false; improved_hidden = false; invulnerable = false; - IsFullHP = (cur_hp == max_hp); - qglobal=0; + IsFullHP = (cur_hp == max_hp); + qglobal = 0; spawned = false; InitializeBuffSlots(); @@ -305,7 +306,7 @@ Mob::Mob(const char* in_name, logging_enabled = false; isgrouped = false; israidgrouped = false; - + IsHorse = false; entity_id_being_looted = 0; @@ -376,13 +377,13 @@ Mob::Mob(const char* in_name, } destructibleobject = false; - wandertype=0; - pausetype=0; + wandertype = 0; + pausetype = 0; cur_wp = 0; m_CurrentWayPoint = glm::vec4(); cur_wp_pause = 0; - patrol=0; - follow=0; + patrol = 0; + follow = 0; follow_dist = 100; // Default Distance for Follow no_target_hotkey = false; flee_mode = false; @@ -396,7 +397,7 @@ Mob::Mob(const char* in_name, rooted = false; charmed = false; has_virus = false; - for (i=0; i= (100 * 100)) { entity_list.QueueClients(this, app, true, true); last_major_update_position = m_Position; + is_distance_roamer = true; } else { entity_list.QueueCloseClients(this, app, true, RuleI(Range, MobPositionUpdates), nullptr, false); diff --git a/zone/mob.h b/zone/mob.h index 058774c54..005021e40 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -162,6 +162,8 @@ public: inline virtual bool IsMob() const { return true; } inline virtual bool InZone() const { return true; } + bool is_distance_roamer; + //Somewhat sorted: needs documenting! //Attack @@ -954,7 +956,7 @@ public: void SendTo(float new_x, float new_y, float new_z); void SendToFixZ(float new_x, float new_y, float new_z); float GetZOffset() const; - void FixZ(int32 z_find_offset = 5); + void FixZ(int32 z_find_offset = 5); void NPCSpecialAttacks(const char* parse, int permtag, bool reset = true, bool remove = false); inline uint32 DontHealMeBefore() const { return pDontHealMeBefore; } inline uint32 DontBuffMeBefore() const { return pDontBuffMeBefore; } @@ -1225,7 +1227,8 @@ protected: uint32 npctype_id; glm::vec4 m_Position; /* Used to determine when an NPC has traversed so many units - to send a zone wide pos update */ - glm::vec4 last_major_update_position; + glm::vec4 last_major_update_position; + int animation; // this is really what MQ2 calls SpeedRun just packed like (int)(SpeedRun * 40.0f) float base_size; float size; From 29a62dfa859cdd769e247381afcbb9f3ffdd9acc Mon Sep 17 00:00:00 2001 From: Akkadius Date: Tue, 21 Nov 2017 21:48:35 -0600 Subject: [PATCH 71/97] Remove debugging --- zone/client_process.cpp | 1 - zone/waypoints.cpp | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 355dd2c1f..57dc58195 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -272,7 +272,6 @@ bool Client::Process() { if (force_spawn_updates && mob != this) { if (mob->is_distance_roamer) { - Log(Logs::General, Logs::Debug, "Updating distance roamer %s", mob->GetCleanName()); mob->SendPositionUpdateToClient(this); continue; } diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index d761c6a70..7517b7fb8 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -849,15 +849,15 @@ float Mob::GetFixedZ(glm::vec3 dest, int32 z_find_offset) timer.reset(); float new_z = dest.z; - if (zone->HasMap() && RuleB(Map, FixZWhenMoving) && - (flymode != 1 && flymode != 2)) + if (zone->HasMap() && RuleB(Map, FixZWhenMoving) && + (flymode != 1 && flymode != 2)) { - if (!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() - || (zone->HasWaterMap() && - !zone->watermap->InWater(glm::vec3(m_Position)))) + if (!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() + || (zone->HasWaterMap() && + !zone->watermap->InWater(glm::vec3(m_Position)))) { /* Any more than 5 in the offset makes NPC's hop/snap to ceiling in small corridors */ - new_z = this->FindDestGroundZ(dest,z_find_offset); + new_z = this->FindDestGroundZ(dest, z_find_offset); if (new_z != BEST_Z_INVALID) { new_z += this->GetZOffset(); @@ -872,7 +872,7 @@ float Mob::GetFixedZ(glm::vec3 dest, int32 z_find_offset) auto duration = timer.elapsed(); Log(Logs::Moderate, Logs::FixZ, - "Mob::GetFixedZ() (%s) returned %4.3f at %4.3f, %4.3f, %4.3f - Took %lf", + "Mob::GetFixedZ() (%s) returned %4.3f at %4.3f, %4.3f, %4.3f - Took %lf", this->GetCleanName(), new_z, dest.x, dest.y, dest.z, duration); } @@ -882,21 +882,21 @@ float Mob::GetFixedZ(glm::vec3 dest, int32 z_find_offset) void Mob::FixZ(int32 z_find_offset /*= 5*/) { glm::vec3 current_loc(m_Position); - float new_z=GetFixedZ(current_loc, z_find_offset); + float new_z = GetFixedZ(current_loc, z_find_offset); if (new_z != m_Position.z) { if ((new_z > -2000) && new_z != BEST_Z_INVALID) { if (RuleB(Map, MobZVisualDebug)) this->SendAppearanceEffect(78, 0, 0, 0, 0); - + m_Position.z = new_z; } else { if (RuleB(Map, MobZVisualDebug)) this->SendAppearanceEffect(103, 0, 0, 0, 0); - Log(Logs::General, Logs::FixZ, "%s is failing to find Z %f", + Log(Logs::General, Logs::FixZ, "%s is failing to find Z %f", this->GetCleanName(), std::abs(m_Position.z - new_z)); } } From aaac2c5a84c009aba9b1c119b0c9af3727e76520 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Wed, 22 Nov 2017 09:38:03 -0500 Subject: [PATCH 72/97] Give weaponless NPCs best offense based on skills --- zone/attack.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++----- zone/mob.h | 1 + 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index a87f504b7..a3c9d663c 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -852,16 +852,56 @@ int Mob::ACSum() return ac; } +int Mob::GetBestMeleeSkill() + { + int bestSkill=0; + EQEmu::skills::SkillType meleeSkills[]= + { EQEmu::skills::Skill1HBlunt, + EQEmu::skills::Skill1HSlashing, + EQEmu::skills::Skill2HBlunt, + EQEmu::skills::Skill2HSlashing, + EQEmu::skills::SkillHandtoHand, + EQEmu::skills::Skill1HPiercing, + EQEmu::skills::Skill2HPiercing, + EQEmu::skills::SkillCount + }; + int i; + + for (i=0; meleeSkills[i] != EQEmu::skills::SkillCount; ++i) { + int value; + value = GetSkill(meleeSkills[i]); + bestSkill = std::max(value, bestSkill); + } + + return bestSkill; + } + int Mob::offense(EQEmu::skills::SkillType skill) { int offense = GetSkill(skill); - int stat_bonus = 0; - if (skill == EQEmu::skills::SkillArchery || skill == EQEmu::skills::SkillThrowing) - stat_bonus = GetDEX(); - else - stat_bonus = GetSTR(); + int stat_bonus = GetSTR(); + + switch (skill) { + case EQEmu::skills::SkillArchery: + case EQEmu::skills::SkillThrowing: + stat_bonus = GetDEX(); + break; + + // Mobs with no weapons default to H2H. + // Since H2H is capped at 100 for many many classes, + // lets not handicap mobs based on not spawning with a + // weapon. + // + // Maybe we tweak this if Disarm is actually implemented. + + case EQEmu::skills::SkillHandtoHand: + offense = GetBestMeleeSkill(); + break; + } + if (stat_bonus >= 75) offense += (2 * stat_bonus - 150) / 3; + offense += GetATK(); return offense; } diff --git a/zone/mob.h b/zone/mob.h index 812f54ca1..6b29cd149 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -199,6 +199,7 @@ public: void ApplyMeleeDamageMods(uint16 skill, int &damage, Mob * defender = nullptr, ExtraAttackOptions *opts = nullptr); int ACSum(); int offense(EQEmu::skills::SkillType skill); + int GetBestMeleeSkill(); void CalcAC() { mitigation_ac = ACSum(); } int GetACSoftcap(); double GetSoftcapReturns(); From e19b7bd3683bdccdac8f095d8bc8fc1c27e40230 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 25 Nov 2017 23:56:29 -0500 Subject: [PATCH 73/97] Start work on OP_MoveMultipleItems (RoF+) Currently it just kicks to prevent desyncs --- common/emu_oplist.h | 1 + common/patches/rof2_structs.h | 14 ++++++++++++++ utils/patches/patch_RoF.conf | 1 + utils/patches/patch_RoF2.conf | 1 + zone/client_packet.cpp | 6 ++++++ zone/client_packet.h | 1 + 6 files changed, 24 insertions(+) diff --git a/common/emu_oplist.h b/common/emu_oplist.h index 319517499..89e0126a8 100644 --- a/common/emu_oplist.h +++ b/common/emu_oplist.h @@ -340,6 +340,7 @@ N(OP_MOTD), N(OP_MoveCoin), N(OP_MoveDoor), N(OP_MoveItem), +N(OP_MoveMultipleItems), N(OP_MoveLogDisregard), N(OP_MoveLogRequest), N(OP_MultiLineMsg), diff --git a/common/patches/rof2_structs.h b/common/patches/rof2_structs.h index 28905dd4a..5aa11977f 100644 --- a/common/patches/rof2_structs.h +++ b/common/patches/rof2_structs.h @@ -1827,6 +1827,20 @@ struct MoveItem_Struct /*0028*/ }; +struct MultiMoveItemSub_Struct +{ +/*0000*/ InventorySlot_Struct from_slot; +/*0012*/ InventorySlot_Struct to_slot; +/*0024*/ uint32 number_in_stack; +/*0028*/ uint8 unknown[8]; +}; + +struct MultiMoveItem_Struct +{ +/*0000*/ uint32 count; +/*0004*/ MultiMoveItemSub_Struct moves[0]; +}; + // // from_slot/to_slot // -1 - destroy diff --git a/utils/patches/patch_RoF.conf b/utils/patches/patch_RoF.conf index f3d4249c0..074d5751d 100644 --- a/utils/patches/patch_RoF.conf +++ b/utils/patches/patch_RoF.conf @@ -248,6 +248,7 @@ OP_AutoAttack=0x0d14 OP_AutoAttack2=0x3912 OP_Consume=0x4692 OP_MoveItem=0x62a2 +OP_MoveMultipleItems=0x55ef OP_DeleteItem=0x3eb5 OP_DeleteCharge=0x2d5b OP_ItemPacket=0x5e0e diff --git a/utils/patches/patch_RoF2.conf b/utils/patches/patch_RoF2.conf index 420fcec70..dd58b3c11 100644 --- a/utils/patches/patch_RoF2.conf +++ b/utils/patches/patch_RoF2.conf @@ -247,6 +247,7 @@ OP_AutoAttack=0x109d OP_AutoAttack2=0x3526 OP_Consume=0x4b70 OP_MoveItem=0x32ee +OP_MoveMultipleItems=0x5623 OP_DeleteItem=0x18ad OP_DeleteCharge=0x01b8 OP_ItemPacket=0x368e diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 8efe55f2b..d336f7f0d 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -291,6 +291,7 @@ void MapOpcodes() ConnectedOpcodes[OP_MercenaryTimerRequest] = &Client::Handle_OP_MercenaryTimerRequest; ConnectedOpcodes[OP_MoveCoin] = &Client::Handle_OP_MoveCoin; ConnectedOpcodes[OP_MoveItem] = &Client::Handle_OP_MoveItem; + ConnectedOpcodes[OP_MoveMultipleItems] = &Client::Handle_OP_MoveMultipleItems; ConnectedOpcodes[OP_OpenContainer] = &Client::Handle_OP_OpenContainer; ConnectedOpcodes[OP_OpenGuildTributeMaster] = &Client::Handle_OP_OpenGuildTributeMaster; ConnectedOpcodes[OP_OpenInventory] = &Client::Handle_OP_OpenInventory; @@ -9855,6 +9856,11 @@ void Client::Handle_OP_MoveItem(const EQApplicationPacket *app) return; } +void Client::Handle_OP_MoveMultipleItems(const EQApplicationPacket *app) +{ + Kick(); // TODO: lets not desync though +} + void Client::Handle_OP_OpenContainer(const EQApplicationPacket *app) { // Does not exist in Ti client diff --git a/zone/client_packet.h b/zone/client_packet.h index c63a57825..1e7981ed9 100644 --- a/zone/client_packet.h +++ b/zone/client_packet.h @@ -204,6 +204,7 @@ void Handle_OP_MercenaryTimerRequest(const EQApplicationPacket *app); void Handle_OP_MoveCoin(const EQApplicationPacket *app); void Handle_OP_MoveItem(const EQApplicationPacket *app); + void Handle_OP_MoveMultipleItems(const EQApplicationPacket *app); void Handle_OP_OpenContainer(const EQApplicationPacket *app); void Handle_OP_OpenGuildTributeMaster(const EQApplicationPacket *app); void Handle_OP_OpenInventory(const EQApplicationPacket *app); From f8b924c26208e7c676d38102106e1fa7d8122473 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 26 Nov 2017 18:51:27 -0500 Subject: [PATCH 74/97] Identified other OP_MoveMultipleItems opcodes Older clients don't actually ever send this but they do accept it --- utils/patches/patch_SoD.conf | 1 + utils/patches/patch_SoF.conf | 1 + utils/patches/patch_Titanium.conf | 1 + utils/patches/patch_UF.conf | 1 + 4 files changed, 4 insertions(+) diff --git a/utils/patches/patch_SoD.conf b/utils/patches/patch_SoD.conf index 0e8e36e02..5913670ae 100644 --- a/utils/patches/patch_SoD.conf +++ b/utils/patches/patch_SoD.conf @@ -241,6 +241,7 @@ OP_AutoAttack=0x3d86 # C OP_AutoAttack2=0x4ca1 # C OP_Consume=0x7ce4 # C OP_MoveItem=0x7f56 # C +OP_MoveMultipleItems=0x4572 OP_DeleteItem=0x36f8 # C OP_DeleteCharge=0x1df9 # C OP_ItemPacket=0x34f8 # C diff --git a/utils/patches/patch_SoF.conf b/utils/patches/patch_SoF.conf index cae177bfc..6360617a2 100644 --- a/utils/patches/patch_SoF.conf +++ b/utils/patches/patch_SoF.conf @@ -237,6 +237,7 @@ OP_AutoAttack=0x3427 #Trevius 01/20/09 OP_AutoAttack2=0x6017 #Trevius 01/20/09 OP_Consume=0x729a #Trevius 02/08/09 OP_MoveItem=0x14B3 #Trevius 02/08/09 +OP_MoveMultipleItems=0x2d3e OP_DeleteItem=0x7DD4 #Xinu 03/08/09 0x41EE 0x018E 0x070C OP_DeleteCharge=0x32e2 #Trevius 03/23/09 OP_ItemPacket=0x78Cd #Trevius 02/08/09 diff --git a/utils/patches/patch_Titanium.conf b/utils/patches/patch_Titanium.conf index 23f07109f..27aa18376 100644 --- a/utils/patches/patch_Titanium.conf +++ b/utils/patches/patch_Titanium.conf @@ -198,6 +198,7 @@ OP_Split=0x4848 # ShowEQ 10/27/05 OP_Surname=0x4668 # ShowEQ 10/27/05 OP_ClearSurname=0x6cdb OP_MoveItem=0x420f # ShowEQ 10/27/05 +OP_MoveMultipleItems=0x463b OP_FaceChange=0x0f8e # ShowEQ 10/27/05 OP_ItemPacket=0x3397 # ShowEQ 10/27/05 OP_ItemLinkResponse=0x667c # ShowEQ 10/27/05 diff --git a/utils/patches/patch_UF.conf b/utils/patches/patch_UF.conf index 6d8064029..a96b4208a 100644 --- a/utils/patches/patch_UF.conf +++ b/utils/patches/patch_UF.conf @@ -251,6 +251,7 @@ OP_AutoAttack=0x1df9 # C OP_AutoAttack2=0x517b # C OP_Consume=0x24c5 # V OP_MoveItem=0x2641 # C +OP_MoveMultipleItems=0x40e8 OP_DeleteItem=0x66e0 # C OP_DeleteCharge=0x4ca1 # C OP_ItemPacket=0x7b6e # C From 55f17670018c7b0c43a325e0264ab4f1096ad372 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Thu, 30 Nov 2017 16:50:10 -0500 Subject: [PATCH 75/97] Add confirmed OP_MoveMultipleItems structs Pretty sure SoF-UF are the same, but I haven't verified that yet --- common/patches/sof_structs.h | 32 +++++++++++++++++++++++++++++++ common/patches/titanium_structs.h | 30 +++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/common/patches/sof_structs.h b/common/patches/sof_structs.h index 2a1eab3f0..9d87bd83a 100644 --- a/common/patches/sof_structs.h +++ b/common/patches/sof_structs.h @@ -52,6 +52,25 @@ struct EnterWorld_Struct { struct WorldObjectsSent_Struct { }; +// yep, even SoF had a version of the new inventory system, used by OP_MoveMultipleItems +struct InventorySlot_Struct +{ +/*000*/ int32 Type; // Worn and Normal inventory = 0, Bank = 1, Shared Bank = 2, Trade = 3, World = 4, Limbo = 5 +/*004*/ int32 Slot; +/*008*/ int32 SubIndex; +/*012*/ int32 AugIndex; +/*016*/ int32 Unknown01; +}; + +// unsure if they have a version of this, completeness though +struct TypelessInventorySlot_Struct +{ +/*000*/ int32 Slot; +/*004*/ int32 SubIndex; +/*008*/ int32 AugIndex; +/*012*/ int32 Unknown01; +}; + /* Name Approval Struct */ /* Len: */ /* Opcode: 0x8B20*/ @@ -1557,6 +1576,19 @@ struct MoveItem_Struct /*0012*/ }; +struct MultiMoveItemSub_Struct +{ +/*0000*/ InventorySlot_Struct from_slot; +/*0020*/ uint32 number_in_stack; // so the amount we are moving from the source +/*0024*/ InventorySlot_Struct to_slot; +}; + +struct MultiMoveItem_Struct +{ +/*0000*/ uint32 count; +/*0004*/ MultiMoveItemSub_Struct moves[0]; +}; + // // from_slot/to_slot // -1 - destroy diff --git a/common/patches/titanium_structs.h b/common/patches/titanium_structs.h index 56213854a..e52b7628c 100644 --- a/common/patches/titanium_structs.h +++ b/common/patches/titanium_structs.h @@ -48,6 +48,23 @@ struct EnterWorld_Struct { /*068*/ uint32 return_home; // 01 on "Return Home", 00 if not }; +// yep, even tit had a version of the new inventory system, used by OP_MoveMultipleItems +struct InventorySlot_Struct +{ +/*000*/ int32 Type; // Worn and Normal inventory = 0, Bank = 1, Shared Bank = 2, Trade = 3, World = 4, Limbo = 5 +/*004*/ int32 Slot; +/*008*/ int32 SubIndex; // no aug index in Tit +/*012*/ int32 Unknown01; +}; + +// unsure if they have a version of this, completeness though +struct TypelessInventorySlot_Struct +{ +/*000*/ int32 Slot; +/*004*/ int32 SubIndex; // no aug index in Tit +/*008*/ int32 Unknown01; +}; + /* Name Approval Struct */ /* Len: */ /* Opcode: 0x8B20*/ @@ -1329,6 +1346,19 @@ struct MoveItem_Struct /*0012*/ }; +struct MultiMoveItemSub_Struct +{ +/*0000*/ InventorySlot_Struct from_slot; +/*0016*/ uint32 number_in_stack; // so the amount we are moving from the source +/*0020*/ InventorySlot_Struct to_slot; +}; + +struct MultiMoveItem_Struct +{ +/*0000*/ uint32 count; +/*0004*/ MultiMoveItemSub_Struct moves[0]; +}; + // // from_slot/to_slot // -1 - destroy From ba1a317119ef161bc568b92b851b975458eaac59 Mon Sep 17 00:00:00 2001 From: Shea Date: Sun, 3 Dec 2017 11:33:29 -0600 Subject: [PATCH 76/97] Add distance logic to mobs that move --- zone/mob.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/zone/mob.cpp b/zone/mob.cpp index 9157b2fe8..322bc7658 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -1480,6 +1480,11 @@ void Mob::SendPositionUpdate(uint8 iSendToSelf) { CastToClient()->FastQueuePacket(&app, false); } } + else if (DistanceSquared(last_major_update_position, m_Position) >= (100 * 100)) { + entity_list.QueueClients(this, app, true, true); + last_major_update_position = m_Position; + is_distance_roamer = true; + } else { entity_list.QueueCloseClients(this, app, (iSendToSelf == 0), RuleI(Range, MobPositionUpdates), nullptr, false); } From 9c6dbe699f98da125e74971bb7c93f169780c8a5 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Sun, 10 Dec 2017 10:55:25 -0500 Subject: [PATCH 77/97] Mobs no longer root feared enemies. --- zone/mob_ai.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index e42e4f617..d653835b5 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -127,7 +127,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes) { } case SpellType_Root: { Mob *rootee = GetHateRandom(); - if (rootee && !rootee->IsRooted() && zone->random.Roll(50) + if (rootee && !rootee->IsRooted() && !rootee->IsFeared() && zone->random.Roll(50) && rootee->DontRootMeBefore() < Timer::GetCurrentTime() && rootee->CanBuffStack(AIspells[i].spellid, GetLevel(), true) >= 0 ) { From 477ba3f4b99619cf4b95ba3bdb48ec447bffd68d Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Fri, 15 Dec 2017 01:47:45 -0500 Subject: [PATCH 78/97] Apply HotZone for AAs Ahh is this the right spot? No idea :P --- zone/exp.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/zone/exp.cpp b/zone/exp.cpp index 7d9a02fa8..1fd8ea0a3 100644 --- a/zone/exp.cpp +++ b/zone/exp.cpp @@ -327,8 +327,7 @@ void Client::AddEXP(uint32 in_add_exp, uint8 conlevel, bool resexp) { aatotalmod *= zone->newzone_data.zone_exp_multiplier; } - - + // Shouldn't race not affect AA XP? if(RuleB(Character,UseRaceClassExpBonuses)) { if(GetBaseRace() == HALFLING){ @@ -340,6 +339,12 @@ void Client::AddEXP(uint32 in_add_exp, uint8 conlevel, bool resexp) { } } + // why wasn't this here? Where should it be? + if(zone->IsHotzone()) + { + aatotalmod += RuleR(Zone, HotZoneBonus); + } + if(RuleB(Zone, LevelBasedEXPMods)){ if(zone->level_exp_mod[GetLevel()].ExpMod){ add_exp *= zone->level_exp_mod[GetLevel()].ExpMod; From 9af9deb0f5e25f88d3f96542b1578d53f3b0a78e Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Fri, 15 Dec 2017 18:42:21 -0500 Subject: [PATCH 79/97] Attempt to fix disc issue when client has no buff but server still does This is kind of hard to test, but it is what the client is doing --- zone/effects.cpp | 4 ++++ zone/mob.h | 1 + zone/spells.cpp | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/zone/effects.cpp b/zone/effects.cpp index 2741a924b..6b0c2a2ad 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -611,6 +611,10 @@ bool Client::UseDiscipline(uint32 spell_id, uint32 target) { return false; } + // the client does this check before calling CastSpell, should prevent discs being eaten + if (spell.buffdurationformula != 0 && spell.targettype == ST_Self && HasDiscBuff()) + return false; + //Check the disc timer pTimerType DiscTimer = pTimerDisciplineReuseStart + spell.EndurTimerIndex; if(!p_timers.Expired(&database, DiscTimer, false)) { // lets not set the reuse timer in case CastSpell fails (or we would have to turn off the timer, but CastSpell will set it as well) diff --git a/zone/mob.h b/zone/mob.h index 0f0a49031..25e6492fb 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -352,6 +352,7 @@ public: virtual int GetMaxSongSlots() const { return 0; } virtual int GetMaxDiscSlots() const { return 0; } virtual int GetMaxTotalSlots() const { return 0; } + bool HasDiscBuff(); virtual uint32 GetFirstBuffSlot(bool disc, bool song); virtual uint32 GetLastBuffSlot(bool disc, bool song); virtual void InitializeBuffSlots() { buffs = nullptr; current_buff_count = 0; } diff --git a/zone/spells.cpp b/zone/spells.cpp index c5a5a0b48..25b0a7ce9 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -3190,6 +3190,12 @@ uint32 Client::GetLastBuffSlot(bool disc, bool song) return GetCurrentBuffSlots(); } +bool Mob::HasDiscBuff() +{ + int slot = GetFirstBuffSlot(true, false); + return buffs[slot].spellid != SPELL_UNKNOWN; +} + // returns the slot the buff was added to, -1 if it wasn't added due to // stacking problems, and -2 if this is not a buff // if caster is null, the buff will be added with the caster level being From 97873ff42d6b4407d790e5d79886c7ee2c2259f0 Mon Sep 17 00:00:00 2001 From: JJ Date: Sat, 16 Dec 2017 23:20:20 -0500 Subject: [PATCH 80/97] Change Ground Spawn respawn timers to match normal spawns (msec to sec). Highly recommended sql included! --- utils/sql/git/optional/2017_12_16_GroundSpawn_Respawn_Timer.sql | 2 ++ zone/object.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 utils/sql/git/optional/2017_12_16_GroundSpawn_Respawn_Timer.sql diff --git a/utils/sql/git/optional/2017_12_16_GroundSpawn_Respawn_Timer.sql b/utils/sql/git/optional/2017_12_16_GroundSpawn_Respawn_Timer.sql new file mode 100644 index 000000000..f7c8b6a31 --- /dev/null +++ b/utils/sql/git/optional/2017_12_16_GroundSpawn_Respawn_Timer.sql @@ -0,0 +1,2 @@ +ALTER TABLE `ground_spawns` MODIFY `respawn_timer` int(11) unsigned NOT NULL default 300; +UPDATE `ground_spawns` SET `respawn_timer` = `respawn_timer` / 1000; diff --git a/zone/object.cpp b/zone/object.cpp index d8db2f1d8..0ba5f9fa3 100644 --- a/zone/object.cpp +++ b/zone/object.cpp @@ -70,7 +70,7 @@ Object::Object(uint32 id, uint32 type, uint32 icon, const Object_Struct& object, //creating a re-ocurring ground spawn. Object::Object(const EQEmu::ItemInstance* inst, char* name,float max_x,float min_x,float max_y,float min_y,float z,float heading,uint32 respawntimer) - : respawn_timer(respawntimer), decay_timer(300000) + : respawn_timer(respawntimer * 1000), decay_timer(300000) { user = nullptr; From 8011c48641d16c1af0948c0c3c6cd3f180588de4 Mon Sep 17 00:00:00 2001 From: JJ Date: Sun, 17 Dec 2017 12:58:42 -0500 Subject: [PATCH 81/97] Make Ground Spawn sql required in https://github.com/EQEmu/Server/commit/97873ff42d6b4407d790e5d79886c7ee2c2259f0 --- utils/sql/db_update_manifest.txt | 1 + .../2017_12_16_GroundSpawn_Respawn_Timer.sql | 0 2 files changed, 1 insertion(+) rename utils/sql/git/{optional => required}/2017_12_16_GroundSpawn_Respawn_Timer.sql (100%) diff --git a/utils/sql/db_update_manifest.txt b/utils/sql/db_update_manifest.txt index c9b6a7b78..11dd1b315 100644 --- a/utils/sql/db_update_manifest.txt +++ b/utils/sql/db_update_manifest.txt @@ -369,6 +369,7 @@ 9113|2017_07_19_show_name.sql|SHOW COLUMNS FROM `npc_types` LIKE 'show_name'|empty| 9114|2017_07_22_aura.sql|SHOW TABLES LIKE 'auras'|empty| 9115|2017_10_28_traps.sql|SHOW COLUMNS FROM `traps` LIKE 'triggered_number'|empty| +9116|2017_12_16_GroundSpawn_Respawn_Timer.sql|SHOW COLUMNS FROM `ground_spawns` WHERE Field = 'respawn_timer' AND Type = 'int(11) unsigned'|empty| # Upgrade conditions: # This won't be needed after this system is implemented, but it is used database that are not diff --git a/utils/sql/git/optional/2017_12_16_GroundSpawn_Respawn_Timer.sql b/utils/sql/git/required/2017_12_16_GroundSpawn_Respawn_Timer.sql similarity index 100% rename from utils/sql/git/optional/2017_12_16_GroundSpawn_Respawn_Timer.sql rename to utils/sql/git/required/2017_12_16_GroundSpawn_Respawn_Timer.sql From c65864ffb681eff88bc1af1fa8eb4128a6dd3494 Mon Sep 17 00:00:00 2001 From: SecretsOTheP Date: Thu, 21 Dec 2017 14:55:59 +0000 Subject: [PATCH 82/97] Fixed Ubuntu 17.10 compiles --- libs/format/fmt/format.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/format/fmt/format.h b/libs/format/fmt/format.h index 47a8b74d8..9c2827d46 100644 --- a/libs/format/fmt/format.h +++ b/libs/format/fmt/format.h @@ -1719,6 +1719,8 @@ FMT_DEFINE_INT_FORMATTERS(unsigned long) FMT_DEFINE_INT_FORMATTERS(LongLong) FMT_DEFINE_INT_FORMATTERS(ULongLong) +#define CHAR_WIDTH 1 + /** \rst Returns a string formatter that pads the formatted argument with the fill @@ -1823,7 +1825,7 @@ class ArgFormatterBase : public ArgVisitor { typedef typename BasicWriter::CharPtr CharPtr; Char fill = internal::CharTraits::cast(spec_.fill()); CharPtr out = CharPtr(); - const unsigned CHAR_WIDTH = 1; + if (spec_.width_ > CHAR_WIDTH) { out = writer_.grow_buffer(spec_.width_); if (spec_.align_ == ALIGN_RIGHT) { From 994e2001a0b9d1f97e3570aaea7187f151fe804d Mon Sep 17 00:00:00 2001 From: Shea Date: Fri, 22 Dec 2017 17:09:47 -0600 Subject: [PATCH 83/97] Fix for Xtargets not being populated when pet initiates aggro. --- zone/attack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index 47b0aad07..8679da02b 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -2716,9 +2716,9 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b // owner must get on list, but he's not actually gained any hate yet if (!owner->GetSpecialAbility(IMMUNE_AGGRO)) { - hate_list.AddEntToHateList(owner, 0, 0, false, !iBuffTic); if (owner->IsClient() && !CheckAggro(owner)) owner->CastToClient()->AddAutoXTarget(this); + hate_list.AddEntToHateList(owner, 0, 0, false, !iBuffTic); } } } From 0356c0a891e1a36f06ff91ffbdd09b5556b67f99 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 23 Dec 2017 22:35:05 -0500 Subject: [PATCH 84/97] Refactor getting resist value out to a function --- zone/mob.h | 1 + zone/spells.cpp | 94 ++++++++++++++++--------------------------------- 2 files changed, 32 insertions(+), 63 deletions(-) diff --git a/zone/mob.h b/zone/mob.h index 25e6492fb..deb24f640 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -281,6 +281,7 @@ public: float ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use_resist_override = false, int resist_override = 0, bool CharismaCheck = false, bool CharmTick = false, bool IsRoot = false, int level_override = -1); + int GetResist(uint8 resist_type); int ResistPhysical(int level_diff, uint8 caster_level); int ResistElementalWeaponDmg(const EQEmu::ItemInstance *item); int CheckBaneDamage(const EQEmu::ItemInstance *item); diff --git a/zone/spells.cpp b/zone/spells.cpp index 25b0a7ce9..07a39678d 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -4437,6 +4437,36 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) return false; } +int Mob::GetResist(uint8 resist_type) +{ + switch(resist_type) + { + case RESIST_FIRE: + return GetFR(); + case RESIST_COLD: + return GetCR(); + case RESIST_MAGIC: + return GetMR(); + case RESIST_DISEASE: + return GetDR(); + case RESIST_POISON: + return GetPR(); + case RESIST_CORRUPTION: + return GetCorrup(); + case RESIST_PRISMATIC: + return (GetFR() + GetCR() + GetMR() + GetDR() + GetPR()) / 5; + case RESIST_CHROMATIC: + return std::min({GetFR(), GetCR(), GetMR(), GetDR(), GetPR()}); + case RESIST_PHYSICAL: + if (IsNPC()) + return GetPhR(); + else + return 0; + default: + return 0; + } +} + // // Spell resists: // returns an effectiveness index from 0 to 100. for most spells, 100 means @@ -4520,69 +4550,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use return 100; } - int target_resist; - switch(resist_type) - { - case RESIST_FIRE: - target_resist = GetFR(); - break; - case RESIST_COLD: - target_resist = GetCR(); - break; - case RESIST_MAGIC: - target_resist = GetMR(); - break; - case RESIST_DISEASE: - target_resist = GetDR(); - break; - case RESIST_POISON: - target_resist = GetPR(); - break; - case RESIST_CORRUPTION: - target_resist = GetCorrup(); - break; - case RESIST_PRISMATIC: - target_resist = (GetFR() + GetCR() + GetMR() + GetDR() + GetPR()) / 5; - break; - case RESIST_CHROMATIC: - { - target_resist = GetFR(); - int temp = GetCR(); - if(temp < target_resist) - { - target_resist = temp; - } - - temp = GetMR(); - if(temp < target_resist) - { - target_resist = temp; - } - - temp = GetDR(); - if(temp < target_resist) - { - target_resist = temp; - } - - temp = GetPR(); - if(temp < target_resist) - { - target_resist = temp; - } - } - break; - case RESIST_PHYSICAL: - { - if (IsNPC()) - target_resist = GetPhR(); - else - target_resist = 0; - } - default: - - target_resist = 0; - } + int target_resist = GetResist(resist_type); //Setup our base resist chance. int resist_chance = 0; From 668634647375712ebe3b7beb3f9ffa176068cfea Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 23 Dec 2017 22:48:21 -0500 Subject: [PATCH 85/97] Implement July 24, 2002 pet resist changes --- zone/spells.cpp | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/zone/spells.cpp b/zone/spells.cpp index 07a39678d..8117a8018 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -4552,13 +4552,23 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use int target_resist = GetResist(resist_type); + // JULY 24, 2002 changes + int level = GetLevel(); + if (IsPetOwnerClient() && caster->IsNPC() && !caster->IsPetOwnerClient()) { + auto owner = GetOwner(); + if (owner != nullptr) { + target_resist = std::max(target_resist, owner->GetResist(resist_type)); + level = owner->GetLevel(); + } + } + //Setup our base resist chance. int resist_chance = 0; int level_mod = 0; //Adjust our resist chance based on level modifiers uint8 caster_level = level_override > 0 ? level_override : caster->GetLevel(); - int temp_level_diff = GetLevel() - caster_level; + int temp_level_diff = level - caster_level; //Physical Resists are calclated using their own formula derived from extensive parsing. if (resist_type == RESIST_PHYSICAL) { @@ -4567,7 +4577,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use else { - if(IsNPC() && GetLevel() >= RuleI(Casting,ResistFalloff)) + if(IsNPC() && level >= RuleI(Casting,ResistFalloff)) { int a = (RuleI(Casting,ResistFalloff)-1) - caster_level; if(a > 0) @@ -4580,7 +4590,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use } } - if(IsClient() && GetLevel() >= 21 && temp_level_diff > 15) + if(IsClient() && level >= 21 && temp_level_diff > 15) { temp_level_diff = 15; } @@ -4596,16 +4606,16 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use level_mod = -level_mod; } - if(IsNPC() && (caster_level - GetLevel()) < -20) + if(IsNPC() && (caster_level - level) < -20) { level_mod = 1000; } //Even more level stuff this time dealing with damage spells - if(IsNPC() && IsDamageSpell(spell_id) && GetLevel() >= 17) + if(IsNPC() && IsDamageSpell(spell_id) && level >= 17) { int level_diff; - if(GetLevel() >= RuleI(Casting,ResistFalloff)) + if(level >= RuleI(Casting,ResistFalloff)) { level_diff = (RuleI(Casting,ResistFalloff)-1) - caster_level; if(level_diff < 0) @@ -4615,7 +4625,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use } else { - level_diff = GetLevel() - caster_level; + level_diff = level - caster_level; } level_mod += (2 * level_diff); } @@ -4726,17 +4736,17 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use if(IsNPC()) { - if(GetLevel() > caster_level && GetLevel() >= 17 && caster_level <= 50) + if(level > caster_level && level >= 17 && caster_level <= 50) { partial_modifier += 5; } - if(GetLevel() >= 30 && caster_level < 50) + if(level >= 30 && caster_level < 50) { partial_modifier += (caster_level - 25); } - if(GetLevel() < 15) + if(level < 15) { partial_modifier -= 5; } @@ -4744,9 +4754,9 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use if(caster->IsNPC()) { - if((GetLevel() - caster_level) >= 20) + if((level - caster_level) >= 20) { - partial_modifier += (GetLevel() - caster_level) * 1.5; + partial_modifier += (level - caster_level) * 1.5; } } From c1ad00cbc61dd321ce1596de8cfaf0770ee706f0 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 23 Dec 2017 22:55:45 -0500 Subject: [PATCH 86/97] Fix where SE_ExtraAttackChance happens Improved AA descriptions say this is after a successful double attack --- zone/attack.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index 8679da02b..88712a08b 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -5290,19 +5290,30 @@ void Client::DoAttackRounds(Mob *target, int hand, bool IsFromSpell) // extra off hand non-sense, can only double with skill of 150 or above // or you have any amount of GiveDoubleAttack if (candouble && hand == EQEmu::inventory::slotSecondary) - candouble = GetSkill(EQEmu::skills::SkillDoubleAttack) > 149 || (aabonuses.GiveDoubleAttack + spellbonuses.GiveDoubleAttack + itembonuses.GiveDoubleAttack) > 0; + candouble = + GetSkill(EQEmu::skills::SkillDoubleAttack) > 149 || + (aabonuses.GiveDoubleAttack + spellbonuses.GiveDoubleAttack + itembonuses.GiveDoubleAttack) > 0; if (candouble) { CheckIncreaseSkill(EQEmu::skills::SkillDoubleAttack, target, -10); if (CheckDoubleAttack()) { Attack(target, hand, false, false, IsFromSpell); + + // Modern AA description: Increases your chance of ... performing one additional hit with a 2-handed weapon when double attacking by 2%. + if (hand == EQEmu::inventory::slotPrimary) { + auto extraattackchance = aabonuses.ExtraAttackChance + spellbonuses.ExtraAttackChance + + itembonuses.ExtraAttackChance; + if (extraattackchance && HasTwoHanderEquipped() && zone->random.Roll(extraattackchance)) + Attack(target, hand, false, false, IsFromSpell); + } + // you can only triple from the main hand if (hand == EQEmu::inventory::slotPrimary && CanThisClassTripleAttack()) { CheckIncreaseSkill(EQEmu::skills::SkillTripleAttack, target, -10); if (CheckTripleAttack()) { Attack(target, hand, false, false, IsFromSpell); auto flurrychance = aabonuses.FlurryChance + spellbonuses.FlurryChance + - itembonuses.FlurryChance; + itembonuses.FlurryChance; if (flurrychance && zone->random.Roll(flurrychance)) { Attack(target, hand, false, false, IsFromSpell); if (zone->random.Roll(flurrychance)) @@ -5313,12 +5324,6 @@ void Client::DoAttackRounds(Mob *target, int hand, bool IsFromSpell) } } } - - if (hand == EQEmu::inventory::slotPrimary) { - auto extraattackchance = aabonuses.ExtraAttackChance + spellbonuses.ExtraAttackChance + itembonuses.ExtraAttackChance; - if (extraattackchance && HasTwoHanderEquipped() && zone->random.Roll(extraattackchance)) - Attack(target, hand, false, false, IsFromSpell); - } } bool Mob::CheckDualWield() From a6b9cd87ecec8211b301b3ef0db68880ea5406d9 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Tue, 26 Dec 2017 11:42:09 -0500 Subject: [PATCH 87/97] Adjust xp loss if using the level_based_mods. --- zone/attack.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/zone/attack.cpp b/zone/attack.cpp index 47b0aad07..8d8b61d74 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -1728,6 +1728,15 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Sk if (!RuleB(Character, UseDeathExpLossMult)) { exploss = (int)(GetLevel() * (GetLevel() / 18.0) * 12000); } + + if (RuleB(Zone, LevelBasedEXPMods)) { + // Death in levels with xp_mod (such as hell levels) was resulting + // in losing more that appropriate since the loss was the same but + // getting it back would take way longer. This makes the death the + // same amount of time to recover. Will also lose more if level is + // granting a bonus. + exploss *= zone->level_exp_mod[GetLevel()].ExpMod; + } if ((GetLevel() < RuleI(Character, DeathExpLossLevel)) || (GetLevel() > RuleI(Character, DeathExpLossMaxLevel)) || IsBecomeNPC()) { From 6e1c8c665b1af56e7ce11d31ba7378153a223327 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Thu, 4 Jan 2018 14:38:29 -0600 Subject: [PATCH 88/97] Fix NPC aggro to account for squared - fixing NPC's that aggro beyond the normal scan range --- zone/client_process.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 57dc58195..804bc32ca 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -264,7 +264,7 @@ bool Client::Process() { if (distance <= scan_range) { close_mobs.insert(std::pair(mob, distance)); } - else if (mob->GetAggroRange() > scan_range) { + else if ((mob->GetAggroRange() * mob->GetAggroRange()) > scan_range) { close_mobs.insert(std::pair(mob, distance)); } } From ee581f27c44639938253d1e77b85efa3ad9adb89 Mon Sep 17 00:00:00 2001 From: Shea Date: Mon, 8 Jan 2018 19:15:36 -0600 Subject: [PATCH 89/97] Packet sends with sz 0 do not work on Linux --- zone/zone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 3a8f1e938..0e6a50092 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1515,7 +1515,7 @@ void Zone::Repop(uint32 delay) { void Zone::GetTimeSync() { if (worldserver.Connected() && !zone_has_current_time) { - auto pack = new ServerPacket(ServerOP_GetWorldTime, 0); + auto pack = new ServerPacket(ServerOP_GetWorldTime, 1); worldserver.SendPacket(pack); safe_delete(pack); } From 2dad087bbd06ef818103b0216aa244a30e6616d3 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Tue, 9 Jan 2018 18:00:34 -0500 Subject: [PATCH 90/97] Removed pets from Witness Heal Aggro. --- zone/entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 0ab10982a..4b0599541 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3257,7 +3257,7 @@ void EntityList::AddHealAggro(Mob *target, Mob *caster, uint16 hate) for (auto &e : npc_list) { auto &npc = e.second; - if (!npc->CheckAggro(target) || npc->IsFeared()) + if (!npc->CheckAggro(target) || npc->IsFeared() || npc->IsPet()) continue; if (zone->random.Roll(50)) // witness check -- place holder From c2a35bb2e1054d545438ccd16f5761bbc69e1eae Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Tue, 9 Jan 2018 20:31:48 -0500 Subject: [PATCH 91/97] Exclude clients from FixZ to fix fear issues. --- zone/waypoints.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index d761c6a70..18800101b 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -884,7 +884,7 @@ void Mob::FixZ(int32 z_find_offset /*= 5*/) glm::vec3 current_loc(m_Position); float new_z=GetFixedZ(current_loc, z_find_offset); - if (new_z != m_Position.z) + if (!IsClient() && new_z != m_Position.z) { if ((new_z > -2000) && new_z != BEST_Z_INVALID) { if (RuleB(Map, MobZVisualDebug)) From e25499b3f27071b1459d570f3a573c111c94012b Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Wed, 10 Jan 2018 13:10:03 -0500 Subject: [PATCH 92/97] Level was missing from Spell error message. --- zone/spell_effects.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 9f78cb35d..67104a234 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -1796,8 +1796,12 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove Message_StringID(4, CORPSE_CANT_SENSE); } } - else if (caster) - caster->Message_StringID(MT_SpellFailure, SPELL_LEVEL_REQ); + else if (caster) { + char level[4]; + ConvertArray(effect_value, level); + caster->Message_StringID(MT_SpellFailure, + SPELL_LEVEL_REQ, level); + } } else { Message_StringID(4, TARGET_NOT_FOUND); From e1f8354905c5671ca2326fd7539653b50cd98575 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Wed, 10 Jan 2018 13:19:26 -0500 Subject: [PATCH 93/97] Add rule to use ClassicBackstab (no mob fronttab) --- common/ruletypes.h | 2 ++ zone/loottables.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/common/ruletypes.h b/common/ruletypes.h index ed5ae8e23..0d7c45edd 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -198,6 +198,7 @@ RULE_CATEGORY(Pets) RULE_REAL(Pets, AttackCommandRange, 150) RULE_BOOL(Pets, UnTargetableSwarmPet, false) RULE_REAL(Pets, PetPowerLevelCap, 10) // Max number of levels your pet can go up with pet power +RULE_BOOL(Pets, CanTakeNoDrop, false) // Can everyone trade nodrop gear to pets RULE_CATEGORY_END() RULE_CATEGORY(GM) @@ -508,6 +509,7 @@ RULE_INT(Combat, NPCAssistCapTimer, 6000) // Time in milliseconds a NPC will tak RULE_BOOL(Combat, UseRevampHandToHand, false) // use h2h revamped dmg/delays I believe this was implemented during SoF RULE_BOOL(Combat, ClassicMasterWu, false) // classic master wu uses a random special, modern doesn't RULE_INT(Combat, LevelToStopDamageCaps, 0) // 1 will effectively disable them, 20 should give basically same results as old incorrect system +RULE_BOOL(Combat, ClassicNPCBackstab, false) // true disables npc facestab - npcs get normal attack if not behind RULE_CATEGORY_END() RULE_CATEGORY(NPC) diff --git a/zone/loottables.cpp b/zone/loottables.cpp index 08d16e412..d9fa86257 100644 --- a/zone/loottables.cpp +++ b/zone/loottables.cpp @@ -336,7 +336,8 @@ void NPC::AddLootDrop(const EQEmu::ItemData *item2, ItemList* itemlist, int16 ch eslot = EQEmu::textures::weaponPrimary; if (item2->Damage > 0) { SendAddPlayerState(PlayerState::PrimaryWeaponEquipped); - SetFacestab(true); + if (!RuleB(Combat, ClassicNPCBackstab)) + SetFacestab(true); } if (item2->IsType2HWeapon()) SetTwoHanderEquipped(true); From 14717840358a95b5dfb8aded2f97aeae2d6f10be Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Wed, 10 Jan 2018 13:41:25 -0500 Subject: [PATCH 94/97] Allow trading nodrop to pets via new rule. --- zone/pets.cpp | 13 +++++++++---- zone/trading.cpp | 8 +++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/zone/pets.cpp b/zone/pets.cpp index ef895410b..bbc4f8eea 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -655,10 +655,15 @@ void NPC::SetPetState(SpellBuff_Struct *pet_buffs, uint32 *items) { continue; const EQEmu::ItemData* item2 = database.GetItem(items[i]); - if (item2 && item2->NoDrop != 0) { - //dont bother saving item charges for now, NPCs never use them - //and nobody should be able to get them off the corpse..? - AddLootDrop(item2, &itemlist, 0, 1, 255, true, true); + + if (item2) { + bool noDrop=(item2->NoDrop == 0); // Field is reverse logic + bool petCanHaveNoDrop = (RuleB(Pets, CanTakeNoDrop) && + _CLIENTPET(this) && GetPetType() <= petOther); + + if (!noDrop || petCanHaveNoDrop) { + AddLootDrop(item2, &itemlist, 0, 1, 255, true, true); + } } } } diff --git a/zone/trading.cpp b/zone/trading.cpp index 5c069cacd..70d5c85c1 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -523,7 +523,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st else qs_audit->char1_count += detail->charges; - //for (uint8 sub_slot = SUB_BEGIN; ((sub_slot < inst->GetItem()->BagSlots) && (sub_slot < EmuConstants::ITEM_CONTAINER_SIZE)); ++sub_slot) { for (uint8 sub_slot = EQEmu::inventory::containerBegin; (sub_slot < EQEmu::inventory::ContainerCount); ++sub_slot) { // this is to catch ALL items const EQEmu::ItemInstance* bag_inst = inst->GetItem(sub_slot); @@ -743,7 +742,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st qs_audit->char1_count += detail->charges; // 'step 3' should never really see containers..but, just in case... - //for (uint8 sub_slot = SUB_BEGIN; ((sub_slot < inst->GetItem()->BagSlots) && (sub_slot < EmuConstants::ITEM_CONTAINER_SIZE)); ++sub_slot) { for (uint8 sub_slot = EQEmu::inventory::containerBegin; (sub_slot < EQEmu::inventory::ContainerCount); ++sub_slot) { // this is to catch ALL items const EQEmu::ItemInstance* bag_inst = inst->GetItem(sub_slot); @@ -888,8 +886,12 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st const EQEmu::ItemData* item = inst->GetItem(); if(item && quest_npc == false) { + bool isPetAndCanHaveNoDrop = (RuleB(Pets, CanTakeNoDrop) && + _CLIENTPET(tradingWith) && + tradingWith->GetPetType()<=petOther); // if it was not a NO DROP or Attuned item (or if a GM is trading), let the NPC have it - if(GetGM() || (item->NoDrop != 0 && inst->IsAttuned() == false)) { + if(GetGM() || (inst->IsAttuned() == false && + (item->NoDrop != 0 || isPetAndCanHaveNoDrop))) { // pets need to look inside bags and try to equip items found there if (item->IsClassBag() && item->BagSlots > 0) { for (int16 bslot = EQEmu::inventory::containerBegin; bslot < item->BagSlots; bslot++) { From fb2f8327e2c163277baf3f8551210c002ab09509 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Wed, 10 Jan 2018 14:13:52 -0500 Subject: [PATCH 95/97] This patches gross pet errors in Z. --- zone/mob_ai.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index d653835b5..d331ee7a0 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1391,19 +1391,33 @@ void Mob::AI_Process() { //if(owner->IsClient()) // printf("Pet start pos: (%f, %f, %f)\n", GetX(), GetY(), GetZ()); - float dist = DistanceSquared(m_Position, owner->GetPosition()); - if (dist >= 400) + glm::vec4 ownerPos = owner->GetPosition(); + float dist = DistanceSquared(m_Position, ownerPos); + float distz = ownerPos.z - m_Position.z; + + if (dist >= 400 || distz > 100) { int speed = GetWalkspeed(); if (dist >= 5625) speed = GetRunspeed(); - CalculateNewPosition2(owner->GetX(), owner->GetY(), owner->GetZ(), speed); + if (distz > 100) + { + m_Position = ownerPos; + SendPositionUpdate(); + moved = true; + } + else + { + CalculateNewPosition2(owner->GetX(), + owner->GetY(), owner->GetZ(), speed); + } } else { if(moved) { + this->FixZ(); SetCurrentSpeed(0); moved = false; } From 760ba01e6b8981a9b1a15686a0650735d5f48492 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Wed, 10 Jan 2018 22:34:57 -0500 Subject: [PATCH 96/97] Update a comment --- common/patches/rof2_limits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/patches/rof2_limits.h b/common/patches/rof2_limits.h index 6f4e649ff..0dd7067a9 100644 --- a/common/patches/rof2_limits.h +++ b/common/patches/rof2_limits.h @@ -164,7 +164,7 @@ namespace RoF2 ItemPacket11 = 111, ItemPacket12 = 112, ItemPacketRecovery = 113, - ItemPacket14 = 115 + ItemPacket14 = 115 // Parcel? adds to merchant window too }; } /*item*/ From d18fb730eca8b97d45d5c1611f0ad060e2edf013 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 13 Jan 2018 01:14:06 -0500 Subject: [PATCH 97/97] Don't increment the xtarget count on feign memory --- zone/attack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index 8e151d7c9..f9edb46ac 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -2684,7 +2684,7 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b hate_list.AddEntToHateList(other, hate, damage, bFrenzy, !iBuffTic); - if (other->IsClient() && !on_hatelist) + if (other->IsClient() && !on_hatelist && !IsOnFeignMemory(other->CastToClient())) other->CastToClient()->AddAutoXTarget(this); #ifdef BOTS