Наследование: BaseObject
Пример #1
0
 public void HandleCast(int header, script.spells.Spell spell, Player player, int target = 0, short castx = 0, short casty = 0)
 {
     if (spell is script.spells.Teleport)
         (spell as script.spells.Teleport).CastIt(player, new Point2D(castx, casty));
       //  if (spell is script.spells.Trace)
        //     (spell as script.spells.Trace).CastIt(player, new Point2D(castx, casty));
 }
Пример #2
0
        public Point2D AdjecentTile(Player player, int swingloc)
        {
            if (swingloc == -1)
                swingloc = 7;
            if (swingloc == 8)
                swingloc = 0;

            if (swingloc == 0)
                return new Point2D(player.X, player.Y - 1);
            if (swingloc == 1)
                return new Point2D(player.X + 1, player.Y - 1);
            if (swingloc == 2)
                return new Point2D(player.X + 1, player.Y);
            if (swingloc == 3)
                return new Point2D(player.X + 1, player.Y + 1);
            if (swingloc == 4)
                return new Point2D(player.X, player.Y + 1);
            if (swingloc == 5)
                return new Point2D(player.X - 1, player.Y + 1);
            if (swingloc == 6)
                return new Point2D(player.X - 1, player.Y);
            if (swingloc == 7)
                return new Point2D(player.X - 1, player.Y - 1);

            return new Point2D(1, 1);
        }
Пример #3
0
 public virtual void Hit(Player player)
 {
     Hits++;
     if (Hits % 10 == 0)
     {
         OreDrop.DropOre(player);
         if (Hits >= 100)
             Alive = false;
     }
 }
Пример #4
0
 public int Proc(Player player, script.monster.Monster mob, Player play = null)
 {
     int take = 0;
     Point2D targetLoc = (play != null) ? play.Loc : mob.m_Loc;
     if (Util.Dice(1, 100, 0) <= (Stage < 7 ? 10 : 14))
     {
         take += Util.Dice((player.GetStat("str") / 1000), 50, player.GetStat("str") / 16);
         int mobile = Serial.NewMobile;
         World.SendToAll(new QueDele(player.Map, new CreateMagicEffect(mobile, 1, (short)targetLoc.X, (short)targetLoc.Y, new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, 110 }, 0).Compile()));
         var tmp = new QueDele(System.Environment.TickCount + 1300, player.m_Map, new DeleteObject(mobile).Compile());
         tmp.tempser = mobile;
         World.TickQue.Add(tmp);
     }
     return take;
 }
Пример #5
0
 public int Proc(Player player, script.monster.Monster mob, Player play = null)
 {
     int take = 0;
     Point2D targetLoc = (play != null) ? play.Loc : mob.m_Loc;
     if (Util.Dice(1, 100, 0) <= ((Stage < 7) ? 7 : 11))
     {
         take += Util.Dice(((player.GetStat("str") + player.GetStat("dex")) / 1000), 50, (player.GetStat("str") + player.GetStat("dex")) / 32);
         int mobile = Serial.NewMobile;
         World.SendToAll(new QueDele(player.Map, new CreateMagicEffect(mobile, 1, (short)targetLoc.X, (short)targetLoc.Y, new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, 16 }, 0).Compile()));
         var tmp = new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + 1300, player.m_Map, new DeleteObject(mobile).Compile());
         tmp.tempser = mobile;
         World.TickQue.Add(tmp);
     }
     return take;
 }
Пример #6
0
        public virtual void DropOre(Player player)
        {
            var roll = Util.Random(1, 100);
            if (roll <= 20) Stage = (int)OreTypeE.PG;
            if (roll <= 50 && roll > 20) Stage = (int)OreTypeE.PN;
            if (roll > 50) Stage = (int)OreTypeE.PB;

            var tempitem = this.Inventory(player);
            (tempitem as BaseOre).SetSprite();
            if (tempitem.Quantity == 1)
            {
                player.client.SendPacket(new LKCamelot.model.AddItemToInventory2(tempitem).Compile());
                World.NewItems.TryAdd((tempitem as script.item.Item).m_Serial, (tempitem as script.item.Item));
            }
        }
Пример #7
0
        public static Point2D AdjecentTile(Player player, int swingloc)
        {
            if (swingloc == -1)
                swingloc = 7;
            if (swingloc == -2)
                swingloc = 6;
            if (swingloc == -3)
                swingloc = 5;
            if (swingloc == -4)
                swingloc = 4;
            if (swingloc == 8)
                swingloc = 0;
            if (swingloc == 9)
                swingloc = 1;
            if (swingloc == 10)
                swingloc = 2;
            if (swingloc == 11)
                swingloc = 3;

            if (swingloc == 0)
                return new Point2D(player.X, player.Y - 1);
            if (swingloc == 1)
                return new Point2D(player.X + 1, player.Y - 1);
            if (swingloc == 2)
                return new Point2D(player.X + 1, player.Y);
            if (swingloc == 3)
                return new Point2D(player.X + 1, player.Y + 1);
            if (swingloc == 4)
                return new Point2D(player.X, player.Y + 1);
            if (swingloc == 5)
                return new Point2D(player.X - 1, player.Y + 1);
            if (swingloc == 6)
                return new Point2D(player.X - 1, player.Y);
            if (swingloc == 7)
                return new Point2D(player.X - 1, player.Y - 1);

            return new Point2D(1, 1);
        }
