[37] | 1 | /* |
---|
[44] | 2 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
[37] | 3 | * |
---|
[44] | 4 | * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> |
---|
| 5 | * |
---|
[37] | 6 | * This program is free software; you can redistribute it and/or modify |
---|
| 7 | * it under the terms of the GNU General Public License as published by |
---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 9 | * (at your option) any later version. |
---|
| 10 | * |
---|
| 11 | * This program is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
[44] | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[37] | 14 | * GNU General Public License for more details. |
---|
| 15 | * |
---|
| 16 | * You should have received a copy of the GNU General Public License |
---|
| 17 | * along with this program; if not, write to the Free Software |
---|
[44] | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
[37] | 19 | */ |
---|
| 20 | |
---|
| 21 | #include "Common.h" |
---|
| 22 | #include "Database/DatabaseEnv.h" |
---|
| 23 | #include "WorldPacket.h" |
---|
| 24 | #include "WorldSession.h" |
---|
| 25 | #include "World.h" |
---|
| 26 | #include "ObjectMgr.h" |
---|
| 27 | #include "PlayerDump.h" |
---|
| 28 | #include "SpellMgr.h" |
---|
| 29 | #include "Player.h" |
---|
| 30 | #include "Opcodes.h" |
---|
| 31 | #include "GameObject.h" |
---|
| 32 | #include "Chat.h" |
---|
| 33 | #include "Log.h" |
---|
| 34 | #include "Guild.h" |
---|
| 35 | #include "ObjectAccessor.h" |
---|
| 36 | #include "MapManager.h" |
---|
| 37 | #include "SpellAuras.h" |
---|
| 38 | #include "ScriptCalls.h" |
---|
| 39 | #include "Language.h" |
---|
| 40 | #include "GridNotifiersImpl.h" |
---|
| 41 | #include "CellImpl.h" |
---|
| 42 | #include "Weather.h" |
---|
| 43 | #include "PointMovementGenerator.h" |
---|
| 44 | #include "TargetedMovementGenerator.h" |
---|
| 45 | #include "SkillDiscovery.h" |
---|
| 46 | #include "SkillExtraItems.h" |
---|
| 47 | #include "SystemConfig.h" |
---|
| 48 | #include "Config/ConfigEnv.h" |
---|
| 49 | #include "Util.h" |
---|
| 50 | #include "ItemEnchantmentMgr.h" |
---|
| 51 | #include "BattleGroundMgr.h" |
---|
| 52 | #include "InstanceSaveMgr.h" |
---|
| 53 | #include "InstanceData.h" |
---|
| 54 | |
---|
| 55 | //reload commands |
---|
| 56 | bool ChatHandler::HandleReloadCommand(const char* arg) |
---|
| 57 | { |
---|
| 58 | // this is error catcher for wrong table name in .reload commands |
---|
| 59 | PSendSysMessage("Db table with name starting from '%s' not found and can't be reloaded.",arg); |
---|
| 60 | SetSentErrorMessage(true); |
---|
| 61 | return false; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | bool ChatHandler::HandleReloadAllCommand(const char*) |
---|
| 65 | { |
---|
| 66 | HandleReloadAreaTriggerTeleportCommand(""); |
---|
| 67 | HandleReloadSkillFishingBaseLevelCommand(""); |
---|
| 68 | |
---|
| 69 | HandleReloadAllAreaCommand(""); |
---|
| 70 | HandleReloadAllLootCommand(""); |
---|
| 71 | HandleReloadAllNpcCommand(""); |
---|
| 72 | HandleReloadAllQuestCommand(""); |
---|
| 73 | HandleReloadAllSpellCommand(""); |
---|
| 74 | HandleReloadAllItemCommand(""); |
---|
| 75 | |
---|
| 76 | HandleReloadCommandCommand(""); |
---|
| 77 | HandleReloadReservedNameCommand(""); |
---|
[44] | 78 | HandleReloadTrinityStringCommand(""); |
---|
[37] | 79 | HandleReloadGameTeleCommand(""); |
---|
| 80 | return true; |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | bool ChatHandler::HandleReloadAllAreaCommand(const char*) |
---|
| 84 | { |
---|
| 85 | //HandleReloadQuestAreaTriggersCommand(""); -- reloaded in HandleReloadAllQuestCommand |
---|
| 86 | HandleReloadAreaTriggerTeleportCommand(""); |
---|
| 87 | HandleReloadAreaTriggerTavernCommand(""); |
---|
| 88 | HandleReloadGameGraveyardZoneCommand(""); |
---|
| 89 | return true; |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | bool ChatHandler::HandleReloadAllLootCommand(const char*) |
---|
| 93 | { |
---|
| 94 | sLog.outString( "Re-Loading Loot Tables..." ); |
---|
| 95 | LoadLootTables(); |
---|
| 96 | SendGlobalSysMessage("DB tables `*_loot_template` reloaded."); |
---|
| 97 | return true; |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | bool ChatHandler::HandleReloadAllNpcCommand(const char* /*args*/) |
---|
| 101 | { |
---|
| 102 | HandleReloadNpcGossipCommand("a"); |
---|
| 103 | HandleReloadNpcTrainerCommand("a"); |
---|
| 104 | HandleReloadNpcVendorCommand("a"); |
---|
| 105 | return true; |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | bool ChatHandler::HandleReloadAllQuestCommand(const char* /*args*/) |
---|
| 109 | { |
---|
| 110 | HandleReloadQuestAreaTriggersCommand("a"); |
---|
| 111 | HandleReloadQuestTemplateCommand("a"); |
---|
| 112 | |
---|
| 113 | sLog.outString( "Re-Loading Quests Relations..." ); |
---|
| 114 | objmgr.LoadQuestRelations(); |
---|
| 115 | SendGlobalSysMessage("DB tables `*_questrelation` and `*_involvedrelation` reloaded."); |
---|
| 116 | return true; |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | bool ChatHandler::HandleReloadAllScriptsCommand(const char*) |
---|
| 120 | { |
---|
| 121 | if(sWorld.IsScriptScheduled()) |
---|
| 122 | { |
---|
| 123 | PSendSysMessage("DB scripts used currently, please attempt reload later."); |
---|
| 124 | SetSentErrorMessage(true); |
---|
| 125 | return false; |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | sLog.outString( "Re-Loading Scripts..." ); |
---|
| 129 | HandleReloadGameObjectScriptsCommand("a"); |
---|
| 130 | HandleReloadEventScriptsCommand("a"); |
---|
| 131 | HandleReloadQuestEndScriptsCommand("a"); |
---|
| 132 | HandleReloadQuestStartScriptsCommand("a"); |
---|
| 133 | HandleReloadSpellScriptsCommand("a"); |
---|
| 134 | SendGlobalSysMessage("DB tables `*_scripts` reloaded."); |
---|
| 135 | return true; |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | bool ChatHandler::HandleReloadAllSpellCommand(const char*) |
---|
| 139 | { |
---|
| 140 | HandleReloadSkillDiscoveryTemplateCommand("a"); |
---|
| 141 | HandleReloadSkillExtraItemTemplateCommand("a"); |
---|
| 142 | HandleReloadSpellAffectCommand("a"); |
---|
| 143 | HandleReloadSpellChainCommand("a"); |
---|
| 144 | HandleReloadSpellElixirCommand("a"); |
---|
| 145 | HandleReloadSpellLearnSpellCommand("a"); |
---|
| 146 | HandleReloadSpellProcEventCommand("a"); |
---|
| 147 | HandleReloadSpellScriptTargetCommand("a"); |
---|
| 148 | HandleReloadSpellTargetPositionCommand("a"); |
---|
| 149 | HandleReloadSpellThreatsCommand("a"); |
---|
| 150 | HandleReloadSpellPetAurasCommand("a"); |
---|
| 151 | return true; |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | bool ChatHandler::HandleReloadAllItemCommand(const char*) |
---|
| 155 | { |
---|
| 156 | HandleReloadPageTextsCommand("a"); |
---|
| 157 | HandleReloadItemEnchantementsCommand("a"); |
---|
| 158 | return true; |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | bool ChatHandler::HandleReloadConfigCommand(const char* arg) |
---|
| 162 | { |
---|
| 163 | sLog.outString( "Re-Loading config settings..." ); |
---|
| 164 | sWorld.LoadConfigSettings(true); |
---|
| 165 | SendGlobalSysMessage("World config settings reloaded."); |
---|
| 166 | return true; |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | bool ChatHandler::HandleReloadAreaTriggerTavernCommand(const char*) |
---|
| 170 | { |
---|
| 171 | sLog.outString( "Re-Loading Tavern Area Triggers..." ); |
---|
| 172 | objmgr.LoadTavernAreaTriggers(); |
---|
| 173 | SendGlobalSysMessage("DB table `areatrigger_tavern` reloaded."); |
---|
| 174 | return true; |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | bool ChatHandler::HandleReloadAreaTriggerTeleportCommand(const char*) |
---|
| 178 | { |
---|
| 179 | sLog.outString( "Re-Loading AreaTrigger teleport definitions..." ); |
---|
| 180 | objmgr.LoadAreaTriggerTeleports(); |
---|
| 181 | SendGlobalSysMessage("DB table `areatrigger_teleport` reloaded."); |
---|
| 182 | return true; |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | bool ChatHandler::HandleReloadCommandCommand(const char*) |
---|
| 186 | { |
---|
| 187 | load_command_table = true; |
---|
| 188 | SendGlobalSysMessage("DB table `command` will be reloaded at next chat command use."); |
---|
| 189 | return true; |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | bool ChatHandler::HandleReloadCreatureQuestRelationsCommand(const char*) |
---|
| 193 | { |
---|
| 194 | sLog.outString( "Loading Quests Relations... (`creature_questrelation`)" ); |
---|
| 195 | objmgr.LoadCreatureQuestRelations(); |
---|
| 196 | SendGlobalSysMessage("DB table `creature_questrelation` (creature quest givers) reloaded."); |
---|
| 197 | return true; |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | bool ChatHandler::HandleReloadCreatureQuestInvRelationsCommand(const char*) |
---|
| 201 | { |
---|
| 202 | sLog.outString( "Loading Quests Relations... (`creature_involvedrelation`)" ); |
---|
| 203 | objmgr.LoadCreatureInvolvedRelations(); |
---|
| 204 | SendGlobalSysMessage("DB table `creature_involvedrelation` (creature quest takers) reloaded."); |
---|
| 205 | return true; |
---|
| 206 | } |
---|
| 207 | |
---|
| 208 | bool ChatHandler::HandleReloadGOQuestRelationsCommand(const char*) |
---|
| 209 | { |
---|
| 210 | sLog.outString( "Loading Quests Relations... (`gameobject_questrelation`)" ); |
---|
| 211 | objmgr.LoadGameobjectQuestRelations(); |
---|
| 212 | SendGlobalSysMessage("DB table `gameobject_questrelation` (gameobject quest givers) reloaded."); |
---|
| 213 | return true; |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | bool ChatHandler::HandleReloadGOQuestInvRelationsCommand(const char*) |
---|
| 217 | { |
---|
| 218 | sLog.outString( "Loading Quests Relations... (`gameobject_involvedrelation`)" ); |
---|
| 219 | objmgr.LoadGameobjectInvolvedRelations(); |
---|
| 220 | SendGlobalSysMessage("DB table `gameobject_involvedrelation` (gameobject quest takers) reloaded."); |
---|
| 221 | return true; |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | bool ChatHandler::HandleReloadQuestAreaTriggersCommand(const char*) |
---|
| 225 | { |
---|
| 226 | sLog.outString( "Re-Loading Quest Area Triggers..." ); |
---|
| 227 | objmgr.LoadQuestAreaTriggers(); |
---|
| 228 | SendGlobalSysMessage("DB table `areatrigger_involvedrelation` (quest area triggers) reloaded."); |
---|
| 229 | return true; |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | bool ChatHandler::HandleReloadQuestTemplateCommand(const char*) |
---|
| 233 | { |
---|
| 234 | sLog.outString( "Re-Loading Quest Templates..." ); |
---|
| 235 | objmgr.LoadQuests(); |
---|
| 236 | SendGlobalSysMessage("DB table `quest_template` (quest definitions) reloaded."); |
---|
| 237 | return true; |
---|
| 238 | } |
---|
| 239 | |
---|
| 240 | bool ChatHandler::HandleReloadLootTemplatesCreatureCommand(const char*) |
---|
| 241 | { |
---|
| 242 | sLog.outString( "Re-Loading Loot Tables... (`creature_loot_template`)" ); |
---|
| 243 | LoadLootTemplates_Creature(); |
---|
| 244 | LootTemplates_Creature.CheckLootRefs(); |
---|
| 245 | SendGlobalSysMessage("DB table `creature_loot_template` reloaded."); |
---|
| 246 | return true; |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | bool ChatHandler::HandleReloadLootTemplatesDisenchantCommand(const char*) |
---|
| 250 | { |
---|
| 251 | sLog.outString( "Re-Loading Loot Tables... (`disenchant_loot_template`)" ); |
---|
| 252 | LoadLootTemplates_Disenchant(); |
---|
| 253 | LootTemplates_Disenchant.CheckLootRefs(); |
---|
| 254 | SendGlobalSysMessage("DB table `disenchant_loot_template` reloaded."); |
---|
| 255 | return true; |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | bool ChatHandler::HandleReloadLootTemplatesFishingCommand(const char*) |
---|
| 259 | { |
---|
| 260 | sLog.outString( "Re-Loading Loot Tables... (`fishing_loot_template`)" ); |
---|
| 261 | LoadLootTemplates_Fishing(); |
---|
| 262 | LootTemplates_Fishing.CheckLootRefs(); |
---|
| 263 | SendGlobalSysMessage("DB table `fishing_loot_template` reloaded."); |
---|
| 264 | return true; |
---|
| 265 | } |
---|
| 266 | |
---|
| 267 | bool ChatHandler::HandleReloadLootTemplatesGameobjectCommand(const char*) |
---|
| 268 | { |
---|
| 269 | sLog.outString( "Re-Loading Loot Tables... (`gameobject_loot_template`)" ); |
---|
| 270 | LoadLootTemplates_Gameobject(); |
---|
| 271 | LootTemplates_Gameobject.CheckLootRefs(); |
---|
| 272 | SendGlobalSysMessage("DB table `gameobject_loot_template` reloaded."); |
---|
| 273 | return true; |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | bool ChatHandler::HandleReloadLootTemplatesItemCommand(const char*) |
---|
| 277 | { |
---|
| 278 | sLog.outString( "Re-Loading Loot Tables... (`item_loot_template`)" ); |
---|
| 279 | LoadLootTemplates_Item(); |
---|
| 280 | LootTemplates_Item.CheckLootRefs(); |
---|
| 281 | SendGlobalSysMessage("DB table `item_loot_template` reloaded."); |
---|
| 282 | return true; |
---|
| 283 | } |
---|
| 284 | |
---|
| 285 | bool ChatHandler::HandleReloadLootTemplatesPickpocketingCommand(const char*) |
---|
| 286 | { |
---|
| 287 | sLog.outString( "Re-Loading Loot Tables... (`pickpocketing_loot_template`)" ); |
---|
| 288 | LoadLootTemplates_Pickpocketing(); |
---|
| 289 | LootTemplates_Pickpocketing.CheckLootRefs(); |
---|
| 290 | SendGlobalSysMessage("DB table `pickpocketing_loot_template` reloaded."); |
---|
| 291 | return true; |
---|
| 292 | } |
---|
| 293 | |
---|
| 294 | bool ChatHandler::HandleReloadLootTemplatesProspectingCommand(const char*) |
---|
| 295 | { |
---|
| 296 | sLog.outString( "Re-Loading Loot Tables... (`prospecting_loot_template`)" ); |
---|
| 297 | LoadLootTemplates_Prospecting(); |
---|
| 298 | LootTemplates_Prospecting.CheckLootRefs(); |
---|
| 299 | SendGlobalSysMessage("DB table `prospecting_loot_template` reloaded."); |
---|
| 300 | return true; |
---|
| 301 | } |
---|
| 302 | |
---|
| 303 | bool ChatHandler::HandleReloadLootTemplatesQuestMailCommand(const char*) |
---|
| 304 | { |
---|
| 305 | sLog.outString( "Re-Loading Loot Tables... (`quest_mail_loot_template`)" ); |
---|
| 306 | LoadLootTemplates_QuestMail(); |
---|
| 307 | LootTemplates_QuestMail.CheckLootRefs(); |
---|
| 308 | SendGlobalSysMessage("DB table `quest_mail_loot_template` reloaded."); |
---|
| 309 | return true; |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | bool ChatHandler::HandleReloadLootTemplatesReferenceCommand(const char*) |
---|
| 313 | { |
---|
| 314 | sLog.outString( "Re-Loading Loot Tables... (`reference_loot_template`)" ); |
---|
| 315 | LoadLootTemplates_Reference(); |
---|
| 316 | SendGlobalSysMessage("DB table `reference_loot_template` reloaded."); |
---|
| 317 | return true; |
---|
| 318 | } |
---|
| 319 | |
---|
| 320 | bool ChatHandler::HandleReloadLootTemplatesSkinningCommand(const char*) |
---|
| 321 | { |
---|
| 322 | sLog.outString( "Re-Loading Loot Tables... (`skinning_loot_template`)" ); |
---|
| 323 | LoadLootTemplates_Skinning(); |
---|
| 324 | LootTemplates_Skinning.CheckLootRefs(); |
---|
| 325 | SendGlobalSysMessage("DB table `skinning_loot_template` reloaded."); |
---|
| 326 | return true; |
---|
| 327 | } |
---|
| 328 | |
---|
[44] | 329 | bool ChatHandler::HandleReloadTrinityStringCommand(const char*) |
---|
[37] | 330 | { |
---|
[44] | 331 | sLog.outString( "Re-Loading trinity_string Table!" ); |
---|
| 332 | objmgr.LoadTrinityStrings(); |
---|
| 333 | SendGlobalSysMessage("DB table `trinity_string` reloaded."); |
---|
[37] | 334 | return true; |
---|
| 335 | } |
---|
| 336 | |
---|
| 337 | bool ChatHandler::HandleReloadNpcGossipCommand(const char*) |
---|
| 338 | { |
---|
| 339 | sLog.outString( "Re-Loading `npc_gossip` Table!" ); |
---|
| 340 | objmgr.LoadNpcTextId(); |
---|
| 341 | SendGlobalSysMessage("DB table `npc_gossip` reloaded."); |
---|
| 342 | return true; |
---|
| 343 | } |
---|
| 344 | |
---|
| 345 | bool ChatHandler::HandleReloadNpcTrainerCommand(const char*) |
---|
| 346 | { |
---|
| 347 | sLog.outString( "Re-Loading `npc_trainer` Table!" ); |
---|
| 348 | objmgr.LoadTrainerSpell(); |
---|
| 349 | SendGlobalSysMessage("DB table `npc_trainer` reloaded."); |
---|
| 350 | return true; |
---|
| 351 | } |
---|
| 352 | |
---|
| 353 | bool ChatHandler::HandleReloadNpcVendorCommand(const char*) |
---|
| 354 | { |
---|
| 355 | sLog.outString( "Re-Loading `npc_vendor` Table!" ); |
---|
| 356 | objmgr.LoadVendors(); |
---|
| 357 | SendGlobalSysMessage("DB table `npc_vendor` reloaded."); |
---|
| 358 | return true; |
---|
| 359 | } |
---|
| 360 | |
---|
| 361 | bool ChatHandler::HandleReloadReservedNameCommand(const char*) |
---|
| 362 | { |
---|
| 363 | sLog.outString( "Loading ReservedNames... (`reserved_name`)" ); |
---|
| 364 | objmgr.LoadReservedPlayersNames(); |
---|
| 365 | SendGlobalSysMessage("DB table `reserved_name` (player reserved names) reloaded."); |
---|
| 366 | return true; |
---|
| 367 | } |
---|
| 368 | |
---|
| 369 | bool ChatHandler::HandleReloadSkillDiscoveryTemplateCommand(const char* /*args*/) |
---|
| 370 | { |
---|
| 371 | sLog.outString( "Re-Loading Skill Discovery Table..." ); |
---|
| 372 | LoadSkillDiscoveryTable(); |
---|
| 373 | SendGlobalSysMessage("DB table `skill_discovery_template` (recipes discovered at crafting) reloaded."); |
---|
| 374 | return true; |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | bool ChatHandler::HandleReloadSkillExtraItemTemplateCommand(const char* /*args*/) |
---|
| 378 | { |
---|
| 379 | sLog.outString( "Re-Loading Skill Extra Item Table..." ); |
---|
| 380 | LoadSkillExtraItemTable(); |
---|
| 381 | SendGlobalSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded."); |
---|
| 382 | return true; |
---|
| 383 | } |
---|
| 384 | |
---|
| 385 | bool ChatHandler::HandleReloadSkillFishingBaseLevelCommand(const char* /*args*/) |
---|
| 386 | { |
---|
| 387 | sLog.outString( "Re-Loading Skill Fishing base level requirements..." ); |
---|
| 388 | objmgr.LoadFishingBaseSkillLevel(); |
---|
| 389 | SendGlobalSysMessage("DB table `skill_fishing_base_level` (fishing base level for zone/subzone) reloaded."); |
---|
| 390 | return true; |
---|
| 391 | } |
---|
| 392 | |
---|
| 393 | bool ChatHandler::HandleReloadSpellAffectCommand(const char*) |
---|
| 394 | { |
---|
| 395 | sLog.outString( "Re-Loading SpellAffect definitions..." ); |
---|
| 396 | spellmgr.LoadSpellAffects(); |
---|
| 397 | SendGlobalSysMessage("DB table `spell_affect` (spell mods apply requirements) reloaded."); |
---|
| 398 | return true; |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | bool ChatHandler::HandleReloadSpellChainCommand(const char*) |
---|
| 402 | { |
---|
| 403 | sLog.outString( "Re-Loading Spell Chain Data... " ); |
---|
| 404 | spellmgr.LoadSpellChains(); |
---|
| 405 | SendGlobalSysMessage("DB table `spell_chain` (spell ranks) reloaded."); |
---|
| 406 | return true; |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | bool ChatHandler::HandleReloadSpellElixirCommand(const char*) |
---|
| 410 | { |
---|
| 411 | sLog.outString( "Re-Loading Spell Elixir types..." ); |
---|
| 412 | spellmgr.LoadSpellElixirs(); |
---|
| 413 | SendGlobalSysMessage("DB table `spell_elixir` (spell exlixir types) reloaded."); |
---|
| 414 | return true; |
---|
| 415 | } |
---|
| 416 | |
---|
| 417 | bool ChatHandler::HandleReloadSpellLearnSpellCommand(const char*) |
---|
| 418 | { |
---|
| 419 | sLog.outString( "Re-Loading Spell Learn Spells..." ); |
---|
| 420 | spellmgr.LoadSpellLearnSpells(); |
---|
| 421 | SendGlobalSysMessage("DB table `spell_learn_spell` reloaded."); |
---|
| 422 | return true; |
---|
| 423 | } |
---|
| 424 | |
---|
| 425 | bool ChatHandler::HandleReloadSpellProcEventCommand(const char*) |
---|
| 426 | { |
---|
| 427 | sLog.outString( "Re-Loading Spell Proc Event conditions..." ); |
---|
| 428 | spellmgr.LoadSpellProcEvents(); |
---|
| 429 | SendGlobalSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded."); |
---|
| 430 | return true; |
---|
| 431 | } |
---|
| 432 | |
---|
| 433 | bool ChatHandler::HandleReloadSpellScriptTargetCommand(const char*) |
---|
| 434 | { |
---|
| 435 | sLog.outString( "Re-Loading SpellsScriptTarget..." ); |
---|
| 436 | spellmgr.LoadSpellScriptTarget(); |
---|
| 437 | SendGlobalSysMessage("DB table `spell_script_target` (spell targets selection in case specific creature/GO requirements) reloaded."); |
---|
| 438 | return true; |
---|
| 439 | } |
---|
| 440 | |
---|
| 441 | bool ChatHandler::HandleReloadSpellTargetPositionCommand(const char*) |
---|
| 442 | { |
---|
| 443 | sLog.outString( "Re-Loading Spell target coordinates..." ); |
---|
| 444 | spellmgr.LoadSpellTargetPositions(); |
---|
| 445 | SendGlobalSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded."); |
---|
| 446 | return true; |
---|
| 447 | } |
---|
| 448 | |
---|
| 449 | bool ChatHandler::HandleReloadSpellThreatsCommand(const char*) |
---|
| 450 | { |
---|
| 451 | sLog.outString( "Re-Loading Aggro Spells Definitions..."); |
---|
| 452 | spellmgr.LoadSpellThreats(); |
---|
| 453 | SendGlobalSysMessage("DB table `spell_threat` (spell aggro definitions) reloaded."); |
---|
| 454 | return true; |
---|
| 455 | } |
---|
| 456 | |
---|
| 457 | bool ChatHandler::HandleReloadSpellPetAurasCommand(const char*) |
---|
| 458 | { |
---|
| 459 | sLog.outString( "Re-Loading Spell pet auras..."); |
---|
| 460 | spellmgr.LoadSpellPetAuras(); |
---|
| 461 | SendGlobalSysMessage("DB table `spell_pet_auras` reloaded."); |
---|
| 462 | return true; |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | bool ChatHandler::HandleReloadPageTextsCommand(const char*) |
---|
| 466 | { |
---|
| 467 | sLog.outString( "Re-Loading Page Texts..." ); |
---|
| 468 | objmgr.LoadPageTexts(); |
---|
| 469 | SendGlobalSysMessage("DB table `page_texts` reloaded."); |
---|
| 470 | return true; |
---|
| 471 | } |
---|
| 472 | |
---|
| 473 | bool ChatHandler::HandleReloadItemEnchantementsCommand(const char*) |
---|
| 474 | { |
---|
| 475 | sLog.outString( "Re-Loading Item Random Enchantments Table..." ); |
---|
| 476 | LoadRandomEnchantmentsTable(); |
---|
| 477 | SendGlobalSysMessage("DB table `item_enchantment_template` reloaded."); |
---|
| 478 | return true; |
---|
| 479 | } |
---|
| 480 | |
---|
| 481 | bool ChatHandler::HandleReloadGameObjectScriptsCommand(const char* arg) |
---|
| 482 | { |
---|
| 483 | if(sWorld.IsScriptScheduled()) |
---|
| 484 | { |
---|
| 485 | SendSysMessage("DB scripts used currently, please attempt reload later."); |
---|
| 486 | SetSentErrorMessage(true); |
---|
| 487 | return false; |
---|
| 488 | } |
---|
| 489 | |
---|
| 490 | if(*arg!='a') |
---|
| 491 | sLog.outString( "Re-Loading Scripts from `gameobject_scripts`..."); |
---|
| 492 | |
---|
| 493 | objmgr.LoadGameObjectScripts(); |
---|
| 494 | |
---|
| 495 | if(*arg!='a') |
---|
| 496 | SendGlobalSysMessage("DB table `gameobject_scripts` reloaded."); |
---|
| 497 | |
---|
| 498 | return true; |
---|
| 499 | } |
---|
| 500 | |
---|
| 501 | bool ChatHandler::HandleReloadEventScriptsCommand(const char* arg) |
---|
| 502 | { |
---|
| 503 | if(sWorld.IsScriptScheduled()) |
---|
| 504 | { |
---|
| 505 | SendSysMessage("DB scripts used currently, please attempt reload later."); |
---|
| 506 | SetSentErrorMessage(true); |
---|
| 507 | return false; |
---|
| 508 | } |
---|
| 509 | |
---|
| 510 | if(*arg!='a') |
---|
| 511 | sLog.outString( "Re-Loading Scripts from `event_scripts`..."); |
---|
| 512 | |
---|
| 513 | objmgr.LoadEventScripts(); |
---|
| 514 | |
---|
| 515 | if(*arg!='a') |
---|
| 516 | SendGlobalSysMessage("DB table `event_scripts` reloaded."); |
---|
| 517 | |
---|
| 518 | return true; |
---|
| 519 | } |
---|
| 520 | |
---|
| 521 | bool ChatHandler::HandleReloadQuestEndScriptsCommand(const char* arg) |
---|
| 522 | { |
---|
| 523 | if(sWorld.IsScriptScheduled()) |
---|
| 524 | { |
---|
| 525 | SendSysMessage("DB scripts used currently, please attempt reload later."); |
---|
| 526 | SetSentErrorMessage(true); |
---|
| 527 | return false; |
---|
| 528 | } |
---|
| 529 | |
---|
| 530 | if(*arg!='a') |
---|
| 531 | sLog.outString( "Re-Loading Scripts from `quest_end_scripts`..."); |
---|
| 532 | |
---|
| 533 | objmgr.LoadQuestEndScripts(); |
---|
| 534 | |
---|
| 535 | if(*arg!='a') |
---|
| 536 | SendGlobalSysMessage("DB table `quest_end_scripts` reloaded."); |
---|
| 537 | |
---|
| 538 | return true; |
---|
| 539 | } |
---|
| 540 | |
---|
| 541 | bool ChatHandler::HandleReloadQuestStartScriptsCommand(const char* arg) |
---|
| 542 | { |
---|
| 543 | if(sWorld.IsScriptScheduled()) |
---|
| 544 | { |
---|
| 545 | SendSysMessage("DB scripts used currently, please attempt reload later."); |
---|
| 546 | SetSentErrorMessage(true); |
---|
| 547 | return false; |
---|
| 548 | } |
---|
| 549 | |
---|
| 550 | if(*arg!='a') |
---|
| 551 | sLog.outString( "Re-Loading Scripts from `quest_start_scripts`..."); |
---|
| 552 | |
---|
| 553 | objmgr.LoadQuestStartScripts(); |
---|
| 554 | |
---|
| 555 | if(*arg!='a') |
---|
| 556 | SendGlobalSysMessage("DB table `quest_start_scripts` reloaded."); |
---|
| 557 | |
---|
| 558 | return true; |
---|
| 559 | } |
---|
| 560 | |
---|
| 561 | bool ChatHandler::HandleReloadSpellScriptsCommand(const char* arg) |
---|
| 562 | { |
---|
| 563 | if(sWorld.IsScriptScheduled()) |
---|
| 564 | { |
---|
| 565 | SendSysMessage("DB scripts used currently, please attempt reload later."); |
---|
| 566 | SetSentErrorMessage(true); |
---|
| 567 | return false; |
---|
| 568 | } |
---|
| 569 | |
---|
| 570 | if(*arg!='a') |
---|
| 571 | sLog.outString( "Re-Loading Scripts from `spell_scripts`..."); |
---|
| 572 | |
---|
| 573 | objmgr.LoadSpellScripts(); |
---|
| 574 | |
---|
| 575 | if(*arg!='a') |
---|
| 576 | SendGlobalSysMessage("DB table `spell_scripts` reloaded."); |
---|
| 577 | |
---|
| 578 | return true; |
---|
| 579 | } |
---|
| 580 | |
---|
| 581 | bool ChatHandler::HandleReloadGameGraveyardZoneCommand(const char* /*arg*/) |
---|
| 582 | { |
---|
| 583 | sLog.outString( "Re-Loading Graveyard-zone links..."); |
---|
| 584 | |
---|
| 585 | objmgr.LoadGraveyardZones(); |
---|
| 586 | |
---|
| 587 | SendGlobalSysMessage("DB table `game_graveyard_zone` reloaded."); |
---|
| 588 | |
---|
| 589 | return true; |
---|
| 590 | } |
---|
| 591 | |
---|
| 592 | bool ChatHandler::HandleReloadGameTeleCommand(const char* /*arg*/) |
---|
| 593 | { |
---|
| 594 | sLog.outString( "Re-Loading Game Tele coordinates..."); |
---|
| 595 | |
---|
| 596 | objmgr.LoadGameTele(); |
---|
| 597 | |
---|
| 598 | SendGlobalSysMessage("DB table `game_tele` reloaded."); |
---|
| 599 | |
---|
| 600 | return true; |
---|
| 601 | } |
---|
| 602 | |
---|
| 603 | bool ChatHandler::HandleLoadScriptsCommand(const char* args) |
---|
| 604 | { |
---|
| 605 | if(!LoadScriptingModule(args)) return true; |
---|
| 606 | |
---|
| 607 | sWorld.SendWorldText(LANG_SCRIPTS_RELOADED); |
---|
| 608 | return true; |
---|
| 609 | } |
---|
| 610 | |
---|
| 611 | bool ChatHandler::HandleSecurityCommand(const char* args) |
---|
| 612 | { |
---|
| 613 | char* arg1 = strtok((char*)args, " "); |
---|
| 614 | if( !arg1 ) |
---|
| 615 | return false; |
---|
| 616 | |
---|
| 617 | char* arg2 = 0; |
---|
| 618 | |
---|
| 619 | std::string targetName; |
---|
| 620 | uint32 targetAccountId = 0; |
---|
| 621 | uint32 targetSecurity = 0; |
---|
| 622 | |
---|
| 623 | Player* targetPlayer = getSelectedPlayer(); |
---|
| 624 | if(targetPlayer) |
---|
| 625 | { |
---|
| 626 | targetName = targetPlayer->GetName(); |
---|
| 627 | targetAccountId = targetPlayer->GetSession()->GetAccountId(); |
---|
| 628 | targetSecurity = targetPlayer->GetSession()->GetSecurity(); |
---|
| 629 | arg2 = arg1; |
---|
| 630 | } |
---|
| 631 | else |
---|
| 632 | { |
---|
| 633 | targetName = arg1; |
---|
| 634 | if(!normalizePlayerName(targetName)) |
---|
| 635 | { |
---|
| 636 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 637 | SetSentErrorMessage(true); |
---|
| 638 | return false; |
---|
| 639 | } |
---|
| 640 | |
---|
| 641 | targetPlayer = ObjectAccessor::Instance().FindPlayerByName(targetName.c_str()); |
---|
| 642 | if(targetPlayer) |
---|
| 643 | { |
---|
| 644 | targetAccountId = targetPlayer->GetSession()->GetAccountId(); |
---|
| 645 | targetSecurity = targetPlayer->GetSession()->GetSecurity(); |
---|
| 646 | } |
---|
| 647 | else |
---|
| 648 | { |
---|
| 649 | uint64 targetGUID = objmgr.GetPlayerGUIDByName(targetName.c_str()); |
---|
| 650 | if(!targetGUID) |
---|
| 651 | { |
---|
| 652 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 653 | SetSentErrorMessage(true); |
---|
| 654 | return false; |
---|
| 655 | } |
---|
| 656 | targetAccountId = objmgr.GetPlayerAccountIdByGUID(targetGUID); |
---|
| 657 | targetSecurity = objmgr.GetSecurityByAccount(targetAccountId); |
---|
| 658 | } |
---|
| 659 | |
---|
| 660 | arg2 = strtok(NULL, " "); |
---|
| 661 | } |
---|
| 662 | |
---|
| 663 | int32 gm = (int32)atoi(arg2); |
---|
| 664 | if ( gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR ) |
---|
| 665 | { |
---|
| 666 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 667 | SetSentErrorMessage(true); |
---|
| 668 | return false; |
---|
| 669 | } |
---|
| 670 | |
---|
| 671 | // can set security level only for target with less security and to less security that we have |
---|
| 672 | if(targetSecurity >= m_session->GetSecurity() || uint32(gm) >= m_session->GetSecurity() ) |
---|
| 673 | { |
---|
| 674 | SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); |
---|
| 675 | SetSentErrorMessage(true); |
---|
| 676 | return false; |
---|
| 677 | } |
---|
| 678 | |
---|
| 679 | if(targetPlayer) |
---|
| 680 | { |
---|
| 681 | if( targetPlayer != m_session->GetPlayer() ) |
---|
| 682 | ChatHandler(targetPlayer).PSendSysMessage(LANG_YOURS_SECURITY_CHANGED,m_session->GetPlayer()->GetName(), gm); |
---|
| 683 | |
---|
| 684 | targetPlayer->GetSession()->SetSecurity(gm); |
---|
| 685 | } |
---|
| 686 | |
---|
| 687 | PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetName.c_str(), gm); |
---|
| 688 | loginDatabase.PExecute("UPDATE account SET gmlevel = '%i' WHERE id = '%u'", gm, targetAccountId); |
---|
| 689 | |
---|
| 690 | return true; |
---|
| 691 | } |
---|
| 692 | |
---|
| 693 | bool ChatHandler::HandleAllowMovementCommand(const char* /*args*/) |
---|
| 694 | { |
---|
| 695 | if(sWorld.getAllowMovement()) |
---|
| 696 | { |
---|
| 697 | sWorld.SetAllowMovement(false); |
---|
| 698 | SendSysMessage(LANG_CREATURE_MOVE_DISABLED); |
---|
| 699 | } |
---|
| 700 | else |
---|
| 701 | { |
---|
| 702 | sWorld.SetAllowMovement(true); |
---|
| 703 | SendSysMessage(LANG_CREATURE_MOVE_ENABLED); |
---|
| 704 | } |
---|
| 705 | return true; |
---|
| 706 | } |
---|
| 707 | |
---|
| 708 | bool ChatHandler::HandleMaxSkillCommand(const char* /*args*/) |
---|
| 709 | { |
---|
| 710 | Player* SelectedPlayer = getSelectedPlayer(); |
---|
| 711 | if(!SelectedPlayer) |
---|
| 712 | { |
---|
| 713 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 714 | SetSentErrorMessage(true); |
---|
| 715 | return false; |
---|
| 716 | } |
---|
| 717 | |
---|
| 718 | // each skills that have max skill value dependent from level seted to current level max skill value |
---|
| 719 | SelectedPlayer->UpdateSkillsToMaxSkillsForLevel(); |
---|
| 720 | return true; |
---|
| 721 | } |
---|
| 722 | |
---|
| 723 | bool ChatHandler::HandleSetSkillCommand(const char* args) |
---|
| 724 | { |
---|
| 725 | // number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r |
---|
| 726 | char* skill_p = extractKeyFromLink((char*)args,"Hskill"); |
---|
| 727 | if(!skill_p) |
---|
| 728 | return false; |
---|
| 729 | |
---|
| 730 | char *level_p = strtok (NULL, " "); |
---|
| 731 | |
---|
| 732 | if( !level_p) |
---|
| 733 | return false; |
---|
| 734 | |
---|
| 735 | char *max_p = strtok (NULL, " "); |
---|
| 736 | |
---|
| 737 | int32 skill = atoi(skill_p); |
---|
| 738 | |
---|
| 739 | if (skill <= 0) |
---|
| 740 | { |
---|
| 741 | PSendSysMessage(LANG_INVALID_SKILL_ID, skill); |
---|
| 742 | SetSentErrorMessage(true); |
---|
| 743 | return false; |
---|
| 744 | } |
---|
| 745 | |
---|
| 746 | int32 level = atol (level_p); |
---|
| 747 | |
---|
| 748 | Player * target = getSelectedPlayer(); |
---|
| 749 | if(!target) |
---|
| 750 | { |
---|
| 751 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 752 | SetSentErrorMessage(true); |
---|
| 753 | return false; |
---|
| 754 | } |
---|
| 755 | |
---|
| 756 | SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill); |
---|
| 757 | if(!sl) |
---|
| 758 | { |
---|
| 759 | PSendSysMessage(LANG_INVALID_SKILL_ID, skill); |
---|
| 760 | SetSentErrorMessage(true); |
---|
| 761 | return false; |
---|
| 762 | } |
---|
| 763 | |
---|
| 764 | if(!target->GetSkillValue(skill)) |
---|
| 765 | { |
---|
| 766 | PSendSysMessage(LANG_SET_SKILL_ERROR, target->GetName(), skill, sl->name[0]); |
---|
| 767 | SetSentErrorMessage(true); |
---|
| 768 | return false; |
---|
| 769 | } |
---|
| 770 | |
---|
| 771 | int32 max = max_p ? atol (max_p) : target->GetPureMaxSkillValue(skill); |
---|
| 772 | |
---|
| 773 | if( level <= 0 || level > max || max <= 0 ) |
---|
| 774 | return false; |
---|
| 775 | |
---|
| 776 | target->SetSkill(skill, level, max); |
---|
| 777 | PSendSysMessage(LANG_SET_SKILL, skill, sl->name[0], target->GetName(), level, max); |
---|
| 778 | |
---|
| 779 | return true; |
---|
| 780 | } |
---|
| 781 | |
---|
| 782 | bool ChatHandler::HandleUnLearnCommand(const char* args) |
---|
| 783 | { |
---|
| 784 | if (!*args) |
---|
| 785 | return false; |
---|
| 786 | |
---|
| 787 | |
---|
| 788 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r |
---|
| 789 | uint32 min_id = extractSpellIdFromLink((char*)args); |
---|
| 790 | if(!min_id) |
---|
| 791 | return false; |
---|
| 792 | |
---|
| 793 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r |
---|
| 794 | char* tail = strtok(NULL,""); |
---|
| 795 | |
---|
| 796 | uint32 max_id = extractSpellIdFromLink(tail); |
---|
| 797 | |
---|
| 798 | if (!max_id) |
---|
| 799 | { |
---|
| 800 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r |
---|
| 801 | max_id = min_id+1; |
---|
| 802 | } |
---|
| 803 | else |
---|
| 804 | { |
---|
| 805 | if (max_id < min_id) |
---|
| 806 | std::swap(min_id,max_id); |
---|
| 807 | |
---|
| 808 | max_id=max_id+1; |
---|
| 809 | } |
---|
| 810 | |
---|
| 811 | Player* target = getSelectedPlayer(); |
---|
| 812 | if(!target) |
---|
| 813 | { |
---|
| 814 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 815 | SetSentErrorMessage(true); |
---|
| 816 | return false; |
---|
| 817 | } |
---|
| 818 | |
---|
| 819 | for(uint32 spell=min_id;spell<max_id;spell++) |
---|
| 820 | { |
---|
| 821 | if (target->HasSpell(spell)) |
---|
| 822 | target->removeSpell(spell); |
---|
| 823 | else |
---|
| 824 | SendSysMessage(LANG_FORGET_SPELL); |
---|
| 825 | } |
---|
| 826 | |
---|
| 827 | return true; |
---|
| 828 | } |
---|
| 829 | |
---|
| 830 | bool ChatHandler::HandleCooldownCommand(const char* args) |
---|
| 831 | { |
---|
| 832 | Player* target = getSelectedPlayer(); |
---|
| 833 | if(!target) |
---|
| 834 | { |
---|
| 835 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 836 | SetSentErrorMessage(true); |
---|
| 837 | return false; |
---|
| 838 | } |
---|
| 839 | |
---|
| 840 | if (!*args) |
---|
| 841 | { |
---|
| 842 | target->RemoveAllSpellCooldown(); |
---|
| 843 | PSendSysMessage(LANG_REMOVEALL_COOLDOWN, target->GetName()); |
---|
| 844 | } |
---|
| 845 | else |
---|
| 846 | { |
---|
| 847 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
| 848 | uint32 spell_id = extractSpellIdFromLink((char*)args); |
---|
| 849 | if(!spell_id) |
---|
| 850 | return false; |
---|
| 851 | |
---|
| 852 | if(!sSpellStore.LookupEntry(spell_id)) |
---|
| 853 | { |
---|
[44] | 854 | PSendSysMessage(LANG_UNKNOWN_SPELL, target==m_session->GetPlayer() ? GetTrinityString(LANG_YOU) : target->GetName()); |
---|
[37] | 855 | SetSentErrorMessage(true); |
---|
| 856 | return false; |
---|
| 857 | } |
---|
| 858 | |
---|
| 859 | WorldPacket data( SMSG_CLEAR_COOLDOWN, (4+8) ); |
---|
| 860 | data << uint32(spell_id); |
---|
| 861 | data << uint64(target->GetGUID()); |
---|
| 862 | target->GetSession()->SendPacket(&data); |
---|
| 863 | target->RemoveSpellCooldown(spell_id); |
---|
[44] | 864 | PSendSysMessage(LANG_REMOVE_COOLDOWN, spell_id, target==m_session->GetPlayer() ? GetTrinityString(LANG_YOU) : target->GetName()); |
---|
[37] | 865 | } |
---|
| 866 | return true; |
---|
| 867 | } |
---|
| 868 | |
---|
| 869 | bool ChatHandler::HandleLearnAllCommand(const char* /*args*/) |
---|
| 870 | { |
---|
| 871 | static const char *allSpellList[] = |
---|
| 872 | { |
---|
| 873 | "3365", |
---|
| 874 | "6233", |
---|
| 875 | "6247", |
---|
| 876 | "6246", |
---|
| 877 | "6477", |
---|
| 878 | "6478", |
---|
| 879 | "22810", |
---|
| 880 | "8386", |
---|
| 881 | "21651", |
---|
| 882 | "21652", |
---|
| 883 | "522", |
---|
| 884 | "7266", |
---|
| 885 | "8597", |
---|
| 886 | "2479", |
---|
| 887 | "22027", |
---|
| 888 | "6603", |
---|
| 889 | "5019", |
---|
| 890 | "133", |
---|
| 891 | "168", |
---|
| 892 | "227", |
---|
| 893 | "5009", |
---|
| 894 | "9078", |
---|
| 895 | "668", |
---|
| 896 | "203", |
---|
| 897 | "20599", |
---|
| 898 | "20600", |
---|
| 899 | "81", |
---|
| 900 | "20597", |
---|
| 901 | "20598", |
---|
| 902 | "20864", |
---|
| 903 | "1459", |
---|
| 904 | "5504", |
---|
| 905 | "587", |
---|
| 906 | "5143", |
---|
| 907 | "118", |
---|
| 908 | "5505", |
---|
| 909 | "597", |
---|
| 910 | "604", |
---|
| 911 | "1449", |
---|
| 912 | "1460", |
---|
| 913 | "2855", |
---|
| 914 | "1008", |
---|
| 915 | "475", |
---|
| 916 | "5506", |
---|
| 917 | "1463", |
---|
| 918 | "12824", |
---|
| 919 | "8437", |
---|
| 920 | "990", |
---|
| 921 | "5145", |
---|
| 922 | "8450", |
---|
| 923 | "1461", |
---|
| 924 | "759", |
---|
| 925 | "8494", |
---|
| 926 | "8455", |
---|
| 927 | "8438", |
---|
| 928 | "6127", |
---|
| 929 | "8416", |
---|
| 930 | "6129", |
---|
| 931 | "8451", |
---|
| 932 | "8495", |
---|
| 933 | "8439", |
---|
| 934 | "3552", |
---|
| 935 | "8417", |
---|
| 936 | "10138", |
---|
| 937 | "12825", |
---|
| 938 | "10169", |
---|
| 939 | "10156", |
---|
| 940 | "10144", |
---|
| 941 | "10191", |
---|
| 942 | "10201", |
---|
| 943 | "10211", |
---|
| 944 | "10053", |
---|
| 945 | "10173", |
---|
| 946 | "10139", |
---|
| 947 | "10145", |
---|
| 948 | "10192", |
---|
| 949 | "10170", |
---|
| 950 | "10202", |
---|
| 951 | "10054", |
---|
| 952 | "10174", |
---|
| 953 | "10193", |
---|
| 954 | "12826", |
---|
| 955 | "2136", |
---|
| 956 | "143", |
---|
| 957 | "145", |
---|
| 958 | "2137", |
---|
| 959 | "2120", |
---|
| 960 | "3140", |
---|
| 961 | "543", |
---|
| 962 | "2138", |
---|
| 963 | "2948", |
---|
| 964 | "8400", |
---|
| 965 | "2121", |
---|
| 966 | "8444", |
---|
| 967 | "8412", |
---|
| 968 | "8457", |
---|
| 969 | "8401", |
---|
| 970 | "8422", |
---|
| 971 | "8445", |
---|
| 972 | "8402", |
---|
| 973 | "8413", |
---|
| 974 | "8458", |
---|
| 975 | "8423", |
---|
| 976 | "8446", |
---|
| 977 | "10148", |
---|
| 978 | "10197", |
---|
| 979 | "10205", |
---|
| 980 | "10149", |
---|
| 981 | "10215", |
---|
| 982 | "10223", |
---|
| 983 | "10206", |
---|
| 984 | "10199", |
---|
| 985 | "10150", |
---|
| 986 | "10216", |
---|
| 987 | "10207", |
---|
| 988 | "10225", |
---|
| 989 | "10151", |
---|
| 990 | "116", |
---|
| 991 | "205", |
---|
| 992 | "7300", |
---|
| 993 | "122", |
---|
| 994 | "837", |
---|
| 995 | "10", |
---|
| 996 | "7301", |
---|
| 997 | "7322", |
---|
| 998 | "6143", |
---|
| 999 | "120", |
---|
| 1000 | "865", |
---|
| 1001 | "8406", |
---|
| 1002 | "6141", |
---|
| 1003 | "7302", |
---|
| 1004 | "8461", |
---|
| 1005 | "8407", |
---|
| 1006 | "8492", |
---|
| 1007 | "8427", |
---|
| 1008 | "8408", |
---|
| 1009 | "6131", |
---|
| 1010 | "7320", |
---|
| 1011 | "10159", |
---|
| 1012 | "8462", |
---|
| 1013 | "10185", |
---|
| 1014 | "10179", |
---|
| 1015 | "10160", |
---|
| 1016 | "10180", |
---|
| 1017 | "10219", |
---|
| 1018 | "10186", |
---|
| 1019 | "10177", |
---|
| 1020 | "10230", |
---|
| 1021 | "10181", |
---|
| 1022 | "10161", |
---|
| 1023 | "10187", |
---|
| 1024 | "10220", |
---|
| 1025 | "2018", |
---|
| 1026 | "2663", |
---|
| 1027 | "12260", |
---|
| 1028 | "2660", |
---|
| 1029 | "3115", |
---|
| 1030 | "3326", |
---|
| 1031 | "2665", |
---|
| 1032 | "3116", |
---|
| 1033 | "2738", |
---|
| 1034 | "3293", |
---|
| 1035 | "2661", |
---|
| 1036 | "3319", |
---|
| 1037 | "2662", |
---|
| 1038 | "9983", |
---|
| 1039 | "8880", |
---|
| 1040 | "2737", |
---|
| 1041 | "2739", |
---|
| 1042 | "7408", |
---|
| 1043 | "3320", |
---|
| 1044 | "2666", |
---|
| 1045 | "3323", |
---|
| 1046 | "3324", |
---|
| 1047 | "3294", |
---|
| 1048 | "22723", |
---|
| 1049 | "23219", |
---|
| 1050 | "23220", |
---|
| 1051 | "23221", |
---|
| 1052 | "23228", |
---|
| 1053 | "23338", |
---|
| 1054 | "10788", |
---|
| 1055 | "10790", |
---|
| 1056 | "5611", |
---|
| 1057 | "5016", |
---|
| 1058 | "5609", |
---|
| 1059 | "2060", |
---|
| 1060 | "10963", |
---|
| 1061 | "10964", |
---|
| 1062 | "10965", |
---|
| 1063 | "22593", |
---|
| 1064 | "22594", |
---|
| 1065 | "596", |
---|
| 1066 | "996", |
---|
| 1067 | "499", |
---|
| 1068 | "768", |
---|
| 1069 | "17002", |
---|
| 1070 | "1448", |
---|
| 1071 | "1082", |
---|
| 1072 | "16979", |
---|
| 1073 | "1079", |
---|
| 1074 | "5215", |
---|
| 1075 | "20484", |
---|
| 1076 | "5221", |
---|
| 1077 | "15590", |
---|
| 1078 | "17007", |
---|
| 1079 | "6795", |
---|
| 1080 | "6807", |
---|
| 1081 | "5487", |
---|
| 1082 | "1446", |
---|
| 1083 | "1066", |
---|
| 1084 | "5421", |
---|
| 1085 | "3139", |
---|
| 1086 | "779", |
---|
| 1087 | "6811", |
---|
| 1088 | "6808", |
---|
| 1089 | "1445", |
---|
| 1090 | "5216", |
---|
| 1091 | "1737", |
---|
| 1092 | "5222", |
---|
| 1093 | "5217", |
---|
| 1094 | "1432", |
---|
| 1095 | "6812", |
---|
| 1096 | "9492", |
---|
| 1097 | "5210", |
---|
| 1098 | "3030", |
---|
| 1099 | "1441", |
---|
| 1100 | "783", |
---|
| 1101 | "6801", |
---|
| 1102 | "20739", |
---|
| 1103 | "8944", |
---|
| 1104 | "9491", |
---|
| 1105 | "22569", |
---|
| 1106 | "5226", |
---|
| 1107 | "6786", |
---|
| 1108 | "1433", |
---|
| 1109 | "8973", |
---|
| 1110 | "1828", |
---|
| 1111 | "9495", |
---|
| 1112 | "9006", |
---|
| 1113 | "6794", |
---|
| 1114 | "8993", |
---|
| 1115 | "5203", |
---|
| 1116 | "16914", |
---|
| 1117 | "6784", |
---|
| 1118 | "9635", |
---|
| 1119 | "22830", |
---|
| 1120 | "20722", |
---|
| 1121 | "9748", |
---|
| 1122 | "6790", |
---|
| 1123 | "9753", |
---|
| 1124 | "9493", |
---|
| 1125 | "9752", |
---|
| 1126 | "9831", |
---|
| 1127 | "9825", |
---|
| 1128 | "9822", |
---|
| 1129 | "5204", |
---|
| 1130 | "5401", |
---|
| 1131 | "22831", |
---|
| 1132 | "6793", |
---|
| 1133 | "9845", |
---|
| 1134 | "17401", |
---|
| 1135 | "9882", |
---|
| 1136 | "9868", |
---|
| 1137 | "20749", |
---|
| 1138 | "9893", |
---|
| 1139 | "9899", |
---|
| 1140 | "9895", |
---|
| 1141 | "9832", |
---|
| 1142 | "9902", |
---|
| 1143 | "9909", |
---|
| 1144 | "22832", |
---|
| 1145 | "9828", |
---|
| 1146 | "9851", |
---|
| 1147 | "9883", |
---|
| 1148 | "9869", |
---|
| 1149 | "17406", |
---|
| 1150 | "17402", |
---|
| 1151 | "9914", |
---|
| 1152 | "20750", |
---|
| 1153 | "9897", |
---|
| 1154 | "9848", |
---|
| 1155 | "3127", |
---|
| 1156 | "107", |
---|
| 1157 | "204", |
---|
| 1158 | "9116", |
---|
| 1159 | "2457", |
---|
| 1160 | "78", |
---|
| 1161 | "18848", |
---|
| 1162 | "331", |
---|
| 1163 | "403", |
---|
| 1164 | "2098", |
---|
| 1165 | "1752", |
---|
| 1166 | "11278", |
---|
| 1167 | "11288", |
---|
| 1168 | "11284", |
---|
| 1169 | "6461", |
---|
| 1170 | "2344", |
---|
| 1171 | "2345", |
---|
| 1172 | "6463", |
---|
| 1173 | "2346", |
---|
| 1174 | "2352", |
---|
| 1175 | "775", |
---|
| 1176 | "1434", |
---|
| 1177 | "1612", |
---|
| 1178 | "71", |
---|
| 1179 | "2468", |
---|
| 1180 | "2458", |
---|
| 1181 | "2467", |
---|
| 1182 | "7164", |
---|
| 1183 | "7178", |
---|
| 1184 | "7367", |
---|
| 1185 | "7376", |
---|
| 1186 | "7381", |
---|
| 1187 | "21156", |
---|
| 1188 | "5209", |
---|
| 1189 | "3029", |
---|
| 1190 | "5201", |
---|
| 1191 | "9849", |
---|
| 1192 | "9850", |
---|
| 1193 | "20719", |
---|
| 1194 | "22568", |
---|
| 1195 | "22827", |
---|
| 1196 | "22828", |
---|
| 1197 | "22829", |
---|
| 1198 | "6809", |
---|
| 1199 | "8972", |
---|
| 1200 | "9005", |
---|
| 1201 | "9823", |
---|
| 1202 | "9827", |
---|
| 1203 | "6783", |
---|
| 1204 | "9913", |
---|
| 1205 | "6785", |
---|
| 1206 | "6787", |
---|
| 1207 | "9866", |
---|
| 1208 | "9867", |
---|
| 1209 | "9894", |
---|
| 1210 | "9896", |
---|
| 1211 | "6800", |
---|
| 1212 | "8992", |
---|
| 1213 | "9829", |
---|
| 1214 | "9830", |
---|
| 1215 | "780", |
---|
| 1216 | "769", |
---|
| 1217 | "6749", |
---|
| 1218 | "6750", |
---|
| 1219 | "9755", |
---|
| 1220 | "9754", |
---|
| 1221 | "9908", |
---|
| 1222 | "20745", |
---|
| 1223 | "20742", |
---|
| 1224 | "20747", |
---|
| 1225 | "20748", |
---|
| 1226 | "9746", |
---|
| 1227 | "9745", |
---|
| 1228 | "9880", |
---|
| 1229 | "9881", |
---|
| 1230 | "5391", |
---|
| 1231 | "842", |
---|
| 1232 | "3025", |
---|
| 1233 | "3031", |
---|
| 1234 | "3287", |
---|
| 1235 | "3329", |
---|
| 1236 | "1945", |
---|
| 1237 | "3559", |
---|
| 1238 | "4933", |
---|
| 1239 | "4934", |
---|
| 1240 | "4935", |
---|
| 1241 | "4936", |
---|
| 1242 | "5142", |
---|
| 1243 | "5390", |
---|
| 1244 | "5392", |
---|
| 1245 | "5404", |
---|
| 1246 | "5420", |
---|
| 1247 | "6405", |
---|
| 1248 | "7293", |
---|
| 1249 | "7965", |
---|
| 1250 | "8041", |
---|
| 1251 | "8153", |
---|
| 1252 | "9033", |
---|
| 1253 | "9034", |
---|
| 1254 | //"9036", problems with ghost state |
---|
| 1255 | "16421", |
---|
| 1256 | "21653", |
---|
| 1257 | "22660", |
---|
| 1258 | "5225", |
---|
| 1259 | "9846", |
---|
| 1260 | "2426", |
---|
| 1261 | "5916", |
---|
| 1262 | "6634", |
---|
| 1263 | //"6718", phasing stealth, annoing for learn all case. |
---|
| 1264 | "6719", |
---|
| 1265 | "8822", |
---|
| 1266 | "9591", |
---|
| 1267 | "9590", |
---|
| 1268 | "10032", |
---|
| 1269 | "17746", |
---|
| 1270 | "17747", |
---|
| 1271 | "8203", |
---|
| 1272 | "11392", |
---|
| 1273 | "12495", |
---|
| 1274 | "16380", |
---|
| 1275 | "23452", |
---|
| 1276 | "4079", |
---|
| 1277 | "4996", |
---|
| 1278 | "4997", |
---|
| 1279 | "4998", |
---|
| 1280 | "4999", |
---|
| 1281 | "5000", |
---|
| 1282 | "6348", |
---|
| 1283 | "6349", |
---|
| 1284 | "6481", |
---|
| 1285 | "6482", |
---|
| 1286 | "6483", |
---|
| 1287 | "6484", |
---|
| 1288 | "11362", |
---|
| 1289 | "11410", |
---|
| 1290 | "11409", |
---|
| 1291 | "12510", |
---|
| 1292 | "12509", |
---|
| 1293 | "12885", |
---|
| 1294 | "13142", |
---|
| 1295 | "21463", |
---|
| 1296 | "23460", |
---|
| 1297 | "11421", |
---|
| 1298 | "11416", |
---|
| 1299 | "11418", |
---|
| 1300 | "1851", |
---|
| 1301 | "10059", |
---|
| 1302 | "11423", |
---|
| 1303 | "11417", |
---|
| 1304 | "11422", |
---|
| 1305 | "11419", |
---|
| 1306 | "11424", |
---|
| 1307 | "11420", |
---|
| 1308 | "27", |
---|
| 1309 | "31", |
---|
| 1310 | "33", |
---|
| 1311 | "34", |
---|
| 1312 | "35", |
---|
| 1313 | "15125", |
---|
| 1314 | "21127", |
---|
| 1315 | "22950", |
---|
| 1316 | "1180", |
---|
| 1317 | "201", |
---|
| 1318 | "12593", |
---|
| 1319 | "12842", |
---|
| 1320 | "16770", |
---|
| 1321 | "6057", |
---|
| 1322 | "12051", |
---|
| 1323 | "18468", |
---|
| 1324 | "12606", |
---|
| 1325 | "12605", |
---|
| 1326 | "18466", |
---|
| 1327 | "12502", |
---|
| 1328 | "12043", |
---|
| 1329 | "15060", |
---|
| 1330 | "12042", |
---|
| 1331 | "12341", |
---|
| 1332 | "12848", |
---|
| 1333 | "12344", |
---|
| 1334 | "12353", |
---|
| 1335 | "18460", |
---|
| 1336 | "11366", |
---|
| 1337 | "12350", |
---|
| 1338 | "12352", |
---|
| 1339 | "13043", |
---|
| 1340 | "11368", |
---|
| 1341 | "11113", |
---|
| 1342 | "12400", |
---|
| 1343 | "11129", |
---|
| 1344 | "16766", |
---|
| 1345 | "12573", |
---|
| 1346 | "15053", |
---|
| 1347 | "12580", |
---|
| 1348 | "12475", |
---|
| 1349 | "12472", |
---|
| 1350 | "12953", |
---|
| 1351 | "12488", |
---|
| 1352 | "11189", |
---|
| 1353 | "12985", |
---|
| 1354 | "12519", |
---|
| 1355 | "16758", |
---|
| 1356 | "11958", |
---|
| 1357 | "12490", |
---|
| 1358 | "11426", |
---|
| 1359 | "3565", |
---|
| 1360 | "3562", |
---|
| 1361 | "18960", |
---|
| 1362 | "3567", |
---|
| 1363 | "3561", |
---|
| 1364 | "3566", |
---|
| 1365 | "3563", |
---|
| 1366 | "1953", |
---|
| 1367 | "2139", |
---|
| 1368 | "12505", |
---|
| 1369 | "13018", |
---|
| 1370 | "12522", |
---|
| 1371 | "12523", |
---|
| 1372 | "5146", |
---|
| 1373 | "5144", |
---|
| 1374 | "5148", |
---|
| 1375 | "8419", |
---|
| 1376 | "8418", |
---|
| 1377 | "10213", |
---|
| 1378 | "10212", |
---|
| 1379 | "10157", |
---|
| 1380 | "12524", |
---|
| 1381 | "13019", |
---|
| 1382 | "12525", |
---|
| 1383 | "13020", |
---|
| 1384 | "12526", |
---|
| 1385 | "13021", |
---|
| 1386 | "18809", |
---|
| 1387 | "13031", |
---|
| 1388 | "13032", |
---|
| 1389 | "13033", |
---|
| 1390 | "4036", |
---|
| 1391 | "3920", |
---|
| 1392 | "3919", |
---|
| 1393 | "3918", |
---|
| 1394 | "7430", |
---|
| 1395 | "3922", |
---|
| 1396 | "3923", |
---|
| 1397 | "7411", |
---|
| 1398 | "7418", |
---|
| 1399 | "7421", |
---|
| 1400 | "13262", |
---|
| 1401 | "7412", |
---|
| 1402 | "7415", |
---|
| 1403 | "7413", |
---|
| 1404 | "7416", |
---|
| 1405 | "13920", |
---|
| 1406 | "13921", |
---|
| 1407 | "7745", |
---|
| 1408 | "7779", |
---|
| 1409 | "7428", |
---|
| 1410 | "7457", |
---|
| 1411 | "7857", |
---|
| 1412 | "7748", |
---|
| 1413 | "7426", |
---|
| 1414 | "13421", |
---|
| 1415 | "7454", |
---|
| 1416 | "13378", |
---|
| 1417 | "7788", |
---|
| 1418 | "14807", |
---|
| 1419 | "14293", |
---|
| 1420 | "7795", |
---|
| 1421 | "6296", |
---|
| 1422 | "20608", |
---|
| 1423 | "755", |
---|
| 1424 | "444", |
---|
| 1425 | "427", |
---|
| 1426 | "428", |
---|
| 1427 | "442", |
---|
| 1428 | "447", |
---|
| 1429 | "3578", |
---|
| 1430 | "3581", |
---|
| 1431 | "19027", |
---|
| 1432 | "3580", |
---|
| 1433 | "665", |
---|
| 1434 | "3579", |
---|
| 1435 | "3577", |
---|
| 1436 | "6755", |
---|
| 1437 | "3576", |
---|
| 1438 | "2575", |
---|
| 1439 | "2577", |
---|
| 1440 | "2578", |
---|
| 1441 | "2579", |
---|
| 1442 | "2580", |
---|
| 1443 | "2656", |
---|
| 1444 | "2657", |
---|
| 1445 | "2576", |
---|
| 1446 | "3564", |
---|
| 1447 | "10248", |
---|
| 1448 | "8388", |
---|
| 1449 | "2659", |
---|
| 1450 | "14891", |
---|
| 1451 | "3308", |
---|
| 1452 | "3307", |
---|
| 1453 | "10097", |
---|
| 1454 | "2658", |
---|
| 1455 | "3569", |
---|
| 1456 | "16153", |
---|
| 1457 | "3304", |
---|
| 1458 | "10098", |
---|
| 1459 | "4037", |
---|
| 1460 | "3929", |
---|
| 1461 | "3931", |
---|
| 1462 | "3926", |
---|
| 1463 | "3924", |
---|
| 1464 | "3930", |
---|
| 1465 | "3977", |
---|
| 1466 | "3925", |
---|
| 1467 | "136", |
---|
| 1468 | "228", |
---|
| 1469 | "5487", |
---|
| 1470 | "43", |
---|
| 1471 | "202", |
---|
| 1472 | "0" |
---|
| 1473 | }; |
---|
| 1474 | |
---|
| 1475 | int loop = 0; |
---|
| 1476 | while(strcmp(allSpellList[loop], "0")) |
---|
| 1477 | { |
---|
| 1478 | uint32 spell = atol((char*)allSpellList[loop++]); |
---|
| 1479 | |
---|
| 1480 | if (m_session->GetPlayer()->HasSpell(spell)) |
---|
| 1481 | continue; |
---|
| 1482 | |
---|
| 1483 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); |
---|
| 1484 | if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) |
---|
| 1485 | { |
---|
| 1486 | PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); |
---|
| 1487 | continue; |
---|
| 1488 | } |
---|
| 1489 | |
---|
| 1490 | m_session->GetPlayer()->learnSpell(spell); |
---|
| 1491 | } |
---|
| 1492 | |
---|
| 1493 | SendSysMessage(LANG_COMMAND_LEARN_MANY_SPELLS); |
---|
| 1494 | |
---|
| 1495 | return true; |
---|
| 1496 | } |
---|
| 1497 | |
---|
| 1498 | bool ChatHandler::HandleLearnAllGMCommand(const char* /*args*/) |
---|
| 1499 | { |
---|
| 1500 | static const char *gmSpellList[] = |
---|
| 1501 | { |
---|
| 1502 | "24347", // Become A Fish, No Breath Bar |
---|
| 1503 | "35132", // Visual Boom |
---|
| 1504 | "38488", // Attack 4000-8000 AOE |
---|
| 1505 | "38795", // Attack 2000 AOE + Slow Down 90% |
---|
| 1506 | "15712", // Attack 200 |
---|
| 1507 | "1852", // GM Spell Silence |
---|
| 1508 | "31899", // Kill |
---|
| 1509 | "31924", // Kill |
---|
| 1510 | "29878", // Kill My Self |
---|
| 1511 | "26644", // More Kill |
---|
| 1512 | |
---|
| 1513 | "28550", //Invisible 24 |
---|
| 1514 | "23452", //Invisible + Target |
---|
| 1515 | "0" |
---|
| 1516 | }; |
---|
| 1517 | |
---|
| 1518 | uint16 gmSpellIter = 0; |
---|
| 1519 | while( strcmp(gmSpellList[gmSpellIter], "0") ) |
---|
| 1520 | { |
---|
| 1521 | uint32 spell = atol((char*)gmSpellList[gmSpellIter++]); |
---|
| 1522 | |
---|
| 1523 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); |
---|
| 1524 | if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) |
---|
| 1525 | { |
---|
| 1526 | PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); |
---|
| 1527 | continue; |
---|
| 1528 | } |
---|
| 1529 | |
---|
| 1530 | m_session->GetPlayer()->learnSpell(spell); |
---|
| 1531 | } |
---|
| 1532 | |
---|
| 1533 | SendSysMessage(LANG_LEARNING_GM_SKILLS); |
---|
| 1534 | return true; |
---|
| 1535 | } |
---|
| 1536 | |
---|
| 1537 | bool ChatHandler::HandleLearnAllMyClassCommand(const char* /*args*/) |
---|
| 1538 | { |
---|
| 1539 | HandleLearnAllMySpellsCommand(""); |
---|
| 1540 | HandleLearnAllMyTalentsCommand(""); |
---|
| 1541 | return true; |
---|
| 1542 | } |
---|
| 1543 | |
---|
| 1544 | bool ChatHandler::HandleLearnAllMySpellsCommand(const char* /*args*/) |
---|
| 1545 | { |
---|
| 1546 | ChrClassesEntry const* clsEntry = sChrClassesStore.LookupEntry(m_session->GetPlayer()->getClass()); |
---|
| 1547 | if(!clsEntry) |
---|
| 1548 | return true; |
---|
| 1549 | uint32 family = clsEntry->spellfamily; |
---|
| 1550 | |
---|
| 1551 | for (uint32 i = 0; i < sSpellStore.GetNumRows(); i++) |
---|
| 1552 | { |
---|
| 1553 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(i); |
---|
| 1554 | if(!spellInfo) |
---|
| 1555 | continue; |
---|
| 1556 | |
---|
| 1557 | // skip wrong class/race skills |
---|
| 1558 | if(!m_session->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id)) |
---|
| 1559 | continue; |
---|
| 1560 | |
---|
| 1561 | // skip other spell families |
---|
| 1562 | if( spellInfo->SpellFamilyName != family) |
---|
| 1563 | continue; |
---|
| 1564 | |
---|
| 1565 | //TODO: skip triggered spells |
---|
| 1566 | |
---|
| 1567 | // skip spells with first rank learned as talent (and all talents then also) |
---|
| 1568 | uint32 first_rank = spellmgr.GetFirstSpellInChain(spellInfo->Id); |
---|
| 1569 | if(GetTalentSpellCost(first_rank) > 0 ) |
---|
| 1570 | continue; |
---|
| 1571 | |
---|
| 1572 | // skip broken spells |
---|
| 1573 | if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) |
---|
| 1574 | continue; |
---|
| 1575 | |
---|
| 1576 | m_session->GetPlayer()->learnSpell(i); |
---|
| 1577 | } |
---|
| 1578 | |
---|
| 1579 | SendSysMessage(LANG_COMMAND_LEARN_CLASS_SPELLS); |
---|
| 1580 | return true; |
---|
| 1581 | } |
---|
| 1582 | |
---|
| 1583 | static void learnAllHighRanks(Player* player, uint32 spellid) |
---|
| 1584 | { |
---|
| 1585 | SpellChainMapNext const& nextMap = spellmgr.GetSpellChainNext(); |
---|
| 1586 | for(SpellChainMapNext::const_iterator itr = nextMap.lower_bound(spellid); itr != nextMap.upper_bound(spellid); ++itr) |
---|
| 1587 | { |
---|
| 1588 | player->learnSpell(itr->second); |
---|
| 1589 | learnAllHighRanks(player,itr->second); |
---|
| 1590 | } |
---|
| 1591 | } |
---|
| 1592 | |
---|
| 1593 | bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/) |
---|
| 1594 | { |
---|
| 1595 | Player* player = m_session->GetPlayer(); |
---|
| 1596 | uint32 classMask = player->getClassMask(); |
---|
| 1597 | |
---|
| 1598 | for (uint32 i = 0; i < sTalentStore.GetNumRows(); i++) |
---|
| 1599 | { |
---|
| 1600 | TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); |
---|
| 1601 | if(!talentInfo) |
---|
| 1602 | continue; |
---|
| 1603 | |
---|
| 1604 | TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); |
---|
| 1605 | if(!talentTabInfo) |
---|
| 1606 | continue; |
---|
| 1607 | |
---|
| 1608 | if( (classMask & talentTabInfo->ClassMask) == 0 ) |
---|
| 1609 | continue; |
---|
| 1610 | |
---|
| 1611 | // search highest talent rank |
---|
| 1612 | uint32 spellid = 0; |
---|
| 1613 | int rank = 4; |
---|
| 1614 | for(; rank >= 0; --rank) |
---|
| 1615 | { |
---|
| 1616 | if(talentInfo->RankID[rank]!=0) |
---|
| 1617 | { |
---|
| 1618 | spellid = talentInfo->RankID[rank]; |
---|
| 1619 | break; |
---|
| 1620 | } |
---|
| 1621 | } |
---|
| 1622 | |
---|
| 1623 | if(!spellid) // ??? none spells in telent |
---|
| 1624 | continue; |
---|
| 1625 | |
---|
| 1626 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); |
---|
| 1627 | if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) |
---|
| 1628 | continue; |
---|
| 1629 | |
---|
| 1630 | // learn highest rank of talent |
---|
| 1631 | player->learnSpell(spellid); |
---|
| 1632 | |
---|
| 1633 | // and learn all non-talent spell ranks (recursive by tree) |
---|
| 1634 | learnAllHighRanks(player,spellid); |
---|
| 1635 | } |
---|
| 1636 | |
---|
| 1637 | SendSysMessage(LANG_COMMAND_LEARN_CLASS_TALENTS); |
---|
| 1638 | return true; |
---|
| 1639 | } |
---|
| 1640 | |
---|
| 1641 | bool ChatHandler::HandleLearnAllLangCommand(const char* /*args*/) |
---|
| 1642 | { |
---|
| 1643 | // skipping UNIVERSAL language (0) |
---|
| 1644 | for(int i = 1; i < LANGUAGES_COUNT; ++i) |
---|
| 1645 | m_session->GetPlayer()->learnSpell(lang_description[i].spell_id); |
---|
| 1646 | |
---|
| 1647 | SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG); |
---|
| 1648 | return true; |
---|
| 1649 | } |
---|
| 1650 | |
---|
| 1651 | bool ChatHandler::HandleLearnAllDefaultCommand(const char* args) |
---|
| 1652 | { |
---|
| 1653 | char* pName = strtok((char*)args, ""); |
---|
| 1654 | Player *player = NULL; |
---|
| 1655 | if (pName) |
---|
| 1656 | { |
---|
| 1657 | std::string name = pName; |
---|
| 1658 | |
---|
| 1659 | if(!normalizePlayerName(name)) |
---|
| 1660 | { |
---|
| 1661 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 1662 | SetSentErrorMessage(true); |
---|
| 1663 | return false; |
---|
| 1664 | } |
---|
| 1665 | |
---|
| 1666 | player = objmgr.GetPlayer(name.c_str()); |
---|
| 1667 | } |
---|
| 1668 | else |
---|
| 1669 | player = getSelectedPlayer(); |
---|
| 1670 | |
---|
| 1671 | if(!player) |
---|
| 1672 | { |
---|
| 1673 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 1674 | SetSentErrorMessage(true); |
---|
| 1675 | return false; |
---|
| 1676 | } |
---|
| 1677 | |
---|
| 1678 | player->learnDefaultSpells(); |
---|
| 1679 | player->learnQuestRewardedSpells(); |
---|
| 1680 | |
---|
| 1681 | PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST,player->GetName()); |
---|
| 1682 | return true; |
---|
| 1683 | } |
---|
| 1684 | |
---|
| 1685 | bool ChatHandler::HandleLearnCommand(const char* args) |
---|
| 1686 | { |
---|
| 1687 | Player* targetPlayer = getSelectedPlayer(); |
---|
| 1688 | |
---|
| 1689 | if(!targetPlayer) |
---|
| 1690 | { |
---|
| 1691 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 1692 | SetSentErrorMessage(true); |
---|
| 1693 | return false; |
---|
| 1694 | } |
---|
| 1695 | |
---|
| 1696 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
| 1697 | uint32 spell = extractSpellIdFromLink((char*)args); |
---|
| 1698 | if(!spell || !sSpellStore.LookupEntry(spell)) |
---|
| 1699 | return false; |
---|
| 1700 | |
---|
| 1701 | if (targetPlayer->HasSpell(spell)) |
---|
| 1702 | { |
---|
| 1703 | if(targetPlayer == m_session->GetPlayer()) |
---|
| 1704 | SendSysMessage(LANG_YOU_KNOWN_SPELL); |
---|
| 1705 | else |
---|
| 1706 | PSendSysMessage(LANG_TARGET_KNOWN_SPELL,targetPlayer->GetName()); |
---|
| 1707 | SetSentErrorMessage(true); |
---|
| 1708 | return false; |
---|
| 1709 | } |
---|
| 1710 | |
---|
| 1711 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); |
---|
| 1712 | if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) |
---|
| 1713 | { |
---|
| 1714 | PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); |
---|
| 1715 | SetSentErrorMessage(true); |
---|
| 1716 | return false; |
---|
| 1717 | } |
---|
| 1718 | |
---|
| 1719 | targetPlayer->learnSpell(spell); |
---|
| 1720 | |
---|
| 1721 | return true; |
---|
| 1722 | } |
---|
| 1723 | |
---|
| 1724 | bool ChatHandler::HandleAddItemCommand(const char* args) |
---|
| 1725 | { |
---|
| 1726 | if (!*args) |
---|
| 1727 | return false; |
---|
| 1728 | |
---|
| 1729 | uint32 itemId = 0; |
---|
| 1730 | |
---|
| 1731 | if(args[0]=='[') // [name] manual form |
---|
| 1732 | { |
---|
| 1733 | char* citemName = citemName = strtok((char*)args, "]"); |
---|
| 1734 | |
---|
| 1735 | if(citemName && citemName[0]) |
---|
| 1736 | { |
---|
| 1737 | std::string itemName = citemName+1; |
---|
| 1738 | WorldDatabase.escape_string(itemName); |
---|
| 1739 | QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName.c_str()); |
---|
| 1740 | if (!result) |
---|
| 1741 | { |
---|
| 1742 | PSendSysMessage(LANG_COMMAND_COULDNOTFIND, citemName+1); |
---|
| 1743 | SetSentErrorMessage(true); |
---|
| 1744 | return false; |
---|
| 1745 | } |
---|
| 1746 | itemId = result->Fetch()->GetUInt16(); |
---|
| 1747 | delete result; |
---|
| 1748 | } |
---|
| 1749 | else |
---|
| 1750 | return false; |
---|
| 1751 | } |
---|
| 1752 | else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r |
---|
| 1753 | { |
---|
| 1754 | char* cId = extractKeyFromLink((char*)args,"Hitem"); |
---|
| 1755 | if(!cId) |
---|
| 1756 | return false; |
---|
| 1757 | itemId = atol(cId); |
---|
| 1758 | } |
---|
| 1759 | |
---|
| 1760 | char* ccount = strtok(NULL, " "); |
---|
| 1761 | |
---|
| 1762 | int32 count = 1; |
---|
| 1763 | |
---|
| 1764 | if (ccount) |
---|
| 1765 | count = strtol(ccount, NULL, 10); |
---|
| 1766 | |
---|
| 1767 | if (count == 0) |
---|
| 1768 | count = 1; |
---|
| 1769 | |
---|
| 1770 | Player* pl = m_session->GetPlayer(); |
---|
| 1771 | Player* plTarget = getSelectedPlayer(); |
---|
| 1772 | if(!plTarget) |
---|
| 1773 | plTarget = pl; |
---|
| 1774 | |
---|
[44] | 1775 | sLog.outDetail(GetTrinityString(LANG_ADDITEM), itemId, count); |
---|
[37] | 1776 | |
---|
| 1777 | ItemPrototype const *pProto = objmgr.GetItemPrototype(itemId); |
---|
| 1778 | if(!pProto) |
---|
| 1779 | { |
---|
| 1780 | PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId); |
---|
| 1781 | SetSentErrorMessage(true); |
---|
| 1782 | return false; |
---|
| 1783 | } |
---|
| 1784 | |
---|
| 1785 | //Subtract |
---|
| 1786 | if (count < 0) |
---|
| 1787 | { |
---|
| 1788 | plTarget->DestroyItemCount(itemId, -count, true, false); |
---|
| 1789 | PSendSysMessage(LANG_REMOVEITEM, itemId, -count, plTarget->GetName()); |
---|
| 1790 | return true; |
---|
| 1791 | } |
---|
| 1792 | |
---|
| 1793 | //Adding items |
---|
| 1794 | uint32 noSpaceForCount = 0; |
---|
| 1795 | |
---|
| 1796 | // check space and find places |
---|
| 1797 | ItemPosCountVec dest; |
---|
| 1798 | uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount ); |
---|
| 1799 | if( msg != EQUIP_ERR_OK ) // convert to possible store amount |
---|
| 1800 | count -= noSpaceForCount; |
---|
| 1801 | |
---|
| 1802 | if( count == 0 || dest.empty()) // can't add any |
---|
| 1803 | { |
---|
| 1804 | PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount ); |
---|
| 1805 | SetSentErrorMessage(true); |
---|
| 1806 | return false; |
---|
| 1807 | } |
---|
| 1808 | |
---|
| 1809 | Item* item = plTarget->StoreNewItem( dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); |
---|
| 1810 | |
---|
| 1811 | // remove binding (let GM give it to another player later) |
---|
| 1812 | if(pl==plTarget) |
---|
| 1813 | for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) |
---|
| 1814 | if(Item* item1 = pl->GetItemByPos(itr->pos)) |
---|
| 1815 | item1->SetBinding( false ); |
---|
| 1816 | |
---|
| 1817 | if(count > 0 && item) |
---|
| 1818 | { |
---|
| 1819 | pl->SendNewItem(item,count,false,true); |
---|
| 1820 | if(pl!=plTarget) |
---|
| 1821 | plTarget->SendNewItem(item,count,true,false); |
---|
| 1822 | } |
---|
| 1823 | |
---|
| 1824 | if(noSpaceForCount > 0) |
---|
| 1825 | PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); |
---|
| 1826 | |
---|
| 1827 | return true; |
---|
| 1828 | } |
---|
| 1829 | |
---|
| 1830 | bool ChatHandler::HandleAddItemSetCommand(const char* args) |
---|
| 1831 | { |
---|
| 1832 | if (!*args) |
---|
| 1833 | return false; |
---|
| 1834 | |
---|
| 1835 | char* cId = extractKeyFromLink((char*)args,"Hitemset"); // number or [name] Shift-click form |color|Hitemset:itemset_id|h[name]|h|r |
---|
| 1836 | if (!cId) |
---|
| 1837 | return false; |
---|
| 1838 | |
---|
| 1839 | uint32 itemsetId = atol(cId); |
---|
| 1840 | |
---|
| 1841 | // prevent generation all items with itemset field value '0' |
---|
| 1842 | if (itemsetId == 0) |
---|
| 1843 | { |
---|
| 1844 | PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND,itemsetId); |
---|
| 1845 | SetSentErrorMessage(true); |
---|
| 1846 | return false; |
---|
| 1847 | } |
---|
| 1848 | |
---|
| 1849 | Player* pl = m_session->GetPlayer(); |
---|
| 1850 | Player* plTarget = getSelectedPlayer(); |
---|
| 1851 | if(!plTarget) |
---|
| 1852 | plTarget = pl; |
---|
| 1853 | |
---|
[44] | 1854 | sLog.outDetail(GetTrinityString(LANG_ADDITEMSET), itemsetId); |
---|
[37] | 1855 | |
---|
| 1856 | QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE itemset = %u",itemsetId); |
---|
| 1857 | |
---|
| 1858 | if(!result) |
---|
| 1859 | { |
---|
| 1860 | PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND,itemsetId); |
---|
| 1861 | |
---|
| 1862 | SetSentErrorMessage(true); |
---|
| 1863 | return false; |
---|
| 1864 | } |
---|
| 1865 | |
---|
| 1866 | do |
---|
| 1867 | { |
---|
| 1868 | Field *fields = result->Fetch(); |
---|
| 1869 | uint32 itemId = fields[0].GetUInt32(); |
---|
| 1870 | |
---|
| 1871 | ItemPosCountVec dest; |
---|
| 1872 | uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, itemId, 1 ); |
---|
| 1873 | if( msg == EQUIP_ERR_OK ) |
---|
| 1874 | { |
---|
| 1875 | Item* item = plTarget->StoreNewItem( dest, itemId, true); |
---|
| 1876 | |
---|
| 1877 | // remove binding (let GM give it to another player later) |
---|
| 1878 | if(pl==plTarget) |
---|
| 1879 | item->SetBinding( false ); |
---|
| 1880 | |
---|
| 1881 | pl->SendNewItem(item,1,false,true); |
---|
| 1882 | if(pl!=plTarget) |
---|
| 1883 | plTarget->SendNewItem(item,1,true,false); |
---|
| 1884 | } |
---|
| 1885 | else |
---|
| 1886 | { |
---|
| 1887 | pl->SendEquipError( msg, NULL, NULL ); |
---|
| 1888 | PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, 1); |
---|
| 1889 | } |
---|
| 1890 | |
---|
| 1891 | }while( result->NextRow() ); |
---|
| 1892 | |
---|
| 1893 | delete result; |
---|
| 1894 | |
---|
| 1895 | return true; |
---|
| 1896 | } |
---|
| 1897 | |
---|
| 1898 | bool ChatHandler::HandleListItemCommand(const char* args) |
---|
| 1899 | { |
---|
| 1900 | if(!*args) |
---|
| 1901 | return false; |
---|
| 1902 | |
---|
| 1903 | char* cId = extractKeyFromLink((char*)args,"Hitem"); |
---|
| 1904 | if(!cId) |
---|
| 1905 | return false; |
---|
| 1906 | uint32 item_id = atol(cId); |
---|
| 1907 | |
---|
| 1908 | ItemPrototype const* itemProto = item_id ? itemProto = objmgr.GetItemPrototype(item_id) : NULL; |
---|
| 1909 | |
---|
| 1910 | if(!itemProto) |
---|
| 1911 | { |
---|
| 1912 | PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); |
---|
| 1913 | SetSentErrorMessage(true); |
---|
| 1914 | return false; |
---|
| 1915 | } |
---|
| 1916 | |
---|
| 1917 | char* c_count = strtok(NULL, " "); |
---|
| 1918 | int count = c_count ? atol(c_count) : 10; |
---|
| 1919 | |
---|
| 1920 | if(count < 0) |
---|
| 1921 | return false; |
---|
| 1922 | |
---|
| 1923 | QueryResult *result; |
---|
| 1924 | |
---|
| 1925 | // inventory case |
---|
| 1926 | uint32 inv_count = 0; |
---|
| 1927 | result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM character_inventory WHERE item_template='%u'",item_id); |
---|
| 1928 | if(result) |
---|
| 1929 | { |
---|
| 1930 | inv_count = (*result)[0].GetUInt32(); |
---|
| 1931 | delete result; |
---|
| 1932 | } |
---|
| 1933 | |
---|
| 1934 | result=CharacterDatabase.PQuery( |
---|
| 1935 | // 0 1 2 3 4 5 |
---|
| 1936 | "SELECT ci.item, cibag.slot AS bag, ci.slot, ci.guid, characters.account,characters.name " |
---|
| 1937 | "FROM character_inventory AS ci LEFT JOIN character_inventory AS cibag ON (cibag.item=ci.bag),characters " |
---|
| 1938 | "WHERE ci.item_template='%u' AND ci.guid = characters.guid LIMIT %u ", |
---|
| 1939 | item_id,uint32(count)); |
---|
| 1940 | |
---|
| 1941 | if(result) |
---|
| 1942 | { |
---|
| 1943 | do |
---|
| 1944 | { |
---|
| 1945 | Field *fields = result->Fetch(); |
---|
| 1946 | uint32 item_guid = fields[0].GetUInt32(); |
---|
| 1947 | uint32 item_bag = fields[1].GetUInt32(); |
---|
| 1948 | uint32 item_slot = fields[2].GetUInt32(); |
---|
| 1949 | uint32 owner_guid = fields[3].GetUInt32(); |
---|
| 1950 | uint32 owner_acc = fields[4].GetUInt32(); |
---|
| 1951 | std::string owner_name = fields[5].GetCppString(); |
---|
| 1952 | |
---|
| 1953 | char const* item_pos = 0; |
---|
| 1954 | if(Player::IsEquipmentPos(item_bag,item_slot)) |
---|
| 1955 | item_pos = "[equipped]"; |
---|
| 1956 | else if(Player::IsInventoryPos(item_bag,item_slot)) |
---|
| 1957 | item_pos = "[in inventory]"; |
---|
| 1958 | else if(Player::IsBankPos(item_bag,item_slot)) |
---|
| 1959 | item_pos = "[in bank]"; |
---|
| 1960 | else |
---|
| 1961 | item_pos = ""; |
---|
| 1962 | |
---|
| 1963 | PSendSysMessage(LANG_ITEMLIST_SLOT, |
---|
| 1964 | item_guid,owner_name.c_str(),owner_guid,owner_acc,item_pos); |
---|
| 1965 | } while (result->NextRow()); |
---|
| 1966 | |
---|
| 1967 | int64 res_count = result->GetRowCount(); |
---|
| 1968 | |
---|
| 1969 | delete result; |
---|
| 1970 | |
---|
| 1971 | if(count > res_count) |
---|
| 1972 | count-=res_count; |
---|
| 1973 | else if(count) |
---|
| 1974 | count = 0; |
---|
| 1975 | } |
---|
| 1976 | |
---|
| 1977 | // mail case |
---|
| 1978 | uint32 mail_count = 0; |
---|
| 1979 | result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM mail_items WHERE item_template='%u'", item_id); |
---|
| 1980 | if(result) |
---|
| 1981 | { |
---|
| 1982 | mail_count = (*result)[0].GetUInt32(); |
---|
| 1983 | delete result; |
---|
| 1984 | } |
---|
| 1985 | |
---|
| 1986 | if(count > 0) |
---|
| 1987 | { |
---|
| 1988 | result=CharacterDatabase.PQuery( |
---|
| 1989 | // 0 1 2 3 4 5 6 |
---|
| 1990 | "SELECT mail_items.item_guid, mail.sender, mail.receiver, char_s.account, char_s.name, char_r.account, char_r.name " |
---|
| 1991 | "FROM mail,mail_items,characters as char_s,characters as char_r " |
---|
| 1992 | "WHERE mail_items.item_template='%u' AND char_s.guid = mail.sender AND char_r.guid = mail.receiver AND mail.id=mail_items.mail_id LIMIT %u", |
---|
| 1993 | item_id,uint32(count)); |
---|
| 1994 | } |
---|
| 1995 | else |
---|
| 1996 | result = NULL; |
---|
| 1997 | |
---|
| 1998 | if(result) |
---|
| 1999 | { |
---|
| 2000 | do |
---|
| 2001 | { |
---|
| 2002 | Field *fields = result->Fetch(); |
---|
| 2003 | uint32 item_guid = fields[0].GetUInt32(); |
---|
| 2004 | uint32 item_s = fields[1].GetUInt32(); |
---|
| 2005 | uint32 item_r = fields[2].GetUInt32(); |
---|
| 2006 | uint32 item_s_acc = fields[3].GetUInt32(); |
---|
| 2007 | std::string item_s_name = fields[4].GetCppString(); |
---|
| 2008 | uint32 item_r_acc = fields[5].GetUInt32(); |
---|
| 2009 | std::string item_r_name = fields[6].GetCppString(); |
---|
| 2010 | |
---|
| 2011 | char const* item_pos = "[in mail]"; |
---|
| 2012 | |
---|
| 2013 | PSendSysMessage(LANG_ITEMLIST_MAIL, |
---|
| 2014 | item_guid,item_s_name.c_str(),item_s,item_s_acc,item_r_name.c_str(),item_r,item_r_acc,item_pos); |
---|
| 2015 | } while (result->NextRow()); |
---|
| 2016 | |
---|
| 2017 | int64 res_count = result->GetRowCount(); |
---|
| 2018 | |
---|
| 2019 | delete result; |
---|
| 2020 | |
---|
| 2021 | if(count > res_count) |
---|
| 2022 | count-=res_count; |
---|
| 2023 | else if(count) |
---|
| 2024 | count = 0; |
---|
| 2025 | } |
---|
| 2026 | |
---|
| 2027 | // auction case |
---|
| 2028 | uint32 auc_count = 0; |
---|
| 2029 | result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM auctionhouse WHERE item_template='%u'",item_id); |
---|
| 2030 | if(result) |
---|
| 2031 | { |
---|
| 2032 | auc_count = (*result)[0].GetUInt32(); |
---|
| 2033 | delete result; |
---|
| 2034 | } |
---|
| 2035 | |
---|
| 2036 | if(count > 0) |
---|
| 2037 | { |
---|
| 2038 | result=CharacterDatabase.PQuery( |
---|
| 2039 | // 0 1 2 3 |
---|
| 2040 | "SELECT auctionhouse.itemguid, auctionhouse.itemowner, characters.account, characters.name " |
---|
| 2041 | "FROM auctionhouse,characters WHERE auctionhouse.item_template='%u' AND characters.guid = auctionhouse.itemowner LIMIT %u", |
---|
| 2042 | item_id,uint32(count)); |
---|
| 2043 | } |
---|
| 2044 | else |
---|
| 2045 | result = NULL; |
---|
| 2046 | |
---|
| 2047 | if(result) |
---|
| 2048 | { |
---|
| 2049 | do |
---|
| 2050 | { |
---|
| 2051 | Field *fields = result->Fetch(); |
---|
| 2052 | uint32 item_guid = fields[0].GetUInt32(); |
---|
| 2053 | uint32 owner = fields[1].GetUInt32(); |
---|
| 2054 | uint32 owner_acc = fields[2].GetUInt32(); |
---|
| 2055 | std::string owner_name = fields[3].GetCppString(); |
---|
| 2056 | |
---|
| 2057 | char const* item_pos = "[in auction]"; |
---|
| 2058 | |
---|
| 2059 | PSendSysMessage(LANG_ITEMLIST_AUCTION, item_guid, owner_name.c_str(), owner, owner_acc,item_pos); |
---|
| 2060 | } while (result->NextRow()); |
---|
| 2061 | |
---|
| 2062 | delete result; |
---|
| 2063 | } |
---|
| 2064 | |
---|
| 2065 | if(inv_count+mail_count+auc_count == 0) |
---|
| 2066 | { |
---|
| 2067 | SendSysMessage(LANG_COMMAND_NOITEMFOUND); |
---|
| 2068 | SetSentErrorMessage(true); |
---|
| 2069 | return false; |
---|
| 2070 | } |
---|
| 2071 | |
---|
| 2072 | PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE,item_id,inv_count+mail_count+auc_count,inv_count,mail_count,auc_count); |
---|
| 2073 | |
---|
| 2074 | return true; |
---|
| 2075 | } |
---|
| 2076 | |
---|
| 2077 | bool ChatHandler::HandleListObjectCommand(const char* args) |
---|
| 2078 | { |
---|
| 2079 | if(!*args) |
---|
| 2080 | return false; |
---|
| 2081 | |
---|
| 2082 | // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r |
---|
| 2083 | char* cId = extractKeyFromLink((char*)args,"Hgameobject_entry"); |
---|
| 2084 | if(!cId) |
---|
| 2085 | return false; |
---|
| 2086 | |
---|
| 2087 | uint32 go_id = atol(cId); |
---|
| 2088 | |
---|
| 2089 | GameObjectInfo const * gInfo = objmgr.GetGameObjectInfo(go_id); |
---|
| 2090 | |
---|
| 2091 | if(!go_id || !gInfo) |
---|
| 2092 | { |
---|
| 2093 | PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, go_id); |
---|
| 2094 | SetSentErrorMessage(true); |
---|
| 2095 | return false; |
---|
| 2096 | } |
---|
| 2097 | |
---|
| 2098 | char* c_count = strtok(NULL, " "); |
---|
| 2099 | int count = c_count ? atol(c_count) : 10; |
---|
| 2100 | |
---|
| 2101 | if(count < 0) |
---|
| 2102 | return false; |
---|
| 2103 | |
---|
| 2104 | Player* pl = m_session->GetPlayer(); |
---|
| 2105 | QueryResult *result; |
---|
| 2106 | |
---|
| 2107 | uint32 obj_count = 0; |
---|
| 2108 | result=WorldDatabase.PQuery("SELECT COUNT(guid) FROM gameobject WHERE id='%u'",go_id); |
---|
| 2109 | if(result) |
---|
| 2110 | { |
---|
| 2111 | obj_count = (*result)[0].GetUInt32(); |
---|
| 2112 | delete result; |
---|
| 2113 | } |
---|
| 2114 | |
---|
| 2115 | result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", |
---|
| 2116 | pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),go_id,uint32(count)); |
---|
| 2117 | |
---|
| 2118 | if (result) |
---|
| 2119 | { |
---|
| 2120 | do |
---|
| 2121 | { |
---|
| 2122 | Field *fields = result->Fetch(); |
---|
| 2123 | uint32 guid = fields[0].GetUInt32(); |
---|
| 2124 | float x = fields[1].GetFloat(); |
---|
| 2125 | float y = fields[2].GetFloat(); |
---|
| 2126 | float z = fields[3].GetFloat(); |
---|
| 2127 | int mapid = fields[4].GetUInt16(); |
---|
| 2128 | |
---|
| 2129 | PSendSysMessage(LANG_GO_LIST, guid, guid, gInfo->name, x, y, z, mapid); |
---|
| 2130 | } while (result->NextRow()); |
---|
| 2131 | |
---|
| 2132 | delete result; |
---|
| 2133 | } |
---|
| 2134 | |
---|
| 2135 | PSendSysMessage(LANG_COMMAND_LISTOBJMESSAGE,go_id,obj_count); |
---|
| 2136 | return true; |
---|
| 2137 | } |
---|
| 2138 | |
---|
| 2139 | bool ChatHandler::HandleNearObjectCommand(const char* args) |
---|
| 2140 | { |
---|
| 2141 | float distance = (!*args) ? 10 : atol(args); |
---|
| 2142 | uint32 count = 0; |
---|
| 2143 | |
---|
| 2144 | Player* pl = m_session->GetPlayer(); |
---|
| 2145 | QueryResult *result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, " |
---|
| 2146 | "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ " |
---|
| 2147 | "FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_", |
---|
| 2148 | pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), |
---|
| 2149 | pl->GetMapId(),pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),distance*distance); |
---|
| 2150 | |
---|
| 2151 | if (result) |
---|
| 2152 | { |
---|
| 2153 | do |
---|
| 2154 | { |
---|
| 2155 | Field *fields = result->Fetch(); |
---|
| 2156 | uint32 guid = fields[0].GetUInt32(); |
---|
| 2157 | uint32 entry = fields[1].GetUInt32(); |
---|
| 2158 | float x = fields[2].GetFloat(); |
---|
| 2159 | float y = fields[3].GetFloat(); |
---|
| 2160 | float z = fields[4].GetFloat(); |
---|
| 2161 | int mapid = fields[5].GetUInt16(); |
---|
| 2162 | |
---|
| 2163 | GameObjectInfo const * gInfo = objmgr.GetGameObjectInfo(entry); |
---|
| 2164 | |
---|
| 2165 | if(!gInfo) |
---|
| 2166 | continue; |
---|
| 2167 | |
---|
| 2168 | PSendSysMessage(LANG_GO_LIST, guid, guid, gInfo->name, x, y, z, mapid); |
---|
| 2169 | |
---|
| 2170 | ++count; |
---|
| 2171 | } while (result->NextRow()); |
---|
| 2172 | |
---|
| 2173 | delete result; |
---|
| 2174 | } |
---|
| 2175 | |
---|
| 2176 | PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE,distance,count); |
---|
| 2177 | return true; |
---|
| 2178 | } |
---|
| 2179 | |
---|
[42] | 2180 | bool ChatHandler::HandleObjectStateCommand(const char* args) |
---|
| 2181 | { |
---|
| 2182 | // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r |
---|
| 2183 | char* cId = extractKeyFromLink((char*)args, "Hgameobject"); |
---|
| 2184 | if(!cId) |
---|
| 2185 | return false; |
---|
| 2186 | |
---|
| 2187 | uint32 lowguid = atoi(cId); |
---|
| 2188 | if(!lowguid) |
---|
| 2189 | return false; |
---|
| 2190 | |
---|
| 2191 | GameObject* gobj = NULL; |
---|
| 2192 | |
---|
| 2193 | if(GameObjectData const* goData = objmgr.GetGOData(lowguid)) |
---|
| 2194 | gobj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, goData->id); |
---|
| 2195 | |
---|
| 2196 | if(!gobj) |
---|
| 2197 | { |
---|
| 2198 | PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); |
---|
| 2199 | SetSentErrorMessage(true); |
---|
| 2200 | return false; |
---|
| 2201 | } |
---|
| 2202 | |
---|
| 2203 | char* cstate = strtok(NULL, " "); |
---|
| 2204 | if(!cstate) |
---|
| 2205 | return false; |
---|
| 2206 | |
---|
| 2207 | int32 state = atoi(cstate); |
---|
| 2208 | if(state < 0) |
---|
| 2209 | gobj->SendObjectDeSpawnAnim(gobj->GetGUID()); |
---|
| 2210 | else |
---|
| 2211 | gobj->SetGoState(state); |
---|
| 2212 | |
---|
| 2213 | return true; |
---|
| 2214 | |
---|
| 2215 | return true; |
---|
| 2216 | } |
---|
| 2217 | |
---|
[37] | 2218 | bool ChatHandler::HandleListCreatureCommand(const char* args) |
---|
| 2219 | { |
---|
| 2220 | if(!*args) |
---|
| 2221 | return false; |
---|
| 2222 | |
---|
| 2223 | // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r |
---|
| 2224 | char* cId = extractKeyFromLink((char*)args,"Hcreature_entry"); |
---|
| 2225 | if(!cId) |
---|
| 2226 | return false; |
---|
| 2227 | |
---|
| 2228 | uint32 cr_id = atol(cId); |
---|
| 2229 | |
---|
| 2230 | CreatureInfo const* cInfo = objmgr.GetCreatureTemplate(cr_id); |
---|
| 2231 | |
---|
| 2232 | if(!cr_id || !cInfo) |
---|
| 2233 | { |
---|
| 2234 | PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, cr_id); |
---|
| 2235 | SetSentErrorMessage(true); |
---|
| 2236 | return false; |
---|
| 2237 | } |
---|
| 2238 | |
---|
| 2239 | char* c_count = strtok(NULL, " "); |
---|
| 2240 | int count = c_count ? atol(c_count) : 10; |
---|
| 2241 | |
---|
| 2242 | if(count < 0) |
---|
| 2243 | return false; |
---|
| 2244 | |
---|
| 2245 | Player* pl = m_session->GetPlayer(); |
---|
| 2246 | QueryResult *result; |
---|
| 2247 | |
---|
| 2248 | uint32 cr_count = 0; |
---|
| 2249 | result=WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id='%u'",cr_id); |
---|
| 2250 | if(result) |
---|
| 2251 | { |
---|
| 2252 | cr_count = (*result)[0].GetUInt32(); |
---|
| 2253 | delete result; |
---|
| 2254 | } |
---|
| 2255 | |
---|
| 2256 | result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", |
---|
| 2257 | pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id,uint32(count)); |
---|
| 2258 | |
---|
| 2259 | if (result) |
---|
| 2260 | { |
---|
| 2261 | do |
---|
| 2262 | { |
---|
| 2263 | Field *fields = result->Fetch(); |
---|
| 2264 | uint32 guid = fields[0].GetUInt32(); |
---|
| 2265 | float x = fields[1].GetFloat(); |
---|
| 2266 | float y = fields[2].GetFloat(); |
---|
| 2267 | float z = fields[3].GetFloat(); |
---|
| 2268 | int mapid = fields[4].GetUInt16(); |
---|
| 2269 | |
---|
| 2270 | PSendSysMessage(LANG_CREATURE_LIST, guid, guid, cInfo->Name, x, y, z, mapid); |
---|
| 2271 | } while (result->NextRow()); |
---|
| 2272 | |
---|
| 2273 | delete result; |
---|
| 2274 | } |
---|
| 2275 | |
---|
| 2276 | PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE,cr_id,cr_count); |
---|
| 2277 | return true; |
---|
| 2278 | } |
---|
| 2279 | |
---|
| 2280 | bool ChatHandler::HandleLookupItemCommand(const char* args) |
---|
| 2281 | { |
---|
| 2282 | if(!*args) |
---|
| 2283 | return false; |
---|
| 2284 | |
---|
| 2285 | std::string namepart = args; |
---|
| 2286 | std::wstring wnamepart; |
---|
| 2287 | |
---|
| 2288 | // converting string that we try to find to lower case |
---|
| 2289 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
| 2290 | return false; |
---|
| 2291 | |
---|
| 2292 | wstrToLower(wnamepart); |
---|
| 2293 | |
---|
| 2294 | uint32 counter = 0; |
---|
| 2295 | |
---|
| 2296 | // Search in `item_template` |
---|
| 2297 | for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) |
---|
| 2298 | { |
---|
| 2299 | ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype >(id); |
---|
| 2300 | if(!pProto) |
---|
| 2301 | continue; |
---|
| 2302 | |
---|
| 2303 | int loc_idx = m_session->GetSessionDbLocaleIndex(); |
---|
| 2304 | if ( loc_idx >= 0 ) |
---|
| 2305 | { |
---|
| 2306 | ItemLocale const *il = objmgr.GetItemLocale(pProto->ItemId); |
---|
| 2307 | if (il) |
---|
| 2308 | { |
---|
| 2309 | if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) |
---|
| 2310 | { |
---|
| 2311 | std::string name = il->Name[loc_idx]; |
---|
| 2312 | |
---|
| 2313 | if (Utf8FitTo(name, wnamepart)) |
---|
| 2314 | { |
---|
| 2315 | PSendSysMessage(LANG_ITEM_LIST, id, id, name.c_str()); |
---|
| 2316 | ++counter; |
---|
| 2317 | continue; |
---|
| 2318 | } |
---|
| 2319 | } |
---|
| 2320 | } |
---|
| 2321 | } |
---|
| 2322 | |
---|
| 2323 | std::string name = pProto->Name1; |
---|
| 2324 | if(name.empty()) |
---|
| 2325 | continue; |
---|
| 2326 | |
---|
| 2327 | if (Utf8FitTo(name, wnamepart)) |
---|
| 2328 | { |
---|
| 2329 | PSendSysMessage(LANG_ITEM_LIST, id, id, name.c_str()); |
---|
| 2330 | ++counter; |
---|
| 2331 | } |
---|
| 2332 | } |
---|
| 2333 | |
---|
| 2334 | if (counter==0) |
---|
| 2335 | SendSysMessage(LANG_COMMAND_NOITEMFOUND); |
---|
| 2336 | |
---|
| 2337 | return true; |
---|
| 2338 | } |
---|
| 2339 | |
---|
| 2340 | bool ChatHandler::HandleLookupItemSetCommand(const char* args) |
---|
| 2341 | { |
---|
| 2342 | if(!*args) |
---|
| 2343 | return false; |
---|
| 2344 | |
---|
| 2345 | std::string namepart = args; |
---|
| 2346 | std::wstring wnamepart; |
---|
| 2347 | |
---|
| 2348 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
| 2349 | return false; |
---|
| 2350 | |
---|
| 2351 | // converting string that we try to find to lower case |
---|
| 2352 | wstrToLower( wnamepart ); |
---|
| 2353 | |
---|
| 2354 | uint32 counter = 0; // Counter for figure out that we found smth. |
---|
| 2355 | |
---|
| 2356 | // Search in ItemSet.dbc |
---|
| 2357 | for (uint32 id = 0; id < sItemSetStore.GetNumRows(); id++) |
---|
| 2358 | { |
---|
| 2359 | ItemSetEntry const *set = sItemSetStore.LookupEntry(id); |
---|
| 2360 | if(set) |
---|
| 2361 | { |
---|
| 2362 | int loc = m_session->GetSessionDbcLocale(); |
---|
| 2363 | std::string name = set->name[m_session->GetSessionDbcLocale()]; |
---|
| 2364 | if(name.empty()) |
---|
| 2365 | continue; |
---|
| 2366 | |
---|
| 2367 | if (!Utf8FitTo(name, wnamepart)) |
---|
| 2368 | { |
---|
| 2369 | loc = 0; |
---|
| 2370 | for(; loc < MAX_LOCALE; ++loc) |
---|
| 2371 | { |
---|
| 2372 | if(loc==m_session->GetSessionDbcLocale()) |
---|
| 2373 | continue; |
---|
| 2374 | |
---|
| 2375 | name = set->name[m_session->GetSessionDbcLocale()]; |
---|
| 2376 | if(name.empty()) |
---|
| 2377 | continue; |
---|
| 2378 | |
---|
| 2379 | if (Utf8FitTo(name, wnamepart)) |
---|
| 2380 | break; |
---|
| 2381 | } |
---|
| 2382 | } |
---|
| 2383 | |
---|
| 2384 | if(loc < MAX_LOCALE) |
---|
| 2385 | { |
---|
| 2386 | // send item set in "id - [namedlink locale]" format |
---|
| 2387 | PSendSysMessage(LANG_ITEMSET_LIST,id,id,name.c_str(),localeNames[loc]); |
---|
| 2388 | ++counter; |
---|
| 2389 | } |
---|
| 2390 | } |
---|
| 2391 | } |
---|
| 2392 | if (counter == 0) // if counter == 0 then we found nth |
---|
| 2393 | SendSysMessage(LANG_COMMAND_NOITEMSETFOUND); |
---|
| 2394 | return true; |
---|
| 2395 | } |
---|
| 2396 | |
---|
| 2397 | bool ChatHandler::HandleLookupSkillCommand(const char* args) |
---|
| 2398 | { |
---|
| 2399 | Player* target = getSelectedPlayer(); |
---|
| 2400 | if(!target) |
---|
| 2401 | { |
---|
| 2402 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 2403 | SetSentErrorMessage(true); |
---|
| 2404 | return false; |
---|
| 2405 | } |
---|
| 2406 | |
---|
| 2407 | if(!*args) |
---|
| 2408 | return false; |
---|
| 2409 | |
---|
| 2410 | std::string namepart = args; |
---|
| 2411 | std::wstring wnamepart; |
---|
| 2412 | |
---|
| 2413 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
| 2414 | return false; |
---|
| 2415 | |
---|
| 2416 | // converting string that we try to find to lower case |
---|
| 2417 | wstrToLower( wnamepart ); |
---|
| 2418 | |
---|
| 2419 | uint32 counter = 0; // Counter for figure out that we found smth. |
---|
| 2420 | |
---|
| 2421 | // Search in SkillLine.dbc |
---|
| 2422 | for (uint32 id = 0; id < sSkillLineStore.GetNumRows(); id++) |
---|
| 2423 | { |
---|
| 2424 | SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(id); |
---|
| 2425 | if(skillInfo) |
---|
| 2426 | { |
---|
| 2427 | int loc = m_session->GetSessionDbcLocale(); |
---|
| 2428 | std::string name = skillInfo->name[loc]; |
---|
| 2429 | if(name.empty()) |
---|
| 2430 | continue; |
---|
| 2431 | |
---|
| 2432 | if (!Utf8FitTo(name, wnamepart)) |
---|
| 2433 | { |
---|
| 2434 | loc = 0; |
---|
| 2435 | for(; loc < MAX_LOCALE; ++loc) |
---|
| 2436 | { |
---|
| 2437 | if(loc==m_session->GetSessionDbcLocale()) |
---|
| 2438 | continue; |
---|
| 2439 | |
---|
| 2440 | name = skillInfo->name[loc]; |
---|
| 2441 | if(name.empty()) |
---|
| 2442 | continue; |
---|
| 2443 | |
---|
| 2444 | if (Utf8FitTo(name, wnamepart)) |
---|
| 2445 | break; |
---|
| 2446 | } |
---|
| 2447 | } |
---|
| 2448 | |
---|
| 2449 | if(loc < MAX_LOCALE) |
---|
| 2450 | { |
---|
| 2451 | // send skill in "id - [namedlink locale]" format |
---|
[44] | 2452 | PSendSysMessage(LANG_SKILL_LIST,id,id,name.c_str(),localeNames[loc],(target->HasSkill(id) ? m_session->GetTrinityString(LANG_KNOWN) : "")); |
---|
[37] | 2453 | |
---|
| 2454 | ++counter; |
---|
| 2455 | } |
---|
| 2456 | } |
---|
| 2457 | } |
---|
| 2458 | if (counter == 0) // if counter == 0 then we found nth |
---|
| 2459 | SendSysMessage(LANG_COMMAND_NOSKILLFOUND); |
---|
| 2460 | return true; |
---|
| 2461 | } |
---|
| 2462 | |
---|
| 2463 | bool ChatHandler::HandleLookupSpellCommand(const char* args) |
---|
| 2464 | { |
---|
| 2465 | Player* target = getSelectedPlayer(); |
---|
| 2466 | if( !target ) |
---|
| 2467 | { |
---|
| 2468 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 2469 | SetSentErrorMessage(true); |
---|
| 2470 | return false; |
---|
| 2471 | } |
---|
| 2472 | |
---|
| 2473 | if(!*args) |
---|
| 2474 | return false; |
---|
| 2475 | |
---|
| 2476 | std::string namepart = args; |
---|
| 2477 | std::wstring wnamepart; |
---|
| 2478 | |
---|
| 2479 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
| 2480 | return false; |
---|
| 2481 | |
---|
| 2482 | // converting string that we try to find to lower case |
---|
| 2483 | wstrToLower( wnamepart ); |
---|
| 2484 | |
---|
| 2485 | uint32 counter = 0; // Counter for figure out that we found smth. |
---|
| 2486 | |
---|
| 2487 | // Search in Spell.dbc |
---|
| 2488 | for (uint32 id = 0; id < sSpellStore.GetNumRows(); id++) |
---|
| 2489 | { |
---|
| 2490 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(id); |
---|
| 2491 | if(spellInfo) |
---|
| 2492 | { |
---|
| 2493 | int loc = m_session->GetSessionDbcLocale(); |
---|
| 2494 | std::string name = spellInfo->SpellName[loc]; |
---|
| 2495 | if(name.empty()) |
---|
| 2496 | continue; |
---|
| 2497 | |
---|
| 2498 | if (!Utf8FitTo(name, wnamepart)) |
---|
| 2499 | { |
---|
| 2500 | loc = 0; |
---|
| 2501 | for(; loc < MAX_LOCALE; ++loc) |
---|
| 2502 | { |
---|
| 2503 | if(loc==m_session->GetSessionDbcLocale()) |
---|
| 2504 | continue; |
---|
| 2505 | |
---|
| 2506 | name = spellInfo->SpellName[loc]; |
---|
| 2507 | if(name.empty()) |
---|
| 2508 | continue; |
---|
| 2509 | |
---|
| 2510 | if (Utf8FitTo(name, wnamepart)) |
---|
| 2511 | break; |
---|
| 2512 | } |
---|
| 2513 | } |
---|
| 2514 | |
---|
| 2515 | if(loc < MAX_LOCALE) |
---|
| 2516 | { |
---|
| 2517 | bool known = target->HasSpell(id); |
---|
| 2518 | bool learn = (spellInfo->Effect[0] == SPELL_EFFECT_LEARN_SPELL); |
---|
| 2519 | |
---|
| 2520 | uint32 telentCost = GetTalentSpellCost(id); |
---|
| 2521 | |
---|
| 2522 | bool talent = (telentCost > 0); |
---|
| 2523 | bool passive = IsPassiveSpell(id); |
---|
| 2524 | bool active = target->HasAura(id,0) || target->HasAura(id,1) || target->HasAura(id,2); |
---|
| 2525 | |
---|
| 2526 | // unit32 used to prevent interpreting uint8 as char at output |
---|
| 2527 | // find rank of learned spell for learning spell, or talent rank |
---|
| 2528 | uint32 rank = telentCost ? telentCost : spellmgr.GetSpellRank(learn ? spellInfo->EffectTriggerSpell[0] : id); |
---|
| 2529 | |
---|
| 2530 | // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format |
---|
| 2531 | std::ostringstream ss; |
---|
| 2532 | ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name; |
---|
| 2533 | |
---|
| 2534 | // include rank in link name |
---|
| 2535 | if(rank) |
---|
[44] | 2536 | ss << GetTrinityString(LANG_SPELL_RANK) << rank; |
---|
[37] | 2537 | |
---|
| 2538 | ss << " " << localeNames[loc] << "]|h|r"; |
---|
| 2539 | |
---|
| 2540 | if(talent) |
---|
[44] | 2541 | ss << GetTrinityString(LANG_TALENT); |
---|
[37] | 2542 | if(passive) |
---|
[44] | 2543 | ss << GetTrinityString(LANG_PASSIVE); |
---|
[37] | 2544 | if(learn) |
---|
[44] | 2545 | ss << GetTrinityString(LANG_LEARN); |
---|
[37] | 2546 | if(known) |
---|
[44] | 2547 | ss << GetTrinityString(LANG_KNOWN); |
---|
[37] | 2548 | if(active) |
---|
[44] | 2549 | ss << GetTrinityString(LANG_ACTIVE); |
---|
[37] | 2550 | |
---|
| 2551 | SendSysMessage(ss.str().c_str()); |
---|
| 2552 | |
---|
| 2553 | ++counter; |
---|
| 2554 | } |
---|
| 2555 | } |
---|
| 2556 | } |
---|
| 2557 | if (counter == 0) // if counter == 0 then we found nth |
---|
| 2558 | SendSysMessage(LANG_COMMAND_NOSPELLFOUND); |
---|
| 2559 | return true; |
---|
| 2560 | } |
---|
| 2561 | |
---|
| 2562 | bool ChatHandler::HandleLookupQuestCommand(const char* args) |
---|
| 2563 | { |
---|
| 2564 | Player* target = getSelectedPlayer(); |
---|
| 2565 | if( !target ) |
---|
| 2566 | { |
---|
| 2567 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 2568 | SetSentErrorMessage(true); |
---|
| 2569 | return false; |
---|
| 2570 | } |
---|
| 2571 | |
---|
| 2572 | if(!*args) |
---|
| 2573 | return false; |
---|
| 2574 | |
---|
| 2575 | std::string namepart = args; |
---|
| 2576 | std::wstring wnamepart; |
---|
| 2577 | |
---|
| 2578 | // converting string that we try to find to lower case |
---|
| 2579 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
| 2580 | return false; |
---|
| 2581 | |
---|
| 2582 | wstrToLower(wnamepart); |
---|
| 2583 | |
---|
| 2584 | uint32 counter = 0 ; |
---|
| 2585 | |
---|
| 2586 | ObjectMgr::QuestMap const& qTemplates = objmgr.GetQuestTemplates(); |
---|
| 2587 | for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter) |
---|
| 2588 | { |
---|
| 2589 | Quest * qinfo = iter->second; |
---|
| 2590 | |
---|
| 2591 | int loc_idx = m_session->GetSessionDbLocaleIndex(); |
---|
| 2592 | if ( loc_idx >= 0 ) |
---|
| 2593 | { |
---|
| 2594 | QuestLocale const *il = objmgr.GetQuestLocale(qinfo->GetQuestId()); |
---|
| 2595 | if (il) |
---|
| 2596 | { |
---|
| 2597 | if (il->Title.size() > loc_idx && !il->Title[loc_idx].empty()) |
---|
| 2598 | { |
---|
| 2599 | std::string title = il->Title[loc_idx]; |
---|
| 2600 | |
---|
| 2601 | if (Utf8FitTo(title, wnamepart)) |
---|
| 2602 | { |
---|
| 2603 | QuestStatus status = target->GetQuestStatus(qinfo->GetQuestId()); |
---|
| 2604 | |
---|
| 2605 | char const* statusStr = ""; |
---|
| 2606 | if(status == QUEST_STATUS_COMPLETE) |
---|
| 2607 | { |
---|
| 2608 | if(target->GetQuestRewardStatus(qinfo->GetQuestId())) |
---|
[44] | 2609 | statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED); |
---|
[37] | 2610 | else |
---|
[44] | 2611 | statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE); |
---|
[37] | 2612 | } |
---|
| 2613 | else if(status == QUEST_STATUS_INCOMPLETE) |
---|
[44] | 2614 | statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE); |
---|
[37] | 2615 | |
---|
[44] | 2616 | PSendSysMessage(LANG_QUEST_LIST,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),(status == QUEST_STATUS_COMPLETE ? GetTrinityString(LANG_COMPLETE) : (status == QUEST_STATUS_INCOMPLETE ? GetTrinityString(LANG_ACTIVE) : "") )); |
---|
[37] | 2617 | ++counter; |
---|
| 2618 | continue; |
---|
| 2619 | } |
---|
| 2620 | } |
---|
| 2621 | } |
---|
| 2622 | } |
---|
| 2623 | |
---|
| 2624 | std::string title = qinfo->GetTitle(); |
---|
| 2625 | if(title.empty()) |
---|
| 2626 | continue; |
---|
| 2627 | |
---|
| 2628 | if (Utf8FitTo(title, wnamepart)) |
---|
| 2629 | { |
---|
| 2630 | QuestStatus status = target->GetQuestStatus(qinfo->GetQuestId()); |
---|
| 2631 | |
---|
| 2632 | char const* statusStr = ""; |
---|
| 2633 | if(status == QUEST_STATUS_COMPLETE) |
---|
| 2634 | { |
---|
| 2635 | if(target->GetQuestRewardStatus(qinfo->GetQuestId())) |
---|
[44] | 2636 | statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED); |
---|
[37] | 2637 | else |
---|
[44] | 2638 | statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE); |
---|
[37] | 2639 | } |
---|
| 2640 | else if(status == QUEST_STATUS_INCOMPLETE) |
---|
[44] | 2641 | statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE); |
---|
[37] | 2642 | |
---|
[44] | 2643 | PSendSysMessage(LANG_QUEST_LIST,qinfo->GetQuestId(),qinfo->GetQuestId(), title.c_str(),(status == QUEST_STATUS_COMPLETE ? GetTrinityString(LANG_COMPLETE) : (status == QUEST_STATUS_INCOMPLETE ? GetTrinityString(LANG_ACTIVE) : "") )); |
---|
[37] | 2644 | ++counter; |
---|
| 2645 | } |
---|
| 2646 | } |
---|
| 2647 | |
---|
| 2648 | if (counter==0) |
---|
| 2649 | SendSysMessage(LANG_COMMAND_NOQUESTFOUND); |
---|
| 2650 | |
---|
| 2651 | return true; |
---|
| 2652 | } |
---|
| 2653 | |
---|
| 2654 | bool ChatHandler::HandleLookupCreatureCommand(const char* args) |
---|
| 2655 | { |
---|
| 2656 | if(!*args) |
---|
| 2657 | return false; |
---|
| 2658 | |
---|
| 2659 | std::string namepart = args; |
---|
| 2660 | std::wstring wnamepart; |
---|
| 2661 | |
---|
| 2662 | // converting string that we try to find to lower case |
---|
| 2663 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
| 2664 | return false; |
---|
| 2665 | |
---|
| 2666 | wstrToLower(wnamepart); |
---|
| 2667 | |
---|
| 2668 | uint32 counter = 0; |
---|
| 2669 | |
---|
| 2670 | for (uint32 id = 0; id< sCreatureStorage.MaxEntry; id++ ) |
---|
| 2671 | { |
---|
| 2672 | CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(id); |
---|
| 2673 | if(!cInfo) |
---|
| 2674 | continue; |
---|
| 2675 | |
---|
| 2676 | int loc_idx = m_session->GetSessionDbLocaleIndex(); |
---|
| 2677 | if ( loc_idx >= 0 ) |
---|
| 2678 | { |
---|
| 2679 | CreatureLocale const *cl = objmgr.GetCreatureLocale(id); |
---|
| 2680 | if (cl) |
---|
| 2681 | { |
---|
| 2682 | if (cl->Name.size() > loc_idx && !cl->Name[loc_idx].empty()) |
---|
| 2683 | { |
---|
| 2684 | std::string name = cl->Name[loc_idx]; |
---|
| 2685 | |
---|
| 2686 | if (Utf8FitTo(name, wnamepart)) |
---|
| 2687 | { |
---|
| 2688 | PSendSysMessage(LANG_CREATURE_ENTRY_LIST, id, id, name.c_str()); |
---|
| 2689 | ++counter; |
---|
| 2690 | continue; |
---|
| 2691 | } |
---|
| 2692 | } |
---|
| 2693 | } |
---|
| 2694 | } |
---|
| 2695 | |
---|
| 2696 | std::string name = cInfo->Name; |
---|
| 2697 | if(name.empty()) |
---|
| 2698 | continue; |
---|
| 2699 | |
---|
| 2700 | if (Utf8FitTo(name, wnamepart)) |
---|
| 2701 | { |
---|
| 2702 | PSendSysMessage(LANG_CREATURE_ENTRY_LIST,id,id,name.c_str()); |
---|
| 2703 | ++counter; |
---|
| 2704 | } |
---|
| 2705 | } |
---|
| 2706 | |
---|
| 2707 | if (counter==0) |
---|
| 2708 | SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); |
---|
| 2709 | |
---|
| 2710 | return true; |
---|
| 2711 | } |
---|
| 2712 | |
---|
| 2713 | bool ChatHandler::HandleLookupObjectCommand(const char* args) |
---|
| 2714 | { |
---|
| 2715 | if(!*args) |
---|
| 2716 | return false; |
---|
| 2717 | |
---|
| 2718 | std::string namepart = args; |
---|
| 2719 | std::wstring wnamepart; |
---|
| 2720 | |
---|
| 2721 | // converting string that we try to find to lower case |
---|
| 2722 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
| 2723 | return false; |
---|
| 2724 | |
---|
| 2725 | wstrToLower(wnamepart); |
---|
| 2726 | |
---|
| 2727 | uint32 counter = 0; |
---|
| 2728 | |
---|
| 2729 | for (uint32 id = 0; id< sGOStorage.MaxEntry; id++ ) |
---|
| 2730 | { |
---|
| 2731 | GameObjectInfo const* gInfo = sGOStorage.LookupEntry<GameObjectInfo>(id); |
---|
| 2732 | if(!gInfo) |
---|
| 2733 | continue; |
---|
| 2734 | |
---|
| 2735 | int loc_idx = m_session->GetSessionDbLocaleIndex(); |
---|
| 2736 | if ( loc_idx >= 0 ) |
---|
| 2737 | { |
---|
| 2738 | GameObjectLocale const *gl = objmgr.GetGameObjectLocale(id); |
---|
| 2739 | if (gl) |
---|
| 2740 | { |
---|
| 2741 | if (gl->Name.size() > loc_idx && !gl->Name[loc_idx].empty()) |
---|
| 2742 | { |
---|
| 2743 | std::string name = gl->Name[loc_idx]; |
---|
| 2744 | |
---|
| 2745 | if (Utf8FitTo(name, wnamepart)) |
---|
| 2746 | { |
---|
| 2747 | PSendSysMessage(LANG_GO_ENTRY_LIST, id, id, name.c_str()); |
---|
| 2748 | ++counter; |
---|
| 2749 | continue; |
---|
| 2750 | } |
---|
| 2751 | } |
---|
| 2752 | } |
---|
| 2753 | } |
---|
| 2754 | |
---|
| 2755 | std::string name = gInfo->name; |
---|
| 2756 | if(name.empty()) |
---|
| 2757 | continue; |
---|
| 2758 | |
---|
| 2759 | if(Utf8FitTo(name, wnamepart)) |
---|
| 2760 | { |
---|
| 2761 | PSendSysMessage(LANG_GO_ENTRY_LIST, id, id, name.c_str()); |
---|
| 2762 | ++counter; |
---|
| 2763 | } |
---|
| 2764 | } |
---|
| 2765 | |
---|
| 2766 | if(counter==0) |
---|
| 2767 | SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); |
---|
| 2768 | |
---|
| 2769 | return true; |
---|
| 2770 | } |
---|
| 2771 | |
---|
| 2772 | /** \brief GM command level 3 - Create a guild. |
---|
| 2773 | * |
---|
| 2774 | * This command allows a GM (level 3) to create a guild. |
---|
| 2775 | * |
---|
| 2776 | * The "args" parameter contains the name of the guild leader |
---|
| 2777 | * and then the name of the guild. |
---|
| 2778 | * |
---|
| 2779 | */ |
---|
| 2780 | bool ChatHandler::HandleGuildCreateCommand(const char* args) |
---|
| 2781 | { |
---|
| 2782 | |
---|
| 2783 | if (!*args) |
---|
| 2784 | return false; |
---|
| 2785 | |
---|
| 2786 | Guild *guild; |
---|
| 2787 | Player * player; |
---|
| 2788 | char *lname,*gname; |
---|
| 2789 | std::string guildname; |
---|
| 2790 | |
---|
| 2791 | lname = strtok((char*)args, " "); |
---|
| 2792 | gname = strtok(NULL, ""); |
---|
| 2793 | |
---|
| 2794 | if(!lname) |
---|
| 2795 | return false; |
---|
| 2796 | else if(!gname) |
---|
| 2797 | { |
---|
| 2798 | SendSysMessage(LANG_INSERT_GUILD_NAME); |
---|
| 2799 | SetSentErrorMessage(true); |
---|
| 2800 | return false; |
---|
| 2801 | } |
---|
| 2802 | |
---|
| 2803 | guildname = gname; |
---|
| 2804 | player = ObjectAccessor::Instance().FindPlayerByName(lname); |
---|
| 2805 | |
---|
| 2806 | if(!player) |
---|
| 2807 | { |
---|
| 2808 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 2809 | SetSentErrorMessage(true); |
---|
| 2810 | return false; |
---|
| 2811 | } |
---|
| 2812 | |
---|
| 2813 | if(!player->GetGuildId()) |
---|
| 2814 | { |
---|
| 2815 | guild = new Guild; |
---|
| 2816 | if(!guild->create(player->GetGUID(),guildname)) |
---|
| 2817 | { |
---|
| 2818 | delete guild; |
---|
| 2819 | SendSysMessage(LANG_GUILD_NOT_CREATED); |
---|
| 2820 | SetSentErrorMessage(true); |
---|
| 2821 | return false; |
---|
| 2822 | } |
---|
| 2823 | |
---|
| 2824 | objmgr.AddGuild(guild); |
---|
| 2825 | } |
---|
| 2826 | else |
---|
| 2827 | SendSysMessage(LANG_PLAYER_IN_GUILD); |
---|
| 2828 | |
---|
| 2829 | return true; |
---|
| 2830 | } |
---|
| 2831 | |
---|
| 2832 | bool ChatHandler::HandleGuildInviteCommand(const char *args) |
---|
| 2833 | { |
---|
| 2834 | if(!*args) |
---|
| 2835 | return false; |
---|
| 2836 | |
---|
| 2837 | char* par1 = strtok((char*)args, " "); |
---|
| 2838 | char* par2 = strtok (NULL, ""); |
---|
| 2839 | if(!par1 || !par2) |
---|
| 2840 | return false; |
---|
| 2841 | |
---|
| 2842 | std::string glName = par2; |
---|
| 2843 | Guild* targetGuild = objmgr.GetGuildByName(glName); |
---|
| 2844 | if(!targetGuild) |
---|
| 2845 | return false; |
---|
| 2846 | |
---|
| 2847 | std::string plName = par1; |
---|
| 2848 | if(!normalizePlayerName(plName)) |
---|
| 2849 | { |
---|
| 2850 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 2851 | SetSentErrorMessage(true); |
---|
| 2852 | return false; |
---|
| 2853 | } |
---|
| 2854 | |
---|
| 2855 | uint64 plGuid = 0; |
---|
| 2856 | if(Player* targetPlayer = ObjectAccessor::Instance().FindPlayerByName(plName.c_str())) |
---|
| 2857 | plGuid = targetPlayer->GetGUID(); |
---|
| 2858 | else |
---|
| 2859 | plGuid = objmgr.GetPlayerGUIDByName(plName.c_str()); |
---|
| 2860 | |
---|
| 2861 | if(!plGuid) |
---|
| 2862 | false; |
---|
| 2863 | |
---|
| 2864 | // players's guild membership checked in AddMember before add |
---|
| 2865 | if(!targetGuild->AddMember(plGuid,targetGuild->GetLowestRank())) |
---|
| 2866 | return false; |
---|
| 2867 | |
---|
| 2868 | return true; |
---|
| 2869 | } |
---|
| 2870 | |
---|
| 2871 | bool ChatHandler::HandleGuildUninviteCommand(const char *args) |
---|
| 2872 | { |
---|
| 2873 | if(!*args) |
---|
| 2874 | return false; |
---|
| 2875 | |
---|
| 2876 | char* par1 = strtok((char*)args, " "); |
---|
| 2877 | if(!par1) |
---|
| 2878 | return false; |
---|
| 2879 | std::string plName = par1; |
---|
| 2880 | if(!normalizePlayerName(plName)) |
---|
| 2881 | { |
---|
| 2882 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 2883 | SetSentErrorMessage(true); |
---|
| 2884 | return false; |
---|
| 2885 | } |
---|
| 2886 | |
---|
| 2887 | uint64 plGuid = 0; |
---|
| 2888 | uint32 glId = 0; |
---|
| 2889 | if(Player* targetPlayer = ObjectAccessor::Instance().FindPlayerByName(plName.c_str())) |
---|
| 2890 | { |
---|
| 2891 | plGuid = targetPlayer->GetGUID(); |
---|
| 2892 | glId = targetPlayer->GetGuildId(); |
---|
| 2893 | } |
---|
| 2894 | else |
---|
| 2895 | { |
---|
| 2896 | plGuid = objmgr.GetPlayerGUIDByName(plName.c_str()); |
---|
| 2897 | glId = Player::GetGuildIdFromDB(plGuid); |
---|
| 2898 | } |
---|
| 2899 | |
---|
| 2900 | if(!plGuid || !glId) |
---|
| 2901 | return false; |
---|
| 2902 | |
---|
| 2903 | Guild* targetGuild = objmgr.GetGuildById(glId); |
---|
| 2904 | if(!targetGuild) |
---|
| 2905 | return false; |
---|
| 2906 | |
---|
| 2907 | targetGuild->DelMember(plGuid); |
---|
| 2908 | |
---|
| 2909 | return true; |
---|
| 2910 | } |
---|
| 2911 | |
---|
| 2912 | bool ChatHandler::HandleGuildRankCommand(const char *args) |
---|
| 2913 | { |
---|
| 2914 | if(!*args) |
---|
| 2915 | return false; |
---|
| 2916 | |
---|
| 2917 | char* par1 = strtok((char*)args, " "); |
---|
| 2918 | char* par2 = strtok(NULL, " "); |
---|
| 2919 | if(!par1 || !par2) |
---|
| 2920 | return false; |
---|
| 2921 | std::string plName = par1; |
---|
| 2922 | if(!normalizePlayerName(plName)) |
---|
| 2923 | { |
---|
| 2924 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 2925 | SetSentErrorMessage(true); |
---|
| 2926 | return false; |
---|
| 2927 | } |
---|
| 2928 | |
---|
| 2929 | uint64 plGuid = 0; |
---|
| 2930 | uint32 glId = 0; |
---|
| 2931 | if(Player* targetPlayer = ObjectAccessor::Instance().FindPlayerByName(plName.c_str())) |
---|
| 2932 | { |
---|
| 2933 | plGuid = targetPlayer->GetGUID(); |
---|
| 2934 | glId = targetPlayer->GetGuildId(); |
---|
| 2935 | } |
---|
| 2936 | else |
---|
| 2937 | { |
---|
| 2938 | plGuid = objmgr.GetPlayerGUIDByName(plName.c_str()); |
---|
| 2939 | glId = Player::GetGuildIdFromDB(plGuid); |
---|
| 2940 | } |
---|
| 2941 | |
---|
| 2942 | if(!plGuid || !glId) |
---|
| 2943 | return false; |
---|
| 2944 | |
---|
| 2945 | Guild* targetGuild = objmgr.GetGuildById(glId); |
---|
| 2946 | if(!targetGuild) |
---|
| 2947 | return false; |
---|
| 2948 | |
---|
| 2949 | uint32 newrank = uint32(atoi(par2)); |
---|
| 2950 | if(newrank > targetGuild->GetLowestRank()) |
---|
| 2951 | return false; |
---|
| 2952 | |
---|
| 2953 | targetGuild->ChangeRank(plGuid,newrank); |
---|
| 2954 | |
---|
| 2955 | return true; |
---|
| 2956 | } |
---|
| 2957 | |
---|
| 2958 | bool ChatHandler::HandleGuildDeleteCommand(const char* args) |
---|
| 2959 | { |
---|
| 2960 | if(!*args) |
---|
| 2961 | return false; |
---|
| 2962 | |
---|
| 2963 | char* par1 = strtok((char*)args, " "); |
---|
| 2964 | if(!par1) |
---|
| 2965 | return false; |
---|
| 2966 | |
---|
| 2967 | std::string gld = par1; |
---|
| 2968 | |
---|
| 2969 | Guild* targetGuild = objmgr.GetGuildByName(gld); |
---|
| 2970 | if(!targetGuild) |
---|
| 2971 | return false; |
---|
| 2972 | |
---|
| 2973 | targetGuild->Disband(); |
---|
| 2974 | |
---|
| 2975 | return true; |
---|
| 2976 | } |
---|
| 2977 | |
---|
| 2978 | bool ChatHandler::HandleGetDistanceCommand(const char* /*args*/) |
---|
| 2979 | { |
---|
| 2980 | Unit* pUnit = getSelectedUnit(); |
---|
| 2981 | |
---|
| 2982 | if(!pUnit) |
---|
| 2983 | { |
---|
| 2984 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 2985 | SetSentErrorMessage(true); |
---|
| 2986 | return false; |
---|
| 2987 | } |
---|
| 2988 | |
---|
| 2989 | PSendSysMessage(LANG_DISTANCE, m_session->GetPlayer()->GetDistance(pUnit),m_session->GetPlayer()->GetDistance2d(pUnit)); |
---|
| 2990 | |
---|
| 2991 | return true; |
---|
| 2992 | } |
---|
| 2993 | |
---|
| 2994 | // FIX-ME!!! |
---|
| 2995 | |
---|
| 2996 | bool ChatHandler::HandleAddWeaponCommand(const char* /*args*/) |
---|
| 2997 | { |
---|
| 2998 | /*if (!*args) |
---|
| 2999 | return false; |
---|
| 3000 | |
---|
| 3001 | uint64 guid = m_session->GetPlayer()->GetSelection(); |
---|
| 3002 | if (guid == 0) |
---|
| 3003 | { |
---|
| 3004 | SendSysMessage(LANG_NO_SELECTION); |
---|
| 3005 | return true; |
---|
| 3006 | } |
---|
| 3007 | |
---|
| 3008 | Creature *pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); |
---|
| 3009 | |
---|
| 3010 | if(!pCreature) |
---|
| 3011 | { |
---|
| 3012 | SendSysMessage(LANG_SELECT_CREATURE); |
---|
| 3013 | return true; |
---|
| 3014 | } |
---|
| 3015 | |
---|
| 3016 | char* pSlotID = strtok((char*)args, " "); |
---|
| 3017 | if (!pSlotID) |
---|
| 3018 | return false; |
---|
| 3019 | |
---|
| 3020 | char* pItemID = strtok(NULL, " "); |
---|
| 3021 | if (!pItemID) |
---|
| 3022 | return false; |
---|
| 3023 | |
---|
| 3024 | uint32 ItemID = atoi(pItemID); |
---|
| 3025 | uint32 SlotID = atoi(pSlotID); |
---|
| 3026 | |
---|
| 3027 | ItemPrototype* tmpItem = objmgr.GetItemPrototype(ItemID); |
---|
| 3028 | |
---|
| 3029 | bool added = false; |
---|
| 3030 | if(tmpItem) |
---|
| 3031 | { |
---|
| 3032 | switch(SlotID) |
---|
| 3033 | { |
---|
| 3034 | case 1: |
---|
| 3035 | pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, ItemID); |
---|
| 3036 | added = true; |
---|
| 3037 | break; |
---|
| 3038 | case 2: |
---|
| 3039 | pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, ItemID); |
---|
| 3040 | added = true; |
---|
| 3041 | break; |
---|
| 3042 | case 3: |
---|
| 3043 | pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_02, ItemID); |
---|
| 3044 | added = true; |
---|
| 3045 | break; |
---|
| 3046 | default: |
---|
| 3047 | PSendSysMessage(LANG_ITEM_SLOT_NOT_EXIST,SlotID); |
---|
| 3048 | added = false; |
---|
| 3049 | break; |
---|
| 3050 | } |
---|
| 3051 | if(added) |
---|
| 3052 | { |
---|
| 3053 | PSendSysMessage(LANG_ITEM_ADDED_TO_SLOT,ItemID,tmpItem->Name1,SlotID); |
---|
| 3054 | } |
---|
| 3055 | } |
---|
| 3056 | else |
---|
| 3057 | { |
---|
| 3058 | PSendSysMessage(LANG_ITEM_NOT_FOUND,ItemID); |
---|
| 3059 | return true; |
---|
| 3060 | } |
---|
| 3061 | */ |
---|
| 3062 | return true; |
---|
| 3063 | } |
---|
| 3064 | |
---|
| 3065 | bool ChatHandler::HandleDieCommand(const char* /*args*/) |
---|
| 3066 | { |
---|
| 3067 | Unit* target = getSelectedUnit(); |
---|
| 3068 | |
---|
| 3069 | if(!target || !m_session->GetPlayer()->GetSelection()) |
---|
| 3070 | { |
---|
| 3071 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 3072 | SetSentErrorMessage(true); |
---|
| 3073 | return false; |
---|
| 3074 | } |
---|
| 3075 | |
---|
| 3076 | if( target->isAlive() ) |
---|
| 3077 | { |
---|
| 3078 | m_session->GetPlayer()->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); |
---|
| 3079 | } |
---|
| 3080 | |
---|
| 3081 | return true; |
---|
| 3082 | } |
---|
| 3083 | |
---|
| 3084 | bool ChatHandler::HandleDamageCommand(const char * args) |
---|
| 3085 | { |
---|
| 3086 | if (!*args) |
---|
| 3087 | return false; |
---|
| 3088 | |
---|
| 3089 | Unit* target = getSelectedUnit(); |
---|
| 3090 | |
---|
| 3091 | if(!target || !m_session->GetPlayer()->GetSelection()) |
---|
| 3092 | { |
---|
| 3093 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 3094 | SetSentErrorMessage(true); |
---|
| 3095 | return false; |
---|
| 3096 | } |
---|
| 3097 | |
---|
| 3098 | if( !target->isAlive() ) |
---|
| 3099 | return true; |
---|
| 3100 | |
---|
| 3101 | char* damageStr = strtok((char*)args, " "); |
---|
| 3102 | if(!damageStr) |
---|
| 3103 | return false; |
---|
| 3104 | |
---|
| 3105 | int32 damage = atoi((char*)damageStr); |
---|
| 3106 | if(damage <=0) |
---|
| 3107 | return true; |
---|
| 3108 | |
---|
| 3109 | char* schoolStr = strtok((char*)NULL, " "); |
---|
| 3110 | |
---|
| 3111 | // flat melee damage without resistence/etc reduction |
---|
| 3112 | if(!schoolStr) |
---|
| 3113 | { |
---|
| 3114 | m_session->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); |
---|
| 3115 | m_session->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_NORMAL, 0); |
---|
| 3116 | return true; |
---|
| 3117 | } |
---|
| 3118 | |
---|
| 3119 | uint32 school = schoolStr ? atoi((char*)schoolStr) : SPELL_SCHOOL_NORMAL; |
---|
| 3120 | if(school >= MAX_SPELL_SCHOOL) |
---|
| 3121 | return false; |
---|
| 3122 | |
---|
| 3123 | SpellSchoolMask schoolmask = SpellSchoolMask(1 << school); |
---|
| 3124 | |
---|
| 3125 | if ( schoolmask & SPELL_SCHOOL_MASK_NORMAL ) |
---|
| 3126 | damage = m_session->GetPlayer()->CalcArmorReducedDamage(target, damage); |
---|
| 3127 | |
---|
| 3128 | char* spellStr = strtok((char*)NULL, " "); |
---|
| 3129 | |
---|
| 3130 | // melee damage by specific school |
---|
| 3131 | if(!spellStr) |
---|
| 3132 | { |
---|
| 3133 | uint32 absorb = 0; |
---|
| 3134 | uint32 resist = 0; |
---|
| 3135 | |
---|
| 3136 | m_session->GetPlayer()->CalcAbsorbResist(target,schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); |
---|
| 3137 | |
---|
| 3138 | if (damage <= absorb + resist) |
---|
| 3139 | return true; |
---|
| 3140 | |
---|
| 3141 | damage -= absorb + resist; |
---|
| 3142 | |
---|
| 3143 | m_session->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false); |
---|
| 3144 | m_session->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2, target, 1, schoolmask, damage, absorb, resist, VICTIMSTATE_NORMAL, 0); |
---|
| 3145 | return true; |
---|
| 3146 | } |
---|
| 3147 | |
---|
| 3148 | // non-melee damage |
---|
| 3149 | |
---|
| 3150 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
| 3151 | uint32 spellid = extractSpellIdFromLink((char*)args); |
---|
| 3152 | if(!spellid || !sSpellStore.LookupEntry(spellid)) |
---|
| 3153 | return false; |
---|
| 3154 | |
---|
| 3155 | m_session->GetPlayer()->SpellNonMeleeDamageLog(target, spellid, damage, false); |
---|
| 3156 | return true; |
---|
| 3157 | } |
---|
| 3158 | |
---|
| 3159 | bool ChatHandler::HandleModifyArenaCommand(const char * args) |
---|
| 3160 | { |
---|
| 3161 | if (!*args) |
---|
| 3162 | return false; |
---|
| 3163 | |
---|
| 3164 | Player *target = getSelectedPlayer(); |
---|
| 3165 | if(!target) |
---|
| 3166 | { |
---|
| 3167 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 3168 | SetSentErrorMessage(true); |
---|
| 3169 | return false; |
---|
| 3170 | } |
---|
| 3171 | |
---|
| 3172 | int32 amount = (uint32)atoi(args); |
---|
| 3173 | |
---|
| 3174 | target->ModifyArenaPoints(amount); |
---|
| 3175 | |
---|
| 3176 | PSendSysMessage(LANG_COMMAND_MODIFY_ARENA, target->GetName(), target->GetArenaPoints()); |
---|
| 3177 | |
---|
| 3178 | return true; |
---|
| 3179 | } |
---|
| 3180 | |
---|
| 3181 | bool ChatHandler::HandleReviveCommand(const char* args) |
---|
| 3182 | { |
---|
| 3183 | Player* SelectedPlayer = NULL; |
---|
| 3184 | |
---|
| 3185 | if (*args) |
---|
| 3186 | { |
---|
| 3187 | std::string name = args; |
---|
| 3188 | if(!normalizePlayerName(name)) |
---|
| 3189 | { |
---|
| 3190 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 3191 | SetSentErrorMessage(true); |
---|
| 3192 | return false; |
---|
| 3193 | } |
---|
| 3194 | |
---|
| 3195 | SelectedPlayer = objmgr.GetPlayer(name.c_str()); |
---|
| 3196 | } |
---|
| 3197 | else |
---|
| 3198 | SelectedPlayer = getSelectedPlayer(); |
---|
| 3199 | |
---|
| 3200 | if(!SelectedPlayer) |
---|
| 3201 | { |
---|
| 3202 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 3203 | SetSentErrorMessage(true); |
---|
| 3204 | return false; |
---|
| 3205 | } |
---|
| 3206 | |
---|
| 3207 | SelectedPlayer->ResurrectPlayer(0.5f); |
---|
| 3208 | SelectedPlayer->SpawnCorpseBones(); |
---|
| 3209 | SelectedPlayer->SaveToDB(); |
---|
| 3210 | return true; |
---|
| 3211 | } |
---|
| 3212 | |
---|
| 3213 | bool ChatHandler::HandleAuraCommand(const char* args) |
---|
| 3214 | { |
---|
| 3215 | char* px = strtok((char*)args, " "); |
---|
| 3216 | if (!px) |
---|
| 3217 | return false; |
---|
| 3218 | |
---|
| 3219 | Unit *target = getSelectedUnit(); |
---|
| 3220 | if(!target) |
---|
| 3221 | { |
---|
| 3222 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 3223 | SetSentErrorMessage(true); |
---|
| 3224 | return false; |
---|
| 3225 | } |
---|
| 3226 | |
---|
| 3227 | uint32 spellID = (uint32)atoi(px); |
---|
| 3228 | SpellEntry const *spellInfo = sSpellStore.LookupEntry( spellID ); |
---|
| 3229 | if(spellInfo) |
---|
| 3230 | { |
---|
| 3231 | for(uint32 i = 0;i<3;i++) |
---|
| 3232 | { |
---|
| 3233 | uint8 eff = spellInfo->Effect[i]; |
---|
| 3234 | if (eff>=TOTAL_SPELL_EFFECTS) |
---|
| 3235 | continue; |
---|
| 3236 | if( IsAreaAuraEffect(eff) || |
---|
| 3237 | eff == SPELL_EFFECT_APPLY_AURA || |
---|
| 3238 | eff == SPELL_EFFECT_PERSISTENT_AREA_AURA ) |
---|
| 3239 | { |
---|
| 3240 | Aura *Aur = CreateAura(spellInfo, i, NULL, target); |
---|
| 3241 | target->AddAura(Aur); |
---|
| 3242 | } |
---|
| 3243 | } |
---|
| 3244 | } |
---|
| 3245 | |
---|
| 3246 | return true; |
---|
| 3247 | } |
---|
| 3248 | |
---|
| 3249 | bool ChatHandler::HandleUnAuraCommand(const char* args) |
---|
| 3250 | { |
---|
| 3251 | char* px = strtok((char*)args, " "); |
---|
| 3252 | if (!px) |
---|
| 3253 | return false; |
---|
| 3254 | |
---|
| 3255 | Unit *target = getSelectedUnit(); |
---|
| 3256 | if(!target) |
---|
| 3257 | { |
---|
| 3258 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 3259 | SetSentErrorMessage(true); |
---|
| 3260 | return false; |
---|
| 3261 | } |
---|
| 3262 | |
---|
| 3263 | std::string argstr = args; |
---|
| 3264 | if (argstr == "all") |
---|
| 3265 | { |
---|
| 3266 | target->RemoveAllAuras(); |
---|
| 3267 | return true; |
---|
| 3268 | } |
---|
| 3269 | |
---|
| 3270 | uint32 spellID = (uint32)atoi(px); |
---|
| 3271 | target->RemoveAurasDueToSpell(spellID); |
---|
| 3272 | |
---|
| 3273 | return true; |
---|
| 3274 | } |
---|
| 3275 | |
---|
| 3276 | bool ChatHandler::HandleLinkGraveCommand(const char* args) |
---|
| 3277 | { |
---|
| 3278 | if(!*args) |
---|
| 3279 | return false; |
---|
| 3280 | |
---|
| 3281 | char* px = strtok((char*)args, " "); |
---|
| 3282 | if (!px) |
---|
| 3283 | return false; |
---|
| 3284 | |
---|
| 3285 | uint32 g_id = (uint32)atoi(px); |
---|
| 3286 | |
---|
| 3287 | uint32 g_team; |
---|
| 3288 | |
---|
| 3289 | char* px2 = strtok(NULL, " "); |
---|
| 3290 | |
---|
| 3291 | if (!px2) |
---|
| 3292 | g_team = 0; |
---|
| 3293 | else if (strncmp(px2,"horde",6)==0) |
---|
| 3294 | g_team = HORDE; |
---|
| 3295 | else if (strncmp(px2,"alliance",9)==0) |
---|
| 3296 | g_team = ALLIANCE; |
---|
| 3297 | else |
---|
| 3298 | return false; |
---|
| 3299 | |
---|
| 3300 | WorldSafeLocsEntry const* graveyard = sWorldSafeLocsStore.LookupEntry(g_id); |
---|
| 3301 | |
---|
| 3302 | if(!graveyard ) |
---|
| 3303 | { |
---|
| 3304 | PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, g_id); |
---|
| 3305 | SetSentErrorMessage(true); |
---|
| 3306 | return false; |
---|
| 3307 | } |
---|
| 3308 | |
---|
| 3309 | Player* player = m_session->GetPlayer(); |
---|
| 3310 | |
---|
| 3311 | uint32 zoneId = player->GetZoneId(); |
---|
| 3312 | |
---|
| 3313 | AreaTableEntry const *areaEntry = GetAreaEntryByAreaID(zoneId); |
---|
| 3314 | if(!areaEntry || areaEntry->zone !=0 ) |
---|
| 3315 | { |
---|
| 3316 | PSendSysMessage(LANG_COMMAND_GRAVEYARDWRONGZONE, g_id,zoneId); |
---|
| 3317 | SetSentErrorMessage(true); |
---|
| 3318 | return false; |
---|
| 3319 | } |
---|
| 3320 | |
---|
| 3321 | if(graveyard->map_id != areaEntry->mapid && g_team != 0) |
---|
| 3322 | { |
---|
| 3323 | SendSysMessage(LANG_COMMAND_GRAVEYARDWRONGTEAM); |
---|
| 3324 | SetSentErrorMessage(true); |
---|
| 3325 | return false; |
---|
| 3326 | } |
---|
| 3327 | |
---|
| 3328 | if(objmgr.AddGraveYardLink(g_id,player->GetZoneId(),g_team)) |
---|
| 3329 | PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, g_id,zoneId); |
---|
| 3330 | else |
---|
| 3331 | PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, g_id,zoneId); |
---|
| 3332 | |
---|
| 3333 | return true; |
---|
| 3334 | } |
---|
| 3335 | |
---|
| 3336 | bool ChatHandler::HandleNearGraveCommand(const char* args) |
---|
| 3337 | { |
---|
| 3338 | uint32 g_team; |
---|
| 3339 | |
---|
| 3340 | size_t argslen = strlen(args); |
---|
| 3341 | |
---|
| 3342 | if(!*args) |
---|
| 3343 | g_team = 0; |
---|
| 3344 | else if (strncmp((char*)args,"horde",argslen)==0) |
---|
| 3345 | g_team = HORDE; |
---|
| 3346 | else if (strncmp((char*)args,"alliance",argslen)==0) |
---|
| 3347 | g_team = ALLIANCE; |
---|
| 3348 | else |
---|
| 3349 | return false; |
---|
| 3350 | |
---|
| 3351 | Player* player = m_session->GetPlayer(); |
---|
| 3352 | |
---|
| 3353 | WorldSafeLocsEntry const* graveyard = objmgr.GetClosestGraveYard( |
---|
| 3354 | player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(),player->GetMapId(),g_team); |
---|
| 3355 | |
---|
| 3356 | if(graveyard) |
---|
| 3357 | { |
---|
| 3358 | uint32 g_id = graveyard->ID; |
---|
| 3359 | |
---|
| 3360 | GraveYardData const* data = objmgr.FindGraveYardData(g_id,player->GetZoneId()); |
---|
| 3361 | if (!data) |
---|
| 3362 | { |
---|
| 3363 | PSendSysMessage(LANG_COMMAND_GRAVEYARDERROR,g_id); |
---|
| 3364 | SetSentErrorMessage(true); |
---|
| 3365 | return false; |
---|
| 3366 | } |
---|
| 3367 | |
---|
| 3368 | g_team = data->team; |
---|
| 3369 | |
---|
[44] | 3370 | std::string team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_NOTEAM); |
---|
[37] | 3371 | |
---|
| 3372 | if(g_team == 0) |
---|
[44] | 3373 | team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY); |
---|
[37] | 3374 | else if(g_team == HORDE) |
---|
[44] | 3375 | team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE); |
---|
[37] | 3376 | else if(g_team == ALLIANCE) |
---|
[44] | 3377 | team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE); |
---|
[37] | 3378 | |
---|
| 3379 | PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST, g_id,team_name.c_str(),player->GetZoneId()); |
---|
| 3380 | } |
---|
| 3381 | else |
---|
| 3382 | { |
---|
| 3383 | std::string team_name; |
---|
| 3384 | |
---|
| 3385 | if(g_team == 0) |
---|
[44] | 3386 | team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY); |
---|
[37] | 3387 | else if(g_team == HORDE) |
---|
[44] | 3388 | team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE); |
---|
[37] | 3389 | else if(g_team == ALLIANCE) |
---|
[44] | 3390 | team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE); |
---|
[37] | 3391 | |
---|
| 3392 | if(g_team == ~uint32(0)) |
---|
| 3393 | PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS, player->GetZoneId()); |
---|
| 3394 | else |
---|
| 3395 | PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, player->GetZoneId(),team_name.c_str()); |
---|
| 3396 | } |
---|
| 3397 | |
---|
| 3398 | return true; |
---|
| 3399 | } |
---|
| 3400 | |
---|
| 3401 | bool ChatHandler::HandleSpawnTransportCommand(const char* /*args*/) |
---|
| 3402 | { |
---|
| 3403 | return true; |
---|
| 3404 | } |
---|
| 3405 | |
---|
| 3406 | //play npc emote |
---|
| 3407 | bool ChatHandler::HandlePlayEmoteCommand(const char* args) |
---|
| 3408 | { |
---|
| 3409 | uint32 emote = atoi((char*)args); |
---|
| 3410 | |
---|
| 3411 | Creature* target = getSelectedCreature(); |
---|
| 3412 | if(!target) |
---|
| 3413 | { |
---|
| 3414 | SendSysMessage(LANG_SELECT_CREATURE); |
---|
| 3415 | SetSentErrorMessage(true); |
---|
| 3416 | return false; |
---|
| 3417 | } |
---|
| 3418 | |
---|
| 3419 | target->SetUInt32Value(UNIT_NPC_EMOTESTATE,emote); |
---|
| 3420 | |
---|
| 3421 | return true; |
---|
| 3422 | } |
---|
| 3423 | |
---|
| 3424 | bool ChatHandler::HandleNpcInfoCommand(const char* /*args*/) |
---|
| 3425 | { |
---|
| 3426 | Creature* target = getSelectedCreature(); |
---|
| 3427 | |
---|
| 3428 | if(!target) |
---|
| 3429 | { |
---|
| 3430 | SendSysMessage(LANG_SELECT_CREATURE); |
---|
| 3431 | SetSentErrorMessage(true); |
---|
| 3432 | return false; |
---|
| 3433 | } |
---|
| 3434 | |
---|
| 3435 | uint32 faction = target->getFaction(); |
---|
| 3436 | uint32 npcflags = target->GetUInt32Value(UNIT_NPC_FLAGS); |
---|
| 3437 | uint32 displayid = target->GetDisplayId(); |
---|
| 3438 | uint32 nativeid = target->GetNativeDisplayId(); |
---|
| 3439 | uint32 Entry = target->GetEntry(); |
---|
| 3440 | CreatureInfo const* cInfo = target->GetCreatureInfo(); |
---|
| 3441 | |
---|
| 3442 | int32 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL); |
---|
| 3443 | if(curRespawnDelay < 0) |
---|
| 3444 | curRespawnDelay = 0; |
---|
| 3445 | std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true); |
---|
| 3446 | std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); |
---|
| 3447 | |
---|
| 3448 | PSendSysMessage(LANG_NPCINFO_CHAR, target->GetDBTableGUIDLow(), faction, npcflags, Entry, displayid, nativeid); |
---|
| 3449 | PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel()); |
---|
| 3450 | PSendSysMessage(LANG_NPCINFO_HEALTH,target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); |
---|
| 3451 | PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction()); |
---|
| 3452 | PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); |
---|
| 3453 | PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid,cInfo->pickpocketLootId,cInfo->SkinLootId); |
---|
| 3454 | PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId()); |
---|
| 3455 | PSendSysMessage(LANG_NPCINFO_POSITION,float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ())); |
---|
| 3456 | |
---|
| 3457 | if ((npcflags & UNIT_NPC_FLAG_VENDOR) ) |
---|
| 3458 | { |
---|
| 3459 | SendSysMessage(LANG_NPCINFO_VENDOR); |
---|
| 3460 | } |
---|
| 3461 | if ((npcflags & UNIT_NPC_FLAG_TRAINER) ) |
---|
| 3462 | { |
---|
| 3463 | SendSysMessage(LANG_NPCINFO_TRAINER); |
---|
| 3464 | } |
---|
| 3465 | |
---|
| 3466 | return true; |
---|
| 3467 | } |
---|
| 3468 | |
---|
| 3469 | bool ChatHandler::HandleExploreCheatCommand(const char* args) |
---|
| 3470 | { |
---|
| 3471 | if (!*args) |
---|
| 3472 | return false; |
---|
| 3473 | |
---|
| 3474 | int flag = atoi((char*)args); |
---|
| 3475 | |
---|
| 3476 | Player *chr = getSelectedPlayer(); |
---|
| 3477 | if (chr == NULL) |
---|
| 3478 | { |
---|
| 3479 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 3480 | SetSentErrorMessage(true); |
---|
| 3481 | return false; |
---|
| 3482 | } |
---|
| 3483 | |
---|
| 3484 | if (flag != 0) |
---|
| 3485 | { |
---|
| 3486 | PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, chr->GetName()); |
---|
| 3487 | if(chr!=m_session->GetPlayer()) |
---|
| 3488 | ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL,m_session->GetPlayer()->GetName()); |
---|
| 3489 | } |
---|
| 3490 | else |
---|
| 3491 | { |
---|
| 3492 | PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING, chr->GetName()); |
---|
| 3493 | if(chr!=m_session->GetPlayer()) |
---|
| 3494 | ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING,m_session->GetPlayer()->GetName()); |
---|
| 3495 | } |
---|
| 3496 | |
---|
| 3497 | for (uint8 i=0; i<128; i++) |
---|
| 3498 | { |
---|
| 3499 | if (flag != 0) |
---|
| 3500 | { |
---|
| 3501 | m_session->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i,0xFFFFFFFF); |
---|
| 3502 | } |
---|
| 3503 | else |
---|
| 3504 | { |
---|
| 3505 | m_session->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i,0); |
---|
| 3506 | } |
---|
| 3507 | } |
---|
| 3508 | |
---|
| 3509 | return true; |
---|
| 3510 | } |
---|
| 3511 | |
---|
| 3512 | bool ChatHandler::HandleHoverCommand(const char* args) |
---|
| 3513 | { |
---|
| 3514 | char* px = strtok((char*)args, " "); |
---|
| 3515 | uint32 flag; |
---|
| 3516 | if (!px) |
---|
| 3517 | flag = 1; |
---|
| 3518 | else |
---|
| 3519 | flag = atoi(px); |
---|
| 3520 | |
---|
| 3521 | m_session->GetPlayer()->SetHover(flag); |
---|
| 3522 | |
---|
| 3523 | if (flag) |
---|
| 3524 | SendSysMessage(LANG_HOVER_ENABLED); |
---|
| 3525 | else |
---|
| 3526 | SendSysMessage(LANG_HOVER_DISABLED); |
---|
| 3527 | |
---|
| 3528 | return true; |
---|
| 3529 | } |
---|
| 3530 | |
---|
| 3531 | bool ChatHandler::HandleLevelUpCommand(const char* args) |
---|
| 3532 | { |
---|
| 3533 | char* px = strtok((char*)args, " "); |
---|
| 3534 | char* py = strtok((char*)NULL, " "); |
---|
| 3535 | |
---|
| 3536 | // command format parsing |
---|
| 3537 | char* pname = (char*)NULL; |
---|
| 3538 | int addlevel = 1; |
---|
| 3539 | |
---|
| 3540 | if(px && py) // .levelup name level |
---|
| 3541 | { |
---|
| 3542 | addlevel = atoi(py); |
---|
| 3543 | pname = px; |
---|
| 3544 | } |
---|
| 3545 | else if(px && !py) // .levelup name OR .levelup level |
---|
| 3546 | { |
---|
| 3547 | if(isalpha(px[0])) // .levelup name |
---|
| 3548 | pname = px; |
---|
| 3549 | else // .levelup level |
---|
| 3550 | addlevel = atoi(px); |
---|
| 3551 | } |
---|
| 3552 | // else .levelup - nothing do for prepering |
---|
| 3553 | |
---|
| 3554 | // player |
---|
| 3555 | Player *chr = NULL; |
---|
| 3556 | uint64 chr_guid = 0; |
---|
| 3557 | |
---|
| 3558 | std::string name; |
---|
| 3559 | |
---|
| 3560 | if(pname) // player by name |
---|
| 3561 | { |
---|
| 3562 | name = pname; |
---|
| 3563 | if(!normalizePlayerName(name)) |
---|
| 3564 | { |
---|
| 3565 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 3566 | SetSentErrorMessage(true); |
---|
| 3567 | return false; |
---|
| 3568 | } |
---|
| 3569 | |
---|
| 3570 | chr = objmgr.GetPlayer(name.c_str()); |
---|
| 3571 | if(!chr) // not in game |
---|
| 3572 | { |
---|
| 3573 | chr_guid = objmgr.GetPlayerGUIDByName(name); |
---|
| 3574 | if (chr_guid == 0) |
---|
| 3575 | { |
---|
| 3576 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 3577 | SetSentErrorMessage(true); |
---|
| 3578 | return false; |
---|
| 3579 | } |
---|
| 3580 | } |
---|
| 3581 | } |
---|
| 3582 | else // player by selection |
---|
| 3583 | { |
---|
| 3584 | chr = getSelectedPlayer(); |
---|
| 3585 | |
---|
| 3586 | if (chr == NULL) |
---|
| 3587 | { |
---|
| 3588 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 3589 | SetSentErrorMessage(true); |
---|
| 3590 | return false; |
---|
| 3591 | } |
---|
| 3592 | |
---|
| 3593 | name = chr->GetName(); |
---|
| 3594 | } |
---|
| 3595 | |
---|
| 3596 | assert(chr || chr_guid); |
---|
| 3597 | |
---|
| 3598 | int32 oldlevel = chr ? chr->getLevel() : Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL,chr_guid); |
---|
| 3599 | int32 newlevel = oldlevel + addlevel; |
---|
| 3600 | if(newlevel < 1) |
---|
| 3601 | newlevel = 1; |
---|
| 3602 | if(newlevel > 255) // hardcoded maximum level |
---|
| 3603 | newlevel = 255; |
---|
| 3604 | |
---|
| 3605 | if(chr) |
---|
| 3606 | { |
---|
| 3607 | chr->GiveLevel(newlevel); |
---|
| 3608 | chr->InitTalentForLevel(); |
---|
| 3609 | chr->SetUInt32Value(PLAYER_XP,0); |
---|
| 3610 | |
---|
| 3611 | if(oldlevel == newlevel) |
---|
| 3612 | ChatHandler(chr).SendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET); |
---|
| 3613 | else |
---|
| 3614 | if(oldlevel < newlevel) |
---|
| 3615 | ChatHandler(chr).PSendSysMessage(LANG_YOURS_LEVEL_UP,newlevel-oldlevel); |
---|
| 3616 | else |
---|
| 3617 | if(oldlevel > newlevel) |
---|
| 3618 | ChatHandler(chr).PSendSysMessage(LANG_YOURS_LEVEL_DOWN,newlevel-oldlevel); |
---|
| 3619 | } |
---|
| 3620 | else |
---|
| 3621 | { |
---|
| 3622 | // update levle and XP at level, all other will be updated at loading |
---|
| 3623 | Tokens values; |
---|
| 3624 | Player::LoadValuesArrayFromDB(values,chr_guid); |
---|
| 3625 | Player::SetUInt32ValueInArray(values,UNIT_FIELD_LEVEL,newlevel); |
---|
| 3626 | Player::SetUInt32ValueInArray(values,PLAYER_XP,0); |
---|
| 3627 | Player::SaveValuesArrayInDB(values,chr_guid); |
---|
| 3628 | } |
---|
| 3629 | |
---|
| 3630 | if(m_session->GetPlayer() != chr) // including chr==NULL |
---|
| 3631 | PSendSysMessage(LANG_YOU_CHANGE_LVL,name.c_str(),newlevel); |
---|
| 3632 | return true; |
---|
| 3633 | } |
---|
| 3634 | |
---|
| 3635 | bool ChatHandler::HandleShowAreaCommand(const char* args) |
---|
| 3636 | { |
---|
| 3637 | if (!*args) |
---|
| 3638 | return false; |
---|
| 3639 | |
---|
| 3640 | int area = atoi((char*)args); |
---|
| 3641 | |
---|
| 3642 | Player *chr = getSelectedPlayer(); |
---|
| 3643 | if (chr == NULL) |
---|
| 3644 | { |
---|
| 3645 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 3646 | SetSentErrorMessage(true); |
---|
| 3647 | return false; |
---|
| 3648 | } |
---|
| 3649 | |
---|
| 3650 | int offset = area / 32; |
---|
| 3651 | uint32 val = (uint32)(1 << (area % 32)); |
---|
| 3652 | |
---|
| 3653 | if(offset >= 128) |
---|
| 3654 | { |
---|
| 3655 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 3656 | SetSentErrorMessage(true); |
---|
| 3657 | return false; |
---|
| 3658 | } |
---|
| 3659 | |
---|
| 3660 | uint32 currFields = chr->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset); |
---|
| 3661 | chr->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, (uint32)(currFields | val)); |
---|
| 3662 | |
---|
| 3663 | SendSysMessage(LANG_EXPLORE_AREA); |
---|
| 3664 | return true; |
---|
| 3665 | } |
---|
| 3666 | |
---|
| 3667 | bool ChatHandler::HandleHideAreaCommand(const char* args) |
---|
| 3668 | { |
---|
| 3669 | if (!*args) |
---|
| 3670 | return false; |
---|
| 3671 | |
---|
| 3672 | int area = atoi((char*)args); |
---|
| 3673 | |
---|
| 3674 | Player *chr = getSelectedPlayer(); |
---|
| 3675 | if (chr == NULL) |
---|
| 3676 | { |
---|
| 3677 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 3678 | SetSentErrorMessage(true); |
---|
| 3679 | return false; |
---|
| 3680 | } |
---|
| 3681 | |
---|
| 3682 | int offset = area / 32; |
---|
| 3683 | uint32 val = (uint32)(1 << (area % 32)); |
---|
| 3684 | |
---|
| 3685 | if(offset >= 128) |
---|
| 3686 | { |
---|
| 3687 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 3688 | SetSentErrorMessage(true); |
---|
| 3689 | return false; |
---|
| 3690 | } |
---|
| 3691 | |
---|
| 3692 | uint32 currFields = chr->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset); |
---|
| 3693 | chr->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, (uint32)(currFields ^ val)); |
---|
| 3694 | |
---|
| 3695 | SendSysMessage(LANG_UNEXPLORE_AREA); |
---|
| 3696 | return true; |
---|
| 3697 | } |
---|
| 3698 | |
---|
| 3699 | bool ChatHandler::HandleUpdate(const char* args) |
---|
| 3700 | { |
---|
| 3701 | if(!*args) |
---|
| 3702 | return false; |
---|
| 3703 | |
---|
| 3704 | uint32 updateIndex; |
---|
| 3705 | uint32 value; |
---|
| 3706 | |
---|
| 3707 | char* pUpdateIndex = strtok((char*)args, " "); |
---|
| 3708 | |
---|
| 3709 | Unit* chr = getSelectedUnit(); |
---|
| 3710 | if (chr == NULL) |
---|
| 3711 | { |
---|
| 3712 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 3713 | SetSentErrorMessage(true); |
---|
| 3714 | return false; |
---|
| 3715 | } |
---|
| 3716 | |
---|
| 3717 | if(!pUpdateIndex) |
---|
| 3718 | { |
---|
| 3719 | return true; |
---|
| 3720 | } |
---|
| 3721 | updateIndex = atoi(pUpdateIndex); |
---|
| 3722 | //check updateIndex |
---|
| 3723 | if(chr->GetTypeId() == TYPEID_PLAYER) |
---|
| 3724 | { |
---|
| 3725 | if (updateIndex>=PLAYER_END) return true; |
---|
| 3726 | } |
---|
| 3727 | else |
---|
| 3728 | { |
---|
| 3729 | if (updateIndex>=UNIT_END) return true; |
---|
| 3730 | } |
---|
| 3731 | |
---|
| 3732 | char* pvalue = strtok(NULL, " "); |
---|
| 3733 | if (!pvalue) |
---|
| 3734 | { |
---|
| 3735 | value=chr->GetUInt32Value(updateIndex); |
---|
| 3736 | |
---|
| 3737 | PSendSysMessage(LANG_UPDATE, chr->GetGUIDLow(),updateIndex,value); |
---|
| 3738 | return true; |
---|
| 3739 | } |
---|
| 3740 | |
---|
| 3741 | value=atoi(pvalue); |
---|
| 3742 | |
---|
| 3743 | PSendSysMessage(LANG_UPDATE_CHANGE, chr->GetGUIDLow(),updateIndex,value); |
---|
| 3744 | |
---|
| 3745 | chr->SetUInt32Value(updateIndex,value); |
---|
| 3746 | |
---|
| 3747 | return true; |
---|
| 3748 | } |
---|
| 3749 | |
---|
| 3750 | bool ChatHandler::HandleBankCommand(const char* /*args*/) |
---|
| 3751 | { |
---|
| 3752 | m_session->SendShowBank( m_session->GetPlayer()->GetGUID() ); |
---|
| 3753 | |
---|
| 3754 | return true; |
---|
| 3755 | } |
---|
| 3756 | |
---|
| 3757 | bool ChatHandler::HandleChangeWeather(const char* args) |
---|
| 3758 | { |
---|
| 3759 | if(!*args) |
---|
| 3760 | return false; |
---|
| 3761 | |
---|
| 3762 | //Weather is OFF |
---|
| 3763 | if (!sWorld.getConfig(CONFIG_WEATHER)) |
---|
| 3764 | { |
---|
| 3765 | SendSysMessage(LANG_WEATHER_DISABLED); |
---|
| 3766 | SetSentErrorMessage(true); |
---|
| 3767 | return false; |
---|
| 3768 | } |
---|
| 3769 | |
---|
| 3770 | //*Change the weather of a cell |
---|
| 3771 | char* px = strtok((char*)args, " "); |
---|
| 3772 | char* py = strtok(NULL, " "); |
---|
| 3773 | |
---|
| 3774 | if (!px || !py) |
---|
| 3775 | return false; |
---|
| 3776 | |
---|
| 3777 | uint32 type = (uint32)atoi(px); //0 to 3, 0: fine, 1: rain, 2: snow, 3: sand |
---|
| 3778 | float grade = (float)atof(py); //0 to 1, sending -1 is instand good weather |
---|
| 3779 | |
---|
| 3780 | Player *player = m_session->GetPlayer(); |
---|
| 3781 | uint32 zoneid = player->GetZoneId(); |
---|
| 3782 | |
---|
| 3783 | Weather* wth = sWorld.FindWeather(zoneid); |
---|
| 3784 | |
---|
| 3785 | if(!wth) |
---|
| 3786 | wth = sWorld.AddWeather(zoneid); |
---|
| 3787 | if(!wth) |
---|
| 3788 | { |
---|
| 3789 | SendSysMessage(LANG_NO_WEATHER); |
---|
| 3790 | SetSentErrorMessage(true); |
---|
| 3791 | return false; |
---|
| 3792 | } |
---|
| 3793 | |
---|
| 3794 | wth->SetWeather(WeatherType(type), grade); |
---|
| 3795 | |
---|
| 3796 | return true; |
---|
| 3797 | } |
---|
| 3798 | |
---|
| 3799 | bool ChatHandler::HandleSetValue(const char* args) |
---|
| 3800 | { |
---|
| 3801 | if(!*args) |
---|
| 3802 | return false; |
---|
| 3803 | |
---|
| 3804 | char* px = strtok((char*)args, " "); |
---|
| 3805 | char* py = strtok(NULL, " "); |
---|
| 3806 | char* pz = strtok(NULL, " "); |
---|
| 3807 | |
---|
| 3808 | if (!px || !py) |
---|
| 3809 | return false; |
---|
| 3810 | |
---|
| 3811 | Unit* target = getSelectedUnit(); |
---|
| 3812 | if(!target) |
---|
| 3813 | { |
---|
| 3814 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 3815 | SetSentErrorMessage(true); |
---|
| 3816 | return false; |
---|
| 3817 | } |
---|
| 3818 | |
---|
| 3819 | uint64 guid = target->GetGUID(); |
---|
| 3820 | |
---|
| 3821 | uint32 Opcode = (uint32)atoi(px); |
---|
| 3822 | if(Opcode >= target->GetValuesCount()) |
---|
| 3823 | { |
---|
| 3824 | PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); |
---|
| 3825 | return false; |
---|
| 3826 | } |
---|
| 3827 | uint32 iValue; |
---|
| 3828 | float fValue; |
---|
| 3829 | bool isint32 = true; |
---|
| 3830 | if(pz) |
---|
| 3831 | isint32 = (bool)atoi(pz); |
---|
| 3832 | if(isint32) |
---|
| 3833 | { |
---|
| 3834 | iValue = (uint32)atoi(py); |
---|
[44] | 3835 | sLog.outDebug(GetTrinityString(LANG_SET_UINT), GUID_LOPART(guid), Opcode, iValue); |
---|
[37] | 3836 | target->SetUInt32Value( Opcode , iValue ); |
---|
| 3837 | PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode,iValue); |
---|
| 3838 | } |
---|
| 3839 | else |
---|
| 3840 | { |
---|
| 3841 | fValue = (float)atof(py); |
---|
[44] | 3842 | sLog.outDebug(GetTrinityString(LANG_SET_FLOAT), GUID_LOPART(guid), Opcode, fValue); |
---|
[37] | 3843 | target->SetFloatValue( Opcode , fValue ); |
---|
| 3844 | PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode,fValue); |
---|
| 3845 | } |
---|
| 3846 | |
---|
| 3847 | return true; |
---|
| 3848 | } |
---|
| 3849 | |
---|
| 3850 | bool ChatHandler::HandleGetValue(const char* args) |
---|
| 3851 | { |
---|
| 3852 | if(!*args) |
---|
| 3853 | return false; |
---|
| 3854 | |
---|
| 3855 | char* px = strtok((char*)args, " "); |
---|
| 3856 | char* pz = strtok(NULL, " "); |
---|
| 3857 | |
---|
| 3858 | if (!px) |
---|
| 3859 | return false; |
---|
| 3860 | |
---|
| 3861 | Unit* target = getSelectedUnit(); |
---|
| 3862 | if(!target) |
---|
| 3863 | { |
---|
| 3864 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 3865 | SetSentErrorMessage(true); |
---|
| 3866 | return false; |
---|
| 3867 | } |
---|
| 3868 | |
---|
| 3869 | uint64 guid = target->GetGUID(); |
---|
| 3870 | |
---|
| 3871 | uint32 Opcode = (uint32)atoi(px); |
---|
| 3872 | if(Opcode >= target->GetValuesCount()) |
---|
| 3873 | { |
---|
| 3874 | PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); |
---|
| 3875 | return false; |
---|
| 3876 | } |
---|
| 3877 | uint32 iValue; |
---|
| 3878 | float fValue; |
---|
| 3879 | bool isint32 = true; |
---|
| 3880 | if(pz) |
---|
| 3881 | isint32 = (bool)atoi(pz); |
---|
| 3882 | |
---|
| 3883 | if(isint32) |
---|
| 3884 | { |
---|
| 3885 | iValue = target->GetUInt32Value( Opcode ); |
---|
[44] | 3886 | sLog.outDebug(GetTrinityString(LANG_GET_UINT), GUID_LOPART(guid), Opcode, iValue); |
---|
[37] | 3887 | PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); |
---|
| 3888 | } |
---|
| 3889 | else |
---|
| 3890 | { |
---|
| 3891 | fValue = target->GetFloatValue( Opcode ); |
---|
[44] | 3892 | sLog.outDebug(GetTrinityString(LANG_GET_FLOAT), GUID_LOPART(guid), Opcode, fValue); |
---|
[37] | 3893 | PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); |
---|
| 3894 | } |
---|
| 3895 | |
---|
| 3896 | return true; |
---|
| 3897 | } |
---|
| 3898 | |
---|
| 3899 | bool ChatHandler::HandleSet32Bit(const char* args) |
---|
| 3900 | { |
---|
| 3901 | if(!*args) |
---|
| 3902 | return false; |
---|
| 3903 | |
---|
| 3904 | char* px = strtok((char*)args, " "); |
---|
| 3905 | char* py = strtok(NULL, " "); |
---|
| 3906 | |
---|
| 3907 | if (!px || !py) |
---|
| 3908 | return false; |
---|
| 3909 | |
---|
| 3910 | uint32 Opcode = (uint32)atoi(px); |
---|
| 3911 | uint32 Value = (uint32)atoi(py); |
---|
| 3912 | if (Value > 32) //uint32 = 32 bits |
---|
| 3913 | return false; |
---|
| 3914 | |
---|
[44] | 3915 | sLog.outDebug(GetTrinityString(LANG_SET_32BIT), Opcode, Value); |
---|
[37] | 3916 | |
---|
| 3917 | m_session->GetPlayer( )->SetUInt32Value( Opcode , 2^Value ); |
---|
| 3918 | |
---|
| 3919 | PSendSysMessage(LANG_SET_32BIT_FIELD, Opcode,1); |
---|
| 3920 | return true; |
---|
| 3921 | } |
---|
| 3922 | |
---|
| 3923 | bool ChatHandler::HandleMod32Value(const char* args) |
---|
| 3924 | { |
---|
| 3925 | if(!*args) |
---|
| 3926 | return false; |
---|
| 3927 | |
---|
| 3928 | char* px = strtok((char*)args, " "); |
---|
| 3929 | char* py = strtok(NULL, " "); |
---|
| 3930 | |
---|
| 3931 | if (!px || !py) |
---|
| 3932 | return false; |
---|
| 3933 | |
---|
| 3934 | uint32 Opcode = (uint32)atoi(px); |
---|
| 3935 | int Value = atoi(py); |
---|
| 3936 | |
---|
| 3937 | if(Opcode >= m_session->GetPlayer()->GetValuesCount()) |
---|
| 3938 | { |
---|
| 3939 | PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, m_session->GetPlayer()->GetGUIDLow(), m_session->GetPlayer( )->GetValuesCount()); |
---|
| 3940 | return false; |
---|
| 3941 | } |
---|
| 3942 | |
---|
[44] | 3943 | sLog.outDebug(GetTrinityString(LANG_CHANGE_32BIT), Opcode, Value); |
---|
[37] | 3944 | |
---|
| 3945 | int CurrentValue = (int)m_session->GetPlayer( )->GetUInt32Value( Opcode ); |
---|
| 3946 | |
---|
| 3947 | CurrentValue += Value; |
---|
| 3948 | m_session->GetPlayer( )->SetUInt32Value( Opcode , (uint32)CurrentValue ); |
---|
| 3949 | |
---|
| 3950 | PSendSysMessage(LANG_CHANGE_32BIT_FIELD, Opcode,CurrentValue); |
---|
| 3951 | |
---|
| 3952 | return true; |
---|
| 3953 | } |
---|
| 3954 | |
---|
| 3955 | bool ChatHandler::HandleAddTeleCommand(const char * args) |
---|
| 3956 | { |
---|
| 3957 | if(!*args) |
---|
| 3958 | return false; |
---|
| 3959 | |
---|
| 3960 | Player *player=m_session->GetPlayer(); |
---|
| 3961 | if (!player) |
---|
| 3962 | return false; |
---|
| 3963 | |
---|
| 3964 | std::string name = args; |
---|
| 3965 | |
---|
| 3966 | if(objmgr.GetGameTele(name)) |
---|
| 3967 | { |
---|
| 3968 | SendSysMessage(LANG_COMMAND_TP_ALREADYEXIST); |
---|
| 3969 | SetSentErrorMessage(true); |
---|
| 3970 | return false; |
---|
| 3971 | } |
---|
| 3972 | |
---|
| 3973 | GameTele tele; |
---|
| 3974 | tele.position_x = player->GetPositionX(); |
---|
| 3975 | tele.position_y = player->GetPositionY(); |
---|
| 3976 | tele.position_z = player->GetPositionZ(); |
---|
| 3977 | tele.orientation = player->GetOrientation(); |
---|
| 3978 | tele.mapId = player->GetMapId(); |
---|
| 3979 | tele.name = name; |
---|
| 3980 | |
---|
| 3981 | if(objmgr.AddGameTele(tele)) |
---|
| 3982 | { |
---|
| 3983 | SendSysMessage(LANG_COMMAND_TP_ADDED); |
---|
| 3984 | } |
---|
| 3985 | else |
---|
| 3986 | { |
---|
| 3987 | SendSysMessage(LANG_COMMAND_TP_ADDEDERR); |
---|
| 3988 | SetSentErrorMessage(true); |
---|
| 3989 | return false; |
---|
| 3990 | } |
---|
| 3991 | |
---|
| 3992 | return true; |
---|
| 3993 | } |
---|
| 3994 | |
---|
| 3995 | bool ChatHandler::HandleDelTeleCommand(const char * args) |
---|
| 3996 | { |
---|
| 3997 | if(!*args) |
---|
| 3998 | return false; |
---|
| 3999 | |
---|
| 4000 | std::string name = args; |
---|
| 4001 | |
---|
| 4002 | if(!objmgr.DeleteGameTele(name)) |
---|
| 4003 | { |
---|
| 4004 | SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); |
---|
| 4005 | SetSentErrorMessage(true); |
---|
| 4006 | return false; |
---|
| 4007 | } |
---|
| 4008 | |
---|
| 4009 | SendSysMessage(LANG_COMMAND_TP_DELETED); |
---|
| 4010 | return true; |
---|
| 4011 | } |
---|
| 4012 | |
---|
| 4013 | bool ChatHandler::HandleListAurasCommand (const char * /*args*/) |
---|
| 4014 | { |
---|
| 4015 | Unit *unit = getSelectedUnit(); |
---|
| 4016 | if(!unit) |
---|
| 4017 | { |
---|
| 4018 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 4019 | SetSentErrorMessage(true); |
---|
| 4020 | return false; |
---|
| 4021 | } |
---|
| 4022 | |
---|
[44] | 4023 | char const* talentStr = GetTrinityString(LANG_TALENT); |
---|
| 4024 | char const* passiveStr = GetTrinityString(LANG_PASSIVE); |
---|
[37] | 4025 | |
---|
| 4026 | Unit::AuraMap const& uAuras = unit->GetAuras(); |
---|
| 4027 | PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, uAuras.size()); |
---|
| 4028 | for (Unit::AuraMap::const_iterator itr = uAuras.begin(); itr != uAuras.end(); ++itr) |
---|
| 4029 | { |
---|
| 4030 | bool talent = GetTalentSpellCost(itr->second->GetId()) > 0; |
---|
| 4031 | PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, itr->second->GetId(), itr->second->GetEffIndex(), |
---|
| 4032 | itr->second->GetModifier()->m_auraname, itr->second->GetAuraDuration(), itr->second->GetAuraMaxDuration(), |
---|
| 4033 | itr->second->GetSpellProto()->SpellName[m_session->GetSessionDbcLocale()], |
---|
| 4034 | (itr->second->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), |
---|
| 4035 | IS_PLAYER_GUID(itr->second->GetCasterGUID()) ? "player" : "creature",GUID_LOPART(itr->second->GetCasterGUID())); |
---|
| 4036 | } |
---|
| 4037 | for (int i = 0; i < TOTAL_AURAS; i++) |
---|
| 4038 | { |
---|
| 4039 | Unit::AuraList const& uAuraList = unit->GetAurasByType(AuraType(i)); |
---|
| 4040 | if (uAuraList.empty()) continue; |
---|
| 4041 | PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, uAuraList.size(), i); |
---|
| 4042 | for (Unit::AuraList::const_iterator itr = uAuraList.begin(); itr != uAuraList.end(); ++itr) |
---|
| 4043 | { |
---|
| 4044 | bool talent = GetTalentSpellCost((*itr)->GetId()) > 0; |
---|
| 4045 | PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(), |
---|
| 4046 | (*itr)->GetSpellProto()->SpellName[m_session->GetSessionDbcLocale()],((*itr)->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), |
---|
| 4047 | IS_PLAYER_GUID((*itr)->GetCasterGUID()) ? "player" : "creature",GUID_LOPART((*itr)->GetCasterGUID())); |
---|
| 4048 | } |
---|
| 4049 | } |
---|
| 4050 | return true; |
---|
| 4051 | } |
---|
| 4052 | |
---|
| 4053 | bool ChatHandler::HandleResetHonorCommand (const char * args) |
---|
| 4054 | { |
---|
| 4055 | char* pName = strtok((char*)args, ""); |
---|
| 4056 | Player *player = NULL; |
---|
| 4057 | if (pName) |
---|
| 4058 | { |
---|
| 4059 | std::string name = pName; |
---|
| 4060 | if(!normalizePlayerName(name)) |
---|
| 4061 | { |
---|
| 4062 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 4063 | SetSentErrorMessage(true); |
---|
| 4064 | return false; |
---|
| 4065 | } |
---|
| 4066 | |
---|
| 4067 | uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()); |
---|
| 4068 | player = objmgr.GetPlayer(guid); |
---|
| 4069 | } |
---|
| 4070 | else |
---|
| 4071 | player = getSelectedPlayer(); |
---|
| 4072 | |
---|
| 4073 | if(!player) |
---|
| 4074 | { |
---|
| 4075 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 4076 | return true; |
---|
| 4077 | } |
---|
| 4078 | |
---|
| 4079 | player->SetUInt32Value(PLAYER_FIELD_KILLS, 0); |
---|
| 4080 | player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS, 0); |
---|
| 4081 | player->SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, 0); |
---|
| 4082 | player->SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, 0); |
---|
| 4083 | player->SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0); |
---|
| 4084 | |
---|
| 4085 | return true; |
---|
| 4086 | } |
---|
| 4087 | |
---|
| 4088 | static bool HandleResetStatsOrLevelHelper(Player* player) |
---|
| 4089 | { |
---|
| 4090 | PlayerInfo const *info = objmgr.GetPlayerInfo(player->getRace(), player->getClass()); |
---|
| 4091 | if(!info) return false; |
---|
| 4092 | |
---|
| 4093 | ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(player->getClass()); |
---|
| 4094 | if(!cEntry) |
---|
| 4095 | { |
---|
| 4096 | sLog.outError("Class %u not found in DBC (Wrong DBC files?)",player->getClass()); |
---|
| 4097 | return false; |
---|
| 4098 | } |
---|
| 4099 | |
---|
| 4100 | uint8 powertype = cEntry->powerType; |
---|
| 4101 | |
---|
| 4102 | uint32 unitfield; |
---|
| 4103 | if(powertype == POWER_RAGE) |
---|
| 4104 | unitfield = 0x1100EE00; |
---|
| 4105 | else if(powertype == POWER_ENERGY) |
---|
| 4106 | unitfield = 0x00000000; |
---|
| 4107 | else if(powertype == POWER_MANA) |
---|
| 4108 | unitfield = 0x0000EE00; |
---|
| 4109 | else |
---|
| 4110 | { |
---|
| 4111 | sLog.outError("Invalid default powertype %u for player (class %u)",powertype,player->getClass()); |
---|
| 4112 | return false; |
---|
| 4113 | } |
---|
| 4114 | |
---|
| 4115 | // reset m_form if no aura |
---|
| 4116 | if(!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT)) |
---|
| 4117 | player->m_form = FORM_NONE; |
---|
| 4118 | |
---|
| 4119 | player->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE ); |
---|
| 4120 | player->SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f ); |
---|
| 4121 | |
---|
| 4122 | player->setFactionForRace(player->getRace()); |
---|
| 4123 | |
---|
| 4124 | player->SetUInt32Value(UNIT_FIELD_BYTES_0, ( ( player->getRace() ) | ( player->getClass() << 8 ) | ( player->getGender() << 16 ) | ( powertype << 24 ) ) ); |
---|
| 4125 | |
---|
| 4126 | // reset only if player not in some form; |
---|
| 4127 | if(player->m_form==FORM_NONE) |
---|
| 4128 | { |
---|
| 4129 | switch(player->getGender()) |
---|
| 4130 | { |
---|
| 4131 | case GENDER_FEMALE: |
---|
| 4132 | player->SetDisplayId(info->displayId_f); |
---|
| 4133 | player->SetNativeDisplayId(info->displayId_f); |
---|
| 4134 | break; |
---|
| 4135 | case GENDER_MALE: |
---|
| 4136 | player->SetDisplayId(info->displayId_m); |
---|
| 4137 | player->SetNativeDisplayId(info->displayId_m); |
---|
| 4138 | break; |
---|
| 4139 | default: |
---|
| 4140 | break; |
---|
| 4141 | } |
---|
| 4142 | } |
---|
| 4143 | |
---|
| 4144 | // set UNIT_FIELD_BYTES_1 to init state but preserve m_form value |
---|
| 4145 | player->SetUInt32Value(UNIT_FIELD_BYTES_1, unitfield); |
---|
| 4146 | player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_UNK3 | UNIT_BYTE2_FLAG_UNK5 ); |
---|
| 4147 | player->SetByteValue(UNIT_FIELD_BYTES_2, 3, player->m_form); |
---|
| 4148 | |
---|
| 4149 | player->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); |
---|
| 4150 | |
---|
| 4151 | //-1 is default value |
---|
| 4152 | player->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1)); |
---|
| 4153 | |
---|
| 4154 | //player->SetUInt32Value(PLAYER_FIELD_BYTES, 0xEEE00000 ); |
---|
| 4155 | return true; |
---|
| 4156 | } |
---|
| 4157 | |
---|
| 4158 | bool ChatHandler::HandleResetLevelCommand(const char * args) |
---|
| 4159 | { |
---|
| 4160 | char* pName = strtok((char*)args, ""); |
---|
| 4161 | Player *player = NULL; |
---|
| 4162 | if (pName) |
---|
| 4163 | { |
---|
| 4164 | std::string name = pName; |
---|
| 4165 | if(!normalizePlayerName(name)) |
---|
| 4166 | { |
---|
| 4167 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 4168 | SetSentErrorMessage(true); |
---|
| 4169 | return false; |
---|
| 4170 | } |
---|
| 4171 | |
---|
| 4172 | uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()); |
---|
| 4173 | player = objmgr.GetPlayer(guid); |
---|
| 4174 | } |
---|
| 4175 | else |
---|
| 4176 | player = getSelectedPlayer(); |
---|
| 4177 | |
---|
| 4178 | if(!player) |
---|
| 4179 | { |
---|
| 4180 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 4181 | SetSentErrorMessage(true); |
---|
| 4182 | return false; |
---|
| 4183 | } |
---|
| 4184 | |
---|
| 4185 | if(!HandleResetStatsOrLevelHelper(player)) |
---|
| 4186 | return false; |
---|
| 4187 | |
---|
| 4188 | player->SetLevel(1); |
---|
| 4189 | player->InitStatsForLevel(true); |
---|
| 4190 | player->InitTaxiNodesForLevel(); |
---|
| 4191 | player->InitTalentForLevel(); |
---|
| 4192 | player->SetUInt32Value(PLAYER_XP,0); |
---|
| 4193 | |
---|
| 4194 | // reset level to summoned pet |
---|
| 4195 | Pet* pet = player->GetPet(); |
---|
| 4196 | if(pet && pet->getPetType()==SUMMON_PET) |
---|
| 4197 | pet->InitStatsForLevel(1); |
---|
| 4198 | |
---|
| 4199 | return true; |
---|
| 4200 | } |
---|
| 4201 | |
---|
| 4202 | bool ChatHandler::HandleResetStatsCommand(const char * args) |
---|
| 4203 | { |
---|
| 4204 | char* pName = strtok((char*)args, ""); |
---|
| 4205 | Player *player = NULL; |
---|
| 4206 | if (pName) |
---|
| 4207 | { |
---|
| 4208 | std::string name = pName; |
---|
| 4209 | if(!normalizePlayerName(name)) |
---|
| 4210 | { |
---|
| 4211 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 4212 | SetSentErrorMessage(true); |
---|
| 4213 | return false; |
---|
| 4214 | } |
---|
| 4215 | |
---|
| 4216 | uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()); |
---|
| 4217 | player = objmgr.GetPlayer(guid); |
---|
| 4218 | } |
---|
| 4219 | else |
---|
| 4220 | player = getSelectedPlayer(); |
---|
| 4221 | |
---|
| 4222 | if(!player) |
---|
| 4223 | { |
---|
| 4224 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 4225 | SetSentErrorMessage(true); |
---|
| 4226 | return false; |
---|
| 4227 | } |
---|
| 4228 | |
---|
| 4229 | if(!HandleResetStatsOrLevelHelper(player)) |
---|
| 4230 | return false; |
---|
| 4231 | |
---|
| 4232 | player->InitStatsForLevel(true); |
---|
| 4233 | player->InitTaxiNodesForLevel(); |
---|
| 4234 | player->InitTalentForLevel(); |
---|
| 4235 | |
---|
| 4236 | return true; |
---|
| 4237 | } |
---|
| 4238 | |
---|
| 4239 | bool ChatHandler::HandleResetSpellsCommand(const char * args) |
---|
| 4240 | { |
---|
| 4241 | char* pName = strtok((char*)args, ""); |
---|
| 4242 | Player *player = NULL; |
---|
| 4243 | uint64 playerGUID = 0; |
---|
| 4244 | if (pName) |
---|
| 4245 | { |
---|
| 4246 | std::string name = pName; |
---|
| 4247 | |
---|
| 4248 | if(!normalizePlayerName(name)) |
---|
| 4249 | { |
---|
| 4250 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 4251 | SetSentErrorMessage(true); |
---|
| 4252 | return false; |
---|
| 4253 | } |
---|
| 4254 | |
---|
| 4255 | player = objmgr.GetPlayer(name.c_str()); |
---|
| 4256 | if(!player) |
---|
| 4257 | playerGUID = objmgr.GetPlayerGUIDByName(name.c_str()); |
---|
| 4258 | } |
---|
| 4259 | else |
---|
| 4260 | player = getSelectedPlayer(); |
---|
| 4261 | |
---|
| 4262 | if(!player && !playerGUID) |
---|
| 4263 | { |
---|
| 4264 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 4265 | SetSentErrorMessage(true); |
---|
| 4266 | return false; |
---|
| 4267 | } |
---|
| 4268 | |
---|
| 4269 | if(player) |
---|
| 4270 | { |
---|
| 4271 | player->resetSpells(); |
---|
| 4272 | |
---|
| 4273 | ChatHandler(player).SendSysMessage(LANG_RESET_SPELLS); |
---|
| 4274 | |
---|
| 4275 | if(m_session->GetPlayer()!=player) |
---|
| 4276 | PSendSysMessage(LANG_RESET_SPELLS_ONLINE,player->GetName()); |
---|
| 4277 | } |
---|
| 4278 | else |
---|
| 4279 | { |
---|
| 4280 | CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_SPELLS), GUID_LOPART(playerGUID)); |
---|
| 4281 | PSendSysMessage(LANG_RESET_SPELLS_OFFLINE,pName); |
---|
| 4282 | } |
---|
| 4283 | |
---|
| 4284 | return true; |
---|
| 4285 | } |
---|
| 4286 | |
---|
| 4287 | bool ChatHandler::HandleResetTalentsCommand(const char * args) |
---|
| 4288 | { |
---|
| 4289 | char* pName = strtok((char*)args, ""); |
---|
| 4290 | Player *player = NULL; |
---|
| 4291 | uint64 playerGUID = 0; |
---|
| 4292 | if (pName) |
---|
| 4293 | { |
---|
| 4294 | std::string name = pName; |
---|
| 4295 | if(!normalizePlayerName(name)) |
---|
| 4296 | { |
---|
| 4297 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 4298 | SetSentErrorMessage(true); |
---|
| 4299 | return false; |
---|
| 4300 | } |
---|
| 4301 | |
---|
| 4302 | player = objmgr.GetPlayer(name.c_str()); |
---|
| 4303 | if(!player) |
---|
| 4304 | playerGUID = objmgr.GetPlayerGUIDByName(name.c_str()); |
---|
| 4305 | } |
---|
| 4306 | else |
---|
| 4307 | player = getSelectedPlayer(); |
---|
| 4308 | |
---|
| 4309 | if(!player && !playerGUID) |
---|
| 4310 | { |
---|
| 4311 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 4312 | SetSentErrorMessage(true); |
---|
| 4313 | return false; |
---|
| 4314 | } |
---|
| 4315 | |
---|
| 4316 | if(player) |
---|
| 4317 | { |
---|
| 4318 | player->resetTalents(true); |
---|
| 4319 | |
---|
| 4320 | ChatHandler(player).SendSysMessage(LANG_RESET_TALENTS); |
---|
| 4321 | |
---|
| 4322 | if(m_session->GetPlayer()!=player) |
---|
| 4323 | PSendSysMessage(LANG_RESET_TALENTS_ONLINE,player->GetName()); |
---|
| 4324 | } |
---|
| 4325 | else |
---|
| 4326 | { |
---|
| 4327 | CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_TALENTS), GUID_LOPART(playerGUID) ); |
---|
| 4328 | PSendSysMessage(LANG_RESET_TALENTS_OFFLINE,pName); |
---|
| 4329 | } |
---|
| 4330 | |
---|
| 4331 | return true; |
---|
| 4332 | } |
---|
| 4333 | |
---|
| 4334 | bool ChatHandler::HandleResetAllCommand(const char * args) |
---|
| 4335 | { |
---|
| 4336 | if(!*args) |
---|
| 4337 | return false; |
---|
| 4338 | |
---|
| 4339 | std::string casename = args; |
---|
| 4340 | |
---|
| 4341 | AtLoginFlags atLogin; |
---|
| 4342 | |
---|
| 4343 | // Command specially created as single command to prevent using short case names |
---|
| 4344 | if(casename=="spells") |
---|
| 4345 | { |
---|
| 4346 | atLogin = AT_LOGIN_RESET_SPELLS; |
---|
| 4347 | sWorld.SendWorldText(LANG_RESETALL_SPELLS); |
---|
| 4348 | } |
---|
| 4349 | else if(casename=="talents") |
---|
| 4350 | { |
---|
| 4351 | atLogin = AT_LOGIN_RESET_TALENTS; |
---|
| 4352 | sWorld.SendWorldText(LANG_RESETALL_TALENTS); |
---|
| 4353 | } |
---|
| 4354 | else |
---|
| 4355 | { |
---|
| 4356 | PSendSysMessage(LANG_RESETALL_UNKNOWN_CASE,args); |
---|
| 4357 | SetSentErrorMessage(true); |
---|
| 4358 | return false; |
---|
| 4359 | } |
---|
| 4360 | |
---|
| 4361 | CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u'",atLogin); |
---|
| 4362 | HashMapHolder<Player>::MapType const& plist = ObjectAccessor::Instance().GetPlayers(); |
---|
| 4363 | for(HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr) |
---|
| 4364 | itr->second->SetAtLoginFlag(atLogin); |
---|
| 4365 | |
---|
| 4366 | return true; |
---|
| 4367 | } |
---|
| 4368 | |
---|
| 4369 | bool ChatHandler::HandleShutDownCommand(const char* args) |
---|
| 4370 | { |
---|
| 4371 | if(!*args) |
---|
| 4372 | return false; |
---|
| 4373 | |
---|
| 4374 | if(std::string(args)=="cancel") |
---|
| 4375 | { |
---|
| 4376 | sWorld.ShutdownCancel(); |
---|
| 4377 | } |
---|
| 4378 | else |
---|
| 4379 | { |
---|
| 4380 | int32 time = atoi(args); |
---|
| 4381 | |
---|
| 4382 | ///- Prevent interpret wrong arg value as 0 secs shutdown time |
---|
| 4383 | if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) |
---|
| 4384 | return false; |
---|
| 4385 | |
---|
| 4386 | sWorld.ShutdownServ(time); |
---|
| 4387 | } |
---|
| 4388 | return true; |
---|
| 4389 | } |
---|
| 4390 | |
---|
| 4391 | bool ChatHandler::HandleRestartCommand(const char* args) |
---|
| 4392 | { |
---|
| 4393 | if(!*args) |
---|
| 4394 | return false; |
---|
| 4395 | |
---|
| 4396 | if(std::string(args)=="cancel") |
---|
| 4397 | { |
---|
| 4398 | sWorld.ShutdownCancel(); |
---|
| 4399 | } |
---|
| 4400 | else |
---|
| 4401 | { |
---|
| 4402 | int32 time = atoi(args); |
---|
| 4403 | |
---|
| 4404 | ///- Prevent interpret wrong arg value as 0 secs shutdown time |
---|
| 4405 | if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) |
---|
| 4406 | return false; |
---|
| 4407 | |
---|
| 4408 | sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART); |
---|
| 4409 | } |
---|
| 4410 | return true; |
---|
| 4411 | } |
---|
| 4412 | |
---|
| 4413 | bool ChatHandler::HandleIdleRestartCommand(const char* args) |
---|
| 4414 | { |
---|
| 4415 | if(!*args) |
---|
| 4416 | return false; |
---|
| 4417 | |
---|
| 4418 | if(std::string(args)=="cancel") |
---|
| 4419 | { |
---|
| 4420 | sWorld.ShutdownCancel(); |
---|
| 4421 | } |
---|
| 4422 | else |
---|
| 4423 | { |
---|
| 4424 | int32 time = atoi(args); |
---|
| 4425 | |
---|
| 4426 | ///- Prevent interpret wrong arg value as 0 secs shutdown time |
---|
| 4427 | if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) |
---|
| 4428 | return false; |
---|
| 4429 | |
---|
| 4430 | sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART+SHUTDOWN_MASK_IDLE); |
---|
| 4431 | } |
---|
| 4432 | return true; |
---|
| 4433 | } |
---|
| 4434 | |
---|
| 4435 | bool ChatHandler::HandleIdleShutDownCommand(const char* args) |
---|
| 4436 | { |
---|
| 4437 | if(!*args) |
---|
| 4438 | return false; |
---|
| 4439 | |
---|
| 4440 | if(std::string(args)=="cancel") |
---|
| 4441 | { |
---|
| 4442 | sWorld.ShutdownCancel(); |
---|
| 4443 | } |
---|
| 4444 | else |
---|
| 4445 | { |
---|
| 4446 | int32 time = atoi(args); |
---|
| 4447 | |
---|
| 4448 | ///- Prevent interpret wrong arg value as 0 secs shutdown time |
---|
| 4449 | if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) |
---|
| 4450 | return false; |
---|
| 4451 | |
---|
| 4452 | sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE); |
---|
| 4453 | } |
---|
| 4454 | return true; |
---|
| 4455 | } |
---|
| 4456 | |
---|
| 4457 | bool ChatHandler::HandleAddQuest(const char* args) |
---|
| 4458 | { |
---|
| 4459 | Player* player = getSelectedPlayer(); |
---|
| 4460 | if(!player) |
---|
| 4461 | { |
---|
| 4462 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 4463 | SetSentErrorMessage(true); |
---|
| 4464 | return false; |
---|
| 4465 | } |
---|
| 4466 | |
---|
| 4467 | // .addquest #entry' |
---|
| 4468 | // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r |
---|
| 4469 | char* cId = extractKeyFromLink((char*)args,"Hquest"); |
---|
| 4470 | if(!cId) |
---|
| 4471 | return false; |
---|
| 4472 | |
---|
| 4473 | uint32 entry = atol(cId); |
---|
| 4474 | |
---|
| 4475 | Quest const* pQuest = objmgr.GetQuestTemplate(entry); |
---|
| 4476 | |
---|
| 4477 | if(!pQuest) |
---|
| 4478 | { |
---|
| 4479 | PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND,entry); |
---|
| 4480 | SetSentErrorMessage(true); |
---|
| 4481 | return false; |
---|
| 4482 | } |
---|
| 4483 | |
---|
| 4484 | // check item starting quest (it can work incorrectly if added without item in inventory) |
---|
| 4485 | QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE startquest = '%u' LIMIT 1",entry); |
---|
| 4486 | if(result) |
---|
| 4487 | { |
---|
| 4488 | Field* fields = result->Fetch(); |
---|
| 4489 | uint32 item_id = fields[0].GetUInt32(); |
---|
| 4490 | delete result; |
---|
| 4491 | |
---|
| 4492 | PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry,item_id); |
---|
| 4493 | SetSentErrorMessage(true); |
---|
| 4494 | return false; |
---|
| 4495 | } |
---|
| 4496 | |
---|
| 4497 | // ok, normal (creature/GO starting) quest |
---|
| 4498 | if( player->CanAddQuest( pQuest, true ) ) |
---|
| 4499 | { |
---|
| 4500 | player->AddQuest( pQuest, NULL ); |
---|
| 4501 | |
---|
| 4502 | if ( player->CanCompleteQuest( entry ) ) |
---|
| 4503 | player->CompleteQuest( entry ); |
---|
| 4504 | } |
---|
| 4505 | |
---|
| 4506 | return true; |
---|
| 4507 | } |
---|
| 4508 | |
---|
| 4509 | bool ChatHandler::HandleRemoveQuest(const char* args) |
---|
| 4510 | { |
---|
| 4511 | Player* player = getSelectedPlayer(); |
---|
| 4512 | if(!player) |
---|
| 4513 | { |
---|
| 4514 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 4515 | SetSentErrorMessage(true); |
---|
| 4516 | return false; |
---|
| 4517 | } |
---|
| 4518 | |
---|
| 4519 | // .removequest #entry' |
---|
| 4520 | // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r |
---|
| 4521 | char* cId = extractKeyFromLink((char*)args,"Hquest"); |
---|
| 4522 | if(!cId) |
---|
| 4523 | return false; |
---|
| 4524 | |
---|
| 4525 | uint32 entry = atol(cId); |
---|
| 4526 | |
---|
| 4527 | Quest const* pQuest = objmgr.GetQuestTemplate(entry); |
---|
| 4528 | |
---|
| 4529 | if(!pQuest) |
---|
| 4530 | { |
---|
| 4531 | PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); |
---|
| 4532 | SetSentErrorMessage(true); |
---|
| 4533 | return false; |
---|
| 4534 | } |
---|
| 4535 | |
---|
| 4536 | // remove all quest entries for 'entry' from quest log |
---|
| 4537 | for(uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot ) |
---|
| 4538 | { |
---|
| 4539 | uint32 quest = player->GetQuestSlotQuestId(slot); |
---|
| 4540 | if(quest==entry) |
---|
| 4541 | { |
---|
| 4542 | player->SetQuestSlot(slot,0); |
---|
| 4543 | |
---|
| 4544 | // we ignore unequippable quest items in this case, its' still be equipped |
---|
| 4545 | player->TakeQuestSourceItem( quest, false ); |
---|
| 4546 | } |
---|
| 4547 | } |
---|
| 4548 | |
---|
| 4549 | // set quest status to not started (will updated in DB at next save) |
---|
| 4550 | player->SetQuestStatus( entry, QUEST_STATUS_NONE); |
---|
| 4551 | |
---|
| 4552 | // reset rewarded for restart repeatable quest |
---|
| 4553 | player->getQuestStatusMap()[entry].m_rewarded = false; |
---|
| 4554 | |
---|
| 4555 | SendSysMessage(LANG_COMMAND_QUEST_REMOVED); |
---|
| 4556 | return true; |
---|
| 4557 | } |
---|
| 4558 | |
---|
| 4559 | bool ChatHandler::HandleCompleteQuest(const char* args) |
---|
| 4560 | { |
---|
| 4561 | Player* player = getSelectedPlayer(); |
---|
| 4562 | if(!player) |
---|
| 4563 | { |
---|
| 4564 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 4565 | SetSentErrorMessage(true); |
---|
| 4566 | return false; |
---|
| 4567 | } |
---|
| 4568 | |
---|
| 4569 | // .quest complete #entry |
---|
| 4570 | // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r |
---|
| 4571 | char* cId = extractKeyFromLink((char*)args,"Hquest"); |
---|
| 4572 | if(!cId) |
---|
| 4573 | return false; |
---|
| 4574 | |
---|
| 4575 | uint32 entry = atol(cId); |
---|
| 4576 | |
---|
| 4577 | Quest const* pQuest = objmgr.GetQuestTemplate(entry); |
---|
| 4578 | |
---|
| 4579 | // If player doesn't have the quest |
---|
| 4580 | if(!pQuest || player->GetQuestStatus(entry) == QUEST_STATUS_NONE) |
---|
| 4581 | { |
---|
| 4582 | PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); |
---|
| 4583 | SetSentErrorMessage(true); |
---|
| 4584 | return false; |
---|
| 4585 | } |
---|
| 4586 | |
---|
| 4587 | // Add quest items for quests that require items |
---|
| 4588 | for(uint8 x = 0; x < QUEST_OBJECTIVES_COUNT; ++x) |
---|
| 4589 | { |
---|
| 4590 | uint32 id = pQuest->ReqItemId[x]; |
---|
| 4591 | uint32 count = pQuest->ReqItemCount[x]; |
---|
| 4592 | if(!id || !count) |
---|
| 4593 | continue; |
---|
| 4594 | |
---|
| 4595 | uint32 curItemCount = player->GetItemCount(id,true); |
---|
| 4596 | |
---|
| 4597 | ItemPosCountVec dest; |
---|
| 4598 | uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, id, count-curItemCount ); |
---|
| 4599 | if( msg == EQUIP_ERR_OK ) |
---|
| 4600 | { |
---|
| 4601 | Item* item = player->StoreNewItem( dest, id, true); |
---|
| 4602 | player->SendNewItem(item,count-curItemCount,true,false); |
---|
| 4603 | } |
---|
| 4604 | } |
---|
| 4605 | |
---|
| 4606 | // All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10") |
---|
| 4607 | for(uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++) |
---|
| 4608 | { |
---|
| 4609 | uint32 creature = pQuest->ReqCreatureOrGOId[i]; |
---|
| 4610 | uint32 creaturecount = pQuest->ReqCreatureOrGOCount[i]; |
---|
| 4611 | |
---|
| 4612 | if(uint32 spell_id = pQuest->ReqSpell[i]) |
---|
| 4613 | { |
---|
| 4614 | for(uint16 z = 0; z < creaturecount; ++z) |
---|
| 4615 | player->CastedCreatureOrGO(creature,0,spell_id); |
---|
| 4616 | } |
---|
| 4617 | else if(creature > 0) |
---|
| 4618 | { |
---|
| 4619 | for(uint16 z = 0; z < creaturecount; ++z) |
---|
| 4620 | player->KilledMonster(creature,0); |
---|
| 4621 | } |
---|
| 4622 | else if(creature < 0) |
---|
| 4623 | { |
---|
| 4624 | for(uint16 z = 0; z < creaturecount; ++z) |
---|
| 4625 | player->CastedCreatureOrGO(creature,0,0); |
---|
| 4626 | } |
---|
| 4627 | } |
---|
| 4628 | |
---|
| 4629 | // If the quest requires reputation to complete |
---|
| 4630 | if(uint32 repFaction = pQuest->GetRepObjectiveFaction()) |
---|
| 4631 | { |
---|
| 4632 | uint32 repValue = pQuest->GetRepObjectiveValue(); |
---|
| 4633 | uint32 curRep = player->GetReputation(repFaction); |
---|
| 4634 | if(curRep < repValue) |
---|
| 4635 | { |
---|
| 4636 | FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction); |
---|
| 4637 | player->SetFactionReputation(factionEntry,repValue); |
---|
| 4638 | } |
---|
| 4639 | } |
---|
| 4640 | |
---|
| 4641 | // If the quest requires money |
---|
| 4642 | int32 ReqOrRewMoney = pQuest->GetRewOrReqMoney(); |
---|
| 4643 | if(ReqOrRewMoney < 0) |
---|
| 4644 | player->ModifyMoney(-ReqOrRewMoney); |
---|
| 4645 | |
---|
| 4646 | player->CompleteQuest(entry); |
---|
| 4647 | return true; |
---|
| 4648 | } |
---|
| 4649 | |
---|
| 4650 | bool ChatHandler::HandleBanCommand(const char* args) |
---|
| 4651 | { |
---|
| 4652 | if(!args) |
---|
| 4653 | return false; |
---|
| 4654 | |
---|
| 4655 | char* type = strtok((char*)args, " "); |
---|
| 4656 | |
---|
| 4657 | if(!type) |
---|
| 4658 | return false; |
---|
| 4659 | char* nameOrIP = strtok(NULL, " "); |
---|
| 4660 | |
---|
| 4661 | if(!nameOrIP) |
---|
| 4662 | return false; |
---|
| 4663 | |
---|
| 4664 | char* duration = strtok(NULL," "); |
---|
| 4665 | if(!duration || !atoi(duration)) |
---|
| 4666 | return false; |
---|
| 4667 | |
---|
| 4668 | char* reason = strtok(NULL,""); |
---|
| 4669 | if(!reason) |
---|
| 4670 | return false; |
---|
| 4671 | |
---|
| 4672 | switch(sWorld.BanAccount(type, nameOrIP, duration, reason,m_session->GetPlayerName())) |
---|
| 4673 | { |
---|
| 4674 | case BAN_SUCCESS: |
---|
| 4675 | if(atoi(duration)>0) |
---|
| 4676 | PSendSysMessage(LANG_BAN_YOUBANNED,nameOrIP,secsToTimeString(TimeStringToSecs(duration),true).c_str(),reason); |
---|
| 4677 | else |
---|
| 4678 | PSendSysMessage(LANG_BAN_YOUPERMBANNED,nameOrIP,reason); |
---|
| 4679 | break; |
---|
| 4680 | case BAN_SYNTAX_ERROR: |
---|
| 4681 | return false; |
---|
| 4682 | case BAN_NOTFOUND: |
---|
| 4683 | PSendSysMessage(LANG_BAN_NOTFOUND,type,nameOrIP); |
---|
| 4684 | break; |
---|
| 4685 | } |
---|
| 4686 | |
---|
| 4687 | return true; |
---|
| 4688 | } |
---|
| 4689 | |
---|
| 4690 | bool ChatHandler::HandleUnBanCommand(const char* args) |
---|
| 4691 | { |
---|
| 4692 | if(!args) |
---|
| 4693 | return false; |
---|
| 4694 | char* type = strtok((char*)args, " "); |
---|
| 4695 | if(!type) |
---|
| 4696 | return false; |
---|
| 4697 | char* nameOrIP = strtok(NULL, " "); |
---|
| 4698 | |
---|
| 4699 | if(!nameOrIP) |
---|
| 4700 | return false; |
---|
| 4701 | |
---|
| 4702 | if(sWorld.RemoveBanAccount(type,nameOrIP)) |
---|
| 4703 | PSendSysMessage(LANG_UNBAN_UNBANNED,nameOrIP); |
---|
| 4704 | else |
---|
| 4705 | PSendSysMessage(LANG_UNBAN_ERROR,nameOrIP); |
---|
| 4706 | |
---|
| 4707 | return true; |
---|
| 4708 | } |
---|
| 4709 | |
---|
| 4710 | bool ChatHandler::HandleBanInfoCommand(const char* args) |
---|
| 4711 | { |
---|
| 4712 | if(!args) |
---|
| 4713 | return false; |
---|
| 4714 | |
---|
| 4715 | char* cType = strtok((char*)args, " "); |
---|
| 4716 | char* cnameOrIP = strtok(NULL, ""); |
---|
| 4717 | if(!cType || !cnameOrIP) |
---|
| 4718 | return false; |
---|
| 4719 | |
---|
| 4720 | std::string nameOrIP = cnameOrIP; |
---|
| 4721 | std::string type = cType; |
---|
| 4722 | if (!IsIPAddress(cnameOrIP) && type=="ip") |
---|
| 4723 | return false; |
---|
| 4724 | |
---|
| 4725 | Field *fields; |
---|
| 4726 | if(type != "ip") |
---|
| 4727 | { |
---|
| 4728 | //look the accountid up |
---|
| 4729 | uint32 accountid; |
---|
| 4730 | std::string accountname; |
---|
| 4731 | if(type == "account") |
---|
| 4732 | { |
---|
| 4733 | loginDatabase.escape_string(nameOrIP); |
---|
| 4734 | QueryResult *result = loginDatabase.PQuery("SELECT id, username FROM account WHERE username = '%s'",nameOrIP.c_str()); |
---|
| 4735 | if (!result) |
---|
| 4736 | { |
---|
| 4737 | PSendSysMessage(LANG_BANINFO_NOACCOUNT); |
---|
| 4738 | return true; |
---|
| 4739 | } |
---|
| 4740 | fields = result->Fetch(); |
---|
| 4741 | accountid = fields[0].GetUInt32(); |
---|
| 4742 | accountname = fields[1].GetCppString(); |
---|
| 4743 | delete result; |
---|
| 4744 | } |
---|
| 4745 | else if(type == "character") |
---|
| 4746 | { |
---|
| 4747 | if(!normalizePlayerName(nameOrIP)) |
---|
| 4748 | { |
---|
| 4749 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 4750 | SetSentErrorMessage(true); |
---|
| 4751 | return false; |
---|
| 4752 | } |
---|
| 4753 | |
---|
| 4754 | loginDatabase.escape_string(nameOrIP); |
---|
| 4755 | QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", nameOrIP.c_str()); |
---|
| 4756 | if (!result) |
---|
| 4757 | { |
---|
| 4758 | PSendSysMessage(LANG_BANINFO_NOCHARACTER); |
---|
| 4759 | return true; |
---|
| 4760 | } |
---|
| 4761 | fields = result->Fetch(); |
---|
| 4762 | accountid = fields[0].GetUInt32(); |
---|
| 4763 | delete result; |
---|
| 4764 | result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", accountid); |
---|
| 4765 | if (!result) |
---|
| 4766 | { |
---|
| 4767 | PSendSysMessage(LANG_BANINFO_NOCHARACTER); |
---|
| 4768 | return true; |
---|
| 4769 | } |
---|
| 4770 | fields = result->Fetch(); |
---|
| 4771 | accountname = fields[0].GetCppString(); |
---|
| 4772 | delete result; |
---|
| 4773 | } |
---|
| 4774 | else |
---|
| 4775 | return false; |
---|
| 4776 | |
---|
| 4777 | QueryResult *result = loginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC",accountid); |
---|
| 4778 | if(!result) |
---|
| 4779 | { |
---|
| 4780 | PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN, accountname.c_str()); |
---|
| 4781 | return true; |
---|
| 4782 | } |
---|
| 4783 | |
---|
| 4784 | PSendSysMessage(LANG_BANINFO_BANHISTORY,accountname.c_str()); |
---|
| 4785 | do |
---|
| 4786 | { |
---|
| 4787 | fields = result->Fetch(); |
---|
| 4788 | |
---|
| 4789 | time_t unbandate = time_t(fields[3].GetUInt64()); |
---|
| 4790 | bool active = false; |
---|
| 4791 | if(fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= time(NULL)) ) |
---|
| 4792 | active = true; |
---|
| 4793 | bool permanent = (fields[1].GetUInt64() == (uint64)0); |
---|
[44] | 4794 | std::string bantime = permanent?GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[1].GetUInt64(), true); |
---|
[37] | 4795 | PSendSysMessage(LANG_BANINFO_HISTORYENTRY, |
---|
[44] | 4796 | fields[0].GetString(), bantime.c_str(), active ? GetTrinityString(LANG_BANINFO_YES):GetTrinityString(LANG_BANINFO_NO), fields[4].GetString(), fields[5].GetString()); |
---|
[37] | 4797 | }while (result->NextRow()); |
---|
| 4798 | |
---|
| 4799 | delete result; |
---|
| 4800 | } |
---|
| 4801 | else |
---|
| 4802 | { |
---|
| 4803 | loginDatabase.escape_string(nameOrIP); |
---|
| 4804 | QueryResult *result = loginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",nameOrIP.c_str()); |
---|
| 4805 | if(!result) |
---|
| 4806 | { |
---|
| 4807 | PSendSysMessage(LANG_BANINFO_NOIP); |
---|
| 4808 | return true; |
---|
| 4809 | } |
---|
| 4810 | fields = result->Fetch(); |
---|
| 4811 | bool permanent = (fields[6].GetUInt64()==(uint64)0); |
---|
| 4812 | PSendSysMessage(LANG_BANINFO_IPENTRY, |
---|
[44] | 4813 | fields[0].GetString(), fields[1].GetString(), permanent ? GetTrinityString(LANG_BANINFO_NEVER):fields[2].GetString(), |
---|
| 4814 | permanent ? GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString()); |
---|
[37] | 4815 | delete result; |
---|
| 4816 | } |
---|
| 4817 | return true; |
---|
| 4818 | } |
---|
| 4819 | |
---|
| 4820 | bool ChatHandler::HandleBanListCommand(const char* args) |
---|
| 4821 | { |
---|
| 4822 | loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); |
---|
| 4823 | if(!*args) |
---|
| 4824 | return false; |
---|
| 4825 | char* cType = strtok((char*)args, " "); |
---|
| 4826 | char* cFilter = strtok(NULL, ""); |
---|
| 4827 | if(!cType || !cFilter) |
---|
| 4828 | return false; |
---|
| 4829 | std::string Filter = cFilter; |
---|
| 4830 | std::string Type = cType; |
---|
| 4831 | loginDatabase.escape_string(Filter); |
---|
| 4832 | |
---|
| 4833 | QueryResult* result = NULL; |
---|
| 4834 | Field *fields = NULL; |
---|
| 4835 | if(Type == "ip") |
---|
| 4836 | { |
---|
| 4837 | result = loginDatabase.PQuery("SELECT ip FROM ip_banned WHERE ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),Filter.c_str()); |
---|
| 4838 | if(!result) |
---|
| 4839 | { |
---|
| 4840 | PSendSysMessage(LANG_BANLIST_NOIP); |
---|
| 4841 | return true; |
---|
| 4842 | } |
---|
| 4843 | PSendSysMessage(LANG_BANLIST_MATCHINGIP); |
---|
| 4844 | do |
---|
| 4845 | { |
---|
| 4846 | fields = result->Fetch(); |
---|
| 4847 | PSendSysMessage("%s",fields[0].GetString()); |
---|
| 4848 | } while (result->NextRow()); |
---|
| 4849 | |
---|
| 4850 | delete result; |
---|
| 4851 | return true; |
---|
| 4852 | } |
---|
| 4853 | //lookup accountid |
---|
| 4854 | if(Type == "account") |
---|
| 4855 | { |
---|
| 4856 | result = loginDatabase.PQuery("SELECT id FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),Filter.c_str()); |
---|
| 4857 | if (!result) |
---|
| 4858 | { |
---|
| 4859 | PSendSysMessage(LANG_BANLIST_NOACCOUNT); |
---|
| 4860 | return true; |
---|
| 4861 | } |
---|
| 4862 | //do not delete result |
---|
| 4863 | } |
---|
| 4864 | else if(Type == "characters") |
---|
| 4865 | { |
---|
| 4866 | result = CharacterDatabase.PQuery("SELECT account FROM characters, WHERE name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),Filter.c_str()); |
---|
| 4867 | if (!result) |
---|
| 4868 | { |
---|
| 4869 | PSendSysMessage(LANG_BANLIST_NOCHARACTER); |
---|
| 4870 | return true; |
---|
| 4871 | } |
---|
| 4872 | } |
---|
| 4873 | else |
---|
| 4874 | return false; |
---|
| 4875 | |
---|
| 4876 | PSendSysMessage(LANG_BANLIST_MATCHINGACCOUNT); |
---|
| 4877 | do |
---|
| 4878 | { |
---|
| 4879 | fields = result->Fetch(); |
---|
| 4880 | uint32 accountid = fields[0].GetUInt32(); |
---|
| 4881 | QueryResult* banresult = loginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.active = '1' AND account_banned.id=account.id",accountid); |
---|
| 4882 | if(banresult) |
---|
| 4883 | { |
---|
| 4884 | Field* fields2 = banresult->Fetch(); |
---|
| 4885 | PSendSysMessage("%s",fields2[0].GetString()); |
---|
| 4886 | delete banresult; |
---|
| 4887 | } |
---|
| 4888 | } while (result->NextRow()); |
---|
| 4889 | |
---|
| 4890 | delete result; |
---|
| 4891 | return true; |
---|
| 4892 | } |
---|
| 4893 | |
---|
| 4894 | bool ChatHandler::HandleRespawnCommand(const char* /*args*/) |
---|
| 4895 | { |
---|
[40] | 4896 | Unit* target = getSelectedUnit(); |
---|
| 4897 | |
---|
| 4898 | if(target && target->GetTypeId() == TYPEID_UNIT && target->isDead()) |
---|
| 4899 | { |
---|
| 4900 | ((Creature*)target)->Respawn(); |
---|
| 4901 | return true; |
---|
| 4902 | } |
---|
| 4903 | |
---|
[37] | 4904 | Player* pl = m_session->GetPlayer(); |
---|
| 4905 | |
---|
[44] | 4906 | CellPair p(Trinity::ComputeCellPair(pl->GetPositionX(), pl->GetPositionY())); |
---|
[37] | 4907 | Cell cell(p); |
---|
| 4908 | cell.data.Part.reserved = ALL_DISTRICT; |
---|
| 4909 | cell.SetNoCreate(); |
---|
| 4910 | |
---|
[44] | 4911 | Trinity::RespawnDo u_do; |
---|
| 4912 | Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(u_do); |
---|
[37] | 4913 | |
---|
[44] | 4914 | TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker); |
---|
[37] | 4915 | CellLock<GridReadGuard> cell_lock(cell, p); |
---|
| 4916 | cell_lock->Visit(cell_lock, obj_worker, *MapManager::Instance().GetMap(pl->GetMapId(), pl)); |
---|
| 4917 | |
---|
| 4918 | return true; |
---|
| 4919 | } |
---|
| 4920 | |
---|
| 4921 | bool ChatHandler::HandleFlyModeCommand(const char* args) |
---|
| 4922 | { |
---|
| 4923 | if(!args) |
---|
| 4924 | return false; |
---|
| 4925 | |
---|
| 4926 | Unit *unit = getSelectedUnit(); |
---|
| 4927 | if (!unit || (unit->GetTypeId() != TYPEID_PLAYER)) |
---|
| 4928 | unit = m_session->GetPlayer(); |
---|
| 4929 | |
---|
| 4930 | WorldPacket data(12); |
---|
| 4931 | if (strncmp(args, "on", 3) == 0) |
---|
| 4932 | data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); |
---|
| 4933 | else if (strncmp(args, "off", 4) == 0) |
---|
| 4934 | data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); |
---|
| 4935 | else |
---|
| 4936 | { |
---|
| 4937 | SendSysMessage(LANG_USE_BOL); |
---|
| 4938 | return false; |
---|
| 4939 | } |
---|
| 4940 | data.append(unit->GetPackGUID()); |
---|
| 4941 | data << uint32(0); // unknown |
---|
| 4942 | unit->SendMessageToSet(&data, true); |
---|
| 4943 | PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, unit->GetName(), args); |
---|
| 4944 | return true; |
---|
| 4945 | } |
---|
| 4946 | |
---|
| 4947 | bool ChatHandler::HandleLoadPDumpCommand(const char *args) |
---|
| 4948 | { |
---|
| 4949 | if(!args) |
---|
| 4950 | return false; |
---|
| 4951 | |
---|
| 4952 | char * file = strtok((char*)args, " "); if(!file) return false; |
---|
| 4953 | char * acc = strtok(NULL, " "); if(!acc) return false; |
---|
| 4954 | if(!file || !acc) |
---|
| 4955 | return false; |
---|
| 4956 | |
---|
| 4957 | uint32 account_id = objmgr.GetAccountByAccountName(acc); |
---|
| 4958 | if(!account_id) |
---|
| 4959 | { |
---|
| 4960 | account_id = atoi(acc); |
---|
| 4961 | if(account_id) |
---|
| 4962 | { |
---|
| 4963 | std::string acc_name; |
---|
| 4964 | if(!objmgr.GetAccountNameByAccount(account_id,acc_name)) |
---|
| 4965 | return false; |
---|
| 4966 | } |
---|
| 4967 | else |
---|
| 4968 | return false; |
---|
| 4969 | } |
---|
| 4970 | |
---|
| 4971 | char * name = strtok(NULL, " "); |
---|
| 4972 | char * guid_str = name ? strtok(NULL, " ") : NULL; |
---|
| 4973 | |
---|
| 4974 | uint32 guid = guid_str ? atoi(guid_str) : 0; |
---|
| 4975 | |
---|
| 4976 | if(PlayerDumpReader().LoadDump(file, account_id, name ? name : "", guid)) |
---|
| 4977 | PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS); |
---|
| 4978 | else |
---|
| 4979 | PSendSysMessage(LANG_COMMAND_IMPORT_FAILED); |
---|
| 4980 | |
---|
| 4981 | return true; |
---|
| 4982 | } |
---|
| 4983 | |
---|
| 4984 | bool ChatHandler::HandleChangeEntryCommand(const char *args) |
---|
| 4985 | { |
---|
| 4986 | if(!args) |
---|
| 4987 | return false; |
---|
| 4988 | |
---|
| 4989 | uint32 newEntryNum = atoi(args); |
---|
| 4990 | if(!newEntryNum) |
---|
| 4991 | return false; |
---|
| 4992 | |
---|
| 4993 | Unit* unit = getSelectedUnit(); |
---|
| 4994 | if(!unit || unit->GetTypeId() != TYPEID_UNIT) |
---|
| 4995 | { |
---|
| 4996 | SendSysMessage(LANG_SELECT_CREATURE); |
---|
| 4997 | SetSentErrorMessage(true); |
---|
| 4998 | return false; |
---|
| 4999 | } |
---|
| 5000 | Creature* creature = (Creature*)unit; |
---|
| 5001 | if(creature->UpdateEntry(newEntryNum)) |
---|
| 5002 | SendSysMessage(LANG_DONE); |
---|
| 5003 | else |
---|
| 5004 | SendSysMessage(LANG_ERROR); |
---|
| 5005 | return true; |
---|
| 5006 | } |
---|
| 5007 | |
---|
| 5008 | bool ChatHandler::HandleWritePDumpCommand(const char *args) |
---|
| 5009 | { |
---|
| 5010 | if(!args) |
---|
| 5011 | return false; |
---|
| 5012 | |
---|
| 5013 | char* file = strtok((char*)args, " "); |
---|
| 5014 | char* p2 = strtok(NULL, " "); |
---|
| 5015 | |
---|
| 5016 | if(!file || !p2) |
---|
| 5017 | return false; |
---|
| 5018 | |
---|
| 5019 | uint32 guid = objmgr.GetPlayerGUIDByName(p2); |
---|
| 5020 | if(!guid) |
---|
| 5021 | guid = atoi(p2); |
---|
| 5022 | |
---|
| 5023 | if (PlayerDumpWriter().WriteDump(file, guid)) |
---|
| 5024 | PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS); |
---|
| 5025 | else |
---|
| 5026 | PSendSysMessage(LANG_COMMAND_EXPORT_FAILED); |
---|
| 5027 | |
---|
| 5028 | return true; |
---|
| 5029 | } |
---|
| 5030 | |
---|
| 5031 | bool ChatHandler::HandleMovegensCommand(const char* /*args*/) |
---|
| 5032 | { |
---|
| 5033 | Unit* unit = getSelectedUnit(); |
---|
| 5034 | if(!unit) |
---|
| 5035 | { |
---|
| 5036 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 5037 | SetSentErrorMessage(true); |
---|
| 5038 | return false; |
---|
| 5039 | } |
---|
| 5040 | |
---|
| 5041 | PSendSysMessage(LANG_MOVEGENS_LIST,(unit->GetTypeId()==TYPEID_PLAYER ? "Player" : "Creature" ),unit->GetGUIDLow()); |
---|
| 5042 | |
---|
| 5043 | MotionMaster* mm = unit->GetMotionMaster(); |
---|
| 5044 | for(MotionMaster::const_iterator itr = mm->begin(); itr != mm->end(); ++itr) |
---|
| 5045 | { |
---|
| 5046 | switch((*itr)->GetMovementGeneratorType()) |
---|
| 5047 | { |
---|
| 5048 | case IDLE_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_IDLE); break; |
---|
| 5049 | case RANDOM_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_RANDOM); break; |
---|
| 5050 | case WAYPOINT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_WAYPOINT); break; |
---|
| 5051 | case ANIMAL_RANDOM_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_ANIMAL_RANDOM); break; |
---|
| 5052 | case CONFUSED_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_CONFUSED); break; |
---|
| 5053 | case TARGETED_MOTION_TYPE: |
---|
| 5054 | { |
---|
| 5055 | if(unit->GetTypeId()==TYPEID_PLAYER) |
---|
| 5056 | { |
---|
| 5057 | TargetedMovementGenerator<Player> const* mgen = static_cast<TargetedMovementGenerator<Player> const*>(*itr); |
---|
| 5058 | Unit* target = mgen->GetTarget(); |
---|
| 5059 | if(target) |
---|
| 5060 | PSendSysMessage(LANG_MOVEGENS_TARGETED_PLAYER,target->GetName(),target->GetGUIDLow()); |
---|
| 5061 | else |
---|
| 5062 | SendSysMessage(LANG_MOVEGENS_TARGETED_NULL); |
---|
| 5063 | } |
---|
| 5064 | else |
---|
| 5065 | { |
---|
| 5066 | TargetedMovementGenerator<Creature> const* mgen = static_cast<TargetedMovementGenerator<Creature> const*>(*itr); |
---|
| 5067 | Unit* target = mgen->GetTarget(); |
---|
| 5068 | if(target) |
---|
| 5069 | PSendSysMessage(LANG_MOVEGENS_TARGETED_CREATURE,target->GetName(),target->GetGUIDLow()); |
---|
| 5070 | else |
---|
| 5071 | SendSysMessage(LANG_MOVEGENS_TARGETED_NULL); |
---|
| 5072 | } |
---|
| 5073 | break; |
---|
| 5074 | } |
---|
| 5075 | case HOME_MOTION_TYPE: |
---|
| 5076 | if(unit->GetTypeId()==TYPEID_UNIT) |
---|
| 5077 | { |
---|
| 5078 | float x,y,z; |
---|
| 5079 | (*itr)->GetDestination(x,y,z); |
---|
| 5080 | PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE,x,y,z); |
---|
| 5081 | } |
---|
| 5082 | else |
---|
| 5083 | SendSysMessage(LANG_MOVEGENS_HOME_PLAYER); |
---|
| 5084 | break; |
---|
| 5085 | case FLIGHT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FLIGHT); break; |
---|
| 5086 | case POINT_MOTION_TYPE: |
---|
| 5087 | { |
---|
| 5088 | float x,y,z; |
---|
| 5089 | (*itr)->GetDestination(x,y,z); |
---|
| 5090 | PSendSysMessage(LANG_MOVEGENS_POINT,x,y,z); |
---|
| 5091 | break; |
---|
| 5092 | } |
---|
| 5093 | case FLEEING_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FEAR); break; |
---|
| 5094 | case DISTRACT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_DISTRACT); break; |
---|
| 5095 | default: |
---|
| 5096 | PSendSysMessage(LANG_MOVEGENS_UNKNOWN,(*itr)->GetMovementGeneratorType()); |
---|
| 5097 | break; |
---|
| 5098 | } |
---|
| 5099 | } |
---|
| 5100 | return true; |
---|
| 5101 | } |
---|
| 5102 | |
---|
| 5103 | bool ChatHandler::HandlePLimitCommand(const char *args) |
---|
| 5104 | { |
---|
| 5105 | if(*args) |
---|
| 5106 | { |
---|
| 5107 | char* param = strtok((char*)args, " "); |
---|
| 5108 | if(!param) |
---|
| 5109 | return false; |
---|
| 5110 | |
---|
| 5111 | int l = strlen(param); |
---|
| 5112 | |
---|
| 5113 | if( strncmp(param,"player",l) == 0 ) |
---|
| 5114 | sWorld.SetPlayerLimit(-SEC_PLAYER); |
---|
| 5115 | else if(strncmp(param,"moderator",l) == 0 ) |
---|
| 5116 | sWorld.SetPlayerLimit(-SEC_MODERATOR); |
---|
| 5117 | else if(strncmp(param,"gamemaster",l) == 0 ) |
---|
| 5118 | sWorld.SetPlayerLimit(-SEC_GAMEMASTER); |
---|
| 5119 | else if(strncmp(param,"administrator",l) == 0 ) |
---|
| 5120 | sWorld.SetPlayerLimit(-SEC_ADMINISTRATOR); |
---|
| 5121 | else if(strncmp(param,"reset",l) == 0 ) |
---|
| 5122 | sWorld.SetPlayerLimit( sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT) ); |
---|
| 5123 | else |
---|
| 5124 | { |
---|
| 5125 | int val = atoi(param); |
---|
| 5126 | if(val < -SEC_ADMINISTRATOR) val = -SEC_ADMINISTRATOR; |
---|
| 5127 | |
---|
| 5128 | sWorld.SetPlayerLimit(val); |
---|
| 5129 | } |
---|
| 5130 | |
---|
| 5131 | // kick all low security level players |
---|
| 5132 | if(sWorld.GetPlayerAmountLimit() > SEC_PLAYER) |
---|
| 5133 | sWorld.KickAllLess(sWorld.GetPlayerSecurityLimit()); |
---|
| 5134 | } |
---|
| 5135 | |
---|
| 5136 | uint32 pLimit = sWorld.GetPlayerAmountLimit(); |
---|
| 5137 | AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit(); |
---|
| 5138 | char const* secName = ""; |
---|
| 5139 | switch(allowedAccountType) |
---|
| 5140 | { |
---|
| 5141 | case SEC_PLAYER: secName = "Player"; break; |
---|
| 5142 | case SEC_MODERATOR: secName = "Moderator"; break; |
---|
| 5143 | case SEC_GAMEMASTER: secName = "Gamemaster"; break; |
---|
| 5144 | case SEC_ADMINISTRATOR: secName = "Administrator"; break; |
---|
| 5145 | default: secName = "<unknown>"; break; |
---|
| 5146 | } |
---|
| 5147 | |
---|
| 5148 | PSendSysMessage("Player limits: amount %u, min. security level %s.",pLimit,secName); |
---|
| 5149 | |
---|
| 5150 | return true; |
---|
| 5151 | } |
---|
| 5152 | |
---|
| 5153 | bool ChatHandler::HandleCastCommand(const char* args) |
---|
| 5154 | { |
---|
| 5155 | if(!*args) |
---|
| 5156 | return false; |
---|
| 5157 | |
---|
| 5158 | Unit* target = getSelectedUnit(); |
---|
| 5159 | |
---|
| 5160 | if(!target) |
---|
| 5161 | { |
---|
| 5162 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 5163 | SetSentErrorMessage(true); |
---|
| 5164 | return false; |
---|
| 5165 | } |
---|
| 5166 | |
---|
| 5167 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
| 5168 | uint32 spell = extractSpellIdFromLink((char*)args); |
---|
| 5169 | if(!spell) |
---|
| 5170 | return false; |
---|
| 5171 | |
---|
| 5172 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); |
---|
| 5173 | if(!spellInfo) |
---|
| 5174 | return false; |
---|
| 5175 | |
---|
| 5176 | if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) |
---|
| 5177 | { |
---|
| 5178 | PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); |
---|
| 5179 | SetSentErrorMessage(true); |
---|
| 5180 | return false; |
---|
| 5181 | } |
---|
| 5182 | |
---|
| 5183 | char* trig_str = strtok(NULL, " "); |
---|
| 5184 | if(trig_str) |
---|
| 5185 | { |
---|
| 5186 | int l = strlen(trig_str); |
---|
| 5187 | if(strncmp(trig_str,"triggered",l) != 0 ) |
---|
| 5188 | return false; |
---|
| 5189 | } |
---|
| 5190 | |
---|
| 5191 | bool triggered = (trig_str != NULL); |
---|
| 5192 | |
---|
| 5193 | m_session->GetPlayer()->CastSpell(target,spell,triggered); |
---|
| 5194 | |
---|
| 5195 | return true; |
---|
| 5196 | } |
---|
| 5197 | |
---|
| 5198 | bool ChatHandler::HandleCastBackCommand(const char* args) |
---|
| 5199 | { |
---|
| 5200 | Creature* caster = getSelectedCreature(); |
---|
| 5201 | |
---|
| 5202 | if(!caster) |
---|
| 5203 | { |
---|
| 5204 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 5205 | SetSentErrorMessage(true); |
---|
| 5206 | return false; |
---|
| 5207 | } |
---|
| 5208 | |
---|
| 5209 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r |
---|
| 5210 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
| 5211 | uint32 spell = extractSpellIdFromLink((char*)args); |
---|
| 5212 | if(!spell || !sSpellStore.LookupEntry(spell)) |
---|
| 5213 | return false; |
---|
| 5214 | |
---|
| 5215 | char* trig_str = strtok(NULL, " "); |
---|
| 5216 | if(trig_str) |
---|
| 5217 | { |
---|
| 5218 | int l = strlen(trig_str); |
---|
| 5219 | if(strncmp(trig_str,"triggered",l) != 0 ) |
---|
| 5220 | return false; |
---|
| 5221 | } |
---|
| 5222 | |
---|
| 5223 | bool triggered = (trig_str != NULL); |
---|
| 5224 | |
---|
| 5225 | // update orientation at server |
---|
| 5226 | caster->SetOrientation(caster->GetAngle(m_session->GetPlayer())); |
---|
| 5227 | |
---|
| 5228 | // and client |
---|
| 5229 | WorldPacket data; |
---|
| 5230 | caster->BuildHeartBeatMsg(&data); |
---|
| 5231 | caster->SendMessageToSet(&data,true); |
---|
| 5232 | |
---|
| 5233 | caster->CastSpell(m_session->GetPlayer(),spell,false); |
---|
| 5234 | |
---|
| 5235 | return true; |
---|
| 5236 | } |
---|
| 5237 | |
---|
| 5238 | bool ChatHandler::HandleCastDistCommand(const char* args) |
---|
| 5239 | { |
---|
| 5240 | if(!*args) |
---|
| 5241 | return false; |
---|
| 5242 | |
---|
| 5243 | |
---|
| 5244 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
| 5245 | uint32 spell = extractSpellIdFromLink((char*)args); |
---|
| 5246 | if(!spell) |
---|
| 5247 | return false; |
---|
| 5248 | |
---|
| 5249 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); |
---|
| 5250 | if(!spellInfo) |
---|
| 5251 | return false; |
---|
| 5252 | |
---|
| 5253 | if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) |
---|
| 5254 | { |
---|
| 5255 | PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); |
---|
| 5256 | SetSentErrorMessage(true); |
---|
| 5257 | return false; |
---|
| 5258 | } |
---|
| 5259 | |
---|
| 5260 | char *distStr = strtok(NULL, " "); |
---|
| 5261 | |
---|
| 5262 | float dist = 0; |
---|
| 5263 | |
---|
| 5264 | if(distStr) |
---|
| 5265 | sscanf(distStr, "%f", &dist); |
---|
| 5266 | |
---|
| 5267 | char* trig_str = strtok(NULL, " "); |
---|
| 5268 | if(trig_str) |
---|
| 5269 | { |
---|
| 5270 | int l = strlen(trig_str); |
---|
| 5271 | if(strncmp(trig_str,"triggered",l) != 0 ) |
---|
| 5272 | return false; |
---|
| 5273 | } |
---|
| 5274 | |
---|
| 5275 | bool triggered = (trig_str != NULL); |
---|
| 5276 | |
---|
| 5277 | float x,y,z; |
---|
| 5278 | m_session->GetPlayer()->GetClosePoint(x,y,z,dist); |
---|
| 5279 | |
---|
| 5280 | m_session->GetPlayer()->CastSpell(x,y,z,spell,triggered); |
---|
| 5281 | return true; |
---|
| 5282 | } |
---|
| 5283 | |
---|
| 5284 | bool ChatHandler::HandleCastTargetCommand(const char* args) |
---|
| 5285 | { |
---|
| 5286 | Creature* caster = getSelectedCreature(); |
---|
| 5287 | |
---|
| 5288 | if(!caster) |
---|
| 5289 | { |
---|
| 5290 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 5291 | SetSentErrorMessage(true); |
---|
| 5292 | return false; |
---|
| 5293 | } |
---|
| 5294 | |
---|
| 5295 | if(!caster->getVictim()) |
---|
| 5296 | { |
---|
| 5297 | SendSysMessage(LANG_SELECTED_TARGET_NOT_HAVE_VICTIM); |
---|
| 5298 | SetSentErrorMessage(true); |
---|
| 5299 | return false; |
---|
| 5300 | } |
---|
| 5301 | |
---|
| 5302 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
| 5303 | uint32 spell = extractSpellIdFromLink((char*)args); |
---|
| 5304 | if(!spell || !sSpellStore.LookupEntry(spell)) |
---|
| 5305 | return false; |
---|
| 5306 | |
---|
| 5307 | char* trig_str = strtok(NULL, " "); |
---|
| 5308 | if(trig_str) |
---|
| 5309 | { |
---|
| 5310 | int l = strlen(trig_str); |
---|
| 5311 | if(strncmp(trig_str,"triggered",l) != 0 ) |
---|
| 5312 | return false; |
---|
| 5313 | } |
---|
| 5314 | |
---|
| 5315 | bool triggered = (trig_str != NULL); |
---|
| 5316 | |
---|
| 5317 | // update orientation at server |
---|
| 5318 | caster->SetOrientation(caster->GetAngle(m_session->GetPlayer())); |
---|
| 5319 | |
---|
| 5320 | // and client |
---|
| 5321 | WorldPacket data; |
---|
| 5322 | caster->BuildHeartBeatMsg(&data); |
---|
| 5323 | caster->SendMessageToSet(&data,true); |
---|
| 5324 | |
---|
| 5325 | caster->CastSpell(caster->getVictim(),spell,false); |
---|
| 5326 | |
---|
| 5327 | return true; |
---|
| 5328 | } |
---|
| 5329 | |
---|
| 5330 | /* |
---|
| 5331 | ComeToMe command REQUIRED for 3rd party scripting library to have access to PointMovementGenerator |
---|
| 5332 | Without this function 3rd party scripting library will get linking errors (unresolved external) |
---|
| 5333 | when attempting to use the PointMovementGenerator |
---|
| 5334 | */ |
---|
| 5335 | bool ChatHandler::HandleComeToMeCommand(const char *args) |
---|
| 5336 | { |
---|
| 5337 | Creature* caster = getSelectedCreature(); |
---|
| 5338 | |
---|
| 5339 | if(!caster) |
---|
| 5340 | { |
---|
| 5341 | SendSysMessage(LANG_SELECT_CREATURE); |
---|
| 5342 | SetSentErrorMessage(true); |
---|
| 5343 | return false; |
---|
| 5344 | } |
---|
| 5345 | |
---|
| 5346 | char* newFlagStr = strtok((char*)args, " "); |
---|
| 5347 | |
---|
| 5348 | if(!newFlagStr) |
---|
| 5349 | return false; |
---|
| 5350 | |
---|
| 5351 | uint32 newFlags = atoi(newFlagStr); |
---|
| 5352 | |
---|
| 5353 | caster->SetUnitMovementFlags(newFlags); |
---|
| 5354 | |
---|
| 5355 | Player* pl = m_session->GetPlayer(); |
---|
| 5356 | |
---|
| 5357 | caster->GetMotionMaster()->MovePoint(0, pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ()); |
---|
| 5358 | return true; |
---|
| 5359 | } |
---|
| 5360 | |
---|
| 5361 | bool ChatHandler::HandleCastSelfCommand(const char* args) |
---|
| 5362 | { |
---|
| 5363 | if(!*args) |
---|
| 5364 | return false; |
---|
| 5365 | |
---|
| 5366 | Unit* target = getSelectedUnit(); |
---|
| 5367 | |
---|
| 5368 | if(!target) |
---|
| 5369 | { |
---|
| 5370 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 5371 | SetSentErrorMessage(true); |
---|
| 5372 | return false; |
---|
| 5373 | } |
---|
| 5374 | |
---|
| 5375 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
| 5376 | uint32 spell = extractSpellIdFromLink((char*)args); |
---|
| 5377 | if(!spell) |
---|
| 5378 | return false; |
---|
| 5379 | |
---|
| 5380 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); |
---|
| 5381 | if(!spellInfo) |
---|
| 5382 | return false; |
---|
| 5383 | |
---|
| 5384 | if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) |
---|
| 5385 | { |
---|
| 5386 | PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); |
---|
| 5387 | SetSentErrorMessage(true); |
---|
| 5388 | return false; |
---|
| 5389 | } |
---|
| 5390 | |
---|
| 5391 | target->CastSpell(target,spell,false); |
---|
| 5392 | |
---|
| 5393 | return true; |
---|
| 5394 | } |
---|
| 5395 | |
---|
| 5396 | std::string GetTimeString(uint32 time) |
---|
| 5397 | { |
---|
| 5398 | uint16 days = time / DAY, hours = (time % DAY) / HOUR, minute = (time % HOUR) / MINUTE; |
---|
| 5399 | std::ostringstream ss; |
---|
| 5400 | if(days) ss << days << "d "; |
---|
| 5401 | if(hours) ss << hours << "h "; |
---|
| 5402 | ss << minute << "m"; |
---|
| 5403 | return ss.str(); |
---|
| 5404 | } |
---|
| 5405 | |
---|
| 5406 | bool ChatHandler::HandleInstanceListBindsCommand(const char* /*args*/) |
---|
| 5407 | { |
---|
| 5408 | Player* player = getSelectedPlayer(); |
---|
| 5409 | if (!player) player = m_session->GetPlayer(); |
---|
| 5410 | uint32 counter = 0; |
---|
| 5411 | for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) |
---|
| 5412 | { |
---|
| 5413 | Player::BoundInstancesMap &binds = player->GetBoundInstances(i); |
---|
| 5414 | for(Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end(); ++itr) |
---|
| 5415 | { |
---|
| 5416 | InstanceSave *save = itr->second.save; |
---|
| 5417 | std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); |
---|
| 5418 | PSendSysMessage("map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); |
---|
| 5419 | counter++; |
---|
| 5420 | } |
---|
| 5421 | } |
---|
| 5422 | PSendSysMessage("player binds: %d", counter); |
---|
| 5423 | counter = 0; |
---|
| 5424 | Group *group = player->GetGroup(); |
---|
| 5425 | if(group) |
---|
| 5426 | { |
---|
| 5427 | for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) |
---|
| 5428 | { |
---|
| 5429 | Group::BoundInstancesMap &binds = group->GetBoundInstances(i); |
---|
| 5430 | for(Group::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end(); ++itr) |
---|
| 5431 | { |
---|
| 5432 | InstanceSave *save = itr->second.save; |
---|
| 5433 | std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); |
---|
| 5434 | PSendSysMessage("map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); |
---|
| 5435 | counter++; |
---|
| 5436 | } |
---|
| 5437 | } |
---|
| 5438 | } |
---|
| 5439 | PSendSysMessage("group binds: %d", counter); |
---|
| 5440 | |
---|
| 5441 | return true; |
---|
| 5442 | } |
---|
| 5443 | |
---|
| 5444 | bool ChatHandler::HandleInstanceUnbindCommand(const char* args) |
---|
| 5445 | { |
---|
| 5446 | if(!*args) |
---|
| 5447 | return false; |
---|
| 5448 | |
---|
| 5449 | std::string cmd = args; |
---|
| 5450 | if(cmd == "all") |
---|
| 5451 | { |
---|
| 5452 | Player* player = getSelectedPlayer(); |
---|
| 5453 | if (!player) player = m_session->GetPlayer(); |
---|
| 5454 | uint32 counter = 0; |
---|
| 5455 | for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) |
---|
| 5456 | { |
---|
| 5457 | Player::BoundInstancesMap &binds = player->GetBoundInstances(i); |
---|
| 5458 | for(Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end();) |
---|
| 5459 | { |
---|
| 5460 | if(itr->first != player->GetMapId()) |
---|
| 5461 | { |
---|
| 5462 | InstanceSave *save = itr->second.save; |
---|
| 5463 | std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); |
---|
| 5464 | PSendSysMessage("unbinding map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); |
---|
| 5465 | player->UnbindInstance(itr, i); |
---|
| 5466 | counter++; |
---|
| 5467 | } |
---|
| 5468 | else |
---|
| 5469 | ++itr; |
---|
| 5470 | } |
---|
| 5471 | } |
---|
| 5472 | PSendSysMessage("instances unbound: %d", counter); |
---|
| 5473 | } |
---|
| 5474 | return true; |
---|
| 5475 | } |
---|
| 5476 | |
---|
| 5477 | bool ChatHandler::HandleInstanceStatsCommand(const char* /*args*/) |
---|
| 5478 | { |
---|
| 5479 | PSendSysMessage("instances loaded: %d", MapManager::Instance().GetNumInstances()); |
---|
| 5480 | PSendSysMessage("players in instances: %d", MapManager::Instance().GetNumPlayersInInstances()); |
---|
| 5481 | PSendSysMessage("instance saves: %d", sInstanceSaveManager.GetNumInstanceSaves()); |
---|
| 5482 | PSendSysMessage("players bound: %d", sInstanceSaveManager.GetNumBoundPlayersTotal()); |
---|
| 5483 | PSendSysMessage("groups bound: %d", sInstanceSaveManager.GetNumBoundGroupsTotal()); |
---|
| 5484 | return true; |
---|
| 5485 | } |
---|
| 5486 | |
---|
| 5487 | bool ChatHandler::HandleInstanceSaveDataCommand(const char * /*args*/) |
---|
| 5488 | { |
---|
| 5489 | Player* pl = m_session->GetPlayer(); |
---|
| 5490 | |
---|
| 5491 | Map* map = pl->GetMap(); |
---|
| 5492 | if (!map->IsDungeon()) |
---|
| 5493 | { |
---|
| 5494 | PSendSysMessage("Map is not a dungeon."); |
---|
| 5495 | SetSentErrorMessage(true); |
---|
| 5496 | return false; |
---|
| 5497 | } |
---|
| 5498 | |
---|
| 5499 | if (!((InstanceMap*)map)->GetInstanceData()) |
---|
| 5500 | { |
---|
| 5501 | PSendSysMessage("Map has no instance data."); |
---|
| 5502 | SetSentErrorMessage(true); |
---|
| 5503 | return false; |
---|
| 5504 | } |
---|
| 5505 | |
---|
| 5506 | ((InstanceMap*)map)->GetInstanceData()->SaveToDB(); |
---|
| 5507 | return true; |
---|
| 5508 | } |
---|
| 5509 | |
---|
[62] | 5510 | bool ChatHandler::HandleFreezeCommand(const char *args) |
---|
| 5511 | { |
---|
| 5512 | std::string name; |
---|
| 5513 | Player* player; |
---|
| 5514 | char* TargetName = strtok((char*)args, " "); //get entered name |
---|
| 5515 | if (!TargetName) //if no name entered use target |
---|
| 5516 | { |
---|
| 5517 | player = getSelectedPlayer(); |
---|
| 5518 | if (player) //prevent crash with creature as target |
---|
| 5519 | { |
---|
| 5520 | name = player->GetName(); |
---|
| 5521 | normalizePlayerName(name); |
---|
| 5522 | } |
---|
| 5523 | } |
---|
| 5524 | else // if name entered |
---|
| 5525 | { |
---|
| 5526 | name = TargetName; |
---|
| 5527 | normalizePlayerName(name); |
---|
| 5528 | player = objmgr.GetPlayer(name.c_str()); //get player by name |
---|
| 5529 | } |
---|
| 5530 | |
---|
| 5531 | if (!player) |
---|
| 5532 | { |
---|
| 5533 | SendSysMessage(LANG_COMMAND_FREEZE_WRONG); |
---|
| 5534 | return true; |
---|
| 5535 | } |
---|
| 5536 | |
---|
| 5537 | if (player==m_session->GetPlayer()) |
---|
| 5538 | { |
---|
| 5539 | SendSysMessage(LANG_COMMAND_FREEZE_ERROR); |
---|
| 5540 | return true; |
---|
| 5541 | } |
---|
| 5542 | |
---|
| 5543 | //effect |
---|
| 5544 | if ((player) && (!(player==m_session->GetPlayer()))) |
---|
| 5545 | { |
---|
| 5546 | PSendSysMessage(LANG_COMMAND_FREEZE,name.c_str()); |
---|
| 5547 | |
---|
| 5548 | //stop combat + make player unattackable + duel stop + stop some spells |
---|
| 5549 | player->setFaction(35); |
---|
| 5550 | player->CombatStop(); |
---|
| 5551 | if(player->IsNonMeleeSpellCasted(true)) |
---|
| 5552 | player->InterruptNonMeleeSpells(true); |
---|
| 5553 | player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); |
---|
| 5554 | player->SetUInt32Value(PLAYER_DUEL_TEAM, 1); |
---|
| 5555 | |
---|
| 5556 | //if player class = hunter || warlock remove pet if alive |
---|
| 5557 | if((player->getClass() == CLASS_HUNTER) || (player->getClass() == CLASS_WARLOCK)) |
---|
| 5558 | { |
---|
| 5559 | if(Pet* pet = player->GetPet()) |
---|
| 5560 | { |
---|
| 5561 | pet->SavePetToDB(PET_SAVE_AS_CURRENT); |
---|
| 5562 | // not let dismiss dead pet |
---|
| 5563 | if(pet && pet->isAlive()) |
---|
| 5564 | player->RemovePet(pet,PET_SAVE_NOT_IN_SLOT); |
---|
| 5565 | } |
---|
| 5566 | } |
---|
| 5567 | |
---|
| 5568 | //stop movement and disable spells |
---|
| 5569 | uint32 spellID = 9454; |
---|
| 5570 | //m_session->GetPlayer()->CastSpell(player,spellID,false); |
---|
| 5571 | SpellEntry const *spellInfo = sSpellStore.LookupEntry( spellID ); |
---|
| 5572 | if(spellInfo) //TODO: Change the duration of the aura to -1 instead of 5000000 |
---|
| 5573 | { |
---|
| 5574 | for(uint32 i = 0;i<3;i++) |
---|
| 5575 | { |
---|
| 5576 | uint8 eff = spellInfo->Effect[i]; |
---|
| 5577 | if (eff>=TOTAL_SPELL_EFFECTS) |
---|
| 5578 | continue; |
---|
| 5579 | if( eff == SPELL_EFFECT_APPLY_AREA_AURA_PARTY || eff == SPELL_EFFECT_APPLY_AURA || |
---|
| 5580 | eff == SPELL_EFFECT_PERSISTENT_AREA_AURA || eff == SPELL_EFFECT_APPLY_AREA_AURA_FRIEND || |
---|
| 5581 | eff == SPELL_EFFECT_APPLY_AREA_AURA_ENEMY) |
---|
| 5582 | { |
---|
| 5583 | Aura *Aur = CreateAura(spellInfo, i, NULL, player); |
---|
| 5584 | player->AddAura(Aur); |
---|
| 5585 | } |
---|
| 5586 | } |
---|
| 5587 | } |
---|
| 5588 | |
---|
| 5589 | //save player |
---|
| 5590 | player->SaveToDB(); |
---|
| 5591 | } |
---|
| 5592 | return true; |
---|
| 5593 | } |
---|
| 5594 | |
---|
| 5595 | bool ChatHandler::HandleUnFreezeCommand(const char *args) |
---|
| 5596 | { |
---|
| 5597 | std::string name; |
---|
| 5598 | Player* player; |
---|
| 5599 | char* TargetName = strtok((char*)args, " "); //get entered name |
---|
| 5600 | if (!TargetName) //if no name entered use target |
---|
| 5601 | { |
---|
| 5602 | player = getSelectedPlayer(); |
---|
| 5603 | if (player) //prevent crash with creature as target |
---|
| 5604 | { |
---|
| 5605 | name = player->GetName(); |
---|
| 5606 | } |
---|
| 5607 | } |
---|
| 5608 | |
---|
| 5609 | else // if name entered |
---|
| 5610 | { |
---|
| 5611 | name = TargetName; |
---|
| 5612 | normalizePlayerName(name); |
---|
| 5613 | player = objmgr.GetPlayer(name.c_str()); //get player by name |
---|
| 5614 | } |
---|
| 5615 | |
---|
| 5616 | //effect |
---|
| 5617 | if (player) |
---|
| 5618 | { |
---|
| 5619 | PSendSysMessage(LANG_COMMAND_UNFREEZE,name.c_str()); |
---|
| 5620 | |
---|
| 5621 | //Reset player faction + allow combat + allow duels |
---|
| 5622 | player->setFactionForRace(player->getRace()); |
---|
| 5623 | player->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); |
---|
| 5624 | |
---|
| 5625 | //allow movement and spells |
---|
| 5626 | uint32 spellID = 9454; |
---|
| 5627 | player->RemoveAurasDueToSpell(spellID); |
---|
| 5628 | |
---|
| 5629 | //save player |
---|
| 5630 | player->SaveToDB(); |
---|
| 5631 | } |
---|
| 5632 | |
---|
| 5633 | if (!player) |
---|
| 5634 | { |
---|
| 5635 | if (TargetName) |
---|
| 5636 | { |
---|
| 5637 | //check for offline players |
---|
| 5638 | QueryResult *result = CharacterDatabase.PQuery("SELECT characters.guid FROM `characters` WHERE characters.name = '%s'",name.c_str()); |
---|
| 5639 | if(!result) |
---|
| 5640 | { |
---|
| 5641 | SendSysMessage(LANG_COMMAND_FREEZE_WRONG); |
---|
| 5642 | return true; |
---|
| 5643 | } |
---|
| 5644 | //if player found: delete his freeze aura |
---|
| 5645 | Field *fields=result->Fetch(); |
---|
| 5646 | uint64 pguid = fields[0].GetUInt64(); |
---|
| 5647 | delete result; |
---|
| 5648 | CharacterDatabase.PQuery("DELETE FROM `character_aura` WHERE character_aura.spell = 9454 AND character_aura.guid = '%u'",pguid); |
---|
| 5649 | PSendSysMessage(LANG_COMMAND_UNFREEZE,name.c_str()); |
---|
| 5650 | return true; |
---|
| 5651 | } |
---|
| 5652 | else |
---|
| 5653 | { |
---|
| 5654 | SendSysMessage(LANG_COMMAND_FREEZE_WRONG); |
---|
| 5655 | return true; |
---|
| 5656 | } |
---|
| 5657 | } |
---|
| 5658 | |
---|
| 5659 | return true; |
---|
| 5660 | } |
---|
| 5661 | |
---|
| 5662 | bool ChatHandler::HandleListFreezeCommand(const char* args) |
---|
| 5663 | { |
---|
| 5664 | //Get names from DB |
---|
| 5665 | QueryResult *result = CharacterDatabase.PQuery("SELECT characters.name FROM `characters` LEFT JOIN `character_aura` ON (characters.guid = character_aura.guid) WHERE character_aura.spell = 9454"); |
---|
| 5666 | if(!result) |
---|
| 5667 | { |
---|
| 5668 | SendSysMessage(LANG_COMMAND_NO_FROZEN_PLAYERS); |
---|
| 5669 | return true; |
---|
| 5670 | } |
---|
| 5671 | //Header of the names |
---|
| 5672 | PSendSysMessage(LANG_COMMAND_LIST_FREEZE); |
---|
| 5673 | |
---|
| 5674 | //Output of the results |
---|
| 5675 | do |
---|
| 5676 | { |
---|
| 5677 | Field *fields = result->Fetch(); |
---|
| 5678 | std::string fplayers = fields[0].GetCppString(); |
---|
| 5679 | PSendSysMessage(LANG_COMMAND_FROZEN_PLAYERS,fplayers.c_str()); |
---|
| 5680 | } while (result->NextRow()); |
---|
| 5681 | |
---|
| 5682 | delete result; |
---|
| 5683 | return true; |
---|
| 5684 | } |
---|
| 5685 | |
---|
[37] | 5686 | bool ChatHandler::HandleFlushArenaPointsCommand(const char * /*args*/) |
---|
| 5687 | { |
---|
| 5688 | sBattleGroundMgr.DistributeArenaPoints(); |
---|
| 5689 | return true; |
---|
| 5690 | } |
---|
[42] | 5691 | |
---|
| 5692 | bool ChatHandler::HandleGroupLeaderCommand(const char* args) |
---|
| 5693 | { |
---|
| 5694 | Player* plr = NULL; |
---|
| 5695 | Group* group = NULL; |
---|
| 5696 | uint64 guid = 0; |
---|
| 5697 | char* cname = strtok((char*)args, " "); |
---|
| 5698 | |
---|
| 5699 | if(GetPlayerGroupAndGUIDByName(cname, plr, group, guid)) |
---|
| 5700 | if(group && group->GetLeaderGUID() != guid) |
---|
| 5701 | group->ChangeLeader(guid); |
---|
| 5702 | |
---|
| 5703 | return true; |
---|
| 5704 | } |
---|
| 5705 | |
---|
| 5706 | bool ChatHandler::HandleGroupDisbandCommand(const char* args) |
---|
| 5707 | { |
---|
| 5708 | Player* plr = NULL; |
---|
| 5709 | Group* group = NULL; |
---|
| 5710 | uint64 guid = 0; |
---|
| 5711 | char* cname = strtok((char*)args, " "); |
---|
| 5712 | |
---|
| 5713 | if(GetPlayerGroupAndGUIDByName(cname, plr, group, guid)) |
---|
| 5714 | if(group) |
---|
| 5715 | group->Disband(); |
---|
| 5716 | |
---|
| 5717 | return true; |
---|
| 5718 | } |
---|
| 5719 | |
---|
| 5720 | bool ChatHandler::HandleGroupRemoveCommand(const char* args) |
---|
| 5721 | { |
---|
| 5722 | Player* plr = NULL; |
---|
| 5723 | Group* group = NULL; |
---|
| 5724 | uint64 guid = 0; |
---|
| 5725 | char* cname = strtok((char*)args, " "); |
---|
| 5726 | |
---|
| 5727 | if(GetPlayerGroupAndGUIDByName(cname, plr, group, guid, true)) |
---|
| 5728 | if(group) |
---|
| 5729 | group->RemoveMember(guid, 0); |
---|
| 5730 | |
---|
| 5731 | return true; |
---|
| 5732 | } |
---|