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 CreateMagicEffect(Point2D target, string map, byte sprite, int time = 1500) { int mobile = Serial.NewMobile; World.SendToAll(new QueDele(map, new CreateMagicEffect(mobile, 1, (short)target.X, (short)target.Y, new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, sprite }, 0).Compile())); var tmp = new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + time, map, new DeleteObject(mobile).Compile()); tmp.tempser = mobile; World.TickQue.Add(tmp); }
public void removePlayerClient(IOClient client) { Player cli; // add.TryRemove(client, out cli); if (client.player != null) { World.SendToAll(new QueDele(client.player.Map, new DeleteObject(client.player.Serial).Compile())); } Console.WriteLine("Players Online: " + add.Count); }
public void TakeDamage(Player player, Monster mob, int take) { float h = ((float)player.Hit / ((float)player.Hit + (float)mob.Hit)) * 200; if (h >= 100 || new Random().Next(0, 100) < (int)h) { if (player.Weapon is script.item.IProc) { take += (player.Weapon as script.item.IProc).Proc(player, mob); } mob.HPCur -= take; World.SendToAll(new QueDele(mob.m_Map, new HitAnimation(mob.m_Serial, Convert.ToByte(((((float)mob.HPCur / (float)mob.HP) * 100) * 1))).Compile())); if (mob.HPCur <= 0) { if (player.Promo > 0) { var temp = mob.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 += temp;// *3; } else { player.XP += mob.XP;// *3; } mob.DropLoot(player); mob.m_Loc.X = mob.m_SpawnLoc.X; mob.m_Loc.Y = mob.m_SpawnLoc.Y; } } }
public void TakeDamage(Player player, Player player2, int take) { float h = ((float)player.Hit / ((float)player.Hit + (float)player2.Hit)) * 200; if (h >= 100 || new Random().Next(0, 100) < (int)h) { if (player.Weapon is script.item.IProc) { take += (player.Weapon as script.item.IProc).Proc(player, null, player); } player2.HPCur -= take; World.SendToAll(new QueDele(player2.m_Map, new HitAnimation(player2.Serial, Convert.ToByte(((((float)player2.m_HPCur / (float)player2.HP) * 100) * 1))).Compile())); } }
public void HandleMelee(Player play, int swingdir) { var Targets = World.NewMonsters.Where(xe => xe.Value.m_Map != null && xe.Value.m_Map == play.Map && xe.Value.m_Loc.X == AdjecentTile(play, swingdir).X&& xe.Value.m_Loc.Y == AdjecentTile(play, swingdir).Y && xe.Value.Alive) .Select(xe => xe); var Targets2 = PlayerHandler.getSingleton().add.Where(xe => xe.Value != null && xe.Value.Map != null && xe.Value != play && xe.Value.Map == play.Map && xe.Value.Loc.X == AdjecentTile(play, swingdir).X&& xe.Value.Loc.Y == AdjecentTile(play, swingdir).Y).Select(xe => xe); if (play.m_Buffs.Where(xe => xe.Name == "TRIPLE").FirstOrDefault() != null) { Targets = World.NewMonsters.Where(xe => xe.Value.m_Map != null && xe.Value.m_Map == play.Map && ( (xe.Value.m_Loc.X == AdjecentTile(play, swingdir).X&& xe.Value.m_Loc.Y == AdjecentTile(play, swingdir).Y) || (xe.Value.m_Loc.X == AdjecentTile(play, swingdir - 1).X&& xe.Value.m_Loc.Y == AdjecentTile(play, swingdir - 1).Y) || (xe.Value.m_Loc.X == AdjecentTile(play, swingdir + 1).X&& xe.Value.m_Loc.Y == AdjecentTile(play, swingdir + 1).Y) ) && xe.Value.Alive) .Select(xe => xe); Targets2 = PlayerHandler.getSingleton().add.Where(xe => xe.Key != null && xe.Value != null && xe.Value.Map == play.Map && ( (xe.Value.m_Loc.X == AdjecentTile(play, swingdir).X&& xe.Value.m_Loc.Y == AdjecentTile(play, swingdir).Y) || (xe.Value.m_Loc.X == AdjecentTile(play, swingdir - 1).X&& xe.Value.m_Loc.Y == AdjecentTile(play, swingdir - 1).Y) || (xe.Value.m_Loc.X == AdjecentTile(play, swingdir + 1).X&& xe.Value.m_Loc.Y == AdjecentTile(play, swingdir + 1).Y) ) ).Select(xe => xe); } foreach (var plays in Targets2) { if (play.Map == "Village1" || play.Map == "Rest" || play.Map == "Arnold" || play.Map == "Loen" || plays.Value.Level < play.Level - 40) { break; } var take = (play.Dam - plays.Value.AC); if (take <= 0) { take = 1; } if (play.m_Buffs.Where(xe => xe.Name == "TRIPLE").FirstOrDefault() != null) { var ttt = (play.m_Buffs.Where(xe => xe.Name == "TRIPLE").FirstOrDefault().Level * 0.05); var tpp = take * (ttt + 0.40d); take = (int)tpp; int tempface1 = play.Face - 1, tempface2 = play.Face + 1; if (tempface1 == -1) { tempface1 = 7; } if (tempface2 == 8) { tempface2 = 0; } World.TickQue.Add(new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + (int)(play.AttackSpeed * 0.1d), play.Map, new SwingAnimation(play.Serial, (short)(tempface1)).Compile())); World.TickQue.Add(new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + (int)(play.AttackSpeed * 0.2d), play.Map, new SwingAnimation(play.Serial, (short)(tempface2)).Compile())); World.TickQue.Add(new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + (int)(play.AttackSpeed * 0.3d), play.Map, new ChangeFace(play.Serial, (short)(play.Face)).Compile())); } TakeDamage(play, plays.Value, take); } foreach (var mobs in Targets) { var take = (play.Dam - mobs.Value.AC); if (take <= 0) { take = 1; } if (play.m_Buffs.Where(xe => xe.Name == "TRIPLE").FirstOrDefault() != null) { var ttt = (play.m_Buffs.Where(xe => xe.Name == "TRIPLE").FirstOrDefault().Level * 0.05); var tpp = take * (ttt + 0.40d); take = (int)tpp; int tempface1 = play.Face - 1, tempface2 = play.Face + 1; if (tempface1 == -1) { tempface1 = 7; } if (tempface2 == 8) { tempface2 = 0; } World.TickQue.Add(new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + (int)(play.AttackSpeed * 0.1d), play.Map, new SwingAnimation(play.Serial, (short)(tempface1)).Compile())); World.TickQue.Add(new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + (int)(play.AttackSpeed * 0.2d), play.Map, new SwingAnimation(play.Serial, (short)(tempface2)).Compile())); World.TickQue.Add(new QueDele(LKCamelot.Server.tickcount.ElapsedMilliseconds + (int)(play.AttackSpeed * 0.3d), play.Map, new ChangeFace(play.Serial, (short)(play.Face)).Compile())); } TakeDamage(play, mobs.Value, take); } World.SendToAll(new QueDele(play.Serial, play.Map, new SwingAnimationChar(play.Serial, play.Face).Compile())); }
public void TakeDamage(Player player, object tar, int take) { float h = 0; if (tar is Player) { h = ((float)player.Hit / ((float)player.Hit + (float)(tar as Player).Hit)) * 200; } else if (tar is script.monster.Monster) { h = ((float)player.Hit / ((float)player.Hit + (float)(tar as script.monster.Monster).Hit)) * 200; } if (h >= 100 || new Random().Next(0, 100) < (int)h) { if (player.Weapon is script.item.IProc) { if (tar is Player) { take += (player.Weapon as script.item.IProc).Proc(player, null, tar as Player); } else if (tar is script.monster.Monster) { take += (player.Weapon as script.item.IProc).Proc(player, tar as script.monster.Monster); } } var swingbuff = player.m_Buffs.Where(xe => xe.BuffEffect.BuffType == script.spells.BuffCase.Triple || xe.BuffEffect.BuffType == script.spells.BuffCase.Twister).FirstOrDefault(); if (swingbuff != null) { var ttt = swingbuff.Level * 0.05; take = (int)(take * (ttt + 0.40d)); } if (tar is Player) { (tar as Player).HPCur -= take; World.SendToAll(new QueDele((tar as Player).m_Map, new HitAnimation((tar as Player).Serial, Convert.ToByte(((((float)(tar as Player).HPCur / (float)(tar as Player).HP) * 100) * 1))).Compile())); } else if (tar is script.monster.Monster) { (tar as script.monster.Monster).HPCur -= take; World.SendToAll(new QueDele((tar as script.monster.Monster).m_Map, new HitAnimation((tar as script.monster.Monster).m_Serial, Convert.ToByte(((((float)(tar as script.monster.Monster).HPCur / (float)(tar as script.monster.Monster).HP) * 100) * 1))).Compile())); if ((tar as script.monster.Monster).HPCur <= 0) { if (player.Promo > 0) { var temp = (tar as script.monster.Monster).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;// *3; } else { player.XP += (tar as script.monster.Monster).XP;// *3; } (tar as script.monster.Monster).DropLoot(player); (tar as script.monster.Monster).m_Loc.X = (tar as script.monster.Monster).m_SpawnLoc.X; (tar as script.monster.Monster).m_Loc.Y = (tar as script.monster.Monster).m_SpawnLoc.Y; } } } }
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" || play.TakeDam == false) { continue; } take -= (tar as Player).AC; if (take <= 0) { take = 1; } if (play.Map != "대전장") { TakeDamage(play, tar, take); } if (play.Map == "대전장" && play.Color != (tar as Player).Color) { 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) { if (play.Map != "대전장" && play.Map != "큰대전장") { play.pklastpk.Add(Server.tickcount.ElapsedMilliseconds); play.pklastred = Server.tickcount.ElapsedMilliseconds; string text2 = play.Name + " " + "→ PK " + " " + (tar as Player).Name + "→ Die " + "맵 " + play.Map + " "; World.SendToAll(new QueDele(play.Serial, "all", new UpdateChatBox(7, 0x65, 1, (short)text2.Count(), text2).Compile())); } /* * if (play.PVPSubRank < (tar as Player).PVPSubRank) * { * if ((tar as Player).PVPSubRank - play.PVPSubRank <= 3) * { * play.m_Win += 1; * var temp = 5000; * * if (play.PVPSubRank >= 0 && play.PVPSubRank <= 3) * temp = (int)(temp * 1.0); * if (play.PVPSubRank >= 4 && play.PVPSubRank <= 4) * temp = (int)(temp * 0.8); * if (play.PVPSubRank >= 5 && play.PVPSubRank <= 6) * temp = (int)(temp * 0.05); * if (play.PVPSubRank >= 7 && play.PVPSubRank <= 10) * temp = (int)(temp * 0.02); * if (play.PVPSubRank >= 7 && play.PVPSubRank <= 11) * temp = (int)(temp * 0.02); * if (play.PVPSubRank >= 12) * temp = (int)(temp * 0.01); * play.PvPPoint += temp * 1; * * Console.WriteLine("대전테스트"); * } * } * if (play.PVPSubRank > (tar as Player).PVPSubRank) * { * if (play.PVPSubRank - (tar as Player).PVPSubRank <= 3) * { * play.m_Win += 1; * * var temp = 5000; * * if (play.PVPSubRank >= 0 && play.PVPSubRank <= 3) * temp = (int)(temp * 1.0); * if (play.PVPSubRank >= 4 && play.PVPSubRank <= 4) * temp = (int)(temp * 0.8); * if (play.PVPSubRank >= 5 && play.PVPSubRank <= 6) * temp = (int)(temp * 0.05); * if (play.PVPSubRank >= 7 && play.PVPSubRank <= 10) * temp = (int)(temp * 0.02); * if (play.PVPSubRank >= 7 && play.PVPSubRank <= 11) * temp = (int)(temp * 0.02); * if (play.PVPSubRank >= 12) * temp = (int)(temp * 0.01); * play.PvPPoint += temp * 1; * Console.WriteLine("대전테스트2"); * } * } * if (play.PVPSubRank == (tar as Player).PVPSubRank) * { * if (play.PVPSubRank - (tar as Player).PVPSubRank <= 3) * { * play.m_Win += 1; * * var temp = 5000; * * if (play.PVPSubRank >= 0 && play.PVPSubRank <= 3) * temp = (int)(temp * 1.0); * if (play.PVPSubRank >= 4 && play.PVPSubRank <= 4) * temp = (int)(temp * 0.8); * if (play.PVPSubRank >= 5 && play.PVPSubRank <= 6) * temp = (int)(temp * 0.05); * if (play.PVPSubRank >= 7 && play.PVPSubRank <= 10) * temp = (int)(temp * 0.02); * if (play.PVPSubRank >= 7 && play.PVPSubRank <= 11) * temp = (int)(temp * 0.02); * if (play.PVPSubRank >= 12) * temp = (int)(temp * 0.01); * play.PvPPoint += temp * 1; * Console.WriteLine("대전테스트3"); * } * } * */ } } else if (tar is script.monster.Monster) { take -= (tar as script.monster.Monster).AC; if (take <= 0) { take = 1; } TakeDamage(play, tar, take); } } }
public void TakeDamage(Player player, object tar, int take) { float h = 0; if (tar is Player) { h = ((float)player.Hit / ((float)player.Hit + (float)(tar as Player).Hit)) * 200; } else if (tar is script.monster.Monster) { h = ((float)player.Hit / ((float)player.Hit + (float)(tar as script.monster.Monster).Hit)) * 200; } if (h >= 100 || new Random().Next(0, 100) < (int)h) { if (player.Weapon is script.item.IProc) { if (tar is Player) { take += (player.Weapon as script.item.IProc).Proc(player, null, tar as Player); } else if (tar is script.monster.Monster) { take += (player.Weapon as script.item.IProc).Proc(player, tar as script.monster.Monster); } } var swingbuff = player.m_Buffs.Where(xe => xe.BuffEffect.BuffType == script.spells.BuffCase.Triple || xe.BuffEffect.BuffType == script.spells.BuffCase.Twister).FirstOrDefault(); if (swingbuff != null) { var ttt = swingbuff.Level * 0.05; take = (int)(take * (ttt + 0.40d)); } if (tar is Player) { (tar as Player).HPCur -= take; World.SendToAll(new QueDele((tar as Player).m_Map, new HitAnimation((tar as Player).Serial, Convert.ToByte(((((float)(tar as Player).HPCur / (float)(tar as Player).HP) * 100) * 1))).Compile())); if (player.TakeDam2 == true) { string damg = string.Format("데미지:{0}" + " ", take, 0); player.client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)damg.Count(), damg).Compile()); } } else if (tar is script.monster.Monster) { (tar as script.monster.Monster).HPCur -= take; World.SendToAll(new QueDele((tar as script.monster.Monster).m_Map, new HitAnimation((tar as script.monster.Monster).m_Serial, Convert.ToByte(((((float)(tar as script.monster.Monster).HPCur / (float)(tar as script.monster.Monster).HP) * 100) * 1))).Compile())); if (player.TakeDam2 == true) { string damg = string.Format("데미지:{0}" + " ", take, 0); player.client.SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)damg.Count(), damg).Compile()); } if ((tar as script.monster.Monster).HPCur <= 0) { int ExpRatio = Server.Exp_Ratio; /* if ((tar 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 (player.member.Count != 0) { switch (player.member.Count()) { case 2: XPMulti = 1.05 / (2); break; case 3: XPMulti = 1.1 / (3); break; case 4: XPMulti = 1.15 / 4; 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) { System.Diagnostics.Debug.Write(player.Name); if (mem.Name != player.Name) { XPMulti = XPMultiTemp / mem.member.Count() * 1.5; } else { XPMulti = XPMultiTemp; } if ((tar 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 ((tar 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 = (tar as script.monster.Monster).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 += temp * 1; // *3; } if (mem.Promo > 0 && mem.NormalXp == false && mem.PlusXp == true && DateTime.Now.Hour != 10) //조건 : 0 승급 이상 and 플러스경험치 적용 and 두배타임 X { var temp = (tar as script.monster.Monster).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 += temp * 2; // *3; } if (mem.Promo > 0 && mem.NormalXp == true && mem.PlusXp == false && DateTime.Now.Hour == 10) //조건 : 0 승급 이상 and 플러스경험치 미적용 and 두배타임 OK { var temp = (tar as script.monster.Monster).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 += temp * 2; // *3; } if (mem.Promo > 0 && mem.NormalXp == false && mem.PlusXp == true && DateTime.Now.Hour == 10) //조건 : 0 승급 이상 and 플러스경험치 적용 and 두배타임 OK { var temp = (tar as script.monster.Monster).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 += temp * 4; // *3; } else if (mem.Promo == 0 && mem.PlusXp == false && mem.NormalXp == true && DateTime.Now.Hour != 10) //조건 : 비승급 and 플러스경험치 미적용 and 두배타임 X { mem.XP += (tar as script.monster.Monster).XP * 1; // *3; } else if (mem.Promo == 0 && mem.PlusXp == true && mem.NormalXp == false && DateTime.Now.Hour != 10) //조건 : 비승급 and 플러스경험치 적용 and 두배타임 X { mem.XP += (tar as script.monster.Monster).XP * 2; // *3; } else if (mem.Promo == 0 && mem.PlusXp == false && mem.NormalXp == true && DateTime.Now.Hour == 10) //조건 : 비승급 and 플러스경험치 미적용 and 두배타임 OK { mem.XP += (tar as script.monster.Monster).XP * 2; // *3; } else if (mem.Promo == 0 && mem.PlusXp == true && mem.NormalXp == false && DateTime.Now.Hour == 10) //조건 : 비승급 and 플러스경험치 적용 and 두배타임 OK { mem.XP += (tar as script.monster.Monster).XP * 4; // *3; } //mem.XP += (tar as script.monster.Monster).XP * 100;// *3; if (mem.m_Map == "레이드") { (tar as script.monster.Monster).DropLoot(mem); (tar as script.monster.Monster).m_Loc.X = (tar as script.monster.Monster).m_SpawnLoc.X; (tar as script.monster.Monster).m_Loc.Y = (tar as script.monster.Monster).m_SpawnLoc.Y; } if (mem.m_Map != "레이드") { (tar as script.monster.Monster).DropLoot(player); (tar as script.monster.Monster).m_Loc.X = (tar as script.monster.Monster).m_SpawnLoc.X; (tar as script.monster.Monster).m_Loc.Y = (tar as script.monster.Monster).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 ((tar 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 = (tar as script.monster.Monster).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 += temp * 1; // *3; } if (player.Promo > 0 && player.NormalXp == false && player.PlusXp == true && DateTime.Now.Hour != 10) //조건 : 0 승급 이상 and 플러스경험치 적용 and 두배타임 X { var temp = (tar as script.monster.Monster).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 += temp * 2; // *3; } if (player.Promo > 0 && player.NormalXp == true && player.PlusXp == false && DateTime.Now.Hour == 10) //조건 : 0 승급 이상 and 플러스경험치 미적용 and 두배타임 OK { var temp = (tar as script.monster.Monster).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 += temp * 2; // *3; } if (player.Promo > 0 && player.NormalXp == false && player.PlusXp == true && DateTime.Now.Hour == 10) //조건 : 0 승급 이상 and 플러스경험치 적용 and 두배타임 OK { var temp = (tar as script.monster.Monster).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 += temp * 4; // *3; } else if (player.Promo == 0 && player.PlusXp == false && player.NormalXp == true && DateTime.Now.Hour != 10) //조건 : 비승급 and 플러스경험치 미적용 and 두배타임 X { player.XP += (tar as script.monster.Monster).XP * 1 * ExpRatio; // *3; } else if (player.Promo == 0 && player.PlusXp == true && player.NormalXp == false && DateTime.Now.Hour != 10) //조건 : 비승급 and 플러스경험치 적용 and 두배타임 X { player.XP += (tar as script.monster.Monster).XP * 2; // *3; } else if (player.Promo == 0 && player.PlusXp == false && player.NormalXp == true && DateTime.Now.Hour == 10) //조건 : 비승급 and 플러스경험치 미적용 and 두배타임 OK { player.XP += (tar as script.monster.Monster).XP * 2; // *3; } else if (player.Promo == 0 && player.PlusXp == true && player.NormalXp == false && DateTime.Now.Hour == 10) //조건 : 비승급 and 플러스경험치 적용 and 두배타임 OK { player.XP += (tar as script.monster.Monster).XP * 4; // *3; } //player.XP += (tar as script.monster.Monster).XP * 100;// *3; if (player.m_Map != "레이드") { (tar as script.monster.Monster).DropLoot(player); (tar as script.monster.Monster).m_Loc.X = (tar as script.monster.Monster).m_SpawnLoc.X; (tar as script.monster.Monster).m_Loc.Y = (tar as script.monster.Monster).m_SpawnLoc.Y; } } } } } }
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 Tick() { if (NewItems == null) { NewItems = new ConcurrentDictionary <Serial, LKCamelot.script.item.Item>(); NewAuctions = new ConcurrentDictionary <Serial, script.item.AuctionItem>(); foreach (var items in BinaryIO.LoadItems()) { NewItems.TryAdd(items.m_Serial, items); } foreach (var play in BinaryIO.LoadAuctions()) { NewAuctions.TryAdd(play.item.m_Serial, play); } foreach (var play in BinaryIO.LoadPlayers()) { handler.add.TryAdd(play.Name, play); } Console.WriteLine("Loaded " + NewAuctions.Count + " Auctions."); Console.WriteLine("Loaded " + NewItems.Count + " Items."); Console.WriteLine("Loaded " + handler.add.Count + " Players."); } if (m_MObjects == null) { m_MObjects = new ConcurrentDictionary <Serial, Serial>(); foreach (var mobile in handler.add.Values) { m_MObjects.TryAdd(mobile.Serial, mobile.Serial); } foreach (var item in NewItems) { m_MObjects.TryAdd(item.Key, item.Key); } foreach (var item in NewAuctions) { m_MObjects.TryAdd(item.Key, item.Key); } } if (NewNpcs == null) { NewNpcs = new Dictionary <Serial, LKCamelot.script.npc.BaseNPC>() { { 1, new script.npc.Arnold() }, { 2, new script.npc.Employee() }, { 3, new script.npc.Loen() }, { 4, new script.npc.Aron() }, { 7, new script.npc.Boy() }, { 5, new script.npc.Alias() }, } } ; if (World.NewMonsters == null) { Spawnere.Spawn(); } if (spawner == null) { spawner = Task.Factory.StartNew(() => { spawnrun(); } ); } QueDele tq; List <QueDele> TickQued = new List <QueDele>(); try { TickQued = TickQue.ToList(); } catch { }; foreach (var tick in TickQued) { if (tick == null) { TickQue.RemoveAt(0); continue; } if (tick.Serial < LKCamelot.Server.tickcount.ElapsedMilliseconds) { SendToAll(tick); TickQue.Remove(tick); // var ttt = tick.Packet.Skip(1).Take(4); Serial temp; if (m_MObjects.ContainsKey(tick.tempser)) { m_MObjects.TryRemove(tick.tempser, out temp); } } } if (LKCamelot.Server.tickcount.ElapsedMilliseconds - 3600000 > lastitemsave) { lastitemsave = LKCamelot.Server.tickcount.ElapsedMilliseconds; SaveAll(); string chat = "[Alias]: Bring your friends to the Last Kingdom!"; SendToAll(new QueDele("all", new UpdateChatBox(0x08, 0x02, 0, (short)chat.Count(), chat).Compile())); chat = "[Alias]: Visit the trader at: lk.kingdomofk.net/trader!"; SendToAll(new QueDele("all", new UpdateChatBox(0x08, 0x02, 0, (short)chat.Count(), chat).Compile())); } foreach (var playe in w_server.OnlineConnections) { if (playe.Client == null || playe.Client.player == null) { continue; } KeyValuePair <string, Player> play = new KeyValuePair <string, Player>(playe.Client.player.Name, playe.Client.player); if (play.Value == null || play.Value.loggedIn == false) { continue; } if ((play.Value.client.keepalive + 15000) < Server.tickcount.ElapsedMilliseconds) { w_server.Disconnect(play.Value.client.connection); } if (play.Value.client.connection == null || play.Value.client.connection.Socket == null) { w_server.Disconnect(play.Value.client.connection); } if (play.Value.Color == 0) { if (play.Value.pklastpk.Count > 0) { play.Value.Color = 1; } else if (Server.tickcount.ElapsedMilliseconds > play.Value.pkPinkDelay && Server.tickcount.ElapsedMilliseconds - play.Value.pkpinkktime < play.Value.pkPinkDelay) { play.Value.Color = 2; } } if (play.Value.Color == 2) { if (Server.tickcount.ElapsedMilliseconds - play.Value.pkpinkktime > play.Value.pkPinkDelay) { play.Value.Color = 0; } if (play.Value.pklastpk.Count > 0) { play.Value.Color = 1; } } if (play.Value.Color == 1) { try { long[] pkslist = new long[play.Value.pklastpk.Count]; play.Value.pklastpk.CopyTo(pkslist); if (Server.tickcount.ElapsedMilliseconds - play.Value.pklastred > play.Value.pkRedDelay) { play.Value.pklastred = Server.tickcount.ElapsedMilliseconds; play.Value.pklastpk.RemoveAt(0); } if (play.Value.pklastpk.Count == 0) { play.Value.Color = 0; } /* foreach (var pk in pkslist) * { * if (Server.tickcount.ElapsedMilliseconds - pk > play.Value.pkRedDelay) * play.Value.pklastpk.Remove(pk); * }*/ } catch { } } if (play.Value.AutoMana && play.Value.MPCur < (play.Value.MP * play.Value.AutoManaP)) { var pot = NewItems.Where(xe => xe.Value.Parent != null && (xe.Value.Parent == play.Value || xe.Value.ParSer == play.Value.Serial) && (xe.Value.Name == "Magic Drug" || xe.Value.Name == "Full Magic Drug")).FirstOrDefault(); if (pot.Value != null) { pot.Value.Use(play.Value); } } if (play.Value.AutoHP && play.Value.HPCur < (play.Value.HP * play.Value.AutoHPP)) { var pot = NewItems.Where(xe => xe.Value.Parent != null && (xe.Value.Parent == play.Value || xe.Value.ParSer == play.Value.Serial) && (xe.Value.Name == "Life Drug" || xe.Value.Name == "Full Life Drug")).FirstOrDefault(); if (pot.Value != null) { pot.Value.Use(play.Value); } } if (play.Value.AutoHit && LKCamelot.Server.tickcount.ElapsedMilliseconds - play.Value.AttackSpeed > play.Value.autohittick && LKCamelot.Server.tickcount.ElapsedMilliseconds - play.Value.AttackSpeed > play.Value.client.LastAttack) { play.Value.autohittick = LKCamelot.Server.tickcount.ElapsedMilliseconds; play.Value.client.LastAttack = LKCamelot.Server.tickcount.ElapsedMilliseconds; World.SendToAll(new QueDele(play.Value.Map, new SwingAnimationChar(play.Value.Serial, play.Value.Face).Compile())); play.Value.client.combatHandler.HandleMelee(play.Value, play.Value.Face); } if (LKCamelot.Server.tickcount.ElapsedMilliseconds - play.Value.RegenTick > play.Value.LastRegen) { float regamt = 0.1f; if (play.Value.Map == "Rest") { regamt = 0.25f; } play.Value.LastRegen = LKCamelot.Server.tickcount.ElapsedMilliseconds; var playhp = play.Value; playhp.HPCur += (int)((float)playhp.HP * regamt); playhp.MPCur += (int)((float)playhp.MP * regamt); } /* var Items = World.NewItems.Where(xe => xe.Value.m_Map != null * && xe.Value.m_Map == play.Value.Map) * .Select(xe => xe); */ /* var LocalPlayers = handler.add.Where(xe => xe.Value != null && xe.Value.Map != null * && xe.Value.loggedIn && xe.Value.Map == play.Value.Map).Select(xe => xe); * * * * foreach (var playee in LocalPlayers) * { * if (playee.Key == play.Key) * continue; * * if (!play.Value.InstancedObjects.Contains(playee.Value.Serial)) * { * play.Value.InstancedObjects.Add(playee.Value.Serial); * play.Value.client.SendPacket(new CreateChar(playee.Value, playee.Value.Serial).Compile()); * play.Value.client.SendPacket(new SetObjectEffectsPlayer(playee.Value).Compile()); * } * }*/ // System.Threading.Tasks.Parallel.ForEach(Monsters, mob => ProcMobs(play, mob)); } }
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; } }