示例#1
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                var mod    = trigger.Text.NextModifiers();
                var id     = trigger.Text.NextEnum(SkillId.None);
                var amount = trigger.Text.NextUInt(0);
                var chr    = (Character)trigger.Args.Target;
                var inv    = chr.Inventory;

                var skillLine = SkillHandler.Get(id);

                if (skillLine != null)
                {
                    var skill = ((Character)trigger.Args.Target).Skills.GetOrCreate(id, true);
                    skill.CurrentValue = amount > 0 ? (ushort)amount : (ushort)skillLine.MaxValue;
                    skill.MaxValue     = (ushort)skillLine.MaxValue;
                    trigger.Reply(RealmLangKey.CmdSkillLearnResponse, skillLine, amount > 0 ? amount : skillLine.MaxValue);
                    if (mod == "r")
                    {
                        // add bags
                        for (var i = InventorySlot.Bag1; i <= InventorySlot.BagLast; i++)
                        {
                            if (inv[i] == null)
                            {
                                inv.AddUnchecked((int)i, ItemId.FororsCrateOfEndlessResistGearStorage, 1, true);
                            }
                        }
                    }

                    var count = 0;
                    foreach (var ability in SkillHandler.GetAbilities(id))
                    {
                        if (ability.GreyValue < 1)
                        {
                            continue;
                        }
                        count++;
                        if (count > amount)
                        {
                            break;
                        }
                        chr.Spells.AddSpell(ability.Spell);
                        if (mod == "r")
                        {
                            chr.PlayerSpells.AddSpellRequirements(ability.Spell);
                        }
                    }
                }
                else
                {
                    trigger.Reply(RealmLangKey.CmdSkillLearnError, id);
                }
            }