public override void Load(string str) { if (str.IsEmpty()) { OUT_LOAD_INST_DATA_FAIL(); return; } OUT_LOAD_INST_DATA(str); StringArguments loadStream = new StringArguments(str); string dataHead = loadStream.NextString(); if (dataHead[0] == 'T' && dataHead[1] == 'C') { for (byte i = 0; i < 4; ++i) { m_auiEncounter[i] = (EncounterState)loadStream.NextUInt32(); if (m_auiEncounter[i] == EncounterState.InProgress) { m_auiEncounter[i] = EncounterState.NotStarted; } } uiGrandChampionsDeaths = loadStream.NextUInt16(); uiMovementDone = loadStream.NextUInt16(); } else { OUT_LOAD_INST_DATA_FAIL(); } OUT_LOAD_INST_DATA_COMPLETE(); }
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); }
public override void Load(string str) { if (!string.IsNullOrEmpty(str)) { OUT_LOAD_INST_DATA_FAIL(); return; } OUT_LOAD_INST_DATA(str); StringArguments args = new StringArguments(str); char dataHead1 = args.NextChar(); char dataHead2 = args.NextChar(); ushort data0 = args.NextUInt16(); ushort data1 = args.NextUInt16(); ushort data2 = args.NextUInt16(); ushort data3 = args.NextUInt16(); ushort data4 = args.NextUInt16(); if (dataHead1 == 'V' && dataHead2 == 'H') { m_auiEncounter[0] = data0; m_auiEncounter[1] = data1; m_auiEncounter[2] = data2; for (byte i = 0; i < MAX_ENCOUNTER; ++i) { if ((EncounterState)m_auiEncounter[i] == EncounterState.InProgress) { m_auiEncounter[i] = (ushort)EncounterState.NotStarted; } } uiFirstBoss = (byte)data3; uiSecondBoss = (byte)data4; } else { OUT_LOAD_INST_DATA_FAIL(); } OUT_LOAD_INST_DATA_COMPLETE(); }
static bool Bit(StringArguments args, CommandHandler handler) { if (args.Empty()) { return(false); } Unit target = handler.getSelectedUnit(); if (!target) { handler.SendSysMessage(CypherStrings.NoCharSelected); return(false); } // check online security if (target.IsTypeId(TypeId.Player) && handler.HasLowerSecurity(target.ToPlayer(), ObjectGuid.Empty)) { return(false); } ushort field = args.NextUInt16(); int bit = args.NextInt32(); if (field < (int)ObjectFields.End || field >= target.valuesCount) { handler.SendSysMessage(CypherStrings.BadValue); return(false); } if (bit < 1 || bit > 32) { handler.SendSysMessage(CypherStrings.BadValue); return(false); } if (target.HasFlag(field, (1 << (bit - 1)))) { target.RemoveFlag(field, (1 << (bit - 1))); handler.SendSysMessage(CypherStrings.RemoveBit, bit, field); } else { target.SetFlag(field, (1 << (bit - 1))); handler.SendSysMessage(CypherStrings.SetBit, bit, field); } return(true); }
static bool HandleModifySpellCommand(StringArguments args, CommandHandler handler) { if (args.Empty()) { return(false); } byte spellflatid = args.NextByte(); if (spellflatid == 0) { return(false); } byte op = args.NextByte(); if (op == 0) { return(false); } ushort val = args.NextUInt16(); if (val == 0) { return(false); } ushort mark; string pmark = args.NextString(); if (string.IsNullOrEmpty(pmark)) { mark = 65535; } else { mark = ushort.Parse(pmark); } Player target = handler.getSelectedPlayerOrSelf(); if (!target) { handler.SendSysMessage(CypherStrings.NoCharSelected); return(false); } // check online security if (handler.HasLowerSecurity(target, ObjectGuid.Empty)) { return(false); } handler.SendSysMessage(CypherStrings.YouChangeSpellflatid, spellflatid, val, mark, handler.GetNameLink(target)); if (handler.needReportToTarget(target)) { target.SendSysMessage(CypherStrings.YoursSpellflatidChanged, handler.GetNameLink(), spellflatid, val, mark); } SetSpellModifier packet = new SetSpellModifier(ServerOpcodes.SetFlatSpellModifier); SpellModifierInfo spellMod = new SpellModifierInfo(); spellMod.ModIndex = op; SpellModifierData modData; modData.ClassIndex = spellflatid; modData.ModifierValue = val; spellMod.ModifierData.Add(modData); packet.Modifiers.Add(spellMod); target.SendPacket(packet); return(true); }