Пример #8
0
        public void HandleMelee(Player play, int swingdir)
        {
            List<BaseObject> target = World.GetTileTarget(play, AdjecentTile(play, swingdir), swingdir);
            if (target == null)
                return;
            var take = play.Dam;

            foreach (var tar in target)
            {
                if (tar is Player)
                {
                    if (play.Map == "Village1" || play.Map == "Rest" || play.Map == "Arnold" || play.Map == "Loen")
                        continue;

                    take -= (tar as Player).AC;
                    if (take <= 0)
                        take = 1;
                    TakeDamage(play, tar, take);

                    if ((tar as Player).Color == 0)
                      play.pkpinkktime = Server.tickcount.ElapsedMilliseconds;

                    if ((tar as Player).Map == "Rest" && (tar as Player).Color != 1)
                    {
                        play.pklastpk.Add(Server.tickcount.ElapsedMilliseconds);
                        play.pklastred = Server.tickcount.ElapsedMilliseconds;
                    }
                }
                else if (tar is script.monster.Monster)
                {
                    take -= (tar as script.monster.Monster).AC;
                    if (take <= 0)
                        take = 1;
                    TakeDamage(play, tar, take);
                }
            }
        }
Пример #9
0
        public virtual void TakeDamage(Player player)
        {
            float h = ((float)player.Hit / ((float)player.Hit + (float)Hit)) * 200;

            if (h >= 100 || new Random().Next(0, 100) < (int)h)
            {
                var take = (player.Dam - AC);
                if (take <= 0)
                    take = 1;
                HPCur -= take;
                World.SendToAll(new QueDele(m_Map, new HitAnimation(m_Serial,
                    Convert.ToByte(((((float)m_HPCur / (float)HP) * 100) * 1))).Compile()));

                if (HPCur <= 0)
                {
                    if (player.Promo > 0)
                    {
                        var temp = XP;
                        int y = player.Promo >= 7 ? 2 : 1;
                        for (int x = 0; x < y; x++)
                            temp = (int)(temp * 0.1);

                        player.XP += temp * XPMulti;
                    }
                    else
                        player.XP += XP * XPMulti;
                    DropLoot(player);
                    m_Loc.X = m_SpawnLoc.X;
                    m_Loc.Y = m_SpawnLoc.Y;
                }
            }
        }
Пример #10
0
 public virtual void DropLoot(Player play)
 {
     if (Loot != null)
     {
         foreach (var loot in Loot.m_Entries)
         {
             if (loot.TryDrop())
             {
                 var inst = Activator.CreateInstance(Type.GetType(loot.m_item.ToString()));
                 if (inst is script.item.Gold)
                 {
                     var amount = loot.m_Quantity.Roll();
                     if (amount < 500)
                         (inst as script.item.Gold).m_ItemID = 40;
                     if (amount >= 500 && amount < 5000)
                         (inst as script.item.Gold).m_ItemID = 41;
                     if (amount >= 5000 && amount < 50000)
                         (inst as script.item.Gold).m_ItemID = 42;
                     if (amount >= 50000)
                         (inst as script.item.Gold).m_ItemID = 43;
                     (inst as script.item.Gold).Quantity = amount;
                 }
                 (inst as script.item.Item).Drop(this, play);
                 World.NewItems.TryAdd((inst as script.item.Item).m_Serial, (inst as script.item.Item));
                 return;
             }
         }
     }
 }
Пример #11
0
        public virtual void Attack(Player player)
        {
            float h = ((float)Hit / ((float)player.Hit + (float)Hit)) * 200;

            if (h >= 100 || new Random().Next(0, 100) < (int)h)
            {
                var take = Dam - player.AC;
                if (take <= 0)
                    take = 1;
                player.HPCur -= take;
            }
        }
Пример #12
0
        public MyPathNode AIStep(TiledMap map, Player target)
        {
            var mobs = World.NewMonsters.Where(xe => xe.Value != this && xe.Value.Alive && xe.Value.m_Map == target.Map);
            foreach (var mob in mobs)
                map.tiles[mob.Value.m_Loc.X, mob.Value.m_Loc.Y].IsWall = true;

            aStar = new MySolver<MyPathNode, Object>(map.tiles);
            path = aStar.SearchOnce(new Point(m_Loc.X, m_Loc.Y), new Point(target.X, target.Y), null);

            foreach (var mob in mobs)
                map.tiles[mob.Value.m_Loc.X, mob.Value.m_Loc.Y].IsWall = false;

            MyPathNode p = new MyPathNode(m_Loc.X, m_Loc.Y);
            if (path != null)
            {
                p.X = path.X;
                p.Y = path.Y;
            }
            path = null;
            aStar.Dispose();
            aStar = null;
            return p;
        }
Пример #13
0
 public virtual void Buy(Player player, int buyslot)
 {
 }
Пример #14
0
 public ChangeObjectSpritePlayer(Player play)
     : base(0x26)
 {
     m_Stream.Write(play.Serial);
     m_Stream.Write(play.Appearance, 0, 10);
     m_Stream.Write((byte)0);
     m_Stream.Write((byte)play.Color);
 }
