Esempio n. 1
0
        public override bool TeleportRandom(int attempts, int distance, Map temp = null)
        {
            if (Target == null) return false;

            for (int i = 0; i < attempts; i++)
            {
                Point location;

                location = new Point(Target.CurrentLocation.X + Envir.Random.Next(-distance, distance + 1),
                                          Target.CurrentLocation.Y + Envir.Random.Next(-distance, distance + 1));

                if (Teleport(CurrentMap, location, true, 5)) return true;
            }

            return false;
        }
Esempio n. 2
0
        public override bool TeleportRandom(int attempts, int distance, Map temp = null)
        {
            for (int i = 0; i < attempts; i++)
            {
                Point location;

                if (distance <= 0)
                    location = new Point(Envir.Random.Next(CurrentMap.Width), Envir.Random.Next(CurrentMap.Height));
                else
                    location = new Point(CurrentLocation.X + Envir.Random.Next(-distance, distance + 1),
                                         CurrentLocation.Y + Envir.Random.Next(-distance, distance + 1));

                if (Teleport(CurrentMap, location, true, 1)) return true;
            }

            return false;
        }
Esempio n. 3
0
        public Point GetRandomPoint(int attempts, int distance, Map map)
        {
            byte edgeoffset = 0;

            if (map.Width < 150)
            {
                if (map.Height < 30) edgeoffset = 2;
                else edgeoffset = 20;
            }

            for (int i = 0; i < attempts; i++)
            {
                Point location;

                if (distance <= 0)
                    location = new Point(edgeoffset + Envir.Random.Next(map.Width - edgeoffset), edgeoffset + Envir.Random.Next(map.Height - edgeoffset)); //Can adjust Random Range...
                else
                    location = new Point(CurrentLocation.X + Envir.Random.Next(-distance, distance + 1),
                                         CurrentLocation.Y + Envir.Random.Next(-distance, distance + 1));

                if (map.ValidPoint(location)) return location;
            }

            return new Point(0, 0);
        }
Esempio n. 4
0
        public virtual bool TeleportRandom(int attempts, int distance, Map map = null)
        {
            if (map == null) map = CurrentMap;
            byte edgeoffset = 0;

            if (map.Width < 150)
            {
                if (map.Height < 30) edgeoffset = 2;
                else edgeoffset = 20;
            }
            else edgeoffset = 50;

            for (int i = 0; i < attempts; i++)
            {
                Point location;

                if (distance <= 0)
                    location = new Point(edgeoffset + Envir.Random.Next(map.Width - edgeoffset), edgeoffset + Envir.Random.Next(map.Height - edgeoffset)); //Can adjust Random Range...
                else
                    location = new Point(CurrentLocation.X + Envir.Random.Next(-distance, distance + 1),
                                         CurrentLocation.Y + Envir.Random.Next(-distance, distance + 1));

                if (Teleport(map, location)) return true;
            }

            return false;
        }
Esempio n. 5
0
        public void CreateMap()
        {
            for (int j = 0; j < SMain.Envir.NPCInfoList.Count; j++)
            {
                if (SMain.Envir.NPCInfoList[j].MapIndex != Index) continue;

                NPCs.Add(SMain.Envir.NPCInfoList[j]);
            }

            Map map = new Map(this);
            if (!map.Load()) return;

            SMain.Envir.MapList.Add(map);

            for (int i = 0; i < SafeZones.Count; i++)
                if (SafeZones[i].StartPoint)
                    SMain.Envir.StartPoints.Add(SafeZones[i]);
        }
