aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/updates/world/3.3.5/2016_04_23_01_world.sql4
-rw-r--r--src/server/game/Entities/Player/Player.cpp53
-rw-r--r--src/server/game/Entities/Player/Player.h6
-rw-r--r--src/server/game/Entities/Unit/Unit.h10
-rw-r--r--src/server/game/Handlers/GroupHandler.cpp26
-rw-r--r--src/server/game/Spells/SpellEffects.cpp22
-rw-r--r--src/server/scripts/Spells/spell_item.cpp102
7 files changed, 175 insertions, 48 deletions
diff --git a/sql/updates/world/3.3.5/2016_04_23_01_world.sql b/sql/updates/world/3.3.5/2016_04_23_01_world.sql
new file mode 100644
index 00000000000..d1be7adacfc
--- /dev/null
+++ b/sql/updates/world/3.3.5/2016_04_23_01_world.sql
@@ -0,0 +1,4 @@
+DELETE FROM `spell_script_names` WHERE `ScriptName` IN ('spell_item_decahedral_dwarven_dice', 'spell_item_worn_troll_dice');
+INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
+(47770, 'spell_item_decahedral_dwarven_dice'),
+(47776, 'spell_item_worn_troll_dice');
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index a74334621a3..4a5ebe3a8a5 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -20051,6 +20051,11 @@ void Player::Say(std::string const& text, Language language, WorldObject const*
SendMessageToSetInRange(packet.Write(), sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), true);
}
+void Player::Say(uint32 textId, WorldObject const* target /*= nullptr*/)
+{
+ Talk(textId, CHAT_MSG_SAY, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), target);
+}
+
void Player::Yell(std::string const& text, Language language, WorldObject const* /*= nullptr*/)
{
std::string _text(text);
@@ -20061,6 +20066,11 @@ void Player::Yell(std::string const& text, Language language, WorldObject const*
SendMessageToSetInRange(packet.Write(), sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), true);
}
+void Player::Yell(uint32 textId, WorldObject const* target /*= nullptr*/)
+{
+ Talk(textId, CHAT_MSG_YELL, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), target);
+}
+
void Player::TextEmote(std::string const& text, WorldObject const* /*= nullptr*/, bool /*= false*/)
{
std::string _text(text);
@@ -20084,6 +20094,11 @@ void Player::WhisperAddon(std::string const& text, const std::string& prefix, Pl
receiver->SendDirectMessage(packet.Write());
}
+void Player::TextEmote(uint32 textId, WorldObject const* target /*= nullptr*/, bool /*isBossEmote = false*/)
+{
+ Talk(textId, CHAT_MSG_EMOTE, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), target);
+}
+
void Player::Whisper(std::string const& text, Language language, Player* target, bool /*= false*/)
{
ASSERT(target);
@@ -20120,6 +20135,24 @@ void Player::Whisper(std::string const& text, Language language, Player* target,
ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_DND, target->GetName().c_str(), target->autoReplyMsg.c_str());
}
+void Player::Whisper(uint32 textId, Player* target, bool /*isBossWhisper = false*/)
+{
+ if (!target)
+ return;
+
+ BroadcastTextEntry const* bct = sBroadcastTextStore.LookupEntry(textId);
+ if (!bct)
+ {
+ TC_LOG_ERROR("entities.unit", "WorldObject::MonsterWhisper: `broadcast_text` was not %u found", textId);
+ return;
+ }
+
+ LocaleConstant locale = target->GetSession()->GetSessionDbLocaleIndex();
+ WorldPackets::Chat::Chat packet;
+ packet.Initialize(CHAT_MSG_WHISPER, LANG_UNIVERSAL, this, target, DB2Manager::GetBroadcastTextValue(bct, locale, getGender()));
+ target->SendDirectMessage(packet.Write());
+}
+
Item* Player::GetMItem(ObjectGuid::LowType id)
{
ItemMap::const_iterator itr = mMitems.find(id);
@@ -26368,3 +26401,23 @@ void Player::RemoveRestFlag(RestFlag restFlag)
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
}
}
+
+uint32 Player::DoRandomRoll(uint32 minimum, uint32 maximum)
+{
+ ASSERT(maximum <= 10000);
+
+ uint32 roll = urand(minimum, maximum);
+
+ WorldPackets::Misc::RandomRoll randomRoll;
+ randomRoll.Min = minimum;
+ randomRoll.Max = maximum;
+ randomRoll.Result = roll;
+ randomRoll.Roller = GetGUID();
+ randomRoll.RollerWowAccount = GetSession()->GetAccountGUID();
+ if (Group* group = GetGroup())
+ group->BroadcastPacket(randomRoll.Write(), false);
+ else
+ SendDirectMessage(randomRoll.Write());
+
+ return roll;
+}
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 93e5d5a2753..1e9f949b721 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1304,12 +1304,16 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
/// Handles said message in regular chat based on declared language and in config pre-defined Range.
void Say(std::string const& text, Language language, WorldObject const* = nullptr) override;
+ void Say(uint32 textId, WorldObject const* target = nullptr) override;
/// Handles yelled message in regular chat based on declared language and in config pre-defined Range.
void Yell(std::string const& text, Language language, WorldObject const* = nullptr) override;
+ void Yell(uint32 textId, WorldObject const* target = nullptr) override;
/// Outputs an universal text which is supposed to be an action.
void TextEmote(std::string const& text, WorldObject const* = nullptr, bool = false) override;
+ void TextEmote(uint32 textId, WorldObject const* target = nullptr, bool isBossEmote = false) override;
/// Handles whispers from Addons and players based on sender, receiver's guid and language.
void Whisper(std::string const& text, Language language, Player* receiver, bool = false) override;
+ void Whisper(uint32 textId, Player* target, bool isBossWhisper = false) override;
void WhisperAddon(std::string const& text, std::string const& prefix, Player* receiver);
/*********************************************************/
@@ -2334,6 +2338,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void SendCinematicStart(uint32 CinematicSequenceId) const;
void SendMovieStart(uint32 MovieId) const;
+ uint32 DoRandomRoll(uint32 minimum, uint32 maximum);
+
/*********************************************************/
/*** INSTANCE SYSTEM ***/
/*********************************************************/
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 8db238f2e88..d0d824b41c0 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -2226,11 +2226,11 @@ class TC_GAME_API Unit : public WorldObject
virtual void Yell(std::string const& text, Language language, WorldObject const* target = nullptr);
virtual void TextEmote(std::string const& text, WorldObject const* target = nullptr, bool isBossEmote = false);
virtual void Whisper(std::string const& text, Language language, Player* target, bool isBossWhisper = false);
- void Talk(uint32 textId, ChatMsg msgType, float textRange, WorldObject const* target);
- void Say(uint32 textId, WorldObject const* target = nullptr);
- void Yell(uint32 textId, WorldObject const* target = nullptr);
- void TextEmote(uint32 textId, WorldObject const* target = nullptr, bool isBossEmote = false);
- void Whisper(uint32 textId, Player* target, bool isBossWhisper = false);
+ virtual void Talk(uint32 textId, ChatMsg msgType, float textRange, WorldObject const* target);
+ virtual void Say(uint32 textId, WorldObject const* target = nullptr);
+ virtual void Yell(uint32 textId, WorldObject const* target = nullptr);
+ virtual void TextEmote(uint32 textId, WorldObject const* target = nullptr, bool isBossEmote = false);
+ virtual void Whisper(uint32 textId, Player* target, bool isBossWhisper = false);
uint32 GetVirtualItemId(uint32 slot) const;
uint16 GetVirtualItemAppearanceMod(uint32 slot) const;
diff --git a/src/server/game/Handlers/GroupHandler.cpp b/src/server/game/Handlers/GroupHandler.cpp
index 297cd9c3124..ec29083d2f8 100644
--- a/src/server/game/Handlers/GroupHandler.cpp
+++ b/src/server/game/Handlers/GroupHandler.cpp
@@ -21,16 +21,16 @@
#include "Group.h"
#include "GroupMgr.h"
#include "Log.h"
+#include "LootPackets.h"
+#include "MiscPackets.h"
#include "ObjectMgr.h"
+#include "PartyPackets.h"
#include "Player.h"
#include "SocialMgr.h"
#include "Util.h"
#include "World.h"
#include "WorldPacket.h"
#include "WorldSession.h"
-#include "MiscPackets.h"
-#include "LootPackets.h"
-#include "PartyPackets.h"
class Aura;
@@ -398,28 +398,12 @@ void WorldSession::HandleMinimapPingOpcode(WorldPackets::Party::MinimapPingClien
void WorldSession::HandleRandomRollOpcode(WorldPackets::Misc::RandomRollClient& packet)
{
- uint32 minimum, maximum, roll;
- minimum = packet.Min;
- maximum = packet.Max;
-
/** error handling **/
- if (minimum > maximum || maximum > 10000) // < 32768 for urand call
+ if (packet.Min > packet.Max || packet.Max > 10000) // < 32768 for urand call
return;
/********************/
- // everything's fine, do it
- roll = urand(minimum, maximum);
-
- WorldPackets::Misc::RandomRoll randomRoll;
- randomRoll.Min = minimum;
- randomRoll.Max = maximum;
- randomRoll.Result = roll;
- randomRoll.Roller = GetPlayer()->GetGUID();
- randomRoll.RollerWowAccount = GetAccountGUID();
- if (GetPlayer()->GetGroup())
- GetPlayer()->GetGroup()->BroadcastPacket(randomRoll.Write(), false);
- else
- SendPacket(randomRoll.Write());
+ GetPlayer()->DoRandomRoll(packet.Min, packet.Max);
}
void WorldSession::HandleUpdateRaidTargetOpcode(WorldPackets::Party::UpdateRaidTarget& packet)
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 2a6a69cbb78..4d1c5ab06a9 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -3500,28 +3500,6 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
break;
}
- // Roll Dice - Decahedral Dwarven Dice
- case 47770:
- {
- char buf[128];
- const char *gender = "his";
- if (m_caster->getGender() > 0)
- gender = "her";
- sprintf(buf, "%s rubs %s [Decahedral Dwarven Dice] between %s hands and rolls. One %u and one %u.", m_caster->GetName().c_str(), gender, gender, urand(1, 10), urand(1, 10));
- m_caster->TextEmote(buf);
- break;
- }
- // Roll 'dem Bones - Worn Troll Dice
- case 47776:
- {
- char buf[128];
- const char *gender = "his";
- if (m_caster->getGender() > 0)
- gender = "her";
- sprintf(buf, "%s causually tosses %s [Worn Troll Dice]. One %u and one %u.", m_caster->GetName().c_str(), gender, urand(1, 6), urand(1, 6));
- m_caster->TextEmote(buf);
- break;
- }
// Death Knight Initiate Visual
case 51519:
{
diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp
index 23dfd4d85a7..d6938cdc3b1 100644
--- a/src/server/scripts/Spells/spell_item.cpp
+++ b/src/server/scripts/Spells/spell_item.cpp
@@ -201,6 +201,55 @@ class spell_item_blessing_of_ancient_kings : public SpellScriptLoader
}
};
+// 47770 - Roll Dice
+class spell_item_decahedral_dwarven_dice : public SpellScriptLoader
+{
+ public:
+ spell_item_decahedral_dwarven_dice() : SpellScriptLoader("spell_item_decahedral_dwarven_dice") { }
+
+ class spell_item_decahedral_dwarven_dice_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_item_decahedral_dwarven_dice_SpellScript);
+
+ enum
+ {
+ TEXT_DECAHEDRAL_DWARVEN_DICE = 26147
+ };
+
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ if (!sObjectMgr->GetBroadcastText(TEXT_DECAHEDRAL_DWARVEN_DICE))
+ return false;
+ return true;
+ }
+
+ bool Load() override
+ {
+ return GetCaster()->GetTypeId() == TYPEID_PLAYER;
+ }
+
+ void HandleScript(SpellEffIndex /*effIndex*/)
+ {
+ GetCaster()->TextEmote(TEXT_DECAHEDRAL_DWARVEN_DICE, GetHitUnit());
+
+ static uint32 const minimum = 1;
+ static uint32 const maximum = 100;
+
+ GetCaster()->ToPlayer()->DoRandomRoll(minimum, maximum);
+ }
+
+ void Register() override
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_item_decahedral_dwarven_dice_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new spell_item_decahedral_dwarven_dice_SpellScript();
+ }
+};
+
// 8342 - Defibrillate (Goblin Jumper Cables) have 33% chance on success
// 22999 - Defibrillate (Goblin Jumper Cables XL) have 50% chance on success
// 54732 - Defibrillate (Gnomish Army Knife) have 67% chance on success
@@ -1325,6 +1374,57 @@ class spell_item_underbelly_elixir : public SpellScriptLoader
}
};
+// 47776 - Roll 'dem Bones
+class spell_item_worn_troll_dice : public SpellScriptLoader
+{
+ public:
+ spell_item_worn_troll_dice() : SpellScriptLoader("spell_item_worn_troll_dice") { }
+
+ class spell_item_worn_troll_dice_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_item_worn_troll_dice_SpellScript);
+
+ enum
+ {
+ TEXT_WORN_TROLL_DICE = 26152
+ };
+
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ if (!sObjectMgr->GetBroadcastText(TEXT_WORN_TROLL_DICE))
+ return false;
+ return true;
+ }
+
+ bool Load() override
+ {
+ return GetCaster()->GetTypeId() == TYPEID_PLAYER;
+ }
+
+ void HandleScript(SpellEffIndex /*effIndex*/)
+ {
+ GetCaster()->TextEmote(TEXT_WORN_TROLL_DICE, GetHitUnit());
+
+ static uint32 const minimum = 1;
+ static uint32 const maximum = 6;
+
+ // roll twice
+ GetCaster()->ToPlayer()->DoRandomRoll(minimum, maximum);
+ GetCaster()->ToPlayer()->DoRandomRoll(minimum, maximum);
+ }
+
+ void Register() override
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_item_worn_troll_dice_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new spell_item_worn_troll_dice_SpellScript();
+ }
+};
+
enum AirRifleSpells
{
SPELL_AIR_RIFLE_HOLD_VISUAL = 65582,
@@ -2643,6 +2743,7 @@ void AddSC_item_spell_scripts()
new spell_item_aegis_of_preservation();
new spell_item_arcane_shroud();
new spell_item_blessing_of_ancient_kings();
+ new spell_item_decahedral_dwarven_dice();
new spell_item_defibrillate("spell_item_goblin_jumper_cables", 67, SPELL_GOBLIN_JUMPER_CABLES_FAIL);
new spell_item_defibrillate("spell_item_goblin_jumper_cables_xl", 50, SPELL_GOBLIN_JUMPER_CABLES_XL_FAIL);
new spell_item_defibrillate("spell_item_gnomish_army_knife", 33);
@@ -2667,6 +2768,7 @@ void AddSC_item_spell_scripts()
new spell_item_six_demon_bag();
new spell_item_the_eye_of_diminution();
new spell_item_underbelly_elixir();
+ new spell_item_worn_troll_dice();
new spell_item_red_rider_air_rifle();
new spell_item_create_heart_candy();