private void CreateZone(bool create = true) { if (create) { WarEffects.Clear(); for (int y = Info.KingLocation.Y - Info.KingSize; y <= Info.KingLocation.Y + Info.KingSize; y++) { if (y < 0) { continue; } if (y >= ConquestMap.Height) { break; } for (int x = Info.KingLocation.X - Info.KingSize; x <= Info.KingLocation.X + Info.KingSize; x += Math.Abs(y - Info.KingLocation.Y) == Info.KingSize ? 1 : Info.KingSize * 2) { if (x < 0) { continue; } if (x >= ConquestMap.Width) { break; } if (!ConquestMap.Cells[x, y].Valid) { continue; } SpellObject spell = new SpellObject { ExpireTime = long.MaxValue, Spell = Spell.TrapHexagon, TickSpeed = int.MaxValue, CurrentLocation = new Point(x, y), CurrentMap = ConquestMap, Decoration = true }; ConquestMap.Cells[x, y].Add(spell); WarEffects.Add(spell); spell.Spawned(); } } } else { for (int i = 0; i < WarEffects.Count; i++) { //if (WarEffects[i].CurrentLocation != null) //{ WarEffects[i].Despawn(); ConquestMap.RemoveObject(WarEffects[i]); //} } WarEffects.Clear(); } }
private void CompleteMagic(IList<object> data) { bool train = false; PlayerObject player = (PlayerObject)data[0]; UserMagic magic = (UserMagic)data[1]; int value, value2; Point location; Cell cell; MirDirection dir; MonsterObject monster; Point front; switch (magic.Spell) { #region HellFire case Spell.HellFire: value = (int)data[2]; dir = (MirDirection)data[4]; location = Functions.PointMove((Point)data[3], dir, 1); int count = (int)data[5] - 1; if (!ValidPoint(location)) return; if (count > 0) { DelayedAction action = new DelayedAction(DelayedType.Magic, Envir.Time + 100, player, magic, value, location, dir, count); ActionList.Add(action); } cell = GetCell(location); if (cell.Objects == null) return; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (target.IsAttackTarget(player)) { if (target.Attacked(player, value, DefenceType.MAC, false) > 0) player.LevelMagic(magic); return; } break; } } break; #endregion #region SummonSkeleton case Spell.SummonSkeleton: monster = (MonsterObject)data[2]; front = (Point)data[3]; if (ValidPoint(front)) monster.Spawn(this, front); else monster.Spawn(player.CurrentMap, player.CurrentLocation); break; #endregion #region FireBang, IceStorm case Spell.IceStorm: case Spell.FireBang: value = (int)data[2]; location = (Point)data[3]; for (int y = location.Y - 1; y <= location.Y + 1; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 1; x <= location.X + 1; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (target.IsAttackTarget(player)) { if (target.Attacked(player, value, DefenceType.MAC, false) > 0) train = true; } break; } } } } break; #endregion #region MassHiding case Spell.MassHiding: value = (int)data[2]; location = (Point)data[3]; for (int y = location.Y - 1; y <= location.Y + 1; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 1; x <= location.X + 1; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (target.IsFriendlyTarget(player)) { for (int b = 0; b < target.Buffs.Count; b++) if (target.Buffs[b].Type == BuffType.Hiding) return; target.AddBuff(new Buff { Type = BuffType.Hiding, Caster = player, ExpireTime = Envir.Time + value * 1000 }); target.OperateTime = 0; train = true; } break; } } } } break; #endregion #region SoulShield, BlessedArmour case Spell.SoulShield: case Spell.BlessedArmour: value = (int)data[2]; location = (Point)data[3]; BuffType type = magic.Spell == Spell.SoulShield ? BuffType.SoulShield : BuffType.BlessedArmour; for (int y = location.Y - 3; y <= location.Y + 3; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 3; x <= location.X + 3; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (target.IsFriendlyTarget(player)) { target.AddBuff(new Buff { Type = type, Caster = player, ExpireTime = Envir.Time + value * 1000, Values = new int[]{ target.Level / 7 + 4 } }); target.OperateTime = 0; train = true; } break; } } } } break; #endregion #region FireWall case Spell.FireWall: value = (int)data[2]; location = (Point)data[3]; player.LevelMagic(magic); if (ValidPoint(location)) { cell = GetCell(location); bool cast = true; if (cell.Objects != null) for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Spell || ((SpellObject)target).Spell != Spell.FireWall) continue; cast = false; break; } if (cast) { SpellObject ob = new SpellObject { Spell = Spell.FireWall, Value = value, ExpireTime = Envir.Time + (10 + value / 2) * 1000, TickSpeed = 2000, Caster = player, CurrentLocation = location, CurrentMap = this, }; AddObject(ob); ob.Spawned(); } } dir = MirDirection.Up; for (int i = 0; i < 4; i++) { location = Functions.PointMove((Point)data[3], dir, 1); dir += 2; if (!ValidPoint(location)) continue; cell = GetCell(location); bool cast = true; if (cell.Objects != null) for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Spell || ((SpellObject)target).Spell != Spell.FireWall) continue; cast = false; break; } if (!cast) continue; SpellObject ob = new SpellObject { Spell = Spell.FireWall, Value = value, ExpireTime = Envir.Time + (10 + value / 2) * 1000, TickSpeed = 2000, Caster = player, CurrentLocation = location, CurrentMap = this, }; AddObject(ob); ob.Spawned(); } break; #endregion #region Lightning case Spell.Lightning: value = (int)data[2]; location = (Point)data[3]; dir = (MirDirection)data[4]; for (int i = 0; i < 6; i++) { location = Functions.PointMove(location, dir, 1); if (!ValidPoint(location)) continue; cell = GetCell(location); if (cell.Objects == null) continue; for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Player && target.Race != ObjectType.Monster) continue; if (!target.IsAttackTarget(player)) continue; if (target.Attacked(player, value, DefenceType.MAC, false) > 0) train = true; break; } } break; #endregion #region HeavenlySword case Spell.HeavenlySword: value = (int)data[2]; location = (Point)data[3]; dir = (MirDirection)data[4]; for (int i = 0; i < 3; i++) { location = Functions.PointMove(location, dir, 1); if (!ValidPoint(location)) continue; cell = GetCell(location); if (cell.Objects == null) continue; for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Player && target.Race != ObjectType.Monster) continue; if (!target.IsAttackTarget(player)) continue; if (target.Attacked(player, value, DefenceType.MAC, false) > 0) train = true; break; } } break; #endregion #region MassHealing case Spell.MassHealing: value = (int)data[2]; location = (Point)data[3]; for (int y = location.Y - 1; y <= location.Y + 1; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 1; x <= location.X + 1; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (target.IsFriendlyTarget(player)) { if (target.Health >= target.MaxHealth) continue; target.HealAmount = (ushort)Math.Min(ushort.MaxValue, target.HealAmount + value); target.OperateTime = 0; train = true; } break; } } } } break; #endregion #region ThunderStorm case Spell.ThunderStorm: case Spell.FlameField: case Spell.NapalmShot: value = (int)data[2]; location = (Point)data[3]; for (int y = location.Y - 2; y <= location.Y + 2; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 2; x <= location.X + 2; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (!target.IsAttackTarget(player)) break; if (target.Attacked(player, magic.Spell == Spell.ThunderStorm && !target.Undead ? value / 10 : value , DefenceType.MAC, false) <= 0) break; train = true; break; } } } } break; #endregion #region SummonShinsu case Spell.SummonShinsu: monster = (MonsterObject)data[2]; front = (Point)data[3]; if (ValidPoint(front)) monster.Spawn(this, front); else monster.Spawn(player.CurrentMap, player.CurrentLocation); break; #endregion #region LionRoar case Spell.LionRoar: location = (Point)data[2]; for (int y = location.Y - 2; y <= location.Y + 2; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 2; x <= location.X + 2; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; if (target.Race != ObjectType.Monster) continue; //Only targets if (!target.IsAttackTarget(player) || player.Level + 10 < target.Level) continue; target.ApplyPoison(new Poison { PType = PoisonType.Paralysis, Duration = magic.Level + 2, TickSpeed = 1000 }, player); target.OperateTime = 0; train = true; } } } break; #endregion #region PoisonCloud case Spell.PoisonCloud: value = (int)data[2]; location = (Point)data[3]; byte bonusdmg = (byte)data[4]; train = true; bool show = true; for (int y = location.Y - 1; y <= location.Y + 1; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 1; x <= location.X + 1; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid) continue; bool cast = true; if (cell.Objects != null) for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Spell || ((SpellObject)target).Spell != Spell.PoisonCloud) continue; cast = false; break; } if (!cast) continue; SpellObject ob = new SpellObject { Spell = Spell.PoisonCloud, Value = value + bonusdmg, ExpireTime = Envir.Time + 6000, TickSpeed = 1000, Caster = player, CurrentLocation = new Point(x, y), CastLocation = location, Show = show, CurrentMap = this, }; show = false; AddObject(ob); ob.Spawned(); } } break; #endregion #region IceThrust case Spell.IceThrust: { location = (Point)data[2]; MirDirection direction = (MirDirection)data[3]; int criticalDamage = (int)data[4]; int nearDamage = (int)data[5]; int farDamage = (int)data[6]; int col = 3; int row = 3; Point[] loc = new Point[col]; //0 = left 1 = center 2 = right loc[0] = Functions.PointMove(location, Functions.PreviousDir(direction), 1); loc[1] = Functions.PointMove(location, direction, 1); loc[2] = Functions.PointMove(location, Functions.NextDir(direction), 1); for (int i = 0; i < col; i++) { Point startPoint = loc[i]; for (int j = 0; j < row; j++) { Point hitPoint = Functions.PointMove(startPoint, direction, j); if (!ValidPoint(hitPoint)) continue; cell = GetCell(hitPoint); if (cell.Objects == null) continue; for (int k = 0; k < cell.Objects.Count; k++) { MapObject target = cell.Objects[k]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: if (target.IsAttackTarget(player)) { //Only targets if (target.Attacked(player, j <= 1 ? nearDamage : farDamage, DefenceType.MAC, false) > 0) { if (player.Level + (target.Race == ObjectType.Player ? 2 : 10) >= target.Level && Envir.Random.Next(target.Race == ObjectType.Player ? 100 : 20) <= magic.Level) { target.ApplyPoison(new Poison { Owner = player, Duration = target.Race == ObjectType.Player ? 4 : 5 + Envir.Random.Next(5), PType = PoisonType.Slow, TickSpeed = 1000, }, player); target.OperateTime = 0; } if (player.Level + (target.Race == ObjectType.Player ? 2 : 10) >= target.Level && Envir.Random.Next(target.Race == ObjectType.Player ? 100 : 40) <= magic.Level) { target.ApplyPoison(new Poison { Owner = player, Duration = target.Race == ObjectType.Player ? 2 : 5 + Envir.Random.Next(player.Freezing), PType = PoisonType.Frozen, TickSpeed = 1000, }, player); target.OperateTime = 0; } train = true; } } break; } } } } } break; #endregion #region SlashingBurst case Spell.SlashingBurst: value = (int)data[2]; location = (Point)data[3]; dir = (MirDirection)data[4]; count = (int)data[5]; for (int i = 0; i < count; i++) { location = Functions.PointMove(location, dir, 1); if (!ValidPoint(location)) continue; cell = GetCell(location); if (cell.Objects == null) continue; for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Player && target.Race != ObjectType.Monster) continue; if (!target.IsAttackTarget(player)) continue; if (target.Attacked(player, value, DefenceType.AC, false) > 0) train = true; break; } } break; #endregion #region Mirroring case Spell.Mirroring: monster = (MonsterObject)data[2]; front = (Point)data[3]; bool finish = (bool)data[4]; if (finish) { monster.Die(); return; }; if (ValidPoint(front)) monster.Spawn(this, front); else monster.Spawn(player.CurrentMap, player.CurrentLocation); break; #endregion #region Blizzard case Spell.Blizzard: value = (int)data[2]; location = (Point)data[3]; train = true; show = true; for (int y = location.Y - 2; y <= location.Y + 2; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 2; x <= location.X + 2; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid) continue; bool cast = true; if (cell.Objects != null) for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Spell || ((SpellObject) target).Spell != Spell.Blizzard) continue; cast = false; break; } if (!cast) continue; SpellObject ob = new SpellObject { Spell = Spell.Blizzard, Value = value, ExpireTime = Envir.Time + 3000, TickSpeed = 440, Caster = player, CurrentLocation = new Point(x, y), CastLocation = location, Show = show, CurrentMap = this, StartTime = Envir.Time + 800, }; show = false; AddObject(ob); ob.Spawned(); } } break; #endregion #region MeteorStrike case Spell.MeteorStrike: value = (int)data[2]; location = (Point)data[3]; train = true; show = true; for (int y = location.Y - 2; y <= location.Y + 2; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 2; x <= location.X + 2; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid) continue; bool cast = true; if (cell.Objects != null) for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Spell || ((SpellObject)target).Spell != Spell.MeteorStrike) continue; cast = false; break; } if (!cast) continue; SpellObject ob = new SpellObject { Spell = Spell.MeteorStrike, Value = value, ExpireTime = Envir.Time + 3000, TickSpeed = 440, Caster = player, CurrentLocation = new Point(x, y), CastLocation = location, Show = show, CurrentMap = this, StartTime = Envir.Time + 800, }; show = false; AddObject(ob); ob.Spawned(); } } break; #endregion #region TrapHexagon case Spell.TrapHexagon: value = (int)data[2]; location = (Point)data[3]; MonsterObject centerTarget = null; for (int y = location.Y - 1; y <= location.Y + 1; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 1; x <= location.X + 1; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; if (y == location.Y && x == location.X && target.Race == ObjectType.Monster) { centerTarget = (MonsterObject)target; } switch (target.Race) { case ObjectType.Monster: if (target == null || !target.IsAttackTarget(player) || target.Node == null || target.Level > player.Level + 2) continue; MonsterObject mobTarget = (MonsterObject)target; if (centerTarget == null) centerTarget = mobTarget; mobTarget.ShockTime = Envir.Time + value; mobTarget.Target = null; break; } } } } if (centerTarget == null) return; for (byte i = 0; i < 8; i += 2) { Point startpoint = Functions.PointMove(location, (MirDirection)i, 2); for (byte j = 0; j <= 4; j += 4) { MirDirection spawndirection = i == 0 || i == 4 ? MirDirection.Right : MirDirection.Up; Point spawnpoint = Functions.PointMove(startpoint, spawndirection + j, 1); if (spawnpoint.X <= 0 || spawnpoint.X > centerTarget.CurrentMap.Width) continue; if (spawnpoint.Y <= 0 || spawnpoint.Y > centerTarget.CurrentMap.Height) continue; SpellObject ob = new SpellObject { Spell = Spell.TrapHexagon, ExpireTime = Envir.Time + value, TickSpeed = 100, Caster = player, CurrentLocation = spawnpoint, CastLocation = location, CurrentMap = centerTarget.CurrentMap, Target = centerTarget, }; centerTarget.CurrentMap.AddObject(ob); ob.Spawned(); } } train = true; break; #endregion #region SummonHolyDeva case Spell.SummonHolyDeva: monster = (MonsterObject)data[2]; front = (Point)data[3]; if (ValidPoint(front)) monster.Spawn(this, front); else monster.Spawn(player.CurrentMap, player.CurrentLocation); break; #endregion #region Curse case Spell.Curse: value = (int)data[2]; location = (Point)data[3]; value2 = (int)data[4]; type = BuffType.Curse; for (int y = location.Y - 3; y <= location.Y + 3; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 3; x <= location.X + 3; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: if (Envir.Random.Next(10) >= 4) continue; //Only targets if (target.IsAttackTarget(player)) { target.ApplyPoison(new Poison { PType = PoisonType.Slow, Duration = value, TickSpeed = 1000, Value = value2 }, player); target.AddBuff(new Buff { Type = type, Caster = player, ExpireTime = Envir.Time + value * 1000, Values = new int[]{ value2 } }); target.OperateTime = 0; train = true; } break; } } } } break; #endregion #region ExplosiveTrap case Spell.ExplosiveTrap: value = (int)data[2]; front = (Point)data[3]; int trapID = (int)data[4]; if (ValidPoint(front)) { cell = GetCell(front); bool cast = true; if (cell.Objects != null) for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Spell || (((SpellObject)target).Spell != Spell.FireWall && ((SpellObject)target).Spell != Spell.ExplosiveTrap)) continue; cast = false; break; } if (cast) { player.LevelMagic(magic); System.Drawing.Point[] Traps = new Point[3]; Traps[0] = front; Traps[1] = Functions.Left(front, player.Direction); Traps[2] = Functions.Right(front, player.Direction); for (int i = 0; i <= 2; i++) { SpellObject ob = new SpellObject { Spell = Spell.ExplosiveTrap, Value = value, ExpireTime = Envir.Time + (10 + value / 2) * 1000, TickSpeed = 500, Caster = player, CurrentLocation = Traps[i], CurrentMap = this, ExplosiveTrapID = trapID, ExplosiveTrapCount = i }; AddObject(ob); ob.Spawned(); player.ArcherTrapObjectsArray[trapID, i] = ob; } } } break; #endregion #region Plague case Spell.Plague: value = (int)data[2]; location = (Point)data[3]; for (int y = location.Y - 3; y <= location.Y + 3; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 3; x <= location.X + 3; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (target.IsAttackTarget(player)) { int chance = Envir.Random.Next(6); PoisonType poison; switch (chance) { case 0: poison = PoisonType.Slow; break; case 1: poison = PoisonType.Frozen; break; case 2: poison = (PoisonType)data[4]; break; default: poison = PoisonType.None; break; } int tempValue = 0; if (poison == PoisonType.Green) { tempValue = value / 15 + magic.Level + 1; } else { tempValue = value + (magic.Level + 1) * 2; } if (poison != PoisonType.None) { target.ApplyPoison(new Poison { PType = poison, Duration = (2 * (magic.Level + 1)) + (value / 10), TickSpeed = 1000, Value = tempValue, Owner = player }, player); } if (target.Race == ObjectType.Player) { PlayerObject tempOb = (PlayerObject)target; tempOb.ChangeMP(-tempValue); } train = true; } break; } } } } break; #endregion #region Trap case Spell.Trap: value = (int)data[2]; location = (Point)data[3]; MonsterObject selectTarget = null; if (!ValidPoint(location)) break; cell = GetCell(location); if (!cell.Valid || cell.Objects == null) break; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; if (target.Race == ObjectType.Monster) { selectTarget = (MonsterObject)target; if (selectTarget == null || !selectTarget.IsAttackTarget(player) || selectTarget.Node == null || selectTarget.Level >= player.Level + 2) continue; selectTarget.ShockTime = Envir.Time + value; selectTarget.Target = null; break; } } if (selectTarget == null) return; if (location.X <= 0 || location.X > selectTarget.CurrentMap.Width) break; if (location.Y <= 0 || location.Y > selectTarget.CurrentMap.Height) break; SpellObject spellOb = new SpellObject { Spell = Spell.Trap, ExpireTime = Envir.Time + value, TickSpeed = 100, Caster = player, CurrentLocation = location, CastLocation = location, CurrentMap = selectTarget.CurrentMap, Target = selectTarget, }; selectTarget.CurrentMap.AddObject(spellOb); spellOb.Spawned(); train = true; break; #endregion #region OneWithNature case Spell.OneWithNature: value = (int)data[2]; location = (Point)data[3]; bool hasVampBuff = (player.Buffs.Where(ex => ex.Type == BuffType.VampireShot).ToList().Count() > 0); bool hasPoisonBuff = (player.Buffs.Where(ex => ex.Type == BuffType.PoisonShot).ToList().Count() > 0); for (int y = location.Y - 2; y <= location.Y + 2; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 2; x <= location.X + 2; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (!target.IsAttackTarget(player) || target.Dead) break; //knockback //int distance = 1 + Math.Max(0, magic.Level - 1) + Envir.Random.Next(2); //dir = Functions.DirectionFromPoint(location, target.CurrentLocation); //if(target.Level < player.Level) // target.Pushed(player, dir, distance);// <--crashes server somehow? if (target.Attacked(player, value, DefenceType.MAC, false) <= 0) break; if (hasVampBuff)//Vampire Effect { if (player.VampAmount == 0) player.VampTime = Envir.Time + 1000; player.VampAmount += (ushort)(value * (magic.Level + 1) * 0.25F); } if (hasPoisonBuff)//Poison Effect { target.ApplyPoison(new Poison { Duration = (value * 2) + (magic.Level + 1) * 7, Owner = player, PType = PoisonType.Green, TickSpeed = 2000, Value = value / 15 + magic.Level + 1 + Envir.Random.Next(player.PoisonAttack) }, player); target.OperateTime = 0; } train = true; break; } } } } if (hasVampBuff)//Vampire Effect { //cancel out buff player.AddBuff(new Buff { Type = BuffType.VampireShot, Caster = player, ExpireTime = Envir.Time + 1000, Values = new int[]{ value }, Visible = true, ObjectID = player.ObjectID }); } if (hasPoisonBuff)//Poison Effect { //cancel out buff player.AddBuff(new Buff { Type = BuffType.PoisonShot, Caster = player, ExpireTime = Envir.Time + 1000, Values = new int[]{ value }, Visible = true, ObjectID = player.ObjectID }); } break; #endregion #region ArcherSummons case Spell.SummonVampire: case Spell.SummonToad: case Spell.SummonSnakes: monster = (MonsterObject)data[2]; front = (Point)data[3]; if (ValidPoint(front)) monster.Spawn(this, front); else monster.Spawn(player.CurrentMap, player.CurrentLocation); break; #endregion #region Portal case Spell.Portal: value = (int)data[2]; location = (Point)data[3]; spellOb = new SpellObject { Spell = Spell.Portal, Value = 0, ExpireTime = Envir.Time + value * 1000, TickSpeed = 2000, Caster = player, CurrentLocation = location, CurrentMap = this, }; if (player.PortalObjectsArray[0] == null) { player.PortalObjectsArray[0] = spellOb; } else { player.PortalObjectsArray[1] = spellOb; player.PortalObjectsArray[1].ExitMap = player.PortalObjectsArray[0].CurrentMap; player.PortalObjectsArray[1].ExitCoord = player.PortalObjectsArray[0].CurrentLocation; player.PortalObjectsArray[0].ExitMap = player.PortalObjectsArray[1].CurrentMap; player.PortalObjectsArray[0].ExitCoord = player.PortalObjectsArray[1].CurrentLocation; } AddObject(spellOb); spellOb.Spawned(); train = true; break; #endregion #region DelayedExplosion case Spell.DelayedExplosion: value = (int)data[2]; location = (Point)data[3]; for (int y = location.Y - 1; y <= location.Y + 1; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 1; x <= location.X + 1; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (target.IsAttackTarget(player)) { if (target.Attacked(player, value, DefenceType.MAC, false) > 0) train = false;//wouldnt want to make the skill give twice the points } break; } } } } break; #endregion } if (train) player.LevelMagic(magic); }
public void Process() { ProcessRespawns(); if ((Info.Lightning) && Envir.Time > LightningTime) { LightningTime = Envir.Time + Envir.Random.Next(3000, 15000); for (int i = Players.Count - 1; i >= 0; i--) { PlayerObject player = Players[i]; Point Location; if (Envir.Random.Next(4) == 0) { Location = player.CurrentLocation; } else Location = new Point(player.CurrentLocation.X - 10 + Envir.Random.Next(20), player.CurrentLocation.Y - 10 + Envir.Random.Next(20)); if (!ValidPoint(Location)) continue; SpellObject Lightning = null; Lightning = new SpellObject { Spell = Spell.MapLightning, Value = Envir.Random.Next(Info.LightningDamage), ExpireTime = Envir.Time + (1000), TickSpeed = 500, Caster = null, CurrentLocation = Location, CurrentMap = this, Direction = MirDirection.Up }; AddObject(Lightning); Lightning.Spawned(); } } if ((Info.Fire) && Envir.Time > FireTime) { FireTime = Envir.Time + Envir.Random.Next(3000, 15000); for (int i = Players.Count - 1; i >= 0; i--) { PlayerObject player = Players[i]; Point Location; if (Envir.Random.Next(4) == 0) { Location = player.CurrentLocation; } else Location = new Point(player.CurrentLocation.X - 10 + Envir.Random.Next(20), player.CurrentLocation.Y - 10 + Envir.Random.Next(20)); if (!ValidPoint(Location)) continue; SpellObject Lightning = null; Lightning = new SpellObject { Spell = Spell.MapLava, Value = Envir.Random.Next(Info.FireDamage), ExpireTime = Envir.Time + (1000), TickSpeed = 500, Caster = null, CurrentLocation = Location, CurrentMap = this, Direction = MirDirection.Up }; AddObject(Lightning); Lightning.Spawned(); } } for (int i = 0; i < ActionList.Count; i++) { if (Envir.Time < ActionList[i].Time) continue; Process(ActionList[i]); ActionList.RemoveAt(i); } if (InactiveTime < Envir.Time) { if (!Players.Any()) { InactiveTime = Envir.Time + Settings.Minute; InactiveCount++; } else { InactiveCount = 0; } } }
private void CreateSafeZone(SafeZoneInfo info) { if (Settings.SafeZoneBorder) { for (int y = info.Location.Y - info.Size; y <= info.Location.Y + info.Size; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = info.Location.X - info.Size; x <= info.Location.X + info.Size; x += Math.Abs(y - info.Location.Y) == info.Size ? 1 : info.Size * 2) { if (x < 0) continue; if (x >= Width) break; if (!Cells[x, y].Valid) continue; SpellObject spell = new SpellObject { ExpireTime = long.MaxValue, Spell = Spell.TrapHexagon, TickSpeed = int.MaxValue, CurrentLocation = new Point(x, y), CurrentMap = this }; Cells[x, y].Add(spell); spell.Spawned(); } } } if (Settings.SafeZoneHealing) { for (int y = info.Location.Y - info.Size; y <= info.Location.Y + info.Size; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = info.Location.X - info.Size; x <= info.Location.X + info.Size; x++) { if (x < 0) continue; if (x >= Width) break; if (!Cells[x, y].Valid) continue; SpellObject spell = new SpellObject { ExpireTime = long.MaxValue, Value = 25, TickSpeed = 2000, Spell = Spell.Healing, CurrentLocation = new Point(x, y), CurrentMap = this }; Cells[x, y].Add(spell); spell.Spawned(); } } } }
private void Reincarnation(UserMagic magic, PlayerObject target, out bool cast) { cast = true; if (target == null || !target.Dead) return; // checks for amulet of revival UserItem item = GetAmulet(1, 3); if (item == null) return; if (!ActiveReincarnation && !ReincarnationReady) { cast = false; int CastTime = Math.Abs(((magic.Level + 1) * 1000) - 9000); ExpireTime = Envir.Time + CastTime; ReincarnationReady = true; ActiveReincarnation = true; ReincarnationTarget = target; ReincarnationExpireTime = ExpireTime + 5000; target.ReincarnationHost = this; SpellObject ob = new SpellObject { Spell = Spell.Reincarnation, ExpireTime = ExpireTime, TickSpeed = 1000, Caster = this, CurrentLocation = CurrentLocation, CastLocation = CurrentLocation, Show = true, CurrentMap = CurrentMap, }; Packet p = new S.Chat { Message = string.Format("{0} is attempting to revive {1}", Name, target.Name), Type = ChatType.Shout }; Envir.Broadcast(p); CurrentMap.AddObject(ob); ob.Spawned(); ConsumeItem(item, 1); // chance of failing Reincarnation when casting if (Envir.Random.Next(30) > (1 + magic.Level) * 10) { return; } DelayedAction action = new DelayedAction(DelayedType.Magic, ExpireTime, magic); ActionList.Add(action); return; } return; }
public void Attack(MirDirection dir, Spell spell) { LogTime = Envir.Time + Globals.LogDelay; bool Mined = false; bool MoonLightAttack = false; bool DarkBodyAttack = false; if (!CanAttack) { switch (spell) { case Spell.Slaying: Slaying = false; break; } Enqueue(new S.UserLocation { Direction = Direction, Location = CurrentLocation }); return; } if (Hidden) { for (int i = 0; i < Buffs.Count; i++) { switch (Buffs[i].Type) { case BuffType.Hiding: case BuffType.MoonLight: case BuffType.DarkBody: MoonLightAttack = true; DarkBodyAttack = true; Buffs[i].ExpireTime = 0; break; } } } byte level = 0; UserMagic magic; if (RidingMount) { spell = Spell.None; } switch (spell) { case Spell.Slaying: if (!Slaying) spell = Spell.None; else { magic = GetMagic(Spell.Slaying); level = magic.Level; } Slaying = false; break; case Spell.DoubleSlash: magic = GetMagic(spell); if (magic == null || magic.Info.BaseCost + (magic.Level * magic.Info.LevelCost) > MP) { spell = Spell.None; break; } level = magic.Level; ChangeMP(-(magic.Info.BaseCost + magic.Level * magic.Info.LevelCost)); break; case Spell.Thrusting: case Spell.FlamingSword: magic = GetMagic(spell); if ((magic == null) || (!FlamingSword && (spell == Spell.FlamingSword))) { spell = Spell.None; break; } level = magic.Level; break; case Spell.HalfMoon: case Spell.CrossHalfMoon: magic = GetMagic(spell); if (magic == null || magic.Info.BaseCost + (magic.Level * magic.Info.LevelCost) > MP) { spell = Spell.None; break; } level = magic.Level; ChangeMP(-(magic.Info.BaseCost + magic.Level * magic.Info.LevelCost)); break; case Spell.TwinDrakeBlade: magic = GetMagic(spell); if (!TwinDrakeBlade || magic == null || magic.Info.BaseCost + magic.Level * magic.Info.LevelCost > MP) { spell = Spell.None; break; } level = magic.Level; ChangeMP(-(magic.Info.BaseCost + magic.Level * magic.Info.LevelCost)); break; default: spell = Spell.None; break; } if (!Slaying) { magic = GetMagic(Spell.Slaying); if (magic != null && Envir.Random.Next(12) <= magic.Level) { Slaying = true; Enqueue(new S.SpellToggle { Spell = Spell.Slaying, CanUse = Slaying }); } } Direction = dir; if (RidingMount) DecreaseMountLoyalty(3); Enqueue(new S.UserLocation { Direction = Direction, Location = CurrentLocation }); Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Spell = spell, Level = level }); AttackTime = Envir.Time + AttackSpeed; ActionTime = Envir.Time + 550; RegenTime = Envir.Time + RegenDelay; Point target = Functions.PointMove(CurrentLocation, dir, 1); int damage = GetAttackPower(MinDC, MaxDC); if (MoonLightAttack || DarkBodyAttack) { magic = MoonLightAttack ? GetMagic(Spell.MoonLight) : GetMagic(Spell.DarkBody); if (magic != null) { damage += (magic.Level + 1) * 5; } } if (!CurrentMap.ValidPoint(target)) { switch (spell) { case Spell.Thrusting: goto Thrusting; case Spell.HalfMoon: goto HalfMoon; case Spell.CrossHalfMoon: goto CrossHalfMoon; case Spell.None: Mined = true; goto Mining; } return; } Cell cell = CurrentMap.GetCell(target); if (cell.Objects == null) { switch (spell) { case Spell.Thrusting: goto Thrusting; case Spell.HalfMoon: goto HalfMoon; case Spell.CrossHalfMoon: goto CrossHalfMoon; } return; } for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) continue; if (!ob.IsAttackTarget(this)) continue; //Only undead targets if (ob.Undead) damage = Math.Min(int.MaxValue, damage + Holy); #region FatalSword magic = GetMagic(Spell.FatalSword); DefenceType defence = DefenceType.ACAgility; if (magic != null) { if (FatalSword) { damage += (magic.Level + 1) * 5; LevelMagic(magic); S.ObjectEffect p = new S.ObjectEffect { ObjectID = ob.ObjectID, Effect = SpellEffect.FatalSword }; defence = DefenceType.Agility; CurrentMap.Broadcast(p, ob.CurrentLocation); FatalSword = false; } if (!FatalSword && Envir.Random.Next(10) == 0) FatalSword = true; } #endregion #region MPEater magic = GetMagic(Spell.MPEater); if (magic != null) { int baseCount = 1 + Accuracy / 2; int maxCount = baseCount + magic.Level * 5; MPEaterCount += Envir.Random.Next(baseCount, maxCount); if (MPEater) { LevelMagic(magic); defence = DefenceType.ACAgility; S.ObjectEffect p = new S.ObjectEffect { ObjectID = ob.ObjectID, Effect = SpellEffect.MPEater, EffectType = ObjectID }; CurrentMap.Broadcast(p, ob.CurrentLocation); int addMp = 5 * (magic.Level + Accuracy / 4); if (ob.Race == ObjectType.Player) { ((PlayerObject)ob).ChangeMP(-addMp); } ChangeMP(addMp); MPEaterCount = 0; MPEater = false; } else if (!MPEater && 100 <= MPEaterCount) MPEater = true; } #endregion #region Hemorrhage magic = GetMagic(Spell.Hemorrhage); if (magic != null) { HemorrhageAttackCount += Envir.Random.Next(1, 1 + magic.Level * 2); if (Hemorrhage) { damage += damage * 10 / 2; //20% LevelMagic(magic); S.ObjectEffect ef = new S.ObjectEffect { ObjectID = ob.ObjectID, Effect = SpellEffect.Hemorrhage }; CurrentMap.Broadcast(ef, ob.CurrentLocation); if (ob == null || ob.Node == null) continue; long calcDuration = magic.Level * 2 + Luck / 6; ob.ApplyPoison(new Poison { Duration = (calcDuration <= 0) ? 1 : calcDuration, Owner = this, PType = PoisonType.Bleeding, TickSpeed = 1000, Value = MaxDC + 1 }, this); ob.OperateTime = 0; HemorrhageAttackCount = 0; Hemorrhage = false; } else if (!Hemorrhage && 55 <= HemorrhageAttackCount) Hemorrhage = true; } #endregion DelayedAction action; switch (spell) { case Spell.Slaying: magic = GetMagic(Spell.Slaying); damage += 5 + magic.Level; LevelMagic(magic); break; case Spell.DoubleSlash: magic = GetMagic(Spell.DoubleSlash); damage = damage * (magic.Level + 8) / 10; // 110% Damage level 3 if (defence == DefenceType.ACAgility) defence = DefenceType.MACAgility; action = new DelayedAction(DelayedType.Damage, Envir.Time + 400, ob, damage, DefenceType.Agility, false); ActionList.Add(action); LevelMagic(magic); break; case Spell.Thrusting: magic = GetMagic(Spell.Thrusting); LevelMagic(magic); break; case Spell.HalfMoon: magic = GetMagic(Spell.HalfMoon); LevelMagic(magic); break; case Spell.CrossHalfMoon: magic = GetMagic(Spell.CrossHalfMoon); LevelMagic(magic); break; case Spell.TwinDrakeBlade: magic = GetMagic(Spell.TwinDrakeBlade); damage = damage * (magic.Level + 8) / 10; // 110% Damage level 3 TwinDrakeBlade = false; action = new DelayedAction(DelayedType.Damage, Envir.Time + 400, ob, damage, DefenceType.Agility, false); ActionList.Add(action); LevelMagic(magic); if ((((ob.Race != ObjectType.Player) || Settings.PvpCanResistPoison) && (Envir.Random.Next(Settings.PoisonAttackWeight) >= ob.PoisonResist)) && (ob.Level < Level + 10 && Envir.Random.Next(ob.Race == ObjectType.Player ? 40 : 20) <= magic.Level + 1)) { ob.ApplyPoison(new Poison { PType = PoisonType.Stun, Duration = ob.Race == ObjectType.Player ? 2 : 2 + magic.Level, TickSpeed = 1000 }, this); ob.Broadcast(new S.ObjectEffect { ObjectID = ob.ObjectID, Effect = SpellEffect.TwinDrakeBlade }); } break; case Spell.FlamingSword: magic = GetMagic(Spell.FlamingSword); damage = (damage) + (int)(((double)damage / 100) * ((4 + magic.Level * 4) * 10)); FlamingSword = false; defence = DefenceType.AC; //action = new DelayedAction(DelayedType.Damage, Envir.Time + 400, ob, damage, DefenceType.Agility, true); //ActionList.Add(action); LevelMagic(magic); break; } //if (ob.Attacked(this, damage, defence) <= 0) break; action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, ob, damage, defence, true); ActionList.Add(action); break; } Thrusting: if (spell == Spell.Thrusting) { target = Functions.PointMove(target, dir, 1); if (!CurrentMap.ValidPoint(target)) return; cell = CurrentMap.GetCell(target); if (cell.Objects == null) return; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) continue; if (!ob.IsAttackTarget(this)) continue; magic = GetMagic(spell); damage = damage * (magic.Level + 1) / 4; ob.Attacked(this, damage, DefenceType.Agility, false); break; } } HalfMoon: if (spell == Spell.HalfMoon) { dir = Functions.PreviousDir(dir); magic = GetMagic(spell); damage = damage * (magic.Level + 3) / 10; for (int i = 0; i < 4; i++) { target = Functions.PointMove(CurrentLocation, dir, 1); dir = Functions.NextDir(dir); if (target == Front) continue; if (!CurrentMap.ValidPoint(target)) continue; cell = CurrentMap.GetCell(target); if (cell.Objects == null) continue; for (int o = 0; o < cell.Objects.Count; o++) { MapObject ob = cell.Objects[o]; if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) continue; if (!ob.IsAttackTarget(this)) continue; ob.Attacked(this, damage, DefenceType.Agility, false); break; } } } CrossHalfMoon: if (spell == Spell.CrossHalfMoon) { magic = GetMagic(spell); damage = damage * (magic.Level + 4) / 10; for (int i = 0; i < 8; i++) { target = Functions.PointMove(CurrentLocation, dir, 1); dir = Functions.NextDir(dir); if (target == Front) continue; if (!CurrentMap.ValidPoint(target)) continue; cell = CurrentMap.GetCell(target); if (cell.Objects == null) continue; for (int o = 0; o < cell.Objects.Count; o++) { MapObject ob = cell.Objects[o]; if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) continue; if (!ob.IsAttackTarget(this)) continue; ob.Attacked(this, damage, DefenceType.Agility, false); break; } } } Mining: if (Mined) { if (Info.Equipment[(int)EquipmentSlot.Weapon] == null) return; if (!Info.Equipment[(int)EquipmentSlot.Weapon].Info.CanMine) return; if (CurrentMap.Mine == null) return; MineSpot Mine = CurrentMap.Mine[target.X, target.Y]; if ((Mine == null) || (Mine.Mine == null)) return; if (Mine.StonesLeft > 0) { Mine.StonesLeft--; if (Envir.Random.Next(100) <= (Mine.Mine.HitRate + (Info.Equipment[(int)EquipmentSlot.Weapon].Info.Accuracy + Info.Equipment[(int)EquipmentSlot.Weapon].Accuracy) * 10)) { //create some rubble on the floor (or increase whats there) SpellObject Rubble = null; Cell minecell = CurrentMap.GetCell(CurrentLocation); for (int i = 0; i < minecell.Objects.Count; i++) { if (minecell.Objects[i].Race != ObjectType.Spell) continue; SpellObject ob = (SpellObject)minecell.Objects[i]; if (ob.Spell != Spell.Rubble) continue; Rubble = ob; Rubble.ExpireTime = Envir.Time + (5 * 60 * 1000); break; } if (Rubble == null) { Rubble = new SpellObject { Spell = Spell.Rubble, Value = 1, ExpireTime = Envir.Time + (5 * 60 * 1000), TickSpeed = 2000, Caster = null, CurrentLocation = CurrentLocation, CurrentMap = this.CurrentMap, Direction = MirDirection.Up }; CurrentMap.AddObject(Rubble); Rubble.Spawned(); } if (Rubble != null) ActionList.Add(new DelayedAction(DelayedType.Mine, Envir.Time + 400, Rubble)); //check if we get a payout if (Envir.Random.Next(100) <= (Mine.Mine.DropRate + (MineRate * 5))) { GetMinePayout(Mine.Mine); } DamageItem(Info.Equipment[(int)EquipmentSlot.Weapon], 5 + Envir.Random.Next(15)); } } else { if (Envir.Time > Mine.LastRegenTick) { Mine.LastRegenTick = Envir.Time + Mine.Mine.SpotRegenRate * 60 * 1000; Mine.StonesLeft = (byte)Envir.Random.Next(Mine.Mine.MaxStones); } } } }
private void CreateZone(bool Create = true) { if (Create) { WarEffects.Clear(); for (int y = Info.ObjectLoc.Y - Info.ObjectSize; y <= Info.ObjectLoc.Y + Info.ObjectSize; y++) { if (y < 0) continue; if (y >= ConquestMap.Height) break; for (int x = Info.ObjectLoc.X - Info.ObjectSize; x <= Info.ObjectLoc.X + Info.ObjectSize; x += Math.Abs(y - Info.ObjectLoc.Y) == Info.ObjectSize ? 1 : Info.ObjectSize * 2) { if (x < 0) continue; if (x >= ConquestMap.Width) break; if (!ConquestMap.Cells[x, y].Valid) continue; SpellObject spell = new SpellObject { ExpireTime = long.MaxValue, Spell = Spell.TrapHexagon, TickSpeed = int.MaxValue, CurrentLocation = new Point(x, y), CurrentMap = ConquestMap, Decoration = true }; ConquestMap.Cells[x, y].Add(spell); WarEffects.Add(spell); spell.Spawned(); } } } else { for (int i = 0; i < WarEffects.Count; i++) { //if (WarEffects[i].CurrentLocation != null) //{ WarEffects[i].Despawn(); ConquestMap.RemoveObject(WarEffects[i]); //} } WarEffects.Clear(); } }
public void Attack(MirDirection dir, Spell spell) { bool Mined = false; if (!CanAttack) { switch (spell) { case Spell.Slaying: Slaying = false; break; } Enqueue(new S.UserLocation {Direction = Direction, Location = CurrentLocation}); return; } byte level = 0; UserMagic magic; switch (spell) { case Spell.Slaying: if (!Slaying) spell = Spell.None; else { magic = GetMagic(Spell.Slaying); level = magic.Level; } Slaying = false; break; case Spell.DoubleSlash: magic = GetMagic(spell); if (magic == null || magic.Info.BaseCost + (magic.Level*magic.Info.LevelCost) > MP) { spell = Spell.None; break; } level = magic.Level; ChangeMP(-(magic.Info.BaseCost + magic.Level*magic.Info.LevelCost)); break; case Spell.Thrusting: case Spell.FlamingSword: magic = GetMagic(spell); if (magic == null) { spell = Spell.None; break; } level = magic.Level; break; case Spell.HalfMoon: case Spell.CrossHalfMoon: magic = GetMagic(spell); if (magic == null || magic.Info.BaseCost + (magic.Level*magic.Info.LevelCost) > MP) { spell = Spell.None; break; } level = magic.Level; ChangeMP(-(magic.Info.BaseCost + magic.Level*magic.Info.LevelCost)); break; case Spell.TwinDrakeBlade: magic = GetMagic(spell); if (!TwinDrakeBlade || magic == null || magic.Info.BaseCost + magic.Level*magic.Info.LevelCost > MP) { spell = Spell.None; break; } level = magic.Level; ChangeMP(-(magic.Info.BaseCost + magic.Level*magic.Info.LevelCost)); break; default: spell = Spell.None; break; } if (!Slaying) { magic = GetMagic(Spell.Slaying); if (magic != null && Envir.Random.Next(12) <= magic.Level) { Slaying = true; Enqueue(new S.SpellToggle {Spell = Spell.Slaying, CanUse = Slaying}); } } Direction = dir; Enqueue(new S.UserLocation {Direction = Direction, Location = CurrentLocation}); Broadcast(new S.ObjectAttack {ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Spell = spell, Level = level}); AttackTime = Envir.Time + AttackSpeed; ActionTime = Envir.Time + 550; RegenTime = Envir.Time + RegenDelay; Point target = Functions.PointMove(CurrentLocation, dir, 1); int damage = GetAttackPower(MinDC, MaxDC); if (!CurrentMap.ValidPoint(target)) { switch (spell) { case Spell.Thrusting: goto Thrusting; case Spell.HalfMoon: goto HalfMoon; case Spell.CrossHalfMoon: goto CrossHalfMoon; case Spell.None: Mined = true; goto Mining; } return; } Cell cell = CurrentMap.GetCell(target); if (cell.Objects == null) { switch (spell) { case Spell.Thrusting: goto Thrusting; case Spell.HalfMoon: goto HalfMoon; case Spell.CrossHalfMoon: goto CrossHalfMoon; } return; } for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) continue; if (!ob.IsAttackTarget(this)) continue; //Only targets if (ob.Undead) damage = Math.Min(int.MaxValue, damage + Holy); magic = GetMagic(Spell.FatalSword); DefenceType defence = DefenceType.ACAgility; if (magic != null) { if (FatalSword) { damage += (magic.Level + 1)*5; LevelMagic(magic); S.ObjectEffect p = new S.ObjectEffect {ObjectID = ob.ObjectID, Effect = SpellEffect.FatalSword}; defence = DefenceType.Agility; CurrentMap.Broadcast(p, ob.CurrentLocation); FatalSword = false; } if (!FatalSword && Envir.Random.Next(10) == 0) FatalSword = true; } DelayedAction action; switch (spell) { case Spell.Slaying: magic = GetMagic(Spell.Slaying); damage += (magic.Level + 1)*8; LevelMagic(magic); break; case Spell.DoubleSlash: magic = GetMagic(Spell.DoubleSlash); damage = damage*(magic.Level + 8)/10; // 110% Damage level 3 if (defence == DefenceType.ACAgility) defence = DefenceType.MACAgility; action = new DelayedAction(DelayedType.Damage, Envir.Time + 400, ob, damage, DefenceType.Agility, true); ActionList.Add(action); LevelMagic(magic); break; case Spell.Thrusting: magic = GetMagic(Spell.Thrusting); LevelMagic(magic); break; case Spell.HalfMoon: magic = GetMagic(Spell.HalfMoon); LevelMagic(magic); break; case Spell.CrossHalfMoon: magic = GetMagic(Spell.CrossHalfMoon); LevelMagic(magic); break; case Spell.TwinDrakeBlade: magic = GetMagic(Spell.TwinDrakeBlade); damage = damage*(magic.Level + 8)/10; // 110% Damage level 3 TwinDrakeBlade = false; action = new DelayedAction(DelayedType.Damage, Envir.Time + 400, ob, damage, DefenceType.Agility, true); ActionList.Add(action); LevelMagic(magic); if ((((ob.Race != ObjectType.Player) || Settings.PvpCanResistPoison) && (Envir.Random.Next(Settings.PoisonAttackWeight) >= ob.PoisonResist)) && (ob.Level < Level + 10 && Envir.Random.Next(ob.Race == ObjectType.Player ? 40 : 20) <= magic.Level + 1)) { ob.ApplyPoison(new Poison {PType = PoisonType.Stun, Duration = ob.Race == ObjectType.Player ? 2 : 2 + magic.Level, TickSpeed = 1000}, this); ob.Broadcast(new S.ObjectEffect {ObjectID = ob.ObjectID, Effect = SpellEffect.TwinDrakeBlade}); } break; case Spell.FlamingSword: magic = GetMagic(Spell.FlamingSword); damage = damage + (damage / 100 * ((4 + magic.Level * 4) * 10)); FlamingSword = false; action = new DelayedAction(DelayedType.Damage, Envir.Time + 400, ob, damage, DefenceType.Agility, true); ActionList.Add(action); LevelMagic(magic); break; } if (ob.Attacked(this, damage, defence) <= 0) break; //Level Fencing / SpiritSword for (int m = 0; m < Info.Magics.Count; m++) { magic = Info.Magics[m]; switch (magic.Spell) { case Spell.Fencing: case Spell.SpiritSword: LevelMagic(magic); break; } } break; } Thrusting: if (spell == Spell.Thrusting) { target = Functions.PointMove(target, dir, 1); if (!CurrentMap.ValidPoint(target)) return; cell = CurrentMap.GetCell(target); if (cell.Objects == null) return; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) continue; if (!ob.IsAttackTarget(this)) continue; magic = GetMagic(spell); damage = damage*(magic.Level + 1)/4; ob.Attacked(this, damage, DefenceType.Agility); break; } } HalfMoon: if (spell == Spell.HalfMoon) { dir = Functions.PreviousDir(dir); magic = GetMagic(spell); damage = damage*(magic.Level + 3)/10; for (int i = 0; i < 4; i++) { target = Functions.PointMove(CurrentLocation, dir, 1); dir = Functions.NextDir(dir); if (target == Front) continue; if (!CurrentMap.ValidPoint(target)) continue; cell = CurrentMap.GetCell(target); if (cell.Objects == null) continue; for (int o = 0; o < cell.Objects.Count; o++) { MapObject ob = cell.Objects[o]; if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) continue; if (!ob.IsAttackTarget(this)) continue; ob.Attacked(this, damage, DefenceType.Agility); break; } } } CrossHalfMoon: if (spell == Spell.CrossHalfMoon) { magic = GetMagic(spell); damage = damage*(magic.Level + 4)/10; for (int i = 0; i < 8; i++) { target = Functions.PointMove(CurrentLocation, dir, 1); dir = Functions.NextDir(dir); if (target == Front) continue; if (!CurrentMap.ValidPoint(target)) continue; cell = CurrentMap.GetCell(target); if (cell.Objects == null) continue; for (int o = 0; o < cell.Objects.Count; o++) { MapObject ob = cell.Objects[o]; if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) continue; if (!ob.IsAttackTarget(this)) continue; ob.Attacked(this, damage, DefenceType.Agility); break; } } } Mining: if (Mined) { if(Info.Equipment[(int)EquipmentSlot.Weapon] == null) return; if(!Info.Equipment[(int)EquipmentSlot.Weapon].Info.CanMine) return; if (CurrentMap.Mine == null) return; MineSpot Mine = CurrentMap.Mine[target.X, target.Y]; if ((Mine == null) || (Mine.Mine == null)) return; if (Mine.StonesLeft > 0) { Mine.StonesLeft--; if (Envir.Random.Next(100) <= (Mine.Mine.HitRate + (Info.Equipment[(int)EquipmentSlot.Weapon].Info.Accuracy + Info.Equipment[(int)EquipmentSlot.Weapon].Accuracy)*10)) { //create some rubble on the floor (or increase whats there) SpellObject Rubble = null; Cell minecell = CurrentMap.GetCell(CurrentLocation); for (int i = 0; i < minecell.Objects.Count; i++) { if (minecell.Objects[i].Race != ObjectType.Spell) continue; SpellObject ob = (SpellObject)minecell.Objects[i]; if (ob.Spell != Spell.Rubble) continue; Rubble = ob; Rubble.ExpireTime = Envir.Time + (5 * 60 * 1000); break; } if (Rubble == null) { Rubble = new SpellObject { Spell = Spell.Rubble, Value = 1, ExpireTime = Envir.Time + (5 * 60 * 1000), TickSpeed = 2000, Caster = null, CurrentLocation = CurrentLocation, CurrentMap = this.CurrentMap, Direction = MirDirection.Up }; CurrentMap.AddObject(Rubble); Rubble.Spawned(); } if (Rubble != null) ActionList.Add(new DelayedAction(DelayedType.Mine, Envir.Time + 400,Rubble)); //check if we get a payout if (Envir.Random.Next(100) <= Mine.Mine.DropRate) { GetMinePayout(Mine.Mine); } DamageItem(Info.Equipment[(int)EquipmentSlot.Weapon], 5 + Envir.Random.Next(15)); } } else { if (Envir.Time > Mine.LastRegenTick) { Mine.LastRegenTick = Envir.Time + Mine.Mine.SpotRegenRate * 60 * 1000; Mine.StonesLeft = (byte)Envir.Random.Next(Mine.Mine.MaxStones); } } } }
private void CompleteMagic(IList<object> data) { bool train = false; PlayerObject player = (PlayerObject)data[0]; UserMagic magic = (UserMagic)data[1]; int value; Point location; Cell cell; MirDirection dir; MonsterObject monster; Point front; switch (magic.Spell) { #region HellFire case Spell.HellFire: value = (int) data[2]; dir = (MirDirection) data[4]; location = Functions.PointMove((Point) data[3], dir, 1); int count = (int) data[5] - 1; if (!ValidPoint(location)) return; if (count > 0) { DelayedAction action = new DelayedAction(DelayedType.Magic, Envir.Time + 100, player, magic, value, location, dir, count); ActionList.Add(action); } cell = GetCell(location); if (cell.Objects == null) return; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (target.IsAttackTarget(player)) { if (target.Attacked(player, value, DefenceType.MAC, false) > 0) player.LevelMagic(magic); return; } break; } } break; #endregion #region SummonSkeleton case Spell.SummonSkeleton: monster = (MonsterObject)data[2]; front = (Point)data[3]; if (ValidPoint(front)) monster.Spawn(this, front); else monster.Spawn(player.CurrentMap, player.CurrentLocation); break; #endregion #region FireBang, IceStorm case Spell.IceStorm: case Spell.FireBang: value = (int) data[2]; location = (Point) data[3]; for (int y = location.Y - 1; y <= location.Y + 1; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 1; x <= location.X + 1; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (target.IsAttackTarget(player)) { if (target.Attacked(player, value, DefenceType.MAC, false) > 0) train = true; } break; } } } } break; #endregion #region MassHiding case Spell.MassHiding: value = (int) data[2]; location = (Point) data[3]; for (int y = location.Y - 1; y <= location.Y + 1; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 1; x <= location.X + 1; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (target.IsFriendlyTarget(player)) { for (int b = 0; b < target.Buffs.Count; b++) if (target.Buffs[b].Type == BuffType.Hiding) return; target.AddBuff(new Buff { Type = BuffType.Hiding, Caster = player, ExpireTime = Envir.Time + value * 1000 }); target.OperateTime = 0; train = true; } break; } } } } break; #endregion #region SoulShield, BlessedArmour case Spell.SoulShield: case Spell.BlessedArmour: value = (int) data[2]; location = (Point) data[3]; BuffType type = magic.Spell == Spell.SoulShield ? BuffType.SoulShield : BuffType.BlessedArmour; for (int y = location.Y - 3; y <= location.Y + 3; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 3; x <= location.X + 3; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (target.IsFriendlyTarget(player)) { target.AddBuff(new Buff { Type = type, Caster = player, ExpireTime = Envir.Time + value * 1000, Value = target.Level / 7 + 4 }); target.OperateTime = 0; train = true; } break; } } } } break; #endregion #region FireWall case Spell.FireWall: value = (int)data[2]; location = (Point)data[3]; player.LevelMagic(magic); if (ValidPoint(location)) { cell = GetCell(location); bool cast = true; if (cell.Objects != null) for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Spell || ((SpellObject) target).Spell != Spell.FireWall) continue; cast = false; break; } if (cast) { SpellObject ob = new SpellObject { Spell = Spell.FireWall, Value = value, ExpireTime = Envir.Time + (10 + value/2)*1000, TickSpeed = 2000, Caster = player, CurrentLocation = location, CurrentMap = this, }; AddObject(ob); ob.Spawned(); } } dir = MirDirection.Up; for (int i = 0; i < 4; i++) { location = Functions.PointMove((Point) data[3], dir, 1); dir += 2; if (!ValidPoint(location)) continue; cell = GetCell(location); bool cast = true; if (cell.Objects != null) for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Spell || ((SpellObject) target).Spell != Spell.FireWall) continue; cast = false; break; } if (!cast) continue; SpellObject ob = new SpellObject { Spell = Spell.FireWall, Value = value, ExpireTime = Envir.Time + (10 + value / 2) * 1000, TickSpeed = 2000, Caster = player, CurrentLocation = location, CurrentMap = this, }; AddObject(ob); ob.Spawned(); } break; #endregion #region Lightning case Spell.Lightning: value = (int)data[2]; location = (Point)data[3]; dir = (MirDirection)data[4]; for (int i = 0; i < 6; i++) { location = Functions.PointMove(location, dir, 1); if (!ValidPoint(location)) continue; cell = GetCell(location); if (cell.Objects == null) continue; for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Player && target.Race != ObjectType.Monster) continue; if (!target.IsAttackTarget(player)) continue; if (target.Attacked(player, value, DefenceType.MAC, false) > 0) train = true; break; } } break; #endregion #region HeavenlySword case Spell.HeavenlySword: value = (int)data[2]; location = (Point)data[3]; dir = (MirDirection)data[4]; for (int i = 0; i < 3; i++) { location = Functions.PointMove(location, dir, 1); if (!ValidPoint(location)) continue; cell = GetCell(location); if (cell.Objects == null) continue; for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Player && target.Race != ObjectType.Monster) continue; if (!target.IsAttackTarget(player)) continue; if (target.Attacked(player, value, DefenceType.MAC, false) > 0) train = true; break; } } break; #endregion #region MassHealing case Spell.MassHealing: value = (int)data[2]; location = (Point)data[3]; for (int y = location.Y - 1; y <= location.Y + 1; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 1; x <= location.X + 1; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (target.IsFriendlyTarget(player)) { if (target.Health >= target.MaxHealth) continue; target.HealAmount = (ushort)Math.Min(ushort.MaxValue, target.HealAmount + value); target.OperateTime = 0; train = true; } break; } } } } break; #endregion #region ThunderStorm case Spell.ThunderStorm: case Spell.FlameField: value = (int)data[2]; location = (Point)data[3]; for (int y = location.Y - 2; y <= location.Y + 2; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 2; x <= location.X + 2; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (!target.IsAttackTarget(player)) break; if (target.Attacked(player, magic.Spell == Spell.FlameField || target.Undead ? value : value/10, DefenceType.MAC, false) <= 0) break; train = true; break; } } } } break; #endregion #region SummonShinsu case Spell.SummonShinsu: monster = (MonsterObject)data[2]; front = (Point)data[3]; if (ValidPoint(front)) monster.Spawn(this, front); else monster.Spawn(player.CurrentMap, player.CurrentLocation); break; #endregion #region LionRoar case Spell.LionRoar: location = (Point)data[2]; for (int y = location.Y - 2; y <= location.Y + 2; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 2; x <= location.X + 2; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; if (target.Race != ObjectType.Monster) continue; //Only targets if (!target.IsAttackTarget(player) || player.Level + 10 < target.Level) continue; target.ApplyPoison(new Poison { PType = PoisonType.Paralysis, Duration = magic.Level + 2, TickSpeed = 1000 }); target.OperateTime = 0; train = true; } } } break; #endregion #region PoisonField case Spell.PoisonField: value = (int)data[2]; location = (Point)data[3]; train = true; bool show = true; for (int y = location.Y - 1; y <= location.Y + 1; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 1; x <= location.X + 1; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid) continue; bool cast = true; if (cell.Objects != null) for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Spell || ((SpellObject) target).Spell != Spell.PoisonField) continue; cast = false; break; } if (!cast) continue; SpellObject ob = new SpellObject { Spell = Spell.PoisonField, Value = value, ExpireTime = Envir.Time + 6000, TickSpeed = 1000, Caster = player, CurrentLocation = new Point(x, y), CastLocation = location, Show = show, CurrentMap = this, }; show = false; AddObject(ob); ob.Spawned(); } } break; #endregion #region BladeAvalanche case Spell.BladeAvalanche: value = (int)data[2]; dir = (MirDirection)data[4]; location = Functions.PointMove((Point)data[3], dir, 1); count = (int)data[5] - 1; if (!ValidPoint(location)) return; if (count > 0) { DelayedAction action = new DelayedAction(DelayedType.Magic, Envir.Time + 100, player, magic, value, location, dir, count); ActionList.Add(action); } cell = GetCell(location); if (cell.Objects == null) return; for (int i = 0; i < cell.Objects.Count; i++) { MapObject target = cell.Objects[i]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (target.IsAttackTarget(player)) { if (target.Attacked(player, value, DefenceType.MAC, false) > 0) player.LevelMagic(magic); return; } break; } } break; #endregion #region Mirroring case Spell.Mirroring: monster = (MonsterObject)data[2]; front = (Point)data[3]; bool finish = (bool)data[4]; if (finish) { monster.Die(); return; }; if (ValidPoint(front)) monster.Spawn(this, front); else monster.Spawn(player.CurrentMap, player.CurrentLocation); break; #endregion #region Blizzard case Spell.Blizzard: value = (int)data[2]; location = (Point)data[3]; train = true; show = true; for (int y = location.Y - 2; y <= location.Y + 2; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 2; x <= location.X + 2; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid) continue; bool cast = true; if (cell.Objects != null) for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Spell || ((SpellObject) target).Spell != Spell.Blizzard) continue; cast = false; break; } if (!cast) continue; SpellObject ob = new SpellObject { Spell = Spell.Blizzard, Value = value, ExpireTime = Envir.Time + 3000, TickSpeed = 440, Caster = player, CurrentLocation = new Point(x, y), CastLocation = location, Show = show, CurrentMap = this, StartTime = Envir.Time + 800, }; show = false; AddObject(ob); ob.Spawned(); } } break; #endregion #region MeteorStrike case Spell.MeteorStrike: value = (int)data[2]; location = (Point)data[3]; train = true; show = true; for (int y = location.Y - 2; y <= location.Y + 2; y++) { if (y < 0) continue; if (y >= Height) break; for (int x = location.X - 2; x <= location.X + 2; x++) { if (x < 0) continue; if (x >= Width) break; cell = GetCell(x, y); if (!cell.Valid) continue; bool cast = true; if (cell.Objects != null) for (int o = 0; o < cell.Objects.Count; o++) { MapObject target = cell.Objects[o]; if (target.Race != ObjectType.Spell || ((SpellObject)target).Spell != Spell.MeteorStrike) continue; cast = false; break; } if (!cast) continue; SpellObject ob = new SpellObject { Spell = Spell.MeteorStrike, Value = value, ExpireTime = Envir.Time + 3000, TickSpeed = 440, Caster = player, CurrentLocation = new Point(x, y), CastLocation = location, Show = show, CurrentMap = this, StartTime = Envir.Time + 800, }; show = false; AddObject(ob); ob.Spawned(); } } break; #endregion } if (train) player.LevelMagic(magic); }
private void Reincarnation(UserMagic magic, PlayerObject target, out bool cast) { cast = true; if (target == null || !target.Dead) return; // if (ReincarnationTarget == null || !ReincarnationTarget.Dead) return; UserItem item = GetAmulet(1, 3); if (item == null) return; if (!ActiveReincarnation && !ReincarnationReady) { cast = false; ActiveReincarnation = true; ReincarnationTarget = target; SpellObject ob = new SpellObject { Spell = Spell.Reincarnation, ExpireTime = Envir.Time + 3000, TickSpeed = 1000, Caster = this, CurrentLocation = CurrentLocation, CastLocation = CurrentLocation, Show = true, CurrentMap = CurrentMap, }; CurrentMap.AddObject(ob); ob.Spawned(); Packet p = new S.Chat { Message = string.Format("{0} is attempting to revive {1}", Name, target.Name), Type = ChatType.Shout }; ReincarnationReady = false; if (Envir.Random.Next(30) > (magic.Level) * 10) { ReceiveChat("Reviving failed.", ChatType.System); return; } ConsumeItem(item, 1); Envir.Broadcast(p); ReincarnationTarget.Enqueue(new S.RequestReincarnation { }); return; } //else //{ // if (ReincarnationTarget == null || ReincarnationTarget.Node == null || !ReincarnationTarget.Dead) return; // ReincarnationReady = false; // //if (Envir.Random.Next(50) > (magic.Level + 2) * 10) // //{ // // ReceiveChat("Reviving failed.", ChatType.System); // // return; // //} // ReincarnationTarget.Enqueue(new S.RequestReincarnation { }); // ConsumeItem(item, 1); // return; //} }