示例#1
0
 public void CreateBooth(Packets.GeneralDataPacket data)
 {
     foreach (Maps.IMapObject mapcarpet in ShopOwner.Screen.MapObjects.Values)
     {
         if (!(mapcarpet is Entities.NPC))
         {
             return;
         }
         Entities.NPC carpet = (mapcarpet as Entities.NPC);
         if (carpet.NPCType == Enums.NPCType.ShopFlag)
         {
             if (!carpet.IsTakenBooth)
             {
                 if (carpet.X == (ShopOwner.X - 2) && carpet.Y == ShopOwner.Y)
                 {
                     Carpet = carpet;
                     Carpet.IsTakenBooth = true;
                     break;
                 }
             }
         }
     }
     if (Carpet == null)             // could not find a carpet ...
     {
         ShopOwner.Booth = null;
         ShopOwner       = null;
         return;
     }
     Carpet.StartVending(ShopOwner.Name, this);
     Carpet.Screen.UpdateScreen(null);
     data.Data1 = Carpet.EntityUID;
     data.Id    = ShopOwner.EntityUID;
     ShopOwner.Send(data);
     ShopOwner.Screen.FullUpdate();
 }
示例#2
0
 public bool Insert(Entities.NPC Npc)
 {
     if (NPCs.TryAdd(Npc.UniqueID, Npc))
     {
         Owner.Send(Npc.ToBytes);
         return(true);
     }
     return(false);
 }
示例#3
0
        public static void OpenBattle(Entities.GameClient Opponent, int PetID, int BattleID)
        {
            //if (!Trainers.ContainsKey(BattleID))
            //	return;
            //Entities.Trainer Trainer = Trainers[BattleID];

            ArenaMatch Match = ArenaMatch.CreateMatch(Opponent, null);

            Match.FightingMatch      = false;
            Match.Started            = true;
            Match.Player1            = Opponent;
            Opponent.Battle          = Match;
            Opponent.PetBattle       = new PetBattle();
            Opponent.PetBattle.Match = Match;

            Entities.BattlePet pet1 = new ProjectX_V3_Game.Entities.BattlePet();
            pet1.EntityUID          = Core.UIDGenerators.GetMonsterUID();
            pet1.Mesh               = 332;
            pet1.Name               = "Zapdos";
            pet1.MaxHP              = 1000;
            pet1.HP                 = 1000;
            Opponent.PetBattle.Pet1 = pet1;

            Entities.BattlePet pet2 = new ProjectX_V3_Game.Entities.BattlePet();
            pet2.EntityUID          = Core.UIDGenerators.GetMonsterUID();
            pet2.Mesh               = 332;
            pet2.Name               = "Articuno";
            pet2.MaxHP              = 1000;
            pet2.HP                 = 1000;
            Opponent.PetBattle.Pet2 = pet2;

            /*Opponent.PetBattle.Pet1 = Opponent.Pets[PetID];
             * Opponent.PetBattle.Pet2 = Trainer.Pet;*/
            // JailGuard = 150001

            Entities.NPC Trainer = Core.Kernel.NPCs[150001];

            Match.ArenaMap = Core.Kernel.Maps[700].CreateDynamic(out Match.DynamicID);
            Opponent.TeleportDynamic(Match.DynamicID, 51, 58);

            Match.SendMatch();
            Match.SendCountDown(Trainer.Name, Trainer.Level, 15, 0, Trainer.EntityUID, Opponent);
            Match.SendPacket(pet1.EntityUID, pet1.Name, pet1.HP, pet2.EntityUID, pet2.Name, pet2.HP);

            Trainer.X = 51;
            Trainer.Y = 44;

            Match.ArenaMap.EnterMap(Trainer);

            Opponent.PetBattle.ShowOpponent();
            Opponent.PetBattle.SendDialog();
        }
示例#4
0
        public void CancelBooth()
        {
            BoothItems.Clear();

            Carpet.StopVending();
            Carpet.Name = "";
            Carpet.Screen.FullUpdate();
            Carpet = null;

            ShopOwner.Booth = null;
            ShopOwner.Screen.FullUpdate();
            ShopOwner = null;
        }
