Ejemplo n.º 1
0
        public void GenZone()
        {
            ZoneTemplate template = new ZoneTemplate
            {
                Name = $"hideout #{ID}",
                Type = ZoneTemplate.ZoneType.Hideout
            };

            template.SetRange(zoneLoc);

            zone = new hideout_zone
            {
                hideout   = this,
                Name      = template.Name,
                Template  = template,
                Territory = new ZoneNPoly(template.X, template.Y, template.Z1, template.Z2)
            };

            for (int i = 0; i < template.X.Length; i++)
            {
                L2WorldRegion region = L2World.Instance.GetRegion(template.X[i], template.Y[i]);
                if (region != null)
                {
                    // region._zoneManager.addZone(zone);
                }
                else
                {
                    log.Error($"AreaTable[hideout]: null region at {template.X[i]} {template.Y[i]} for zone {zone.Name}");
                }
            }
        }
Ejemplo n.º 2
0
        public void GenZone()
        {
            zone         = new hideout_zone();
            zone.hideout = this;
            ZoneTemplate template = new ZoneTemplate();

            template.Name = "hideout #" + ID;
            template.Type = ZoneTemplate.ZoneType.hideout;
            template.setRange(zoneLoc);

            zone.Name      = template.Name;
            zone.Template  = template;
            zone.Territory = new ZoneNPoly(template._x, template._y, template._z1, template._z2);

            for (int i = 0; i < template._x.Length; i++)
            {
                L2WorldRegion region = L2World.Instance.GetRegion(template._x[i], template._y[i]);
                if (region != null)
                {
                    // region._zoneManager.addZone(zone);
                }
                else
                {
                    CLogger.error("AreaTable[hideout]: null region at " + template._x[i] + " " + template._y[i] + " for zone " + zone.Name);
                }
            }
        }