Esempio n. 6
0
        public override bool Teleport(Map temp, Point location, bool effects = true, byte effectnumber = 0)
        {
            Map oldMap = CurrentMap;
            Point oldLocation = CurrentLocation;

            bool mapChanged = temp != oldMap;

            if (!base.Teleport(temp, location, effects)) return false;

            Enqueue(new S.MapChanged
            {
                FileName = CurrentMap.Info.FileName,
                Title = CurrentMap.Info.Title,
                MiniMap = CurrentMap.Info.MiniMap,
                BigMap = CurrentMap.Info.BigMap,
                Lights = CurrentMap.Info.Light,
                Location = CurrentLocation,
                Direction = Direction,
                MapDarkLight = CurrentMap.Info.MapDarkLight,
                Music = CurrentMap.Info.Music
            });

            if (effects) Enqueue(new S.TeleportIn());

            if (TradePartner != null) TradeCancel();

            if (RidingMount) RefreshMount();

            GetObjectsPassive();

            SafeZoneInfo szi = CurrentMap.GetSafeZone(CurrentLocation);

            if (szi != null)
            {
                BindLocation = szi.Location;
                BindMapIndex = CurrentMapIndex;
                InSafeZone = true;
            }
            else
                InSafeZone = false;

            CheckConquest();

            Fishing = false;
            Enqueue(GetFishInfo());

            if (mapChanged)
            {
                CallDefaultNPC(DefaultNPCType.MapEnter, CurrentMap.Info.FileName);

                if (Info.Married != 0)
                {
                    CharacterInfo Lover = Envir.GetCharacterInfo(Info.Married);
                    PlayerObject player = Envir.GetPlayer(Lover.Name);

                    if (player != null) player.GetRelationship(false);
                }
            }

            if (CheckStacked())
            {
                StackingTime = Envir.Time + 1000;
                Stacking = true;
            }

            Report.MapChange("Teleported", oldMap.Info, CurrentMap.Info);

            return true;
        }
Esempio n. 7
0
        public bool CheckMovement(Point location)
        {
            if (Envir.Time < MovementTime) return false;

            //Script triggered coords
            for (int s = 0; s < CurrentMap.Info.ActiveCoords.Count; s++)
            {
                Point activeCoord = CurrentMap.Info.ActiveCoords[s];

                if (activeCoord != location) continue;

                CallDefaultNPC(DefaultNPCType.MapCoord, CurrentMap.Info.FileName, activeCoord.X, activeCoord.Y);
            }

            //Map movements
            for (int i = 0; i < CurrentMap.Info.Movements.Count; i++)
            {
                MovementInfo info = CurrentMap.Info.Movements[i];

                if (info.Source != location) continue;

                if (info.NeedHole)
                {
                    Cell cell = CurrentMap.GetCell(location);

                    if (cell.Objects == null ||
                        cell.Objects.Where(ob => ob.Race == ObjectType.Spell).All(ob => ((SpellObject)ob).Spell != Spell.DigOutZombie))
                        continue;
                }

                if (info.ConquestIndex > 0)
                {
                    if (MyGuild == null || MyGuild.Conquest == null) continue;
                    if (MyGuild.Conquest.Info.Index != info.ConquestIndex) continue;
                }

                if (info.NeedMove) //use with ENTERMAP npc command
                {
                    NPCMoveMap = Envir.GetMap(info.MapIndex);
                    NPCMoveCoord = info.Destination;
                    continue;
                }

                Map temp = Envir.GetMap(info.MapIndex);

                if (temp == null || !temp.ValidPoint(info.Destination)) continue;

                CurrentMap.RemoveObject(this);
                Broadcast(new S.ObjectRemove { ObjectID = ObjectID });

                CompleteMapMovement(temp, info.Destination, CurrentMap, CurrentLocation);
                return true;
            }

            return false;
        }
Esempio n. 8
0
        public void CreateInstance()
        {
            if (Instance.MapList.Count == 0) return;

            Map map = new Map(this);
            if (!map.Load()) return;

            SMain.Envir.MapList.Add(map);

            Instance.AddMap(map);
        }
Esempio n. 9
0
        public void CreateMap()
        {
            Map map = new Map(this);
            if (!map.Load()) return;

            SMain.Envir.MapList.Add(map);

            for (int i = 0; i < SafeZones.Count; i++)
                if (SafeZones[i].StartPoint)
                    SMain.Envir.StartPoints.Add(SafeZones[i]);
        }