Пример #15
0
        public void HandleIncoming(Byte[] data)
        {
            if (nsa != null)
            {
                nsa.AppendPacketIn(data);
            }
            PacketReader p = null;
            switch (data[0])
            {
                case 0x34: // Keep Alive
                    keepalive = Server.tickcount.ElapsedMilliseconds;
                    break;
                //Identifiy
                /*     case 0x37:
                         //     for (int x = 0; x < 40; x++)
                         //     {
                         //        SendPacket(new CreateSlotMagic(new MagicSpell((byte)(x+81), "Hii", 1, 1, (byte)x, library.MagicType.Casted)).Compile());
                         //    }
                         int y = 14;
                         byte sprite = 0;
                         for (int x = 0; x < 255; x++)
                         {
                             Thread.Sleep(100);
                             if (x != 0 && x % 19 == 0)
                             {
                                 y += 3;
                                 x -= 19;
                             }
                             //    SendPacket(new CreateMonster(new Monster(3, (short)(x+23),(short)y,"village.map", sprite.ToString(), sprite, 0), Serial.NewMobile).Compile());
                             sprite++;
                         }
                         break;*/
                case 0x3A: //find 물건 찾기.
                    if (player.Map == "Loen")
                    {
                        var slot = data[1] + 40 + (12 * player.BankTab);
                        var itemtofind = World.NewItems.Where(xe => xe.Value.ParSer == player.Serial && xe.Value.InvSlot == slot).FirstOrDefault();
                        if (itemtofind.Value != null)
                        {
                            if (player.GetFreeSlot() != -1)
                            {
                                SendPacket(new DeleteEntrustSlot((byte)data[1]).Compile());

                                itemtofind.Value.InvSlot = player.GetFreeSlot();
                                SendPacket(new AddItemToInventory2(itemtofind.Value).Compile());
                            }
                        }
                    }
                    break;
                case 0x36: //Entrust 보관하기.
                    if (player.Map == "Loen")
                    {
                        var itemtoentrust = World.NewItems.Where(xe => xe.Value.ParSer == player.Serial && xe.Value.InvSlot == data[1]).FirstOrDefault();
                        if (itemtoentrust.Value != null)
                        {
                            SendPacket(new DeleteItemSlot((byte)itemtoentrust.Value.InvSlot).Compile());
                            itemtoentrust.Value.InvSlot = player.FreeBankSlot; // 선택한 인벤을 빈칸으로 만듬.
                            SendPacket(new AddItemToEntrust(itemtoentrust.Value).Compile());
                        }
                    }
                    break;

                case 0x35: //sell
                    if (player.Map == "Loen")
                    {
                        var itemtosell = World.NewItems.Where(xe => xe.Value.ParSer == player.Serial && xe.Value.InvSlot == data[1]).FirstOrDefault();
                        if (itemtosell.Value != null && itemtosell.Value.SellPrice > 0)
                        {
                            player.Gold += (uint)itemtosell.Value.SellPrice;
                            itemtosell.Value.Delete(player);
                        }
                    }
                    break;

                //Cast
                //  3D-00-00-01-00-00-00-0A-00-09-00
                case 0x3D:
                case 0x19:
                case 0x18: // 마법 캐스트 관련.
                    if (LKCamelot.Server.tickcount.ElapsedMilliseconds - player.CastSpeed > LastCast)
                    {
                        LastCast = LKCamelot.Server.tickcount.ElapsedMilliseconds;
                        p = new PacketReader(data, data.Count(), true);
                        int spellslot = p.ReadInt16();
												//if (player.MagicLearned.Count() < spellslot)
												//		return;
                        int castonid = p.ReadInt32();
                        short castx = p.ReadInt16();
                        short casty = p.ReadInt16();

                        script.spells.Spell castspell = player.MagicLearned.Where(xe => xe.Slot == spellslot).FirstOrDefault();
                        if (castspell == null) return;

                        castHandler.HandleCast(data[0], castspell, player, castonid, castx, casty);
                    }
                    break;
                //Attack
                case 0x17: // 공격하는 쪽.
                    if (LKCamelot.Server.tickcount.ElapsedMilliseconds - player.AttackSpeed > LastAttack)
                    {
                        LastAttack = LKCamelot.Server.tickcount.ElapsedMilliseconds;

                        World.SendToAll(new QueDele(player.Serial, player.Map, new SwingAnimationChar(player.Serial, player.Face).Compile()));
                        combatHandler.HandleMelee(player, data[1]);
                    }
                    break;

                //NPC Shop
                case 0x45:
                    var npclook = World.NewNpcs.Where(xe => xe.Key == data[1]).FirstOrDefault();
                    if (npclook.Value != null)
                    {
                        if (npclook.Value.Name == "Loen")
                        {
                            SendPacket(new SpawnShopGump2(npclook.Value.Gump).Compile());
                        }
                        if (npclook.Value.Name == "Arnold")
                        {
                            SendPacket(new SpawnShopGump2(npclook.Value.Gump).Compile());
                        }
                        if (npclook.Value.Name == "Employee")
                        {
                            SendPacket(new SpawnShopGump2(npclook.Value.Gump).Compile());
                        }
                        if (npclook.Value.Name == "Boy")
                        {
                            SendPacket(new SpawnShopGump2(npclook.Value.Gump).Compile());
                        }
                    }
                    break;

                case 0x2B: //2B-03-00-00-00-01-00-04-00-4D-65-6E-75-00
                    p = new PacketReader(data, data.Count(), true);
                    var npcid = p.ReadInt32();
                    var buyslot = p.ReadByte();

                    var npcitself = World.NewNpcs.Where(xe => xe.Key == npcid).FirstOrDefault();
                    if (npcitself.Value != null)
                        npcitself.Value.Buy(player, buyslot);

                    break;

                //Inventory
                case 0x00: //use
                    if (data[1] == 0)
                        return;
                    var itemu = World.NewItems.Where(xe => xe.Value.m_Parent == player
                      && xe.Value.InvSlot == data[1]).FirstOrDefault();

                    if (itemu.Value != null)
                        itemu.Value.Use(player);

                    break;

                case 0x20: //drop
                    var item = World.NewItems.Where(xe => xe.Value.m_Parent == player
                        && xe.Value.InvSlot == data[1]).FirstOrDefault();

                    if (item.Value != null)
                        item.Value.Drop(player);
                    break;

                case 0x1F: //pickup
                    var item1 = World.NewItems.Where(xe => xe.Value.m_Map != null
                        && xe.Value.m_Map == player.Map
                        && xe.Value.Loc.X == player.X && xe.Value.Loc.Y == player.Y)
                       .FirstOrDefault();

                    if (item1.Value != null)
                        item1.Value.PickUp(player);

                    break;
                case 0x1E: //equip Use
                    // case 0x36:
                    var eitem = World.NewItems.Where(xe => xe.Value.m_Parent == player
                        && xe.Value.InvSlot == data[1]).FirstOrDefault();

                    if (eitem.Value != null)
                    {
                        if (eitem.Value is script.item.BaseArmor || eitem.Value is script.item.BaseWeapon)
                            eitem.Value.Equip(player);
                        if (eitem.Value is script.item.BaseSpellbook)
                            eitem.Value.Use(player);
                        if (eitem.Value is script.item.BasePotion)
                            eitem.Value.Use(player);
                    }

                    break;
                case 0x23://unequip
                    var uitem = World.NewItems.Where(xe => xe.Value.m_Parent == player
                        && xe.Value.InvSlot == (data[1] + 25)).FirstOrDefault();

                    if (uitem.Value != null)
                        uitem.Value.Unequip(player, data[1] + 25);
                    break;

                case 0x25: //swap items
                    var item11 = World.NewItems.Where(xe => xe.Value.ParSer == player.Serial && xe.Value.InvSlot == data[1]).FirstOrDefault().Value;
                    int sss = 0;
                    if (data.Count() > 3)
                        sss = data[3];

                    var target1 = World.NewItems.Where(xe => xe.Value.ParSer == player.Serial && xe.Value.InvSlot == sss).FirstOrDefault().Value;

                    player.SwapItems(item11, target1, sss);

                    break;

                case 0x24: //drag,drop
                    var itemdragdrop = World.NewItems.Where(xe => xe.Value.ParSer == player.Serial && xe.Value.InvSlot == data[1]).FirstOrDefault().Value;
                    if (itemdragdrop != null)
                    {
                        p = new PacketReader(data, data.Count(), false);
                        var targetid = p.ReadInt32();

                        script.item.Item targeti = null;
                        World.NewItems.TryGetValue(targetid, out targeti);
                        if (targeti != null)
                        {
                            string fail = "Refining failed.";
                            string succ = "Refining success.";
                            if ((itemdragdrop is script.item.Zel && targeti is script.item.BaseArmor)
                                || (itemdragdrop is script.item.Dai && targeti is script.item.BaseWeapon))
                            {
                                if (targeti.TryUpgrade())
                                {
                                    castHandler.CreateMagicEffect(targeti.Loc, targeti.m_Map, 42);
                                    SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)succ.Count(), succ).Compile());
                                    SendPacket(new DeleteObject(targeti.m_Serial).Compile());
                                    SendPacket(new CreateItemGround2(targeti, targeti.m_Serial).Compile());
                                }
                                else
                                {
                                    castHandler.CreateMagicEffect(targeti.Loc, targeti.m_Map, 56);
                                    SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)fail.Count(), fail).Compile());
                                }
                                itemdragdrop.Delete(player);
                            }
                        }

                        if (targetid == 4)
                        {
                            if (itemdragdrop.Name == "Promote Life Drug" && AronStage == 4)
                            {
                                AronStage = 1;
                                itemdragdrop.Delete(player);
                                string achat = "[Aron]: Are you ready for the promotion?";
                                SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)achat.Count(), achat).Compile());
                            }
                            if (itemdragdrop.Name == "Promote Magic Drug" && AronStage == 4)
                            {
                                AronStage = 2;
                                itemdragdrop.Delete(player);
                                string achat = "[Aron]: Are you ready for the promotion?";
                                SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)achat.Count(), achat).Compile());
                            }
                        }
                    }
                    break;

                //Chat message
                case 0x16:
                    p = new PacketReader(data, data.Count(), false);
                    var str = p.ReadString();
                    var str2 = str.Split(' ');

                    if (Util.ContainsUnicodeCharacter(str))
                    {
                        var x = 1;
                    }

                    HandleChat(str2, str);

                    break;

                //Movement
                case 0x14:
                    player.Face = data[1];
                    World.SendToAll(new QueDele(player.Serial, player.Map, new ChangeFace(player.Serial, player.Face).Compile()));
                    break;
                case 0x15:

                    if (Server.tickcount.ElapsedMilliseconds - player.lastmove < 150)
                    {
                        return;
                    }

                    long totalwalk = 0;
                    foreach (var loc in walktrace)
                    {
                        totalwalk += loc;
                    }

                  //  if(player.Name == "SIR")
                  //  Console.WriteLine(string.Format("{0},{1}   {2}", px, py, Server.tickcount.ElapsedMilliseconds));           
                    if (Server.tickcount.ElapsedMilliseconds - player.lastmove > player.m_MoveSpeed)
                    {
                        p = new PacketReader(data, data.Count(), true);
                        player.Face = p.ReadInt16();
                        var px = p.ReadInt16();
                        var py = p.ReadInt16();

                        walktrace.Add(Server.tickcount.ElapsedMilliseconds - player.lastmove);
                        player.lastmove = Server.tickcount.ElapsedMilliseconds;
                        /*
                        if (walktrace.Count > 3 && totalwalk < 1600)
                        {
                            SendPacket(new MoveSpriteWalkChar(player.Serial, player.Face, player.X, player.Y).Compile());
                            return;
                        }

                        while (walktrace.Count > 4)
                            walktrace.Remove(walktrace.ElementAt(0)); 
                               */
                        if (World.Dist2d(new Point2D(px, py), player.m_Loc) > 3)
                        {
                            SendPacket(new MoveSpriteWalkChar(player.Serial, player.Face, player.X, player.Y).Compile());
                            return;
                        }
                        player.X = px;
                        player.Y = py;

                        World.SendToAll(new QueDele(player.Serial, player.Map, new MoveSpriteWalkChar(player.Serial, player.Face,
                        player.X, player.Y).Compile()));
                        parseFace();
                    }
                    else
                    {
                        SendPacket(new MoveSpriteWalkChar(player.Serial, player.Face, player.X, player.Y).Compile());
                    }
                    break;

                //Stats
                case 0x2C:
                    player.AddStat(ref player.m_Str);
                    SendPacket(new UpdateCharStats(player).Compile());
                    break;
                case 0x2D:
                    player.AddStat(ref player.m_Men);
                    SendPacket(new UpdateCharStats(player).Compile());
                    break;
                case 0x2E:
                    player.AddStat(ref player.m_Dex);
                    SendPacket(new UpdateCharStats(player).Compile());
                    break;
                case 0x2F:
                    player.AddStat(ref player.m_Vit);
                    SendPacket(new UpdateCharStats(player).Compile());
                    break;


                case 0x03: //Login
                    var result = TryLogin(data);
                    switch (result[0])
                    {
                        case '1':
                            var puser2 = result.Remove(0, 1).Split(',');
                            player = handler.add.Where(xe => xe.Value.Name == puser2[0]).FirstOrDefault().Value;
                            player.client = this;
                            player.loggedIn = true;
                            LoadPlayer();
                            SendPacket(new CloseLogin().Compile());
                            break;
                        case '2':
                            SendPacket(new WrongPass().Compile());
                            break;
                        case '3':
                            SendPacket(new WrongID().Compile());
                            break;
                        case '4': //invalid chars
                            SendPacket(new WrongID().Compile());
                            break;
                        case '5':
                            SendPacket(new AlreadyOnline().Compile());
                            break;
                        case '6':
                            player = new Player(this);
                            player.CreateBeginner(result.Remove(0, 1));
                            firstlogin = true;
                            LoadPlayer();
                            player.Pass = Cryption.CreateSaltedSHA256(player.Pass, player.Name);
                            try
                            {
                                handler.add.TryAdd(player.Name, player);
                                var touch = handler.add.Where(xe => xe.Key == player.Name).FirstOrDefault();
                                touch.Value.client = this;
                                touch.Value.loggedIn = true;
                                //   BinaryIO.SavePlayer(player);
                                // World.DBConnect.InsertPlayer(player);
                            }
                            catch
                            {
                                Console.WriteLine("failed to insert new player");
                            }
                            SendPacket(new CloseLogin().Compile());
                            break;
                    }
                    break;

                case 0x49: //delete magic
                    var magdelslot = data[1];
                    player.DeleteMagic(magdelslot);
                    break;

                case 0x26: //swap magic
                    if (data.Count() < 4)
                        player.SwapMagic(data[1], 0);
                    else
                        player.SwapMagic(data[1], data[3]);
                    break;

                case 0xff:
                    SendPacket(new PlayMusic(1000).Compile());
                    if (true) //Login
                    {
                        //         SendPacket(new CloseLogin().Compile());

                        //           SendPacket(new LoadWorld(1, 0x12, 0x12, new byte[] { 00, 04, 00, 00, 00, 00, 00, 00, 00, 03 },
                        //               01, 01, 00, 03, 04, 00, 00,
                        //               new byte[] { 0x69, 0x70, 0x69, 0x67, 0x6d, 0x79, 0x31, 0x2e, 0x6d, 0x61, 0x70, 00 }).Format());
                        break;
                    }
            }
        }
