mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 02:46:33 +01:00
Implement a PlayerScript class with a handful of new hooks:
* OnPVPKill * OnCreatureKill * OnPlayerKilledByCreature * OnPlayerLevelChanged * OnPlayerFreeTalentPointsChanged * OnPlayerTalentsReset * More hooks may be added in the future --HG-- branch : trunk
This commit is contained in:
@@ -652,6 +652,33 @@ class AchievementCriteriaScript : public ScriptObject
|
||||
virtual bool OnCheck(Player* source, Unit* target) = 0;
|
||||
};
|
||||
|
||||
class PlayerScript : public ScriptObject
|
||||
{
|
||||
protected:
|
||||
PlayerScript(const char* name);
|
||||
|
||||
public:
|
||||
bool IsDatabaseBound() const { return false; }
|
||||
|
||||
// Called when a player kills another player
|
||||
virtual void OnPVPKill(Player *killer, Player *killed);
|
||||
|
||||
// Called when a player kills a creature
|
||||
virtual void OnCreatureKill(Player *killer, Creature *killed);
|
||||
|
||||
// Called when a player is killed by a creature
|
||||
virtual void OnPlayerKilledByCreature(Creature *killer, Player *killed);
|
||||
|
||||
// Called when a player's level changes (right before the level is applied)
|
||||
virtual void OnLevelChanged(Player *player, uint8 newLevel);
|
||||
|
||||
// Called when a player's free talent points change (right before the change is applied)
|
||||
virtual void OnFreeTalentPointsChanged(Player *player, uint32 points);
|
||||
|
||||
// Called when a player's talent points are reset (right before the reset is done)
|
||||
virtual void OnTalentsReset(Player *player, bool no_cost);
|
||||
};
|
||||
|
||||
// Placed here due to ScriptRegistry::AddScript dependency.
|
||||
#define sScriptMgr (*ACE_Singleton<ScriptMgr, ACE_Null_Mutex>::instance())
|
||||
|
||||
@@ -824,6 +851,14 @@ class ScriptMgr
|
||||
|
||||
bool OnCriteriaCheck(AchievementCriteriaData const* data, Player* source, Unit* target);
|
||||
|
||||
public: /* PlayerScript */
|
||||
void OnPVPKill(Player *killer, Player *killed);
|
||||
void OnCreatureKill(Player *killer, Creature *killed);
|
||||
void OnPlayerKilledByCreature(Creature *killer, Player *killed);
|
||||
void OnPlayerLevelChanged(Player *player, uint8 newLevel);
|
||||
void OnPlayerFreeTalentPointsChanged(Player *player, uint32 newPoints);
|
||||
void OnPlayerTalentsReset(Player *player, bool no_cost);
|
||||
|
||||
public: /* ScriptRegistry */
|
||||
|
||||
// This is the global static registry of scripts.
|
||||
|
||||
Reference in New Issue
Block a user