Add PlayerScript hooks:

* OnMoneyChanged
* OnGiveXP
* OnReputationChange
* OnChat
* OnEmote
* OnTextEmote

--HG--
branch : trunk
This commit is contained in:
silinoron
2010-08-11 22:53:31 -07:00
parent ce29cfa7f7
commit c7b48c1ca9
6 changed files with 98 additions and 20 deletions
@@ -2614,6 +2614,8 @@ void Player::GiveXP(uint32 xp, Unit* victim)
uint8 level = getLevel();
sScriptMgr.OnGivePlayerXP(this, xp, victim);
// Favored experience increase START
uint32 zone = GetZoneId();
float favored_exp_mult = 0;
@@ -20707,6 +20709,28 @@ void Player::InitPrimaryProfessions()
SetFreePrimaryProfessions(sWorld.getConfig(CONFIG_MAX_PRIMARY_TRADE_SKILL));
}
void Player::ModifyMoney(int32 d)
{
sScriptMgr.OnPlayerMoneyChanged(this, d);
if (d < 0)
SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0);
else
{
uint32 newAmount = 0;
if (GetMoney() < uint32(MAX_MONEY_AMOUNT - d))
newAmount = GetMoney() + d;
else
{
// "At Gold Limit"
newAmount = MAX_MONEY_AMOUNT;
if (d)
SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD, NULL, NULL);
}
SetMoney (newAmount);
}
}
Unit * Player::GetSelectedUnit() const
{
if (m_curSelection)
+2 -20
View File
@@ -25,7 +25,6 @@
#include "ItemPrototype.h"
#include "Unit.h"
#include "Item.h"
#include "DatabaseEnv.h"
#include "NPCHandler.h"
#include "QuestDef.h"
@@ -1447,25 +1446,8 @@ class Player : public Unit, public GridObject<Player>
void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;}
uint32 GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE); }
void ModifyMoney(int32 d)
{
if (d < 0)
SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0);
else
{
uint32 newAmount = 0;
if (GetMoney() < uint32(MAX_MONEY_AMOUNT - d))
newAmount = GetMoney() + d;
else
{
// "At Gold Limit"
newAmount = MAX_MONEY_AMOUNT;
if (d)
SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD, NULL, NULL);
}
SetMoney (newAmount);
}
}
void ModifyMoney(int32 d);
void SetMoney(uint32 value)
{
SetUInt32Value (PLAYER_FIELD_COINAGE, value);