diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..eb64e2f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +tab_width = 4 +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 80 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6667b6a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,104 @@ +## AUTO-DETECT +## Handle line endings automatically for files detected as +## text and leave all files detected as binary untouched. +## This will handle all files NOT defined below. +* text eol=lf + +# Text +*.conf text +*.conf.dist text +*.cmake text + +## Scripts +*.sh text +*.fish text +*.lua text + +## SQL +*.sql text + +## C++ +*.c text +*.cc text +*.cxx text +*.cpp text +*.c++ text +*.hpp text +*.h text +*.h++ text +*.hh text + +## For documentation + +# Documents +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain + +## DOCUMENTATION +*.markdown text +*.md text +*.mdwn text +*.mdown text +*.mkd text +*.mkdn text +*.mdtxt text +*.mdtext text +*.txt text +AUTHORS text +CHANGELOG text +CHANGES text +CONTRIBUTING text +COPYING text +copyright text +COPYRIGHT text +INSTALL text +license text +LICENSE text +NEWS text +readme text +README text +TODO text + +## GRAPHICS +*.ai binary +*.bmp binary +*.eps binary +*.gif binary +*.ico binary +*.jng binary +*.jp2 binary +*.jpg binary +*.jpeg binary +*.jpx binary +*.jxr binary +*.pdf binary +*.png binary +*.psb binary +*.psd binary +*.svg text +*.svgz binary +*.tif binary +*.tiff binary +*.wbmp binary +*.webp binary + + +## ARCHIVES +*.7z binary +*.gz binary +*.jar binary +*.rar binary +*.tar binary +*.zip binary + +## EXECUTABLES +*.exe binary +*.pyc binary diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..5610d2b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,72 @@ +name: Bug report +description: Create a bug report to help us improve. +title: "Bug: " +body: + - type: textarea + id: current + attributes: + label: Current Behaviour + description: | + Description of the problem or issue here. + Include entries of affected creatures / items / quests / spells etc. + If this is a crash, post the crashlog (upload to https://gist.github.com/) and include the link here. + Never upload files! Use GIST for text and YouTube for videos! + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected Behaviour + description: | + Tell us what should happen instead. + validations: + required: true + - type: textarea + id: reproduce + attributes: + label: Steps to reproduce the problem + description: | + What does someone else need to do to encounter the same bug? + placeholder: | + 1. Step 1 + 2. Step 2 + 3. Step 3 + validations: + required: true + - type: textarea + id: extra + attributes: + label: Extra Notes + description: | + Do you have any extra notes that can help solve the issue that does not fit any other field? + placeholder: | + None + validations: + required: false + - type: textarea + id: commit + attributes: + label: AC rev. hash/commit + description: | + Copy the result of the `.server debug` command (if you need to run it from the client get a prat addon) + validations: + required: true + - type: input + id: os + attributes: + label: Operating system + description: | + The Operating System the Server is running on. + i.e. Windows 11 x64, Debian 10 x64, macOS 12, Ubuntu 20.04 + validations: + required: true + - type: textarea + id: custom + attributes: + label: Custom changes or Modules + description: | + List which custom changes or modules you have applied, i.e. Eluna module, etc. + placeholder: | + None + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..58f79dd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,33 @@ +name: Feature request +description: Suggest an idea for this project +title: "Feature: " +body: + - type: markdown + attributes: + value: | + Thank you for taking your time to fill out a feature request. Remember to fill out all fields including the title above. + An issue that is not properly filled out will be closed. + - type: textarea + id: description + attributes: + label: Describe your feature request or suggestion in detail + description: | + A clear and concise description of what you want to happen. + validations: + required: true + - type: textarea + id: solution + attributes: + label: Describe a possible solution to your feature or suggestion in detail + description: | + A clear and concise description of any alternative solutions or features you've considered. + validations: + required: false + - type: textarea + id: additional + attributes: + label: Additional context + description: | + Add any other context or screenshots about the feature request here. + validations: + required: false diff --git a/.github/workflows/core-build.yml b/.github/workflows/core-build.yml new file mode 100644 index 0000000..921c9eb --- /dev/null +++ b/.github/workflows/core-build.yml @@ -0,0 +1,12 @@ +name: core-build +on: + push: + branches: + - 'master' + pull_request: + +jobs: + build: + uses: azerothcore/reusable-workflows/.github/workflows/core_build_modules.yml@main + with: + module_repo: ${{ github.event.repository.name }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3bfd0f7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -sudo: required -dist: trusty # (14.04) -# xenial (16.04) is not supported yet - -language: cpp -compiler: - - clang - -git: - depth: 1 - -before_install: - - sudo apt-get -y install build-essential libtool make cmake cmake-data openssl - - sudo apt-get -y install libssl-dev libmysqlclient-dev libmysql++-dev libreadline6-dev zlib1g-dev libbz2-dev libace-dev - - git config user.email "travis@build.bot" && git config user.name "Travis CI" - - git tag -a -m "Travis build" init - -install: - - cd .. - - git clone --depth=1 --branch=master https://github.com/azerothcore/azerothcore-wotlk.git azerothcore - - mv mod-duelreset azerothcore/modules - - cd azerothcore - - git submodule update --init --recursive - - - mysql -uroot -e 'create database test_mysql;' - - cd bin - - cmake ../ -DWITH_WARNINGS=1 -DWITH_COREDEBUG=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DTOOLS=0 -DSCRIPTS=1 -DSERVERS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=check_install - - cd .. - -script: - - $CXX --version - - mysql -uroot < data/sql/create/create_mysql.sql - - cat data/sql/base/db_auth/*.sql | mysql -uacore -pacore auth - - cat data/sql/base/db_characters/*.sql | mysql -uacore -pacore characters - - cat data/sql/base/db_world/*.sql | mysql -uacore -pacore world - - cat data/sql/updates/db_auth/*.sql | mysql -uacore -pacore auth - - cat data/sql/updates/db_characters/*.sql | mysql -uacore -pacore characters - - cat data/sql/updates/db_world/*.sql | mysql -uacore -pacore world - - mysql -uroot < data/sql/create/drop_mysql.sql - - cd bin - - make -j 8 -k && make install - - cd check_install/bin diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index e82bc1c..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -CU_SET_PATH("CMAKE_PvPScript_DIR" "${CMAKE_CURRENT_LIST_DIR}") - -AC_ADD_SCRIPT("${CMAKE_CURRENT_LIST_DIR}/src/PvPScript.cpp") - -AC_ADD_SCRIPT_LOADER("PvP" "${CMAKE_CURRENT_LIST_DIR}/src/loader.h") - -CU_ADD_HOOK(AFTER_WORLDSERVER_CMAKE "${CMAKE_CURRENT_LIST_DIR}/src/cmake/after_ws_install.cmake") - -message("-- PvPScript CONFIGURED --") diff --git a/README.md b/README.md index b5f2782..05699ab 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,19 @@ -# PvPScript +# ![logo](https://raw.githubusercontent.com/azerothcore/azerothcore.github.io/master/images/logo-github.png) AzerothCore -This is a module for [AzerothCore](http://www.azerothcore.org) +## PvPScript + +### This is a module for [AzerothCore](http://www.azerothcore.org) + +- Latest build status with azerothcore: + +[![Build Status](https://github.com/azerothcore/mod-pvpscript/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/azerothcore/mod-pvpscript) Current features: --**Puts a players armor in a chest for other players to loot if they are killed. Only works in open world. +-**Puts a players armor in a chest for other players to loot if they are killed. Only works in open world.** Upcoming features: - ## Requirements PvPScript Module currently requires: @@ -30,4 +35,5 @@ 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) diff --git a/conf/PvPScript.conf.dist b/conf/PvPScript.conf.dist index 42a4017..5e206f4 100644 --- a/conf/PvPScript.conf.dist +++ b/conf/PvPScript.conf.dist @@ -5,33 +5,38 @@ # Description: Enable or Disable this feature for the players to drop loot. # Default: Enabled = 1 # Disabled = 0 + PvPChest = 1 # # ChestID # Description: allows the player to spawn the chest of their choice # Default: Enabled = 179697 -# +# + ChestID = "80000" # # KillAnnounce # Description: Announces to the player who killed them. # Config: Disable = "0" : Announce = "1" : Notifaction = "2" : Both = "3" -# +# + KillAnnounce = "1" # # ChestTimer # Description: The ammount of time the chest is in world before despawn (In Seconds) # Config: Default = 120 -# +# + ChestTimer = "120" # # spawnchestIP # Description: Allow the chest to spawn if player is on the same IP address # Config: Disable = "0" -# Enable = "1" do not spawn chest if same IP -# -spawnchestIP = "1" \ No newline at end of file +# Enable = "1" do not spawn chest if same IP +# + +spawnchestIP = "1" diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..21c9245 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,25 @@ + + +## Changes Proposed: +- +- + +## Issues Addressed: + +- Closes + +## SOURCE: + + +## Tests Performed: + +- +- + + +## How to Test the Changes: + + +1. +2. +3. diff --git a/src/PS_loader.cpp b/src/PS_loader.cpp new file mode 100644 index 0000000..9f42f16 --- /dev/null +++ b/src/PS_loader.cpp @@ -0,0 +1,6 @@ +void AddPvPScripts(); + +void Addmod_pvpscriptScripts() +{ + AddPvPScripts(); +} diff --git a/src/PvPScript.cpp b/src/PvPScript.cpp index 5cfe3fc..9e0d5fe 100644 --- a/src/PvPScript.cpp +++ b/src/PvPScript.cpp @@ -2,27 +2,26 @@ #include "Player.h" #include "Creature.h" #include "AccountMgr.h" -#include "ScriptedAI/ScriptedCreature.h" #include "ScriptMgr.h" #include "Define.h" #include "GossipDef.h" #include "Pet.h" -#include "Item.h" +#include "LootMgr.h" +#include "Chat.h" -uint32 SUMMON_CHEST; -uint32 KillAnnounce; +uint32 SummonChest, KillAnnounce; bool spawnchestIP; -uint32 chest_despawn; -std::vector AreatoIgnore = { 1741/*Gurubashi*/, 2177 }; +uint32 chestDespawn; +std::vector AreatoIgnore = { 1741 /*Gurubashi*/, 2177 }; class PvPScript : public PlayerScript { public: - PvPScript() : PlayerScript("PvPScript") {} + PvPScript() : PlayerScript("PvPScript") {} void OnPlayerKilledByCreature(Creature* killer, Player* killed) { - if (!sConfigMgr->GetBoolDefault("PvPChest", true)) + if (!sConfigMgr->GetOption("PvPChest", true)) return; if (!killer->IsPet()) @@ -50,7 +49,7 @@ class PvPScript : public PlayerScript //Gurubashi Arena if (killed->GetMapId() == 0 && killed->GetZoneId() == 33) - for (int i = 0; i < AreatoIgnore.size(); ++i) + for (int i = 0; i < int(AreatoIgnore.size()); ++i) if (killed->GetAreaId() == AreatoIgnore[i]) return; @@ -66,7 +65,7 @@ class PvPScript : public PlayerScript // if target is killed and killer is pet if (!killed->IsAlive() && killer->IsPet()) { - if (GameObject* go = killer->SummonGameObject(SUMMON_CHEST, killed->GetPositionX(), killed->GetPositionY(), killed->GetPositionZ(), killed->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, chest_despawn, false)) + 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) { @@ -83,7 +82,7 @@ class PvPScript : public PlayerScript } killer->AddGameObject(go); - go->SetOwnerGUID(0); //This is so killed players can also loot the chest + 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)) @@ -99,7 +98,7 @@ class PvPScript : public PlayerScript void OnPVPKill(Player* killer, Player* killed) { - if (!sConfigMgr->GetBoolDefault("PvPChest", true)) + if (!sConfigMgr->GetOption("PvPChest", true)) return; std::string name = killer->GetName(); @@ -119,7 +118,7 @@ class PvPScript : public PlayerScript //Gurubashi Arena if (killed->GetMapId() == 0 && killed->GetZoneId() == 33) - for (int i = 0; i < AreatoIgnore.size(); ++i) + for (int i = 0; i < int(AreatoIgnore.size()); ++i) if (killed->GetAreaId() == AreatoIgnore[i]) return; @@ -133,7 +132,7 @@ class PvPScript : public PlayerScript if (!killed->IsAlive()) { - if (GameObject* go = killer->SummonGameObject(SUMMON_CHEST, killed->GetPositionX(), killed->GetPositionY(), killed->GetPositionZ(), killed->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, chest_despawn, false)) + 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) { @@ -150,9 +149,9 @@ class PvPScript : public PlayerScript } killer->AddGameObject(go); - go->SetOwnerGUID(0); //This is so killed players can also loot the chest + 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) + 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(); @@ -172,21 +171,12 @@ class PvPScript_conf : public WorldScript void OnBeforeConfigLoad(bool reload) override { - if (!reload) { - std::string conf_path = _CONF_DIR; - std::string cfg_file = conf_path + "/PvPScript.conf"; - -#ifdef WIN32 - cfg_file = "PvPScript.conf"; -#endif - std::string cfg_def_file = cfg_file + ".dist"; - sConfigMgr->LoadMore(cfg_def_file.c_str()); - sConfigMgr->LoadMore(cfg_file.c_str()); - - SUMMON_CHEST = sConfigMgr->GetIntDefault("ChestID", 179697); - KillAnnounce = sConfigMgr->GetIntDefault("KillAnnounce", 1); - chest_despawn = sConfigMgr->GetIntDefault("ChestTimer", 120); - spawnchestIP = sConfigMgr->GetBoolDefault("spawnchestIP", true); + if (!reload) + { + SummonChest = sConfigMgr->GetOption("ChestID", 179697); + KillAnnounce = sConfigMgr->GetOption("KillAnnounce", 1); + chestDespawn = sConfigMgr->GetOption("ChestTimer", 120); + spawnchestIP = sConfigMgr->GetOption("spawnchestIP", true); } } }; diff --git a/src/cmake/after_ws_install.cmake b/src/cmake/after_ws_install.cmake deleted file mode 100644 index 821d878..0000000 --- a/src/cmake/after_ws_install.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if ( MSVC ) - add_custom_command(TARGET worldserver - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_PvPScript_DIR}/conf/PvPScript.conf.dist ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/ - ) -elseif ( MINGW ) - add_custom_command(TARGET worldserver - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_PvPScript_DIR}/conf/PvPScript.conf.dist ${CMAKE_BINARY_DIR}/bin/ - ) -endif() - -install(FILES "${CMAKE_PvPScript_DIR}/conf/PvPScript.conf.dist" DESTINATION ${CONF_DIR}) diff --git a/src/loader.h b/src/loader.h deleted file mode 100644 index 009aa38..0000000 --- a/src/loader.h +++ /dev/null @@ -1 +0,0 @@ -void AddPvPScripts(); \ No newline at end of file