示例#5
0
        public void CancelBooth()
        {
            BoothItems.Clear();

            Carpet.StopVending();
            Carpet.Name = "";
            Carpet.Screen.FullUpdate();
            Carpet = null;

            ShopOwner.Booth = null;
            ShopOwner.Screen.FullUpdate();
            ShopOwner = null;
        }
示例#6
0
 public void Insert(Entities.NPC Npc)
 {
     if (NPCs.TryAdd(Npc.UniqueID, Npc))
     {
         foreach (SocketClient client in Players.Values)
         {
             if (Calculations.GetDistance(client.Character.X, client.Character.Y, Npc.X, Npc.Y) <= Constants.ScreenDistance)
             {
                 client.Character.Screen.Insert(Npc);
             }
         }
     }
 }
示例#7
0
        public static void LoadNPCs()
        {
            Database db = new Database("C:/db/npcs.s3db");

            using (DataTable DT = db.GetDataTable("SELECT `UniqueID`, `Name`, `Type`, `Facing`, `MapID`, `X`, `Y` FROM `npcs`"))
            {
                for (int i = 0; i < DT.Rows.Count; i++)
                {
                    DataRow      dr  = DT.Rows[i];
                    Entities.NPC npc = new Entities.NPC();
                    npc.UniqueID = Convert.ToUInt32(dr.ItemArray[0]);
                    npc.Name     = dr.ItemArray[1].ToString();
                    npc.Type     = Convert.ToUInt16(dr.ItemArray[2]);
                    npc.Facing   = (Enums.ConquerAngle)Convert.ToByte(dr.ItemArray[3]);
                    npc.X        = Convert.ToUInt16(dr.ItemArray[5]);
                    npc.Y        = Convert.ToUInt16(dr.ItemArray[6]);

                    int Len = 20;
                    if (npc.Name != "Unknown")
                    {
                        Len += npc.Name.Length;
                    }
                    Writer PWR = new Writer(Len);
                    PWR.Fill((ushort)Len, 0);
                    PWR.Fill((ushort)2030, 2);
                    PWR.Fill((uint)npc.UniqueID, 4);
                    PWR.Fill((ushort)npc.X, 8);
                    PWR.Fill((ushort)npc.Y, 10);
                    PWR.Fill((ushort)npc.Type, 12);
                    PWR.Fill((byte)npc.Facing, 14);
                    PWR.Fill((ushort)0, 16);
                    if (npc.Name != "Unknown")
                    {
                        PWR.Fill((byte)1, 18);
                        PWR.Fill((byte)npc.Name.Length, 19);
                        PWR.Fill(npc.Name, 20);
                    }
                    npc.ToBytes = PWR.Bytes;
                    Mapping.Map m;
                    if (Kernel.Maps.TryGetValue(Convert.ToUInt32(dr.ItemArray[4]), out m))
                    {
                        m.Insert(npc);
                    }
                }
            }
            db.Dispose();
        }