Esempio n. 10
0
        public override bool Teleport(Map temp, Point location, bool effects = true, byte effectnumber = 0)
        {
            if (!base.Teleport(temp, location, effects)) return false;

            Enqueue(new S.MapChanged
            {
                FileName = CurrentMap.Info.FileName,
                Title = CurrentMap.Info.Title,
                MiniMap = CurrentMap.Info.MiniMap,
                BigMap = CurrentMap.Info.BigMap,
                Lights = CurrentMap.Info.Light,
                Location = CurrentLocation,
                Direction = Direction,
                MapDarkLight = CurrentMap.Info.MapDarkLight
            });

            if (effects) Enqueue(new S.TeleportIn());

            GetObjectsPassive();

            SafeZoneInfo szi = CurrentMap.GetSafeZone(CurrentLocation);

            if (szi != null)
            {
                BindLocation = szi.Location;
                BindMapIndex = CurrentMapIndex;
                InSafeZone = true;
            }
            else
                InSafeZone = false;

            return true;
        }
Esempio n. 11
0
        public override bool Teleport(Map temp, Point location, bool effects = true, byte effectnumber = 0)
        {
            Map oldMap = CurrentMap;

            bool mapChanged = temp != oldMap;

            if (!base.Teleport(temp, location, effects)) return false;

            Enqueue(new S.MapChanged
            {
                FileName = CurrentMap.Info.FileName,
                Title = CurrentMap.Info.Title,
                MiniMap = CurrentMap.Info.MiniMap,
                BigMap = CurrentMap.Info.BigMap,
                Lights = CurrentMap.Info.Light,
                Location = CurrentLocation,
                Direction = Direction,
                MapDarkLight = CurrentMap.Info.MapDarkLight,
                Music = CurrentMap.Info.Music
            });

            if (effects) Enqueue(new S.TeleportIn());

            if (TradePartner != null) TradeCancel();

            if (RidingMount) RefreshMount();

            GetObjectsPassive();

            SafeZoneInfo szi = CurrentMap.GetSafeZone(CurrentLocation);

            if (szi != null)
            {
                BindLocation = szi.Location;
                BindMapIndex = CurrentMapIndex;
                InSafeZone = true;
            }
            else
                InSafeZone = false;

            Fishing = false;
            Enqueue(GetFishInfo());

            if (mapChanged)
            {
                CallDefaultNPC(DefaultNPCType.MapEnter, CurrentMap.Info.FileName);
            }

            Report.MapChange("Teleported", oldMap.Info, CurrentMap.Info);

            return true;
        }
Esempio n. 12
0
        public bool Spawn(Map temp, Point location)
        {
            if (!temp.ValidPoint(location)) return false;
            if (uniqueAI != null && uniqueAI.UseKillTimer)
            {
                DateTime timeKilled = new DateTime(uniqueAI.LastKillYear, uniqueAI.LastKillMonth, uniqueAI.LastKillDay, uniqueAI.LastKillHour, uniqueAI.LastKillMinute, 0, 0);
                DateTime timeNow = DateTime.Now;
                if (timeNow.CompareTo(timeKilled) < 0)
                    return false;
            }

            CurrentMap = temp;
            CurrentLocation = location;

            CurrentMap.AddObject(this);

            RefreshAll();
            SetHP(MaxHP);

            Spawned();
            Envir.MonsterCount++;
            CurrentMap.MonsterCount++;
            return true;
        }
Esempio n. 13
0
 public void RemoveMap(Map map)
 {
     MapList.Remove(map);
 }
Esempio n. 14
0
 public void AddMap(Map map)
 {
     MapList.Add(map);
 }
Esempio n. 15
0
        /*
         Notes
         Create new instance from here if all current maps are full
         Destroy maps when instance is empty - process loop in map or here?
         Change NPC INSTANCEMOVE to move and create next available instance

        */
        public InstanceInfo(MapInfo mapInfo, Map map)
        {
            MapInfo = mapInfo;
            AddMap(map);
        }
Esempio n. 16
0
        public virtual bool Teleport(Map temp, Point location, bool effects = true, byte effectnumber = 0)
        {
            if (temp == null || !temp.ValidPoint(location)) return false;

            CurrentMap.RemoveObject(this);
            if (effects) Broadcast(new S.ObjectTeleportOut {ObjectID = ObjectID, Type = effectnumber});
            Broadcast(new S.ObjectRemove {ObjectID = ObjectID});

            CurrentMap = temp;
            CurrentLocation = location;

            InTrapRock = false;

            CurrentMap.AddObject(this);
            BroadcastInfo();

            if (effects) Broadcast(new S.ObjectTeleportIn { ObjectID = ObjectID, Type = effectnumber });

            BroadcastHealthChange();

            return true;
        }
