From e3419657971e3016d242bb4d0e3b5a90ffcd3981 Mon Sep 17 00:00:00 2001 From: Yehonal Date: Thu, 17 Nov 2016 10:25:43 +0100 Subject: [PATCH] First version of Transmog Module for AC --- .gitignore | 50 ++ CMakeLists.txt | 6 + LICENSE | 223 ++++++++ conf/conf.sh.dist | 26 + conf/transmog.conf.dist | 206 +++++++ data/sql/db-characters/trasmorg.sql | 20 + data/sql/db-world/trasm_world_NPC.sql | 7 + data/sql/db-world/trasm_world_texts.sql | 20 + data/sql/updates/char/.dummy | 1 + data/sql/updates/world/.dummy | 1 + include.sh | 9 + src/CMakeLists.txt | 8 + src/Transmogrification.cpp | 716 ++++++++++++++++++++++++ src/Transmogrification.h | 152 +++++ src/cmake/after_ws.cmake | 13 + src/transmog_scripts.cpp | 473 ++++++++++++++++ src/transmog_scripts_loader.h | 12 + 17 files changed, 1943 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 LICENSE create mode 100644 conf/conf.sh.dist create mode 100644 conf/transmog.conf.dist create mode 100644 data/sql/db-characters/trasmorg.sql create mode 100644 data/sql/db-world/trasm_world_NPC.sql create mode 100644 data/sql/db-world/trasm_world_texts.sql create mode 100644 data/sql/updates/char/.dummy create mode 100644 data/sql/updates/world/.dummy create mode 100644 include.sh create mode 100644 src/CMakeLists.txt create mode 100644 src/Transmogrification.cpp create mode 100644 src/Transmogrification.h create mode 100644 src/cmake/after_ws.cmake create mode 100644 src/transmog_scripts.cpp create mode 100644 src/transmog_scripts_loader.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..92da74b --- /dev/null +++ b/.gitignore @@ -0,0 +1,50 @@ +!.gitignore + +!* + +# +#Generic +# + +.directory +.mailmap +*.orig +*.rej +*~ +.hg/ +*.kdev* +.DS_Store +CMakeLists.txt.user +*.bak +*.patch +*.diff +*.REMOTE.* +*.BACKUP.* +*.BASE.* +*.LOCAL.* + +# +# IDE & other softwares +# +/.settings/ +/.externalToolBuilders/* +# exclude in all levels +nbproject/ +.sync.ffs_db +*.kate-swp + +# +# Eclipse +# +*.pydevproject +.metadata +.gradle +tmp/ +*.tmp +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.project +.cproject diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..cba7b3c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +CU_SET_PATH("CMAKE_TRANSM_DIR" "${CMAKE_CURRENT_LIST_DIR}") +CU_SET_PATH("CMAKE_TRANSM_SRC_DIR" "${CMAKE_CURRENT_LIST_DIR}/src/") + +include("${CMAKE_TRANSM_SRC_DIR}/CMakeLists.txt") + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fcd586b --- /dev/null +++ b/LICENSE @@ -0,0 +1,223 @@ +Copyright (C) 2006 - 2016 AzerothShard All rights reserved. + +Acceptable Use; Safety-Critical Systems. Your use of the AzerothShard Materials must comply with the AzerothShard Acceptable Use Policy. +The AzerothShard Materials are not intended for use with life-critical or safety-critical systems, such as use in operation +of medical equipment, automated transportation systems, autonomous vehicles, aircraft or air traffic control, nuclear facilities, +manned spacecraft, or military use in connection with live combat. However, +this restriction will not apply in the event of the occurrence (certified by the United States Centers for Disease Control or successor body) +of a widespread viral infection transmitted via bites or contact with bodily fluids that causes human corpses to reanimate and seek to consume +living human flesh, blood, brain or nerve tissue and is likely to result in the fall of organized civilization. + + +GNU AFFERO GENERAL PUBLIC LICENSE + +Version 3, 19 November 2007 + +Copyright © 2007 Free Software Foundation, Inc. +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. + +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. + +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 them 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. + +Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. + +A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. + +The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. + +An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS + +0. Definitions. +"This License" refers to version 3 of the GNU Affero General Public License. + +"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. + +"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. + +To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. + +A "covered work" means either the unmodified Program or a work based on the Program. + +To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. + +To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. + +1. Source Code. +The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. + +A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. + +The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. + +The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. + +2. Basic Permissions. +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. + +3. Protecting Users' Legal Rights From Anti-Circumvention Law. +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. + +4. Conveying Verbatim Copies. +You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. + +5. Conveying Modified Source Versions. +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: + +a) The work must carry prominent notices stating that you modified it, and giving a relevant date. +b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". +c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. +d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. + +6. Conveying Non-Source Forms. +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: + +a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. +b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. +c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. +d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. +e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. + +A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. + +"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. + +7. Additional Terms. +"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: + +a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or +b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or +c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or +d) Limiting the use for publicity purposes of names of licensors or authors of the material; or +e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or +f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. +All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. + +8. Termination. +You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. + +9. Acceptance Not Required for Having Copies. +You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. + +10. Automatic Licensing of Downstream Recipients. +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. + +An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. + +11. Patents. +A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". + +A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. + +In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. + +A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. + +12. No Surrender of Others' Freedom. +If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. + +13. Remote Network Interaction; Use with the GNU General Public License. +Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. + +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. + +14. Revised Versions of this License. +The Free Software Foundation may publish revised and/or new versions of the GNU Affero 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 that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. + +15. Disclaimer of Warranty. +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. + +16. Limitation of Liability. +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. + +17. Interpretation of Sections 15 and 16. +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. + +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 state 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 Affero General Public License as + published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +Also add information on how to contact you by electronic and paper mail. + +If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. + +You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . diff --git a/conf/conf.sh.dist b/conf/conf.sh.dist new file mode 100644 index 0000000..1ea5b7a --- /dev/null +++ b/conf/conf.sh.dist @@ -0,0 +1,26 @@ +#!/bin/bash + +# +# CUSTOM +# + +DB_CHARACTERS_CUSTOM_PATHS+=( + $TRANSM_PATH_ROOT"/data/sql/db-characters/" +) + +DB_WORLD_CUSTOM_PATHS+=( + $TRANSM_PATH_ROOT"/data/sql/db-world/" +) + +# +# UPDATES +# + +DB_CHARACTERS_UPDATE_PATHS+=( + $TRANSM_PATH_ROOT"/data/sql/updates/char/" +) + +DB_WORLD_UPDATE_PATHS+=( + $TRANSM_PATH_ROOT"/data/sql/updates/world/" +) + diff --git a/conf/transmog.conf.dist b/conf/transmog.conf.dist new file mode 100644 index 0000000..5952fca --- /dev/null +++ b/conf/transmog.conf.dist @@ -0,0 +1,206 @@ +[worldserver] + + +################################################################################################### +# Transmogrification config +################################################################################################### +# +# SETTINGS +# +# Logger.custom.transmog +# Description: Transmogrification logging setting, see logger settings +# Default: 3, Console Server +# +# Transmogrification.EnableTransmogInfo +# Description: Enables / Disables the info button for transmogrification +# Default: 1 +# +# Transmogrification.TransmogNpcText +# Description: The npc_text entry of the info menu for transmogrification +# Default: 50000 +# +# Transmogrification.Allowed +# Description: A list of item entries that are allowed for transmogrification (skips quality and CanUseItem check) +# Example: "25 35674 5623" +# Default: "" +# +# Transmogrification.NotAllowed +# Description: A list of item entries that are NOT allowed for transmogrification +# Example: "25 35674 5623" +# Default: "" + +Transmogrification.EnableTransmogInfo = 1 +Transmogrification.TransmogNpcText = 50000 + +Transmogrification.Allowed = "" +Transmogrification.NotAllowed = "" + +# +# COPPER COST +# +# Transmogrification.ScaledCostModifier +# Description: A multiplier for the default gold cost (change to 0 for no default cost) +# Default: 1.0 +# +# Transmogrification.CopperCost +# Description: Cost added on top of other costs (can be negative) +# Default: 0 +# +# For custom gold cost set ScaledCostModifier to 0.0 and CopperCost to what ever cost you want + +Transmogrification.ScaledCostModifier = 1.0 +Transmogrification.CopperCost = 0 + +# +# TOKEN COST +# +# Transmogrification.RequireToken +# Description: Adds/disables token cost +# Default: 0 +# +# Transmogrification.TokenEntry +# Description: Entry of the token item +# Default: 49426 +# +# Transmogrification.TokenAmount +# Description: Amount of tokens required +# Default: 1 + +Transmogrification.RequireToken = 0 +Transmogrification.TokenEntry = 49426 +Transmogrification.TokenAmount = 1 + +# +# REQUIREMENTS +# +# Transmogrification.AllowPoor +# Description: Allow poor quality items to be used as source and target items +# Default: 0 +# +# Transmogrification.AllowCommon +# Description: Allow common quality items to be used as source and target items +# Default: 0 +# +# Transmogrification.AllowUncommon +# Description: Allow uncommon quality items to be used as source and target items +# Default: 1 +# +# Transmogrification.AllowRare +# Description: Allow rare quality items to be used as source and target items +# Default: 1 +# +# Transmogrification.AllowEpic +# Description: Allow epic quality items to be used as source and target items +# Default: 1 +# +# Transmogrification.AllowLegendary +# Description: Allow legendary quality items to be used as source and target items +# Default: 0 +# +# Transmogrification.AllowArtifact +# Description: Allow artifact quality items to be used as source and target items +# Default: 0 +# +# Transmogrification.AllowHeirloom +# Description: Allow heirloom quality items to be used as source and target items +# Default: 1 +# +# Transmogrification.AllowMixedArmorTypes +# Description: Allow cloth items to be transmogrified with plate for example +# Default: 0 +# +# Transmogrification.AllowMixedWeaponTypes +# Description: Allow axe to be transmogrified with dagger for example +# Default: 0 +# +# Transmogrification.AllowFishingPoles +# Description: Allow fishing poles to be transmogrified +# Default: 0 +# +# Transmogrification.IgnoreReqRace +# Description: Ignore required race for source items +# Default: 0 +# +# Transmogrification.IgnoreReqClass +# Description: Ignore required class for source items +# Default: 0 +# +# Transmogrification.IgnoreReqSkill +# Description: Ignore required skill for source items +# Default: 0 +# +# Transmogrification.IgnoreReqSpell +# Description: Ignore required spell for source items +# Default: 0 +# +# Transmogrification.IgnoreReqLevel +# Description: Ignore required level for source items +# Default: 0 +# +# Transmogrification.IgnoreReqEvent +# Description: Ignore required event for source items +# Default: 0 +# +# Transmogrification.IgnoreReqStats +# Description: Ignore stat count > 0 requirement for source items +# Default: 0 + +Transmogrification.AllowPoor = 0 +Transmogrification.AllowCommon = 0 +Transmogrification.AllowUncommon = 1 +Transmogrification.AllowRare = 1 +Transmogrification.AllowEpic = 1 +Transmogrification.AllowLegendary = 0 +Transmogrification.AllowArtifact = 0 +Transmogrification.AllowHeirloom = 1 + +Transmogrification.AllowMixedArmorTypes = 0 +Transmogrification.AllowMixedWeaponTypes = 0 +Transmogrification.AllowFishingPoles = 0 + +Transmogrification.IgnoreReqRace = 0 +Transmogrification.IgnoreReqClass = 0 +Transmogrification.IgnoreReqSkill = 0 +Transmogrification.IgnoreReqSpell = 0 +Transmogrification.IgnoreReqLevel = 0 +Transmogrification.IgnoreReqEvent = 0 +Transmogrification.IgnoreReqStats = 0 + +# +# SET FEATURE +# +# Transmogrification.EnableSets +# Description: Enables / Disables the set feature. If you want permanent disable, check Transmogrification.h +# Default: 1 +# +# Transmogrification.MaxSets +# Description: Maximum amount of sets a player can save (hardcap at 25) +# Default: 10 +# +# Transmogrification.EnableSetInfo +# Description: Enables / Disables the info button for set fature +# Default: 1 +# +# Transmogrification.SetNpcText +# Description: The npc_text entry of the info menu for the set feature +# Default: 50001 +# +# Transmogrification.SetCostModifier +# Description: A multiplier for the default gold cost (all costs summed together) (change to 0 for no default cost) +# Default: 3.0 +# +# Transmogrification.SetCopperCost +# Description: Cost added on top of other costs (can be negative) +# Default: 0 + +Transmogrification.EnableSets = 1 +Transmogrification.MaxSets = 10 + +Transmogrification.EnableSetInfo = 1 +Transmogrification.SetNpcText = 50001 + +Transmogrification.SetCostModifier = 3.0 +Transmogrification.SetCopperCost = 0 + +# +################################################################################################### diff --git a/data/sql/db-characters/trasmorg.sql b/data/sql/db-characters/trasmorg.sql new file mode 100644 index 0000000..d993086 --- /dev/null +++ b/data/sql/db-characters/trasmorg.sql @@ -0,0 +1,20 @@ +-- Dumping structure for table tc_c.custom_transmogrification +CREATE TABLE IF NOT EXISTS `custom_transmogrification` ( + `GUID` int(10) unsigned NOT NULL COMMENT 'Item guidLow', + `FakeEntry` int(10) unsigned NOT NULL COMMENT 'Item entry', + `Owner` int(10) unsigned NOT NULL COMMENT 'Player guidLow', + PRIMARY KEY (`GUID`), + KEY `Owner` (`Owner`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='6_2'; + +-- Data exporting was unselected. + + +-- Dumping structure for table tc_c.custom_transmogrification_sets +CREATE TABLE IF NOT EXISTS `custom_transmogrification_sets` ( + `Owner` int(10) unsigned NOT NULL COMMENT 'Player guidlow', + `PresetID` tinyint(3) unsigned NOT NULL COMMENT 'Preset identifier', + `SetName` text COMMENT 'SetName', + `SetData` text COMMENT 'Slot1 Entry1 Slot2 Entry2', + PRIMARY KEY (`Owner`,`PresetID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='6_1'; diff --git a/data/sql/db-world/trasm_world_NPC.sql b/data/sql/db-world/trasm_world_NPC.sql new file mode 100644 index 0000000..5d558b1 --- /dev/null +++ b/data/sql/db-world/trasm_world_NPC.sql @@ -0,0 +1,7 @@ +SET +@Entry = 190010, +@Name = "Warpweaver"; +DELETE FROM `creature_template` WHERE `entry` = 190010; + +INSERT INTO `creature_template` (`entry`, `modelid1`, `modelid2`, `name`, `subname`, `IconName`, `gossip_menu_id`, `minlevel`, `maxlevel`, `exp`, `faction`, `npcflag`, `scale`, `rank`, `dmgschool`, `baseattacktime`, `rangeattacktime`, `unit_class`, `unit_flags`, `type`, `type_flags`, `lootid`, `pickpocketloot`, `skinloot`, `AIName`, `MovementType`, `InhabitType`, `HoverHeight`, `RacialLeader`, `movementId`, `RegenHealth`, `mechanic_immune_mask`, `flags_extra`, `ScriptName`) VALUES +(@Entry, 19646, 0, @Name, "Transmogrifier", NULL, 0, 80, 80, 2, 35, 1, 1, 0, 0, 2000, 0, 1, 0, 7, 138936390, 0, 0, 0, '', 0, 3, 1, 0, 0, 1, 0, 0, 'npc_transmogrifier'); diff --git a/data/sql/db-world/trasm_world_texts.sql b/data/sql/db-world/trasm_world_texts.sql new file mode 100644 index 0000000..bf2b81e --- /dev/null +++ b/data/sql/db-world/trasm_world_texts.sql @@ -0,0 +1,20 @@ +SET @TEXT_ID := 50000; +DELETE FROM `npc_text` WHERE `ID` IN (@TEXT_ID,@TEXT_ID+1); +INSERT INTO `npc_text` (`ID`, `text0_0`) VALUES +(@TEXT_ID, 'Transmogrification allows you to change how your items look like without changing the stats of the items.\r\nItems used in transmogrification are no longer refundable, tradeable and are bound to you.\r\nUpdating a menu updates the view and prices.\r\n\r\nNot everything can be transmogrified with eachother.\r\nRestrictions include but are not limited to:\r\nOnly armor and weapons can be transmogrified\r\nGuns, bows and crossbows can be transmogrified with eachother\r\nFishing poles can not be transmogrified\r\nYou must be able to equip both items used in the process.\r\n\r\nTransmogrifications stay on your items as long as you own them.\r\nIf you try to put the item in guild bank or mail it to someone else, the transmogrification is stripped.\r\n\r\nYou can also remove transmogrifications for free at the transmogrifier.'), +(@TEXT_ID+1, 'You can save your own transmogrification sets.\r\n\r\nTo save, first you must transmogrify your equipped items.\r\nThen when you go to the set management menu and go to save set menu,\r\nall items you have transmogrified are displayed so you see what you are saving.\r\nIf you think the set is fine, you can click to save the set and name it as you wish.\r\n\r\nTo use a set you can click the saved set in the set management menu and then select use set.\r\nIf the set has a transmogrification for an item that is already transmogrified, the old transmogrification is lost.\r\nNote that same transmogrification restrictions apply when trying to use a set as in normal transmogrification.\r\n\r\nTo delete a set you can go to the set\'s menu and select delete set.'); + +SET @STRING_ENTRY := 11100; +DELETE FROM `trinity_string` WHERE `entry` IN (@STRING_ENTRY+0,@STRING_ENTRY+1,@STRING_ENTRY+2,@STRING_ENTRY+3,@STRING_ENTRY+4,@STRING_ENTRY+5,@STRING_ENTRY+6,@STRING_ENTRY+7,@STRING_ENTRY+8,@STRING_ENTRY+9,@STRING_ENTRY+10); +INSERT INTO `trinity_string` (`entry`, `content_default`) VALUES +(@STRING_ENTRY+0, 'Item transmogrified'), +(@STRING_ENTRY+1, 'Equipment slot is empty'), +(@STRING_ENTRY+2, 'Invalid source item selected'), +(@STRING_ENTRY+3, 'Source item does not exist'), +(@STRING_ENTRY+4, 'Destination item does not exist'), +(@STRING_ENTRY+5, 'Selected items are invalid'), +(@STRING_ENTRY+6, 'Not enough money'), +(@STRING_ENTRY+7, 'You don\'t have enough tokens'), +(@STRING_ENTRY+8, 'Transmogrifications removed'), +(@STRING_ENTRY+9, 'There are no transmogrifications'), +(@STRING_ENTRY+10, 'Invalid name inserted'); diff --git a/data/sql/updates/char/.dummy b/data/sql/updates/char/.dummy new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/data/sql/updates/char/.dummy @@ -0,0 +1 @@ + diff --git a/data/sql/updates/world/.dummy b/data/sql/updates/world/.dummy new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/data/sql/updates/world/.dummy @@ -0,0 +1 @@ + diff --git a/include.sh b/include.sh new file mode 100644 index 0000000..1b3cc62 --- /dev/null +++ b/include.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +TRANSM_PATH_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/" && pwd )" + +source $TRANSM_PATH_ROOT"/conf/conf.sh.dist" + +if [ -f $TRANSM_PATH_ROOT"/conf/conf.sh" ]; then + source $TRANSM_PATH_ROOT"/conf/conf.sh" +fi diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..e5a0491 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,8 @@ +CU_SET_PATH("CMAKE_TRANSM_SRC_DIR" "${CMAKE_CURRENT_LIST_DIR}") + +AC_ADD_SCRIPT("${CMAKE_TRANSM_SRC_DIR}/transmog_scripts.cpp") +AC_ADD_SCRIPT("${CMAKE_TRANSM_SRC_DIR}/Transmogrification.cpp") + +CU_ADD_HOOK(AFTER_WORLDSERVER_CMAKE "${CMAKE_TRANSM_SRC_DIR}/cmake/after_ws.cmake") + +AC_ADD_SCRIPT_LOADER("Transmog" "${CMAKE_TRANSM_SRC_DIR}/transmog_scripts_loader.h") diff --git a/src/Transmogrification.cpp b/src/Transmogrification.cpp new file mode 100644 index 0000000..2c7fe2b --- /dev/null +++ b/src/Transmogrification.cpp @@ -0,0 +1,716 @@ +#include "Transmogrification.h" + +#ifdef PRESETS +void Transmogrification::PresetTransmog(Player* player, Item* itemTransmogrified, uint32 fakeEntry, uint8 slot) +{ + sLog->outDebug(LOG_FILTER_MODULES, "Transmogrification::PresetTransmog"); + + if (!EnableSets) + return; + if (!player || !itemTransmogrified) + return; + if (slot >= EQUIPMENT_SLOT_END) + return; + if (!CanTransmogrifyItemWithItem(player, itemTransmogrified->GetTemplate(), sObjectMgr->GetItemTemplate(fakeEntry))) + return; + + // [AZTH] Custom + if (GetFakeEntry(itemTransmogrified->GetGUID())) + DeleteFakeEntry(player, slot, itemTransmogrified); + + SetFakeEntry(player, fakeEntry, slot, itemTransmogrified); // newEntry + + + itemTransmogrified->UpdatePlayedTime(player); + + itemTransmogrified->SetOwnerGUID(player->GetGUID()); + itemTransmogrified->SetNotRefundable(player); + itemTransmogrified->ClearSoulboundTradeable(player); +} + +void Transmogrification::LoadPlayerSets(uint64 pGUID) +{ + sLog->outDebug(LOG_FILTER_MODULES, "Transmogrification::LoadPlayerSets"); + + for (presetData::iterator it = presetById[pGUID].begin(); it != presetById[pGUID].end(); ++it) + it->second.clear(); + + presetById[pGUID].clear(); + + presetByName[pGUID].clear(); + + QueryResult result = CharacterDatabase.PQuery("SELECT `PresetID`, `SetName`, `SetData` FROM `custom_transmogrification_sets` WHERE Owner = %u", GUID_LOPART(pGUID)); + if (result) + { + do + { + uint8 PresetID = (*result)[0].GetUInt8(); + std::string SetName = (*result)[1].GetString(); + std::istringstream SetData((*result)[2].GetString()); + while (SetData.good()) + { + uint32 slot; + uint32 entry; + SetData >> slot >> entry; + if (SetData.fail()) + break; + if (slot >= EQUIPMENT_SLOT_END) + { + sLog->outError("Item entry (FakeEntry: %u, playerGUID: %u, slot: %u, presetId: %u) has invalid slot, ignoring.", entry, GUID_LOPART(pGUID), slot, uint32(PresetID)); + continue; + } + if (sObjectMgr->GetItemTemplate(entry)) + presetById[pGUID][PresetID][slot] = entry; // Transmogrification::Preset(presetName, fakeEntry); + //else + //sLog->outError(LOG_FILTER_SQL, "Item entry (FakeEntry: %u, playerGUID: %u, slot: %u, presetId: %u) does not exist, ignoring.", entry, GUID_LOPART(pGUID), uint32(slot), uint32(PresetID)); + } + + if (!presetById[pGUID][PresetID].empty()) + { + presetByName[pGUID][PresetID] = SetName; + // load all presets anyways + //if (presetByName[pGUID].size() >= GetMaxSets()) + // break; + } + else // should be deleted on startup, so this never runs (shouldnt..) + { + presetById[pGUID].erase(PresetID); + CharacterDatabase.PExecute("DELETE FROM `custom_transmogrification_sets` WHERE Owner = %u AND PresetID = %u", GUID_LOPART(pGUID), PresetID); + } + } while (result->NextRow()); + } +} + +bool Transmogrification::GetEnableSets() const +{ + return EnableSets; +} +uint8 Transmogrification::GetMaxSets() const +{ + return MaxSets; +} +float Transmogrification::GetSetCostModifier() const +{ + return SetCostModifier; +} +int32 Transmogrification::GetSetCopperCost() const +{ + return SetCopperCost; +} + +void Transmogrification::UnloadPlayerSets(uint64 pGUID) +{ + for (presetData::iterator it = presetById[pGUID].begin(); it != presetById[pGUID].end(); ++it) + it->second.clear(); + presetById[pGUID].clear(); + + presetByName[pGUID].clear(); +} +#endif + +const char* Transmogrification::GetSlotName(uint8 slot, WorldSession* /*session*/) const +{ + sLog->outDebug(LOG_FILTER_MODULES, "Transmogrification::GetSlotName"); + + switch (slot) + { + case EQUIPMENT_SLOT_HEAD: return "Head";// session->GetTrinityString(LANG_SLOT_NAME_HEAD); + case EQUIPMENT_SLOT_SHOULDERS: return "Shoulders";// session->GetTrinityString(LANG_SLOT_NAME_SHOULDERS); + case EQUIPMENT_SLOT_BODY: return "Shirt";// session->GetTrinityString(LANG_SLOT_NAME_BODY); + case EQUIPMENT_SLOT_CHEST: return "Chest";// session->GetTrinityString(LANG_SLOT_NAME_CHEST); + case EQUIPMENT_SLOT_WAIST: return "Waist";// session->GetTrinityString(LANG_SLOT_NAME_WAIST); + case EQUIPMENT_SLOT_LEGS: return "Legs";// session->GetTrinityString(LANG_SLOT_NAME_LEGS); + case EQUIPMENT_SLOT_FEET: return "Feet";// session->GetTrinityString(LANG_SLOT_NAME_FEET); + case EQUIPMENT_SLOT_WRISTS: return "Wrists";// session->GetTrinityString(LANG_SLOT_NAME_WRISTS); + case EQUIPMENT_SLOT_HANDS: return "Hands";// session->GetTrinityString(LANG_SLOT_NAME_HANDS); + case EQUIPMENT_SLOT_BACK: return "Back";// session->GetTrinityString(LANG_SLOT_NAME_BACK); + case EQUIPMENT_SLOT_MAINHAND: return "Main hand";// session->GetTrinityString(LANG_SLOT_NAME_MAINHAND); + case EQUIPMENT_SLOT_OFFHAND: return "Off hand";// session->GetTrinityString(LANG_SLOT_NAME_OFFHAND); + case EQUIPMENT_SLOT_RANGED: return "Ranged";// session->GetTrinityString(LANG_SLOT_NAME_RANGED); + case EQUIPMENT_SLOT_TABARD: return "Tabard";// session->GetTrinityString(LANG_SLOT_NAME_TABARD); + default: return NULL; + } +} + +std::string Transmogrification::GetItemIcon(uint32 entry, uint32 width, uint32 height, int x, int y) const +{ + sLog->outDebug(LOG_FILTER_MODULES, "Transmogrification::GetItemIcon"); + + std::ostringstream ss; + ss << "|TInterface"; + const ItemTemplate* temp = sObjectMgr->GetItemTemplate(entry); + const ItemDisplayInfoEntry* dispInfo = NULL; + if (temp) + { + dispInfo = sItemDisplayInfoStore.LookupEntry(temp->DisplayInfoID); + if (dispInfo) + ss << "/ICONS/" << dispInfo->inventoryIcon; + } + if (!dispInfo) + ss << "/InventoryItems/WoWUnknownItem01"; + ss << ":" << width << ":" << height << ":" << x << ":" << y << "|t"; + return ss.str(); +} + +std::string Transmogrification::GetSlotIcon(uint8 slot, uint32 width, uint32 height, int x, int y) const +{ + sLog->outDebug(LOG_FILTER_MODULES, "Transmogrification::GetSlotIcon"); + + std::ostringstream ss; + ss << "|TInterface/PaperDoll/"; + switch (slot) + { + case EQUIPMENT_SLOT_HEAD: ss << "UI-PaperDoll-Slot-Head"; break; + case EQUIPMENT_SLOT_SHOULDERS: ss << "UI-PaperDoll-Slot-Shoulder"; break; + case EQUIPMENT_SLOT_BODY: ss << "UI-PaperDoll-Slot-Shirt"; break; + case EQUIPMENT_SLOT_CHEST: ss << "UI-PaperDoll-Slot-Chest"; break; + case EQUIPMENT_SLOT_WAIST: ss << "UI-PaperDoll-Slot-Waist"; break; + case EQUIPMENT_SLOT_LEGS: ss << "UI-PaperDoll-Slot-Legs"; break; + case EQUIPMENT_SLOT_FEET: ss << "UI-PaperDoll-Slot-Feet"; break; + case EQUIPMENT_SLOT_WRISTS: ss << "UI-PaperDoll-Slot-Wrists"; break; + case EQUIPMENT_SLOT_HANDS: ss << "UI-PaperDoll-Slot-Hands"; break; + case EQUIPMENT_SLOT_BACK: ss << "UI-PaperDoll-Slot-Chest"; break; + case EQUIPMENT_SLOT_MAINHAND: ss << "UI-PaperDoll-Slot-MainHand"; break; + case EQUIPMENT_SLOT_OFFHAND: ss << "UI-PaperDoll-Slot-SecondaryHand"; break; + case EQUIPMENT_SLOT_RANGED: ss << "UI-PaperDoll-Slot-Ranged"; break; + case EQUIPMENT_SLOT_TABARD: ss << "UI-PaperDoll-Slot-Tabard"; break; + default: ss << "UI-Backpack-EmptySlot"; + } + ss << ":" << width << ":" << height << ":" << x << ":" << y << "|t"; + return ss.str(); +} + +std::string Transmogrification::GetItemLink(Item* item, WorldSession* session) const +{ + sLog->outDebug(LOG_FILTER_MODULES, "Transmogrification::GetItemLink"); + + int loc_idx = session->GetSessionDbLocaleIndex(); + const ItemTemplate* temp = item->GetTemplate(); + std::string name = temp->Name1; + if (ItemLocale const* il = sObjectMgr->GetItemLocale(temp->ItemId)) + ObjectMgr::GetLocaleString(il->Name, loc_idx, name); + + if (int32 itemRandPropId = item->GetItemRandomPropertyId()) + { + char* const* suffix = NULL; + if (itemRandPropId < 0) + { + const ItemRandomSuffixEntry* itemRandEntry = sItemRandomSuffixStore.LookupEntry(-item->GetItemRandomPropertyId()); + if (itemRandEntry) + suffix = itemRandEntry->nameSuffix; + } + else + { + const ItemRandomPropertiesEntry* itemRandEntry = sItemRandomPropertiesStore.LookupEntry(item->GetItemRandomPropertyId()); + if (itemRandEntry) + suffix = itemRandEntry->nameSuffix; + } + if (suffix) + { + std::string test(suffix[(name != temp->Name1) ? loc_idx : DEFAULT_LOCALE]); + if (!test.empty()) + { + name += ' '; + name += test; + } + } + } + + std::ostringstream oss; + oss << "|c" << std::hex << ItemQualityColors[temp->Quality] << std::dec << + "|Hitem:" << temp->ItemId << ":" << + item->GetEnchantmentId(PERM_ENCHANTMENT_SLOT) << ":" << + item->GetEnchantmentId(SOCK_ENCHANTMENT_SLOT) << ":" << + item->GetEnchantmentId(SOCK_ENCHANTMENT_SLOT_2) << ":" << + item->GetEnchantmentId(SOCK_ENCHANTMENT_SLOT_3) << ":" << + item->GetEnchantmentId(BONUS_ENCHANTMENT_SLOT) << ":" << + item->GetItemRandomPropertyId() << ":" << item->GetItemSuffixFactor() << ":" << + (uint32)item->GetOwner()->getLevel() << "|h[" << name << "]|h|r"; + + return oss.str(); +} + +std::string Transmogrification::GetItemLink(uint32 entry, WorldSession* session) const +{ + sLog->outDebug(LOG_FILTER_MODULES, "Transmogrification::GetItemLink"); + + const ItemTemplate* temp = sObjectMgr->GetItemTemplate(entry); + int loc_idx = session->GetSessionDbLocaleIndex(); + std::string name = temp->Name1; + if (ItemLocale const* il = sObjectMgr->GetItemLocale(entry)) + ObjectMgr::GetLocaleString(il->Name, loc_idx, name); + + std::ostringstream oss; + oss << "|c" << std::hex << ItemQualityColors[temp->Quality] << std::dec << + "|Hitem:" << entry << ":0:0:0:0:0:0:0:0:0|h[" << name << "]|h|r"; + + return oss.str(); +} + +uint32 Transmogrification::GetFakeEntry(uint64 itemGUID) const +{ + sLog->outDebug(LOG_FILTER_MODULES, "Transmogrification::GetFakeEntry"); + + transmogData::const_iterator itr = dataMap.find(itemGUID); + if (itr == dataMap.end()) return 0; + transmogMap::const_iterator itr2 = entryMap.find(itr->second); + if (itr2 == entryMap.end()) return 0; + transmogData::const_iterator itr3 = itr2->second.find(itemGUID); + if (itr3 == itr2->second.end()) return 0; + return itr3->second; +} + +void Transmogrification::UpdateItem(Player* player, Item* item) const +{ + sLog->outDebug(LOG_FILTER_MODULES, "Transmogrification::UpdateItem"); + + if (item->IsEquipped()) + { + player->SetVisibleItemSlot(item->GetSlot(), item); + if (player->IsInWorld()) + item->SendUpdateToPlayer(player); + } +} + +void Transmogrification::DeleteFakeEntry(Player* player, uint8 slot, Item* itemTransmogrified, SQLTransaction* trans) +{ + //if (!GetFakeEntry(item)) + // return false; + DeleteFakeFromDB(itemTransmogrified->GetGUID(), trans); + UpdateItem(player, itemTransmogrified); +} + +void Transmogrification::SetFakeEntry(Player* player, uint32 newEntry, uint8 slot, Item* itemTransmogrified) +{ + uint64 itemGUID = itemTransmogrified->GetGUID(); + entryMap[player->GetGUID()][itemGUID] = newEntry; + dataMap[itemGUID] = player->GetGUID(); + CharacterDatabase.PExecute("REPLACE INTO custom_transmogrification (GUID, FakeEntry, Owner) VALUES (%u, %u, %u)", GUID_LOPART(itemGUID), newEntry, player->GetGUIDLow()); + UpdateItem(player, itemTransmogrified); +} + +TransmogTrinityStrings Transmogrification::Transmogrify(Player* player, uint64 itemGUID, uint8 slot, /*uint32 newEntry, */bool no_cost) +{ + int32 cost = 0; + // slot of the transmogrified item + if (slot >= EQUIPMENT_SLOT_END) + { + // TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify an item (lowguid: %u) with a wrong slot (%u) when transmogrifying items.", player->GetGUIDLow(), player->GetName().c_str(), GUID_LOPART(itemGUID), slot); + return LANG_ERR_TRANSMOG_INVALID_SLOT; + } + + Item* itemTransmogrifier = NULL; + // guid of the transmogrifier item, if it's not 0 + if (itemGUID) + { + itemTransmogrifier = player->GetItemByGuid(itemGUID); + if (!itemTransmogrifier) + { + //TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify with an invalid item (lowguid: %u).", player->GetGUIDLow(), player->GetName().c_str(), GUID_LOPART(itemGUID)); + return LANG_ERR_TRANSMOG_MISSING_SRC_ITEM; + } + } + + // transmogrified item + Item* itemTransmogrified = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); + if (!itemTransmogrified) + { + //TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify an invalid item in a valid slot (slot: %u).", player->GetGUIDLow(), player->GetName().c_str(), slot); + return LANG_ERR_TRANSMOG_MISSING_DEST_ITEM; + } + + if (!itemTransmogrifier) // reset look newEntry + { + // Custom + DeleteFakeEntry(player, slot, itemTransmogrified); + } + else + { + if (!CanTransmogrifyItemWithItem(player, itemTransmogrified->GetTemplate(), itemTransmogrifier->GetTemplate())) + { + //TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) failed CanTransmogrifyItemWithItem (%u with %u).", player->GetGUIDLow(), player->GetName().c_str(), itemTransmogrified->GetEntry(), itemTransmogrifier->GetEntry()); + return LANG_ERR_TRANSMOG_INVALID_ITEMS; + } + + if (!no_cost) + { + if (RequireToken) + { + if (player->HasItemCount(TokenEntry, TokenAmount)) + player->DestroyItemCount(TokenEntry, TokenAmount, true); + else + return LANG_ERR_TRANSMOG_NOT_ENOUGH_TOKENS; + } + + cost = GetSpecialPrice(itemTransmogrified->GetTemplate()); + cost *= ScaledCostModifier; + cost += CopperCost; + + if (cost) // 0 cost if reverting look + { + if (cost < 0) + sLog->outDebug(LOG_FILTER_MODULES, "Transmogrification::Transmogrify - %s (%u) transmogrification invalid cost (non negative, amount %i). Transmogrified %u with %u", player->GetName().c_str(), player->GetGUIDLow(), -cost, itemTransmogrified->GetEntry(), itemTransmogrifier->GetEntry()); + else + { + if (!player->HasEnoughMoney(cost)) + return LANG_ERR_TRANSMOG_NOT_ENOUGH_MONEY; + player->ModifyMoney(-cost, false); + } + } + } + + // Custom + SetFakeEntry(player, itemTransmogrifier->GetEntry(), slot, itemTransmogrified); // newEntry + + itemTransmogrified->UpdatePlayedTime(player); + + itemTransmogrified->SetOwnerGUID(player->GetGUID()); + itemTransmogrified->SetNotRefundable(player); + itemTransmogrified->ClearSoulboundTradeable(player); + + if (itemTransmogrifier->GetTemplate()->Bonding == BIND_WHEN_EQUIPED || itemTransmogrifier->GetTemplate()->Bonding == BIND_WHEN_USE) + itemTransmogrifier->SetBinding(true); + + itemTransmogrifier->SetOwnerGUID(player->GetGUID()); + itemTransmogrifier->SetNotRefundable(player); + itemTransmogrifier->ClearSoulboundTradeable(player); + } + + // trusting the client, if it got here it has to have enough money + // ... unless client was modified + if (cost) // 0 cost if reverting look + player->ModifyMoney(-1 * cost, false); + + return LANG_ERR_TRANSMOG_OK; +} + +bool Transmogrification::CanTransmogrifyItemWithItem(Player* player, ItemTemplate const* target, ItemTemplate const* source) const +{ + + if (!target || !source) + return false; + + if (source->ItemId == target->ItemId) + return false; + + if (source->DisplayInfoID == target->DisplayInfoID) + return false; + + if (source->Class != target->Class) + return false; + + if (source->InventoryType == INVTYPE_BAG || + source->InventoryType == INVTYPE_RELIC || + // source->InventoryType == INVTYPE_BODY || + source->InventoryType == INVTYPE_FINGER || + source->InventoryType == INVTYPE_TRINKET || + source->InventoryType == INVTYPE_AMMO || + source->InventoryType == INVTYPE_QUIVER) + return false; + + if (target->InventoryType == INVTYPE_BAG || + target->InventoryType == INVTYPE_RELIC || + // target->InventoryType == INVTYPE_BODY || + target->InventoryType == INVTYPE_FINGER || + target->InventoryType == INVTYPE_TRINKET || + target->InventoryType == INVTYPE_AMMO || + target->InventoryType == INVTYPE_QUIVER) + return false; + + if (!SuitableForTransmogrification(player, target) || !SuitableForTransmogrification(player, source)) // if (!transmogrified->CanTransmogrify() || !transmogrifier->CanBeTransmogrified()) + return false; + + if (IsRangedWeapon(source->Class, source->SubClass) != IsRangedWeapon(target->Class, target->SubClass)) + return false; + + if (source->SubClass != target->SubClass && !IsRangedWeapon(target->Class, target->SubClass)) + { + if (source->Class == ITEM_CLASS_ARMOR && !AllowMixedArmorTypes) + return false; + if (source->Class == ITEM_CLASS_WEAPON && !AllowMixedWeaponTypes) + return false; + } + + if (source->InventoryType != target->InventoryType) + { + if (source->Class == ITEM_CLASS_WEAPON && !(IsRangedWeapon(target->Class, target->SubClass) || + ( + // [AZTH] Yehonal: fixed weapon check + (target->InventoryType == INVTYPE_WEAPON || target->InventoryType == INVTYPE_2HWEAPON || target->InventoryType == INVTYPE_WEAPONMAINHAND || target->InventoryType == INVTYPE_WEAPONOFFHAND) + && (source->InventoryType == INVTYPE_WEAPON || source->InventoryType == INVTYPE_2HWEAPON || source->InventoryType == INVTYPE_WEAPONMAINHAND || source->InventoryType == INVTYPE_WEAPONOFFHAND) + ) + )) + return false; + if (source->Class == ITEM_CLASS_ARMOR && + !((source->InventoryType == INVTYPE_CHEST || source->InventoryType == INVTYPE_ROBE) && + (target->InventoryType == INVTYPE_CHEST || target->InventoryType == INVTYPE_ROBE))) + return false; + } + + return true; +} + +bool Transmogrification::SuitableForTransmogrification(Player* player, ItemTemplate const* proto) const +{ + // ItemTemplate const* proto = item->GetTemplate(); + if (!player || !proto) + return false; + + if (proto->Class != ITEM_CLASS_ARMOR && + proto->Class != ITEM_CLASS_WEAPON) + return false; + + // Skip all checks for allowed items + if (IsAllowed(proto->ItemId)) + return true; + + //[AZTH] Yehonal + if (/*TODO: conf here*/ proto->SubClass>0 && player->GetSkillValue(proto->GetSkill()) == 0) + return false; + + if (IsNotAllowed(proto->ItemId)) + return false; + + if (!AllowFishingPoles && proto->Class == ITEM_CLASS_WEAPON && proto->SubClass == ITEM_SUBCLASS_WEAPON_FISHING_POLE) + return false; + + if (!IsAllowedQuality(proto->Quality)) // (proto->Quality == ITEM_QUALITY_LEGENDARY) + return false; + + if ((proto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && player->GetTeamId() != TEAM_HORDE) + return false; + + if ((proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && player->GetTeamId() != TEAM_ALLIANCE) + return false; + + if (!IgnoreReqClass && (proto->AllowableClass & player->getClassMask()) == 0) + return false; + + if (!IgnoreReqRace && (proto->AllowableRace & player->getRaceMask()) == 0) + return false; + + if (!IgnoreReqSkill && proto->RequiredSkill != 0) + { + if (player->GetSkillValue(proto->RequiredSkill) == 0) + return false; + else if (player->GetSkillValue(proto->RequiredSkill) < proto->RequiredSkillRank) + return false; + } + + if (!IgnoreReqSpell && proto->RequiredSpell != 0 && !player->HasSpell(proto->RequiredSpell)) + return false; + + if (!IgnoreReqLevel && player->getLevel() < proto->RequiredLevel) + return false; + + // If World Event is not active, prevent using event dependant items + if (!IgnoreReqEvent && proto->HolidayId && !IsHolidayActive((HolidayIds)proto->HolidayId)) + return false; + + if (!IgnoreReqStats) + { + if (!proto->RandomProperty && !proto->RandomSuffix + /*[AZTH] Yehonal: we should transmorg also items without stats*/ + && proto->StatsCount > 0) + { + bool found = false; + for (uint8 i = 0; i < proto->StatsCount; ++i) + { + if (proto->ItemStat[i].ItemStatValue != 0) + { + found = true; + break; + } + } + if (!found) + return false; + } + } + + return true; +} + +uint32 Transmogrification::GetSpecialPrice(ItemTemplate const* proto) const +{ + uint32 cost = proto->SellPrice < 10000 ? 10000 : proto->SellPrice; + return cost; +} +bool Transmogrification::IsRangedWeapon(uint32 Class, uint32 SubClass) const +{ + return Class == ITEM_CLASS_WEAPON && ( + SubClass == ITEM_SUBCLASS_WEAPON_BOW || + SubClass == ITEM_SUBCLASS_WEAPON_GUN || + SubClass == ITEM_SUBCLASS_WEAPON_CROSSBOW); +} + +bool Transmogrification::IsAllowed(uint32 entry) const +{ + return Allowed.find(entry) != Allowed.end(); +} + +bool Transmogrification::IsNotAllowed(uint32 entry) const +{ + return NotAllowed.find(entry) != NotAllowed.end(); +} + +bool Transmogrification::IsAllowedQuality(uint32 quality) const +{ + switch (quality) + { + case ITEM_QUALITY_POOR: return AllowPoor; + case ITEM_QUALITY_NORMAL: return AllowCommon; + case ITEM_QUALITY_UNCOMMON: return AllowUncommon; + case ITEM_QUALITY_RARE: return AllowRare; + case ITEM_QUALITY_EPIC: return AllowEpic; + case ITEM_QUALITY_LEGENDARY: return AllowLegendary; + case ITEM_QUALITY_ARTIFACT: return AllowArtifact; + case ITEM_QUALITY_HEIRLOOM: return AllowHeirloom; + default: return false; + } +} + +void Transmogrification::LoadConfig(bool reload) +{ +#ifdef PRESETS + EnableSetInfo = sConfigMgr->GetBoolDefault("Transmogrification.EnableSetInfo", true); + SetNpcText = uint32(sConfigMgr->GetIntDefault("Transmogrification.SetNpcText", 50001)); + + EnableSets = sConfigMgr->GetBoolDefault("Transmogrification.EnableSets", true); + MaxSets = (uint8)sConfigMgr->GetIntDefault("Transmogrification.MaxSets", 10); + SetCostModifier = sConfigMgr->GetFloatDefault("Transmogrification.SetCostModifier", 3.0f); + SetCopperCost = sConfigMgr->GetIntDefault("Transmogrification.SetCopperCost", 0); + + if (MaxSets > MAX_OPTIONS) + MaxSets = MAX_OPTIONS; + + if (reload) // dont store presets for nothing + { + SessionMap const& sessions = sWorld->GetAllSessions(); + for (SessionMap::const_iterator it = sessions.begin(); it != sessions.end(); ++it) + { + if (Player* player = it->second->GetPlayer()) + { + // skipping session check + UnloadPlayerSets(player->GetGUID()); + if (GetEnableSets()) + LoadPlayerSets(player->GetGUID()); + } + } + } +#endif + + EnableTransmogInfo = sConfigMgr->GetBoolDefault("Transmogrification.EnableTransmogInfo", true); + TransmogNpcText = uint32(sConfigMgr->GetIntDefault("Transmogrification.TransmogNpcText", 50000)); + + std::istringstream issAllowed(sConfigMgr->GetStringDefault("Transmogrification.Allowed", "")); + std::istringstream issNotAllowed(sConfigMgr->GetStringDefault("Transmogrification.NotAllowed", "")); + while (issAllowed.good()) + { + uint32 entry; + issAllowed >> entry; + if (issAllowed.fail()) + break; + Allowed.insert(entry); + } + while (issNotAllowed.good()) + { + uint32 entry; + issNotAllowed >> entry; + if (issNotAllowed.fail()) + break; + NotAllowed.insert(entry); + } + + ScaledCostModifier = sConfigMgr->GetFloatDefault("Transmogrification.ScaledCostModifier", 1.0f); + CopperCost = sConfigMgr->GetIntDefault("Transmogrification.CopperCost", 0); + + RequireToken = sConfigMgr->GetBoolDefault("Transmogrification.RequireToken", false); + TokenEntry = uint32(sConfigMgr->GetIntDefault("Transmogrification.TokenEntry", 49426)); + TokenAmount = uint32(sConfigMgr->GetIntDefault("Transmogrification.TokenAmount", 1)); + + AllowPoor = sConfigMgr->GetBoolDefault("Transmogrification.AllowPoor", false); + AllowCommon = sConfigMgr->GetBoolDefault("Transmogrification.AllowCommon", false); + AllowUncommon = sConfigMgr->GetBoolDefault("Transmogrification.AllowUncommon", true); + AllowRare = sConfigMgr->GetBoolDefault("Transmogrification.AllowRare", true); + AllowEpic = sConfigMgr->GetBoolDefault("Transmogrification.AllowEpic", true); + AllowLegendary = sConfigMgr->GetBoolDefault("Transmogrification.AllowLegendary", false); + AllowArtifact = sConfigMgr->GetBoolDefault("Transmogrification.AllowArtifact", false); + AllowHeirloom = sConfigMgr->GetBoolDefault("Transmogrification.AllowHeirloom", true); + + AllowMixedArmorTypes = sConfigMgr->GetBoolDefault("Transmogrification.AllowMixedArmorTypes", false); + AllowMixedWeaponTypes = sConfigMgr->GetBoolDefault("Transmogrification.AllowMixedWeaponTypes", false); + AllowFishingPoles = sConfigMgr->GetBoolDefault("Transmogrification.AllowFishingPoles", false); + + IgnoreReqRace = sConfigMgr->GetBoolDefault("Transmogrification.IgnoreReqRace", false); + IgnoreReqClass = sConfigMgr->GetBoolDefault("Transmogrification.IgnoreReqClass", false); + IgnoreReqSkill = sConfigMgr->GetBoolDefault("Transmogrification.IgnoreReqSkill", false); + IgnoreReqSpell = sConfigMgr->GetBoolDefault("Transmogrification.IgnoreReqSpell", false); + IgnoreReqLevel = sConfigMgr->GetBoolDefault("Transmogrification.IgnoreReqLevel", false); + IgnoreReqEvent = sConfigMgr->GetBoolDefault("Transmogrification.IgnoreReqEvent", false); + IgnoreReqStats = sConfigMgr->GetBoolDefault("Transmogrification.IgnoreReqStats", false); + + if (!sObjectMgr->GetItemTemplate(TokenEntry)) + { + //sLog->outError(LOG_FILTER_SERVER_LOADING, "Transmogrification.TokenEntry (%u) does not exist. Using default.", TokenEntry); + TokenEntry = 49426; + } +} + +void Transmogrification::DeleteFakeFromDB(uint64 itemGUID, SQLTransaction* trans) +{ + if (dataMap.find(itemGUID) != dataMap.end()) + { + if (entryMap.find(dataMap[itemGUID]) != entryMap.end()) + entryMap[dataMap[itemGUID]].erase(itemGUID); + dataMap.erase(itemGUID); + } + if (trans) + (*trans)->PAppend("DELETE FROM custom_transmogrification WHERE GUID = %u", GUID_LOPART(itemGUID)); + else + CharacterDatabase.PExecute("DELETE FROM custom_transmogrification WHERE GUID = %u", GUID_LOPART(itemGUID)); +} + +bool Transmogrification::GetEnableTransmogInfo() const +{ + return EnableTransmogInfo; +} +uint32 Transmogrification::GetTransmogNpcText() const +{ + return TransmogNpcText; +} +bool Transmogrification::GetEnableSetInfo() const +{ + return EnableSetInfo; +} +uint32 Transmogrification::GetSetNpcText() const +{ + return SetNpcText; +} +float Transmogrification::GetScaledCostModifier() const +{ + return ScaledCostModifier; +} +int32 Transmogrification::GetCopperCost() const +{ + return CopperCost; +} +bool Transmogrification::GetRequireToken() const +{ + return RequireToken; +} +uint32 Transmogrification::GetTokenEntry() const +{ + return TokenEntry; +} +uint32 Transmogrification::GetTokenAmount() const +{ + return TokenAmount; +} +bool Transmogrification::GetAllowMixedArmorTypes() const +{ + return AllowMixedArmorTypes; +}; +bool Transmogrification::GetAllowMixedWeaponTypes() const +{ + return AllowMixedWeaponTypes; +}; diff --git a/src/Transmogrification.h b/src/Transmogrification.h new file mode 100644 index 0000000..ad415d6 --- /dev/null +++ b/src/Transmogrification.h @@ -0,0 +1,152 @@ +#ifndef DEF_TRANSMOGRIFICATION_H +#define DEF_TRANSMOGRIFICATION_H + +#include +#include "Define.h" +#include "ScriptPCH.h" +#include "Language.h" +#include "Config.h" + +#define PRESETS // comment this line to disable preset feature totally +#define MAX_OPTIONS 25 // do not alter + +class Item; +class Player; +class WorldSession; +struct ItemTemplate; + +enum TransmogTrinityStrings // Language.h might have same entries, appears when executing SQL, change if needed +{ + LANG_ERR_TRANSMOG_OK = 11100, // change this + LANG_ERR_TRANSMOG_INVALID_SLOT, + LANG_ERR_TRANSMOG_INVALID_SRC_ENTRY, + LANG_ERR_TRANSMOG_MISSING_SRC_ITEM, + LANG_ERR_TRANSMOG_MISSING_DEST_ITEM, + LANG_ERR_TRANSMOG_INVALID_ITEMS, + LANG_ERR_TRANSMOG_NOT_ENOUGH_MONEY, + LANG_ERR_TRANSMOG_NOT_ENOUGH_TOKENS, + + LANG_ERR_UNTRANSMOG_OK, + LANG_ERR_UNTRANSMOG_NO_TRANSMOGS, + +#ifdef PRESETS + LANG_PRESET_ERR_INVALID_NAME, +#endif +}; + +class Transmogrification +{ +public: + typedef UNORDERED_MAP transmogData; + typedef UNORDERED_MAP transmogMap; + transmogMap entryMap; // entryMap[pGUID][iGUID] = entry + transmogData dataMap; // dataMap[iGUID] = pGUID + +#ifdef PRESETS + bool EnableSetInfo; + uint32 SetNpcText; + + typedef std::map slotMap; + typedef std::map presetData; + typedef UNORDERED_MAP presetDataMap; + presetDataMap presetById; // presetById[pGUID][presetID][slot] = entry + typedef std::map presetIdMap; + typedef UNORDERED_MAP presetNameMap; + presetNameMap presetByName; // presetByName[pGUID][presetID] = presetName + + void PresetTransmog(Player* player, Item* itemTransmogrified, uint32 fakeEntry, uint8 slot); + + bool EnableSets; + uint8 MaxSets; + float SetCostModifier; + int32 SetCopperCost; + + bool GetEnableSets() const; + uint8 GetMaxSets() const; + float GetSetCostModifier() const; + int32 GetSetCopperCost() const; + + void LoadPlayerSets(uint64 pGUID); + void UnloadPlayerSets(uint64 pGUID); +#endif + + bool EnableTransmogInfo; + uint32 TransmogNpcText; + + // Use IsAllowed() and IsNotAllowed() + // these are thread unsafe, but assumed to be static data so it should be safe + std::set Allowed; + std::set NotAllowed; + + float ScaledCostModifier; + int32 CopperCost; + + bool RequireToken; + uint32 TokenEntry; + uint32 TokenAmount; + + bool AllowPoor; + bool AllowCommon; + bool AllowUncommon; + bool AllowRare; + bool AllowEpic; + bool AllowLegendary; + bool AllowArtifact; + bool AllowHeirloom; + + bool AllowMixedArmorTypes; + bool AllowMixedWeaponTypes; + bool AllowFishingPoles; + + bool IgnoreReqRace; + bool IgnoreReqClass; + bool IgnoreReqSkill; + bool IgnoreReqSpell; + bool IgnoreReqLevel; + bool IgnoreReqEvent; + bool IgnoreReqStats; + + bool IsAllowed(uint32 entry) const; + bool IsNotAllowed(uint32 entry) const; + bool IsAllowedQuality(uint32 quality) const; + bool IsRangedWeapon(uint32 Class, uint32 SubClass) const; + + void LoadConfig(bool reload); // thread unsafe + + std::string GetItemIcon(uint32 entry, uint32 width, uint32 height, int x, int y) const; + std::string GetSlotIcon(uint8 slot, uint32 width, uint32 height, int x, int y) const; + const char * GetSlotName(uint8 slot, WorldSession* session) const; + std::string GetItemLink(Item* item, WorldSession* session) const; + std::string GetItemLink(uint32 entry, WorldSession* session) const; + uint32 GetFakeEntry(uint64 itemGUID) const; + void UpdateItem(Player* player, Item* item) const; + void DeleteFakeEntry(Player* player, uint8 slot, Item* itemTransmogrified, SQLTransaction* trans = NULL); + void SetFakeEntry(Player* player, uint32 newEntry, uint8 slot, Item* itemTransmogrified); + + TransmogTrinityStrings Transmogrify(Player* player, uint64 itemGUID, uint8 slot, /*uint32 newEntry, */bool no_cost = false); + bool CanTransmogrifyItemWithItem(Player* player, ItemTemplate const* destination, ItemTemplate const* source) const; + bool SuitableForTransmogrification(Player* player, ItemTemplate const* proto) const; + // bool CanBeTransmogrified(Item const* item); + // bool CanTransmogrify(Item const* item); + uint32 GetSpecialPrice(ItemTemplate const* proto) const; + + void DeleteFakeFromDB(uint64 itemGUID, SQLTransaction* trans = NULL); + float GetScaledCostModifier() const; + int32 GetCopperCost() const; + + bool GetRequireToken() const; + uint32 GetTokenEntry() const; + uint32 GetTokenAmount() const; + + bool GetAllowMixedArmorTypes() const; + bool GetAllowMixedWeaponTypes() const; + + // Config + bool GetEnableTransmogInfo() const; + uint32 GetTransmogNpcText() const; + bool GetEnableSetInfo() const; + uint32 GetSetNpcText() const; +}; +#define sTransmogrification ACE_Singleton::instance() + +#endif diff --git a/src/cmake/after_ws.cmake b/src/cmake/after_ws.cmake new file mode 100644 index 0000000..30b2759 --- /dev/null +++ b/src/cmake/after_ws.cmake @@ -0,0 +1,13 @@ +if ( MSVC ) + add_custom_command(TARGET worldserver + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_TRANSM_DIR}/conf/transmog.conf.dist ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/ + ) +elseif ( MINGW ) + add_custom_command(TARGET worldserver + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_TRANSM_DIR}/conf/transmog.conf.dist ${CMAKE_BINARY_DIR}/bin/ + ) +endif() + +install(FILES "${CMAKE_TRANSM_DIR}/conf/transmog.conf.dist" DESTINATION ${CONF_DIR}) diff --git a/src/transmog_scripts.cpp b/src/transmog_scripts.cpp new file mode 100644 index 0000000..adcf580 --- /dev/null +++ b/src/transmog_scripts.cpp @@ -0,0 +1,473 @@ +/* +5.0 +Transmogrification 3.3.5a - Gossip menu +By Rochet2 + +ScriptName for NPC: +Creature_Transmogrify + +TODO: +Make DB saving even better (Deleting)? What about coding? + +Fix the cost formula +-- Too much data handling, use default costs + +Are the qualities right? +Blizzard might have changed the quality requirements. +(TC handles it with stat checks) + +Cant transmogrify rediculus items // Foereaper: would be fun to stab people with a fish +-- Cant think of any good way to handle this easily, could rip flagged items from cata DB +*/ + +#include "Transmogrification.h" +#define sT sTransmogrification +#define GTS session->GetTrinityString // dropped translation support, no one using? + +class npc_transmogrifier : public CreatureScript +{ +public: + npc_transmogrifier() : CreatureScript("npc_transmogrifier") { } + + bool OnGossipHello(Player* player, Creature* creature) + { + WorldSession* session = player->GetSession(); + if (sT->GetEnableTransmogInfo()) + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/INV_Misc_Book_11:30:30:-18:0|tHow transmogrification works", EQUIPMENT_SLOT_END + 9, 0); + for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) + { + if (const char* slotName = sT->GetSlotName(slot, session)) + { + Item* newItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); + uint32 entry = newItem ? sT->GetFakeEntry(newItem->GetGUID()) : 0; + std::string icon = entry ? sT->GetItemIcon(entry, 30, 30, -18, 0) : sT->GetSlotIcon(slot, 30, 30, -18, 0); + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, icon + std::string(slotName), EQUIPMENT_SLOT_END, slot); + } + } +#ifdef PRESETS + if (sT->GetEnableSets()) + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/RAIDFRAME/UI-RAIDFRAME-MAINASSIST:30:30:-18:0|tManage sets", EQUIPMENT_SLOT_END + 4, 0); +#endif + player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/INV_Enchant_Disenchant:30:30:-18:0|tRemove all transmogrifications", EQUIPMENT_SLOT_END + 2, 0, "Remove transmogrifications from all equipped items?", 0, false); + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/PaperDollInfoFrame/UI-GearManager-Undo:30:30:-18:0|tUpdate menu", EQUIPMENT_SLOT_END + 1, 0); + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); + return true; + } + + bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action) + { + player->PlayerTalkClass->ClearMenus(); + WorldSession* session = player->GetSession(); + switch (sender) + { + case EQUIPMENT_SLOT_END: // Show items you can use + ShowTransmogItems(player, creature, action); + break; + case EQUIPMENT_SLOT_END + 1: // Main menu + OnGossipHello(player, creature); + break; + case EQUIPMENT_SLOT_END + 2: // Remove Transmogrifications + { + bool removed = false; + SQLTransaction trans = CharacterDatabase.BeginTransaction(); + for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) + { + if (Item* newItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) + { + if (!sT->GetFakeEntry(newItem->GetGUID())) + continue; + sT->DeleteFakeEntry(player, slot, newItem, &trans); + removed = true; + } + } + if (removed) + { + session->SendAreaTriggerMessage(GTS(LANG_ERR_UNTRANSMOG_OK)); + CharacterDatabase.CommitTransaction(trans); + } + else + session->SendNotification(LANG_ERR_UNTRANSMOG_NO_TRANSMOGS); + OnGossipHello(player, creature); + } break; + case EQUIPMENT_SLOT_END + 3: // Remove Transmogrification from single item + { + if (Item* newItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, action)) + { + if (sT->GetFakeEntry(newItem->GetGUID())) + { + sT->DeleteFakeEntry(player, action, newItem); + session->SendAreaTriggerMessage(GTS(LANG_ERR_UNTRANSMOG_OK)); + } + else + session->SendNotification(LANG_ERR_UNTRANSMOG_NO_TRANSMOGS); + } + OnGossipSelect(player, creature, EQUIPMENT_SLOT_END, action); + } break; + #ifdef PRESETS + case EQUIPMENT_SLOT_END + 4: // Presets menu + { + if (!sT->GetEnableSets()) + { + OnGossipHello(player, creature); + return true; + } + if (sT->GetEnableSetInfo()) + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/INV_Misc_Book_11:30:30:-18:0|tHow sets work", EQUIPMENT_SLOT_END + 10, 0); + for (Transmogrification::presetIdMap::const_iterator it = sT->presetByName[player->GetGUID()].begin(); it != sT->presetByName[player->GetGUID()].end(); ++it) + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/INV_Misc_Statue_02:30:30:-18:0|t" + it->second, EQUIPMENT_SLOT_END + 6, it->first); + + if (sT->presetByName[player->GetGUID()].size() < sT->GetMaxSets()) + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/GuildBankFrame/UI-GuildBankFrame-NewTab:30:30:-18:0|tSave set", EQUIPMENT_SLOT_END + 8, 0); + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/Ability_Spy:30:30:-18:0|tBack..", EQUIPMENT_SLOT_END + 1, 0); + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); + } break; + case EQUIPMENT_SLOT_END + 5: // Use preset + { + if (!sT->GetEnableSets()) + { + OnGossipHello(player, creature); + return true; + } + // action = presetID + for (Transmogrification::slotMap::const_iterator it = sT->presetById[player->GetGUID()][action].begin(); it != sT->presetById[player->GetGUID()][action].end(); ++it) + { + if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, it->first)) + sT->PresetTransmog(player, item, it->second, it->first); + } + OnGossipSelect(player, creature, EQUIPMENT_SLOT_END + 6, action); + } break; + case EQUIPMENT_SLOT_END + 6: // view preset + { + if (!sT->GetEnableSets()) + { + OnGossipHello(player, creature); + return true; + } + // action = presetID + for (Transmogrification::slotMap::const_iterator it = sT->presetById[player->GetGUID()][action].begin(); it != sT->presetById[player->GetGUID()][action].end(); ++it) + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, sT->GetItemIcon(it->second, 30, 30, -18, 0) + sT->GetItemLink(it->second, session), sender, action); + + player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/INV_Misc_Statue_02:30:30:-18:0|tUse set", EQUIPMENT_SLOT_END + 5, action, "Using this set for transmogrify will bind transmogrified items to you and make them non-refundable and non-tradeable.\nDo you wish to continue?\n\n" + sT->presetByName[player->GetGUID()][action], 0, false); + player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "|TInterface/PaperDollInfoFrame/UI-GearManager-LeaveItem-Opaque:30:30:-18:0|tDelete set", EQUIPMENT_SLOT_END + 7, action, "Are you sure you want to delete " + sT->presetByName[player->GetGUID()][action] + "?", 0, false); + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/Ability_Spy:30:30:-18:0|tBack..", EQUIPMENT_SLOT_END + 4, 0); + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); + } break; + case EQUIPMENT_SLOT_END + 7: // Delete preset + { + if (!sT->GetEnableSets()) + { + OnGossipHello(player, creature); + return true; + } + // action = presetID + CharacterDatabase.PExecute("DELETE FROM `custom_transmogrification_sets` WHERE Owner = %u AND PresetID = %u", player->GetGUIDLow(), action); + sT->presetById[player->GetGUID()][action].clear(); + sT->presetById[player->GetGUID()].erase(action); + sT->presetByName[player->GetGUID()].erase(action); + + OnGossipSelect(player, creature, EQUIPMENT_SLOT_END + 4, 0); + } break; + case EQUIPMENT_SLOT_END + 8: // Save preset + { + if (!sT->GetEnableSets() || sT->presetByName[player->GetGUID()].size() >= sT->GetMaxSets()) + { + OnGossipHello(player, creature); + return true; + } + uint32 cost = 0; + bool canSave = false; + for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) + { + if (!sT->GetSlotName(slot, session)) + continue; + if (Item* newItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) + { + uint32 entry = sT->GetFakeEntry(newItem->GetGUID()); + if (!entry) + continue; + const ItemTemplate* temp = sObjectMgr->GetItemTemplate(entry); + if (!temp) + continue; + if (!sT->SuitableForTransmogrification(player, temp)) // no need to check? + continue; + cost += sT->GetSpecialPrice(temp); + canSave = true; + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, sT->GetItemIcon(entry, 30, 30, -18, 0) + sT->GetItemLink(entry, session), EQUIPMENT_SLOT_END + 8, 0); + } + } + if (canSave) + player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "|TInterface/GuildBankFrame/UI-GuildBankFrame-NewTab:30:30:-18:0|tSave set", 0, 0, "Insert set name", cost*sT->GetSetCostModifier() + sT->GetSetCopperCost(), true); + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/PaperDollInfoFrame/UI-GearManager-Undo:30:30:-18:0|tUpdate menu", sender, action); + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/Ability_Spy:30:30:-18:0|tBack..", EQUIPMENT_SLOT_END + 4, 0); + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); + } break; + case EQUIPMENT_SLOT_END + 10: // Set info + { + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/Ability_Spy:30:30:-18:0|tBack..", EQUIPMENT_SLOT_END + 4, 0); + player->SEND_GOSSIP_MENU(sT->GetSetNpcText(), creature->GetGUID()); + } break; + #endif + case EQUIPMENT_SLOT_END + 9: // Transmog info + { + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/Ability_Spy:30:30:-18:0|tBack..", EQUIPMENT_SLOT_END + 1, 0); + player->SEND_GOSSIP_MENU(sT->GetTransmogNpcText(), creature->GetGUID()); + } break; + default: // Transmogrify + { + if (!sender && !action) + { + OnGossipHello(player, creature); + return true; + } + // sender = slot, action = display + TransmogTrinityStrings res = sT->Transmogrify(player, MAKE_NEW_GUID(action, 0, HIGHGUID_ITEM), sender); + if (res == LANG_ERR_TRANSMOG_OK) + session->SendAreaTriggerMessage(GTS(LANG_ERR_TRANSMOG_OK)); + else + session->SendNotification(res); + // OnGossipSelect(player, creature, EQUIPMENT_SLOT_END, sender); + // ShowTransmogItems(player, creature, sender); + player->CLOSE_GOSSIP_MENU(); // Wait for SetMoney to get fixed, issue #10053 + } break; + } + return true; + } + +#ifdef PRESETS + bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code) + { + player->PlayerTalkClass->ClearMenus(); + if (sender || action) + return true; // should never happen + if (!sT->GetEnableSets()) + { + OnGossipHello(player, creature); + return true; + } + std::string name(code); + if (name.find('"') != std::string::npos || name.find('\\') != std::string::npos) + player->GetSession()->SendNotification(LANG_PRESET_ERR_INVALID_NAME); + else + { + for (uint8 presetID = 0; presetID < sT->GetMaxSets(); ++presetID) // should never reach over max + { + if (sT->presetByName[player->GetGUID()].find(presetID) != sT->presetByName[player->GetGUID()].end()) + continue; // Just remember never to use presetByName[pGUID][presetID] when finding etc! + + int32 cost = 0; + std::map items; + for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) + { + if (!sT->GetSlotName(slot, player->GetSession())) + continue; + if (Item* newItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) + { + uint32 entry = sT->GetFakeEntry(newItem->GetGUID()); + if (!entry) + continue; + const ItemTemplate* temp = sObjectMgr->GetItemTemplate(entry); + if (!temp) + continue; + if (!sT->SuitableForTransmogrification(player, temp)) + continue; + cost += sT->GetSpecialPrice(temp); + items[slot] = entry; + } + } + if (items.empty()) + break; // no transmogrified items were found to be saved + cost *= sT->GetSetCostModifier(); + cost += sT->GetSetCopperCost(); + if (!player->HasEnoughMoney(cost)) + { + player->GetSession()->SendNotification(LANG_ERR_TRANSMOG_NOT_ENOUGH_MONEY); + break; + } + + std::ostringstream ss; + for (std::map::iterator it = items.begin(); it != items.end(); ++it) + { + ss << uint32(it->first) << ' ' << it->second << ' '; + sT->presetById[player->GetGUID()][presetID][it->first] = it->second; + } + sT->presetByName[player->GetGUID()][presetID] = name; // Make sure code doesnt mess up SQL! + CharacterDatabase.PExecute("REPLACE INTO `custom_transmogrification_sets` (`Owner`, `PresetID`, `SetName`, `SetData`) VALUES (%u, %u, \"%s\", \"%s\")", player->GetGUIDLow(), uint32(presetID), name.c_str(), ss.str().c_str()); + if (cost) + player->ModifyMoney(cost); + break; + } + } + //OnGossipSelect(player, creature, EQUIPMENT_SLOT_END+4, 0); + player->CLOSE_GOSSIP_MENU(); // Wait for SetMoney to get fixed, issue #10053 + return true; + } +#endif + + void ShowTransmogItems(Player* player, Creature* creature, uint8 slot) // Only checks bags while can use an item from anywhere in inventory + { + WorldSession* session = player->GetSession(); + Item* oldItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); + if (oldItem) + { + uint32 limit = 0; + uint32 price = sT->GetSpecialPrice(oldItem->GetTemplate()); + price *= sT->GetScaledCostModifier(); + price += sT->GetCopperCost(); + std::ostringstream ss; + ss << std::endl; + if (sT->GetRequireToken()) + ss << std::endl << std::endl << sT->GetTokenAmount() << " x " << sT->GetItemLink(sT->GetTokenEntry(), session); + + for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) + { + if (limit > MAX_OPTIONS) + break; + Item* newItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (!newItem) + continue; + if (!sT->CanTransmogrifyItemWithItem(player, oldItem->GetTemplate(), newItem->GetTemplate())) + continue; + if (sT->GetFakeEntry(oldItem->GetGUID()) == newItem->GetEntry()) + continue; + ++limit; + player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, sT->GetItemIcon(newItem->GetEntry(), 30, 30, -18, 0) + sT->GetItemLink(newItem, session), slot, newItem->GetGUIDLow(), "Using this item for transmogrify will bind it to you and make it non-refundable and non-tradeable.\nDo you wish to continue?\n\n" + sT->GetItemIcon(newItem->GetEntry(), 40, 40, -15, -10) + sT->GetItemLink(newItem, session) + ss.str(), price, false); + } + + for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + { + Bag* bag = player->GetBagByPos(i); + if (!bag) + continue; + for (uint32 j = 0; j < bag->GetBagSize(); ++j) + { + if (limit > MAX_OPTIONS) + break; + Item* newItem = player->GetItemByPos(i, j); + if (!newItem) + continue; + if (!sT->CanTransmogrifyItemWithItem(player, oldItem->GetTemplate(), newItem->GetTemplate())) + continue; + if (sT->GetFakeEntry(oldItem->GetGUID()) == newItem->GetEntry()) + continue; + ++limit; + player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, sT->GetItemIcon(newItem->GetEntry(), 30, 30, -18, 0) + sT->GetItemLink(newItem, session), slot, newItem->GetGUIDLow(), "Using this item for transmogrify will bind it to you and make it non-refundable and non-tradeable.\nDo you wish to continue?\n\n" + sT->GetItemIcon(newItem->GetEntry(), 40, 40, -15, -10) + sT->GetItemLink(newItem, session) + ss.str(), price, false); + } + } + } + + player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/INV_Enchant_Disenchant:30:30:-18:0|tRemove transmogrification", EQUIPMENT_SLOT_END + 3, slot, "Remove transmogrification from the slot?", 0, false); + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/PaperDollInfoFrame/UI-GearManager-Undo:30:30:-18:0|tUpdate menu", EQUIPMENT_SLOT_END, slot); + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/Ability_Spy:30:30:-18:0|tBack..", EQUIPMENT_SLOT_END + 1, 0); + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); + } +}; + +class PS_Transmogrification : public PlayerScript +{ +public: + PS_Transmogrification() : PlayerScript("Player_Transmogrify") { } + + void OnAfterSetVisibleItemSlot(Player* player, uint8 slot, Item *item) { + if (!item) + return; + + if (uint32 entry = sT->GetFakeEntry(item->GetGUID())) + player->SetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + (slot * 2), entry); + } + + void OnLogin(Player* player) + { + uint64 playerGUID = player->GetGUID(); + sT->entryMap.erase(playerGUID); + QueryResult result = CharacterDatabase.PQuery("SELECT GUID, FakeEntry FROM custom_transmogrification WHERE Owner = %u", player->GetGUIDLow()); + if (result) + { + do + { + uint64 itemGUID = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_ITEM); + uint32 fakeEntry = (*result)[1].GetUInt32(); + if (sObjectMgr->GetItemTemplate(fakeEntry)) + { + sT->dataMap[itemGUID] = playerGUID; + sT->entryMap[playerGUID][itemGUID] = fakeEntry; + } + else + { + //sLog->outError(LOG_FILTER_SQL, "Item entry (Entry: %u, itemGUID: %u, playerGUID: %u) does not exist, ignoring.", fakeEntry, GUID_LOPART(itemGUID), player->GetGUIDLow()); + // CharacterDatabase.PExecute("DELETE FROM custom_transmogrification WHERE FakeEntry = %u", fakeEntry); + } + } while (result->NextRow()); + + for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) + { + if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) + player->SetVisibleItemSlot(slot, item); + } + } + +#ifdef PRESETS + if (sT->GetEnableSets()) + sT->LoadPlayerSets(playerGUID); +#endif + } + + void OnLogout(Player* player) + { + uint32 pGUID = player->GetGUID(); + for (Transmogrification::transmogData::const_iterator it = sT->entryMap[pGUID].begin(); it != sT->entryMap[pGUID].end(); ++it) + sT->dataMap.erase(it->first); + sT->entryMap.erase(pGUID); + +#ifdef PRESETS + if (sT->GetEnableSets()) + sT->UnloadPlayerSets(pGUID); +#endif + } +}; + +class WS_Transmogrification : public WorldScript +{ +public: + WS_Transmogrification() : WorldScript("WS_Transmogrification") { } + + void OnAfterConfigLoad(bool reload) + { + if (reload) + sT->LoadConfig(reload); + } + + void OnStartup() + { + sT->LoadConfig(false); + //sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Deleting non-existing transmogrification entries..."); + CharacterDatabase.Execute("DELETE FROM custom_transmogrification WHERE NOT EXISTS (SELECT 1 FROM item_instance WHERE item_instance.guid = custom_transmogrification.GUID)"); + +#ifdef PRESETS + // Clean even if disabled + // Dont delete even if player has more presets than should + CharacterDatabase.Execute("DELETE FROM `custom_transmogrification_sets` WHERE NOT EXISTS(SELECT 1 FROM characters WHERE characters.guid = custom_transmogrification_sets.Owner)"); +#endif + } +}; + +class global_transmog_script : public GlobalScript { + public: + global_transmog_script() : GlobalScript("global_transmog_script") { } + + void OnItemDelFromDB(SQLTransaction& trans, uint32 itemGuid) { + sT->DeleteFakeFromDB(itemGuid, &trans); + } + + void OnMirrorImageDisplayItem(const Item *item, uint32 &display) { + if (uint32 entry = sTransmogrification->GetFakeEntry(item->GetGUID())) + display=uint32(sObjectMgr->GetItemTemplate(entry)->DisplayInfoID); + } +}; + +void AddSC_transmog() { + new global_transmog_script(); + new npc_transmogrifier(); + new PS_Transmogrification(); + new WS_Transmogrification(); +} + diff --git a/src/transmog_scripts_loader.h b/src/transmog_scripts_loader.h new file mode 100644 index 0000000..6f87f0d --- /dev/null +++ b/src/transmog_scripts_loader.h @@ -0,0 +1,12 @@ +#ifndef TRANSMOGR_SCRIPTS_LOADER_H +#define TRANSMOGR_SCRIPTS_LOADER_H + +void AddSC_transmog(); + +void AddTransmogScripts() +{ + AddSC_transmog(); +} + +#endif /* TRANSMOG_SCRIPTS_LOADER_H */ +