aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/Chat/Commands/Level2.cpp2
-rw-r--r--src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp4
-rw-r--r--src/server/scripts/World/npc_professions.cpp584
3 files changed, 203 insertions, 387 deletions
diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp
index ea7f17201d5..7362353b3cf 100755
--- a/src/server/game/Chat/Commands/Level2.cpp
+++ b/src/server/game/Chat/Commands/Level2.cpp
@@ -87,7 +87,7 @@ bool ChatHandler::HandleMuteCommand(const char* args)
else
{
//! Target is offline, mute will be in effect starting from the next login.
- int32 muteTime = -(notspeaktime * MINUTE);
+ int32 muteTime = -int32(notspeaktime * MINUTE);
LoginDatabase.PExecute("UPDATE account SET mutetime = %d WHERE id = %u", muteTime, account_id);
}
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp b/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp
index 4e0c50972ff..4b2776b688f 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp
+++ b/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp
@@ -712,8 +712,8 @@ class boss_stormcaller_brundir : public CreatureScript
case EVENT_MOVE_POSITION:
if (me->IsWithinMeleeRange(me->getVictim()))
{
- float x = irand(-25, 25);
- float y = irand(-25, 25);
+ float x = float(irand(-25, 25));
+ float y = float(irand(-25, 25));
me->GetMotionMaster()->MovePoint(0, me->GetPositionX() + x, me->GetPositionY() + y, FLOOR_Z);
// Prevention to go outside the room or into the walls
if (Creature* trigger = me->FindNearestCreature(NPC_WORLD_TRIGGER, 100.0f, true))
diff --git a/src/server/scripts/World/npc_professions.cpp b/src/server/scripts/World/npc_professions.cpp
index 66fdf0a3fbe..af3544d2bd3 100644
--- a/src/server/scripts/World/npc_professions.cpp
+++ b/src/server/scripts/World/npc_professions.cpp
@@ -107,75 +107,77 @@ there is no difference here (except that default text is chosen with `gameobject
/*###
# spells defines
###*/
-
-#define S_WEAPON 9787
-#define S_ARMOR 9788
-#define S_HAMMER 17040
-#define S_AXE 17041
-#define S_SWORD 17039
-
-#define S_LEARN_WEAPON 9789
-#define S_LEARN_ARMOR 9790
-#define S_LEARN_HAMMER 39099
-#define S_LEARN_AXE 39098
-#define S_LEARN_SWORD 39097
-
-#define S_UNLEARN_WEAPON 36436
-#define S_UNLEARN_ARMOR 36435
-#define S_UNLEARN_HAMMER 36441
-#define S_UNLEARN_AXE 36439
-#define S_UNLEARN_SWORD 36438
-
-#define S_REP_ARMOR 17451
-#define S_REP_WEAPON 17452
-
-#define REP_ARMOR 46
-#define REP_WEAPON 289
-#define REP_HAMMER 569
-#define REP_AXE 570
-#define REP_SWORD 571
-
-#define S_DRAGON 10656
-#define S_ELEMENTAL 10658
-#define S_TRIBAL 10660
-
-#define S_LEARN_DRAGON 10657
-#define S_LEARN_ELEMENTAL 10659
-#define S_LEARN_TRIBAL 10661
-
-#define S_UNLEARN_DRAGON 36434
-#define S_UNLEARN_ELEMENTAL 36328
-#define S_UNLEARN_TRIBAL 36433
-
-#define S_GOBLIN 20222
-#define S_GNOMISH 20219
-
-#define S_LEARN_GOBLIN 20221
-#define S_LEARN_GNOMISH 20220
-
-#define S_SPELLFIRE 26797
-#define S_MOONCLOTH 26798
-#define S_SHADOWEAVE 26801
-
-#define S_LEARN_SPELLFIRE 26796
-#define S_LEARN_MOONCLOTH 26799
-#define S_LEARN_SHADOWEAVE 26800
-
-#define S_UNLEARN_SPELLFIRE 41299
-#define S_UNLEARN_MOONCLOTH 41558
-#define S_UNLEARN_SHADOWEAVE 41559
-
-#define S_TRANSMUTE 28672
-#define S_ELIXIR 28677
-#define S_POTION 28675
-
-#define S_LEARN_TRANSMUTE 28674
-#define S_LEARN_ELIXIR 28678
-#define S_LEARN_POTION 28676
-
-#define S_UNLEARN_TRANSMUTE 41565
-#define S_UNLEARN_ELIXIR 41564
-#define S_UNLEARN_POTION 41563
+enum ProfessionSpells
+{
+ S_WEAPON = 9787,
+ S_ARMOR = 9788,
+ S_HAMMER = 17040,
+ S_AXE = 17041,
+ S_SWORD = 17039,
+
+ S_LEARN_WEAPON = 9789,
+ S_LEARN_ARMOR = 9790,
+ S_LEARN_HAMMER = 39099,
+ S_LEARN_AXE = 39098,
+ S_LEARN_SWORD = 39097,
+
+ S_UNLEARN_WEAPON = 36436,
+ S_UNLEARN_ARMOR = 36435,
+ S_UNLEARN_HAMMER = 36441,
+ S_UNLEARN_AXE = 36439,
+ S_UNLEARN_SWORD = 36438,
+
+ S_REP_ARMOR = 17451,
+ S_REP_WEAPON = 17452,
+
+ REP_ARMOR = 46,
+ REP_WEAPON = 289,
+ REP_HAMMER = 569,
+ REP_AXE = 570,
+ REP_SWORD = 571,
+
+ S_DRAGON = 10656,
+ S_ELEMENTAL = 10658,
+ S_TRIBAL = 10660,
+
+ S_LEARN_DRAGON = 10657,
+ S_LEARN_ELEMENTAL = 10659,
+ S_LEARN_TRIBAL = 10661,
+
+ S_UNLEARN_DRAGON = 36434,
+ S_UNLEARN_ELEMENTAL = 36328,
+ S_UNLEARN_TRIBAL = 36433,
+
+ S_GOBLIN = 20222,
+ S_GNOMISH = 20219,
+
+ S_LEARN_GOBLIN = 20221,
+ S_LEARN_GNOMISH = 20220,
+
+ S_SPELLFIRE = 26797,
+ S_MOONCLOTH = 26798,
+ S_SHADOWEAVE = 26801,
+
+ S_LEARN_SPELLFIRE = 26796,
+ S_LEARN_MOONCLOTH = 26799,
+ S_LEARN_SHADOWEAVE = 26800,
+
+ S_UNLEARN_SPELLFIRE = 41299,
+ S_UNLEARN_MOONCLOTH = 41558,
+ S_UNLEARN_SHADOWEAVE = 41559,
+
+ S_TRANSMUTE = 28672,
+ S_ELIXIR = 28677,
+ S_POTION = 28675,
+
+ S_LEARN_TRANSMUTE = 28674,
+ S_LEARN_ELIXIR = 28678,
+ S_LEARN_POTION = 28676,
+
+ S_UNLEARN_TRANSMUTE = 41565,
+ S_UNLEARN_ELIXIR = 41564,
+ S_UNLEARN_POTION = 41563,
+};
/*###
# formulas to calculate unlearning cost
@@ -211,6 +213,18 @@ int32 DoLowUnlearnCost(Player* player) //blacksmith
return 100000;
}
+void ProcessCastAction(Player* player, Creature* creature, uint32 spellId, uint32 triggeredSpellId, int32 cost)
+{
+ if (!(spellId && player->HasSpell(spellId)) && player->HasEnoughMoney(cost))
+ {
+ player->CastSpell(player, triggeredSpellId, true);
+ player->ModifyMoney(-cost);
+ }
+ else
+ player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
+ player->CLOSE_GOSSIP_MENU();
+}
+
/*###
# unlearning related profession spells
###*/
@@ -218,7 +232,6 @@ int32 DoLowUnlearnCost(Player* player) //blacksmith
bool EquippedOk(Player* player, uint32 spellId)
{
SpellInfo const* spell = sSpellMgr->GetSpellInfo(spellId);
-
if (!spell)
return false;
@@ -232,11 +245,10 @@ bool EquippedOk(Player* player, uint32 spellId)
for (uint8 j = EQUIPMENT_SLOT_START; j < EQUIPMENT_SLOT_END; ++j)
{
pItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, j);
- if (pItem)
- if (pItem->GetTemplate()->RequiredSpell == reqSpell)
+ if (pItem && pItem->GetTemplate()->RequiredSpell == reqSpell)
{
//player has item equipped that require specialty. Not allow to unlearn, player has to unequip first
- sLog->outDebug(LOG_FILTER_TSCR, "TSCR: player attempt to unlearn spell %u, but item %u is equipped.", reqSpell, pItem->GetTemplate()->ItemId);
+ sLog->outDebug(LOG_FILTER_TSCR, "TSCR: player attempt to unlearn spell %u, but item %u is equipped.", reqSpell, pItem->GetEntry());
return false;
}
}
@@ -248,12 +260,12 @@ void ProfessionUnlearnSpells(Player* player, uint32 type)
{
switch (type)
{
- case 36436: // S_UNLEARN_WEAPON
+ case S_UNLEARN_WEAPON: // S_UNLEARN_WEAPON
player->removeSpell(36125); // Light Earthforged Blade
player->removeSpell(36128); // Light Emberforged Hammer
player->removeSpell(36126); // Light Skyforged Axe
break;
- case 36435: // S_UNLEARN_ARMOR
+ case S_UNLEARN_ARMOR: // S_UNLEARN_ARMOR
player->removeSpell(36122); // Earthforged Leggings
player->removeSpell(36129); // Heavy Earthforged Breastplate
player->removeSpell(36130); // Stormforged Hauberk
@@ -265,7 +277,7 @@ void ProfessionUnlearnSpells(Player* player, uint32 type)
player->removeSpell(34530); // Twisting Nether Chain Shirt
player->removeSpell(36124); // Windforged Leggings
break;
- case 36441: // S_UNLEARN_HAMMER
+ case S_UNLEARN_HAMMER: // S_UNLEARN_HAMMER
player->removeSpell(36262); // Dragonstrike
player->removeSpell(34546); // Dragonmaw
player->removeSpell(34545); // Drakefist Hammer
@@ -275,7 +287,7 @@ void ProfessionUnlearnSpells(Player* player, uint32 type)
player->removeSpell(36263); // Stormherald
player->removeSpell(36137); // Great Earthforged Hammer
break;
- case 36439: // S_UNLEARN_AXE
+ case S_UNLEARN_AXE: // S_UNLEARN_AXE
player->removeSpell(36260); // Wicked Edge of the Planes
player->removeSpell(34562); // Black Planar Edge
player->removeSpell(34541); // The Planar Edge
@@ -285,7 +297,7 @@ void ProfessionUnlearnSpells(Player* player, uint32 type)
player->removeSpell(34543); // Lunar Crescent
player->removeSpell(34544); // Mooncleaver
break;
- case 36438: // S_UNLEARN_SWORD
+ case S_UNLEARN_SWORD: // S_UNLEARN_SWORD
player->removeSpell(36258); // Blazefury
player->removeSpell(34537); // Blazeguard
player->removeSpell(34535); // Fireguard
@@ -295,7 +307,7 @@ void ProfessionUnlearnSpells(Player* player, uint32 type)
player->removeSpell(34540); // Lionheart Champion
player->removeSpell(36259); // Lionheart Executioner
break;
- case 36434: // S_UNLEARN_DRAGON
+ case S_UNLEARN_DRAGON: // S_UNLEARN_DRAGON
player->removeSpell(36076); // Dragonstrike Leggings
player->removeSpell(36079); // Golden Dragonstrike Breastplate
player->removeSpell(35576); // Ebon Netherscale Belt
@@ -305,31 +317,31 @@ void ProfessionUnlearnSpells(Player* player, uint32 type)
player->removeSpell(35584); // Netherstrike Bracers
player->removeSpell(35580); // Netherstrike Breastplate
break;
- case 36328: // S_UNLEARN_ELEMENTAL
+ case S_UNLEARN_ELEMENTAL: // S_UNLEARN_ELEMENTAL
player->removeSpell(36074); // Blackstorm Leggings
player->removeSpell(36077); // Primalstorm Breastplate
player->removeSpell(35590); // Primalstrike Belt
player->removeSpell(35591); // Primalstrike Bracers
player->removeSpell(35589); // Primalstrike Vest
break;
- case 36433: // S_UNLEARN_TRIBAL
+ case S_UNLEARN_TRIBAL: // S_UNLEARN_TRIBAL
player->removeSpell(35585); // Windhawk Hauberk
player->removeSpell(35587); // Windhawk Belt
player->removeSpell(35588); // Windhawk Bracers
player->removeSpell(36075); // Wildfeather Leggings
player->removeSpell(36078); // Living Crystal Breastplate
break;
- case 41299: // S_UNLEARN_SPELLFIRE
+ case S_UNLEARN_SPELLFIRE: // S_UNLEARN_SPELLFIRE
player->removeSpell(26752); // Spellfire Belt
player->removeSpell(26753); // Spellfire Gloves
player->removeSpell(26754); // Spellfire Robe
break;
- case 41558: // S_UNLEARN_MOONCLOTH
+ case S_UNLEARN_MOONCLOTH: // S_UNLEARN_MOONCLOTH
player->removeSpell(26760); // Primal Mooncloth Belt
player->removeSpell(26761); // Primal Mooncloth Shoulders
player->removeSpell(26762); // Primal Mooncloth Robe
break;
- case 41559: // S_UNLEARN_SHADOWEAVE
+ case S_UNLEARN_SHADOWEAVE: // S_UNLEARN_SHADOWEAVE
player->removeSpell(26756); // Frozen Shadoweave Shoulders
player->removeSpell(26757); // Frozen Shadoweave Boots
player->removeSpell(26758); // Frozen Shadoweave Robe
@@ -337,22 +349,40 @@ void ProfessionUnlearnSpells(Player* player, uint32 type)
}
}
+void ProcessUnlearnAction(Player* player, Creature* creature, uint32 spellId, uint32 alternativeSpellId, int32 cost)
+{
+ if (EquippedOk(player, spellId))
+ {
+ if (player->HasEnoughMoney(cost))
+ {
+ player->CastSpell(player, spellId, true);
+ ProfessionUnlearnSpells(player, spellId);
+ player->ModifyMoney(-cost);
+ if (alternativeSpellId)
+ creature->CastSpell(player, alternativeSpellId, true);
+ }
+ else
+ player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
+ }
+ else
+ player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, NULL, NULL);
+ player->CLOSE_GOSSIP_MENU();
+}
+
/*###
# start menues alchemy
###*/
-bool HasAlchemySpell(Player* player)
-{
- if (player->HasSpell(S_TRANSMUTE) || player->HasSpell(S_ELIXIR) || player->HasSpell(S_POTION))
- return true;
- return false;
-}
-
class npc_prof_alchemy : public CreatureScript
{
public:
npc_prof_alchemy() : CreatureScript("npc_prof_alchemy") { }
+ inline bool HasAlchemySpell(Player* player)
+ {
+ return (player->HasSpell(S_TRANSMUTE) || player->HasSpell(S_ELIXIR) || player->HasSpell(S_POTION));
+ }
+
bool OnGossipHello(Player* player, Creature* creature)
{
if (creature->isQuestGiver())
@@ -362,13 +392,11 @@ public:
if (creature->isTrainer())
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN);
- uint32 eCreature = creature->GetEntry();
-
if (player->HasSkill(SKILL_ALCHEMY) && player->GetBaseSkillValue(SKILL_ALCHEMY) >= 350 && player->getLevel() > 67)
{
if (player->GetQuestRewardStatus(10899) || player->GetQuestRewardStatus(10902) || player->GetQuestRewardStatus(10897))
{
- switch (eCreature)
+ switch (creature->GetEntry())
{
case 22427: //Zarevhi
if (!HasAlchemySpell(player))
@@ -408,59 +436,23 @@ public:
break;
//Learn Alchemy
case GOSSIP_ACTION_INFO_DEF + 1:
- if (!player->HasSpell(S_TRANSMUTE) && player->HasEnoughMoney(DoLearnCost(player)))
- {
- player->CastSpell(player, S_LEARN_TRANSMUTE, true);
- player->ModifyMoney(-DoLearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- player->CLOSE_GOSSIP_MENU();
+ ProcessCastAction(player, creature, S_TRANSMUTE, S_LEARN_TRANSMUTE, DoLearnCost(player));
break;
case GOSSIP_ACTION_INFO_DEF + 2:
- if (!player->HasSpell(S_ELIXIR) && player->HasEnoughMoney(DoLearnCost(player)))
- {
- player->CastSpell(player, S_LEARN_ELIXIR, true);
- player->ModifyMoney(-DoLearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- player->CLOSE_GOSSIP_MENU();
+ ProcessCastAction(player, creature, S_ELIXIR, S_LEARN_ELIXIR, DoLearnCost(player));
break;
case GOSSIP_ACTION_INFO_DEF + 3:
- if (!player->HasSpell(S_POTION) && player->HasEnoughMoney(DoLearnCost(player)))
- {
- player->CastSpell(player, S_LEARN_POTION, true);
- player->ModifyMoney(-DoLearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- player->CLOSE_GOSSIP_MENU();
+ ProcessCastAction(player, creature, S_POTION, S_LEARN_POTION, DoLearnCost(player));
break;
//Unlearn Alchemy
case GOSSIP_ACTION_INFO_DEF + 4:
- if (player->HasEnoughMoney(DoHighUnlearnCost(player)))
- {
- creature->CastSpell(player, S_UNLEARN_TRANSMUTE, true);
- player->ModifyMoney(-DoHighUnlearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- player->CLOSE_GOSSIP_MENU();
+ ProcessCastAction(player, creature, 0, S_UNLEARN_TRANSMUTE, DoHighUnlearnCost(player));
break;
case GOSSIP_ACTION_INFO_DEF + 5:
- if (player->HasEnoughMoney(DoHighUnlearnCost(player)))
- {
- creature->CastSpell(player, S_UNLEARN_ELIXIR, true);
- player->ModifyMoney(-DoHighUnlearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- player->CLOSE_GOSSIP_MENU();
+ ProcessCastAction(player, creature, 0, S_UNLEARN_ELIXIR, DoHighUnlearnCost(player));
break;
case GOSSIP_ACTION_INFO_DEF + 6:
- if (player->HasEnoughMoney(DoHighUnlearnCost(player)))
- {
- creature->CastSpell(player, S_UNLEARN_POTION, true);
- player->ModifyMoney(-DoHighUnlearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- player->CLOSE_GOSSIP_MENU();
+ ProcessCastAction(player, creature, 0, S_UNLEARN_POTION, DoHighUnlearnCost(player));
break;
}
}
@@ -469,8 +461,7 @@ public:
{
if (uiAction)
{
- uint32 eCreature = creature->GetEntry();
- switch(eCreature)
+ switch (creature->GetEntry())
{
case 22427:
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_TRANSMUTE, GOSSIP_SENDER_CHECK, uiAction);
@@ -495,8 +486,7 @@ public:
{
if (uiAction)
{
- uint32 eCreature = creature->GetEntry();
- switch(eCreature)
+ switch (creature->GetEntry())
{
case 22427: //Zarevhi
player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_TRANSMUTE, GOSSIP_SENDER_CHECK, uiAction, BOX_UNLEARN_ALCHEMY_SPEC, DoHighUnlearnCost(player), false);
@@ -535,18 +525,16 @@ public:
# start menues blacksmith
###*/
-bool HasWeaponSub(Player* player)
-{
- if (player->HasSpell(S_HAMMER) || player->HasSpell(S_AXE) || player->HasSpell(S_SWORD))
- return true;
- return false;
-}
-
class npc_prof_blacksmith : public CreatureScript
{
public:
npc_prof_blacksmith() : CreatureScript("npc_prof_blacksmith") { }
+ inline bool HasWeaponSub(Player* player)
+ {
+ return (player->HasSpell(S_HAMMER) || player->HasSpell(S_AXE) || player->HasSpell(S_SWORD));
+ }
+
bool OnGossipHello(Player* player, Creature* creature)
{
if (creature->isQuestGiver())
@@ -645,38 +633,11 @@ public:
//unknown textID (TALK_MUST_UNLEARN_WEAPON)
player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
}
- else if (EquippedOk(player, S_UNLEARN_WEAPON))
- {
- if (player->HasEnoughMoney(DoLowUnlearnCost(player)))
- {
- player->CastSpell(player, S_UNLEARN_WEAPON, true);
- ProfessionUnlearnSpells(player, S_UNLEARN_WEAPON);
- player->ModifyMoney(-DoLowUnlearnCost(player));
- creature->CastSpell(player, S_REP_ARMOR, true);
- player->CLOSE_GOSSIP_MENU();
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- }
else
- {
- player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, NULL, NULL);
- player->CLOSE_GOSSIP_MENU();
- }
+ ProcessUnlearnAction(player, creature, S_UNLEARN_WEAPON, S_REP_ARMOR, DoLowUnlearnCost(player));
break;
case GOSSIP_ACTION_INFO_DEF + 4:
- if (EquippedOk(player, S_UNLEARN_ARMOR))
- {
- if (player->HasEnoughMoney(DoLowUnlearnCost(player)))
- {
- player->CastSpell(player, S_UNLEARN_ARMOR, true);
- ProfessionUnlearnSpells(player, S_UNLEARN_ARMOR);
- player->ModifyMoney(-DoLowUnlearnCost(player));
- creature->CastSpell(player, S_REP_WEAPON, true);
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- } else
- player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, NULL, NULL);
- player->CLOSE_GOSSIP_MENU();
+ ProcessUnlearnAction(player, creature, S_UNLEARN_ARMOR, S_REP_WEAPON, DoLowUnlearnCost(player));
break;
//Learn Hammer/Axe/Sword
case GOSSIP_ACTION_INFO_DEF + 5:
@@ -693,46 +654,13 @@ public:
break;
//Unlearn Hammer/Axe/Sword
case GOSSIP_ACTION_INFO_DEF + 8:
- if (EquippedOk(player, S_UNLEARN_HAMMER))
- {
- if (player->HasEnoughMoney(DoMedUnlearnCost(player)))
- {
- player->CastSpell(player, S_UNLEARN_HAMMER, true);
- ProfessionUnlearnSpells(player, S_UNLEARN_HAMMER);
- player->ModifyMoney(-DoMedUnlearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- } else
- player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, NULL, NULL);
- player->CLOSE_GOSSIP_MENU();
+ ProcessUnlearnAction(player, creature, S_UNLEARN_HAMMER, 0, DoMedUnlearnCost(player));
break;
case GOSSIP_ACTION_INFO_DEF + 9:
- if (EquippedOk(player, S_UNLEARN_AXE))
- {
- if (player->HasEnoughMoney(DoMedUnlearnCost(player)))
- {
- player->CastSpell(player, S_UNLEARN_AXE, true);
- ProfessionUnlearnSpells(player, S_UNLEARN_AXE);
- player->ModifyMoney(-DoMedUnlearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- } else
- player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, NULL, NULL);
- player->CLOSE_GOSSIP_MENU();
+ ProcessUnlearnAction(player, creature, S_UNLEARN_AXE, 0, DoMedUnlearnCost(player));
break;
case GOSSIP_ACTION_INFO_DEF + 10:
- if (EquippedOk(player, S_UNLEARN_SWORD))
- {
- if (player->HasEnoughMoney(DoMedUnlearnCost(player)))
- {
- player->CastSpell(player, S_UNLEARN_SWORD, true);
- ProfessionUnlearnSpells(player, S_UNLEARN_SWORD);
- player->ModifyMoney(-DoMedUnlearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- } else
- player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, NULL, NULL);
- player->CLOSE_GOSSIP_MENU();
+ ProcessUnlearnAction(player, creature, S_UNLEARN_SWORD, 0, DoMedUnlearnCost(player));
break;
}
}
@@ -741,8 +669,7 @@ public:
{
if (uiAction)
{
- uint32 eCreature = creature->GetEntry();
- switch(eCreature)
+ switch(creature->GetEntry())
{
case 11191:
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_HAMMER, GOSSIP_SENDER_CHECK, uiAction);
@@ -767,8 +694,7 @@ public:
{
if (uiAction)
{
- uint32 eCreature = creature->GetEntry();
- switch(eCreature)
+ switch (creature->GetEntry())
{
case 11146: //Ironus Coldsteel
case 11178: //Borgosh Corebender
@@ -801,7 +727,7 @@ public:
bool OnGossipSelect(Player* player, Creature* creature, uint32 uiSender, uint32 uiAction)
{
player->PlayerTalkClass->ClearMenus();
- switch(uiSender)
+ switch (uiSender)
{
case GOSSIP_SENDER_MAIN: SendActionMenu(player, creature, uiAction); break;
case GOSSIP_SENDER_LEARN: SendConfirmLearn(player, creature, uiAction); break;
@@ -844,88 +770,70 @@ class npc_engineering_tele_trinket : public CreatureScript
public:
npc_engineering_tele_trinket() : CreatureScript("npc_engineering_tele_trinket") { }
+ bool CanLearn(Player* player, uint32 textId, uint32 altTextId, uint32 skillValue, uint32 reqSpellId, uint32 spellId, uint32& npcTextId)
+ {
+ bool res = false;
+ npcTextId = textId;
+ if (player->GetBaseSkillValue(SKILL_ENGINERING) >= skillValue && player->HasSpell(reqSpellId))
+ {
+ if (!player->HasSpell(spellId))
+ res = true;
+ else
+ npcTextId = altTextId;
+ }
+ return res;
+ }
+
bool OnGossipHello(Player* player, Creature* creature)
{
- uint32 NpcTextId = 0;
- std::string GossipItem;
- bool CanLearn = false;
+ uint32 npcTextId = 0;
+ std::string gossipItem;
+ bool canLearn = false;
if (player->HasSkill(SKILL_ENGINERING))
{
- switch(creature->GetEntry())
+ switch (creature->GetEntry())
{
case NPC_ZAP:
- NpcTextId = 7249;
- if (player->GetBaseSkillValue(SKILL_ENGINERING) >= 260 && player->HasSpell(S_GOBLIN))
- {
- if (!player->HasSpell(SPELL_TO_EVERLOOK))
- {
- CanLearn = true;
- GossipItem = GOSSIP_ITEM_ZAP;
- }
- else if (player->HasSpell(SPELL_TO_EVERLOOK))
- NpcTextId = 0;
- }
+ canLearn = CanLearn(player, 7249, 0, 260, S_GOBLIN, SPELL_TO_EVERLOOK, npcTextId);
+ if (canLearn)
+ gossipItem = GOSSIP_ITEM_ZAP;
break;
case NPC_JHORDY:
- NpcTextId = 7251;
- if (player->GetBaseSkillValue(SKILL_ENGINERING) >= 260 && player->HasSpell(S_GNOMISH))
- {
- if (!player->HasSpell(SPELL_TO_GADGET))
- {
- CanLearn = true;
- GossipItem = GOSSIP_ITEM_JHORDY;
- }
- else if (player->HasSpell(SPELL_TO_GADGET))
- NpcTextId = 7252;
- }
+ canLearn = CanLearn(player, 7251, 7252, 260, S_GNOMISH, SPELL_TO_GADGET, npcTextId);
+ if (canLearn)
+ gossipItem = GOSSIP_ITEM_JHORDY;
break;
case NPC_KABLAM:
- NpcTextId = 10365;
- if (player->GetBaseSkillValue(SKILL_ENGINERING) >= 350 && player->HasSpell(S_GOBLIN))
- {
- if (!player->HasSpell(SPELL_TO_AREA52))
- {
- CanLearn = true;
- GossipItem = GOSSIP_ITEM_KABLAM;
- }
- else if (player->HasSpell(SPELL_TO_AREA52))
- NpcTextId = 0;
- }
+ canLearn = CanLearn(player, 10365, 0, 350, S_GOBLIN, SPELL_TO_AREA52, npcTextId);
+ if (canLearn)
+ gossipItem = GOSSIP_ITEM_KABLAM;
break;
case NPC_SMILES:
- NpcTextId = 10363;
- if (player->GetBaseSkillValue(SKILL_ENGINERING) >= 350 && player->HasSpell(S_GNOMISH))
- {
- if (!player->HasSpell(SPELL_TO_TOSHLEY))
- {
- CanLearn = true;
- GossipItem = GOSSIP_ITEM_SMILES;
- }
- else if (player->HasSpell(SPELL_TO_TOSHLEY))
- NpcTextId = 0;
- }
+ canLearn = CanLearn(player, 10363, 0, 350, S_GNOMISH, SPELL_TO_TOSHLEY, npcTextId);
+ if (canLearn)
+ gossipItem = GOSSIP_ITEM_KABLAM;
break;
}
}
- if (CanLearn)
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GossipItem, creature->GetEntry(), GOSSIP_ACTION_INFO_DEF+1);
+ if (canLearn)
+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, gossipItem, creature->GetEntry(), GOSSIP_ACTION_INFO_DEF + 1);
- player->SEND_GOSSIP_MENU(NpcTextId ? NpcTextId : player->GetGossipTextId(creature), creature->GetGUID());
+ player->SEND_GOSSIP_MENU(npcTextId ? npcTextId : player->GetGossipTextId(creature), creature->GetGUID());
return true;
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 uiSender, uint32 uiAction)
{
player->PlayerTalkClass->ClearMenus();
- if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
+ if (uiAction == GOSSIP_ACTION_INFO_DEF + 1)
player->CLOSE_GOSSIP_MENU();
if (uiSender != creature->GetEntry())
return true;
- switch(uiSender)
+ switch (uiSender)
{
case NPC_ZAP:
player->CastSpell(player, SPELL_LEARN_TO_EVERLOOK, false);
@@ -963,11 +871,9 @@ public:
if (creature->isTrainer())
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN);
- uint32 eCreature = creature->GetEntry();
-
if (player->HasSkill(SKILL_LEATHERWORKING) && player->GetBaseSkillValue(SKILL_LEATHERWORKING) >= 250 && player->getLevel() > 49)
{
- switch (eCreature)
+ switch (creature->GetEntry())
{
case 7866: //Peter Galen
case 7867: //Thorkaf Dragoneye
@@ -993,7 +899,7 @@ public:
void SendActionMenu(Player* player, Creature* creature, uint32 uiAction)
{
- switch(uiAction)
+ switch (uiAction)
{
case GOSSIP_ACTION_TRADE:
player->GetSession()->SendListInventory(creature->GetGUID());
@@ -1003,46 +909,13 @@ public:
break;
//Unlearn Leather
case GOSSIP_ACTION_INFO_DEF + 1:
- if (EquippedOk(player, S_UNLEARN_DRAGON))
- {
- if (player->HasEnoughMoney(DoMedUnlearnCost(player)))
- {
- player->CastSpell(player, S_UNLEARN_DRAGON, true);
- ProfessionUnlearnSpells(player, S_UNLEARN_DRAGON);
- player->ModifyMoney(-DoMedUnlearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- } else
- player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, NULL, NULL);
- player->CLOSE_GOSSIP_MENU();
+ ProcessUnlearnAction(player, creature, S_UNLEARN_DRAGON, 0, DoMedUnlearnCost(player));
break;
case GOSSIP_ACTION_INFO_DEF + 2:
- if (EquippedOk(player, S_UNLEARN_ELEMENTAL))
- {
- if (player->HasEnoughMoney(DoMedUnlearnCost(player)))
- {
- player->CastSpell(player, S_UNLEARN_ELEMENTAL, true);
- ProfessionUnlearnSpells(player, S_UNLEARN_ELEMENTAL);
- player->ModifyMoney(-DoMedUnlearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- } else
- player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, NULL, NULL);
- player->CLOSE_GOSSIP_MENU();
+ ProcessUnlearnAction(player, creature, S_UNLEARN_ELEMENTAL, 0, DoMedUnlearnCost(player));
break;
case GOSSIP_ACTION_INFO_DEF + 3:
- if (EquippedOk(player, S_UNLEARN_TRIBAL))
- {
- if (player->HasEnoughMoney(DoMedUnlearnCost(player)))
- {
- player->CastSpell(player, S_UNLEARN_TRIBAL, true);
- ProfessionUnlearnSpells(player, S_UNLEARN_TRIBAL);
- player->ModifyMoney(-DoMedUnlearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- } else
- player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, NULL, NULL);
- player->CLOSE_GOSSIP_MENU();
+ ProcessUnlearnAction(player, creature, S_UNLEARN_TRIBAL, 0, DoMedUnlearnCost(player));
break;
}
}
@@ -1051,8 +924,7 @@ public:
{
if (uiAction)
{
- uint32 eCreature = creature->GetEntry();
- switch(eCreature)
+ switch (creature->GetEntry())
{
case 7866: //Peter Galen
case 7867: //Thorkaf Dragoneye
@@ -1079,7 +951,7 @@ public:
bool OnGossipSelect(Player* player, Creature* creature, uint32 uiSender, uint32 uiAction)
{
player->PlayerTalkClass->ClearMenus();
- switch(uiSender)
+ switch (uiSender)
{
case GOSSIP_SENDER_MAIN: SendActionMenu(player, creature, uiAction); break;
case GOSSIP_SENDER_UNLEARN: SendConfirmUnlearn(player, creature, uiAction); break;
@@ -1093,18 +965,16 @@ public:
# start menues tailoring
###*/
-bool HasTailorSpell(Player* player)
-{
- if (player->HasSpell(S_MOONCLOTH) || player->HasSpell(S_SHADOWEAVE) || player->HasSpell(S_SPELLFIRE))
- return true;
- return false;
-}
-
class npc_prof_tailor : public CreatureScript
{
public:
npc_prof_tailor() : CreatureScript("npc_prof_tailor") { }
+ inline bool HasTailorSpell(Player* player)
+ {
+ return (player->HasSpell(S_MOONCLOTH) || player->HasSpell(S_SHADOWEAVE) || player->HasSpell(S_SPELLFIRE));
+ }
+
bool OnGossipHello(Player* player, Creature* creature)
{
if (creature->isQuestGiver())
@@ -1114,13 +984,12 @@ public:
if (creature->isTrainer())
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN);
- uint32 eCreature = creature->GetEntry();
//TAILORING SPEC
if (player->HasSkill(SKILL_TAILORING) && player->GetBaseSkillValue(SKILL_TAILORING) >= 350 && player->getLevel() > 59)
{
if (player->GetQuestRewardStatus(10831) || player->GetQuestRewardStatus(10832) || player->GetQuestRewardStatus(10833))
{
- switch (eCreature)
+ switch (creature->GetEntry())
{
case 22213: //Gidge Spellweaver
if (!HasTailorSpell(player))
@@ -1150,7 +1019,7 @@ public:
void SendActionMenu(Player* player, Creature* creature, uint32 uiAction)
{
- switch(uiAction)
+ switch (uiAction)
{
case GOSSIP_ACTION_TRADE:
player->GetSession()->SendListInventory(creature->GetGUID());
@@ -1160,74 +1029,23 @@ public:
break;
//Learn Tailor
case GOSSIP_ACTION_INFO_DEF + 1:
- if (!player->HasSpell(S_SPELLFIRE) && player->HasEnoughMoney(DoLearnCost(player)))
- {
- player->CastSpell(player, S_LEARN_SPELLFIRE, true);
- player->ModifyMoney(-DoLearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- player->CLOSE_GOSSIP_MENU();
+ ProcessCastAction(player, creature, S_SPELLFIRE, S_LEARN_SPELLFIRE, DoLearnCost(player));
break;
case GOSSIP_ACTION_INFO_DEF + 2:
- if (!player->HasSpell(S_MOONCLOTH) && player->HasEnoughMoney(DoLearnCost(player)))
- {
- player->CastSpell(player, S_LEARN_MOONCLOTH, true);
- player->ModifyMoney(-DoLearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- player->CLOSE_GOSSIP_MENU();
+ ProcessCastAction(player, creature, S_MOONCLOTH, S_LEARN_MOONCLOTH, DoLearnCost(player));
break;
case GOSSIP_ACTION_INFO_DEF + 3:
- if (!player->HasSpell(S_SHADOWEAVE) && player->HasEnoughMoney(DoLearnCost(player)))
- {
- player->CastSpell(player, S_LEARN_SHADOWEAVE, true);
- player->ModifyMoney(-DoLearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- player->CLOSE_GOSSIP_MENU();
+ ProcessCastAction(player, creature, S_SHADOWEAVE, S_LEARN_SHADOWEAVE, DoLearnCost(player));
break;
//Unlearn Tailor
case GOSSIP_ACTION_INFO_DEF + 4:
- if (EquippedOk(player, S_UNLEARN_SPELLFIRE))
- {
- if (player->HasEnoughMoney(DoHighUnlearnCost(player)))
- {
- player->CastSpell(player, S_UNLEARN_SPELLFIRE, true);
- ProfessionUnlearnSpells(player, S_UNLEARN_SPELLFIRE);
- player->ModifyMoney(-DoHighUnlearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- } else
- player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, NULL, NULL);
- player->CLOSE_GOSSIP_MENU();
+ ProcessUnlearnAction(player, creature, S_UNLEARN_SPELLFIRE, 0, DoHighUnlearnCost(player));
break;
case GOSSIP_ACTION_INFO_DEF + 5:
- if (EquippedOk(player, S_UNLEARN_MOONCLOTH))
- {
- if (player->HasEnoughMoney(DoHighUnlearnCost(player)))
- {
- player->CastSpell(player, S_UNLEARN_MOONCLOTH, true);
- ProfessionUnlearnSpells(player, S_UNLEARN_MOONCLOTH);
- player->ModifyMoney(-DoHighUnlearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- } else
- player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, NULL, NULL);
- player->CLOSE_GOSSIP_MENU();
+ ProcessUnlearnAction(player, creature, S_UNLEARN_MOONCLOTH, 0, DoHighUnlearnCost(player));
break;
case GOSSIP_ACTION_INFO_DEF + 6:
- if (EquippedOk(player, S_UNLEARN_SHADOWEAVE))
- {
- if (player->HasEnoughMoney(DoHighUnlearnCost(player)))
- {
- player->CastSpell(player, S_UNLEARN_SHADOWEAVE, true);
- ProfessionUnlearnSpells(player, S_UNLEARN_SHADOWEAVE);
- player->ModifyMoney(-DoHighUnlearnCost(player));
- } else
- player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0, 0);
- } else
- player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, NULL, NULL);
- player->CLOSE_GOSSIP_MENU();
+ ProcessUnlearnAction(player, creature, S_UNLEARN_SHADOWEAVE, 0, DoHighUnlearnCost(player));
break;
}
}
@@ -1236,8 +1054,7 @@ public:
{
if (uiAction)
{
- uint32 eCreature = creature->GetEntry();
- switch(eCreature)
+ switch (creature->GetEntry())
{
case 22213:
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_SPELLFIRE, GOSSIP_SENDER_CHECK, uiAction);
@@ -1262,8 +1079,7 @@ public:
{
if (uiAction)
{
- uint32 eCreature = creature->GetEntry();
- switch(eCreature)
+ switch (creature->GetEntry())
{
case 22213: //Gidge Spellweaver
player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_SPELLFIRE, GOSSIP_SENDER_CHECK, uiAction, BOX_UNLEARN_TAILOR_SPEC, DoHighUnlearnCost(player), false);