Jump to content

[patch][7559] allow script to send KilledMonster to all group members


Guest Ramses_II

Recommended Posts

What features does the patch add?

a possibility to send KilledMonster to all group members from script library is needed.

For which revision was the patch created?

6841 commit [42d0d95d08c672cfcaf8c707453d6654a7270d33]

*master

Additional info

Using Player::RewardPlayerAndGroupAtKill(Unit* Victim) from scripts is not a good idea,

so I decided to create an additional method: void Player::GroupKilledMonster( uint32 entry, uint64 guid )

this reproduces some code from Player::RewardPlayerAndGroupAtKill(Unit* Victim) but seems like the best solution for me.

any comments are welcome ;)

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 17b5e37..d0a552e 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -13054,6 +13054,24 @@ void Player::KilledMonster( uint32 entry, uint64 guid )
    }
}

+void Player::GroupKilledMonster( uint32 entry, uint64 guid )
+{
+    if (Group *pGroup = GetGroup())
+    {
+       for( GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next() )
+       {
+           Player* pGroupGuy = itr->getSource();
+           if ( !pGroupGuy )
+               continue;
+           if ( !pGroupGuy->IsAtGroupRewardDistance( this ))
+               continue;
+
+           if ( pGroupGuy->isAlive() || !pGroupGuy->GetCorpse() )
+               pGroupGuy->KilledMonster( entry, guid);
+       }
+    } else KilledMonster( entry, guid );
+}
+
void Player::CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id )
{
    bool isCreature = IS_CREATURE_GUID(guid);
@@ -16815,7 +16833,7 @@ uint32 Player::GetMaxPersonalArenaRatingRequirement()
    }
    return max_personal_rating;
}
-
+
void Player::UpdateHomebindTime(uint32 time)
{
    // GMs never get homebind timer online
diff --git a/src/game/Player.h b/src/game/Player.h
index 2bf300e..b7e6b84 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1218,6 +1218,7 @@ class MANGOS_DLL_SPEC Player : public Unit
        void ItemAddedQuestCheck( uint32 entry, uint32 count );
        void ItemRemovedQuestCheck( uint32 entry, uint32 count );
        void KilledMonster( uint32 entry, uint64 guid );
+       void GroupKilledMonster( uint32 entry, uint64 guid );
        void CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id );
        void TalkedToCreature( uint32 entry, uint64 guid );
        void MoneyChanged( uint32 value );

Link to comment
Share on other sites

Personally I would go further... instead of .. Single /Group Quest method... put into one function... This would include all kinds of Quest Complete functions.. if the quest shareabel it should search group members and complete specific quest parts. Don't forget pets.. but I don't know how they deal with the situation...

Link to comment
Share on other sites

I don't know exactly what you mean.

Merging all functions updating quest objectives is not a good idea imo.

Not all quest objectives are handled in the same way.

Btw. shareable quests do not mean counting objectives for group members, it says quest can be given to group meber with share quest button.

Counting kills of quest creatures for groups is done in Player::RewardPlayerAndGroupAtKill(Unit* Victim)

this is the correct place for it, also handling everything related to creature kills like XP, honor etc.

This patch is only needed for external scripts which need to count creature kills without rewarding the kill itself. (e.g. quest triggers)

my method GroupKilledMonster is used like Player::GroupEventHappens perhaps this makes it more clear.

Link to comment
Share on other sites

  • 2 months later...

Hi,

sry for the late answer. I'm not really active atm, cause im really busy.

Yes this patch will alow (e.g a script) to call GroupKilledMonster for a group member and the credit (entry) will be awarded for all group members with active quest. So this code is no longer needed in script library (it's also unwanted there).

The patch is quite old and I don't know if it currently compiles. I will try to find the time to check and update the patch during the next week.

Link to comment
Share on other sites

  • 4 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