Heal at duel

Hi, I found script for cast heal on self, when you try heal player in duel, but its causing crash and I dont know, if its working for all heal spells.

[CODE]diff -r 803cb847c17b src/server/game/Entities/Player/Player.h

— a/src/server/game/Entities/Player/Player.h Mon Nov 29 15:50:38 2010 +0600

+++ b/src/server/game/Entities/Player/Player.h Mon Nov 29 16:49:11 2010 +0100

@@ -1706,6 +1706,7 @@

     void CheckDuelDistance(time_t currTime);

     void DuelComplete(DuelCompleteType type);

     void SendDuelCountdown(uint32 counter);
  •    bool isDueling() const { return duel != NULL; }
    
    
       bool IsGroupVisibleFor(Player const* p) const;
    
       bool IsInSameGroupWith(Player const* p) const;
    

diff -r 803cb847c17b src/server/game/Spells/Spell.cpp

— a/src/server/game/Spells/Spell.cpp Mon Nov 29 15:50:38 2010 +0600

+++ b/src/server/game/Spells/Spell.cpp Mon Nov 29 16:49:11 2010 +0100

@@ -4829,6 +4829,15 @@

     if (!m_IsTriggeredSpell && target == m_caster && m_spellInfo->AttributesEx & SPELL_ATTR_EX_CANT_TARGET_SELF)

         return SPELL_FAILED_BAD_TARGETS;
  •    // If target is dueling, cast on self.
    
  •    if (target != m_caster && m_caster->IsFriendlyTo(target) && target->ToPlayer()->isDueling())
    
  •    {
    
  •        if (IsPositiveSpell(m_spellInfo->Id))
    
  •            target = m_caster;
    
  •        else
    
  •            return SPELL_FAILED_TARGET_DUELING;
    
  •    }
    
     bool non_caster_target = target != m_caster && !sSpellMgr.IsSpellWithCasterSourceTargetsOnly(m_spellInfo);


     if (non_caster_target)[/CODE]

Patch by: jesper.meyr (I think)

Any ideas? Thanks

if (m_caster->IsFriendlyTo(unitTarget) && (unitTarget->ToPlayer() != NULL && unitTarget->ToPlayer()->isDueling() != NULL))try this

lemme get this correct. If a player is dueling against another player, and a player trys to heal one of the duelists. The heal just targets the caster and not the duelist?

and is it fully working?

Persephone: You’re right ;-). Script in first post crashing core, I wrote it in first post too.

Viste: Thanks, I think, I can try it tomorrow ;-).

nice /emoticons/default_biggrin.png awsome script, ok if it aint crashing can you post here working version? i would love this script /emoticons/default_biggrin.png i hate my opponent getting healed -.-

Try this instead:

diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index a4f5b42..0514bda 100755
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1716,6 +1716,7 @@ class Player : public Unit, public GridObject<Player>
         void CheckDuelDistance(time_t currTime);
         void DuelComplete(DuelCompleteType type);
         void SendDuelCountdown(uint32 counter);
+        bool isDueling() const { return duel != NULL; }

         bool IsGroupVisibleFor(Player const* p) const;
         bool IsInSameGroupWith(Player const* p) const;
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 2cc6d08..614737a 100755
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -4789,6 +4789,18 @@ SpellCastResult Spell::CheckCast(bool strict)
         if (!m_IsTriggeredSpell && target == m_caster && m_spellInfo->AttributesEx & SPELL_ATTR1_CANT_TARGET_SELF)
             return SPELL_FAILED_BAD_TARGETS;

+        // If target is dueling, cast on self.
+        if (target != m_caster && m_caster->IsFriendlyTo(target))
+        {
+            if (Player* targetPlayer = target->ToPlayer())
+            {
+                if (targetPlayer->isDueling() && IsPositiveSpell(m_spellInfo->Id))
+                    target = m_caster;
+                else
+                    return SPELL_FAILED_TARGET_DUELING;
+            }
+        }
+
         bool non_caster_target = target != m_caster && !sSpellMgr->IsSpellWithCasterSourceTargetsOnly(m_spellInfo);

         if (non_caster_target)