Пример #16
0
 public override void Use(Player player)
 {
     if (player.LearnSpell(this))
     {
         this.Delete(player);
     }
 }
Пример #17
0
 public virtual void Use(Player player)
 {
 }
Пример #18
0
 public virtual void Unequip(Player player, int slot)
 {
     if (slot >= 25 && slot <= 30)
     {
         if (World.NewItems.Where(xe => xe.Value.m_Parent != null && xe.Value.m_Parent == player
             && xe.Value.InvSlot == slot).FirstOrDefault().Value != null)
         {
             var freeslot = Parent.GetFreeSlot();
             if (freeslot != -1)
             {
                 script.item.Item outt;
                 Parent.Equipped2.TryRemove(slot, out outt);
                 Parent.client.SendPacket(new DeleteEquipItem2(this).Compile());
                 InvSlot = freeslot;
                 Parent.client.SendPacket(new AddItemToInventory2(this).Compile());
                 Parent.client.SendPacket(new UpdateCharStats(Parent).Compile());
                 World.SendToAll(new QueDele(Parent.Map, new ChangeObjectSpritePlayer(Parent).Compile()));
                 try
                 {
                     //  World.DBConnect.WriteQue.Enqueue(() => World.DBConnect.UpdateItem(this));
                     //   World.DBConnect.UpdateItem(this);
                 }
                 catch { Console.WriteLine("Update Item on Unequip Failed"); }
             }
         }
     }
 }
