mirror of
https://github.com/BytesGalore/mod-no-hearthstone-cooldown.git
synced 2026-01-13 00:58:37 +00:00
mod: renamed config file
fix: only apply cooldown if mod is enabled mod: refactored code mod: read enabled state only when the world-config is loaded add: config option to switch mod announcement
This commit is contained in:
13
README.md
13
README.md
@@ -3,7 +3,7 @@
|
||||
### This is a module for [AzerothCore](http://www.azerothcore.org)
|
||||
|
||||
#### Features:
|
||||
- It disables the Hearthstone cooldown
|
||||
- It resets the Hearthstone cooldown immediatly
|
||||
|
||||
### This module currently requires:
|
||||
- AzerothCore v4.0.0+
|
||||
@@ -11,14 +11,13 @@
|
||||
### 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. that's all
|
||||
|
||||
### (Optional) Edit module configuration
|
||||
You can turn the module **on** and **off**, default it is **on**.
|
||||
If you want to disable it, go to your server configuration folder (e.g. **etc**), copy `no-hearthstone-cooldown.conf.dist` to `no-hearthstone-cooldown.conf` and change
|
||||
`NoHearthstoneCooldown.Enable = 1`
|
||||
to
|
||||
`NoHearthstoneCooldown.Enable = 0`
|
||||
- You can turn the module **on** and **off**, default it is **on**
|
||||
- You can also turn the announcement of the module on player-login **on** and **off**, default it is **on**
|
||||
- If you want change the settings, go to your server configuration folder (e.g. **etc**), copy `mod_no_hearthstone_cooldown.conf.dist` to `mod_no_hearthstone_cooldown.conf` and edit the settings
|
||||
|
||||
## Credits
|
||||
* BytesGalore
|
||||
* [BytesGalore](https://github.com/BytesGalore) (author of the module)
|
||||
* AzerothCore: [repository](https://github.com/azerothcore) - [website](http://azerothcore.org/) - [discord chat community](https://discord.gg/PaqQRkd)
|
||||
|
||||
@@ -13,5 +13,12 @@
|
||||
# Default: 1 - Enabled
|
||||
# 0 - Disabled
|
||||
#
|
||||
# NoHearthstoneCooldownConfig.Announce
|
||||
# Description: Inform the player about the loaded module
|
||||
# Default: 1 - Enabled
|
||||
# 0 - Disabled
|
||||
#
|
||||
|
||||
NoHearthstoneCooldown.Enable = 1
|
||||
|
||||
NoHearthstoneCooldown.Announce = 1
|
||||
@@ -6,40 +6,56 @@
|
||||
#include "Player.h"
|
||||
#include "Config.h"
|
||||
#include "Chat.h"
|
||||
#include "Item.h"
|
||||
|
||||
// Add player scripts
|
||||
class NoHearthstoneCooldown : public PlayerScript
|
||||
class NoHearthstoneCooldown : public PlayerScript, public WorldScript
|
||||
{
|
||||
public:
|
||||
NoHearthstoneCooldown(): PlayerScript("NoHearthstoneCooldown") {}
|
||||
NoHearthstoneCooldown(): PlayerScript("NoHearthstoneCooldown"), WorldScript("NoHearthstoneCooldown") {}
|
||||
|
||||
bool OnBeforeTeleport(Player* player, uint32 /*mapid*/, float /*x*/, float /*y*/, float /*z*/, float /*orientation*/, uint32 /*options*/, Unit* /*target*/) override
|
||||
{
|
||||
auto* spell = player->FindCurrentSpellBySpellId(8690);
|
||||
if (spell)
|
||||
{
|
||||
player->RemoveSpellCooldown(8690, true);
|
||||
player->RemoveSpellCooldown(39937, true);
|
||||
player->SendClearCooldown(8690, player);
|
||||
player->SendClearCooldown(39937, player);
|
||||
}
|
||||
ClearHearthstoneCooldown(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnLogin(Player* player) override
|
||||
{
|
||||
if (sConfigMgr->GetOption<bool>("NoHearthstoneCooldown.Enable", false))
|
||||
if (sConfigMgr->GetOption<bool>("NoHearthstoneCooldown.Announce", true))
|
||||
{
|
||||
ChatHandler(player->GetSession()).SendSysMessage("This server is running the |cff4CFF00No Hearthstone cooldown|rmodule!");
|
||||
|
||||
player->RemoveSpellCooldown(8690, true);
|
||||
player->RemoveSpellCooldown(39937, true);
|
||||
player->SendClearCooldown(8690, player);
|
||||
player->SendClearCooldown(39937, player);
|
||||
ChatHandler(player->GetSession()).SendSysMessage("This server is running the |cff4CFF00No Hearthstone cooldown|r module.");
|
||||
}
|
||||
|
||||
ClearHearthstoneCooldown(player);
|
||||
}
|
||||
|
||||
void OnAfterConfigLoad(bool /*reload*/) override
|
||||
{
|
||||
m_bNHCModuleEnabled = sConfigMgr->GetOption<bool>("NoHearthstoneCooldown.Enable", true);
|
||||
}
|
||||
|
||||
private:
|
||||
void ClearHearthstoneCooldown(Player* player)
|
||||
{
|
||||
if (m_bNHCModuleEnabled)
|
||||
{
|
||||
// only clear the cooldown if the player actually casted the Hearthstone spell
|
||||
if (player->FindCurrentSpellBySpellId(m_nSpellIDHearthstone))
|
||||
{
|
||||
// we remove the cooldown from the list of the player current cooldowns
|
||||
player->RemoveSpellCooldown(m_nSpellIDHearthstone, true);
|
||||
player->RemoveSpellCooldown(m_nSpellIDNoPlaceLikeHome, true);
|
||||
// then we clear the cooldown and send an update to the player client
|
||||
player->SendClearCooldown(m_nSpellIDHearthstone, player);
|
||||
player->SendClearCooldown(m_nSpellIDNoPlaceLikeHome, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool m_bNHCModuleEnabled = false;
|
||||
// https://www.wowhead.com/spell=8690/hearthstone
|
||||
const uint32 m_nSpellIDHearthstone = 8690;
|
||||
// https://tbc.wowhead.com/spell=39937/theres-no-place-like-home
|
||||
const uint32 m_nSpellIDNoPlaceLikeHome = 39937;
|
||||
};
|
||||
|
||||
// Add all scripts in one
|
||||
|
||||
Reference in New Issue
Block a user