Ejemplo n.º 1
0
        public static void NpcAddAction(WorldClient client, string[] args)
        {
            if (args.Length < 3)
            {
                client.Character.Reply("Add an action to an NPC.");
                client.Character.Reply(".npc addaction|aa $SpawnId $ActionTypeId $Value1 $Value2");
                client.Character.Reply(" - $SpawnId ⇒ ID of the NPC spawn instance.");
                client.Character.Reply(" - $ActionTypeId ⇒ The action type int. Talk = 3. See NpcActionTypeEnum.");
                client.Character.Reply(" - $Value1 ⇒ The action's value1. The value depends on the action type. For Talk: message ID.");
                client.Character.Reply(" - $Value2 ⇒ The action's value2. The value depends on the action type. For Talk: empty. ");

                return;
            }

            int    spawnId  = int.Parse(args[1]);
            sbyte  actionId = sbyte.Parse(args[2]);           // Talk = 3
            string value1   = args.Length > 3 ? args[3] : ""; // Talk ? MessageId
            string value2   = args.Length > 4 ? args[4] : "";

            NpcActionRecord npcAction = new NpcActionRecord(spawnId, actionId, value1, value2);

            npcAction.AddInstantElement();

            Npc npc = client.Character.Map.Instance.GetNpc(spawnId);

            npc.ActionsRecord.Add(npcAction);

            client.Character.Map.Instance.Reload();
            client.Character.Reply($"Successfully added action {actionId} (Value1='{value1}', Value2='{value2}') to npc SpawnId={spawnId}.");
        }
Ejemplo n.º 2
0
        public static void NpcRemoveAction(WorldClient client, string[] args)
        {
            if (args.Length < 3)
            {
                client.Character.Reply("Remove an action from an NPC.");
                client.Character.Reply(".npc rmaction|ra $SpawnId $ActionTypeId");
                client.Character.Reply(" - $SpawnId ⇒ ID of the NPC spawn instance.");
                client.Character.Reply(" - $ActionTypeId ⇒ The action type int. Talk = 3. See NpcActionTypeEnum.");

                return;
            }

            int   spawnId  = int.Parse(args[1]);
            sbyte actionId = sbyte.Parse(args[2]);

            Npc npc = client.Character.Map.Instance.GetNpc(spawnId);

            NpcActionRecord record = npc.ActionsRecord.Find(r => r.NpcId == spawnId && r.ActionId == actionId);

            record.RemoveInstantElement();

            npc.ActionsRecord.Remove(record);

            client.Character.Map.Instance.Reload();
            client.Character.Reply($"Successfully removed action {actionId} (Value1='{record.Value1}', Value2='{record.Value2}') for npc SpawnId={spawnId}.");
        }
Ejemplo n.º 3
0
 public Npc(NpcSpawnRecord spawnRecord)
 {
     this.SpawnRecord   = spawnRecord;
     this.ActionsRecord = NpcActionRecord.GetActions(SpawnRecord.Id);
     this.Map           = MapRecord.GetMap(spawnRecord.MapId);
     this.m_Id          = this.Map.Instance.PopNextNPEntityId();
 }
Ejemplo n.º 4
0
        public void InteractWith(Character character, NpcActionTypeEnum actionType)
        {
            if (character.Busy)
            {
                return;
            }

            if (actionType == NpcActionTypeEnum.Talk && CinematicProvider.Instance.IsNpcHandled(character, SpawnRecord.Id))
            {
                var npcPoint = new Maps.MapPoint((short)this.CellId);
                character.SetDirection(character.Point.OrientationTo(npcPoint, true));
                character.RandomTalkEmote();
                CinematicProvider.Instance.TalkToNpc(character, SpawnRecord.Id);
                return;
            }

            NpcActionRecord action = GetAction(actionType);

            if (action != null)
            {
                NpcActionProvider.Handle(character, this, action);
            }
            else if (character.Client.Account.Role > ServerRoleEnum.Player)
            {
                character.Reply("No (" + actionType + ") action linked to this npc...(" + SpawnRecord.Id + ")");
            }
        }
Ejemplo n.º 5
0
 public NpcTalkDialog(Character character, Npc npc, NpcActionRecord action)
     : base(character)
 {
     this.Npc       = npc;
     this.Action    = action;
     this.MessageId = ushort.Parse(Action.Value1);
     this.Replies   = GetPossibleReply(NpcReplyRecord.GetNpcReplies(this.MessageId));
 }
Ejemplo n.º 6
0
        public static void ReloadNpcActions(string input)
        {
            DatabaseManager.GetInstance().Reload <NpcActionRecord>();

            foreach (var map in MapRecord.Maps)
            {
                foreach (var npc in map.Instance.GetEntities <Npc>())
                {
                    npc.ActionsRecord = NpcActionRecord.GetActions(npc.SpawnRecord.Id);
                }
            }
            logger.White("Npc reloaded!");
        }
Ejemplo n.º 7
0
        public static void Handle(Character character, Npc npc, NpcActionRecord actionRecord)
        {
            var handler = Handlers.FirstOrDefault(x => x.Key.ActionType == actionRecord.ActionIdEnum);

            if (handler.Value != null)
            {
                handler.Value.Invoke(null, new object[] { character, npc, actionRecord });
            }
            else
            {
                character.ReplyError(actionRecord.ActionIdEnum + " is not handled...");
            }
        }
Ejemplo n.º 8
0
        public static void BuySell(Character character, Npc npc, NpcActionRecord action)
        {
            ushort tokenId    = 0;
            bool   priceLevel = false;

            if (action.Value2 != null && action.Value2 != string.Empty)
            {
                var splitted = action.Value2.Split(',');
                tokenId    = ushort.Parse(splitted[0]);
                priceLevel = bool.Parse(splitted[1]);
            }

            ItemRecord[] items = Array.ConvertAll <ushort, ItemRecord>(action.Value1.FromCSV <ushort>().ToArray(), x => ItemRecord.GetItem(x));

            character.OpenNpcShop(npc, items, tokenId, priceLevel);
        }
Ejemplo n.º 9
0
 public NpcBidBuyAction(NpcActionRecord record)
     : base(record)
 {
 }
Ejemplo n.º 10
0
 public NpcActionDatabase(NpcActionRecord record)
 {
     this.Record = record;
 }
Ejemplo n.º 11
0
 protected NpcActionDatabase(NpcActionRecord record)
 {
     Record = record;
 }
Ejemplo n.º 12
0
 public static void Sell(Character character, Npc npc, NpcActionRecord action)
 {
     character.OpenBidhouseSell(npc, BidShopRecord.GetBidShop(int.Parse(action.Value1)),
                                character.IsInExchange(ExchangeTypeEnum.BIDHOUSE_BUY));
 }
Ejemplo n.º 13
0
 public static void Talk(Character character, Npc npc, NpcActionRecord action)
 {
     character.TalkToNpc(npc, action);
 }
Ejemplo n.º 14
0
 public NpcBidSellAction(NpcActionRecord record)
     : base(record)
 {
 }
Ejemplo n.º 15
0
 public NpcTalkAction(NpcActionRecord record)
     : base(record)
 {
 }