Пример #19
0
        public void PickUp(Player player)
        {
            var slot = player.GetFreeSlot();
            if (this is Gold)
            {
                Item temp;
                player.Gold += (uint)Quantity;
                World.SendToAll(new QueDele(m_Map, new DeleteObject(m_Serial).Compile()));
                World.NewItems.TryRemove(m_Serial, out temp);
                Loc = null;
                World.RemoveDynamicObj(m_Map, m_Serial);

                return;
            }
            if (slot != -1)
            {
                DropTime = 0;
                World.RemoveDynamicObj(m_Map, m_Serial);
                World.SendToAll(new QueDele(m_Map, new DeleteObject(m_Serial).Compile()));
                m_Map = "inventory";
                Parent = player;

                Loc = null;
                InvSlot = slot;
               // World.DBConnect.WriteQue.Enqueue(() => World.DBConnect.UpdateItem(this));
                Parent.client.SendPacket(new AddItemToInventory2(this).Compile());
            }
        }
Пример #20
0
        public virtual void TakeDamage(Player player, script.spells.Spell spell)
        {
            float h = ((float)player.Hit / ((float)player.Hit + (float)Hit)) * 200;

            if (h >= 100 || new Random().Next(0, 100) < (int)h)
            {
                int take = spell.DamBase + (spell.DamPl * spell.Level);// + (spell.DamPl * spell.SLevel2);
                if (spell.ManaCostPl != 0)
                    take += (player.GetStat("men") / spell.menCoff);
                if (spell is script.spells.DemonDeath)
                    take = Convert.ToInt32(player.HP * 0.5) + player.GetStat("dex");

                HPCur -= (take - AC);
                World.SendToAll(new QueDele(m_Map, new HitAnimation(m_Serial,
                   Convert.ToByte(((((float)m_HPCur / (float)HP) * 100) * 1))).Compile()));

                if (HPCur <= 0)
                {
                    if (player.Promo > 0)
                    {
                        var temp = XP;
                        int y = player.Promo >= 7 ? 2 : 1;
                        for (int x = 0; x < y; x++)
                            temp = (int)(temp * 0.1);

                        player.XP += temp * XPMulti;
                    }
                    else
                        player.XP += XP * XPMulti;
                    DropLoot(player);
                    m_Loc.X = m_SpawnLoc.X;
                    m_Loc.Y = m_SpawnLoc.Y;
                }
            }
        }
