Exemplo n.º 1
0
        public NPC CreateEnemy(Enums.NPCType type, int level, bool healer)
        {
            var random = 0;

            if (healer == true)
            {
                random = Utils.RandomProvider.GetRandom(0, 5);
            }
            else
            {
                random = Utils.RandomProvider.GetRandom(0, 4);
            }
            var className = (Enums.NPCClassName)Enum.Parse(typeof(Enums.NPCClassName), random.ToString());

            return(NPC.Create(className, type, level));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new npc and spawns it.
        /// </summary>
        /// <param name="id">The id of the npc.</param>
        /// <param name="name">The name of the npc.</param>
        /// <param name="location">The location of the npc.</param>
        /// <param name="mesh">The mesh of the npc.</param>
        /// <param name="avatar">The avatar of the npc.</param>
        /// <param name="npctype">The type of the npc.</param>
        /// <param name="flag">The flat of the npc.</param>
        public static void CreateNPC(uint id, string name, Maps.MapPoint location, ushort mesh, byte avatar, Enums.NPCType npctype = Enums.NPCType.Normal, ushort flag = 2)
        {
            Entities.NPC npc = new ProjectX_V3_Game.Entities.NPC();

            npc.EntityUID = id;
            npc.Mesh      = (ushort)(mesh * 10);
            npc.Flag      = flag;
            npc.Name      = name;
            npc.X         = location.X;
            npc.Y         = location.Y;
            npc.NPCType   = npctype;
            npc.Avatar    = avatar;

            if (!location.Map.EnterMap(npc))
            {
                return;
            }

            if (Core.Kernel.NPCs.TryAdd(npc.EntityUID, npc))
            {
                IniFile npcini = new IniFile(ServerDatabase.DatabaseLocation + "\\NPCInfo\\" + id + ".ini", "Info");
                npcini.WriteString("Name", name);
                npcini.WriteString("Type", npctype.ToString());
                npcini.Write <ushort>("MapID", location.MapID);
                npcini.Write <ushort>("X", location.X);
                npcini.Write <ushort>("Y", location.Y);
                npcini.Write <ushort>("Flag", flag);
                npcini.Write <ushort>("Mesh", mesh);
                npcini.Write <byte>("Avatar", avatar);

                npc.Screen.UpdateScreen(null);
            }
        }