static bool Reward(StringArguments args, CommandHandler handler) { Player player = handler.getSelectedPlayer(); if (!player) { handler.SendSysMessage(CypherStrings.NoCharSelected); return(false); } // .quest reward #entry // number or [name] Shift-click form |color|Hquest:quest_id:quest_level:min_level:max_level:scaling_faction|h[name]|h|r string cId = handler.extractKeyFromLink(args, "Hquest"); if (!uint.TryParse(cId, out uint entry)) { return(false); } Quest quest = Global.ObjectMgr.GetQuestTemplate(entry); // If player doesn't have the quest if (quest == null || player.GetQuestStatus(entry) != QuestStatus.Complete) { handler.SendSysMessage(CypherStrings.CommandQuestNotfound, entry); return(false); } player.RewardQuest(quest, 0, player); return(true); }
static bool HandleGameObjectActivateCommand(StringArguments args, CommandHandler handler) { if (args.Empty()) { return(false); } string id = handler.extractKeyFromLink(args, "Hgameobject"); if (string.IsNullOrEmpty(id)) { return(false); } if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0) { return(false); } GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow); if (!obj) { handler.SendSysMessage(CypherStrings.CommandObjnotfound, guidLow); return(false); } // Activate obj.SetLootState(LootState.Ready); obj.UseDoorOrButton(10000, false, handler.GetSession().GetPlayer()); handler.SendSysMessage("Object activated!"); return(true); }
static bool SetSkill(StringArguments args, CommandHandler handler) { // number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r string skillStr = handler.extractKeyFromLink(args, "Hskill"); if (string.IsNullOrEmpty(skillStr)) { return(false); } if (!uint.TryParse(skillStr, out uint skill) || skill == 0) { handler.SendSysMessage(CypherStrings.InvalidSkillId, skill); return(false); } uint level = args.NextUInt32(); if (level == 0) { return(false); } Player target = handler.getSelectedPlayerOrSelf(); if (!target) { handler.SendSysMessage(CypherStrings.NoCharSelected); return(false); } SkillLineRecord skillLine = CliDB.SkillLineStorage.LookupByKey(skill); if (skillLine == null) { handler.SendSysMessage(CypherStrings.InvalidSkillId, skill); return(false); } bool targetHasSkill = target.GetSkillValue((SkillType)skill) != 0; ushort maxPureSkill = args.NextUInt16(); // If our target does not yet have the skill they are trying to add to them, the chosen level also becomes // the max level of the new profession. ushort max = maxPureSkill != 0 ? maxPureSkill : targetHasSkill?target.GetPureMaxSkillValue((SkillType)skill) : (ushort)level; if (level == 0 || level > max || max <= 0) { return(false); } // If the player has the skill, we get the current skill step. If they don't have the skill, we // add the skill to the player's book with step 1 (which is the first rank, in most cases something // like 'Apprentice <skill>'. target.SetSkill((SkillType)skill, (uint)(targetHasSkill ? target.GetSkillStep((SkillType)skill) : 1), level, max); handler.SendSysMessage(CypherStrings.SetSkill, skill, skillLine.DisplayName[handler.GetSessionDbcLocale()], handler.GetNameLink(target), level, max); return(true); }
static bool Remove(StringArguments args, CommandHandler handler) { Player player = handler.getSelectedPlayer(); if (!player) { handler.SendSysMessage(CypherStrings.NoCharSelected); return(false); } // .removequest #entry' // number or [name] Shift-click form |color|Hquest:quest_id:quest_level:min_level:max_level:scaling_faction|h[name]|h|r string cId = handler.extractKeyFromLink(args, "Hquest"); if (!uint.TryParse(cId, out uint entry)) { return(false); } Quest quest = Global.ObjectMgr.GetQuestTemplate(entry); if (quest == null) { handler.SendSysMessage(CypherStrings.CommandQuestNotfound, entry); return(false); } QuestStatus oldStatus = player.GetQuestStatus(entry); // remove all quest entries for 'entry' from quest log for (byte slot = 0; slot < SharedConst.MaxQuestLogSize; ++slot) { uint logQuest = player.GetQuestSlotQuestId(slot); if (logQuest == entry) { player.SetQuestSlot(slot, 0); // we ignore unequippable quest items in this case, its' still be equipped player.TakeQuestSourceItem(logQuest, false); if (quest.HasFlag(QuestFlags.Pvp)) { player.pvpInfo.IsHostile = player.pvpInfo.IsInHostileArea || player.HasPvPForcingQuest(); player.UpdatePvPState(); } } } player.RemoveActiveQuest(entry, false); player.RemoveRewardedQuest(entry); Global.ScriptMgr.OnQuestStatusChange(player, entry); Global.ScriptMgr.OnQuestStatusChange(player, quest, oldStatus, QuestStatus.None); handler.SendSysMessage(CypherStrings.CommandQuestRemoved); return(true); }
static bool HandleEventInfoCommand(StringArguments args, CommandHandler handler) { if (args.Empty()) { return(false); } // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r string id = handler.extractKeyFromLink(args, "Hgameevent"); if (string.IsNullOrEmpty(id)) { return(false); } if (!ushort.TryParse(id, out ushort eventId)) { return(false); } var events = Global.GameEventMgr.GetEventMap(); if (eventId >= events.Length) { handler.SendSysMessage(CypherStrings.EventNotExist); return(false); } GameEventData eventData = events[eventId]; if (!eventData.isValid()) { handler.SendSysMessage(CypherStrings.EventNotExist); return(false); } var activeEvents = Global.GameEventMgr.GetActiveEventList(); bool active = activeEvents.Contains(eventId); string activeStr = active ? Global.ObjectMgr.GetCypherString(CypherStrings.Active) : ""; string startTimeStr = Time.UnixTimeToDateTime(eventData.start).ToLongDateString(); string endTimeStr = Time.UnixTimeToDateTime(eventData.end).ToLongDateString(); uint delay = Global.GameEventMgr.NextCheck(eventId); long nextTime = Time.UnixTime + delay; string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? Time.UnixTimeToDateTime(Time.UnixTime + delay).ToShortTimeString() : "-"; string occurenceStr = Time.secsToTimeString(eventData.occurence * Time.Minute); string lengthStr = Time.secsToTimeString(eventData.length * Time.Minute); handler.SendSysMessage(CypherStrings.EventInfo, eventId, eventData.description, activeStr, startTimeStr, endTimeStr, occurenceStr, lengthStr, nextStr); return(true); }
static bool HandleModifyFactionCommand(StringArguments args, CommandHandler handler) { string pfactionid = handler.extractKeyFromLink(args, "Hfaction"); Creature target = handler.getSelectedCreature(); if (!target) { handler.SendSysMessage(CypherStrings.SelectCreature); return(false); } if (!uint.TryParse(pfactionid, out uint factionid)) { uint _factionid = target.GetFaction(); uint _flag = target.m_unitData.Flags; ulong _npcflag = (ulong)target.m_unitData.NpcFlags[0] << 32 | target.m_unitData.NpcFlags[1]; uint _dyflag = target.m_objectData.DynamicFlags; handler.SendSysMessage(CypherStrings.CurrentFaction, target.GetGUID().ToString(), _factionid, _flag, _npcflag, _dyflag); return(true); } if (!uint.TryParse(args.NextString(), out uint flag)) { flag = target.m_unitData.Flags; } if (!ulong.TryParse(args.NextString(), out ulong npcflag)) { npcflag = (ulong)target.m_unitData.NpcFlags[0] << 32 | target.m_unitData.NpcFlags[1]; } if (!uint.TryParse(args.NextString(), out uint dyflag)) { dyflag = target.m_objectData.DynamicFlags; } if (!CliDB.FactionTemplateStorage.ContainsKey(factionid)) { handler.SendSysMessage(CypherStrings.WrongFaction, factionid); return(false); } handler.SendSysMessage(CypherStrings.YouChangeFaction, target.GetGUID().ToString(), factionid, flag, npcflag, dyflag); target.SetFaction(factionid); target.SetUnitFlags((UnitFlags)flag); target.SetNpcFlags((NPCFlags)(npcflag & 0xFFFFFFFF)); target.SetNpcFlags2((NPCFlags2)(npcflag >> 32)); target.SetDynamicFlags((UnitDynFlags)dyflag); return(true); }
static bool HandleModifyFactionCommand(StringArguments args, CommandHandler handler) { string pfactionid = handler.extractKeyFromLink(args, "Hfaction"); Creature target = handler.getSelectedCreature(); if (!target) { handler.SendSysMessage(CypherStrings.SelectCreature); return(false); } if (!uint.TryParse(pfactionid, out uint factionid)) { uint _factionid = target.getFaction(); uint _flag = target.GetUInt32Value(UnitFields.Flags); ulong _npcflag = target.GetUInt64Value(UnitFields.NpcFlags); uint _dyflag = target.GetUInt32Value(ObjectFields.DynamicFlags); handler.SendSysMessage(CypherStrings.CurrentFaction, target.GetGUID().ToString(), _factionid, _flag, _npcflag, _dyflag); return(true); } if (!uint.TryParse(args.NextString(), out uint flag)) { flag = target.GetUInt32Value(UnitFields.Flags); } if (!ulong.TryParse(args.NextString(), out ulong npcflag)) { npcflag = target.GetUInt64Value(UnitFields.NpcFlags); } if (!uint.TryParse(args.NextString(), out uint dyflag)) { dyflag = target.GetUInt32Value(ObjectFields.DynamicFlags); } if (!CliDB.FactionTemplateStorage.ContainsKey(factionid)) { handler.SendSysMessage(CypherStrings.WrongFaction, factionid); return(false); } handler.SendSysMessage(CypherStrings.YouChangeFaction, target.GetGUID().ToString(), factionid, flag, npcflag, dyflag); target.SetFaction(factionid); target.SetUInt32Value(UnitFields.Flags, flag); target.SetUInt64Value(UnitFields.NpcFlags, npcflag); target.SetUInt32Value(ObjectFields.DynamicFlags, dyflag); return(true); }
static bool HandleEventStopCommand(StringArguments args, CommandHandler handler) { if (args.Empty()) { return(false); } // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r string id = handler.extractKeyFromLink(args, "Hgameevent"); if (string.IsNullOrEmpty(id)) { return(false); } if (!ushort.TryParse(id, out ushort eventId)) { return(false); } var events = Global.GameEventMgr.GetEventMap(); if (eventId < 1 || eventId >= events.Length) { handler.SendSysMessage(CypherStrings.EventNotExist); return(false); } GameEventData eventData = events[eventId]; if (!eventData.isValid()) { handler.SendSysMessage(CypherStrings.EventNotExist); return(false); } var activeEvents = Global.GameEventMgr.GetActiveEventList(); if (!activeEvents.Contains(eventId)) { handler.SendSysMessage(CypherStrings.EventNotActive, eventId); return(false); } Global.GameEventMgr.StopEvent(eventId, true); return(true); }
static bool HandleGameObjectDeleteCommand(StringArguments args, CommandHandler handler) { // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r string id = handler.extractKeyFromLink(args, "Hgameobject"); if (string.IsNullOrEmpty(id)) { return(false); } ulong guidLow = ulong.Parse(id); if (guidLow == 0) { return(false); } GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow); if (!obj) { handler.SendSysMessage(CypherStrings.CommandObjnotfound, guidLow); return(false); } ObjectGuid ownerGuid = obj.GetOwnerGUID(); if (ownerGuid.IsEmpty()) { Unit owner = Global.ObjAccessor.GetUnit(handler.GetPlayer(), ownerGuid); if (!owner || !ownerGuid.IsPlayer()) { handler.SendSysMessage(CypherStrings.CommandDelobjrefercreature, ownerGuid.ToString(), obj.GetGUID().ToString()); return(false); } owner.RemoveGameObject(obj, false); } obj.SetRespawnTime(0); // not save respawn time obj.Delete(); obj.DeleteFromDB(); handler.SendSysMessage(CypherStrings.CommandDelobjmessage, obj.GetGUID().ToString()); return(true); }
static bool Add(StringArguments args, CommandHandler handler) { Player player = handler.getSelectedPlayer(); if (!player) { handler.SendSysMessage(CypherStrings.NoCharSelected); return(false); } // .addquest #entry' // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r string cId = handler.extractKeyFromLink(args, "Hquest"); if (string.IsNullOrEmpty(cId)) { return(false); } uint entry = uint.Parse(cId); Quest quest = Global.ObjectMgr.GetQuestTemplate(entry); if (quest == null) { handler.SendSysMessage(CypherStrings.CommandQuestNotfound, entry); return(false); } // check item starting quest (it can work incorrectly if added without item in inventory) var itc = Global.ObjectMgr.GetItemTemplates(); var result = itc.Values.FirstOrDefault(p => p.GetStartQuest() == entry); if (result != null) { handler.SendSysMessage(CypherStrings.CommandQuestStartfromitem, entry, result.GetId()); return(false); } // ok, normal (creature/GO starting) quest if (player.CanAddQuest(quest, true)) { player.AddQuestAndCheckCompletion(quest, null); } return(true); }
static bool HandleGameObjectTargetCommand(StringArguments args, CommandHandler handler) { Player player = handler.GetSession().GetPlayer(); SQLResult result; var activeEventsList = Global.GameEventMgr.GetActiveEventList(); if (!args.Empty()) { // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r string idStr = handler.extractKeyFromLink(args, "Hgameobject_entry"); if (string.IsNullOrEmpty(idStr)) { return(false); } if (!uint.TryParse(idStr, out uint objectId) || objectId != 0) { result = DB.World.Query("SELECT guid, id, position_x, position_y, position_z, orientation, map, PhaseId, PhaseGroup, (POW(position_x - '{0}', 2) + POW(position_y - '{1}', 2) + POW(position_z - '{2}', 2)) AS order_ FROM gameobject WHERE map = '{3}' AND id = '{4}' ORDER BY order_ ASC LIMIT 1", player.GetPositionX(), player.GetPositionY(), player.GetPositionZ(), player.GetMapId(), objectId); } else { result = DB.World.Query( "SELECT guid, id, position_x, position_y, position_z, orientation, map, PhaseId, PhaseGroup, (POW(position_x - {0}, 2) + POW(position_y - {1}, 2) + POW(position_z - {2}, 2)) AS order_ " + "FROM gameobject LEFT JOIN gameobject_template ON gameobject_template.entry = gameobject.id WHERE map = {3} AND name LIKE CONCAT('%%', '{4}', '%%') ORDER BY order_ ASC LIMIT 1", player.GetPositionX(), player.GetPositionY(), player.GetPositionZ(), player.GetMapId(), objectId); } } else { StringBuilder eventFilter = new StringBuilder(); eventFilter.Append(" AND (eventEntry IS NULL "); bool initString = true; foreach (var entry in activeEventsList) { if (initString) { eventFilter.Append("OR eventEntry IN (" + entry); initString = false; } else { eventFilter.Append(',' + entry); } } if (!initString) { eventFilter.Append("))"); } else { eventFilter.Append(')'); } result = DB.World.Query("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, PhaseId, PhaseGroup, " + "(POW(position_x - {0}, 2) + POW(position_y - {1}, 2) + POW(position_z - {2}, 2)) AS order_ FROM gameobject " + "LEFT OUTER JOIN game_event_gameobject on gameobject.guid = game_event_gameobject.guid WHERE map = '{3}' {4} ORDER BY order_ ASC LIMIT 10", handler.GetSession().GetPlayer().GetPositionX(), handler.GetSession().GetPlayer().GetPositionY(), handler.GetSession().GetPlayer().GetPositionZ(), handler.GetSession().GetPlayer().GetMapId(), eventFilter.ToString()); } if (result.IsEmpty()) { handler.SendSysMessage(CypherStrings.CommandTargetobjnotfound); return(true); } bool found = false; float x, y, z, o; ulong guidLow; uint id, phaseId, phaseGroup; ushort mapId; uint poolId; do { guidLow = result.Read <ulong>(0); id = result.Read <uint>(1); x = result.Read <float>(2); y = result.Read <float>(3); z = result.Read <float>(4); o = result.Read <float>(5); mapId = result.Read <ushort>(6); phaseId = result.Read <uint>(7); phaseGroup = result.Read <uint>(8); poolId = Global.PoolMgr.IsPartOfAPool <GameObject>(guidLow); if (poolId == 0 || Global.PoolMgr.IsSpawnedObject <GameObject>(guidLow)) { found = true; } } while (result.NextRow() && !found); if (!found) { handler.SendSysMessage(CypherStrings.GameobjectNotExist, id); return(false); } GameObjectTemplate objectInfo = Global.ObjectMgr.GetGameObjectTemplate(id); if (objectInfo == null) { handler.SendSysMessage(CypherStrings.GameobjectNotExist, id); return(false); } GameObject target = handler.GetObjectFromPlayerMapByDbGuid(guidLow); handler.SendSysMessage(CypherStrings.GameobjectDetail, guidLow, objectInfo.name, guidLow, id, x, y, z, mapId, o, phaseId, phaseGroup); if (target) { int curRespawnDelay = (int)(target.GetRespawnTimeEx() - Time.UnixTime); if (curRespawnDelay < 0) { curRespawnDelay = 0; } string curRespawnDelayStr = Time.secsToTimeString((uint)curRespawnDelay, true); string defRespawnDelayStr = Time.secsToTimeString(target.GetRespawnDelay(), true); handler.SendSysMessage(CypherStrings.CommandRawpawntimes, defRespawnDelayStr, curRespawnDelayStr); } return(true); }
static bool HandleGameObjectMoveCommand(StringArguments args, CommandHandler handler) { // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r string id = handler.extractKeyFromLink(args, "Hgameobject"); if (string.IsNullOrEmpty(id)) { return(false); } if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0) { return(false); } GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow); if (!obj) { handler.SendSysMessage(CypherStrings.CommandObjnotfound, guidLow); return(false); } string toX = args.NextString(); string toY = args.NextString(); string toZ = args.NextString(); float x, y, z; if (string.IsNullOrEmpty(toX)) { Player player = handler.GetSession().GetPlayer(); player.GetPosition(out x, out y, out z); } else { if (!float.TryParse(toX, out x)) { return(false); } if (!float.TryParse(toY, out y)) { return(false); } if (!float.TryParse(toZ, out z)) { return(false); } if (!GridDefines.IsValidMapCoord(obj.GetMapId(), x, y, z)) { handler.SendSysMessage(CypherStrings.InvalidTargetCoord, x, y, obj.GetMapId()); return(false); } } Map map = obj.GetMap(); obj.Relocate(x, y, z, obj.GetOrientation()); obj.SaveToDB(); // Generate a completely new spawn with new guid // client caches recently deleted objects and brings them back to life // when CreateObject block for this guid is received again // however it entirely skips parsing that block and only uses already known location obj.Delete(); obj = GameObject.CreateGameObjectFromDB(guidLow, map); if (!obj) { return(false); } handler.SendSysMessage(CypherStrings.CommandMoveobjmessage, obj.GetSpawnId(), obj.GetGoInfo().name, obj.GetGUID().ToString()); return(true); }
static bool HandleGameObjectSetStateCommand(StringArguments args, CommandHandler handler) { // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r string id = handler.extractKeyFromLink(args, "Hgameobject"); if (string.IsNullOrEmpty(id)) { return(false); } if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0) { return(false); } GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow); if (!obj) { handler.SendSysMessage(CypherStrings.CommandObjnotfound, guidLow); return(false); } string type = args.NextString(); if (string.IsNullOrEmpty(type)) { return(false); } if (!int.TryParse(type, out int objectType)) { return(false); } if (objectType < 0) { if (objectType == -1) { obj.SendGameObjectDespawn(); } else if (objectType == -2) { return(false); } return(true); } string state = args.NextString(); if (string.IsNullOrEmpty(state)) { return(false); } if (!uint.TryParse(state, out uint objectState)) { return(false); } switch (objectType) { case 0: obj.SetGoState((GameObjectState)objectState); break; case 1: obj.SetGoType((GameObjectTypes)objectState); break; case 2: obj.SetGoArtKit((byte)objectState); break; case 3: obj.SetGoAnimProgress(objectState); break; case 4: obj.SendCustomAnim(objectState); break; case 5: if (objectState < 0 || objectState > (uint)GameObjectDestructibleState.Rebuilding) { return(false); } obj.SetDestructibleState((GameObjectDestructibleState)objectState); break; default: break; } handler.SendSysMessage("Set gobject type {0} state {1}", objectType, objectState); return(true); }
static bool HandleGameObjectInfoCommand(StringArguments args, CommandHandler handler) { uint entry = 0; GameObjectTypes type = 0; uint displayId = 0; uint lootId = 0; if (args.Empty()) { return(false); } string param1 = handler.extractKeyFromLink(args, "Hgameobject_entry"); if (param1.IsEmpty()) { return(false); } if (param1.Equals("guid")) { string cValue = handler.extractKeyFromLink(args, "Hgameobject"); if (cValue.IsEmpty()) { return(false); } if (!ulong.TryParse(cValue, out ulong guidLow)) { return(false); } GameObjectData data = Global.ObjectMgr.GetGOData(guidLow); if (data == null) { return(false); } entry = data.id; } else { if (!uint.TryParse(param1, out entry)) { return(false); } } GameObjectTemplate gameObjectInfo = Global.ObjectMgr.GetGameObjectTemplate(entry); if (gameObjectInfo == null) { return(false); } type = gameObjectInfo.type; displayId = gameObjectInfo.displayId; string name = gameObjectInfo.name; lootId = gameObjectInfo.GetLootId(); handler.SendSysMessage(CypherStrings.GoinfoEntry, entry); handler.SendSysMessage(CypherStrings.GoinfoType, type); handler.SendSysMessage(CypherStrings.GoinfoLootid, lootId); handler.SendSysMessage(CypherStrings.GoinfoDisplayid, displayId); handler.SendSysMessage(CypherStrings.GoinfoName, name); handler.SendSysMessage(CypherStrings.GoinfoSize, gameObjectInfo.size); GameObjectTemplateAddon addon = Global.ObjectMgr.GetGameObjectTemplateAddon(entry); if (addon != null) { handler.SendSysMessage(CypherStrings.GoinfoAddon, addon.faction, addon.flags); } GameObjectDisplayInfoRecord modelInfo = CliDB.GameObjectDisplayInfoStorage.LookupByKey(displayId); if (modelInfo != null) { handler.SendSysMessage(CypherStrings.GoinfoModel, modelInfo.GeoBoxMax.X, modelInfo.GeoBoxMax.Y, modelInfo.GeoBoxMax.Z, modelInfo.GeoBoxMin.X, modelInfo.GeoBoxMin.Y, modelInfo.GeoBoxMin.Z); } return(true); }
static bool Complete(StringArguments args, CommandHandler handler) { Player player = handler.getSelectedPlayer(); if (!player) { handler.SendSysMessage(CypherStrings.NoCharSelected); return(false); } // .quest complete #entry // number or [name] Shift-click form |color|Hquest:quest_id:quest_level:min_level:max_level:scaling_faction|h[name]|h|r string cId = handler.extractKeyFromLink(args, "Hquest"); if (!uint.TryParse(cId, out uint entry)) { return(false); } Quest quest = Global.ObjectMgr.GetQuestTemplate(entry); // If player doesn't have the quest if (quest == null || player.GetQuestStatus(entry) == QuestStatus.None) { handler.SendSysMessage(CypherStrings.CommandQuestNotfound, entry); return(false); } for (int i = 0; i < quest.Objectives.Count; ++i) { QuestObjective obj = quest.Objectives[i]; switch (obj.Type) { case QuestObjectiveType.Item: { uint curItemCount = player.GetItemCount((uint)obj.ObjectID, true); List <ItemPosCount> dest = new List <ItemPosCount>(); InventoryResult msg = player.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, (uint)obj.ObjectID, (uint)(obj.Amount - curItemCount)); if (msg == InventoryResult.Ok) { Item item = player.StoreNewItem(dest, (uint)obj.ObjectID, true); player.SendNewItem(item, (uint)(obj.Amount - curItemCount), true, false); } break; } case QuestObjectiveType.Monster: { CreatureTemplate creatureInfo = Global.ObjectMgr.GetCreatureTemplate((uint)obj.ObjectID); if (creatureInfo != null) { for (int z = 0; z < obj.Amount; ++z) { player.KilledMonster(creatureInfo, ObjectGuid.Empty); } } break; } case QuestObjectiveType.GameObject: { for (int z = 0; z < obj.Amount; ++z) { player.KillCreditGO((uint)obj.ObjectID); } break; } case QuestObjectiveType.MinReputation: { int curRep = player.GetReputationMgr().GetReputation((uint)obj.ObjectID); if (curRep < obj.Amount) { FactionRecord factionEntry = CliDB.FactionStorage.LookupByKey(obj.ObjectID); if (factionEntry != null) { player.GetReputationMgr().SetReputation(factionEntry, obj.Amount); } } break; } case QuestObjectiveType.MaxReputation: { int curRep = player.GetReputationMgr().GetReputation((uint)obj.ObjectID); if (curRep > obj.Amount) { FactionRecord factionEntry = CliDB.FactionStorage.LookupByKey(obj.ObjectID); if (factionEntry != null) { player.GetReputationMgr().SetReputation(factionEntry, obj.Amount); } } break; } case QuestObjectiveType.Money: { player.ModifyMoney(obj.Amount); break; } } } player.CompleteQuest(entry); return(true); }
static bool HandleGameObjectTurnCommand(StringArguments args, CommandHandler handler) { // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r string id = handler.extractKeyFromLink(args, "Hgameobject"); if (string.IsNullOrEmpty(id)) { return(false); } if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0) { return(false); } GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow); if (!obj) { handler.SendSysMessage(CypherStrings.CommandObjnotfound, guidLow); return(false); } string orientation = args.NextString(); float oz = 0.0f, oy = 0.0f, ox = 0.0f; if (!orientation.IsEmpty()) { if (!float.TryParse(orientation, out oz)) { return(false); } orientation = args.NextString(); if (!orientation.IsEmpty()) { if (!float.TryParse(orientation, out oy)) { return(false); } orientation = args.NextString(); if (!orientation.IsEmpty()) { if (!float.TryParse(orientation, out ox)) { return(false); } } } } else { Player player = handler.GetPlayer(); oz = player.GetOrientation(); } Map map = obj.GetMap(); obj.Relocate(obj.GetPositionX(), obj.GetPositionY(), obj.GetPositionZ()); obj.SetWorldRotationAngles(oz, oy, ox); obj.SaveToDB(); // Generate a completely new spawn with new guid // client caches recently deleted objects and brings them back to life // when CreateObject block for this guid is received again // however it entirely skips parsing that block and only uses already known location obj.Delete(); obj = GameObject.CreateGameObjectFromDB(guidLow, map); if (!obj) { return(false); } handler.SendSysMessage(CypherStrings.CommandTurnobjmessage, obj.GetSpawnId(), obj.GetGoInfo().name, obj.GetGUID().ToString(), obj.GetOrientation()); return(true); }
static bool HandleGameObjectMoveCommand(StringArguments args, CommandHandler handler) { // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r string id = handler.extractKeyFromLink(args, "Hgameobject"); if (string.IsNullOrEmpty(id)) { return(false); } if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0) { return(false); } GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow); if (!obj) { handler.SendSysMessage(CypherStrings.CommandObjnotfound, guidLow); return(false); } string toX = args.NextString(); string toY = args.NextString(); string toZ = args.NextString(); float x, y, z; if (string.IsNullOrEmpty(toX)) { Player player = handler.GetSession().GetPlayer(); player.GetPosition(out x, out y, out z); } else { if (!float.TryParse(toX, out x)) { return(false); } if (!float.TryParse(toY, out y)) { return(false); } if (!float.TryParse(toZ, out z)) { return(false); } if (!GridDefines.IsValidMapCoord(obj.GetMapId(), x, y, z)) { handler.SendSysMessage(CypherStrings.InvalidTargetCoord, x, y, obj.GetMapId()); return(false); } } obj.DestroyForNearbyPlayers(); obj.RelocateStationaryPosition(x, y, z, obj.GetOrientation()); obj.GetMap().GameObjectRelocation(obj, x, y, z, obj.GetOrientation()); obj.SaveToDB(); handler.SendSysMessage(CypherStrings.CommandMoveobjmessage, obj.GetSpawnId(), obj.GetGoInfo().name, obj.GetGUID().ToString()); return(true); }
static bool HandleGameObjectAddCommand(StringArguments args, CommandHandler handler) { if (args.Empty()) { return(false); } // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r string idStr = handler.extractKeyFromLink(args, "Hgameobject_entry"); if (string.IsNullOrEmpty(idStr)) { return(false); } if (!uint.TryParse(idStr, out uint objectId) || objectId == 0) { return(false); } uint spawntimeSecs = args.NextUInt32(); GameObjectTemplate objectInfo = Global.ObjectMgr.GetGameObjectTemplate(objectId); if (objectInfo == null) { handler.SendSysMessage(CypherStrings.GameobjectNotExist, objectId); return(false); } if (objectInfo.displayId != 0 && !CliDB.GameObjectDisplayInfoStorage.ContainsKey(objectInfo.displayId)) { // report to DB errors log as in loading case Log.outError(LogFilter.Sql, "Gameobject (Entry {0} GoType: {1}) have invalid displayId ({2}), not spawned.", objectId, objectInfo.type, objectInfo.displayId); handler.SendSysMessage(CypherStrings.GameobjectHaveInvalidData, objectId); return(false); } Player player = handler.GetPlayer(); Map map = player.GetMap(); GameObject obj = GameObject.CreateGameObject(objectInfo.entry, map, player, Quaternion.fromEulerAnglesZYX(player.GetOrientation(), 0.0f, 0.0f), 255, GameObjectState.Ready); if (!obj) { return(false); } PhasingHandler.InheritPhaseShift(obj, player); if (spawntimeSecs != 0) { obj.SetRespawnTime((int)spawntimeSecs); } // fill the gameobject data and save to the db obj.SaveToDB(map.GetId(), new List <Difficulty>() { map.GetDifficultyID() }); ulong spawnId = obj.GetSpawnId(); // this will generate a new guid if the object is in an instance obj = GameObject.CreateGameObjectFromDB(spawnId, map); if (!obj) { return(false); } // TODO: is it really necessary to add both the real and DB table guid here ? Global.ObjectMgr.AddGameObjectToGrid(spawnId, Global.ObjectMgr.GetGOData(spawnId)); handler.SendSysMessage(CypherStrings.GameobjectAdd, objectId, objectInfo.name, spawnId, player.GetPositionX(), player.GetPositionY(), player.GetPositionZ()); return(true); }
static bool HandleGameObjectTurnCommand(StringArguments args, CommandHandler handler) { // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r string id = handler.extractKeyFromLink(args, "Hgameobject"); if (string.IsNullOrEmpty(id)) { return(false); } if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0) { return(false); } GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow); if (!obj) { handler.SendSysMessage(CypherStrings.CommandObjnotfound, guidLow); return(false); } string orientation = args.NextString(); float oz = 0.0f, oy = 0.0f, ox = 0.0f; if (!orientation.IsEmpty()) { if (!float.TryParse(orientation, out oz)) { return(false); } orientation = args.NextString(); if (!orientation.IsEmpty()) { if (!float.TryParse(orientation, out oy)) { return(false); } orientation = args.NextString(); if (!orientation.IsEmpty()) { if (!float.TryParse(orientation, out ox)) { return(false); } } } } else { Player player = handler.GetPlayer(); oz = player.GetOrientation(); } obj.Relocate(obj.GetPositionX(), obj.GetPositionY(), obj.GetPositionZ()); obj.RelocateStationaryPosition(obj.GetPositionX(), obj.GetPositionY(), obj.GetPositionZ(), obj.GetOrientation()); obj.SetWorldRotationAngles(oz, oy, ox); obj.DestroyForNearbyPlayers(); obj.UpdateObjectVisibility(); obj.SaveToDB(); handler.SendSysMessage(CypherStrings.CommandTurnobjmessage, obj.GetSpawnId(), obj.GetGoInfo().name, obj.GetGUID().ToString(), obj.GetOrientation()); return(true); }
static bool Rep(StringArguments args, CommandHandler handler) { if (args.Empty()) { return(false); } Player target = handler.getSelectedPlayerOrSelf(); if (!target) { handler.SendSysMessage(CypherStrings.PlayerNotFound); return(false); } // check online security if (handler.HasLowerSecurity(target, ObjectGuid.Empty)) { return(false); } string factionTxt = handler.extractKeyFromLink(args, "Hfaction"); if (string.IsNullOrEmpty(factionTxt)) { return(false); } uint factionId = uint.Parse(factionTxt); int amount = 0; string rankTxt = args.NextString(); if (factionId == 0 || rankTxt.IsEmpty()) { return(false); } amount = int.Parse(rankTxt); if ((amount == 0) && !(amount < 0) && !rankTxt.IsNumber()) { string rankStr = rankTxt.ToLower(); int r = 0; amount = -42000; for (; r < (int)ReputationRank.Max; ++r) { string rank = handler.GetCypherString(ReputationMgr.ReputationRankStrIndex[r]); if (string.IsNullOrEmpty(rank)) { continue; } if (rank.Equals(rankStr)) { string deltaTxt = args.NextString(); if (!string.IsNullOrEmpty(deltaTxt)) { int delta = int.Parse(deltaTxt); if ((delta < 0) || (delta > ReputationMgr.PointsInRank[r] - 1)) { handler.SendSysMessage(CypherStrings.CommandFactionDelta, (ReputationMgr.PointsInRank[r] - 1)); return(false); } amount += delta; } break; } amount += ReputationMgr.PointsInRank[r]; } if (r >= (int)ReputationRank.Max) { handler.SendSysMessage(CypherStrings.CommandFactionInvparam, rankTxt); return(false); } } FactionRecord factionEntry = CliDB.FactionStorage.LookupByKey(factionId); if (factionEntry == null) { handler.SendSysMessage(CypherStrings.CommandFactionUnknown, factionId); return(false); } if (factionEntry.ReputationIndex < 0) { handler.SendSysMessage(CypherStrings.CommandFactionNorepError, factionEntry.Name[handler.GetSessionDbcLocale()], factionId); return(false); } target.GetReputationMgr().SetOneFactionReputation(factionEntry, amount, false); target.GetReputationMgr().SendState(target.GetReputationMgr().GetState(factionEntry)); handler.SendSysMessage(CypherStrings.CommandModifyRep, factionEntry.Name[handler.GetSessionDbcLocale()], factionId, handler.GetNameLink(target), target.GetReputationMgr().GetReputation(factionEntry)); return(true); }
static bool HandleGameObjectSetStateCommand(StringArguments args, CommandHandler handler) { // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r string id = handler.extractKeyFromLink(args, "Hgameobject"); if (string.IsNullOrEmpty(id)) { return(false); } if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0) { return(false); } GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow); if (!obj) { handler.SendSysMessage(CypherStrings.CommandObjnotfound, guidLow); return(false); } string type = args.NextString(); if (string.IsNullOrEmpty(type)) { return(false); } if (!int.TryParse(type, out int objectType)) { return(false); } if (objectType < 0) { if (objectType == -1) { obj.SendGameObjectDespawn(); } else if (objectType == -2) { return(false); } return(true); } string state = args.NextString(); if (string.IsNullOrEmpty(state)) { return(false); } if (!uint.TryParse(state, out uint objectState)) { return(false); } if (objectType < 4) { obj.SetByteValue(GameObjectFields.Bytes1, (byte)objectType, (byte)objectState); } else if (objectType == 4) { obj.SendCustomAnim(objectState); } handler.SendSysMessage("Set gobject type {0} state {1}", objectType, objectState); return(true); }