Пример #21
0
 public override void Use(Player player)
 {
     player.HPCur = player.HP;
     Delete(player);
 }
Пример #22
0
 public LoadWorld(Player player, byte time)
     : base(0x1B)
 {
     m_Stream.Write((byte)time);
     m_Stream.Write((int)player.Serial);
     m_Stream.Fill(4);
     m_Stream.Write((short)player.Face);
     m_Stream.Write((short)player.X);
     m_Stream.Write((short)player.Y);
     m_Stream.Write(player.Appearance, 0, 10);
     m_Stream.Write((byte)0);
     m_Stream.Write((byte)player.Color); //color
     m_Stream.Write((byte)0);
     m_Stream.Write((byte)player.LightRad);
     m_Stream.Write((byte)player.Transparancy);
     m_Stream.Write(player.BuffArray, 0, 4);
     m_Stream.Write((byte)0); //spawn buff
     m_Stream.Write((byte)0x52);
     m_Stream.Write((byte)0x53);
     m_Stream.Write((byte)0x54);
     m_Stream.Write((byte)0x55);
     m_Stream.Write((byte)0);
     m_Stream.WriteAsciiNull(player.LoadMap);
 }
Пример #23
0
 public override void Equip(Player player)
 {
     base.Equip(player);
     World.SendToAll(new QueDele(player.Map, new SetObjectEffectsPlayer(player).Compile()));
 }
Пример #24
0
        public SetObjectEffectsPlayer(Player play)
            : base(0x34)
        {
            //  SetObjectEffects = 0x34; // 0x34 4id 1light 1trans 4byffs 1staticmagic
            m_Stream.Write(play.Serial);
            m_Stream.Write((byte)play.LightRad);
            m_Stream.Write((byte)play.Transparancy);
            m_Stream.Write(play.BuffArray, 0, 4);

            if (play.m_Buffs.Where(xe => xe.Name == "MENTAL SWORD").FirstOrDefault() != null)
                m_Stream.Write((byte)0x63); //move with char
            else
                m_Stream.Write((byte)0); //move with char

            m_Stream.Write((byte)0); //sprite frame type
            m_Stream.Write((byte)0); // speed
            m_Stream.Write((byte)1);
        }
Пример #25
0
        public CreateChar(Player play, Serial key)
            : base(0x1D)
        {
            m_Stream.Write((int)key);
            m_Stream.Write(play.Face);
            m_Stream.Write(play.X);
            m_Stream.Write(play.Y);
            m_Stream.Write(play.Appearance, 0, 10);
            m_Stream.Write((byte)0x14);//1byte ukn
            m_Stream.Write((byte)play.Color); // color
            m_Stream.Write((byte)0x18); //thickness
            m_Stream.Write((byte)0);//uk
            m_Stream.Write((byte)play.Transparancy);//1byte transp

            m_Stream.Fill(4); //buffs
            m_Stream.Write((byte)0x0); //uk
            m_Stream.Write((byte)0x0); //uk
            m_Stream.Write((byte)0x0); //uk
            m_Stream.Write((byte)0x0); //uk

            m_Stream.Write((byte)0x01);
            m_Stream.WriteAsciiNull(play.Name);
        }
Пример #26
0
 public override void Unequip(Player player, int slot)
 {
     base.Unequip(player, slot);
     World.SendToAll(new QueDele(player.Map, new SetObjectEffectsPlayer(player).Compile()));
 }
Пример #27
0
 public SetLevelGold(Player player)
     : base(0x0F)
 {
     m_Stream.WriteAsciiFixed(player.FullClass, 32);
     m_Stream.Write((byte)player.PromoLevel);
     m_Stream.Write(player.XP);
     m_Stream.Write(player.XPNext);
     m_Stream.Write(player.Gold > int.MaxValue ? int.MaxValue : Convert.ToInt32(player.Gold));
     //  public const byte SetLevelGold = 0x0F; //0x0F 1 32text 1lvl 4exp 4 next 4money
 }
Пример #28
0
        public void TakeDamage(Player caster, Player target, script.spells.Spell spell)
        {
            float h = ((float)caster.Hit / ((float)caster.Hit + (float)target.Hit)) * 200;

            if (h >= 100 || new Random().Next(0, 100) < (int)h)
            {
                int take = spell.DamBase + (spell.DamPl * spell.Level);// +(spell.DamPl * spell.SLevel2);
                if (spell.ManaCostPl != 0)
                {
                    take += (caster.GetStat("men") / spell.menCoff);
                    take += (caster.GetStat("str") / spell.strCoff);
                    take += (caster.GetStat("dex") / spell.dexCoff);
                }
                if (spell is script.spells.DemonDeath)
                    take = Convert.ToInt32(caster.HP * 0.5) + caster.GetStat("dex");

                if (target.Color == 0)
                    caster.pkpinkktime = Server.tickcount.ElapsedMilliseconds;

                target.HPCur -= (take - target.AC);
                if (target.Map == "Rest" && target.Color != 1)
                {
                    caster.pklastpk.Add(Server.tickcount.ElapsedMilliseconds);
                    caster.pklastred = Server.tickcount.ElapsedMilliseconds;
                }
                World.SendToAll(new QueDele(caster.m_Map, new HitAnimation(target.Serial,
                   Convert.ToByte(((((float)target.m_HPCur / (float)target.HP) * 100) * 1))).Compile()));
            }
        }
