diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index ac6528860..f91107a14 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -2154,24 +2154,24 @@ struct Illusion_Struct_Old { // OP_Sound - Size: 68 struct QuestReward_Struct { -/*000*/ uint32 from_mob; // ID of mob awarding the client -/*004*/ uint32 unknown004; -/*008*/ uint32 unknown008; -/*012*/ uint32 unknown012; -/*016*/ uint32 unknown016; -/*020*/ uint32 unknown020; -/*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 unknown036; -/*040*/ uint32 unknown040; -/*044*/ uint32 unknown044; -/*048*/ uint32 unknown048; -/*052*/ uint32 unknown052; -/*056*/ uint32 unknown056; -/*060*/ uint32 unknown060; -/*064*/ uint32 unknown064; -/*068*/ + /*000*/ uint32 mob_id; // ID of mob awarding the client + /*004*/ uint32 target_id; + /*008*/ uint32 exp_reward; + /*012*/ uint32 faction; + /*016*/ int32 faction_mod; + /*020*/ uint32 copper; // Gives copper to the client + /*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; + /*068*/ }; // Size: 8 diff --git a/zone/client.cpp b/zone/client.cpp index c31de64fa..0aa5510ff 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -7588,7 +7588,7 @@ FACTION_VALUE Client::GetFactionLevel(uint32 char_id, uint32 npc_id, uint32 p_ra } //Sets the characters faction standing with the specified NPC. -void Client::SetFactionLevel(uint32 char_id, uint32 npc_id, uint8 char_class, uint8 char_race, uint8 char_deity) +void Client::SetFactionLevel(uint32 char_id, uint32 npc_id, uint8 char_class, uint8 char_race, uint8 char_deity, bool quest) { int32 faction_id[MAX_NPC_FACTIONS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int32 npc_value[MAX_NPC_FACTIONS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -7615,6 +7615,15 @@ void Client::SetFactionLevel(uint32 char_id, uint32 npc_id, uint8 char_class, ui database.GetFactionData(&fm, GetClass(), GetRace(), GetDeity(), faction_id[i]); + if (quest) + { + //The ole switcheroo + if (npc_value[i] > 0) + npc_value[i] = -abs(npc_value[i]); + else if (npc_value[i] < 0) + npc_value[i] = abs(npc_value[i]); + } + // Adjust the amount you can go up or down so the resulting range // is PERSONAL_MAX - PERSONAL_MIN // @@ -8584,3 +8593,42 @@ bool Client::TextLink::GenerateLinkBody(std::string& textLinkBody, const TextLin if (textLinkBody.length() != EmuConstants::TEXT_LINK_BODY_LENGTH) { return false; } return true; } + +void Client::QuestReward(Mob* target, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, uint32 itemid, uint32 exp, bool faction) { + + EQApplicationPacket* outapp = new EQApplicationPacket(OP_Sound, sizeof(QuestReward_Struct)); + memset(outapp->pBuffer, 0, sizeof(outapp->pBuffer)); + QuestReward_Struct* qr = (QuestReward_Struct*)outapp->pBuffer; + + qr->mob_id = target->GetID(); // Entity ID for the from mob name + qr->target_id = GetID(); // The Client ID (this) + qr->copper = copper; + qr->silver = silver; + qr->gold = gold; + qr->platinum = platinum; + qr->item_id = itemid; + qr->exp_reward = exp; + + if (copper > 0 || silver > 0 || gold > 0 || platinum > 0) + AddMoneyToPP(copper, silver, gold, platinum, false); + + if (itemid > 0) + SummonItem(itemid, 0, 0, 0, 0, 0, 0, false, MainPowerSource); + + 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 (exp > 0) + AddEXP(exp); + + QueuePacket(outapp, false, Client::CLIENT_CONNECTED); + safe_delete(outapp); +} \ No newline at end of file diff --git a/zone/client.h b/zone/client.h index 533db7b04..38c5911e0 100644 --- a/zone/client.h +++ b/zone/client.h @@ -611,7 +611,7 @@ public: void SendFactionMessage(int32 tmpvalue, int32 faction_id, int32 faction_before_hit, int32 totalvalue, uint8 temp, int32 this_faction_min, int32 this_faction_max); void UpdatePersonalFaction(int32 char_id, int32 npc_value, int32 faction_id, int32 *current_value, int32 temp, int32 this_faction_min, int32 this_faction_max); - void SetFactionLevel(uint32 char_id, uint32 npc_id, uint8 char_class, uint8 char_race, uint8 char_deity); + void SetFactionLevel(uint32 char_id, uint32 npc_id, uint8 char_class, uint8 char_race, uint8 char_deity, bool quest = false); void SetFactionLevel2(uint32 char_id, int32 faction_id, uint8 char_class, uint8 char_race, uint8 char_deity, int32 value, uint8 temp); int32 GetRawItemAC(); uint16 GetCombinedAC_TEST(); @@ -1254,6 +1254,7 @@ public: virtual int32 Tune_GetMeleeMitDmg(Mob* GM, Mob *attacker, int32 damage, int32 minhit, float mit_rating, float atk_rating); 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); protected: friend class Mob; void CalcItemBonuses(StatBonuses* newbon); diff --git a/zone/lua_client.cpp b/zone/lua_client.cpp index ac0ddcf99..47607b705 100644 --- a/zone/lua_client.cpp +++ b/zone/lua_client.cpp @@ -1255,6 +1255,46 @@ void Lua_Client::PlayMP3(std::string file) self->PlayMP3(file.c_str()); } +void Lua_Client::QuestReward(Lua_Mob target) { + Lua_Safe_Call_Void(); + self->QuestReward(target); +} + +void Lua_Client::QuestReward(Lua_Mob target, uint32 copper) { + Lua_Safe_Call_Void(); + self->QuestReward(target, copper); +} + +void Lua_Client::QuestReward(Lua_Mob target, uint32 copper, uint32 silver) { + Lua_Safe_Call_Void(); + self->QuestReward(target, copper, silver); +} + +void Lua_Client::QuestReward(Lua_Mob target, uint32 copper, uint32 silver, uint32 gold) { + Lua_Safe_Call_Void(); + self->QuestReward(target, copper, silver, gold); +} + +void Lua_Client::QuestReward(Lua_Mob target, uint32 copper, uint32 silver, uint32 gold, uint32 platinum) { + Lua_Safe_Call_Void(); + self->QuestReward(target, copper, silver, gold, platinum); +} + +void Lua_Client::QuestReward(Lua_Mob target, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, uint32 itemid) { + Lua_Safe_Call_Void(); + self->QuestReward(target, copper, silver, gold, platinum, itemid); +} + +void Lua_Client::QuestReward(Lua_Mob target, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, uint32 itemid, uint32 exp) { + Lua_Safe_Call_Void(); + self->QuestReward(target, copper, silver, gold, platinum, itemid, exp); +} + +void Lua_Client::QuestReward(Lua_Mob target, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, uint32 itemid, uint32 exp, bool faction) { + Lua_Safe_Call_Void(); + self->QuestReward(target, copper, silver, gold, platinum, itemid, exp, faction); +} + luabind::scope lua_register_client() { return luabind::class_("Client") .def(luabind::constructor<>()) @@ -1504,7 +1544,15 @@ luabind::scope lua_register_client() { .def("SetConsumption", (void(Lua_Client::*)(int, int))&Lua_Client::SetConsumption) .def("SendMarqueeMessage", (void(Lua_Client::*)(uint32, uint32, uint32, uint32, uint32, std::string))&Lua_Client::SendMarqueeMessage) .def("SendColoredText", (void(Lua_Client::*)(uint32, std::string))&Lua_Client::SendColoredText) - .def("PlayMP3", (void(Lua_Client::*)(std::string))&Lua_Client::PlayMP3); + .def("PlayMP3", (void(Lua_Client::*)(std::string))&Lua_Client::PlayMP3) + .def("QuestReward", (void(Lua_Client::*)(Lua_Mob))&Lua_Client::QuestReward) + .def("QuestReward", (void(Lua_Client::*)(Lua_Mob, uint32))&Lua_Client::QuestReward) + .def("QuestReward", (void(Lua_Client::*)(Lua_Mob, uint32, uint32))&Lua_Client::QuestReward) + .def("QuestReward", (void(Lua_Client::*)(Lua_Mob, uint32, uint32, uint32))&Lua_Client::QuestReward) + .def("QuestReward", (void(Lua_Client::*)(Lua_Mob, uint32, uint32, uint32, uint32))&Lua_Client::QuestReward) + .def("QuestReward", (void(Lua_Client::*)(Lua_Mob, uint32, uint32, uint32, uint32, uint32))&Lua_Client::QuestReward) + .def("QuestReward", (void(Lua_Client::*)(Lua_Mob, uint32, uint32, uint32, uint32, uint32, uint32))&Lua_Client::QuestReward) + .def("QuestReward", (void(Lua_Client::*)(Lua_Mob, uint32, uint32, uint32, uint32, uint32, uint32, bool))&Lua_Client::QuestReward); } luabind::scope lua_register_inventory_where() { diff --git a/zone/lua_client.h b/zone/lua_client.h index e2b0a6614..8f930fc26 100644 --- a/zone/lua_client.h +++ b/zone/lua_client.h @@ -278,6 +278,14 @@ public: void SendMarqueeMessage(uint32 type, uint32 priority, uint32 fade_in, uint32 fade_out, uint32 duration, std::string msg); void SendColoredText(uint32 type, std::string msg); void PlayMP3(std::string file); + void QuestReward(Lua_Mob target); + void QuestReward(Lua_Mob target, uint32 copper); + void QuestReward(Lua_Mob target, uint32 copper, uint32 silver); + void QuestReward(Lua_Mob target, uint32 copper, uint32 silver, uint32 gold); + void QuestReward(Lua_Mob target, uint32 copper, uint32 silver, uint32 gold, uint32 platinum); + void QuestReward(Lua_Mob target, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, uint32 itemid); + void QuestReward(Lua_Mob target, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, uint32 itemid, uint32 exp); + void QuestReward(Lua_Mob target, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, uint32 itemid, uint32 exp, bool faction); }; #endif diff --git a/zone/lua_mob.cpp b/zone/lua_mob.cpp index 04d11566a..036af2072 100644 --- a/zone/lua_mob.cpp +++ b/zone/lua_mob.cpp @@ -1590,26 +1590,6 @@ void Lua_Mob::SendIllusionPacket(luabind::adl::object illusion) { beard, aa_title, drakkin_heritage, drakkin_tattoo, drakkin_details, size); } -void Lua_Mob::QuestReward(Lua_Client c) { - Lua_Safe_Call_Void(); - self->QuestReward(c); -} - -void Lua_Mob::QuestReward(Lua_Client c, uint32 silver) { - Lua_Safe_Call_Void(); - self->QuestReward(c, silver); -} - -void Lua_Mob::QuestReward(Lua_Client c, uint32 silver, uint32 gold) { - Lua_Safe_Call_Void(); - self->QuestReward(c, silver, gold); -} - -void Lua_Mob::QuestReward(Lua_Client c, uint32 silver, uint32 gold, uint32 platinum) { - Lua_Safe_Call_Void(); - self->QuestReward(c, silver, gold, platinum); -} - void Lua_Mob::CameraEffect(uint32 duration, uint32 intensity) { Lua_Safe_Call_Void(); self->CameraEffect(duration, intensity); @@ -2132,10 +2112,6 @@ luabind::scope lua_register_mob() { .def("SetRace", (void(Lua_Mob::*)(int))&Lua_Mob::SetRace) .def("SetGender", (void(Lua_Mob::*)(int))&Lua_Mob::SetGender) .def("SendIllusionPacket", (void(Lua_Mob::*)(luabind::adl::object))&Lua_Mob::SendIllusionPacket) - .def("QuestReward", (void(Lua_Mob::*)(Lua_Client))&Lua_Mob::QuestReward) - .def("QuestReward", (void(Lua_Mob::*)(Lua_Client,uint32))&Lua_Mob::QuestReward) - .def("QuestReward", (void(Lua_Mob::*)(Lua_Client,uint32,uint32))&Lua_Mob::QuestReward) - .def("QuestReward", (void(Lua_Mob::*)(Lua_Client,uint32,uint32,uint32))&Lua_Mob::QuestReward) .def("CameraEffect", (void(Lua_Mob::*)(uint32,uint32))&Lua_Mob::CameraEffect) .def("CameraEffect", (void(Lua_Mob::*)(uint32,uint32,Lua_Client))&Lua_Mob::CameraEffect) .def("CameraEffect", (void(Lua_Mob::*)(uint32,uint32,Lua_Client,bool))&Lua_Mob::CameraEffect) diff --git a/zone/lua_mob.h b/zone/lua_mob.h index f272cd440..3caf62839 100644 --- a/zone/lua_mob.h +++ b/zone/lua_mob.h @@ -296,10 +296,6 @@ public: void SetRace(int in); void SetGender(int in); void SendIllusionPacket(luabind::adl::object illusion); - void QuestReward(Lua_Client c); - void QuestReward(Lua_Client c, uint32 silver); - void QuestReward(Lua_Client c, uint32 silver, uint32 gold); - void QuestReward(Lua_Client c, uint32 silver, uint32 gold, uint32 platinum); void CameraEffect(uint32 duration, uint32 intensity); void CameraEffect(uint32 duration, uint32 intensity, Lua_Client c); void CameraEffect(uint32 duration, uint32 intensity, Lua_Client c, bool global); diff --git a/zone/mob.cpp b/zone/mob.cpp index b4c3370cb..05ec2015d 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -1910,22 +1910,6 @@ void Mob::SendTargetable(bool on, Client *specific_target) { safe_delete(outapp); } -void Mob::QuestReward(Client *c, uint32 silver, uint32 gold, uint32 platinum) { - - EQApplicationPacket* outapp = new EQApplicationPacket(OP_Sound, sizeof(QuestReward_Struct)); - QuestReward_Struct* qr = (QuestReward_Struct*) outapp->pBuffer; - - qr->from_mob = GetID(); // Entity ID for the from mob name - qr->silver = silver; - qr->gold = gold; - qr->platinum = platinum; - - if(c) - c->QueuePacket(outapp, false, Client::CLIENT_CONNECTED); - - safe_delete(outapp); -} - void Mob::CameraEffect(uint32 duration, uint32 intensity, Client *c, bool global) { diff --git a/zone/mob.h b/zone/mob.h index 3b0702e60..0d412a666 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -493,7 +493,6 @@ public: inline bool CheckLastLosState() const { return last_los_check; } //Quest - void QuestReward(Client *c = nullptr, uint32 silver = 0, uint32 gold = 0, uint32 platinum = 0); void CameraEffect(uint32 duration, uint32 intensity, Client *c = nullptr, bool global = false); inline bool GetQglobal() const { return qglobal; } diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index a885922e9..b9ba00622 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -6188,6 +6188,55 @@ XS(XS_Client_GetTargetRingZ) XSRETURN(1); } +XS(XS_Client_QuestReward); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Client_QuestReward) +{ + dXSARGS; + if (items < 1 || items > 9) + Perl_croak(aTHX_ "Usage: Client::QuestReward(THIS, mob, copper, silver, gold, platinum, itemid, exp, faction)"); + { + Client* THIS; + Mob * mob = nullptr; + int32 copper = 0; + int32 silver = 0; + int32 gold = 0; + int32 platinum = 0; + int32 itemid = 0; + int32 exp = 0; + bool faction = false; + + if (sv_derived_from(ST(0), "THIS")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + if (items > 1) { + if (sv_derived_from(ST(1), "mob")) { + IV tmp = SvIV((SV*)SvRV(ST(1))); + mob = INT2PTR(Mob *, tmp); + } + else + Perl_croak(aTHX_ "mob is not of type Mob"); + if (mob == nullptr) + Perl_croak(aTHX_ "mob is nullptr, avoiding crash."); + } + if (items > 2) { copper = (int32)SvIV(ST(2)); } + if (items > 3) { silver = (int32)SvIV(ST(3)); } + if (items > 4) { gold = (int32)SvIV(ST(4)); } + if (items > 5) { platinum = (int32)SvIV(ST(5)); } + if (items > 6) { itemid = (int32)SvIV(ST(6)); } + if (items > 7) { exp = (int32)SvIV(ST(7)); } + if (items > 8) { faction = (bool)SvIV(ST(8)); } + + THIS->QuestReward(mob, copper, silver, gold, platinum, itemid, exp, faction); + } + XSRETURN_EMPTY; +} + #ifdef __cplusplus extern "C" #endif @@ -6432,7 +6481,7 @@ XS(boot_Client) newXSproto(strcpy(buf, "GetTargetRingX"), XS_Client_GetTargetRingX, file, "$$"); newXSproto(strcpy(buf, "GetTargetRingY"), XS_Client_GetTargetRingY, file, "$$"); newXSproto(strcpy(buf, "GetTargetRingZ"), XS_Client_GetTargetRingZ, file, "$$"); - + newXSproto(strcpy(buf, "QuestReward"), XS_Client_QuestReward, file, "$$;$$$$$$$"); XSRETURN_YES; } diff --git a/zone/perl_mob.cpp b/zone/perl_mob.cpp index 5eeb7be1b..f5ab99cd6 100644 --- a/zone/perl_mob.cpp +++ b/zone/perl_mob.cpp @@ -7027,47 +7027,6 @@ XS(XS_Mob_SendAppearanceEffect) XSRETURN_EMPTY; } -XS(XS_Mob_QuestReward); /* prototype to pass -Wmissing-prototypes */ -XS(XS_Mob_QuestReward) -{ - dXSARGS; - if (items < 1 || items > 5) - Perl_croak(aTHX_ "Usage: Mob::QuestReward(THIS, client, silver, gold, platinum)"); - { - Mob * THIS; - Client* client = nullptr; - int32 silver = 0; - int32 gold = 0; - int32 platinum = 0; - - if (sv_derived_from(ST(0), "Mob")) { - IV tmp = SvIV((SV*)SvRV(ST(0))); - THIS = INT2PTR(Mob *,tmp); - } - else - Perl_croak(aTHX_ "THIS is not of type Mob"); - if(THIS == nullptr) - Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - - if (items > 1) { - if (sv_derived_from(ST(1), "Client")) { - IV tmp = SvIV((SV*)SvRV(ST(1))); - client = INT2PTR(Client *,tmp); - } - else - Perl_croak(aTHX_ "client is not of type Client"); - if(client == nullptr) - Perl_croak(aTHX_ "client is nullptr, avoiding crash."); - } - if (items > 2) { silver = (int32)SvIV(ST(2)); } - if (items > 3) { gold = (int32)SvIV(ST(3)); } - if (items > 4) { platinum = (int32)SvIV(ST(4)); } - - THIS->QuestReward(client, silver, gold, platinum); - } - XSRETURN_EMPTY; -} - XS(XS_Mob_SetFlyMode); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_SetFlyMode) { @@ -8660,7 +8619,6 @@ XS(boot_Mob) newXSproto(strcpy(buf, "SendIllusion"), XS_Mob_SendIllusion, file, "$$;$$$$$$$$$$$$"); newXSproto(strcpy(buf, "MakeTempPet"), XS_Mob_MakeTempPet, file, "$$;$$$$"); newXSproto(strcpy(buf, "TypesTempPet"), XS_Mob_TypesTempPet, file, "$$;$$$$$"); - newXSproto(strcpy(buf, "QuestReward"), XS_Mob_QuestReward, file, "$$;$$$"); newXSproto(strcpy(buf, "CameraEffect"), XS_Mob_CameraEffect, file, "$$;$$$"); newXSproto(strcpy(buf, "SpellEffect"), XS_Mob_SpellEffect, file, "$$;$$$$$$"); newXSproto(strcpy(buf, "TempName"), XS_Mob_TempName, file, "$:$");