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