Esempio n. 17
0
        public virtual bool TeleportRandom(int attempts, int distance, Map map = null)
        {
            if (map == null) map = CurrentMap;
            if (map.Cells == null) return false;

            var walkableCells = new List<Point>();
            for (var x = 0; x < map.Cells.GetLength(0); x++)
                for (var y = 0; y < map.Cells.GetLength(1); y++)
                    if (map.Cells[x, y] != null && map.Cells[x, y].Attribute == CellAttribute.Walk)
                        walkableCells.Add(new Point(x, y));

            if (!walkableCells.Any()) return false;

            var randomCell = Envir.Random.Next(0, walkableCells.Count - 1);

            return Teleport(map, new Point(walkableCells[randomCell].X, walkableCells[randomCell].Y));
        }
Esempio n. 18
0
        public void LoadNPCs()
        {
            for (int i = 0; i < ConquestMap.NPCs.Count; i++)
                if (ConquestMap.NPCs[i].Info.Conquest == Info.Index)
                {
                    ConquestMap.NPCs[i].Conq = this;
                    ConquestNPCs.Add(ConquestMap.NPCs[i]);
                }

            PalaceMap = Envir.GetMap(Info.PalaceIndex);

            if (PalaceMap != null)
            {
                for (int i = 0; i < PalaceMap.NPCs.Count; i++)
                    if (PalaceMap.NPCs[i].Info.Conquest == Info.Index)
                    {
                        PalaceMap.NPCs[i].Conq = this;
                        ConquestNPCs.Add(ConquestMap.NPCs[i]);
                    }

            }

            Map temp;
            for (int i = 0; i < Info.ExtraMaps.Count; i++)
            {
                temp = Envir.GetMap(Info.ExtraMaps[i]);
                if (temp == null) continue;
                for (int j = 0; j < temp.NPCs.Count; j++)
                    if (temp.NPCs[j].Info.Conquest == Info.Index)
                    {
                        temp.NPCs[j].Conq = this;
                        ConquestNPCs.Add(temp.NPCs[j]);
                    }

            }
        }
Esempio n. 19
0
        public bool Spawn(Map temp, Point location)
        {
            if (!temp.ValidPoint(location)) return false;

            CurrentMap = temp;
            CurrentLocation = location;

            CurrentMap.AddObject(this);

            RefreshAll();
            SetHP(MaxHP);

            Spawned();
            Envir.MonsterCount++;
            CurrentMap.MonsterCount++;
            return true;
        }
Esempio n. 20
0
        private void NPCVisibility(bool Show = true)
        {
            //Check if Players in Conquest Zone;
            for (int j = 0; j < ConquestMap.Players.Count; j++)
                ConquestMap.Players[j].CheckConquest();

            PalaceMap = Envir.GetMap(Info.PalaceIndex);
            if (PalaceMap != null)
            {
                if (Show)
                    PalaceMap.tempConquest = this;
                else
                    PalaceMap.tempConquest = null;

                for (int j = 0; j < PalaceMap.Players.Count; j++)
                    PalaceMap.Players[j].CheckConquest();
            }

            Map temp;
            for (int i = 0; i < Info.ExtraMaps.Count; i++)
            {
                temp = Envir.GetMap(Info.ExtraMaps[i]);
                if (temp == null) continue;

                if (Show)
                    temp.tempConquest = this;
                else
                    temp.tempConquest = null;

                for (int k = 0; k < temp.Players.Count; k++)
                    temp.Players[k].CheckConquest();
            }

            //Set NPCs to invisible
            Map npcMap;
            NPCObject npcTemp;

            for (int i = 0; i < ConquestNPCs.Count; i++)
            {
                npcMap = ConquestNPCs[i].CurrentMap;
                npcTemp = ConquestNPCs[i];
                for (int j = 0; j < npcMap.Players.Count; j++)
                {
                    if (Functions.InRange(npcTemp.CurrentLocation, npcMap.Players[j].CurrentLocation, Globals.DataRange))
                        npcTemp.CheckVisible(npcMap.Players[j]);
                }

            }
        }