TrinityCore
Loading...
Searching...
No Matches
npc_professions.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "ScriptMgr.h"
19#include "Item.h"
20#include "Player.h"
21#include "ScriptedCreature.h"
22#include "ScriptedGossip.h"
23
24/*###
25# gossip item and box texts
26###*/
27
29{
30 GOSSIP_ZAP = 6092, // Zap Farflinger
31 GOSSIP_JHORDY = 6094, // Jhordy Lapforge
32 GOSSIP_KABLAM = 8308, // Kablamm Farflinger
33 GOSSIP_SMILES = 8306, // Smiles O'Byron
34};
35
36/*###
37# spells defines
38###*/
39
41{
42 S_GOBLIN = 20222,
43 S_GNOMISH = 20219,
44};
45
46/*###
47# engineering trinkets
48###*/
49
67
69{
70public:
71 npc_engineering_tele_trinket() : CreatureScript("npc_engineering_tele_trinket") { }
72
74 {
76
77 static bool CanLearn(Player const* player, uint32 textId, uint32 altTextId, uint32 skillId, uint32 skillValue, uint32 reqSpellId, uint32 spellId, uint32& npcTextId)
78 {
79 bool res = false;
80 npcTextId = textId;
81 if (player->GetBaseSkillValue(skillId) >= skillValue && player->HasSpell(reqSpellId))
82 {
83 if (!player->HasSpell(spellId))
84 res = true;
85 else
86 npcTextId = altTextId;
87 }
88 return res;
89 }
90
91 bool OnGossipHello(Player* player) override
92 {
93 uint32 npcTextId = 0;
94 uint32 gossipItem;
95 bool canLearn = false;
96
97 if (player->HasSkill(SKILL_ENGINEERING))
98 {
99 switch (me->GetEntry())
100 {
101 case NPC_ZAP:
102 canLearn = CanLearn(player, 6092, 0, SKILL_CLASSIC_ENGINEERING, 260, S_GOBLIN, SPELL_TO_EVERLOOK, npcTextId);
103 if (canLearn)
104 gossipItem = GOSSIP_ZAP;
105 break;
106 case NPC_JHORDY:
107 canLearn = CanLearn(player, 7251, 7252, SKILL_CLASSIC_ENGINEERING, 260, S_GNOMISH, SPELL_TO_GADGET, npcTextId);
108 if (canLearn)
109 gossipItem = GOSSIP_JHORDY;
110 break;
111 case NPC_KABLAM:
112 canLearn = CanLearn(player, 10365, 0, SKILL_OUTLAND_ENGINEERING, 50, S_GOBLIN, SPELL_TO_AREA52, npcTextId);
113 if (canLearn)
114 gossipItem = GOSSIP_KABLAM;
115 break;
116 case NPC_SMILES:
117 canLearn = CanLearn(player, 10363, 0, SKILL_OUTLAND_ENGINEERING, 50, S_GNOMISH, SPELL_TO_TOSHLEY, npcTextId);
118 if (canLearn)
119 gossipItem = GOSSIP_SMILES;
120 break;
121 default:
122 break;
123 }
124 }
125
126 if (canLearn)
127 AddGossipItemFor(player, gossipItem, 2, me->GetEntry(), GOSSIP_ACTION_INFO_DEF + 1);
128
129 SendGossipMenuFor(player, npcTextId ? npcTextId : player->GetGossipTextId(me), me->GetGUID());
130 return true;
131 }
132
133 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
134 {
135 uint32 const sender = player->PlayerTalkClass->GetGossipOptionSender(gossipListId);
136
137 if (sender != me->GetEntry())
138 return true;
139
140 switch (sender)
141 {
142 case NPC_ZAP:
143 player->CastSpell(player, SPELL_LEARN_TO_EVERLOOK, false);
144 break;
145 case NPC_JHORDY:
146 player->CastSpell(player, SPELL_LEARN_TO_GADGET, false);
147 break;
148 case NPC_KABLAM:
149 player->CastSpell(player, SPELL_LEARN_TO_AREA52, false);
150 break;
151 case NPC_SMILES:
152 player->CastSpell(player, SPELL_LEARN_TO_TOSHLEY, false);
153 break;
154 default:
155 break;
156 }
157
158 return false;
159 }
160 };
161
162 CreatureAI* GetAI(Creature* creature) const override
163 {
164 return new npc_engineering_tele_trinketAI(creature);
165 }
166};
167
uint32_t uint32
Definition Define.h:154
void AddGossipItemFor(Player *player, GossipOptionNpc optionNpc, std::string text, uint32 sender, uint32 action)
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const &guid)
@ GOSSIP_ACTION_INFO_DEF
@ SKILL_ENGINEERING
@ SKILL_CLASSIC_ENGINEERING
@ SKILL_OUTLAND_ENGINEERING
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
Creature *const me
Definition CreatureAI.h:63
uint32 GetEntry() const
Definition Object.h:89
bool HasSkill(uint32 skill) const
Definition Player.cpp:5989
uint16 GetBaseSkillValue(uint32 skill) const
Definition Player.cpp:6052
bool HasSpell(uint32 spell) const override
Definition Player.cpp:3735
uint32 GetGossipTextId(uint32 menuId, WorldObject *source)
Definition Player.cpp:14269
std::unique_ptr< PlayerMenu > PlayerTalkClass
Definition Player.h:2570
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
CreatureAI * GetAI(Creature *creature) const override
ProfessionSpells
@ S_GNOMISH
@ S_GOBLIN
void AddSC_npc_professions()
@ GOSSIP_SMILES
@ GOSSIP_JHORDY
@ GOSSIP_ZAP
@ GOSSIP_KABLAM
EngineeringTrinkets
@ SPELL_LEARN_TO_EVERLOOK
@ NPC_SMILES
@ SPELL_TO_GADGET
@ NPC_ZAP
@ NPC_JHORDY
@ SPELL_TO_EVERLOOK
@ SPELL_TO_AREA52
@ SPELL_LEARN_TO_GADGET
@ SPELL_LEARN_TO_AREA52
@ SPELL_LEARN_TO_TOSHLEY
@ SPELL_TO_TOSHLEY
@ NPC_KABLAM
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override
static bool CanLearn(Player const *player, uint32 textId, uint32 altTextId, uint32 skillId, uint32 skillValue, uint32 reqSpellId, uint32 spellId, uint32 &npcTextId)