-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Modules/ItemAddTalent): implement module for add talents via item
- Loading branch information
1 parent
319e1af
commit a0f37f7
Showing
6 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# This file is part of the WarheadCore Project. See AUTHORS file for Copyright information | ||
# | ||
# 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 General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
######################################## | ||
# ItemAddTalent module configuration | ||
######################################## | ||
# | ||
# ItemAddTalent.Enable | ||
# Description: Enable this module | ||
# Default: 0 | ||
# | ||
|
||
ItemAddTalent.Enable = 0 |
8 changes: 8 additions & 0 deletions
8
modules/mod-item-add-talent/sql/db_world/2023_10_07_00_item_add_talent.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Add item | ||
SET @ITEM_ID := 114000; | ||
|
||
DELETE FROM `item_template` | ||
WHERE `entry` = @ITEM_ID; | ||
|
||
INSERT INTO `item_template` | ||
VALUES (@ITEM_ID, 0, 0, - 1, 'Add talent token', 46787, 6, 0, 0, 1, 0, 0, 0, - 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 0, 0, 18282, 0, 0, 0, 8000, 0, - 1, 0, 0, 0, 0, - 1, 0, - 1, 0, 0, 0, 0, - 1, 0, - 1, 0, 0, 0, 0, - 1, 0, - 1, 0, 0, 0, 0, - 1, 0, - 1, 0, '|cff00FF00Использование: Добавить себе 1 талант.|r', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 'ItemAddTalent_Item', 0, 0, 0, 0, 0, - 4); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* This file is part of the WarheadCore Project. See AUTHORS file for Copyright information | ||
* | ||
* 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 General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "ItemAddTalent.h" | ||
#include "ModulesConfig.h" | ||
#include "Player.h" | ||
#include "Item.h" | ||
|
||
ItemAddTalentMgr* ItemAddTalentMgr::instance() | ||
{ | ||
static ItemAddTalentMgr instance; | ||
return &instance; | ||
} | ||
|
||
void ItemAddTalentMgr::LoadConfig(bool /*reload*/) | ||
{ | ||
_isEnable = MOD_CONF_GET_BOOL("ItemAddTalent.Enable"); | ||
} | ||
|
||
bool ItemAddTalentMgr::OnPlayerItemUse(Player* player, Item* item) | ||
{ | ||
if (!_isEnable) | ||
return false; | ||
|
||
player->RewardExtraBonusTalentPoints(1); | ||
player->InitTalentForLevel(); | ||
player->DestroyItemCount(item->GetEntry(), 1, true); | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* This file is part of the WarheadCore Project. See AUTHORS file for Copyright information | ||
* | ||
* 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 General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef _ITEM_ADD_TALENT_H_ | ||
#define _ITEM_ADD_TALENT_H_ | ||
|
||
#include "Define.h" | ||
|
||
class Player; | ||
class Item; | ||
|
||
class ItemAddTalentMgr | ||
{ | ||
public: | ||
static ItemAddTalentMgr* instance(); | ||
|
||
void LoadConfig(bool reload); | ||
bool OnPlayerItemUse(Player* player, Item* item); | ||
|
||
private: | ||
bool _isEnable{ false }; | ||
|
||
ItemAddTalentMgr() = default; | ||
~ItemAddTalentMgr() = default; | ||
|
||
ItemAddTalentMgr(ItemAddTalentMgr const&) = delete; | ||
ItemAddTalentMgr(ItemAddTalentMgr&&) = delete; | ||
ItemAddTalentMgr& operator=(ItemAddTalentMgr const&) = delete; | ||
ItemAddTalentMgr& operator=(ItemAddTalentMgr&&) = delete; | ||
}; | ||
|
||
#define sItemAddTalentMgr ItemAddTalentMgr::instance() | ||
|
||
#endif // _ITEM_ADD_TALENT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* This file is part of the WarheadCore Project. See AUTHORS file for Copyright information | ||
* | ||
* 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 General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "ItemAddTalent.h" | ||
#include "ScriptObject.h" | ||
|
||
class ItemAddTalent_Item : public ItemScript | ||
{ | ||
public: | ||
ItemAddTalent_Item() : ItemScript("ItemAddTalent_Item") {} | ||
|
||
bool OnUse(Player* player, Item* item, const SpellCastTargets& /*Targets*/) override | ||
{ | ||
return sItemAddTalentMgr->OnPlayerItemUse(player, item); | ||
} | ||
}; | ||
|
||
class ItemAddTalent_World : public WorldScript | ||
{ | ||
public: | ||
ItemAddTalent_World() : WorldScript("ItemAddTalent_World") { } | ||
|
||
void OnAfterConfigLoad(bool reload) override | ||
{ | ||
sItemAddTalentMgr->LoadConfig(reload); | ||
} | ||
}; | ||
|
||
// Group all custom scripts | ||
void AddSC_ItemAddTalent() | ||
{ | ||
new ItemAddTalent_Item(); | ||
new ItemAddTalent_World(); | ||
} |
25 changes: 25 additions & 0 deletions
25
modules/mod-item-add-talent/src/item_add_talent_loader.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* This file is part of the WarheadCore Project. See AUTHORS file for Copyright information | ||
* | ||
* 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 General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
// From SC | ||
void AddSC_ItemAddTalent(); | ||
|
||
// Add all | ||
void Addmod_item_add_talentScripts() | ||
{ | ||
AddSC_ItemAddTalent(); | ||
} |