Jump to content

[FIX] Judgement of the wise


kozelo

Recommended Posts

  • Replies 77
  • Created
  • Last Reply

Top Posters In This Topic

here is kozelo's patch on diff format

Spell.cpp:

--- patch/src/game/Spell.cpp    2009-03-13 11:36:30.000000000 -0200
+++ mangos/src/game/Spell.cpp    2009-03-13 11:40:01.000000000 -0200
@@ -49,6 +49,14 @@

extern pEffect SpellEffects[TOTAL_SPELL_EFFECTS];

+class PrioritizeMana
+{
+    public:int operator()( const Player* x, const Player* y ) const {
+            return ((x->GetPower(POWER_MANA)/x->GetMaxPower(POWER_MANA) * 100) < (y->GetPower(POWER_MANA)/y->GetMaxPower(POWER_MANA)*100)); 
+    }
+};
+
+
bool IsQuestTameSpell(uint32 spellId)
{
    SpellEntry const *spellproto = sSpellStore.LookupEntry(spellId);
@@ -1592,25 +1600,50 @@

            if(pGroup)
            {
-                uint8 subgroup = pTarget->GetSubGroup();
-
-                for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
-                {
-                    Player* Target = itr->getSource();
-
-                    // IsHostileTo check duel and controlled by enemy
-                    if( Target &&
-                        (cur==TARGET_ALL_RAID_AROUND_CASTER || Target->GetSubGroup()==subgroup) &&
-                        !m_caster->IsHostileTo(Target) )
-                    {
-                        if( m_caster->IsWithinDistInMap(Target, radius) )
-                            TagUnitMap.push_back(Target);
-
-                        if(Pet* pet = Target->GetPet())
-                            if( m_caster->IsWithinDistInMap(pet, radius) )
-                                TagUnitMap.push_back(pet);
-                    }
-                }
+        if(m_spellInfo->Id==57669) //Replenishment
+        {
+        typedef std::Priority_queue<Player*, std::vector<Player*>, PrioritizeMana> Top10;
+        Top10 manaUsers;
+
+            for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
+                {
+                    Player* Target = itr->getSource();
+                    if(m_caster->GetGUID() != Target->GetGUID() && Target->getPowerType() == POWER_MANA && !Target->isDead() && m_caster->IsWithinDistInMap(Target, radius))
+                    {
+                        manaUsers.push(Target);
+                    }
+                }
+
+                for(int countera=0; ( !manaUsers.empty() )&& countera<10;countera++)
+                {
+                    Player* Target = manaUsers.top();
+                    manaUsers.pop();
+                    TagUnitMap.push_back(Target);
+                }
+        }
+        else
+        {
+
+                uint8 subgroup = pTarget->GetSubGroup();
+
+                for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
+                {
+                    Player* Target = itr->getSource();
+
+                    // IsHostileTo check duel and controlled by enemy
+                    if( Target &&
+                        (cur==TARGET_ALL_RAID_AROUND_CASTER || Target->GetSubGroup()==subgroup) &&
+                        !m_caster->IsHostileTo(Target) )
+                    {
+                        if( m_caster->IsWithinDistInMap(Target, radius) )
+                            TagUnitMap.push_back(Target);
+
+                        if(Pet* pet = Target->GetPet())
+                            if( m_caster->IsWithinDistInMap(pet, radius) )
+                                TagUnitMap.push_back(pet);
+                    }
+                }
+        }
            }
            else
            {

SpellEffects.cpp:

--- patch/src/game/SpellEffects.cpp    2009-03-13 11:36:39.000000000 -0200
+++ mangos/src/game/SpellEffects.cpp    2009-03-13 11:42:19.000000000 -0200
@@ -5158,6 +5158,24 @@
                    default:
                        return;
                }
+        //Judgement of the wise
+        int chance =0;
+        int32 aur =0;
+        if(m_caster->HasAura(31876)) {chance=33;aur=31876;}
+        else if (m_caster->HasAura(31877)) {chance=66;aur=31877;}
+        else if (m_caster->HasAura(31878)) {chance=100;aur=31878;}
+        if(chance != 0)
+        {
+            int32 mana15 = m_caster->GetCreateMana() * 0.15;
+            if(urand(1,100) <= chance) 
+            {
+                m_caster->CastCustomSpell(m_caster,31930,&mana15,false,false,true,NULL,m_caster->GetDummyAura(aur),m_caster->GetGUID());
+                                m_caster->CastSpell(m_caster,57669,true,NULL,m_caster->GetDummyAura(aur),m_caster->GetGUID());
+            }
+                    
+        }        
+        //Judgement of the wise end 
+
                // all seals have aura dummy in 2 effect
                Unit::AuraList const& m_dummyAuras = m_caster->GetAurasByType(SPELL_AURA_DUMMY);
                for(Unit::AuraList::const_iterator itr = m_dummyAuras.begin(); itr != m_dummyAuras.end(); ++itr)

Link to comment
Share on other sites

i have been over the comparer, and i think the currently used is less than optimal.

so im puting a wrapper around the player object. it calculates the filled mana percentage upon construction. this prevents the constant calculation of the percentages every time the sorting takes place speeding up things a bit.

Spell.cpp:

--- patch/src/game/Spell.cpp    2009-03-13 11:36:30.000000000 -0200
+++ mangos/src/game/Spell.cpp    2009-03-13 12:14:55.000000000 -0200
@@ -48,6 +48,27 @@
#define SPELL_CHANNEL_UPDATE_INTERVAL (1*IN_MILISECONDS)

extern pEffect SpellEffects[TOTAL_SPELL_EFFECTS];
+class ReplenishPlayerWraper
+{
+    Player* player;
+    uint32 percentMana;
+    friend class PrioritizeMana;
+public:
+    ReplenishPlayerWraper(Player* player):Player(player)
+    {
+        percentMana=(player->GetPower(POWER_MANA)/player->GetMaxPower(POWER_MANA)) * 100;
+    }
+    Player* getPlayer(){
+        return player;
+    }
+};
+class PrioritizeMana
+{
+    public:int operator()( const ReplenishPlayerWraper& x, const ReplenishPlayerWraper& y ) const {
+            return x.percentMana < y.percentMana;
+    }
+};
+

bool IsQuestTameSpell(uint32 spellId)
{
@@ -1592,25 +1613,52 @@

            if(pGroup)
            {
-                uint8 subgroup = pTarget->GetSubGroup();
-
-                for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
-                {
-                    Player* Target = itr->getSource();
-
-                    // IsHostileTo check duel and controlled by enemy
-                    if( Target &&
-                        (cur==TARGET_ALL_RAID_AROUND_CASTER || Target->GetSubGroup()==subgroup) &&
-                        !m_caster->IsHostileTo(Target) )
-                    {
-                        if( m_caster->IsWithinDistInMap(Target, radius) )
-                            TagUnitMap.push_back(Target);
-
-                        if(Pet* pet = Target->GetPet())
-                            if( m_caster->IsWithinDistInMap(pet, radius) )
-                                TagUnitMap.push_back(pet);
-                    }
-                }
+        if(m_spellInfo->Id==57669) //Replenishment
+        {
+        typedef std::Priority_queue<ReplenishPlayerWraper, std::vector<ReplenishPlayerWraper>, PrioritizeMana> Top10;
+        Top10 manaUsers;
+
+            for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
+                {
+                    Player* Target = itr->getSource();
+                    if(m_caster->GetGUID() != Target->GetGUID() && Target->getPowerType() == POWER_MANA && !Target->isDead() && m_caster->IsWithinDistInMap(Target, radius))
+                    {
+                        ReplenishPlayerWraper WTarget(Target);
+                        manaUsers.push(WTarget);
+                    }
+                }
+
+                for(int countera=0; ( !manaUsers.empty() )&& countera<10;countera++)
+                {
+                    ReplenishPlayerWraper WTarget =    manaUsers.top();
+                    Player* Target = WTarget.getPlayer();
+                    manaUsers.pop();
+                    TagUnitMap.push_back(Target);
+                }
+        }
+        else
+        {
+
+                uint8 subgroup = pTarget->GetSubGroup();
+
+                for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
+                {
+                    Player* Target = itr->getSource();
+
+                    // IsHostileTo check duel and controlled by enemy
+                    if( Target &&
+                        (cur==TARGET_ALL_RAID_AROUND_CASTER || Target->GetSubGroup()==subgroup) &&
+                        !m_caster->IsHostileTo(Target) )
+                    {
+                        if( m_caster->IsWithinDistInMap(Target, radius) )
+                            TagUnitMap.push_back(Target);
+
+                        if(Pet* pet = Target->GetPet())
+                            if( m_caster->IsWithinDistInMap(pet, radius) )
+                                TagUnitMap.push_back(pet);
+                    }
+                }
+        }
            }
            else
            {

for SpellEffects.cpp use the patch on my previous post.

PS: i have been testing it. and it seems is granting replenishment whatever the player is on a party or not. dont know if this is intented or not

Link to comment
Share on other sites

i you replace on SpellEffects.cpp:

  m_caster->CastSpell(m_caster,57669,true,NULL,m_caster->GetDummyAura(aur),m_caster->GetGUID());

by

if (((Player*)m_caster)->GetGroup()) m_caster->CastSpell(m_caster,57669,true,NULL,m_caster->GetDummyAura(aur),m_caster->GetGUID());

replenishment will not be cast while not in group

Link to comment
Share on other sites

1)??? weird. you could try and replace it by

percentMana=((player->GetPower(POWER_MANA)/player->GetMaxPower(POWER_MANA) * 100);

2) i guess i'd never thought of using the object for some player thats not mana based. the replenishment function filters them out.

however someone might do something nasty. this check on the constructor will prevent that

ReplenishPlayerWraper(Player* player):Player(player)
{
        if(Target->getPowerType() == POWER_MANA)
       percentMana=((player->GetPower(POWER_MANA)/player->GetMaxPower(POWER_MANA) * 100);
       else
              percentMana=101;

}

Link to comment
Share on other sites

I think that it's right. GetMaxPower means get the maximum amount of power available to that player at any given time; aka base mana.

I think this is wrong. in like cases in description write: max mana, and base mana referecnes to mana without bonuses. For example when writed spell cost in percent from base mana we use: m_caster->GetCreateMana()

Link to comment
Share on other sites

This is C++: int/int = int

So need first *100 and only after / or use floats.

you are right. i missed that

percentMana=(player->GetPower(POWER_MANA)*100)/player->GetMaxPower(POWER_MANA);

that would be the correct way to do it.

odd this problem hasnt shown up on the first patch

Link to comment
Share on other sites

In fact i have modified patch already at you post time, so i push target seelction part to [7481]. Thank you :)

1) In not added part i not like aura checks by spell ids.

Talent have proc flags and code must be in aura dummy spell proc function: Unit::HandleDummyAuraProc

2) from description meaning that mana restore at percent of target max mana? so Custom spell incorrect and mana gain must calculated into Energize effect. Not sure at 100% from other side