示例#8
0
        public static void LoadNPCs()
        {
            Database db = new Database("C:/db/npcs.s3db");
            using (DataTable DT = db.GetDataTable("SELECT `UniqueID`, `Name`, `Type`, `Facing`, `MapID`, `X`, `Y` FROM `npcs`"))
            {
                for (int i = 0; i < DT.Rows.Count; i++)
                {
                    DataRow dr = DT.Rows[i];
                    Entities.NPC npc = new Entities.NPC();
                    npc.UniqueID = Convert.ToUInt32(dr.ItemArray[0]);
                    npc.Name = dr.ItemArray[1].ToString();
                    npc.Type = Convert.ToUInt16(dr.ItemArray[2]);
                    npc.Facing = (Enums.ConquerAngle)Convert.ToByte(dr.ItemArray[3]);
                    npc.X = Convert.ToUInt16(dr.ItemArray[5]);
                    npc.Y = Convert.ToUInt16(dr.ItemArray[6]);

                    int Len = 20;
                    if (npc.Name != "Unknown") { Len += npc.Name.Length; }
                    Writer PWR = new Writer(Len);
                    PWR.Fill((ushort)Len, 0);
                    PWR.Fill((ushort)2030, 2);
                    PWR.Fill((uint)npc.UniqueID, 4);
                    PWR.Fill((ushort)npc.X, 8);
                    PWR.Fill((ushort)npc.Y, 10);
                    PWR.Fill((ushort)npc.Type, 12);
                    PWR.Fill((byte)npc.Facing, 14);
                    PWR.Fill((ushort)0, 16);
                    if (npc.Name != "Unknown")
                    {
                        PWR.Fill((byte)1, 18);
                        PWR.Fill((byte)npc.Name.Length, 19);
                        PWR.Fill(npc.Name, 20);
                    }
                    npc.ToBytes = PWR.Bytes;
                    Mapping.Map m;
                    if (Kernel.Maps.TryGetValue(Convert.ToUInt32(dr.ItemArray[4]), out m))
                        m.Insert(npc);
                }
            }
            db.Dispose();
        }
        public static void Handle(Entities.GameClient client, DataPacket inPacket)
        {
            if (client.Trade.Trading)
            {
                return;
            }
            if (!client.Alive)
            {
                return;
            }

            using (var npcrequest = new NPCRequestPacket(inPacket))
            {
                try
                {
                    if (npcrequest.Option == 255)
                    {
                        client.CurrentNPC = null;
                        return;
                    }

                    if (Core.Kernel.Shops.ContainsKey(npcrequest.NPCID))
                    {
                        if (!Core.Kernel.Shops[npcrequest.NPCID].AssociatedNPC.IsInMap(client))
                        {
                            return;
                        }

                        Packets.GeneralDataPacket pack = new Packets.GeneralDataPacket();
                        pack.Action    = Enums.DataAction.OpenUpgrade;
                        pack.Id        = client.EntityUID;
                        pack.Data1     = 32;
                        pack.Data3Low  = client.X;
                        pack.Data3High = client.Y;
                        pack.Timestamp = npcrequest.NPCID;
                        client.Send(pack);
                    }
                    else
                    {
                        Entities.NPC npc = Core.Kernel.NPCs[npcrequest.NPCID];
                        if (!npc.IsInMap(client))
                        {
                            return;
                        }

                        if (Core.Screen.GetDistance(client.X, client.Y, npc.X, npc.Y) >= Core.NumericConst.MaxNPCDistance && npc.NPCType != Enums.NPCType.Distance)
                        {
                            using (var fmsg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.TOO_FAR_NPC))
                                client.Send(fmsg);
                            return;
                        }
                        client.CurrentNPC = npc;

                        client.CurrentNPC.CallDialog(client, npcrequest.Option);
                    }
                }
                catch
                {
                    using (var fmsg = Packets.Message.MessageCore.CreateSystem(client.Name, string.Format("NPCID: {0}", npcrequest.NPCID)))
                        client.Send(fmsg);
                }
            }
        }
示例#10
0
 public void CreateBooth(Packets.GeneralDataPacket data)
 {
     foreach (Maps.IMapObject mapcarpet in ShopOwner.Screen.MapObjects.Values)
     {
         if (!(mapcarpet is Entities.NPC))
             return;
         Entities.NPC carpet = (mapcarpet as Entities.NPC);
         if (carpet.NPCType == Enums.NPCType.ShopFlag)
         {
             if (!carpet.IsTakenBooth)
             {
                 if (carpet.X == (ShopOwner.X - 2) && carpet.Y == ShopOwner.Y)
                 {
                     Carpet = carpet;
                     Carpet.IsTakenBooth = true;
                     break;
                 }
             }
         }
     }
     if (Carpet == null) // could not find a carpet ...
     {
         ShopOwner.Booth = null;
         ShopOwner = null;
         return;
     }
     Carpet.StartVending(ShopOwner.Name, this);
     Carpet.Screen.UpdateScreen(null);
     data.Data1 = Carpet.EntityUID;
     data.Id = ShopOwner.EntityUID;
     ShopOwner.Send(data);
     ShopOwner.Screen.FullUpdate();
 }