jesper.meyr = Kealima (my google.code nickname)

[/CODE]

is that working and non crashy /emoticons/default_biggrin.png?

No idea, cant test it myself

kaelima, something is wrong. im unable to duel anyone, it just keeps saying “target is already dueling”. and when i use my teleporter and press “buff me” or “heal me” the npc targets it self xD

crash and boom too :-), I can post crashlog here, if its need

Should this


 bool isDueling() const { return duel != NULL; }

Be inserted in src/server/game/Server/Protocol/Handlers/DuelHandler.cpp ?

cant some crazy dev use 5 minutes and fix this /emoticons/default_tongue.png? would be so awsome

I think this is wrong idea, becouse const isDueling isn’t used for DUEL, but for PLAYER.

Something is wrong :-/, its very useful script, becouse its very annoying, when players break duels with heals…

I fixed it

Remove this:


bool isDueling() const { return duel != NULL; }

Then change this:


if (target != m_caster && m_caster->IsFriendlyTo(target) && target->ToPlayer()->isDueling())

to this:


if (target != m_caster && m_caster->IsFriendlyTo(target) && target->ToPlayer()->duel)

umm i just tested something ingame on my 3.3.5 client. when i try to heal a dueling player i target my self even without this script, then what exactly is the point of this script?

I think its depend on settings type of server and area/zone flags (sanctuary / contested etc…), becouse when I make sanctuary area in core, you cannot healing duel players too.

i tested in 4 different zones, can you tell me where this script would be useful?

Its only needed for Holy shock / penance / Chain heal

Fix for Penance and Holy shock:


# HG changeset patch -- Bitbucket.org

# Project Deffender BG 3.3.5a

# URL https://bitbucket.org/JaroslavPeter/deffender-bg-3.3.5a/overview

# User Jaroslav Peter <[email protected]>

# Date 1296327282 -3600

# Node ID 0c4037f9cbe0db1ccb87127ec98a6ad91bf7dc99

# Parent  69c9499860c3f72ca3a1634ddb5ebd076c2346f5

FIX Holy shock & Penance in duel


--- a/src/server/scripts/Spells/spell_paladin.cpp

+++ b/src/server/scripts/Spells/spell_paladin.cpp

@@ -279,7 +279,9 @@ public:


                 uint8 rank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id);


-                if (caster->IsFriendlyTo(unitTarget))

+                if (caster->GetGUID() != unitTarget->GetGUID() && caster->IsFriendlyTo(unitTarget) && (unitTarget->ToPlayer() != NULL && unitTarget->ToPlayer()->duel != NULL))

+                    caster->CastSpell(caster, sSpellMgr->GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_HEALING, rank), true, 0);

+                else if (caster->IsFriendlyTo(unitTarget))

                     caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_HEALING, rank), true, 0);

                 else

                     caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_DAMAGE, rank), true, 0);


--- a/src/server/scripts/Spells/spell_priest.cpp

+++ b/src/server/scripts/Spells/spell_priest.cpp

@@ -211,7 +211,9 @@ class spell_pri_penance : public SpellSc


                 uint8 rank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id);


-                if (caster->IsFriendlyTo(unitTarget))

+                if (caster->GetGUID() != unitTarget->GetGUID() && caster->IsFriendlyTo(unitTarget) && (unitTarget->ToPlayer() != NULL && unitTarget->ToPlayer()->duel != NULL)) 

+                    caster->CastSpell(caster, sSpellMgr->GetSpellWithRank(PRIEST_SPELL_PENANCE_R1_HEAL, rank), false, 0);

+                else if (caster->IsFriendlyTo(unitTarget))

                     caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(PRIEST_SPELL_PENANCE_R1_HEAL, rank), false, 0);

                 else

                     caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(PRIEST_SPELL_PENANCE_R1_DAMAGE, rank), false, 0);

Thanks, and there aren’t any other spells like penance / holy shock, that can break duel? thanks for answer