From 134074dfa9c94a1dacd62c7e088f33e18acd94ff Mon Sep 17 00:00:00 2001 From: Lee Date: Mon, 2 Jul 2018 13:36:23 +0100 Subject: [PATCH 1/9] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 0d73b01..a36474a 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,9 @@ AzerothCore v1.0.1+ If you need to change the module configuration, go to your server configuration folder (e.g. **etc**), copy `PvPScript.conf.dist` to `PvPScript.conf` and edit it as you prefer. +# Show your appreciation +[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SBJFTAJKUNEXC) + From baa96ae82573c250fe89cd73098f5680ddd87461 Mon Sep 17 00:00:00 2001 From: drsi Date: Thu, 9 Aug 2018 19:02:22 +0800 Subject: [PATCH 2/9] .h has a error. --- src/PvPScript.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PvPScript.cpp b/src/PvPScript.cpp index df32b38..c9e29d5 100644 --- a/src/PvPScript.cpp +++ b/src/PvPScript.cpp @@ -2,7 +2,7 @@ #include "Player.h" #include "Creature.h" #include "AccountMgr.h" -#include "ScriptedAI\ScriptedCreature.h" +#include "ScriptedAI/ScriptedCreature.h" #include "ScriptMgr.h" #include "Define.h" #include "GossipDef.h" @@ -194,4 +194,4 @@ void AddPvPScripts() { new PvPScript(); new PvPScript_conf(); -} \ No newline at end of file +} From 2eb07a17745119b39c916777a47a4739e2bd1680 Mon Sep 17 00:00:00 2001 From: talamortis Date: Sun, 13 Jan 2019 23:15:32 +0000 Subject: [PATCH 3/9] Fixed for new build. --- src/PvPScript.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/PvPScript.cpp b/src/PvPScript.cpp index c9e29d5..5cfe3fc 100644 --- a/src/PvPScript.cpp +++ b/src/PvPScript.cpp @@ -1,4 +1,4 @@ -#include "Configuration/Config.h" +#include "Configuration/Config.h" #include "Player.h" #include "Creature.h" #include "AccountMgr.h" @@ -7,6 +7,7 @@ #include "Define.h" #include "GossipDef.h" #include "Pet.h" +#include "Item.h" uint32 SUMMON_CHEST; uint32 KillAnnounce; @@ -88,7 +89,7 @@ class PvPScript : public PlayerScript if (Item* pItem = killed->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) { uint8 slot = pItem->GetSlot(); - LootStoreItem storeItem = LootStoreItem(pItem->GetEntry(), 100, LOOT_MODE_DEFAULT, 0, 1, 1); + LootStoreItem storeItem = LootStoreItem(pItem->GetEntry(), 0, 100, 0, LOOT_MODE_DEFAULT, 0, 1, 1); go->loot.AddItem(storeItem); killed->DestroyItem(INVENTORY_SLOT_BAG_0, slot, true); } @@ -155,7 +156,7 @@ class PvPScript : public PlayerScript if (Item* pItem = killed->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) { uint8 slot = pItem->GetSlot(); - LootStoreItem storeItem = LootStoreItem(pItem->GetEntry(), 100, LOOT_MODE_DEFAULT, 0, 1, 1); + LootStoreItem storeItem = LootStoreItem(pItem->GetEntry(), 0, 100, 0, LOOT_MODE_DEFAULT, 0, 1, 1); go->loot.AddItem(storeItem); killed->DestroyItem(INVENTORY_SLOT_BAG_0, slot, true); } From 0cf474d011dac3b6e4bc7d841d9a21663ab46707 Mon Sep 17 00:00:00 2001 From: Lee Date: Mon, 11 Mar 2024 20:29:14 +0000 Subject: [PATCH 4/9] Fix Compile --- src/PS_loader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PS_loader.cpp b/src/PS_loader.cpp index 9f42f16..f2187c3 100644 --- a/src/PS_loader.cpp +++ b/src/PS_loader.cpp @@ -1,6 +1,6 @@ void AddPvPScripts(); -void Addmod_pvpscriptScripts() +void Addmod_PvPScriptScripts() { AddPvPScripts(); } From ba814085da093e85f998863fbb663e7c6f4b02bf Mon Sep 17 00:00:00 2001 From: Lee Date: Mon, 11 Mar 2024 20:58:31 +0000 Subject: [PATCH 5/9] Script update Updated Script --- src/PvPScript.cpp | 145 +++++++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 85 deletions(-) diff --git a/src/PvPScript.cpp b/src/PvPScript.cpp index 9e0d5fe..1235ac8 100644 --- a/src/PvPScript.cpp +++ b/src/PvPScript.cpp @@ -19,7 +19,7 @@ class PvPScript : public PlayerScript public: PvPScript() : PlayerScript("PvPScript") {} - void OnPlayerKilledByCreature(Creature* killer, Player* killed) + void OnPlayerKilledByCreature(Creature* killer, Player* killed, bool& durabilityLoss) { if (!sConfigMgr->GetOption("PvPChest", true)) return; @@ -35,31 +35,11 @@ class PvPScript : public PlayerScript if (Pet* pet = killer->ToPet()) if (Player* owner = pet->GetOwner()) { - if (owner->GetSession()->GetRemoteAddress() == killed->GetSession()->GetRemoteAddress()) - return; - - // Dont drop loot if killed is not worth honor for owner - if (!owner->isHonorOrXPTarget(killed)) + if (!CheckConditions(owner, killed)) return; } - // if player has Ress sickness do not spawn chest - if (killed->HasAura(15007)) - return; - - //Gurubashi Arena - if (killed->GetMapId() == 0 && killed->GetZoneId() == 33) - for (int i = 0; i < int(AreatoIgnore.size()); ++i) - if (killed->GetAreaId() == AreatoIgnore[i]) - return; - - - // Dont drop chess if player is in battleground - if (killed->GetMap()->IsBattlegroundOrArena()) - return; - - //Dont Drop chest if player is no worth XP - if (!killed->isHonorOrXPTarget(killer->GetOwner())) + if (!CheckConditions(nullptr, killed)) return; // if target is killed and killer is pet @@ -67,31 +47,10 @@ class PvPScript : public PlayerScript { if (GameObject* go = killer->SummonGameObject(SummonChest, killed->GetPositionX(), killed->GetPositionY(), killed->GetPositionZ(), killed->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, chestDespawn, false)) { - switch (KillAnnounce) - { - case 1: //Announce in chat handler - ChatHandler(killed->GetSession()).PSendSysMessage("You have been killed by player [%s] ", name.c_str()); - break; - case 2: //Announce in notifaction - killed->GetSession()->SendNotification("You have been slain by [%s]", name.c_str()); - break; - case 3: // Announe in Notifaction and chathandler - killed->GetSession()->SendNotification("You have been slain by [%s]", name.c_str()); - ChatHandler(killed->GetSession()).PSendSysMessage("You have been killed by player [%s] ", name.c_str()); - break; - } - + AnnounceKill(KillAnnounce, killed, name.c_str()); killer->AddGameObject(go); go->SetOwnerGUID(ObjectGuid::Empty); //This is so killed players can also loot the chest - - for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) - if (Item* pItem = killed->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - { - uint8 slot = pItem->GetSlot(); - LootStoreItem storeItem = LootStoreItem(pItem->GetEntry(), 0, 100, 0, LOOT_MODE_DEFAULT, 0, 1, 1); - go->loot.AddItem(storeItem); - killed->DestroyItem(INVENTORY_SLOT_BAG_0, slot, true); - } + SpawnChest(killed, go); } } } @@ -103,65 +62,81 @@ class PvPScript : public PlayerScript std::string name = killer->GetName(); + if (!CheckConditions(killer, killed)) + return; + + if (!killed->IsAlive()) + { + if (GameObject* go = killer->SummonGameObject(SummonChest, killed->GetPositionX(), killed->GetPositionY(), killed->GetPositionZ(), killed->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, chestDespawn, false)) + { + AnnounceKill(KillAnnounce, killed, name.c_str()); + killer->AddGameObject(go); + go->SetOwnerGUID(ObjectGuid::Empty); //This is so killed players can also loot the chest + SpawnChest(killed, go); + } + } + } + + bool CheckConditions(Player* killer, Player* killed) + { //if killer has same IP as death player do not drop loot as its cheating! if (spawnchestIP) if (killer->GetSession()->GetRemoteAddress() == killed->GetSession()->GetRemoteAddress()) - return; + return false; // if player has Ress sickness do not spawn chest if (killed->HasAura(15007)) - return; + return false; // If player kills self do not drop loot if (killer->GetGUID() == killed->GetGUID()) - return; - - //Gurubashi Arena - if (killed->GetMapId() == 0 && killed->GetZoneId() == 33) - for (int i = 0; i < int(AreatoIgnore.size()); ++i) - if (killed->GetAreaId() == AreatoIgnore[i]) - return; + return false; // if killer not worth honnor do not drop loot if (!killer->isHonorOrXPTarget(killed)) - return; + return false; // Dont drop chess if player is in battleground if (killed->GetMap()->IsBattlegroundOrArena()) - return; + return false; - if (!killed->IsAlive()) - { - if (GameObject* go = killer->SummonGameObject(SummonChest, killed->GetPositionX(), killed->GetPositionY(), killed->GetPositionZ(), killed->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, chestDespawn, false)) - { - switch (KillAnnounce) - { - case 1: //Announce in chat handler - ChatHandler(killed->GetSession()).PSendSysMessage("You have been killed by player [%s] ", name.c_str()); - break; - case 2: //Announce in notifaction - killed->GetSession()->SendNotification("You have been slain by [%s]", name.c_str()); - break; - case 3: // Announe in Notifaction and chathandler - killed->GetSession()->SendNotification("You have been slain by [%s]", name.c_str()); - ChatHandler(killed->GetSession()).PSendSysMessage("You have been killed by player [%s] ", name.c_str()); - break; - } + //Gurubashi Arena + if (killed->GetMapId() == 0 && killed->GetZoneId() == 33) + for (int i = 0; i < int(AreatoIgnore.size()); ++i) + if (killed->GetAreaId() == AreatoIgnore[i]) + return false; - killer->AddGameObject(go); - go->SetOwnerGUID(ObjectGuid::Empty); //This is so killed players can also loot the chest + return true; + } - for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) - if (Item* pItem = killed->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - { - uint8 slot = pItem->GetSlot(); - LootStoreItem storeItem = LootStoreItem(pItem->GetEntry(), 0, 100, 0, LOOT_MODE_DEFAULT, 0, 1, 1); - go->loot.AddItem(storeItem); - killed->DestroyItem(INVENTORY_SLOT_BAG_0, slot, true); - } - } + void AnnounceKill(uint32 phase, Player* killed, std::string name) + { + switch (phase) + { + case 1: //Announce in chat handler + ChatHandler(killed->GetSession()).PSendSysMessage("You have been killed by player [%s] ", name.c_str()); + break; + case 2: //Announce in notifaction + killed->GetSession()->SendNotification("You have been slain by [%s]", name.c_str()); + break; + case 3: // Announe in Notifaction and chathandler + killed->GetSession()->SendNotification("You have been slain by [%s]", name.c_str()); + ChatHandler(killed->GetSession()).PSendSysMessage("You have been killed by player [%s] ", name.c_str()); + break; } } + + void SpawnChest(Player* killed, GameObject* go) + { + for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) + if (Item* pItem = killed->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + { + uint8 slot = pItem->GetSlot(); + LootStoreItem storeItem = LootStoreItem(pItem->GetEntry(), 0, 100, 0, LOOT_MODE_DEFAULT, 0, 1, 1); + go->loot.AddItem(storeItem); + killed->DestroyItem(INVENTORY_SLOT_BAG_0, slot, true); + } + } }; class PvPScript_conf : public WorldScript From 1de14203a1608315cdc42bf0e2b04ac87a0884f8 Mon Sep 17 00:00:00 2001 From: Lee Date: Mon, 11 Mar 2024 21:29:10 +0000 Subject: [PATCH 6/9] Fix Build Fixed build, removed my extra checks for required hook --- src/PvPScript.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PvPScript.cpp b/src/PvPScript.cpp index 1235ac8..c98868e 100644 --- a/src/PvPScript.cpp +++ b/src/PvPScript.cpp @@ -19,7 +19,7 @@ class PvPScript : public PlayerScript public: PvPScript() : PlayerScript("PvPScript") {} - void OnPlayerKilledByCreature(Creature* killer, Player* killed, bool& durabilityLoss) + void OnPlayerKilledByCreature(Creature* killer, Player* killed/*, bool& durabilityLoss*/ ) { if (!sConfigMgr->GetOption("PvPChest", true)) return; From e1b19dcac2462c08ea9c10ab163775cf8033421d Mon Sep 17 00:00:00 2001 From: Lee Date: Tue, 12 Mar 2024 19:25:14 +0000 Subject: [PATCH 7/9] Update script Updated Script --- src/PvPScript.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/PvPScript.cpp b/src/PvPScript.cpp index c98868e..93559a0 100644 --- a/src/PvPScript.cpp +++ b/src/PvPScript.cpp @@ -19,14 +19,13 @@ class PvPScript : public PlayerScript public: PvPScript() : PlayerScript("PvPScript") {} - void OnPlayerKilledByCreature(Creature* killer, Player* killed/*, bool& durabilityLoss*/ ) + void OnPlayerKilledByCreature(Creature* killer, Player* killed/*, bool& durabilityLoss*/) { if (!sConfigMgr->GetOption("PvPChest", true)) return; if (!killer->IsPet()) - return; - + return; std::string name = killer->GetOwner()->GetName(); @@ -45,13 +44,8 @@ class PvPScript : public PlayerScript // if target is killed and killer is pet if (!killed->IsAlive() && killer->IsPet()) { - if (GameObject* go = killer->SummonGameObject(SummonChest, killed->GetPositionX(), killed->GetPositionY(), killed->GetPositionZ(), killed->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, chestDespawn, false)) - { - AnnounceKill(KillAnnounce, killed, name.c_str()); - killer->AddGameObject(go); - go->SetOwnerGUID(ObjectGuid::Empty); //This is so killed players can also loot the chest - SpawnChest(killed, go); - } + AnnounceKill(KillAnnounce, killed, name.c_str()); + SpawnChest(killer, killed); } } @@ -67,13 +61,18 @@ class PvPScript : public PlayerScript if (!killed->IsAlive()) { - if (GameObject* go = killer->SummonGameObject(SummonChest, killed->GetPositionX(), killed->GetPositionY(), killed->GetPositionZ(), killed->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, chestDespawn, false)) - { - AnnounceKill(KillAnnounce, killed, name.c_str()); - killer->AddGameObject(go); - go->SetOwnerGUID(ObjectGuid::Empty); //This is so killed players can also loot the chest - SpawnChest(killed, go); - } + SpawnChest(killer, killed); + AnnounceKill(KillAnnounce, killed, name.c_str()); + } + } + + void SpawnChest(Unit* killer, Player* killed) + { + if (GameObject* go = killer->SummonGameObject(SummonChest, killed->GetPositionX(), killed->GetPositionY(), killed->GetPositionZ(), killed->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, chestDespawn, false)) + { + killer->AddGameObject(go); + go->SetOwnerGUID(ObjectGuid::Empty); //This is so killed players can also loot the chest + AddChestItems(killed, go); } } @@ -126,7 +125,7 @@ class PvPScript : public PlayerScript } } - void SpawnChest(Player* killed, GameObject* go) + void AddChestItems(Player* killed, GameObject* go) { for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) if (Item* pItem = killed->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) From d1ea87482108d0ca48493ff0768152d065758824 Mon Sep 17 00:00:00 2001 From: Lee <161210428+Talamorts1@users.noreply.github.com> Date: Thu, 14 Mar 2024 17:40:57 +0000 Subject: [PATCH 8/9] Update PS_loader.cpp --- src/PS_loader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PS_loader.cpp b/src/PS_loader.cpp index f2187c3..864e4b0 100644 --- a/src/PS_loader.cpp +++ b/src/PS_loader.cpp @@ -1,6 +1,6 @@ void AddPvPScripts(); -void Addmod_PvPScriptScripts() +void Addmod_pvpscriptScripts()() { AddPvPScripts(); } From 6d92186ce7f8e07c5968ca4f5c6f38cc2132eacd Mon Sep 17 00:00:00 2001 From: Lee <161210428+Talamorts1@users.noreply.github.com> Date: Sun, 17 Mar 2024 10:45:05 +0000 Subject: [PATCH 9/9] Update PS_loader.cpp --- src/PS_loader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PS_loader.cpp b/src/PS_loader.cpp index 864e4b0..9f42f16 100644 --- a/src/PS_loader.cpp +++ b/src/PS_loader.cpp @@ -1,6 +1,6 @@ void AddPvPScripts(); -void Addmod_pvpscriptScripts()() +void Addmod_pvpscriptScripts() { AddPvPScripts(); }