From 494cde182cd937611500a2746ebd064981fc99b3 Mon Sep 17 00:00:00 2001 From: Walter Pagani Date: Tue, 5 Sep 2023 05:17:05 -0300 Subject: [PATCH] feat. Add option to Learn or cast spells (#30) * feat. Add option to Learn or cast spells * boolean learn attribute --- .github/README.md | 47 ---------------- README.md | 76 ++++++++++++++++++++++++++ conf/mod_congratsonlevel.conf.dist | 4 +- data/sql/db-world/col_reward_items.sql | 33 +++++------ src/mod_congratsonlevel.cpp | 13 +++-- 5 files changed, 104 insertions(+), 69 deletions(-) delete mode 100644 .github/README.md create mode 100644 README.md diff --git a/.github/README.md b/.github/README.md deleted file mode 100644 index 38f7163..0000000 --- a/.github/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# ![logo](https://raw.githubusercontent.com/azerothcore/azerothcore.github.io/master/images/logo-github.png) AzerothCore - -## mod-congrats-on-level - -### This is a module for [AzerothCore](http://www.azerothcore.org) - -- Latest build status with azerothcore: - -[![Build Status](https://github.com/azerothcore/mod-congrats-on-level/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/azerothcore/mod-congrats-on-level) - -#### Features: -This module rewards players when they reach specific levels. It has the option to reward gold, two items, and a buff or any combination. It also announces to the world when a player levels up. All rewards can be set in the config file for quick modifications. - -### This module currently requires: -- AzerothCore v1.0.1+ - -### How to install -1. Simply place the module under the `modules` folder of your AzerothCore source folder. -2. Re-run cmake and launch a clean build of AzerothCore -3. Done :) - -### Usage -- Type: Player/Server -- Script: CongratsOnLevel -- Config: Yes - - Enable Module - - Enable Module Announce - - Set Items/Gold/Buffs Given At Each Level - -## Credits -- [SoulSeekkor](https://github.com/SoulSeekkor) -- [LordPsyan](https://bitbucket.org/lordpsyan/lordpsyan-patches) -- [Blizzard Entertainment](http://blizzard.com) -- [TrinityCore](https://github.com/TrinityCore/TrinityCore/blob/3.3.5/THANKS) -- [SunwellCore](http://www.azerothcore.org/pages/sunwell.pl/) -- [AzerothCore](https://github.com/AzerothCore/azerothcore-wotlk/graphs/contributors) -- [AzerothCore Discord](https://discord.gg/gkt4y2x) -- [EMUDevs](https://youtube.com/user/EmuDevs) -- [AC-Web](http://ac-web.org/) -- [ModCraft.io](http://modcraft.io/) -- [OwnedCore](http://ownedcore.com/) -- [OregonCore](https://wiki.oregon-core.net/) -- [Wowhead.com](http://wowhead.com) -- [AoWoW](https://wotlk.evowow.com/) -- [Stygianthebest]( http://stygianthebest.github.io) - -AzerothCore: [repository](https://github.com/azerothcore) - [website](http://azerothcore.org/) - [discord chat community](https://discord.gg/PaqQRkd) diff --git a/README.md b/README.md new file mode 100644 index 0000000..bf7f693 --- /dev/null +++ b/README.md @@ -0,0 +1,76 @@ +# ![logo](https://raw.githubusercontent.com/azerothcore/azerothcore.github.io/master/images/logo-github.png) AzerothCore + +## mod-congrats-on-level + +### This is a module for [AzerothCore](http://www.azerothcore.org) + +- Latest build status with azerothcore: + +[![Build Status](https://github.com/azerothcore/mod-congrats-on-level/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/azerothcore/mod-congrats-on-level) + +### About the module + +This module allows you to configure a series of prizes, by class, race and levels. To the extent that players reach these levels, they can obtain gold, spells, or items. If you don't want to deliver any of them, it's always possible to leave it at 0. All items were moved to the database. Inside the table, you could customize the prizes, however you want. + +### Table structure + +1. `level`: Level that the player must have to get the reward. +2. `money`: Amount of money to deliver, it can be 0. +3. `spell`: Id of the spell that you want to teach or cast, it can be 0. +4. `learn`: If it's 0, the spell is cast. If it is 1, it is learned. +5. `itemId1`: Id of the item that you want to deliver, it can be 0. +6. `itemId2`: Id of the item that you want to deliver, it can be 0. +7. `race`: 0 for all or specify race id. +8. `class`: 0 for all, or specify the class id. + +| ID | className (enUS) | +|----|------------------| +| 1 | Warrior | +| 2 | Paladin | +| 3 | Hunter | +| 4 | Rogue | +| 5 | Priest | +| 6 | Death Knight | +| 7 | Shaman | +| 8 | Mage | +| 9 | Warlock | +| 11 | Druid | + +| ID | Race .raceName (enUS) | Faction .name (enUS) | +|----|-----------------------|----------------------| +| 1 | Human | Alliance | +| 2 | Orc | Horde | +| 3 | Dwarf | Alliance | +| 4 | Night Elf | Alliance | +| 5 | Undead | Horde | +| 6 | Tauren | Horde | +| 7 | Gnome | Alliance | +| 8 | Troll | Horde | +| 10 | Blood Elf | Horde | +| 11 | Draenei | Alliance | + +### How to install +1. Simply place the module under the `modules` folder of your AzerothCore source folder. +2. Re-run cmake and launch a clean build of AzerothCore +3. Done :) + +## Credits +- [SoulSeekkor](https://github.com/SoulSeekkor) +- [LordPsyan](https://bitbucket.org/lordpsyan/lordpsyan-patches) +- [Blizzard Entertainment](http://blizzard.com) +- [TrinityCore](https://github.com/TrinityCore/TrinityCore/blob/3.3.5/THANKS) +- [SunwellCore](http://www.azerothcore.org/pages/sunwell.pl/) +- [AzerothCore](https://github.com/AzerothCore/azerothcore-wotlk/graphs/contributors) +- [AzerothCore Discord](https://discord.gg/gkt4y2x) +- [EMUDevs](https://youtube.com/user/EmuDevs) +- [AC-Web](http://ac-web.org/) +- [ModCraft.io](http://modcraft.io/) +- [OwnedCore](http://ownedcore.com/) +- [OregonCore](https://wiki.oregon-core.net/) +- [Wowhead.com](http://wowhead.com) +- [AoWoW](https://wotlk.evowow.com/) +- [Stygianthebest]( http://stygianthebest.github.io) + +- AzerothCore: [repository](https://github.com/azerothcore) +- [website](http://azerothcore.org/) +- [discord chat community](https://discord.gg/PaqQRkd) diff --git a/conf/mod_congratsonlevel.conf.dist b/conf/mod_congratsonlevel.conf.dist index d1449df..393b205 100644 --- a/conf/mod_congratsonlevel.conf.dist +++ b/conf/mod_congratsonlevel.conf.dist @@ -1,8 +1,8 @@ [worldserver] -################################################################################################### +############################# # CONGRATS ON LEVEL-UP -################################################################################################### +############################# # Enable the module? (1: true | 0: false) diff --git a/data/sql/db-world/col_reward_items.sql b/data/sql/db-world/col_reward_items.sql index 6500398..495a129 100644 --- a/data/sql/db-world/col_reward_items.sql +++ b/data/sql/db-world/col_reward_items.sql @@ -1,20 +1,21 @@ CREATE TABLE IF NOT EXISTS `mod_congrats_on_level_items` ( - `level` tinyint unsigned NOT NULL DEFAULT '0', - `money` int unsigned NOT NULL DEFAULT '0', - `spell` int unsigned NOT NULL DEFAULT '0', - `itemId1` int unsigned NOT NULL DEFAULT '0', - `itemId2` int unsigned NOT NULL DEFAULT '0', - `race` tinyint unsigned NOT NULL DEFAULT '0', - `class` tinyint unsigned NOT NULL DEFAULT '0' + `level` tinyint unsigned NOT NULL DEFAULT 0, + `money` int unsigned NOT NULL DEFAULT 0, + `spell` int unsigned NOT NULL DEFAULT 0, + `learn` boolean NOT NULL DEFAULT false, + `itemId1` int unsigned NOT NULL DEFAULT 0, + `itemId2` int unsigned NOT NULL DEFAULT 0, + `race` tinyint unsigned NOT NULL DEFAULT 0, + `class` tinyint unsigned NOT NULL DEFAULT 0 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; DELETE FROM `mod_congrats_on_level_items`; -INSERT INTO `mod_congrats_on_level_items` (`level`, `money`, `spell`, `itemId1`, `itemId2`, `race`, `class`) VALUES -(10, 1, 20217, 3419, 45063, 0, 0), -(20, 10, 48161, 5433, 38578, 0, 0), -(30, 15, 48469, 18231, 46780, 0, 0), -(40, 20, 20217, 31945, 49704, 0, 0), -(50, 25, 48161, 11382, 32542, 0, 0), -(60, 30, 48469, 37863, 33219, 0, 0), -(70, 35, 48161, 9360, 54212, 0, 0), -(80, 100, 20217, 9361, 40110, 0, 0); +INSERT INTO `mod_congrats_on_level_items` (`level`, `money`, `spell`, `learn`, `itemId1`, `itemId2`, `race`, `class`) VALUES +(10, 1, 20217, 0, 3419, 45063, 0, 0), +(20, 10, 48161, 0, 5433, 38578, 0, 0), +(30, 15, 48469, 0, 18231, 46780, 0, 0), +(40, 20, 20217, 0, 31945, 49704, 0, 0), +(50, 25, 48161, 0, 11382, 32542, 0, 0), +(60, 30, 48469, 0, 37863, 33219, 0, 0), +(70, 35, 48161, 0, 9360, 54212, 0, 0), +(80, 100, 20217, 0, 9361, 40110, 0, 0); diff --git a/src/mod_congratsonlevel.cpp b/src/mod_congratsonlevel.cpp index eb3f849..2027f52 100644 --- a/src/mod_congratsonlevel.cpp +++ b/src/mod_congratsonlevel.cpp @@ -94,11 +94,16 @@ uint32 giveAward(Player* player) money += fields[1].Get() * GOLD; } if (fields[2].Get() > 0) - player->CastSpell(player, fields[2].Get()); - if (fields[3].Get() > 0) - player->AddItem(fields[3].Get(), 1); - if (fields[4].Get()) + { + if (fields[3].Get() == 0) + player->CastSpell(player, fields[2].Get()); + else + player->learnSpell(fields[2].Get()); + } + if (fields[4].Get() > 0) player->AddItem(fields[4].Get(), 1); + if (fields[5].Get()) + player->AddItem(fields[5].Get(), 1); } while (result->NextRow());