From da21a607f2a60525d1013a4b64e71258547fd03b Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Thu, 19 Sep 2024 23:11:26 +0200 Subject: [PATCH 1/5] add config --- conf/ghost_speed.conf.dist | 25 +++++++++++++++++++++++++ conf/my_custom.conf.dist | 17 ----------------- src/mod_ghost_speed.cpp | 26 ++++++++++++++++++++++++-- src/mod_ghost_speed.h | 15 +++++++++++++++ 4 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 conf/ghost_speed.conf.dist delete mode 100644 conf/my_custom.conf.dist create mode 100644 src/mod_ghost_speed.h diff --git a/conf/ghost_speed.conf.dist b/conf/ghost_speed.conf.dist new file mode 100644 index 0000000..bf2a91e --- /dev/null +++ b/conf/ghost_speed.conf.dist @@ -0,0 +1,25 @@ +# +# Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 +# + +[worldserver] + +######################################## +# Ghost Speed module configuration +######################################## +# +# GhostSpeed.Speed +# Description: Custom BasePoints for 8326 Ghost EFFECT_1 SPELL_AURA_MOD_INCREASE_SPEED +# Default: 200 - Fast +# 50 - Blizzard Default +# 500 - Zoom +# +# GhostSpeed.SwimSpeed +# Description: Custom BasePoints for 8326 Ghost EFFECT_2 SPELL_AURA_MOD_INCREASE_SWIM_SPEED +# Default: 200 - Fast +# 50 - Blizzard Default +# 500 - Zoom +# + +GhostSpeed.Speed = 200 +GhostSpeed.SwimSpeed = 200 diff --git a/conf/my_custom.conf.dist b/conf/my_custom.conf.dist deleted file mode 100644 index eb614f9..0000000 --- a/conf/my_custom.conf.dist +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 -# - -[worldserver] - -######################################## -# My module configuration -######################################## -# -# MyModule.Enable -# Description: Enable my module and print "Hello World" message at server start -# Default: 0 - Disabled -# 1 - Enabled -# - -MyModule.Enable = 1 diff --git a/src/mod_ghost_speed.cpp b/src/mod_ghost_speed.cpp index ad54714..4d4365d 100644 --- a/src/mod_ghost_speed.cpp +++ b/src/mod_ghost_speed.cpp @@ -1,10 +1,31 @@ /* * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 */ +#include "Config.h" +#include "ScriptMgr.h" #include "SpellAuraEffects.h" #include "SpellInfo.h" #include "SpellScript.h" #include "SpellScriptLoader.h" +#include "mod_ghost_speed.h" + +GhostSpeed* GhostSpeed::instance() +{ + static GhostSpeed instance; + return &instance; +} + +class world_ghost_speed : public WorldScript +{ +public: + world_ghost_speed() : WorldScript("world_ghost_speed") { } + + void OnAfterConfigLoad(bool /*reload*/) override + { + sGhostSpeed->speed = sConfigMgr->GetOption("GhostSpeed.Speed", 200); + sGhostSpeed->speedSwim = sConfigMgr->GetOption("GhostSpeed.SpeedSwim", 200); + } +}; // 8326 Ghost class spell_ghost_speed_aura : public AuraScript @@ -13,12 +34,12 @@ class spell_ghost_speed_aura : public AuraScript void CalculateAmountSpeed(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) { - amount = 200; // default: 50 + amount = sGhostSpeed->speed; } void CalculateAmountSwimSpeed(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) { - amount = 200; // default: 50 + amount = sGhostSpeed->speedSwim; } void Register() override @@ -30,5 +51,6 @@ class spell_ghost_speed_aura : public AuraScript void AddSC_ghost_speed_spell_script() { + new world_ghost_speed(); RegisterSpellScript(spell_ghost_speed_aura); } diff --git a/src/mod_ghost_speed.h b/src/mod_ghost_speed.h new file mode 100644 index 0000000..0385d82 --- /dev/null +++ b/src/mod_ghost_speed.h @@ -0,0 +1,15 @@ +#ifndef DEF_GHOSTSPEED_H +#define DEF_GHOSTSPEED_H + +class GhostSpeed +{ +public: + static GhostSpeed* instance(); + + int32 speed; + int32 speedSwim; +}; + +#define sGhostSpeed GhostSpeed::instance() + +#endif From 4a852960db9d4474d66bec97695812bc6756e63a Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Thu, 19 Sep 2024 23:18:08 +0200 Subject: [PATCH 2/5] update config to match cpp name --- conf/ghost_speed.conf.dist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/ghost_speed.conf.dist b/conf/ghost_speed.conf.dist index bf2a91e..99abe68 100644 --- a/conf/ghost_speed.conf.dist +++ b/conf/ghost_speed.conf.dist @@ -14,7 +14,7 @@ # 50 - Blizzard Default # 500 - Zoom # -# GhostSpeed.SwimSpeed +# GhostSpeed.SpeedSwim # Description: Custom BasePoints for 8326 Ghost EFFECT_2 SPELL_AURA_MOD_INCREASE_SWIM_SPEED # Default: 200 - Fast # 50 - Blizzard Default @@ -22,4 +22,4 @@ # GhostSpeed.Speed = 200 -GhostSpeed.SwimSpeed = 200 +GhostSpeed.SpeedSwim = 200 From 8419bc8fab4b528b90d7ba092cd74bb7e962e969 Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Thu, 19 Sep 2024 23:43:28 +0200 Subject: [PATCH 3/5] add night elf speed to config +50% night elf racial bonus --- conf/ghost_speed.conf.dist | 21 +++++++++++++++++++-- data/sql/db-world/base/ghost_speed.sql | 4 +++- optional/undo_ghost_speed.sql | 3 ++- src/mod_ghost_speed.cpp | 25 +++++++++++++++++++++++++ src/mod_ghost_speed.h | 2 ++ 5 files changed, 51 insertions(+), 4 deletions(-) diff --git a/conf/ghost_speed.conf.dist b/conf/ghost_speed.conf.dist index 99abe68..f7c6ad1 100644 --- a/conf/ghost_speed.conf.dist +++ b/conf/ghost_speed.conf.dist @@ -12,14 +12,31 @@ # Description: Custom BasePoints for 8326 Ghost EFFECT_1 SPELL_AURA_MOD_INCREASE_SPEED # Default: 200 - Fast # 50 - Blizzard Default +# 75 - Blizzard Default for Night Elves (+50% racial bonus) # 500 - Zoom # # GhostSpeed.SpeedSwim # Description: Custom BasePoints for 8326 Ghost EFFECT_2 SPELL_AURA_MOD_INCREASE_SWIM_SPEED # Default: 200 - Fast # 50 - Blizzard Default +# 75 - Blizzard Default for Night Elves (+50% racial bonus) # 500 - Zoom # +# GhostSpeed.SpeedNightElf +# Description: Custom BasePoints for Night Elf 20584 Ghost EFFECT_1 SPELL_AURA_MOD_INCREASE_SPEED +# Default: 300 - Fast (200 + 50% racial bonus) +# 50 - Blizzard Default +# 75 - Blizzard Default for Night Elves (+50% racial bonus) +# 500 - Zoom +# +# GhostSpeed.SpeedSwimNightElf +# Description: Custom BasePoints for Night Elf 20584 Ghost EFFECT_2 SPELL_AURA_MOD_INCREASE_SWIM_SPEED +# Default: 300 - Fast (200 + 50% racial bonus) +# 50 - Blizzard Default +# 75 - Blizzard Default for Night Elves (+50% racial bonus) +# 500 - Zoom -GhostSpeed.Speed = 200 -GhostSpeed.SpeedSwim = 200 +GhostSpeed.Speed = 200 +GhostSpeed.SpeedSwim = 200 +GhostSpeed.SpeedNightElf = 300 +GhostSpeed.SpeedSwimNightElf = 300 diff --git a/data/sql/db-world/base/ghost_speed.sql b/data/sql/db-world/base/ghost_speed.sql index bc6f878..57bf19a 100644 --- a/data/sql/db-world/base/ghost_speed.sql +++ b/data/sql/db-world/base/ghost_speed.sql @@ -1,3 +1,5 @@ -- modify ghost speed -DELETE FROM `spell_script_names` WHERE `spell_id` = 8326; +DELETE FROM `spell_script_names` WHERE `spell_id` = 8326 AND `ScriptName` = 'spell_ghost_speed_aura'; INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES (8326, 'spell_ghost_speed_aura'); +DELETE FROM `spell_script_names` WHERE `spell_id` = 20584 AND `ScriptName` = 'spell_ghost_speed_night_elf_aura'; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES (20584, 'spell_ghost_speed_night_elf_aura'); diff --git a/optional/undo_ghost_speed.sql b/optional/undo_ghost_speed.sql index abb0ea8..afbcca4 100644 --- a/optional/undo_ghost_speed.sql +++ b/optional/undo_ghost_speed.sql @@ -1,2 +1,3 @@ -- -DELETE FROM `spell_script_names` WHERE `spell_id` = 8326; +DELETE FROM `spell_script_names` WHERE `spell_id` = 8326 AND `ScriptName` = 'spell_ghost_speed_aura'; +DELETE FROM `spell_script_names` WHERE `spell_id` = 20584 AND `ScriptName` = 'spell_ghost_speed_night_elf_aura'; diff --git a/src/mod_ghost_speed.cpp b/src/mod_ghost_speed.cpp index 4d4365d..0551889 100644 --- a/src/mod_ghost_speed.cpp +++ b/src/mod_ghost_speed.cpp @@ -24,6 +24,8 @@ class world_ghost_speed : public WorldScript { sGhostSpeed->speed = sConfigMgr->GetOption("GhostSpeed.Speed", 200); sGhostSpeed->speedSwim = sConfigMgr->GetOption("GhostSpeed.SpeedSwim", 200); + sGhostSpeed->speedNightElf = sConfigMgr->GetOption("GhostSpeed.SpeedNightElf", 300); + sGhostSpeed->speedSwimNightElf = sConfigMgr->GetOption("GhostSpeed.SpeedSwimNightElf", 300); } }; @@ -49,8 +51,31 @@ class spell_ghost_speed_aura : public AuraScript } }; +// 20584 Ghost - Night Elf +class spell_ghost_speed_night_elf_aura : public AuraScript +{ + PrepareAuraScript(spell_ghost_speed_night_elf_aura); + + void CalculateAmountSpeed(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + { + amount = sGhostSpeed->speedNightElf; + } + + void CalculateAmountSwimSpeed(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + { + amount = sGhostSpeed->speedSwimNightElf; + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ghost_speed_night_elf_aura::CalculateAmountSpeed, EFFECT_1, SPELL_AURA_MOD_INCREASE_SPEED); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ghost_speed_night_elf_aura::CalculateAmountSwimSpeed, EFFECT_2, SPELL_AURA_MOD_INCREASE_SWIM_SPEED); + } +}; + void AddSC_ghost_speed_spell_script() { new world_ghost_speed(); RegisterSpellScript(spell_ghost_speed_aura); + RegisterSpellScript(spell_ghost_speed_night_elf_aura); } diff --git a/src/mod_ghost_speed.h b/src/mod_ghost_speed.h index 0385d82..fa15137 100644 --- a/src/mod_ghost_speed.h +++ b/src/mod_ghost_speed.h @@ -8,6 +8,8 @@ class GhostSpeed int32 speed; int32 speedSwim; + int32 speedNightElf; + int32 speedSwimNightElf; }; #define sGhostSpeed GhostSpeed::instance() From f15cc2023feae1bf65c4bbac9a6b12483e3c2ab3 Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Thu, 19 Sep 2024 23:48:52 +0200 Subject: [PATCH 4/5] fix effects to match dbc --- src/mod_ghost_speed.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mod_ghost_speed.cpp b/src/mod_ghost_speed.cpp index 0551889..531a994 100644 --- a/src/mod_ghost_speed.cpp +++ b/src/mod_ghost_speed.cpp @@ -68,8 +68,8 @@ class spell_ghost_speed_night_elf_aura : public AuraScript void Register() override { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ghost_speed_night_elf_aura::CalculateAmountSpeed, EFFECT_1, SPELL_AURA_MOD_INCREASE_SPEED); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ghost_speed_night_elf_aura::CalculateAmountSwimSpeed, EFFECT_2, SPELL_AURA_MOD_INCREASE_SWIM_SPEED); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ghost_speed_night_elf_aura::CalculateAmountSpeed, EFFECT_0, SPELL_AURA_MOD_INCREASE_SPEED); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ghost_speed_night_elf_aura::CalculateAmountSwimSpeed, EFFECT_1, SPELL_AURA_MOD_INCREASE_SWIM_SPEED); } }; From c0b054544d51199310a913532fa3a6eef802d73c Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Fri, 20 Sep 2024 00:00:26 +0200 Subject: [PATCH 5/5] update readme --- .github/README.md | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/.github/README.md b/.github/README.md index b240fce..732ae55 100644 --- a/.github/README.md +++ b/.github/README.md @@ -6,47 +6,33 @@ [![Build Status]( https://github.com/sogladev/mod-ghost-speed/actions/workflows/core-build.yml/badge.svg?branch=master&event=push)](https://github.com/sogladev/mod-ghost-speed) -This is a module for [AzerothCore](http://www.azerothcore.org) that changes the speed of Ghost +This is a module for [AzerothCore](http://www.azerothcore.org) that changes the speed while dead -- Modifies ghost speed to use custom values +- Modifies Ghost speed to use custom values ## How to install https://www.azerothcore.org/wiki/installing-a-module -1. Modify value(s) `src/mod_ghost_speed.cpp` -2. Requires source recompilation -3. Modify database (should be done automaticly) - -``` -amount = 200; // default: 50 -``` - -example values: -``` -50 default -200 fast -500 zoom -``` - -Apply database changes (this should be done automaticly): `data/sql/db-world/base/ghost_speed.sql` -``` -DELETE FROM `spell_script_names` WHERE `spell_id` = 8326; -INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES (8326, 'spell_ghost_speed_aura'); -``` +1. Requires source recompilation +2. Modify config + found in `/etc/modules`, copy `.conf.dist` to `.conf` and edit +3. Apply database changes + this should be done automaticly `data/sql/db-world/base/ghost_speed.sql` ## How to remove 1. Undo database changes: `optional/undo_ghost_speed.sql` -``` -DELETE FROM `spell_script_names` WHERE `spell_id` = 8326; -``` 2. Remove `mod-ghost-speed` folder ## Resources ghost speed is set by aura 8326 +Night Elves are applied `ID - 20584 Ghost` with Blizzard Default speed of 75 (+50% increase) + +Highest speed value is applied + example of usage in the core - https://github.com/azerothcore/azerothcore-wotlk/blob/a196f7f28aa263dc7f9c532e15839f3b409fb68f/src/server/game/Handlers/CharacterHandler.cpp#L957