Пример #29
0
 public UpdateCharStats(Player player)
     : base(0x14)
 {
     m_Stream.Write(Util.checkUShort((uint)player.HPCur));
     m_Stream.Write(Util.checkUShort((uint)player.HP));
     m_Stream.Write(Util.checkUShort((uint)player.MPCur));
     m_Stream.Write(Util.checkUShort((uint)player.MP));
     m_Stream.Write(Util.checkUShort(player.GetStat("str", true)));
     m_Stream.Write(Util.checkUShort(player.GetStat("men", true)));
     m_Stream.Write(Util.checkUShort(player.GetStat("dex", true)));
     m_Stream.Write(Util.checkUShort(player.GetStat("vit", true)));
     m_Stream.Write(Util.checkUShort(player.GetStat("str")));
     m_Stream.Write(Util.checkUShort(player.GetStat("men")));
     m_Stream.Write(Util.checkUShort(player.GetStat("dex")));
     m_Stream.Write(Util.checkUShort(player.GetStat("vit")));
     m_Stream.Write(Util.checkUShort((uint)player.AC));
     m_Stream.Write(Util.checkUShort((uint)player.Hit));
     m_Stream.Write(Util.checkUShort((uint)player.Dam));
     m_Stream.Write(Util.checkUShort(player.Extra));
 }
