public void ClearMagic() { NextMagic = null; NextMagicDirection = 0; NextMagicLocation = Point.Empty; NextMagicObject = null; }
public override int Pushed(MapObject pusher, MirDirection dir, int distance) { int result = base.Pushed(pusher, dir, distance); if (result > 0) { if (pusher is PlayerObject) Attacked((PlayerObject)pusher, Math.Max(50, Envir.Random.Next((int)MaxHP)), DefenceType.Repulsion); else if (pusher is MonsterObject) Attacked((MonsterObject)pusher, Math.Max(50, Envir.Random.Next((int)MaxHP)), DefenceType.Repulsion); } return result; }
protected override void ProcessAI() { if (!Dead && Envir.Time > VisibleTime) { VisibleTime = Envir.Time + 2000; bool visible = FindNearby(3); if (!Visible && visible) { Visible = true; CellTime = Envir.Time + 500; Broadcast(GetInfo()); Broadcast(new S.ObjectShow { ObjectID = ObjectID }); ActionTime = Envir.Time + 2000; DigOutTime = Envir.Time; DigOutLocation = CurrentLocation; DigOutDirection = Direction; } } if (Visible && Envir.Time > DigOutTime + 1000 && !DoneDigOut) { SpellObject ob = new SpellObject { Spell = Spell.DigOutZombie, Value = 1, ExpireTime = Envir.Time + (5 * 60 * 1000), TickSpeed = 2000, Caster = null, CurrentLocation = DigOutLocation, CurrentMap = this.CurrentMap, Direction = DigOutDirection }; CurrentMap.AddObject(ob); ob.Spawned(); DoneDigOut = true; } base.ProcessAI(); }
public CharacterInfo(BinaryReader reader) { Index = reader.ReadInt32(); Name = reader.ReadString(); Level = reader.ReadByte(); Class = (MirClass)reader.ReadByte(); Gender = (MirGender)reader.ReadByte(); Hair = reader.ReadByte(); CreationIP = reader.ReadString(); CreationDate = DateTime.FromBinary(reader.ReadInt64()); Banned = reader.ReadBoolean(); BanReason = reader.ReadString(); ExpiryDate = DateTime.FromBinary(reader.ReadInt64()); LastIP = reader.ReadString(); LastDate = DateTime.FromBinary(reader.ReadInt64()); Deleted = reader.ReadBoolean(); DeleteDate = DateTime.FromBinary(reader.ReadInt64()); CurrentMapIndex = reader.ReadInt32(); CurrentLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); Direction = (MirDirection)reader.ReadByte(); BindMapIndex = reader.ReadInt32(); BindLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); HP = reader.ReadUInt16(); MP = reader.ReadUInt16(); Experience = reader.ReadInt64(); AMode = (AttackMode)reader.ReadByte(); PMode = (PetMode)reader.ReadByte(); if (Envir.LoadVersion > 34) { PKPoints = reader.ReadInt32(); } int count = reader.ReadInt32(); Array.Resize(ref Inventory, count); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion); if (SMain.Envir.BindItem(item) && i < Inventory.Length) { Inventory[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion); if (SMain.Envir.BindItem(item) && i < Equipment.Length) { Equipment[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion); if (SMain.Envir.BindItem(item) && i < QuestInventory.Length) { QuestInventory[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion); if (SMain.Envir.BindItem(item) && i < Storage.Length) { Storage[i] = item; } } Gold = reader.ReadUInt32(); count = reader.ReadInt32(); for (int i = 0; i < count; i++) { UserMagic magic = new UserMagic(reader); if (magic.Info == null) { continue; } Magics.Add(magic); } if (Envir.LoadVersion < 2) { return; } Thrusting = reader.ReadBoolean(); HalfMoon = reader.ReadBoolean(); CrossHalfMoon = reader.ReadBoolean(); DoubleSlash = reader.ReadBoolean(); if (Envir.LoadVersion < 4) { return; } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Pets.Add(new PetInfo(reader)); } if (Envir.LoadVersion < 5) { return; } AllowGroup = reader.ReadBoolean(); if (Envir.LoadVersion < 12) { return; } if (Envir.LoadVersion == 12) { count = reader.ReadInt32(); } for (int i = 0; i < Globals.FlagIndexCount; i++) { Flags[i] = reader.ReadBoolean(); } if (Envir.LoadVersion > 27) { GuildIndex = reader.ReadInt32(); } if (Envir.LoadVersion > 30) { AllowTrade = reader.ReadBoolean(); } if (Envir.LoadVersion > 33) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { CurrentQuests.Add(new QuestProgressInfo(reader)); } } if (Envir.LoadVersion > 42) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Buff buff = new Buff(reader); if (Envir.LoadVersion > 50) { buff.Caster = SMain.Envir.GetObject(reader.ReadUInt32()); } Buffs.Add(buff); } } if (Envir.LoadVersion > 43) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Mail.Add(new MailInfo(reader)); } } //IntelligentCreature if (Envir.LoadVersion > 44) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { UserIntelligentCreature creature = new UserIntelligentCreature(reader); if (creature.Info == null) { continue; } IntelligentCreatures.Add(creature); } if (Envir.LoadVersion == 45) { var old1 = (IntelligentCreatureType)reader.ReadByte(); var old2 = reader.ReadBoolean(); } PearlCount = reader.ReadInt32(); } if (Envir.LoadVersion > 49) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { CompletedQuests.Add(reader.ReadInt32()); } } if (Envir.LoadVersion > 50) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Poison poison = new Poison(reader); if (Envir.LoadVersion > 50) { poison.Owner = SMain.Envir.GetObject(reader.ReadUInt32()); } Poisons.Add(poison); } } }
protected override void ReadPacket(BinaryReader reader) { Direction = (MirDirection)reader.ReadByte(); }
public virtual void Turn(MirDirection dir) { if (!CanMove) return; Direction = dir; InSafeZone = CurrentMap.GetSafeZone(CurrentLocation) != null; Cell cell = CurrentMap.GetCell(CurrentLocation); for (int i = 0; i < cell.Objects.Count; i++) { if (cell.Objects[i].Race != ObjectType.Spell) continue; SpellObject ob = (SpellObject)cell.Objects[i]; ob.ProcessSpell(this); break; } Broadcast(new S.ObjectTurn { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); }
public static MirDirection NextDir(MirDirection d) { switch (d) { case MirDirection.Up: return MirDirection.UpRight; case MirDirection.UpRight: return MirDirection.Right; case MirDirection.Right: return MirDirection.DownRight; case MirDirection.DownRight: return MirDirection.Down; case MirDirection.Down: return MirDirection.DownLeft; case MirDirection.DownLeft: return MirDirection.Left; case MirDirection.Left: return MirDirection.UpLeft; case MirDirection.UpLeft: return MirDirection.Up; default: return d; } }
public abstract int Pushed(MapObject pusher, MirDirection dir, int distance);
public override void Turn(MirDirection dir) { }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } DelayedAction action; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1); int damage = 0; if (ranged) { if (tornado) { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0, TargetID = Target.ObjectID }); damage = GetAttackPower(MinDC, MaxDC); List <MapObject> targets = FindAllTargets(1, Target.CurrentLocation); for (int i = 0; i < targets.Count; i++) { action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 1000, targets[i], damage, DefenceType.ACAgility); ActionList.Add(action); } ActionTime = Envir.Time + 800; AttackTime = Envir.Time + AttackSpeed; tornado = false; return; } } if (!ranged) { if (stomp) { //Foot stomp Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 }); MirDirection dir = Functions.PreviousDir(Direction); Point tar; Cell cell; damage = GetAttackPower(MinDC, MaxDC); for (int i = 0; i < 8; i++) { tar = Functions.PointMove(CurrentLocation, dir, 1); dir = Functions.NextDir(dir); if (!CurrentMap.ValidPoint(tar)) { continue; } cell = CurrentMap.GetCell(tar); 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; } action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, AttackType.Stomp); ActionList.Add(action); break; } } ActionTime = Envir.Time + 800; AttackTime = Envir.Time + AttackSpeed; stomp = false; return; } switch (Envir.Random.Next(2)) { case 0: //Slash Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); damage = GetAttackPower(MinDC, MaxDC); action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, AttackType.SingleSlash); ActionList.Add(action); damage = GetAttackPower(MinDC, MaxDC); action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.ACAgility, AttackType.SingleSlash); ActionList.Add(action); break; case 1: //Two hand slash Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); damage = GetAttackPower(MinDC, MaxDC); action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, AttackType.SingleSlash); ActionList.Add(action); break; } if (Envir.Random.Next(5) == 0) { stomp = true; } if (Envir.Random.Next(2) == 0) { tornado = true; } } ActionTime = Envir.Time + 500; AttackTime = Envir.Time + AttackSpeed; ShockTime = 0; }
protected override void ReadPacket(BinaryReader reader) { ObjectID = reader.ReadUInt32(); Name = reader.ReadString(); GuildName = reader.ReadString(); GuildRankName = reader.ReadString(); NameColour = Color.FromArgb(reader.ReadInt32()); Class = (MirClass)reader.ReadByte(); Gender = (MirGender)reader.ReadByte(); Level = reader.ReadByte(); Location = new Point(reader.ReadInt32(), reader.ReadInt32()); Direction = (MirDirection)reader.ReadByte(); Hair = reader.ReadByte(); Light = reader.ReadByte(); Weapon = reader.ReadInt16(); Armour = reader.ReadInt16(); Poison = (PoisonType)reader.ReadByte(); Dead = reader.ReadBoolean(); Hidden = reader.ReadBoolean(); Effect = (SpellEffect)reader.ReadByte(); WingEffect = reader.ReadByte(); Extra = reader.ReadBoolean(); MountType = reader.ReadInt16(); RidingMount = reader.ReadBoolean(); Fishing = reader.ReadBoolean(); TransformType = reader.ReadInt16(); ElementOrbEffect = reader.ReadUInt32(); ElementOrbLvl = reader.ReadUInt32(); ElementOrbMax = reader.ReadUInt32(); int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Buffs.Add((BuffType)reader.ReadByte()); } LevelEffects = (LevelEffects)reader.ReadByte(); }
protected override void ProcessTarget() { if (Target == null) { return; } if (InAttackRange() && CanAttack) { Attack(); return; } if (Envir.Time < ShockTime) { Target = null; return; } var hpPercent = (HP * 100) / Stats[Stat.HP]; bool halfHealth = hpPercent <= 50; int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation); if (dist >= Info.ViewRange || !halfHealth) { MoveTo(Target.CurrentLocation); } else { MirDirection dir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation); if (Walk(dir)) { return; } switch (Envir.Random.Next(2)) //No favour { case 0: for (int i = 0; i < 7; i++) { dir = Functions.NextDir(dir); if (Walk(dir)) { return; } } break; default: for (int i = 0; i < 7; i++) { dir = Functions.PreviousDir(dir); if (Walk(dir)) { return; } } break; } } }
public static MirDirection ShiftDirection(MirDirection dir, int i) { return((MirDirection)(((int)dir + i + 8) % 8)); }
public override int Pushed(MirDirection direction, int distance) { return(0); }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); MirDirection dir = Functions.PreviousDir(Direction); Point target; Cell cell; 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, MinDC, DefenceType.Agility); break; } } ShockTime = 0; ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(MinDC, MaxDC); if (damage == 0) { return; } Target.Attacked(this, damage, DefenceType.ACAgility); }
protected override void ProcessTarget() { if (Target == null || !CanAttack || Target.PercentHealth == 100) { return; } if (PercentHealth != 100 && Envir.Time < FearTime) { HealMyself(); return; } if (InAttackRange() && Envir.Time < FearTime && Target.Race != ObjectType.Player) { HealTarget(); return; } FearTime = Envir.Time + 5000; if (Envir.Time < ShockTime) { Target = null; return; } if (Target.Race == ObjectType.Player) { int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation); if (dist < 3) { MirDirection dir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation); if (Walk(dir)) { return; } switch (Envir.Random.Next(2)) //No favour { case 0: for (int i = 0; i < 4; i++) { dir = Functions.NextDir(dir); if (Walk(dir)) { return; } } break; default: for (int i = 0; i < 4; i++) { dir = Functions.PreviousDir(dir); if (Walk(dir)) { return; } } break; } } SearchTarget(); } }
protected override void ReadPacket(BinaryReader reader) { ObjectID = reader.ReadUInt32(); Name = reader.ReadString(); NameColour = Color.FromArgb(reader.ReadInt32()); Image = reader.ReadByte(); Location = new Point(reader.ReadInt32(), reader.ReadInt32()); Direction = (MirDirection)reader.ReadByte(); int count = reader.ReadInt32(); for (var i = 0; i < count; i++) QuestIDs.Add(reader.ReadInt32()); }
private bool CheckAndMoveTo(Point location) { if (CurrentLocation == location) { return(true); } bool inRange = Functions.InRange(location, CurrentLocation, 1); if (inRange) { if (!CurrentMap.ValidPoint(location)) { return(false); } Cell cell = CurrentMap.GetCell(location); if (cell.Objects != null) { for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (!ob.Blocking) { continue; } return(false); } } } MirDirection dir = Functions.DirectionFromPoint(CurrentLocation, location); if (Walk(dir)) { return(true); } switch (Envir.Random.Next(2)) //No favour { case 0: for (int i = 0; i < 7; i++) { dir = Functions.NextDir(dir); if (Walk(dir)) { return(true); } } break; default: for (int i = 0; i < 7; i++) { dir = Functions.PreviousDir(dir); if (Walk(dir)) { return(true); } } break; } return(false); }
protected override void ReadPacket(BinaryReader reader) { ObjectID = reader.ReadUInt32(); Location = new Point(reader.ReadInt32(), reader.ReadInt32()); Direction = (MirDirection)reader.ReadByte(); Spell = (Spell)reader.ReadByte(); TargetID = reader.ReadUInt32(); Target = new Point(reader.ReadInt32(), reader.ReadInt32()); Cast = reader.ReadBoolean(); Level = reader.ReadByte(); SelfBroadcast = reader.ReadBoolean(); }
public static void CheckMouseInput() { if (CurrentScene == null) { return; } if (User.Player == null) { return; } if (UIDragging) { return; } if (User.Player.Dead) { return; } if (User.Player.ActionFeed.Count == 0 && Time.time > InputDelay) { MouseUpdate(); if (Input.GetMouseButton(0)) { if (MouseDistance < turnRange) { if (MouseDirection != User.Player.Direction) { GameScene.QueuedAction = new QueuedAction { Action = MirAction.Standing, Direction = MouseDirection, Location = User.Player.CurrentLocation } } ; } else { if (!TryWalk(MouseDirection)) { MirDirection newdirection = Functions.PreviousDir(MouseDirection); if (!TryWalk(newdirection)) { newdirection = Functions.NextDir(MouseDirection); TryWalk(newdirection); } } } } else if (Input.GetMouseButton(1)) { if (MouseDistance < turnRange) { if (MouseDirection != User.Player.Direction) { GameScene.QueuedAction = new QueuedAction { Action = MirAction.Standing, Direction = MouseDirection, Location = User.Player.CurrentLocation } } ; } else { if (!User.CanRun || !TryRun(MouseDirection)) { if (!TryWalk(MouseDirection)) { MirDirection newdirection = Functions.PreviousDir(MouseDirection); if (!TryWalk(newdirection)) { newdirection = Functions.NextDir(MouseDirection); TryWalk(newdirection); } } } } } } }
public void Turn(MirDirection dir) { Direction = dir; Broadcast(new S.ObjectTurn { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); if (_attackCount >= 5) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 }); int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]); List <MapObject> targets = FindAllTargets(3, CurrentLocation); for (int i = 0; i < targets.Count; i++) { targets[i].Attacked(this, damage, DefenceType.MAC); //TODO - Delay this if (Envir.Random.Next(Settings.PoisonResistWeight) >= targets[i].Stats[Stat.PoisonResist]) { if (Envir.Random.Next(5) == 0) { targets[i].ApplyPoison(new Poison { PType = PoisonType.Frozen, Duration = 5, TickSpeed = 1000 }, this); } } } _attackCount = 0; return; } switch (Envir.Random.Next(3)) { case 0: case 1: _attackCount++; base.Attack(); break; case 2: { int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]); Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); MirDirection dir = Functions.PreviousDir(Direction); Point tar; Cell cell; for (int i = 0; i < 8; i++) { tar = Functions.PointMove(CurrentLocation, dir, 1); dir = Functions.NextDir(dir); if (tar == Front) { continue; } if (!CurrentMap.ValidPoint(tar)) { continue; } cell = CurrentMap.GetCell(tar); 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; } } break; } } ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; ShockTime = 0; }
private void explosionDie() { int damage = Envir.Random.Next(10, 30); for (int i = 0; i < 16; i++) { MirDirection dir = (MirDirection)(i % 8); Point hitPoint = Functions.PointMove(CurrentLocation, dir, (i / 8 + 1)); if (!CurrentMap.ValidPoint(hitPoint)) { continue; } Cell cell = CurrentMap.GetCell(hitPoint); if (cell.Objects == null) { continue; } for (int j = 0; j < cell.Objects.Count; j++) { MapObject target = cell.Objects[j]; switch (target.Race) { case ObjectType.Monster: case ObjectType.Player: //Only targets if (target.IsAttackTarget((PlayerObject)Master)) { target.Attacked((PlayerObject)Master, damage, DefenceType.None, false); } break; } } } // Get all objects within a range of 12 List <MapObject> objs = FindAllNearby(12, CurrentLocation, false); // Loop through each object found for (int i = 0; i < objs.Count; i++) { // If it's not a mob go to the next object if (objs[i].Race != ObjectType.Monster) { continue; } // Check we have a MonsterObject if (objs[i] is MonsterObject tmpM) { // Check it doesn't have master if (tmpM.Master != null) { continue; } // Check we have a master if (Master == null) { continue; } // Check our master is actually a player if (Master.Race != ObjectType.Player) { continue; } // Check if their target is our master if (tmpM.Target == Master) { // Set their target to our self tmpM.Target = this; } } } }
public override bool Walk(MirDirection dir) { if (!CanMove) { return(false); } Point location = Functions.PointMove(CurrentLocation, dir, 1); if (!CurrentMap.ValidPoint(location)) { return(false); } Cell cell = CurrentMap.GetCell(location); if (cell.Objects != null) { for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (AvoidFireWall && ob.Race == ObjectType.Spell) { if (((SpellObject)ob).Spell == Spell.FireWall) { return(false); } } if (!ob.Blocking) { continue; } return(false); } } CurrentMap.GetCell(CurrentLocation).Remove(this); Direction = dir; RemoveObjects(dir, 1); CurrentLocation = location; CurrentMap.GetCell(CurrentLocation).Add(this); AddObjects(dir, 1); if (Hidden) { Hidden = false; for (int i = 0; i < Buffs.Count; i++) { if (Buffs[i].Type != BuffType.Hiding) { continue; } Buffs[i].ExpireTime = 0; break; } } CellTime = Envir.Time + 500; ActionTime = Envir.Time + 300; MoveTime = Envir.Time + MoveSpeed; InSafeZone = CurrentMap.GetSafeZone(CurrentLocation) != null; Broadcast(new S.ObjectWalk { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); cell = CurrentMap.GetCell(CurrentLocation); for (int i = 0; i < cell.Objects.Count; i++) { if (cell.Objects[i].Race != ObjectType.Spell) { continue; } SpellObject ob = (SpellObject)cell.Objects[i]; ob.ProcessSpell(this); break; } return(true); }
public override int Pushed(MapObject pusher, MirDirection dir, int distance) { throw new NotSupportedException(); }
public override int Pushed(MapObject pusher, MirDirection dir, int distance) { return(Stoned ? 0 : base.Pushed(pusher, dir, distance)); }
public void AddObjects(MirDirection dir, int count) { switch (dir) { case MirDirection.Up: for (int a = 0; a < count; a++) { int y = CurrentLocation.Y - Globals.DataRange + a; if (y < 0 || y >= CurrentMap.Height) continue; for (int b = -Globals.DataRange; b <= Globals.DataRange; b++) { int x = CurrentLocation.X + b; if (x < 0 || x >= CurrentMap.Width) continue; Cell cell = CurrentMap.GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player) continue; ob.Add(this); } } } break; case MirDirection.UpRight: //Top Block for (int a = 0; a < count; a++) { int y = CurrentLocation.Y - Globals.DataRange + a; if (y < 0 || y >= CurrentMap.Height) continue; for (int b = -Globals.DataRange; b <= Globals.DataRange; b++) { int x = CurrentLocation.X + b; if (x < 0 || x >= CurrentMap.Width) continue; Cell cell = CurrentMap.GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player) continue; ob.Add(this); } } } //Right Block for (int a = -Globals.DataRange + count; a <= Globals.DataRange; a++) { int y = CurrentLocation.Y + a; if (y < 0 || y >= CurrentMap.Height) continue; for (int b = 0; b < count; b++) { int x = CurrentLocation.X + Globals.DataRange - b; if (x < 0 || x >= CurrentMap.Width) continue; Cell cell = CurrentMap.GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player) continue; ob.Add(this); } } } break; case MirDirection.Right: for (int a = -Globals.DataRange; a <= Globals.DataRange; a++) { int y = CurrentLocation.Y + a; if (y < 0 || y >= CurrentMap.Height) continue; for (int b = 0; b < count; b++) { int x = CurrentLocation.X + Globals.DataRange - b; if (x < 0 || x >= CurrentMap.Width) continue; Cell cell = CurrentMap.GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player) continue; ob.Add(this); } } } break; case MirDirection.DownRight: //Bottom Block for (int a = 0; a < count; a++) { int y = CurrentLocation.Y + Globals.DataRange - a; if (y < 0 || y >= CurrentMap.Height) continue; for (int b = -Globals.DataRange; b <= Globals.DataRange; b++) { int x = CurrentLocation.X + b; if (x < 0 || x >= CurrentMap.Width) continue; Cell cell = CurrentMap.GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player) continue; ob.Add(this); } } } //Right Block for (int a = -Globals.DataRange; a <= Globals.DataRange - count; a++) { int y = CurrentLocation.Y + a; if (y < 0 || y >= CurrentMap.Height) continue; for (int b = 0; b < count; b++) { int x = CurrentLocation.X + Globals.DataRange - b; if (x < 0 || x >= CurrentMap.Width) continue; Cell cell = CurrentMap.GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player) continue; ob.Add(this); } } } break; case MirDirection.Down: //Bottom Block for (int a = 0; a < count; a++) { int y = CurrentLocation.Y + Globals.DataRange - a; if (y < 0 || y >= CurrentMap.Height) continue; for (int b = -Globals.DataRange; b <= Globals.DataRange; b++) { int x = CurrentLocation.X + b; if (x < 0 || x >= CurrentMap.Width) continue; Cell cell = CurrentMap.GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player) continue; ob.Add(this); } } } break; case MirDirection.DownLeft: //Bottom Block for (int a = 0; a < count; a++) { int y = CurrentLocation.Y + Globals.DataRange - a; if (y < 0 || y >= CurrentMap.Height) continue; for (int b = -Globals.DataRange; b <= Globals.DataRange; b++) { int x = CurrentLocation.X + b; if (x < 0 || x >= CurrentMap.Width) continue; Cell cell = CurrentMap.GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player) continue; ob.Add(this); } } } //Left Block for (int a = -Globals.DataRange; a <= Globals.DataRange - count; a++) { int y = CurrentLocation.Y + a; if (y < 0 || y >= CurrentMap.Height) continue; for (int b = 0; b < count; b++) { int x = CurrentLocation.X - Globals.DataRange + b; if (x < 0 || x >= CurrentMap.Width) continue; Cell cell = CurrentMap.GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player) continue; ob.Add(this); } } } break; case MirDirection.Left: //Left Block for (int a = -Globals.DataRange; a <= Globals.DataRange; a++) { int y = CurrentLocation.Y + a; if (y < 0 || y >= CurrentMap.Height) continue; for (int b = 0; b < count; b++) { int x = CurrentLocation.X - Globals.DataRange + b; if (x < 0 || x >= CurrentMap.Width) continue; Cell cell = CurrentMap.GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player) continue; ob.Add(this); } } } break; case MirDirection.UpLeft: //Top Block for (int a = 0; a < count; a++) { int y = CurrentLocation.Y - Globals.DataRange + a; if (y < 0 || y >= CurrentMap.Height) continue; for (int b = -Globals.DataRange; b <= Globals.DataRange; b++) { int x = CurrentLocation.X + b; if (x < 0 || x >= CurrentMap.Width) continue; Cell cell = CurrentMap.GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player) continue; ob.Add(this); } } } //Left Block for (int a = -Globals.DataRange + count; a <= Globals.DataRange; a++) { int y = CurrentLocation.Y + a; if (y < 0 || y >= CurrentMap.Height) continue; for (int b = 0; b < count; b++) { int x = CurrentLocation.X - Globals.DataRange + b; if (x < 0 || x >= CurrentMap.Width) continue; Cell cell = CurrentMap.GetCell(x, y); if (!cell.Valid || cell.Objects == null) continue; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob.Race != ObjectType.Player) continue; ob.Add(this); } } } break; } }
public CharacterInfo(BinaryReader reader) { Index = reader.ReadInt32(); Name = reader.ReadString(); if (Envir.LoadVersion < 62) { Level = (ushort)reader.ReadByte(); } else { Level = reader.ReadUInt16(); } Class = (MirClass)reader.ReadByte(); Gender = (MirGender)reader.ReadByte(); Hair = reader.ReadByte(); CreationIP = reader.ReadString(); CreationDate = DateTime.FromBinary(reader.ReadInt64()); Banned = reader.ReadBoolean(); BanReason = reader.ReadString(); ExpiryDate = DateTime.FromBinary(reader.ReadInt64()); LastIP = reader.ReadString(); LastLogoutDate = DateTime.FromBinary(reader.ReadInt64()); if (Envir.LoadVersion > 81) { LastLoginDate = DateTime.FromBinary(reader.ReadInt64()); } Deleted = reader.ReadBoolean(); DeleteDate = DateTime.FromBinary(reader.ReadInt64()); CurrentMapIndex = reader.ReadInt32(); CurrentLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); Direction = (MirDirection)reader.ReadByte(); BindMapIndex = reader.ReadInt32(); BindLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); if (Envir.LoadVersion <= 84) { HP = reader.ReadUInt16(); MP = reader.ReadUInt16(); } else { HP = reader.ReadInt32(); MP = reader.ReadInt32(); } Experience = reader.ReadInt64(); AMode = (AttackMode)reader.ReadByte(); PMode = (PetMode)reader.ReadByte(); if (Envir.LoadVersion > 34) { PKPoints = reader.ReadInt32(); } int count = reader.ReadInt32(); Array.Resize(ref Inventory, count); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); if (Envir.BindItem(item) && i < Inventory.Length) { Inventory[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); if (Envir.BindItem(item) && i < Equipment.Length) { Equipment[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); if (Envir.BindItem(item) && i < QuestInventory.Length) { QuestInventory[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { UserMagic magic = new UserMagic(reader); if (magic.Info == null) { continue; } Magics.Add(magic); } //reset all magic cooldowns on char loading < stops ppl from having none working skills after a server crash for (int i = 0; i < Magics.Count; i++) { Magics[i].CastTime = 0; } Thrusting = reader.ReadBoolean(); HalfMoon = reader.ReadBoolean(); CrossHalfMoon = reader.ReadBoolean(); DoubleSlash = reader.ReadBoolean(); MentalState = reader.ReadByte(); count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Pets.Add(new PetInfo(reader)); } AllowGroup = reader.ReadBoolean(); for (int i = 0; i < Globals.FlagIndexCount; i++) { Flags[i] = reader.ReadBoolean(); } GuildIndex = reader.ReadInt32(); AllowTrade = reader.ReadBoolean(); count = reader.ReadInt32(); for (int i = 0; i < count; i++) { QuestProgressInfo quest = new QuestProgressInfo(reader); if (Envir.BindQuest(quest)) { CurrentQuests.Add(quest); } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Buff buff = new Buff(reader); Buffs.Add(buff); } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Mail.Add(new MailInfo(reader, Envir.LoadVersion, Envir.LoadCustomVersion)); } //IntelligentCreature count = reader.ReadInt32(); for (int i = 0; i < count; i++) { UserIntelligentCreature creature = new UserIntelligentCreature(reader); if (creature.Info == null) { continue; } IntelligentCreatures.Add(creature); } if (Envir.LoadVersion == 45) { var old1 = (IntelligentCreatureType)reader.ReadByte(); var old2 = reader.ReadBoolean(); } PearlCount = reader.ReadInt32(); count = reader.ReadInt32(); for (int i = 0; i < count; i++) { CompletedQuests.Add(reader.ReadInt32()); } if (reader.ReadBoolean()) { CurrentRefine = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); } if (CurrentRefine != null) { Envir.BindItem(CurrentRefine); } CollectTime = reader.ReadInt64(); CollectTime += Envir.Time; count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Friends.Add(new FriendInfo(reader)); } if (Envir.LoadVersion > 75) { count = reader.ReadInt32(); for (var i = 0; i < count; i++) { RentedItems.Add(new ItemRentalInformation(reader)); } HasRentedItem = reader.ReadBoolean(); } Married = reader.ReadInt32(); MarriedDate = DateTime.FromBinary(reader.ReadInt64()); Mentor = reader.ReadInt32(); MentorDate = DateTime.FromBinary(reader.ReadInt64()); isMentor = reader.ReadBoolean(); MentorExp = reader.ReadInt64(); if (Envir.LoadVersion >= 63) { int logCount = reader.ReadInt32(); for (int i = 0; i < logCount; i++) { GSpurchases.Add(reader.ReadInt32(), reader.ReadInt32()); } } }
public static Point Right(Point p, MirDirection d) { switch (d) { case MirDirection.Up: p.Offset(1, 0); break; case MirDirection.UpRight: p.Offset(1, 1); break; case MirDirection.Right: p.Offset(0, 1); break; case MirDirection.DownRight: p.Offset(-1, 1); break; case MirDirection.Down: p.Offset(-1, 0); break; case MirDirection.DownLeft: p.Offset(-1,-1); break; case MirDirection.Left: p.Offset(0, -1); break; case MirDirection.UpLeft: p.Offset(1, -1); break; } return p; }
public void ProcessSpell(MapObject ob) { if (Envir.Time < StartTime) { return; } switch (Spell) { case Spell.FireWall: if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) { return; } if (ob.Dead) { return; } if (!ob.IsAttackTarget(Caster)) { return; } ob.Attacked(Caster, Value, DefenceType.MAC, false); break; case Spell.Healing: //SafeZone if (ob.Race != ObjectType.Player && (ob.Race != ObjectType.Monster || ob.Master == null || ob.Master.Race != ObjectType.Player)) { return; } if (ob.Dead || ob.HealAmount != 0 || ob.PercentHealth == 100) { return; } ob.HealAmount += 25; Broadcast(new S.ObjectEffect { ObjectID = ob.ObjectID, Effect = SpellEffect.Healing }); break; case Spell.PoisonCloud: if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) { return; } if (ob.Dead) { return; } if (!ob.IsAttackTarget(Caster)) { return; } ob.Attacked(Caster, Value, DefenceType.MAC, false); if (!ob.Dead) { ob.ApplyPoison(new Poison { Duration = 15, Owner = Caster, PType = PoisonType.Green, TickSpeed = 2000, Value = Value / 20 }, Caster, false, false); } break; case Spell.Blizzard: if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) { return; } if (ob.Dead) { return; } if (Caster != null && Caster.ActiveBlizzard == false) { return; } if (!ob.IsAttackTarget(Caster)) { return; } ob.Attacked(Caster, Value, DefenceType.MAC, false); if (!ob.Dead && Envir.Random.Next(8) == 0) { ob.ApplyPoison(new Poison { Duration = 5 + Envir.Random.Next(Caster.Freezing), Owner = Caster, PType = PoisonType.Slow, TickSpeed = 2000, }, Caster); } break; case Spell.MeteorStrike: if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) { return; } if (ob.Dead) { return; } if (Caster != null && Caster.ActiveBlizzard == false) { return; } if (!ob.IsAttackTarget(Caster)) { return; } ob.Attacked(Caster, Value, DefenceType.MAC, false); break; case Spell.ExplosiveTrap: if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) { return; } if (ob.Dead) { return; } if (!ob.IsAttackTarget(Caster)) { return; } if (DetonatedTrap) { return; //make sure explosion happens only once } DetonateTrapNow(); ob.Attacked(Caster, Value, DefenceType.MAC, false); break; case Spell.MapLava: case Spell.MapLightning: case Spell.MapQuake1: case Spell.MapQuake2: if (Value == 0) { return; } if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) { return; } if (ob.Dead) { return; } ob.Struck(Value, DefenceType.MAC); break; case Spell.Portal: if (ob.Race != ObjectType.Player) { return; } if (Caster != ob && (Caster == null || (Caster.GroupMembers == null) || (!Caster.GroupMembers.Contains((PlayerObject)ob)))) { return; } if (ExitMap == null) { return; } MirDirection dir = ob.Direction; Point newExit = Functions.PointMove(ExitCoord, dir, 1); if (!ExitMap.ValidPoint(newExit)) { return; } ob.Teleport(ExitMap, newExit, false); break; } }
protected override void ProcessTarget() { if (Target == null) { return; } if (InAttackRange() && CanAttack) { Attack(); if (Target == null || Target.Dead) { FindTarget(); } return; } if (Envir.Time < ShockTime) { Target = null; return; } if (!CanMove || Target == null) { return; } int distance = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation); if (distance > 6) { MoveTo(Target.CurrentLocation); return; } //40几率跑路 if (RandomUtils.Next(100) < 60) { return; } MirDirection dir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation); if (Walk(dir)) { return; } switch (RandomUtils.Next(2)) //No favour { case 0: for (int i = 0; i < 7; i++) { dir = Functions.NextDir(dir); if (Walk(dir)) { return; } } break; default: for (int i = 0; i < 7; i++) { dir = Functions.PreviousDir(dir); if (Walk(dir)) { return; } } break; } }
void Update() { if (shopController.IsShopWindowOpen()) { Debug.Log("ShopControllerIsActive"); if (Inventory.UseShopInventoryControls()) { return; } } if (SelectedItemImage.gameObject.activeSelf) { SelectedItemImage.transform.position = Input.mousePosition; SelectedItemImage.transform.SetAsLastSibling(); } MouseObject = GetMouseObject(); if (Input.GetKeyDown(KeyCode.Tab)) { if (Time.time > PickUpTime) { PickUpTime = Time.time + 0.2f; Network.Enqueue(new C.PickUp()); } } if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { if (Input.GetMouseButton(0)) { if (!eventSystem.IsPointerOverGameObject() && CanAttack()) { GameManager.InputDelay = Time.time + 0.5f; NextHitTime = Time.time + 1.6f; QueuedAction = new QueuedAction { Action = MirAction.Attack, Direction = GameManager.MouseUpdate(), Location = User.Player.CurrentLocation }; } return; } else if (TargetObject != null && !(TargetObject is MonsterObject) && !TargetObject.Dead && TargetObject.gameObject.activeSelf && CanAttack()) { Point self = new Point(User.Player.CurrentLocation.x, User.Player.CurrentLocation.y); Point targ = new Point(TargetObject.CurrentLocation.x, TargetObject.CurrentLocation.y); if (Functions.InRange(self, targ, 1)) { NextHitTime = Time.time + 1.6f; MirDirection direction = Functions.DirectionFromPoint(self, targ); QueuedAction = new QueuedAction { Action = MirAction.Attack, Direction = direction, Location = User.Player.CurrentLocation }; return; } MirDirection targetdirection = Functions.DirectionFromPoint(self, targ); if (!CanWalk(targetdirection)) { return; } QueuedAction = new QueuedAction { Action = MirAction.Walking, Direction = targetdirection, Location = ClientFunctions.VectorMove(User.Player.CurrentLocation, targetdirection, 1) }; } } if (Input.GetMouseButtonUp(0) && !eventSystem.IsPointerOverGameObject() && Time.time > GameManager.InputDelay) { if (SelectedCell != null) { SelectedItemImage.gameObject.SetActive(false); MessageBox.Show($"Drop {SelectedCell.Item.Name}?", okbutton: true, cancelbutton: true); MessageBox.OK += () => { Network.Enqueue(new C.DropItem { UniqueID = SelectedCell.Item.UniqueID, Count = 1 }); SelectedCell.Locked = true; SelectedCell = null; }; MessageBox.Cancel += () => { Debug.Log("CancelInvoke"); SelectedCell = null; }; return; } } if (Input.GetMouseButton(0) && SelectedCell == null && !eventSystem.IsPointerOverGameObject() && Time.time > GameManager.InputDelay) { GameManager.User.CanRun = false; if (MouseObject != null) { switch (MouseObject.gameObject.layer) { case 9: //Monster MonsterObject monster = (MonsterObject)MouseObject; if (monster.Dead) { break; } TargetObject = monster; GameManager.InputDelay = Time.time + 0.5f; return; case 10: //NPC NPCObject npc = (NPCObject)MouseObject; NPCName = npc.Name; NPCID = npc.ObjectID; NPCCamera.transform.SetParent(npc.CameraLocation.transform, false); Network.Enqueue(new C.CallNPC { ObjectID = npc.ObjectID, Key = "[@Main]" }); GameManager.InputDelay = Time.time + 0.5f; return; } } TargetObject = null; GameManager.CheckMouseInput(); } else if (Input.GetMouseButton(1) && !eventSystem.IsPointerOverGameObject()) { GameManager.CheckMouseInput(); } else { GameManager.User.CanRun = false; if (TargetObject != null && TargetObject is MonsterObject && !TargetObject.Dead && TargetObject.gameObject.activeSelf && CanAttack()) { Point self = new Point(User.Player.CurrentLocation.x, User.Player.CurrentLocation.y); Point targ = new Point(TargetObject.CurrentLocation.x, TargetObject.CurrentLocation.y); if (Functions.InRange(self, targ, 1)) { NextHitTime = Time.time + 1.6f; MirDirection direction = Functions.DirectionFromPoint(self, targ); QueuedAction = new QueuedAction { Action = MirAction.Attack, Direction = direction, Location = User.Player.CurrentLocation }; return; } MirDirection targetdirection = Functions.DirectionFromPoint(self, targ); if (!CanWalk(targetdirection)) { return; } QueuedAction = new QueuedAction { Action = MirAction.Walking, Direction = targetdirection, Location = ClientFunctions.VectorMove(User.Player.CurrentLocation, targetdirection, 1) }; } } }
protected override void ReadPacket(BinaryReader reader) { ObjectID = reader.ReadUInt32(); Name = reader.ReadString(); NameColour = Color.FromArgb(reader.ReadInt32()); Location = new Point(reader.ReadInt32(), reader.ReadInt32()); Image = (Monster)reader.ReadUInt16(); Direction = (MirDirection)reader.ReadByte(); Effect = reader.ReadByte(); AI = reader.ReadByte(); Light = reader.ReadByte(); Dead = reader.ReadBoolean(); Skeleton = reader.ReadBoolean(); Poison = (PoisonType)reader.ReadByte(); Hidden = reader.ReadBoolean(); ShockTime = reader.ReadInt64(); BindingShotCenter = reader.ReadBoolean(); Extra = reader.ReadBoolean(); ExtraByte = reader.ReadByte(); }
private bool CanWalk(MirDirection dir) { Vector2 newpoint = ClientFunctions.VectorMove(User.Player.CurrentLocation, dir, 1); return(GameManager.CurrentScene.Cells[(int)newpoint.x, (int)newpoint.y].walkable && GameManager.CurrentScene.Cells[(int)newpoint.x, (int)newpoint.y].CellObjects == null); }
protected override void ReadPacket(BinaryReader reader) { FileName = reader.ReadString(); Title = reader.ReadString(); MiniMap = reader.ReadUInt16(); BigMap = reader.ReadUInt16(); Lights = (LightSetting)reader.ReadByte(); Location = new Point(reader.ReadInt32(), reader.ReadInt32()); Direction = (MirDirection)reader.ReadByte(); MapDarkLight = reader.ReadByte(); Music = reader.ReadUInt16(); }
protected override void ProcessSearch() { if (Envir.Time < SearchTime) { return; } SearchTime = Envir.Time + SearchDelay; //Stacking or Infront of master - Move bool stacking = false; Cell cell = CurrentMap.GetCell(CurrentLocation); if (cell.Objects != null) { for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (ob == this || !ob.Blocking) { continue; } stacking = true; break; } } if (CanMove && stacking) { //Walk Randomly if (!Walk(Direction)) { MirDirection dir = Direction; switch (Envir.Random.Next(3)) // favour Clockwise { case 0: for (int i = 0; i < 7; i++) { dir = Functions.NextDir(dir); if (Walk(dir)) { break; } } break; default: for (int i = 0; i < 7; i++) { dir = Functions.PreviousDir(dir); if (Walk(dir)) { break; } } break; } } } if (Target == null || Envir.Random.Next(3) == 0) { FindTarget(); } }
public bool CreatureSummoned;//IntelligentCreature protected override void ReadPacket(BinaryReader reader) { ObjectID = reader.ReadUInt32(); RealId = reader.ReadUInt32(); Name = reader.ReadString(); GuildName = reader.ReadString(); GuildRank = reader.ReadString(); NameColour = Color.FromArgb(reader.ReadInt32()); Class = (MirClass)reader.ReadByte(); Gender = (MirGender)reader.ReadByte(); Level = reader.ReadByte(); Location = new Point(reader.ReadInt32(), reader.ReadInt32()); Direction = (MirDirection)reader.ReadByte(); Hair = reader.ReadByte(); HP = reader.ReadUInt16(); MP = reader.ReadUInt16(); Experience = reader.ReadInt64(); MaxExperience = reader.ReadInt64(); LevelEffects = (LevelEffects)reader.ReadByte(); if (reader.ReadBoolean()) { Inventory = new UserItem[reader.ReadInt32()]; for (int i = 0; i < Inventory.Length; i++) { if (!reader.ReadBoolean()) continue; Inventory[i] = new UserItem(reader); } } if (reader.ReadBoolean()) { Equipment = new UserItem[reader.ReadInt32()]; for (int i = 0; i < Equipment.Length; i++) { if (!reader.ReadBoolean()) continue; Equipment[i] = new UserItem(reader); } } if (reader.ReadBoolean()) { QuestInventory = new UserItem[reader.ReadInt32()]; for (int i = 0; i < QuestInventory.Length; i++) { if (!reader.ReadBoolean()) continue; QuestInventory[i] = new UserItem(reader); } } Gold = reader.ReadUInt32(); int count = reader.ReadInt32(); for (int i = 0; i < count; i++) Magics.Add(new ClientMagic(reader)); //IntelligentCreature count = reader.ReadInt32(); for (int i = 0; i < count; i++) IntelligentCreatures.Add(new ClientIntelligentCreature(reader)); SummonedCreatureType = (IntelligentCreatureType)reader.ReadByte(); CreatureSummoned = reader.ReadBoolean(); }
public override bool Walk(MirDirection dir) { if (!CanMove) { return(false); } Point location = Functions.PointMove(CurrentLocation, dir, 2); if (!CurrentMap.ValidPoint(location)) { return(false); } Cell cell = CurrentMap.GetCell(location); bool isBreak = false; if (cell.Objects != null) { for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (!ob.Blocking) { continue; } isBreak = true; break; } } if (isBreak) { location = Functions.PointMove(CurrentLocation, dir, 1); if (!CurrentMap.ValidPoint(location)) { return(false); } cell = CurrentMap.GetCell(location); if (cell.Objects != null) { for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (!ob.Blocking) { continue; } return(false); } } } CurrentMap.GetCell(CurrentLocation).Remove(this); Direction = dir; RemoveObjects(dir, 1); CurrentLocation = location; CurrentMap.GetCell(CurrentLocation).Add(this); AddObjects(dir, 1); if (Hidden) { RemoveBuff(BuffType.Hiding); } CellTime = Envir.Time + 500; ActionTime = Envir.Time + 300; MoveTime = Envir.Time + MoveSpeed; if (MoveTime > AttackTime) { AttackTime = MoveTime; } InSafeZone = CurrentMap.GetSafeZone(CurrentLocation) != null; if (isBreak) { Broadcast(new S.ObjectWalk { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); } else { Broadcast(new S.ObjectRun { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); } cell = CurrentMap.GetCell(CurrentLocation); for (int i = 0; i < cell.Objects.Count; i++) { if (cell.Objects[i].Race != ObjectType.Spell) { continue; } SpellObject ob = (SpellObject)cell.Objects[i]; ob.ProcessSpell(this); //break; } return(true); }
protected override void ReadPacket(BinaryReader reader) { ObjectID = reader.ReadUInt32(); Location = new Point(reader.ReadInt32(), reader.ReadInt32()); Direction = (MirDirection)reader.ReadByte(); }
private bool CanWalk(MirDirection dir) { return EmptyCell(Functions.PointMove(User.CurrentLocation, dir, 1)) && !User.InTrapRock; }
public CharacterInfo(BinaryReader reader) { Index = reader.ReadInt32(); Name = reader.ReadString(); Level = reader.ReadByte(); Class = (MirClass) reader.ReadByte(); Gender = (MirGender) reader.ReadByte(); Hair = reader.ReadByte(); CreationIP = reader.ReadString(); CreationDate = DateTime.FromBinary(reader.ReadInt64()); Banned = reader.ReadBoolean(); BanReason = reader.ReadString(); ExpiryDate = DateTime.FromBinary(reader.ReadInt64()); LastIP = reader.ReadString(); LastDate = DateTime.FromBinary(reader.ReadInt64()); Deleted = reader.ReadBoolean(); DeleteDate = DateTime.FromBinary(reader.ReadInt64()); CurrentMapIndex = reader.ReadInt32(); CurrentLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); Direction = (MirDirection)reader.ReadByte(); BindMapIndex = reader.ReadInt32(); BindLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); HP = reader.ReadUInt16(); MP = reader.ReadUInt16(); Experience = reader.ReadInt64(); AMode = (AttackMode) reader.ReadByte(); PMode = (PetMode) reader.ReadByte(); if (Envir.LoadVersion > 34) { PKPoints = reader.ReadInt32(); } int count = reader.ReadInt32(); Array.Resize(ref Inventory, count); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) continue; UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); if (SMain.Envir.BindItem(item) && i < Inventory.Length) Inventory[i] = item; } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) continue; UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); if (SMain.Envir.BindItem(item) && i < Equipment.Length) Equipment[i] = item; } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) continue; UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); if (SMain.Envir.BindItem(item) && i < QuestInventory.Length) QuestInventory[i] = item; } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { UserMagic magic = new UserMagic(reader); if (magic.Info == null) continue; Magics.Add(magic); } if (Envir.LoadVersion < 2) return; Thrusting = reader.ReadBoolean(); HalfMoon = reader.ReadBoolean(); CrossHalfMoon = reader.ReadBoolean(); DoubleSlash = reader.ReadBoolean(); if(Envir.LoadVersion > 46) { MentalState = reader.ReadByte(); } if (Envir.LoadVersion < 4) return; count = reader.ReadInt32(); for (int i = 0; i < count; i++) Pets.Add(new PetInfo(reader)); if (Envir.LoadVersion < 5) return; AllowGroup = reader.ReadBoolean(); if (Envir.LoadVersion < 12) return; if (Envir.LoadVersion == 12) count = reader.ReadInt32(); for (int i = 0; i < Globals.FlagIndexCount; i++) Flags[i] = reader.ReadBoolean(); if (Envir.LoadVersion > 27) GuildIndex = reader.ReadInt32(); if (Envir.LoadVersion > 30) AllowTrade = reader.ReadBoolean(); if (Envir.LoadVersion > 33) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { QuestProgressInfo quest = new QuestProgressInfo(reader); if (SMain.Envir.BindQuest(quest)) CurrentQuests.Add(quest); } } if(Envir.LoadVersion > 42) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Buff buff = new Buff(reader); if (Envir.LoadVersion == 51) { buff.Caster = SMain.Envir.GetObject(reader.ReadUInt32()); } Buffs.Add(buff); } } if(Envir.LoadVersion > 43) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) Mail.Add(new MailInfo(reader, Envir.LoadVersion, Envir.LoadCustomVersion)); } //IntelligentCreature if (Envir.LoadVersion > 44) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { UserIntelligentCreature creature = new UserIntelligentCreature(reader); if (creature.Info == null) continue; IntelligentCreatures.Add(creature); } if (Envir.LoadVersion == 45) { var old1 = (IntelligentCreatureType)reader.ReadByte(); var old2 = reader.ReadBoolean(); } PearlCount = reader.ReadInt32(); } if (Envir.LoadVersion > 49) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) CompletedQuests.Add(reader.ReadInt32()); } if (Envir.LoadVersion > 50 && Envir.LoadVersion < 54) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Poison poison = new Poison(reader); if (Envir.LoadVersion == 51) { poison.Owner = SMain.Envir.GetObject(reader.ReadUInt32()); } Poisons.Add(poison); } } if (Envir.LoadVersion > 56) { if (reader.ReadBoolean()) CurrentRefine = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); if (CurrentRefine != null) SMain.Envir.BindItem(CurrentRefine); CollectTime = reader.ReadInt64(); CollectTime += SMain.Envir.Time; } if (Envir.LoadVersion > 58) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) Friends.Add(new FriendInfo(reader)); } if (Envir.LoadVersion > 59) { Married = reader.ReadInt32(); MarriedDate = DateTime.FromBinary(reader.ReadInt64()); Mentor = reader.ReadInt32(); MentorDate = DateTime.FromBinary(reader.ReadInt64()); isMentor = reader.ReadBoolean(); MentorExp = reader.ReadInt64(); } }
public bool CanFish(MirDirection dir) { if (!GameScene.User.HasFishingRod || GameScene.User.FishingTime + 1000 > CMain.Time) return false; if (GameScene.User.CurrentAction != MirAction.Standing) return false; if (GameScene.User.Direction != dir) return false; if (GameScene.User.TransformType >= 6 && GameScene.User.TransformType <= 9) return false; Point point = Functions.PointMove(User.CurrentLocation, dir, 3); if (!M2CellInfo[point.X, point.Y].FishingCell) return false; return true; }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); if (Envir.Random.Next(3) > 0) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); } else { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); MirDirection dir = Functions.PreviousDir(Direction); Point target; Cell cell; for (int i = 0; i < 4; i++) { target = Functions.PointMove(CurrentLocation, Direction, 1); dir = Functions.NextDir(Direction); 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, MinDC, DefenceType.ACAgility); DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 350, Target, MinDC, DefenceType.ACAgility); ActionList.Add(action); if (Envir.Random.Next(Settings.PoisonResistWeight) >= ob.PoisonResist) { if (Envir.Random.Next(5) == 0) { ob.ApplyPoison(new Poison { PType = PoisonType.Stun, Duration = Envir.Random.Next(1, 4), TickSpeed = 1000 }, this); } } break; } } } ShockTime = 0; ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(MinDC, MaxDC); if (damage == 0) { return; } Target.Attacked(this, damage, DefenceType.ACAgility); }
public CharacterInfo(BinaryReader reader) { Index = reader.ReadInt32(); Name = reader.ReadString(); Level = reader.ReadByte(); Class = (MirClass)reader.ReadByte(); Gender = (MirGender)reader.ReadByte(); Hair = reader.ReadByte(); CreationIP = reader.ReadString(); CreationDate = DateTime.FromBinary(reader.ReadInt64()); Banned = reader.ReadBoolean(); BanReason = reader.ReadString(); ExpiryDate = DateTime.FromBinary(reader.ReadInt64()); LastIP = reader.ReadString(); LastDate = DateTime.FromBinary(reader.ReadInt64()); Deleted = reader.ReadBoolean(); DeleteDate = DateTime.FromBinary(reader.ReadInt64()); CurrentMapIndex = reader.ReadInt32(); CurrentLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); Direction = (MirDirection)reader.ReadByte(); BindMapIndex = reader.ReadInt32(); BindLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); HP = reader.ReadUInt16(); MP = reader.ReadUInt16(); Experience = reader.ReadInt64(); AMode = (AttackMode)reader.ReadByte(); PMode = (PetMode)reader.ReadByte(); if (Envir.LoadVersion > 34) { PKPoints = reader.ReadInt32(); } int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion); if (SMain.Envir.BindItem(item) && i < Inventory.Length) { Inventory[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion); if (SMain.Envir.BindItem(item) && i < Equipment.Length) { Equipment[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion); if (SMain.Envir.BindItem(item) && i < QuestInventory.Length) { QuestInventory[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { UserMagic magic = new UserMagic(reader); if (magic.Info == null) { continue; } Magics.Add(magic); } if (Envir.LoadVersion < 2) { return; } Thrusting = reader.ReadBoolean(); HalfMoon = reader.ReadBoolean(); CrossHalfMoon = reader.ReadBoolean(); DoubleSlash = reader.ReadBoolean(); if (Envir.LoadVersion < 4) { return; } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Pets.Add(new PetInfo(reader)); } if (Envir.LoadVersion < 5) { return; } AllowGroup = reader.ReadBoolean(); if (Envir.LoadVersion < 12) { return; } if (Envir.LoadVersion == 12) { count = reader.ReadInt32(); } for (int i = 0; i < Globals.FlagIndexCount; i++) { Flags[i] = reader.ReadBoolean(); } if (Envir.LoadVersion > 27) { GuildIndex = reader.ReadInt32(); } if (Envir.LoadVersion > 30) { AllowTrade = reader.ReadBoolean(); } if (Envir.LoadVersion > 33) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { CurrentQuests.Add(new QuestProgressInfo(reader)); } } if (Envir.LoadVersion > 42) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Buffs.Add(new Buff(reader)); } } if (Envir.LoadVersion > 43) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Mail.Add(new MailInfo(reader)); } } }
private bool CanRun(MirDirection dir) { if (User.InTrapRock) return false; if (User.CurrentBagWeight > User.MaxBagWeight) return false; if (CanWalk(dir) && EmptyCell(Functions.PointMove(User.CurrentLocation, dir, 2))) { if (User.RidingMount || User.Sprint && !User.Sneaking) { return EmptyCell(Functions.PointMove(User.CurrentLocation, dir, 3)); } return true; } return false; }
public bool CanHalfMoon(Point p, MirDirection d) { d = Functions.PreviousDir(d); for (int i = 0; i < 4; i++) { if (HasTarget(Functions.PointMove(p, d, 1))) return true; d = Functions.NextDir(d); } return false; }
public override bool Walk(MirDirection dir) { return(!Sitting && base.Walk(dir)); }
public override bool Walk(MirDirection dir) { return false; }
public override bool Walk(MirDirection dir) { return(Visible && base.Walk(dir)); }
public override int Pushed(MapObject pusher, MirDirection dir, int distance) { if (!Info.CanPush) return 0; //if (!CanMove) return 0; //stops mobs that can't move (like cannibalplants) from being pushed int result = 0; MirDirection reverse = Functions.ReverseDirection(dir); for (int i = 0; i < distance; i++) { Point location = Functions.PointMove(CurrentLocation, dir, 1); if (!CurrentMap.ValidPoint(location)) return result; Cell cell = CurrentMap.GetCell(location); bool stop = false; if (cell.Objects != null) for (int c = 0; c < cell.Objects.Count; c++) { MapObject ob = cell.Objects[c]; if (!ob.Blocking) continue; stop = true; } if (stop) break; CurrentMap.GetCell(CurrentLocation).Remove(this); Direction = reverse; RemoveObjects(dir, 1); CurrentLocation = location; CurrentMap.GetCell(CurrentLocation).Add(this); AddObjects(dir, 1); Broadcast(new S.ObjectPushed { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); result++; } ActionTime = Envir.Time + 300 * result; MoveTime = Envir.Time + 500 * result; if (result > 0) { Cell cell = CurrentMap.GetCell(CurrentLocation); for (int i = 0; i < cell.Objects.Count; i++) { if (cell.Objects[i].Race != ObjectType.Spell) continue; SpellObject ob = (SpellObject)cell.Objects[i]; ob.ProcessSpell(this); break; } } return result; }
public virtual bool Walk(MirDirection dir) { if (!CanMove) return false; Point location = Functions.PointMove(CurrentLocation, dir, 1); if (!CurrentMap.ValidPoint(location)) return false; Cell cell = CurrentMap.GetCell(location); if (cell.Objects != null) for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; if (!ob.Blocking) continue; return false; } CurrentMap.GetCell(CurrentLocation).Remove(this); Direction = dir; RemoveObjects(dir, 1); CurrentLocation = location; CurrentMap.GetCell(CurrentLocation).Add(this); AddObjects(dir, 1); if (Hidden) { Hidden = false; for (int i = 0; i < Buffs.Count; i++) { if (Buffs[i].Type != BuffType.Hiding) continue; Buffs[i].ExpireTime = 0; break; } } CellTime = Envir.Time + 500; ActionTime = Envir.Time + 300; MoveTime = Envir.Time + MoveSpeed; if (MoveTime > AttackTime) AttackTime = MoveTime; InSafeZone = CurrentMap.GetSafeZone(CurrentLocation) != null; Broadcast(new S.ObjectWalk { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); cell = CurrentMap.GetCell(CurrentLocation); for (int i = 0; i < cell.Objects.Count; i++) { if (cell.Objects[i].Race != ObjectType.Spell) continue; SpellObject ob = (SpellObject)cell.Objects[i]; ob.ProcessSpell(this); break; } return true; }
public override bool Walk(MirDirection dir) { return(false); }
public static bool FacingEachOther(MirDirection dirA, Point pointA, MirDirection dirB, Point pointB) { if (dirA == DirectionFromPoint(pointA, pointB) && dirB == DirectionFromPoint(pointB, pointA)) { return true; } return false; }
protected override void ProcessTarget() { if (Target == null || !CanAttack) { return; } if (InAttackRange() && (Envir.Time < FearTime)) { Attack(); return; } FearTime = Envir.Time + 5000; if (Envir.Time < ShockTime) { Target = null; return; } int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation); if (dist >= AttackRange) { MoveTo(Target.CurrentLocation); } else { MirDirection dir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation); if (Walk(dir)) { return; } switch (Envir.Random.Next(2)) //No favour { case 0: for (int i = 0; i < 7; i++) { dir = Functions.NextDir(dir); if (Walk(dir)) { return; } } break; default: for (int i = 0; i < 7; i++) { dir = Functions.PreviousDir(dir); if (Walk(dir)) { return; } } break; } } }
public static Point PointMove(Point p, MirDirection d, int i) { switch (d) { case MirDirection.Up: p.Offset(0, -i); break; case MirDirection.UpRight: p.Offset(i, -i); break; case MirDirection.Right: p.Offset(i, 0); break; case MirDirection.DownRight: p.Offset(i, i); break; case MirDirection.Down: p.Offset(0, i); break; case MirDirection.DownLeft: p.Offset(-i, i); break; case MirDirection.Left: p.Offset(-i, 0); break; case MirDirection.UpLeft: p.Offset(-i, -i); break; } return p; }
public static MirDirection ReverseDirection(MirDirection dir) { switch (dir) { case MirDirection.Up: return MirDirection.Down; case MirDirection.UpRight: return MirDirection.DownLeft; case MirDirection.Right: return MirDirection.Left; case MirDirection.DownRight: return MirDirection.UpLeft; case MirDirection.Down: return MirDirection.Up; case MirDirection.DownLeft: return MirDirection.UpRight; case MirDirection.Left: return MirDirection.Right; case MirDirection.UpLeft: return MirDirection.DownRight; default: return dir; } }
public static Vector2Int Back(Vector2Int p, MirDirection direction, int i) { MirDirection backdirection = (MirDirection)(((int)direction + 4) % 8); return(VectorMove(p, backdirection, i)); }