Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptMgr.h"
- #include "SpellScript.h"
- #include "Unit.h"
- class spell_backstab_front : public SpellScriptLoader
- {
- public:
- spell_backstab_front() : SpellScriptLoader("spell_backstab_front") { }
- class spell_backstab_front_SpellScript : public SpellScript
- {
- PrepareSpellScript(spell_backstab_front_SpellScript);
- void HandleOnHit()
- {
- Unit* caster = GetCaster();
- Unit* target = GetHitUnit();
- if (!caster || !target)
- return;
- // Check if the caster is behind the target
- if (!target->isInBack(caster)) // Check if not behind
- {
- // Only deal 80% of the damage if not behind the target
- SetHitDamage(int32(GetHitDamage() * 0.8f));
- }
- }
- void Register() override
- {
- OnHit += SpellHitFn(spell_backstab_front_SpellScript::HandleOnHit);
- }
- };
- SpellScript* GetSpellScript() const override
- {
- return new spell_backstab_front_SpellScript();
- }
- };
- void AddSC_spell_backstab_front()
- {
- new spell_backstab_front();
- }
Advertisement
Add Comment
Please, Sign In to add comment