From b66cca02ea9e7b760d4baa0bc1acef68aac25b8a Mon Sep 17 00:00:00 2001 From: benjymansy123 Date: Tue, 2 Aug 2022 12:17:22 -0400 Subject: [PATCH] Add actual module code. Adds announcement part and scripts the damage for Rocket Barrage. --- conf/conf.sh.dist | 1 - conf/mod_worgoblin.conf.dist | 6 ++++ src/Worgoblin.cpp | 56 ++++++++++++++++++++++++++++++++++++ src/worgoblin_loader.h | 6 ++++ 4 files changed, 68 insertions(+), 1 deletion(-) delete mode 100644 conf/conf.sh.dist create mode 100644 conf/mod_worgoblin.conf.dist create mode 100644 src/Worgoblin.cpp create mode 100644 src/worgoblin_loader.h diff --git a/conf/conf.sh.dist b/conf/conf.sh.dist deleted file mode 100644 index 8b13789..0000000 --- a/conf/conf.sh.dist +++ /dev/null @@ -1 +0,0 @@ - diff --git a/conf/mod_worgoblin.conf.dist b/conf/mod_worgoblin.conf.dist new file mode 100644 index 0000000..1a8c3c5 --- /dev/null +++ b/conf/mod_worgoblin.conf.dist @@ -0,0 +1,6 @@ +[worldserver] + +# Enable the module announcing its presence. +# Default: true + +Announce.enable=true \ No newline at end of file diff --git a/src/Worgoblin.cpp b/src/Worgoblin.cpp new file mode 100644 index 0000000..b727c05 --- /dev/null +++ b/src/Worgoblin.cpp @@ -0,0 +1,56 @@ +#include "worgoblin_loader.h" +#include "Chat.h" +#include "Player.h" +#include "ScriptMgr.h" +#include "SpellScript.h" +#include "Config.h" + +class announce : public PlayerScript { + +public: + announce() : PlayerScript("announce") { } + + void OnLogin(Player* player) override + { + if (sConfigMgr->GetOption("Announce.enable", true)) + { + ChatHandler(player->GetSession()).SendSysMessage("This server is running the Worgoblin module."); // Hell yea + } + } +}; + +class rocket_barrage : public SpellScriptLoader //ID=69041 +{ +public: + rocket_barrage() : SpellScriptLoader("spell_rocket_barrage") { } + + class rocket_barrage_script : public SpellScript + { + PrepareSpellScript(rocket_barrage_script); + + void HandleDamage(SpellEffIndex effIndex) + { + Unit* caster = GetCaster(); + int32 basePoints = 0 + caster->getLevel() * 2; + basePoints += caster->SpellBaseDamageBonusDone(GetSpellInfo()->GetSchoolMask()) * 0.429; //BM=0.429 here, don't ask me how. + basePoints += caster->GetTotalAttackPowerValue(caster->getClass() != CLASS_HUNTER ? BASE_ATTACK : RANGED_ATTACK) * 0.25; // 0.25=BonusCoefficient, hardcoding it here + SetEffectValue(basePoints); + } + + void Register() override + { + OnEffectLaunchTarget += SpellEffectFn(rocket_barrage_script::HandleDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); + } + }; + + SpellScript* GetSpellScript() const override + { + return new rocket_barrage_script; + } +}; + +void Add_Worgoblin() +{ + new announce(); + new rocket_barrage(); +} diff --git a/src/worgoblin_loader.h b/src/worgoblin_loader.h new file mode 100644 index 0000000..97d5141 --- /dev/null +++ b/src/worgoblin_loader.h @@ -0,0 +1,6 @@ +void Add_Worgoblin(); + +void Addmod_worgoblinScripts() +{ + Add_Worgoblin(); +} \ No newline at end of file