Пример #30
0
        public void HandleCast(int header, script.spells.Spell castspell, Player player, int target = 0, short castx = 0, short casty = 0)
        {
            if (castspell is Teleport)
            {
                var teleportdist = ((castspell.Level / 2) * 2);
                if (teleportdist <= 3) teleportdist = 4;
                if (teleportdist > 12) teleportdist = 12;
                if (World.Dist2d(castx, casty, player.X, player.Y) <= teleportdist
                    && player.MPCur > castspell.RealManaCost(player))
                {
                    var nmap = LKCamelot.model.Map.FullMaps.Where(xe => xe.Key == player.Map).FirstOrDefault().Value;
                    TiledMap curmap = null;
                    try
                    {
                        curmap = LKCamelot.model.Map.loadedmaps[nmap];
                    }
                    catch
                    {
                        Console.WriteLine(string.Format("Failed to nmap at {0}", nmap));
                    }
                    LKCamelot.model.MyPathNode randomtile;
                    try
                    {
                        randomtile = curmap.tiles[castx, casty];
                    }
                    catch
                    {
                        return;
                    }
                    if (randomtile.IsWall)
                        return;

                    player.MPCur -= castspell.RealManaCost(player);
                    castspell.CheckLevelUp(player);

                    player.Loc = new Point2D(castx, casty);
                    World.SendToAll(new QueDele(player.Map, new MoveSpriteTele(player.Serial, player.Face, player.X, player.Y).Compile()));
                    return;
                }
            }
            if (castspell is Trace)
            {
                if (player.MPCur > castspell.RealManaCost(player))
                {
                    player.MPCur -= castspell.RealManaCost(player);
                    castspell.CheckLevelUp(player);

                    try
                    {
                        var traceto = script.map.Portal.Portals.Where(xe => xe.Map == player.Map).Select(xe => xe).ToList();
                        if (traceto.Count > 1)
                        {
                            var temp = new Point2D(traceto[0].Locs[0].X, traceto[0].Locs[0].Y + 2);
                            player.Loc = temp;
                        }
                    }
                    catch { return; }

                    World.SendToAll(new QueDele(player.Map, new MoveSpriteTele(player.Serial, player.Face, player.X, player.Y).Compile()));
                    return;
                }
            }
            if (castspell is ComeBack)
            {
                return;
            }

            var caston = World.NewMonsters.Where(xe => xe.Value.m_Serial == target
                                && World.Dist2d(xe.Value.m_Loc.X, xe.Value.m_Loc.Y, player.X, player.Y) <= castspell.Range
                                && xe.Value.Alive
                && xe.Value.m_Map != null && xe.Value.m_Map == player.m_Map
                ).Select(xe => xe.Value);

            var playcaston = PlayerHandler.getSingleton().add.Where(xe => xe.Value != null && xe.Value != player && xe.Value.loggedIn
                && World.Dist2d(xe.Value.m_Loc.X, xe.Value.m_Loc.Y, player.m_Loc.X, player.m_Loc.Y) <= castspell.Range
                && xe.Value.Serial == (Serial)target
                && xe.Value.m_Map != null && xe.Value.m_Map == player.m_Map).FirstOrDefault();

            if (castspell.mType == LKCamelot.library.MagicType.Casted || castspell.mType == LKCamelot.library.MagicType.Target)
            {
                caston = World.NewMonsters.Where(xe => xe.Value.m_Map != null
                       && xe.Value.m_Map == player.Map
                       && World.Dist2d(xe.Value.m_Loc.X, xe.Value.m_Loc.Y, player.X, player.Y) <= castspell.Range
                       && xe.Value.Alive)
                      .Select(xe => xe.Value);
            }

            if (playcaston.Key != null
                && !(player.Map == "Village1" || player.Map == "Rest" || player.Map == "Arnold" || player.Map == "Loen")
                )
            {

                if (castspell is ISingle)
                {
                    if (player.MPCur < castspell.RealManaCost(player))
                        return;
                    player.MPCur -= castspell.RealManaCost(player);
                    castspell.CheckLevelUp(player);

                    CreateMagicEffect(playcaston.Value.Loc, playcaston.Value.Map, (byte)castspell.Seq.OnImpactSprite, 1500);

                    TakeDamage(player, playcaston.Value, castspell);
                    return;
                }

                if (castspell.Name == "DEMON DEATH")
                {
                    if (player.HPCur < (int)(player.HP * 0.70))
                        return;

                    var miyamo = player.Equipped.Where(xe => xe.GetType() == typeof(script.item.MiyamotosStick)).FirstOrDefault();
                    var recast = castspell.RecastTime;
                    if (miyamo != null)
                    {
                        recast -= 1000;
                        recast -= miyamo.Stage * 300;
                    }

                    if (LKCamelot.Server.tickcount.ElapsedMilliseconds - recast > castspell.Cooldown)
                    {
                        castspell.Cooldown = LKCamelot.Server.tickcount.ElapsedMilliseconds;
                    }
                    else
                        return;

                    player.HPCur -= castspell.RealManaCost(player);
                    castspell.CheckLevelUp(player);

                    int mobile = Serial.NewMobile;
                    World.SendToAll(new QueDele(player.Map, new CreateMagicEffect(mobile, 1, (short)playcaston.Value.m_Loc.X, (short)playcaston.Value.m_Loc.Y, new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, (byte)castspell.Seq.OnImpactSprite }, 0).Compile()));
                    var tmp = new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + 2000, player.m_Map, new DeleteObject(mobile).Compile());
                    tmp.tempser = mobile;
                    World.TickQue.Add(tmp);

                    TakeDamage(player, playcaston.Value, castspell);

                    return;
                }

                if (player.MPCur < castspell.RealManaCost(player))
                    return;
                player.MPCur -= castspell.RealManaCost(player);
                castspell.CheckLevelUp(player);
                TakeDamage(player, playcaston.Value, castspell);
                World.SendToAll(new QueDele(player.Map, new CurveMagic(player.Serial,
                    castx, casty, castspell.Seq).Compile()));
            }

            switch (castspell.mType)
            {
                case (LKCamelot.library.MagicType.Target2):
                    foreach (var targete in caston)
                    {
                        if (castspell is ISingle)
                        {
                            if (player.MPCur < castspell.RealManaCost(player))
                                return;
                            player.MPCur -= castspell.RealManaCost(player);
                            castspell.CheckLevelUp(player);

                            CreateMagicEffect(targete.m_Loc, targete.m_Map, (byte)castspell.Seq.OnImpactSprite, 1500);

                            targete.TakeDamage(player, castspell);
                            return;
                        }

                        if (castspell.Name == "DEMON DEATH")
                        {
                            if (player.HPCur < (int)(player.HP * 0.70))
                                return;

                            var miyamo = player.Equipped.Where(xe => xe.GetType() == typeof(script.item.MiyamotosStick)).FirstOrDefault();
                            var recast = castspell.RecastTime;
                            if (miyamo != null)
                            {
                                recast -= 1000;
                                recast -= miyamo.Stage * 300;
                            }

                            if (LKCamelot.Server.tickcount.ElapsedMilliseconds - recast > castspell.Cooldown)
                            {
                                castspell.Cooldown = LKCamelot.Server.tickcount.ElapsedMilliseconds;
                            }
                            else
                                return;

                            player.HPCur -= castspell.RealManaCost(player);
                            castspell.CheckLevelUp(player);

                            int mobile = Serial.NewMobile;
                            World.SendToAll(new QueDele(player.Map, new CreateMagicEffect(mobile, 1, (short)targete.m_Loc.X, (short)targete.m_Loc.Y, new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, (byte)castspell.Seq.OnImpactSprite }, 0).Compile()));
                            var tmp = new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + 2000, player.m_Map, new DeleteObject(mobile).Compile());
                            tmp.tempser = mobile;
                            World.TickQue.Add(tmp);

                            targete.TakeDamage(player, castspell);

                            return;
                        }

                        if (player.MPCur < castspell.RealManaCost(player))
                            return;
                        player.MPCur -= castspell.RealManaCost(player);
                        castspell.CheckLevelUp(player);
                        targete.TakeDamage(player, castspell);
                        World.SendToAll(new QueDele(player.Map, new CurveMagic(player.Serial,
                            castx, casty, castspell.Seq).Compile()));
                    }

                    break;

                case (LKCamelot.library.MagicType.Casted):
                    if (player.MPCur < castspell.RealManaCost(player))
                        return;
                    player.MPCur -= castspell.RealManaCost(player);

                    if (castspell.Cast(player))
                        return;

                    foreach (var targete in caston)
                        targete.TakeDamage(player, castspell);

                    World.SendToAll(new QueDele(player.Map, new CurveMagic(player.Serial,
                      1, 1, castspell.Seq).Compile()));

                    break;
                case (LKCamelot.library.MagicType.Target):
                    if (player.MPCur < castspell.RealManaCost(player))
                        return;
                    player.MPCur -= castspell.RealManaCost(player);
                    if (castspell.Cast(player))
                        return;

                    World.SendToAll(new QueDele(player.Map, new CurveMagic(player.Serial, 1, 1, castspell.Seq).Compile()));
                    foreach (var targetee in caston)
                    {
                        int mobile = Serial.NewMobile;
                        World.SendToAll(new QueDele(player.Map, new CreateMagicEffect(mobile, 1, (short)targetee.m_Loc.X, (short)targetee.m_Loc.Y, new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, (byte)castspell.Seq.OnImpactSprite }, 0).Compile()));
                        // World.SendToAll(new QueDele(player.Map, new SetObjectEffectsMonsterSpell(targetee, castspell.Seq.OnImpactSprite).Compile()));
                        targetee.TakeDamage(player, castspell);
                        var tmp = new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + 1000, player.m_Map, new DeleteObject(mobile).Compile());
                        tmp.tempser = mobile;
                        World.TickQue.Add(tmp);
                    }
                    break;
            }
        }