From 43da07fb55231eb520113a5745c36aab91e5d2bf Mon Sep 17 00:00:00 2001 From: hg <4683435+hgtw@users.noreply.github.com> Date: Tue, 28 Jan 2020 19:04:47 -0500 Subject: [PATCH 01/11] Fix zone crash when a group member raid invites own group leader --- zone/client_packet.cpp | 5 +++++ zone/string_ids.h | 1 + 2 files changed, 6 insertions(+) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index ebc6bd38a..dfb7ab673 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -11130,6 +11130,11 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) break; } + if (player_to_invite_group && player_to_invite_group->IsGroupMember(this)) { + MessageString(Chat::Red, ALREADY_IN_PARTY); + break; + } + if (player_to_invite_group && !player_to_invite_group->IsLeader(player_to_invite)) { Message(Chat::Red, "You can only invite an ungrouped player or group leader to join your raid."); break; diff --git a/zone/string_ids.h b/zone/string_ids.h index 0948d13a8..25321b3c9 100644 --- a/zone/string_ids.h +++ b/zone/string_ids.h @@ -417,6 +417,7 @@ #define TARGET_PLAYER_FOR_GUILD_STATUS 12260 #define GROUP_INVITEE_NOT_FOUND 12268 //You must target a player or use /invite to invite someone to your group. #define GROUP_INVITEE_SELF 12270 //12270 You cannot invite yourself. +#define ALREADY_IN_PARTY 12272 //That person is already in your party. #define NO_LONGER_HIDDEN 12337 //You are no longer hidden. #define STOP_SNEAKING 12338 //You stop sneaking #define NOT_IN_CONTROL 12368 //You do not have control of yourself right now. From 92d32feb0dd98de4a8460292b9ff84ab11697382 Mon Sep 17 00:00:00 2001 From: Uleat Date: Tue, 28 Jan 2020 21:24:14 -0500 Subject: [PATCH 02/11] Fix for player hp updates not matching between client and server --- zone/client_mods.cpp | 4 ++++ zone/mob.cpp | 15 ++++++++++++++- zone/mob.h | 1 + zone/spell_effects.cpp | 3 +++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/zone/client_mods.cpp b/zone/client_mods.cpp index 2d61a59ec..255201090 100644 --- a/zone/client_mods.cpp +++ b/zone/client_mods.cpp @@ -336,6 +336,10 @@ int32 Client::CalcMaxHP() current_hp = curHP_cap; } } + + // hack fix for client health not reflecting server value + last_max_hp = 0; + return max_hp; } diff --git a/zone/mob.cpp b/zone/mob.cpp index 71e876938..a6de82eee 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -186,6 +186,7 @@ Mob::Mob( last_hp_percent = 0; last_hp = 0; + last_max_hp = 0; current_speed = base_runspeed; @@ -1334,6 +1335,16 @@ void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= fal * If our HP is different from last HP update call - let's update selves */ if (IsClient()) { + + // delay to allow the client to catch up on buff states + if (max_hp != last_max_hp) { + + last_max_hp = max_hp; + CastToClient()->hp_self_update_throttle_timer.Trigger(); + + return; + } + if (current_hp != last_hp || force_update_all) { /** @@ -1341,10 +1352,12 @@ void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= fal */ if (this->CastToClient()->hp_self_update_throttle_timer.Check() || force_update_all) { Log(Logs::General, Logs::HPUpdate, - "Mob::SendHPUpdate :: Update HP of self (%s) HP: %i last: %i skip_self: %s", + "Mob::SendHPUpdate :: Update HP of self (%s) HP: %i/%i last: %i/%i skip_self: %s", this->GetCleanName(), current_hp, + max_hp, last_hp, + last_max_hp, (skip_self ? "true" : "false") ); diff --git a/zone/mob.h b/zone/mob.h index d48f47e6d..7c095a001 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -1526,6 +1526,7 @@ protected: int8 last_hp_percent; int32 last_hp; + int32 last_max_hp; int cur_wp; glm::vec4 m_CurrentWayPoint; diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 693222e9f..63a4a113f 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -286,6 +286,9 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove dmg = -dmg; } + // hack fix for client health not reflecting server value + last_hp = 0; + //do any AAs apply to these spells? if(dmg < 0) { if (!PassCastRestriction(false, spells[spell_id].base2[i], true)) From 712366293d661c3d37452f7cfb4ac80cfe84ce86 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Thu, 30 Jan 2020 11:10:57 -0500 Subject: [PATCH 03/11] Further refine monk weight checks for floating point --- zone/attack.cpp | 51 ++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index 911f22dfb..da8dd6e3d 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -659,85 +659,88 @@ int Mob::GetClassRaceACBonus() auto level = GetLevel(); if (GetClass() == MONK) { int hardcap = 30; - int softcap = 14; + double softcap = 14.9; if (level > 99) { hardcap = 58; - softcap = 35; + softcap = 35.9; } else if (level > 94) { hardcap = 57; - softcap = 34; + softcap = 34.9; } else if (level > 89) { hardcap = 56; - softcap = 33; + softcap = 33.9; } else if (level > 84) { hardcap = 55; - softcap = 32; + softcap = 32.9; } else if (level > 79) { hardcap = 54; - softcap = 31; + softcap = 31.9; } else if (level > 74) { hardcap = 53; - softcap = 30; + softcap = 30.9; } else if (level > 69) { hardcap = 53; - softcap = 28; + softcap = 28.9; } else if (level > 64) { hardcap = 53; - softcap = 26; + softcap = 26.9; } else if (level > 63) { hardcap = 50; - softcap = 24; + softcap = 24.9; } else if (level > 61) { hardcap = 47; - softcap = 24; + softcap = 24.9; } else if (level > 59) { hardcap = 45; - softcap = 24; + softcap = 24.9; } else if (level > 54) { hardcap = 40; - softcap = 20; + softcap = 20.9; } else if (level > 50) { hardcap = 38; - softcap = 18; + softcap = 18.9; } else if (level > 44) { hardcap = 36; - softcap = 17; + softcap = 17.9; } else if (level > 29) { hardcap = 34; - softcap = 16; + softcap = 16.9; } else if (level > 14) { hardcap = 32; - softcap = 15; + softcap = 15.9; } - int weight = IsClient() ? CastToClient()->CalcCurrentWeight()/10 : 0; + + double weight = IsClient() ? CastToClient()->CalcCurrentWeight()/10.0 : 0; + if (weight < hardcap - 1) { - int temp = level + 5; + double temp = level + 5; if (weight > softcap) { double redux = (weight - softcap) * 6.66667; - redux = (100.0 - std::min(100.0, redux)) * 0.01; - temp = std::max(0, static_cast(temp * redux)); + redux = (100.0 - redux) * 0.01; + temp = temp * redux; } - ac_bonus = (4 * temp) / 3; + ac_bonus = (4.0 * temp) / 3; + //LogError("weight[{}] temp[{}] ac_bonus[{}]", weight, temp, ac_bonus); } else if (weight > hardcap + 1) { - int temp = level + 5; + double temp = level + 5; double multiplier = std::min(1.0, (weight - (hardcap - 10.0)) / 100.0); - temp = (4 * temp) / 3; + temp = (4.0 * temp) / 3; ac_bonus -= static_cast(temp * multiplier); } } From f968d0df4c9a0493ceb5535d31d764a74d2cfa7d Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Thu, 30 Jan 2020 15:04:06 -0500 Subject: [PATCH 04/11] Reduce changes to those suggested by @mackal --- zone/attack.cpp | 54 ++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index da8dd6e3d..724a8575a 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -655,92 +655,92 @@ double Mob::GetSoftcapReturns() int Mob::GetClassRaceACBonus() { + int ac_bonus = 0; + auto level = GetLevel(); + if (GetClass() == MONK) { int ac_bonus = 0; auto level = GetLevel(); if (GetClass() == MONK) { int hardcap = 30; - double softcap = 14.9; + int softcap = 14; if (level > 99) { hardcap = 58; - softcap = 35.9; + softcap = 35; } else if (level > 94) { hardcap = 57; - softcap = 34.9; + softcap = 34; } else if (level > 89) { hardcap = 56; - softcap = 33.9; + softcap = 33; } else if (level > 84) { hardcap = 55; - softcap = 32.9; + softcap = 32; } else if (level > 79) { hardcap = 54; - softcap = 31.9; + softcap = 31; } else if (level > 74) { hardcap = 53; - softcap = 30.9; + softcap = 30; } else if (level > 69) { hardcap = 53; - softcap = 28.9; + softcap = 28; } else if (level > 64) { hardcap = 53; - softcap = 26.9; + softcap = 26; } else if (level > 63) { hardcap = 50; - softcap = 24.9; + softcap = 24; } else if (level > 61) { hardcap = 47; - softcap = 24.9; + softcap = 24; } else if (level > 59) { hardcap = 45; - softcap = 24.9; + softcap = 24; } else if (level > 54) { hardcap = 40; - softcap = 20.9; + softcap = 20; } else if (level > 50) { hardcap = 38; - softcap = 18.9; + softcap = 18; } else if (level > 44) { hardcap = 36; - softcap = 17.9; + softcap = 17; } else if (level > 29) { hardcap = 34; - softcap = 16.9; + softcap = 16; } else if (level > 14) { hardcap = 32; - softcap = 15.9; + softcap = 15; } - - double weight = IsClient() ? CastToClient()->CalcCurrentWeight()/10.0 : 0; - + double weight = IsClient() ? CastToClient()->CalcCurrentWeight()/10.0:0; if (weight < hardcap - 1) { double temp = level + 5; if (weight > softcap) { - double redux = (weight - softcap) * 6.66667; - redux = (100.0 - redux) * 0.01; - temp = temp * redux; + double redux = static_cast(weight - softcap) * 6.66667; + redux = (100.0 - std::min(100.0, redux)) * 0.01; + temp = std::max(0.0, temp * redux); } - ac_bonus = (4.0 * temp) / 3; - //LogError("weight[{}] temp[{}] ac_bonus[{}]", weight, temp, ac_bonus); + ac_bonus = static_cast((4.0 * temp) / 3.0); } else if (weight > hardcap + 1) { double temp = level + 5; - double multiplier = std::min(1.0, (weight - (hardcap - 10.0)) / 100.0); - temp = (4.0 * temp) / 3; + double multiplier = std::min(1.0, (weight - (static_cast(hardcap) - 10.0)) / 100.0); + temp = (4.0 * temp) / 3.0; ac_bonus -= static_cast(temp * multiplier); } } From bcb08f99f089329f768f0f60eb5ad477ca10ef3d Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Thu, 30 Jan 2020 15:05:41 -0500 Subject: [PATCH 05/11] Update attack.cpp --- zone/attack.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index 724a8575a..f532fc04a 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -655,9 +655,6 @@ double Mob::GetSoftcapReturns() int Mob::GetClassRaceACBonus() { - int ac_bonus = 0; - auto level = GetLevel(); - if (GetClass() == MONK) { int ac_bonus = 0; auto level = GetLevel(); if (GetClass() == MONK) { From 83ad9c86dbed0545de661774baf03dd973e57f3f Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Thu, 30 Jan 2020 15:19:02 -0500 Subject: [PATCH 06/11] Update attack.cpp --- zone/attack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index f532fc04a..308592041 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -724,7 +724,7 @@ int Mob::GetClassRaceACBonus() hardcap = 32; softcap = 15; } - double weight = IsClient() ? CastToClient()->CalcCurrentWeight()/10.0:0; + int weight = IsClient() ? CastToClient()->CalcCurrentWeight()/10 : 0; if (weight < hardcap - 1) { double temp = level + 5; if (weight > softcap) { From 50a39057e4bfd36141d69aa16539b60bdbfa1dca Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 1 Feb 2020 19:27:15 -0500 Subject: [PATCH 07/11] Update QuestReward_Struct --- common/eq_packet_structs.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index 53d7021ba..3fe2430db 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -35,6 +35,7 @@ static const uint32 MAX_MERC = 100; static const uint32 MAX_MERC_GRADES = 10; static const uint32 MAX_MERC_STANCES = 10; static const uint32 BLOCKED_BUFF_COUNT = 20; +static const uint32 QUESTREWARD_COUNT = 8; /* @@ -2180,14 +2181,7 @@ struct QuestReward_Struct /*024*/ uint32 silver; // Gives silver to the client /*028*/ uint32 gold; // Gives gold to the client /*032*/ uint32 platinum; // Gives platinum to the client - /*036*/ uint32 item_id; - /*040*/ uint32 unknown040; - /*044*/ uint32 unknown044; - /*048*/ uint32 unknown048; - /*052*/ uint32 unknown052; - /*056*/ uint32 unknown056; - /*060*/ uint32 unknown060; - /*064*/ uint32 unknown064; + /*036*/ int32 item_id[QUESTREWARD_COUNT]; // -1 for nothing /*068*/ }; From b02e87cce72a9a413de3213aeaa91883e2ce26bc Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 1 Feb 2020 19:54:26 -0500 Subject: [PATCH 08/11] Fix Client::QuestReward for struct adjustment --- zone/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client.cpp b/zone/client.cpp index 9ea27869a..eb157dc2f 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -8539,7 +8539,7 @@ void Client::QuestReward(Mob* target, uint32 copper, uint32 silver, uint32 gold, qr->silver = silver; qr->gold = gold; qr->platinum = platinum; - qr->item_id = itemid; + qr->item_id[0] = itemid; qr->exp_reward = exp; if (copper > 0 || silver > 0 || gold > 0 || platinum > 0) From ab3d65b2ea344fed0f6bf1fdcc5b92ce0ec2989c Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Sat, 1 Feb 2020 20:29:48 -0500 Subject: [PATCH 09/11] Fix FixZ regarding the use of model in npc_types This fix only impacts those that use the model field in npc_types to override race on the client. GetModel() returns model if set, otherwise race. As a refresher, the model field is there so the server can still see a mob as its base race for things like bane, while the client can use a new model. FixZ needs to know about this. --- zone/waypoints.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 0bd18edbf..65f4fd099 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -771,7 +771,7 @@ void Mob::FixZ(int32 z_find_offset /*= 5*/, bool fix_client_z /*= false*/) { float Mob::GetZOffset() const { float offset = 3.125f; - switch (race) { + switch (GetModel()) { case RACE_BASILISK_436: offset = 0.577f; break; From 59903313e4c46ff8b7cae6b8c7eb7b6d46a35f82 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 1 Feb 2020 22:20:19 -0500 Subject: [PATCH 10/11] Expand Lua's Client QuestReward function You can now use it to summon up to 8 items ex: `e.other:QuestReward(e.self, {items = {28745, 28092}, exp = 250})` This expands the version that takes a table. The new item is a table (in the main table) called items, which needs to be auto keyed like the example above. If you also provide the old itemid key, it will be ignored if the items is there. --- zone/client.cpp | 36 ++++++++++++++++++++++++++++++ zone/client.h | 1 + zone/lua_client.cpp | 54 ++++++++++++++++++++++++++++++++++----------- 3 files changed, 78 insertions(+), 13 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index eb157dc2f..acbb7cc74 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -8566,6 +8566,42 @@ void Client::QuestReward(Mob* target, uint32 copper, uint32 silver, uint32 gold, safe_delete(outapp); } +void Client::QuestReward(Mob* target, const QuestReward_Struct &reward, bool faction) +{ + auto outapp = new EQApplicationPacket(OP_Sound, sizeof(QuestReward_Struct)); + memset(outapp->pBuffer, 0, sizeof(QuestReward_Struct)); + QuestReward_Struct* qr = (QuestReward_Struct*)outapp->pBuffer; + + memcpy(qr, &reward, sizeof(QuestReward_Struct)); + + // not set in caller because reasons + qr->mob_id = target->GetID(); // Entity ID for the from mob name + + if (reward.copper > 0 || reward.silver > 0 || reward.gold > 0 || reward.platinum > 0) + AddMoneyToPP(reward.copper, reward.silver, reward.gold, reward.platinum, false); + + for (int i = 0; i < QUESTREWARD_COUNT; ++i) + if (reward.item_id[i] > 0) + SummonItem(reward.item_id[i], 0, 0, 0, 0, 0, 0, false, EQEmu::invslot::slotCursor); + + if (faction) + { + if (target->IsNPC()) + { + int32 nfl_id = target->CastToNPC()->GetNPCFactionID(); + SetFactionLevel(CharacterID(), nfl_id, GetBaseClass(), GetBaseRace(), GetDeity(), true); + qr->faction = target->CastToNPC()->GetPrimaryFaction(); + qr->faction_mod = 1; // Too lazy to get real value, not sure if this is even used by client anyhow. + } + } + + if (reward.exp_reward> 0) + AddEXP(reward.exp_reward); + + QueuePacket(outapp, true, Client::CLIENT_CONNECTED); + safe_delete(outapp); +} + void Client::SendHPUpdateMarquee(){ if (!this || !this->IsClient() || !this->current_hp || !this->max_hp) return; diff --git a/zone/client.h b/zone/client.h index 4ff431520..300073bb5 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1282,6 +1282,7 @@ public: int32 GetMeleeDamage(Mob* other, bool GetMinDamage = false); void QuestReward(Mob* target, uint32 copper = 0, uint32 silver = 0, uint32 gold = 0, uint32 platinum = 0, uint32 itemid = 0, uint32 exp = 0, bool faction = false); + void QuestReward(Mob* target, const QuestReward_Struct &reward, bool faction); // TODO: Fix faction processing void ResetHPUpdateTimer() { hpupdate_timer.Start(); } diff --git a/zone/lua_client.cpp b/zone/lua_client.cpp index 14c009b12..9d0873360 100644 --- a/zone/lua_client.cpp +++ b/zone/lua_client.cpp @@ -1385,18 +1385,23 @@ void Lua_Client::QuestReward(Lua_Mob target, luabind::adl::object reward) { return; } - uint32 copper = 0; - uint32 silver = 0; - uint32 gold = 0; - uint32 platinum = 0; - uint32 itemid = 0; - uint32 exp = 0; + QuestReward_Struct quest_reward; + quest_reward.mob_id = 0; + quest_reward.target_id = self->GetID(); + quest_reward.copper = 0; + quest_reward.silver = 0; + quest_reward.gold = 0; + quest_reward.platinum = 0; + quest_reward.exp_reward = 0; + quest_reward.faction = 0; + quest_reward.faction_mod = 0; bool faction = false; + std::fill(std::begin(quest_reward.item_id), std::end(quest_reward.item_id), -1); auto cur = reward["copper"]; if (luabind::type(cur) != LUA_TNIL) { try { - copper = luabind::object_cast(cur); + quest_reward.copper = luabind::object_cast(cur); } catch (luabind::cast_failed &) { } } @@ -1404,7 +1409,7 @@ void Lua_Client::QuestReward(Lua_Mob target, luabind::adl::object reward) { cur = reward["silver"]; if (luabind::type(cur) != LUA_TNIL) { try { - silver = luabind::object_cast(cur); + quest_reward.silver = luabind::object_cast(cur); } catch (luabind::cast_failed &) { } } @@ -1412,7 +1417,7 @@ void Lua_Client::QuestReward(Lua_Mob target, luabind::adl::object reward) { cur = reward["gold"]; if (luabind::type(cur) != LUA_TNIL) { try { - gold = luabind::object_cast(cur); + quest_reward.gold = luabind::object_cast(cur); } catch (luabind::cast_failed &) { } } @@ -1420,7 +1425,7 @@ void Lua_Client::QuestReward(Lua_Mob target, luabind::adl::object reward) { cur = reward["platinum"]; if (luabind::type(cur) != LUA_TNIL) { try { - platinum = luabind::object_cast(cur); + quest_reward.platinum = luabind::object_cast(cur); } catch (luabind::cast_failed &) { } } @@ -1428,7 +1433,30 @@ void Lua_Client::QuestReward(Lua_Mob target, luabind::adl::object reward) { cur = reward["itemid"]; if (luabind::type(cur) != LUA_TNIL) { try { - itemid = luabind::object_cast(cur); + quest_reward.item_id[0] = luabind::object_cast(cur); + } catch (luabind::cast_failed &) { + } + } + + // if you define both an itemid and items table, the itemid is thrown away + // should we error? + cur = reward["items"]; + if (luabind::type(cur) == LUA_TTABLE) { + try { + // assume they defined a compatible table + for (int i = 1; i <= QUESTREWARD_COUNT; ++i) { + auto item = cur[i]; + int cur_value = -1; + if (luabind::type(item) != LUA_TNIL) { + try { + cur_value = luabind::object_cast(item); + } catch (luabind::cast_failed &) { + } + } else { + break; + } + quest_reward.item_id[i - 1] = cur_value; + } } catch (luabind::cast_failed &) { } } @@ -1436,7 +1464,7 @@ void Lua_Client::QuestReward(Lua_Mob target, luabind::adl::object reward) { cur = reward["exp"]; if (luabind::type(cur) != LUA_TNIL) { try { - exp = luabind::object_cast(cur); + quest_reward.exp_reward = luabind::object_cast(cur); } catch (luabind::cast_failed &) { } } @@ -1449,7 +1477,7 @@ void Lua_Client::QuestReward(Lua_Mob target, luabind::adl::object reward) { } } - self->QuestReward(target, copper, silver, gold, platinum, itemid, exp, faction); + self->QuestReward(target, quest_reward, faction); } bool Lua_Client::IsDead() { From 424b669cbbe574764d121d65f97722e01a92c906 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 2 Feb 2020 16:39:46 -0500 Subject: [PATCH 11/11] Target not required for newer clients in QuestReward --- zone/client.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index acbb7cc74..6b366afba 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -8533,7 +8533,7 @@ void Client::QuestReward(Mob* target, uint32 copper, uint32 silver, uint32 gold, memset(outapp->pBuffer, 0, sizeof(QuestReward_Struct)); QuestReward_Struct* qr = (QuestReward_Struct*)outapp->pBuffer; - qr->mob_id = target->GetID(); // Entity ID for the from mob name + qr->mob_id = target ? target->GetID() : 0; // Entity ID for the from mob name qr->target_id = GetID(); // The Client ID (this) qr->copper = copper; qr->silver = silver; @@ -8550,7 +8550,7 @@ void Client::QuestReward(Mob* target, uint32 copper, uint32 silver, uint32 gold, if (faction) { - if (target->IsNPC()) + if (target && target->IsNPC()) { int32 nfl_id = target->CastToNPC()->GetNPCFactionID(); SetFactionLevel(CharacterID(), nfl_id, GetBaseClass(), GetBaseRace(), GetDeity(), true); @@ -8575,7 +8575,7 @@ void Client::QuestReward(Mob* target, const QuestReward_Struct &reward, bool fac memcpy(qr, &reward, sizeof(QuestReward_Struct)); // not set in caller because reasons - qr->mob_id = target->GetID(); // Entity ID for the from mob name + qr->mob_id = target ? target->GetID() : 0; // Entity ID for the from mob name if (reward.copper > 0 || reward.silver > 0 || reward.gold > 0 || reward.platinum > 0) AddMoneyToPP(reward.copper, reward.silver, reward.gold, reward.platinum, false); @@ -8586,7 +8586,7 @@ void Client::QuestReward(Mob* target, const QuestReward_Struct &reward, bool fac if (faction) { - if (target->IsNPC()) + if (target && target->IsNPC()) { int32 nfl_id = target->CastToNPC()->GetNPCFactionID(); SetFactionLevel(CharacterID(), nfl_id, GetBaseClass(), GetBaseRace(), GetDeity(), true);