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())); } }
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)); }
public CreateSlotMagic2(script.spells.Spell spell) : base(0x19) { m_Stream.Write((byte)spell.Slot); m_Stream.Write((byte)spell.mType); m_Stream.Write((byte)spell.Level); m_Stream.Write((short)spell.SpellLearnedIcon); m_Stream.Fill(3); m_Stream.Write((byte)1); m_Stream.WriteAsciiNull(spell.Name + " :S" + spell.SLevel2.ToString()); }
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); take += (player.GetStat("str") / spell.strCoff); take += (player.GetStat("dex") / spell.dexCoff); } 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; if (player.Promo >= 1 && player.Promo <= 6) { temp = (int)(temp * 0.03); } if (player.Promo >= 7) { temp = (int)(temp * 0.01); } player.XP += temp * XPMulti; } else { player.XP += XP * XPMulti; } DropLoot(player); m_Loc.X = m_SpawnLoc.X; m_Loc.Y = m_SpawnLoc.Y; } } }
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);// + (spell.DamPl * spell.SLevel2); if (spell.ManaCostPl != 0) { take += (player.GetStat("men") / spell.menCoff); take += (player.GetStat("str") / spell.strCoff); take += (player.GetStat("dex") / spell.dexCoff); take += (player.GetStat("vit") / spell.vitCoff); } if (spell is script.spells.DemonDeath) { take = Convert.ToInt32(player.HP * 0.5) + player.GetStat("dex") + (spell.DamPl * spell.SLevel2); } HPCur -= (take); if (player.TakeDam2 == false) { HPCur -= (take - AC); World.SendToAll(new QueDele(m_Map, new HitAnimation(m_Serial, Convert.ToByte(((((float)m_HPCur / (float)HP) * 100) * 1))).Compile())); } if (player.TakeDam2 == true) { HPCur -= (take - AC); World.SendToAll(new QueDele(m_Map, new HitAnimation(m_Serial, Convert.ToByte(((((float)m_HPCur / (float)HP) * 100) * 1))).Compile())); string damg = string.Format("데미지:{0}" + " ", take, 0); player.client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)damg.Count(), damg).Compile()); } if (HPCur <= 0) { if (player.member.Count != 0) { switch (player.member.Count()) { case 2: XPMulti = 1; break; case 3: XPMulti = 1; break; case 4: XPMulti = 1; break; } double XPMultiTemp = XPMulti; var whisp2 = Server.playerHandler.add.Values.Where(xe => xe.member.Count != 0 && xe.loggedIn && xe.member[0] == player.member[0] && xe.Map == player.Map).ToList(); foreach (var mem in whisp2) { if (mem.Name != player.Name) { XPMulti = XPMultiTemp;// / mem.member.Count() * 1.5; } else { XPMulti = XPMultiTemp; } if ((this as script.monster.Monster).Name == "성기사" + " ") { string text3 = "(" + player.Name + ")" + "님이 성기사를 쓰러뜨렸습니다" + " "; World.SendToAll(new QueDele("all", new UpdateChatBox(0x08, 0x02, 0, (short)text3.Count(), text3).Compile())); mem.BossMonster_time = 10; } if ((this as script.monster.Monster).Name == "성물") { string text3 = "(" + player.Name + ")" + "님이 성물을 파괴하였습니다" + " "; World.SendToAll(new QueDele("all", new UpdateChatBox(0x08, 0x02, 0, (short)text3.Count(), text3).Compile())); mem.Warfare_time = 10; Server.Castellan = player.guildName; } if (mem.Promo > 0 && mem.NormalXp == true && mem.PlusXp == false && DateTime.Now.Hour != 10)//조건 : 0 승급 이상 and 플러스경험치 미적용 and 두배타임 X { var temp = XP; if (mem.Promo >= 1 && mem.Promo <= 3) { temp = (int)(temp * 0.015); } if (mem.Promo >= 4 && mem.Promo <= 4) { temp = (int)(temp * 0.008); } if (mem.Promo >= 5 && mem.Promo <= 6) { temp = (int)(temp * 0.002); } if (mem.Promo >= 7) { temp = (int)(temp * 0.002); } mem.XP += (int)(temp * XPMulti * 1); } if (mem.Promo > 0 && mem.NormalXp == false && mem.PlusXp == true && DateTime.Now.Hour != 10)//조건 : 0 승급 이상 and 플러스경험치 적용 and 두배타임 X { var temp = XP; if (mem.Promo >= 1 && mem.Promo <= 3) { temp = (int)(temp * 0.015); } if (mem.Promo >= 4 && mem.Promo <= 4) { temp = (int)(temp * 0.008); } if (mem.Promo >= 5 && mem.Promo <= 6) { temp = (int)(temp * 0.002); } if (mem.Promo >= 7) { temp = (int)(temp * 0.002); } mem.XP += (int)(temp * XPMulti * 2); } if (mem.Promo > 0 && mem.NormalXp == true && mem.PlusXp == false && DateTime.Now.Hour == 10)//조건 : 0 승급 이상 and 플러스경험치 미적용 and 두배타임 OK { var temp = XP; if (mem.Promo >= 1 && mem.Promo <= 3) { temp = (int)(temp * 0.015); } if (mem.Promo >= 4 && mem.Promo <= 4) { temp = (int)(temp * 0.008); } if (mem.Promo >= 5 && mem.Promo <= 6) { temp = (int)(temp * 0.002); } if (mem.Promo >= 7) { temp = (int)(temp * 0.002); } mem.XP += (int)(temp * XPMulti * 2); } if (mem.Promo > 0 && mem.NormalXp == false && mem.PlusXp == true && DateTime.Now.Hour == 10)//조건 : 0 승급 이상 and 플러스경험치 적용 and 두배타임 OK { var temp = XP; if (mem.Promo >= 1 && mem.Promo <= 3) { temp = (int)(temp * 0.015); } if (mem.Promo >= 4 && mem.Promo <= 4) { temp = (int)(temp * 0.008); } if (mem.Promo >= 5 && mem.Promo <= 6) { temp = (int)(temp * 0.002); } if (mem.Promo >= 7) { temp = (int)(temp * 0.002); } mem.XP += (int)(temp * XPMulti * 4); } else if (mem.Promo == 0 && mem.PlusXp == false && mem.NormalXp == true && DateTime.Now.Hour != 10)//조건 : 비승급 and 플러스경험치 미적용 and 두배타임 X { mem.XP += (int)(XP * XPMulti * 1); } else if (mem.Promo == 0 && mem.PlusXp == true && mem.NormalXp == false && DateTime.Now.Hour != 10)//조건 : 비승급 and 플러스경험치 적용 and 두배타임 X { mem.XP += (int)(XP * XPMulti * 2); } else if (mem.Promo == 0 && mem.PlusXp == false && mem.NormalXp == true && DateTime.Now.Hour == 10)//조건 : 비승급 and 플러스경험치 미적용 and 두배타임 OK { mem.XP += (int)(XP * XPMulti * 2); } else if (mem.Promo == 0 && mem.PlusXp == true && mem.NormalXp == false && DateTime.Now.Hour == 10)//조건 : 비승급 and 플러스경험치 적용 and 두배타임 OK { mem.XP += (int)(XP * XPMulti * 4); } if (mem.m_Map == "레이드") { DropLoot(mem); m_Loc.X = m_SpawnLoc.X; m_Loc.Y = m_SpawnLoc.Y; } if (mem.m_Map != "레이드") { DropLoot(player); m_Loc.X = m_SpawnLoc.X; m_Loc.Y = m_SpawnLoc.Y; } } } else { var whisp2 = Server.playerHandler.add.Values.Where(xe => xe.Cmember.Count != 0 && xe.loggedIn && xe.Cmember[0] == player.Cmember[0] && xe.Map == player.Map).ToList(); foreach (var mem in whisp2) { if ((this as script.monster.Monster).Name == "성물") { string text3 = "(" + player.Name + ")" + "님이 성물을 파괴하였습니다" + " "; World.SendToAll(new QueDele("all", new UpdateChatBox(0x08, 0x02, 0, (short)text3.Count(), text3).Compile())); mem.Warfare_time = 10; Server.Castellan = player.guildName; } } if (player.Promo > 0 && player.NormalXp == true && player.PlusXp == false && DateTime.Now.Hour != 10)//조건 : 0 승급 이상 and 플러스경험치 미적용 and 두배타임 X { var temp = XP; if (player.Promo >= 1 && player.Promo <= 3) { temp = (int)(temp * 0.015); } if (player.Promo >= 4 && player.Promo <= 4) { temp = (int)(temp * 0.008); } if (player.Promo >= 5 && player.Promo <= 6) { temp = (int)(temp * 0.002); } if (player.Promo >= 7) { temp = (int)(temp * 0.002); } player.XP += (int)(temp * XPMulti * 1); } if (player.Promo > 0 && player.NormalXp == false && player.PlusXp == true && DateTime.Now.Hour != 10)//조건 : 0 승급 이상 and 플러스경험치 적용 and 두배타임 X { var temp = XP; if (player.Promo >= 1 && player.Promo <= 3) { temp = (int)(temp * 0.015); } if (player.Promo >= 4 && player.Promo <= 4) { temp = (int)(temp * 0.008); } if (player.Promo >= 5 && player.Promo <= 6) { temp = (int)(temp * 0.002); } if (player.Promo >= 7) { temp = (int)(temp * 0.002); } player.XP += (int)(temp * XPMulti * 2); } if (player.Promo > 0 && player.NormalXp == true && player.PlusXp == false && DateTime.Now.Hour == 10)//조건 : 0 승급 이상 and 플러스경험치 미적용 and 두배타임 OK { var temp = XP; if (player.Promo >= 1 && player.Promo <= 3) { temp = (int)(temp * 0.015); } if (player.Promo >= 4 && player.Promo <= 4) { temp = (int)(temp * 0.008); } if (player.Promo >= 5 && player.Promo <= 6) { temp = (int)(temp * 0.002); } if (player.Promo >= 7) { temp = (int)(temp * 0.002); } player.XP += (int)(temp * XPMulti * 2); } if (player.Promo > 0 && player.NormalXp == false && player.PlusXp == true && DateTime.Now.Hour == 10)//조건 : 0 승급 이상 and 플러스경험치 적용 and 두배타임 OK { var temp = XP; if (player.Promo >= 1 && player.Promo <= 3) { temp = (int)(temp * 0.015); } if (player.Promo >= 4 && player.Promo <= 4) { temp = (int)(temp * 0.008); } if (player.Promo >= 5 && player.Promo <= 6) { temp = (int)(temp * 0.002); } if (player.Promo >= 7) { temp = (int)(temp * 0.002); } player.XP += (int)(temp * XPMulti * 4); } else if (player.Promo == 0 && player.PlusXp == false && player.NormalXp == true && DateTime.Now.Hour != 10)//조건 : 비승급 and 플러스경험치 미적용 and 두배타임 X { player.XP += (int)(XP * XPMulti * 1); } else if (player.Promo == 0 && player.PlusXp == true && player.NormalXp == false && DateTime.Now.Hour != 10)//조건 : 비승급 and 플러스경험치 적용 and 두배타임 X { player.XP += (int)(XP * XPMulti * 2); } else if (player.Promo == 0 && player.PlusXp == false && player.NormalXp == true && DateTime.Now.Hour == 10)//조건 : 비승급 and 플러스경험치 미적용 and 두배타임 OK { player.XP += (int)(XP * XPMulti * 2); } else if (player.Promo == 0 && player.PlusXp == true && player.NormalXp == false && DateTime.Now.Hour == 10)//조건 : 비승급 and 플러스경험치 적용 and 두배타임 OK { player.XP += (int)(XP * XPMulti * 4); } else { //player.XP += XP * XPMulti * 100; DropLoot(player); } m_Loc.X = m_SpawnLoc.X; m_Loc.Y = m_SpawnLoc.Y; } } } }
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; } } }
public void TakeDamage(Player caster, Player target, script.spells.Spell spell) { if (caster.Map != "대전장") { 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));// +(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); take += (caster.GetStat("vit") / spell.vitCoff); } 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) { if (caster.Map != "대전장" && caster.Map != "큰대전장") { caster.pklastpk.Add(Server.tickcount.ElapsedMilliseconds); caster.pklastred = Server.tickcount.ElapsedMilliseconds; string text2 = caster.Name + " " + "→ PK " + " " + (target as Player).Name + "→ Die " + "맵 " + caster.Map + " "; World.SendToAll(new QueDele(caster.Serial, "all", new UpdateChatBox(7, 0x65, 1, (short)text2.Count(), text2).Compile())); } if (caster.TakeDam2 == true) { string damg = string.Format("데미지:{0}" + " ", take, 0); caster.client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)damg.Count(), damg).Compile()); } World.SendToAll(new QueDele(caster.m_Map, new HitAnimation(target.Serial, Convert.ToByte(((((float)target.m_HPCur / (float)target.HP) * 100) * 1))).Compile())); } } } if (caster.Map == "대전장" && caster.Color != target.Color) { 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));// +(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); take += (caster.GetStat("vit") / spell.vitCoff); } 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) { if (caster.Map != "대전장" && caster.Map != "큰대전장") { caster.pklastpk.Add(Server.tickcount.ElapsedMilliseconds); caster.pklastred = Server.tickcount.ElapsedMilliseconds; string text2 = caster.Name + " " + "→ PK " + " " + (target as Player).Name + "→ Die " + "맵 " + caster.Map + " "; World.SendToAll(new QueDele(caster.Serial, "all", new UpdateChatBox(7, 0x65, 1, (short)text2.Count(), text2).Compile())); } if (caster.TakeDam2 == true) { string damg = string.Format("데미지:{0}" + " ", take, 0); caster.client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)damg.Count(), damg).Compile()); } World.SendToAll(new QueDele(caster.m_Map, new HitAnimation(target.Serial, Convert.ToByte(((((float)target.m_HPCur / (float)target.HP) * 100) * 1))).Compile())); } } } }
public void HandleCast(int header, script.spells.Spell castspell, Player player, int target = 0, short castx = 0, short casty = 0) { if (castspell is VIEW) { var castonView = World.NewMonsters.Where(xe => xe.Value.m_Serial == target && xe.Value.m_Map != null && xe.Value.m_Map == player.m_Map).FirstOrDefault(); if (castonView.Value != null) { string info = string.Format("<몬스터정보>" + " "); string info2 = string.Format("이름:{0}", castonView.Value.Name + " "); string info3 = string.Format("체력:{0}/{1}", castonView.Value.HPCur, castonView.Value.HP + " "); string info4 = string.Format("파괴:{0}", castonView.Value.Dam + " "); string info5 = string.Format("적중:{0}", castonView.Value.Hit + " "); string info7 = string.Format("방어:{0}", castonView.Value.AC + " "); string info6 = string.Format("경험치:{0}", castonView.Value.XP + " "); client.SendPacket(new UpdateChatBox(0xff, 10, 0, (short)info.Count(), info).Compile()); client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)info2.Count(), info2).Compile()); client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)info3.Count(), info3).Compile()); client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)info4.Count(), info4).Compile()); client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)info5.Count(), info5).Compile()); client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)info7.Count(), info7).Compile()); client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)info6.Count(), info6).Compile()); return; } else { var tele = 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 (tele.Value != null) { string info = string.Format("<유저정보>" + " "); string info2 = string.Format("이름:{0}", tele.Value.Name + " "); string info3 = string.Format("생명:{0}, 마나:{1}", tele.Value.HP, tele.Value.MP + " "); string info4 = string.Format("방어:{0} 적중:{1}", tele.Value.AC, tele.Value.Hit + " "); string info5 = string.Format("힘: {0} 지력: {1} 숙련: {2} 생명: {3}", tele.Value.m_Str, tele.Value.m_Men, tele.Value.m_Dex, tele.Value.m_Vit + " "); string info6 = string.Format("레벨: {0}", tele.Value.Level + " "); client.SendPacket(new UpdateChatBox(0xff, 10, 0, (short)info.Count(), info).Compile()); client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)info2.Count(), info2).Compile()); client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)info3.Count(), info3).Compile()); client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)info4.Count(), info4).Compile()); client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)info5.Count(), info5).Compile()); client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)info6.Count(), info6).Compile()); tele.Value.Loc = new Point2D(player.Loc.X, player.Loc.Y); tele.Value.Map = player.Map; return; } return; } } 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)) { World.SendToAll(new QueDele(player.Map, new CurveMagic(player.Serial, 1, 1, castspell.Seq).Compile())); 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())); int mobile = Serial.NewMobile; World.SendToAll(new QueDele(player.Map, new CreateMagicEffect(mobile, 1, (short)player.X, (short)player.Y, new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, 116 }, 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); return; } } else if (castspell is Trace && player.tempLocate != null && player.tempLocateMap != null) { player.Loc = player.tempLocate; player.Map = player.tempLocateMap; if (tempMusic != 2) { client.SendPacket(new PlayMusic(tempMusic).Compile()); } return; } else if (castspell is ComeBack) { player.tempLocate = new Point2D(player.X, player.Y); player.tempLocateMap = player.Map; player.Loc = new Point2D(98, 100); player.Map = "Village1"; if (player.musicNumber != 2) { tempMusic = player.musicNumber; } client.SendPacket(new PlayMusic(1001).Compile()); return; } else if (castspell is RECALL) { var tele = 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 (tele.Value != null) { tele.Value.Loc = new Point2D(player.Loc.X, player.Loc.Y); tele.Value.Map = player.Map; return; } else { return; } } else if (castspell is 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*/ xe.Value.m_Serial == target) .FirstOrDefault(); if (item1.Value != null) { World.SendToAll(new QueDele(player.Map, new CurveMagic(player.Serial, 1, 1, castspell.Seq).Compile())); item1.Value.PickUp(player); string text = item1.Value.Name + " 을{를} 획득하였습니다"; World.SendToAllRange(new QueDele(player.Map, new BubbleChat(player.Serial, text).Compile()), player, 10); return; } else { return; } } else if (castspell is PlusHeal) { var tele2 = 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 (tele2.Value != null) { int mobile = Serial.NewMobile; World.SendToAll(new QueDele(tele2.Value.Map, new CreateMagicEffect(mobile, 1, (short)tele2.Value.X, (short)tele2.Value.Y, new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, 2 }, 0).Compile())); var tmp = new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + 2000, tele2.Value.m_Map, new DeleteObject(mobile).Compile()); tmp.tempser = mobile; World.TickQue.Add(tmp); tele2.Value.HPCur = tele2.Value.HP; World.SendToAll(new QueDele(player.Map, new CurveMagic(player.Serial, 1, 1, castspell.Seq).Compile())); return; } else { return; } } else if (castspell is Transparency) { if (player.Transparancy != 0) { player.Transparancy = 0; World.SendToAll(new QueDele(player.Map, new SetObjectEffectsPlayer(player).Compile())); } else { player.Transparancy = (Byte)(castspell.Level * 20); World.SendToAll(new QueDele(player.Map, new SetObjectEffectsPlayer(player).Compile())); } return; } else if (castspell is SharpEye) { var playcaston12 = PlayerHandler.getSingleton().add.Where(xe => xe.Value != null && xe.Value.loggedIn && World.Dist2d(xe.Value.m_Loc.X, xe.Value.m_Loc.Y, player.m_Loc.X, player.m_Loc.Y) <= 15 && xe.Value.m_Map != null && xe.Value.m_Map == player.m_Map).ToList(); if (playcaston12 != null) { foreach (var mm in playcaston12) { if (mm.Value.Name != player.Name) { mm.Value.Transparancy = 0; World.SendToAll(new QueDele(mm.Value.Map, new SetObjectEffectsPlayer(mm.Value).Compile())); } } } // return; } if (castspell is StoneCurse) { var castonView = World.NewMonsters.Where(xe => xe.Value.m_Serial == target && xe.Value.m_Map != null && xe.Value.m_Map == player.m_Map).FirstOrDefault(); if (castonView.Value != null) { return; } else { var tele = 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 (tele.Value != null) { tele.Value.Walkbuff_time = 1000; } return; } } if (castspell is Freezing) { var castonView = World.NewMonsters.Where(xe => xe.Value.m_Serial == target && xe.Value.m_Map != null && xe.Value.m_Map == player.m_Map).FirstOrDefault(); if (castonView.Value != null) { return; } else { var tele = 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 (tele.Value != null) { int mobile = Serial.NewMobile; World.SendToAll(new QueDele(tele.Value.Map, new CreateMagicEffect(mobile, 1, (short)tele.Value.X, (short)tele.Value.Y, new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, 62 }, 0).Compile())); var tmp = new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + 10000, tele.Value.m_Map, new DeleteObject(mobile).Compile()); tmp.tempser = mobile; World.TickQue.Add(tmp); } return; } } if (castspell is Butterfly) { var tele = 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 (tele.Value != null) { tele.Value.BHitbuff_time = 500; tele.Value.BHitbuff = 500; tele.Value.client.SendPacket(new UpdateCharStats(tele.Value).Compile()); int mobile = Serial.NewMobile; World.SendToAll(new QueDele(tele.Value.Map, new CreateMagicEffect(mobile, 1, (short)tele.Value.X, (short)tele.Value.Y, new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, 50 }, 0).Compile())); var tmp = new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + 2000, tele.Value.m_Map, new DeleteObject(mobile).Compile()); tmp.tempser = mobile; World.TickQue.Add(tmp); World.SendToAll(new QueDele(tele.Value.Map, new CurveMagic(tele.Value.Serial, 1, 1, castspell.Seq).Compile())); return; } else { if (player.Hit < 100) { player.BHitbuff_time = 500; player.BHitbuff = 30; player.client.SendPacket(new UpdateCharStats(player).Compile()); int mobile = Serial.NewMobile; World.SendToAll(new QueDele(player.Map, new CreateMagicEffect(mobile, 1, (short)player.X, (short)player.Y, new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, 50 }, 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); World.SendToAll(new QueDele(player.Map, new CurveMagic(player.Serial, 1, 1, castspell.Seq).Compile())); return; } if (player.Hit > 100) { player.BHitbuff_time = 500; player.BHitbuff = (player.Hit / 100) * 30; player.client.SendPacket(new UpdateCharStats(player).Compile()); int mobile = Serial.NewMobile; World.SendToAll(new QueDele(player.Map, new CreateMagicEffect(mobile, 1, (short)player.X, (short)player.Y, new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, 50 }, 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); World.SendToAll(new QueDele(player.Map, new CurveMagic(player.Serial, 1, 1, castspell.Seq).Compile())); return; } } } if (castspell is FireWall) { var castonView = World.NewMonsters.Where(xe => xe.Value.m_Serial == target && xe.Value.m_Map != null && xe.Value.m_Map == player.m_Map).FirstOrDefault(); if (castonView.Value != null) { return; } else { var tele = 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 (tele.Value != null) { int mobile = Serial.NewMobile; World.SendToAll(new QueDele(tele.Value.Map, new CreateMagicEffect(mobile, 1, (short)tele.Value.X, (short)tele.Value.Y, new byte[] { 4, 7, 7, 7, 7, 7, 7, 7, 7, 62 }, 0).Compile())); var tmp = new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + 10000, tele.Value.m_Map, new DeleteObject(mobile).Compile()); tmp.tempser = mobile; World.TickQue.Add(tmp); } //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" || player.TakeDam == false) ) { 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.50)) { return; } var miyamo = player.Equipped.Where(xe => xe.GetType() == typeof(script.item.MiyamotosStick)).FirstOrDefault(); var recast = castspell.RecastTime; //if (miyamo != null) { recast -= 1000; recast -= (player.m_Men / 3000) * 300; } if (LKCamelot.Server.tickcount.ElapsedMilliseconds - recast > castspell.Cooldown) { castspell.Cooldown = LKCamelot.Server.tickcount.ElapsedMilliseconds; } else { return; } player.HPCur -= (int)(player.HPCur * 0.5); castspell.CheckLevelUp(player); //System.IO.Stream soundStream0 = (Properties.Resources._33); //new System.Media.SoundPlayer(soundStream0).Play(); 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.50)) { 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 -= (int)(player.HPCur * 0.5); 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; } }
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; } }