Link to comment
Share on other sites

2) from description meaning that mana restore at percent of target max mana?

No its 15% of base mana per Judgement.

Rank 3:

http://www.wowhead.com/?spell=31878

Your Judgement spells have a 100% chance to grant the Replenishment effect to up to 10 party or raid members mana regeneration equal to 0.25% of their maximum mana per second, and to immediately grant you 15% of your base mana.
Link to comment
Share on other sites

fix spell_proc_event for spell chance and procflags

delete from `spell_proc_event` where entry in (31876,31877,31878);
insert into `spell_proc_event` (`entry`, `SchoolMask`, `SpellFamilyName`, `SpellFamilyMask0`, `SpellFamilyMask1`, `SpellFamilyMask2`, `procFlags`, `procEx`, `ppmRate`, `CustomChance`, `Cooldown`) values('31876','0','10','8388608','0','0','16','0','0','33','0');
insert into `spell_proc_event` (`entry`, `SchoolMask`, `SpellFamilyName`, `SpellFamilyMask0`, `SpellFamilyMask1`, `SpellFamilyMask2`, `procFlags`, `procEx`, `ppmRate`, `CustomChance`, `Cooldown`) values('31877','0','10','8388608','0','0','16','0','0','66','0');
insert into `spell_proc_event` (`entry`, `SchoolMask`, `SpellFamilyName`, `SpellFamilyMask0`, `SpellFamilyMask1`, `SpellFamilyMask2`, `procFlags`, `procEx`, `ppmRate`, `CustomChance`, `Cooldown`) values('31878','0','10','8388608','0','0','16','0','0','100','0');

diff is for revision 7477

diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 839ebe2..f50b709 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -5344,6 +5344,16 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu
        }
        case SPELLFAMILY_PALADIN:
        {
+    //Judgements of the wise 
+    if ( dummySpell->SpellIconID==3017 )
+    {
+            target = this;
+            triggered_spell_id =31930;
+            basepoints0 = GetCreateMana() * 0.15;
+            CastSpell ( this,57669,true,NULL,GetDummyAura ( dummySpell->Id ),GetGUID() );
+        break;
+    }
+
            // Seal of Righteousness - melee proc dummy (addition ${$MWS*(0.022*$AP+0.044*$SPH)} damage)
            if (dummySpell->SpellFamilyFlags&0x000000008000000LL && effIndex==0)
            {

Link to comment
Share on other sites

  • 3 weeks later...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use