Ejemplo n.º 3
0
		public Zone(Map rgn, ZoneTemplate template)
		{
			Map = rgn;
			Template = template;
			if (template.WorldStates != null)
			{
				WorldStates = new WorldStateCollection(this, template.WorldStates);
			}

			CreateChatChannels();
		}
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a zone channel, which is a constant, non-moderated channel specific to one or more Zones.
        /// </summary>
        internal ChatChannel CreateLocalDefenseChannel(ZoneTemplate zone)
        {
            var name = string.Format("LocalDefense - {0}", zone.Name);

            ChatChannel channel;

            if (!m_Channels.TryGetValue(name, out channel))
            {
                channel = new ChatChannel(this, name, LocalDefenseFlags, true, null)
                {
                    Announces = false
                };
                m_Channels.Add(channel.Name, channel);
            }
            return(channel);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a zone channel, which is a constant, non-moderated channel specific to one or more Zones.
        /// </summary>
        internal ChatChannel CreateLocalDefenseChannel(ZoneTemplate zone)
        {
            string      str = string.Format("LocalDefense - {0}", (object)zone.Name);
            ChatChannel chatChannel;

            if (!this.m_Channels.TryGetValue(str, out chatChannel))
            {
                chatChannel = new ChatChannel(this, str, ChatChannelGroup.LocalDefenseFlags, true,
                                              (ChatChannel.JoinValidationHandler)null)
                {
                    Announces = false
                };
                this.m_Channels.Add(chatChannel.Name, chatChannel);
            }

            return(chatChannel);
        }
        public override void OnUpdate(AchievementCollection achievements, uint value1, uint value2, ObjectBase involved)
        {
            if ((WorldMapOverlayId)value1 != this.WorldMapOverlayId)
            {
                return;
            }
            WorldMapOverlayEntry worldMapOverlayEntry = WCell.RealmServer.Global.World.s_WorldMapOverlayEntries[value1];

            if (worldMapOverlayEntry == null)
            {
                return;
            }
            bool flag = false;

            foreach (ZoneId zoneID in worldMapOverlayEntry.ZoneTemplateId)
            {
                if (zoneID != ZoneId.None)
                {
                    ZoneTemplate zoneInfo = WCell.RealmServer.Global.World.GetZoneInfo(zoneID);
                    if (zoneInfo.ExplorationBit >= 0 && achievements.Owner.IsZoneExplored(zoneInfo.ExplorationBit))
                    {
                        flag = true;
                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            if (!flag)
            {
                return;
            }
            achievements.SetCriteriaProgress((AchievementCriteriaEntry)this, 1U, ProgressType.ProgressSet);
        }
Ejemplo n.º 7
0
		public void SetZoneExplored(ZoneTemplate zone, bool gainXp)
		{
			// index of the field that contains the bit
			var fieldNo = zone.ExplorationBit >> 5;
			if (fieldNo >= UpdateFieldMgr.ExplorationZoneFieldSize)
			{
				return;
			}

			// index of the byte that contains the bit
			var byteNo = zone.ExplorationBit >> 3;

			// the position of the bit within it's byte
			var bit = (zone.ExplorationBit) % 8;

			// the mask inside the byte
			var bitMask = 1 << bit;

			// the value of the byte
			var byteVal = m_record.ExploredZones[byteNo];

			if ((byteVal & bitMask) == 0)
			{
				// not explored yet
				if (gainXp)
				{
					var xp = XpGenerator.GetExplorationXp(zone, this);
					if (xp > 0)
					{
						if (Level >= RealmServerConfiguration.MaxCharacterLevel)
						{
							// already at level cap
							CharacterHandler.SendExplorationExperience(this, zone.Id, 0);
						}
						else
						{
							// gain XP
							GainXp(xp);
							CharacterHandler.SendExplorationExperience(this, zone.Id, xp);
						}
					}
				}

				// set the bit client side
				var newValue = (byte)(byteVal | bitMask);
				SetByte((int)PlayerFields.EXPLORED_ZONES_1 + fieldNo, byteNo % 4, newValue);

				// cache the new value for easy access
				m_record.ExploredZones[byteNo] = newValue;

				// check possible achievements
				foreach (var worldMapOverlay in zone.WorldMapOverlays)
				{
					Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.ExploreArea, (uint)worldMapOverlay);
				}

				// explore parent
				if (zone.ParentZone != null)
				{
					SetZoneExplored(zone.ParentZone, gainXp);
				}
			}
		}
Ejemplo n.º 8
0
		public bool IsZoneExplored(ZoneTemplate zone)
		{
			return IsZoneExplored(zone.ExplorationBit);
		}
Ejemplo n.º 9
0
 public WorldZoneLocation(MapId map, Vector3 pos, ZoneTemplate zone)
     : base(map, pos, 1U)
 {
     this.ZoneTemplate = zone;
 }
Ejemplo n.º 10
0
 public static int GetExplorationXp(ZoneTemplate zone, Character character)
 {
     return(ExplorationXpFactor * (zone.AreaLevel * 20));
 }
Ejemplo n.º 11
0
		public WorldZoneLocation(Map map, Vector3 pos, ZoneTemplate zone)
			: base(map, pos)
		{
			ZoneTemplate = zone;
		}
Ejemplo n.º 12
0
 public WorldZoneLocation(Map map, Vector3 pos, ZoneTemplate zone)
     : base(map, pos)
 {
     ZoneTemplate = zone;
 }
Ejemplo n.º 13
0
		public ZoneWorldLocation(Region region, Vector3 pos, ZoneTemplate zone)
			: base(region, pos)
		{
			ZoneTemplate = zone;
		}
Ejemplo n.º 14
0
        public ZoneTable()
        {
            int          ctx = 0, cta = 0;
            StreamReader reader = new StreamReader(new FileInfo(@"scripts\areadata_cur.txt").FullName);

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                if (line.Length == 0)
                {
                    continue;
                }

                if (line.StartsWith("//"))
                {
                    continue;
                }

                if (line.StartsWith("area_begin"))
                {
                    L2Zone       zone     = null;
                    ZoneTemplate template = new ZoneTemplate();
                    string[]     d        = line.Split('\t');

                    for (int i = 1; i < d.Length; i++)
                    {
                        if (d[i].Equals("area_end"))
                        {
                            continue;
                        }

                        string param = d[i].Split('=')[0];
                        string val   = d[i].Substring(param.Length + 1);

                        switch (param)
                        {
                        case "name":
                            template.Name = val;
                            break;

                        case "map_no":
                            template._map_no = val;
                            break;

                        case "type":
                        {
                            template.Type = (ZoneTemplate.ZoneType)Enum.Parse(typeof(ZoneTemplate.ZoneType), val);

                            switch (template.Type)
                            {
                            case ZoneTemplate.ZoneType.battle_zone:
                                zone = new battle_zone();
                                break;

                            case ZoneTemplate.ZoneType.peace_zone:
                                zone = new peace_zone();
                                break;

                            case ZoneTemplate.ZoneType.water:
                                zone = new water();
                                break;

                            case ZoneTemplate.ZoneType.no_restart:
                                zone = new no_restart();
                                break;

                            case ZoneTemplate.ZoneType.ssq_zone:
                                zone = new ssq_zone();
                                break;

                            case ZoneTemplate.ZoneType.mother_tree:
                                zone = new mother_tree();
                                template._hp_regen_bonus = 2;
                                template._mp_regen_bonus = 1;
                                break;

                            case ZoneTemplate.ZoneType.damage:
                                zone = new damage();
                                template._damage_on_hp = 200;
                                template._damage_on_mp = 0;
                                break;

                            case ZoneTemplate.ZoneType.poison:
                                zone = new poison();
                                template.setSkill("s_area_a_speed_down");
                                break;

                            case ZoneTemplate.ZoneType.swamp:
                                zone = new swamp();
                                template._move_bonus = -50;
                                break;

                            case ZoneTemplate.ZoneType.instant_skill:
                                zone = new instant_skill();
                                break;
                            }
                        }
                        break;

                        case "affect_race":
                            template._affect_race = val;
                            break;

                        case "entering_message_no":
                            template._entering_message_no = int.Parse(val);
                            break;

                        case "leaving_message_no":
                            template._leaving_message_no = int.Parse(val);
                            break;

                        case "range":
                            template.setRange(val);
                            break;

                        case "move_bonus":
                            template._move_bonus = int.Parse(val);
                            break;

                        case "default_status":
                            template.DefaultStatus = val.Equals("on");
                            break;

                        case "event_id":
                            template._event_id = int.Parse(val);
                            break;

                        case "damage_on_hp":
                            template._damage_on_hp = int.Parse(val);
                            break;

                        case "damage_on_mp":
                            template._damage_on_mp = int.Parse(val);
                            break;

                        case "message_no":
                            template._message_no = int.Parse(val);
                            break;

                        case "target":
                            template._target = (ZoneTemplate.ZoneTarget)Enum.Parse(typeof(ZoneTemplate.ZoneTarget), val);
                            break;

                        case "skill_prob":
                            template._skill_prob = int.Parse(val);
                            break;

                        case "unit_tick":
                            template._unit_tick = int.Parse(val);
                            break;

                        case "initial_delay":
                            template._initial_delay = int.Parse(val);
                            break;

                        case "skill_list":
                            template.setSkillList(val);
                            break;

                        case "skill_name":
                            template.setSkill(val.Substring(1).Replace("]", ""));
                            break;

                        case "exp_penalty_per":
                            template._exp_penalty_per = int.Parse(val);
                            break;

                        case "item_drop":
                            template._item_drop = val.Equals("on");
                            break;
                        }
                    }
                    zone.Name      = template.Name;
                    zone.Template  = template;
                    zone.Territory = new ZoneNPoly(template._x, template._y, template._z1, template._z2);
                    cta++;
                    for (int i = 0; i < template._x.Length; i++)
                    {
                        L2WorldRegion region = L2World.Instance.GetRegion(template._x[i], template._y[i]);
                        if (region != null)
                        {
                            ctx++;
                            // region._zoneManager.addZone(zone);
                        }
                        else
                        {
                            CLogger.error("AreaTable: null region at " + template._x[i] + " " + template._y[i] + " for zone " + zone.Name);
                        }
                    }
                }
            }

            CLogger.info("AreaTable: intercepted " + ctx + " regions with " + cta + " zones");
        }
Ejemplo n.º 15
0
		public static int GetExplorationXp(ZoneTemplate zone, Character character)
		{
			return ExplorationXpFactor * (zone.AreaLevel * 20);
		}
Ejemplo n.º 16
0
		/// <summary>
		/// Creates a zone channel, which is a constant, non-moderated channel specific to one or more Zones.
		/// </summary>
		internal ChatChannel CreateLocalDefenseChannel(ZoneTemplate zone)
		{
			var name = string.Format("LocalDefense - {0}", zone.Name);

			ChatChannel channel;
			if (!m_Channels.TryGetValue(name, out channel))
			{
				channel = new ChatChannel(this, name, LocalDefenseFlags, true, null)
				{
					Announces = false
				};
				m_Channels.Add(channel.Name, channel);
			}
			return channel;
		}
Ejemplo n.º 17
0
		public void SetZoneExplored(ZoneTemplate zone, bool gainXp)
		{
			var index = zone.ExplorationBit >> 5;
			if (index >= UpdateFieldMgr.ExplorationZoneFieldSize * 4)
			{
				return;
			}

			//var intVal = GetUInt32((int)PlayerFields.EXPLORED_ZONES_1 + (int)index);
			var byteVal = m_record.ExploredZones[index];
			var bit = (zone.ExplorationBit - 1) % 8;
			if ((byteVal & (1 << bit)) == 0)
			{
				if (gainXp)
				{
					var xp = XpGenerator.GetExplorationXp(zone, this);
					if (xp > 0)
					{
						if (Level >= RealmServerConfiguration.MaxCharacterLevel)
						{
							CharacterHandler.SendExplorationExperience(this, zone.Id, 0);
						}
						else
						{
							GainXp(xp, false);
							CharacterHandler.SendExplorationExperience(this, zone.Id, xp);
						}
					}
				}

				var value = (byte)(byteVal | (1 << bit));
				SetByte((int)PlayerFields.EXPLORED_ZONES_1 + (zone.ExplorationBit >> 5), index % 4, value);
				m_record.ExploredZones[index] = value;

                foreach (var worldMapOverlay in zone.WorldMapOverlays)
			    {
                    Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.ExploreArea, (uint)worldMapOverlay);   
			    }
			}

			foreach (var child in zone.ChildZones)
			{
				SetZoneExplored(child, gainXp);
			}
		}