예제 #1
0
        private static void CreateCustomEntry(NPCId npcId, NpcCustomEntryId customEntryId, float healthMod, float otherStatsMod, int maxLevel, float speedMod, NpcCustomEntrySettings npcCustomEntrySettings, bool isAggressive = true)
        {
            var entry = NPCMgr.GetEntry(npcId).Clone();

            entry.SetLevel(maxLevel - 5);
            if (npcCustomEntrySettings.Health != null)
            {
                entry.SetHealth((int)(npcCustomEntrySettings.Health.Value * healthMod));
            }
            if (npcCustomEntrySettings.PDef != null)
            {
                entry.Resistances[(int)DamageSchool.Physical] = (int)(npcCustomEntrySettings.PDef.Value * otherStatsMod);
            }
            if (npcCustomEntrySettings.MDef != null)
            {
                entry.Resistances[(int)DamageSchool.Magical] = (int)(npcCustomEntrySettings.MDef.Value * otherStatsMod);
            }
            if (npcCustomEntrySettings.Damage != null)
            {
                entry.MinDamage = npcCustomEntrySettings.Damage.Value * 0.9f * otherStatsMod;
                entry.MaxDamage = npcCustomEntrySettings.Damage.Value * 1.1f * otherStatsMod;
            }
            if (npcCustomEntrySettings.Speed != null)
            {
                entry.RunSpeed  = npcCustomEntrySettings.Speed.Value * speedMod;
                entry.WalkSpeed = npcCustomEntrySettings.Speed.Value * speedMod;
            }
            entry.IsAgressive = isAggressive;
            NPCMgr.AddEntry((uint)customEntryId, entry);
            entry.NPCId = npcId;
        }
예제 #2
0
        protected FigurineBase(NPCId id)
        {
            if (_sharedAuras == null)
            {
                _sharedAuras = new AuraCollection(this);
            }
            m_auras = _sharedAuras;
            GenerateId((uint)id);
            NPCEntry entry = NPCMgr.GetEntry(id);

            UnitFlags         = UnitFlags.SelectableNotAttackable | UnitFlags.Possessed;
            DynamicFlags      = UnitDynamicFlags.TrackUnit;
            EmoteState        = EmoteType.StateDead;
            NPCFlags         |= NPCFlags.Gossip;
            Model             = entry.GetRandomModel();
            EntryId           = entry.Id;
            m_runSpeed        = 1f;
            m_swimSpeed       = 1f;
            m_swimBackSpeed   = 1f;
            m_walkSpeed       = 1f;
            m_walkBackSpeed   = 1f;
            m_flightSpeed     = 1f;
            m_flightBackSpeed = 1f;
            SetInt32(UnitFields.MAXHEALTH, int.MaxValue);
            SetInt32(UnitFields.BASE_HEALTH, int.MaxValue);
            SetInt32(UnitFields.HEALTH, int.MaxValue);
            SetFloat(ObjectFields.SCALE_X, entry.Scale * DefaultScale);
            m_evades = true;
        }
예제 #3
0
        private static void CreateCustomEntry(NPCId npcId, NpcCustomEntryId customEntryId, float healthMod,
                                              float otherStatsMod, int maxLevel, float speedMod,
                                              NpcCustomEntries.NpcCustomEntrySettings npcCustomEntrySettings, bool isAggressive = true)
        {
            NPCEntry entry = NPCMgr.GetEntry(npcId).Clone <NPCEntry>();

            entry.SetLevel(maxLevel - 5);
            if (npcCustomEntrySettings.Health.HasValue)
            {
                entry.SetHealth((int)((double)npcCustomEntrySettings.Health.Value * (double)healthMod));
            }
            if (npcCustomEntrySettings.PDef.HasValue)
            {
                entry.Resistances[0] = (int)((double)npcCustomEntrySettings.PDef.Value * (double)otherStatsMod);
            }
            if (npcCustomEntrySettings.MDef.HasValue)
            {
                entry.Resistances[1] = (int)((double)npcCustomEntrySettings.MDef.Value * (double)otherStatsMod);
            }
            if (npcCustomEntrySettings.Damage.HasValue)
            {
                entry.MinDamage = (float)npcCustomEntrySettings.Damage.Value * 0.9f * otherStatsMod;
                entry.MaxDamage = (float)npcCustomEntrySettings.Damage.Value * 1.1f * otherStatsMod;
            }

            if (npcCustomEntrySettings.Speed.HasValue)
            {
                entry.RunSpeed  = npcCustomEntrySettings.Speed.Value * speedMod;
                entry.WalkSpeed = npcCustomEntrySettings.Speed.Value * speedMod;
            }

            entry.IsAgressive = isAggressive;
            NPCMgr.AddEntry((uint)customEntryId, entry);
            entry.NPCId = npcId;
        }
예제 #4
0
        public static NPCEntry GetEntry(NPCId id, uint difficultyIndex)
        {
            var entry = GetEntry(id);

            if (entry != null)
            {
                return(entry.GetEntry(difficultyIndex));
            }
            return(null);
        }
예제 #5
0
 public static NPCEntry GetEntry(NPCId id)
 {
     if (id >= (NPCId)Entries.Length)
     {
         NPCEntry entry;
         CustomEntries.TryGetValue((uint)id, out entry);
         return(entry);
     }
     return(Entries[(uint)id]);
 }
예제 #6
0
		public static void CreateTeleportNPC(NPCId id, Vector3 location, MapId mapId, uint phase = WorldObject.DefaultPhase)
		{
			var spawn = new NPCSpawnEntry(id, mapId, location);
			spawn.FinalizeDataHolder();

			spawn.Spawned += npc =>
			{
				npc.Invulnerable++;
				npc.GossipMenu = WorldLocationMgr.CreateTeleMenu();
			};
		}
예제 #7
0
파일: NPCMgr.cs 프로젝트: uvbs/Asda2-Server
        public static NPCEntry GetEntry(NPCId id)
        {
            if (id < (NPCId)NPCMgr.Entries.Length)
            {
                return(NPCMgr.Entries[(uint)id]);
            }
            NPCEntry npcEntry;

            NPCMgr.CustomEntries.TryGetValue((uint)id, out npcEntry);
            return(npcEntry);
        }
예제 #8
0
        public static void CreateTeleportNPC(NPCId id, Vector3 location, MapId mapId, uint phase = WorldObject.DefaultPhase)
        {
            var spawn = new NPCSpawnEntry(id, mapId, location);

            spawn.FinalizeDataHolder();

            spawn.Spawned += npc =>
            {
                npc.Invulnerable++;
                npc.GossipMenu = WorldLocationMgr.CreateTeleMenu();
            };
        }
예제 #9
0
        public override SpellFailedReason Initialize()
        {
            NPCId miscValue = (NPCId)this.Effect.MiscValue;

            this.entry = NPCMgr.GetEntry(miscValue);
            if (this.entry != null)
            {
                return(SpellFailedReason.Ok);
            }
            LogManager.GetCurrentClassLogger()
            .Warn("The NPC for Summon-Spell {0} does not exist: {1} (Are NPCs loaded?)", (object)this.Effect.Spell,
                  (object)miscValue);
            return(SpellFailedReason.Error);
        }
예제 #10
0
파일: NPCs.cs 프로젝트: ray2006/WCell
		public static void CreateTeleportNPC(NPCId id, Vector3 location, MapId regionId)
		{
			var spawn = new SpawnEntry
			{
				EntryId = id
			};
			spawn.FinalizeDataHolder();

			spawn.Spawned += npc =>
			{
				npc.Invulnerable++;
				npc.GossipMenu = WorldLocationMgr.CreateTeleMenu();
			};
		}
예제 #11
0
        public static NPC GetNearbyNPC <O>(this O wObj, NPCId id, float radius) where O : WorldObject
        {
            NPC npc = null;

            wObj.IterateEnvironment(radius, obj =>
            {
                if (wObj.CanSee(obj) && obj is NPC && ((NPC)obj).Entry.NPCId == id)
                {
                    npc = (NPC)obj;
                    return(false);
                }
                return(true);
            });
            return(npc);
        }
예제 #12
0
        public static NPC GetNearbyNPC <O>(this O wObj, NPCId id, float radius) where O : WorldObject
        {
            NPC npc = (NPC)null;

            wObj.IterateEnvironment(radius, (Func <WorldObject, bool>)(obj =>
            {
                if (!wObj.CanSee(obj) || !(obj is NPC) || ((NPC)obj).Entry.NPCId != id)
                {
                    return(true);
                }
                npc = (NPC)obj;
                return(false);
            }));
            return(npc);
        }
예제 #13
0
 /// <summary>
 /// Returns the first active Quest that requires the given NPC to be interacted with
 /// </summary>
 public Quest GetReqNPCQuest(NPCId npc)
 {
     for (var j = 0; j < m_NPCInteractionQuests.Count; j++)
     {
         var quest = m_NPCInteractionQuests[j];
         for (var i = 0; i < quest.Template.NPCInteractions.Length; i++)
         {
             var interaction = quest.Template.NPCInteractions[i];
             if (interaction.TemplateId.Contains((uint)npc))
             {
                 return(quest);
             }
         }
     }
     return(null);
 }
예제 #14
0
        /// <summary>
        /// Returns the first active Quest that requires the given NPC to be interacted with
        /// </summary>
        public Quest GetReqNPCQuest(NPCId npc)
        {
            for (int index1 = 0; index1 < this.m_NPCInteractionQuests.Count; ++index1)
            {
                Quest interactionQuest = this.m_NPCInteractionQuests[index1];
                for (int index2 = 0; index2 < interactionQuest.Template.NPCInteractions.Length; ++index2)
                {
                    if (((IEnumerable <uint>)interactionQuest.Template.NPCInteractions[index2].TemplateId)
                        .Contains <uint>((uint)npc))
                    {
                        return(interactionQuest);
                    }
                }
            }

            return((Quest)null);
        }
예제 #15
0
        /// <summary>
        /// Returns the first active Quest that requires the given NPC to be interacted with
        /// </summary>
        public Quest GetReqNPCQuest(NPCId npc)
        {
            for (int index1 = 0; index1 < m_NPCInteractionQuests.Count; ++index1)
            {
                Quest interactionQuest = m_NPCInteractionQuests[index1];
                for (int index2 = 0; index2 < interactionQuest.Template.NPCInteractions.Length; ++index2)
                {
                    if (interactionQuest.Template.NPCInteractions[index2].TemplateId
                        .Contains((uint)npc))
                    {
                        return(interactionQuest);
                    }
                }
            }

            return(null);
        }
예제 #16
0
        protected FigurineBase(NPCId id)
        {
            if (_sharedAuras == null)
            {
                _sharedAuras = new AuraCollection(this);
            }

            m_auras = _sharedAuras;

            GenerateId((uint)id);

            var entry = NPCMgr.GetEntry(id);

            UnitFlags    = UnitFlags.SelectableNotAttackable | UnitFlags.Possessed;
            DynamicFlags = UnitDynamicFlags.TrackUnit;
            EmoteState   = EmoteType.StateDead;
            NPCFlags    |= NPCFlags.Gossip;
            Model        = entry.GetRandomModel();
            EntryId      = entry.Id;

            // speed must be > 0
            // because of the way the client works
            const float speed = 1f;

            m_runSpeed        = speed;
            m_swimSpeed       = speed;
            m_swimBackSpeed   = speed;
            m_walkSpeed       = speed;
            m_walkBackSpeed   = speed;
            m_flightSpeed     = speed;
            m_flightBackSpeed = speed;

            SetInt32(UnitFields.MAXHEALTH, int.MaxValue);
            SetInt32(UnitFields.BASE_HEALTH, int.MaxValue);
            SetInt32(UnitFields.HEALTH, int.MaxValue);

            // just make a smaller version of the creature to be spawned
            SetFloat(ObjectFields.SCALE_X, entry.Scale * DefaultScale);

            m_evades = true;
        }
예제 #17
0
		protected FigurineBase(NPCId id)
		{
			if (_sharedAuras == null)
			{
				_sharedAuras = new AuraCollection(this);
			}

			m_auras = _sharedAuras;

			GenerateId((uint) id);

			var entry = NPCMgr.GetEntry(id);
			UnitFlags = UnitFlags.SelectableNotAttackable | UnitFlags.Possessed;
			DynamicFlags = UnitDynamicFlags.TrackUnit;
			EmoteState = EmoteType.StateDead;
			NPCFlags |= NPCFlags.Gossip;
			Model = entry.GetRandomModel();
			EntryId = entry.Id;

			// speed must be > 0
			// because of the way the client works
			const float speed = 1f;
			m_runSpeed = speed;
			m_swimSpeed = speed;
			m_swimBackSpeed = speed;
			m_walkSpeed = speed;
			m_walkBackSpeed = speed;
			m_flightSpeed = speed;
			m_flightBackSpeed = speed;

			SetInt32(UnitFields.MAXHEALTH, int.MaxValue);
			SetInt32(UnitFields.BASE_HEALTH, int.MaxValue);
			SetInt32(UnitFields.HEALTH, int.MaxValue);

			// just make a smaller version of the creature to be spawned
			SetFloat(ObjectFields.SCALE_X, entry.Scale * DefaultScale);

			m_evades = true;
		}
예제 #18
0
        /// <summary>
        /// Is called to initialize the object; usually after a set of other operations have been performed or if
        /// the right time has come and other required steps have been performed.
        /// </summary>
        public void FinalizeAfterLoad()
        {
            NPCId          = (NPCId)Id;
            SetFlagIndeces = Utility.GetSetIndices((uint)Flags);
            DefaultFaction = FactionMgr.Get(DefaultFactionId);

            if (AuraIds != null)
            {
                var auras = new List <Spell>(AuraIds.Length);
                foreach (var auraId in AuraIds)
                {
                    var spell = SpellHandler.Get(auraId);
                    if (spell != null)
                    {
                        auras.Add(spell);
                    }
                }
                Auras = auras.ToArray();
            }
            else
            {
                Auras = Spell.EmptyArray;
            }

            var entry = NPCMgr.GetEntry(Id);

            if (entry != null)
            {
                // set the prototype
                entry.Prototype = this;
                Entry           = entry;
            }

            InstanceTypeHandlers = NPCMgr.GetNPCTypeHandlers(this);
            SpawnTypeHandlers    = NPCMgr.GetNPCSpawnTypeHandlers(this);
        }
예제 #19
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                string str1 = trigger.Text.NextModifiers();
                string name = null;

                if (str1.Contains("d"))
                {
                    name = trigger.Text.NextWord();
                }
                if (str1.Contains("r"))
                {
                    NPC target = trigger.Args.Target as NPC;
                    if (target == null)
                    {
                        trigger.Reply("Wrong target.");
                    }
                    else
                    {
                        EntityId      entityId   = target.EntityId;
                        NPCSpawnEntry spawnEntry = target.SpawnEntry;
                        spawnEntry.CommitDeleteAndFlush();
                        trigger.Reply("Monstr {0} deleted from spawn.", (object)spawnEntry);
                    }
                }
                else
                {
                    NPCId id = trigger.Text.NextEnum(NPCId.End);
                    if (id == NPCId.End)
                    {
                        trigger.Reply("Invalid NPC.");
                    }
                    else
                    {
                        uint num1 = trigger.Text.NextUInt(1U);
                        if (num1 < 1U)
                        {
                            trigger.Reply("Invalid amount: " + num1);
                        }
                        else
                        {
                            string   str2  = null;
                            NPCEntry entry = NPCMgr.GetEntry(id);
                            if (entry == null)
                            {
                                trigger.Reply("Invalid NPCId: " + id);
                            }
                            else
                            {
                                IWorldLocation target;
                                if (!string.IsNullOrEmpty(name))
                                {
                                    target = WorldLocationMgr.Get(name);
                                    if (target == null)
                                    {
                                        trigger.Reply("Invalid destination: " + name);
                                        return;
                                    }
                                }
                                else
                                {
                                    if (trigger.Args.Target == null)
                                    {
                                        trigger.Reply("No destination given.");
                                        return;
                                    }

                                    target = trigger.Args.Target;
                                }

                                int  num2 = 1;
                                int  x1   = -num2;
                                int  y1   = -num2;
                                int  num3 = 8;
                                long num4 = num1 + num3;
                                int  num5 = 0;
                                while (true)
                                {
                                    while (y1 > num2 || num5++ >= num4)
                                    {
                                        int y2 = num2;
                                        int x2 = x1 + 1;
                                        if (num5 < num4)
                                        {
                                            for (; x2 <= num2 && (long)num5++ < num4; ++x2)
                                            {
                                                if (num3 < num5)
                                                {
                                                    SpawnMob(x2, y2, entry, target);
                                                }
                                            }

                                            int x3 = num2;
                                            int y3 = y2 - 1;
                                            if (num5 < num4)
                                            {
                                                for (; y3 >= -num2 && (long)num5++ < num4; --y3)
                                                {
                                                    if (num3 < num5)
                                                    {
                                                        SpawnMob(x3, y3, entry, target);
                                                    }
                                                }

                                                y1 = -num2;
                                                x1 = x3 - 1;
                                                if (num5 < num4)
                                                {
                                                    for (; x1 >= -num2; --x1)
                                                    {
                                                        if (x1 == -num2)
                                                        {
                                                            ++num2;
                                                            x1 = -num2;
                                                            y1 = -num2;
                                                            break;
                                                        }

                                                        if (num5++ < num4)
                                                        {
                                                            if (num3 < num5)
                                                            {
                                                                SpawnMob(x1, y1, entry, target);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            break;
                                                        }
                                                    }

                                                    if (num5 < num4)
                                                    {
                                                        continue;
                                                    }
                                                }
                                            }
                                        }

                                        trigger.Reply("Created {0}.", (object)str2);
                                        return;
                                    }

                                    if (num3 < num5)
                                    {
                                        SpawnMob(x1, y1, entry, target);
                                    }
                                    ++y1;
                                }
                            }
                        }
                    }
                }
            }
예제 #20
0
파일: NPCMgr.cs 프로젝트: uvbs/Asda2-Server
 public static Spell[] GetSpells(NPCId id)
 {
     return(NPCMgr.PetSpells.Get <Spell[]>((uint)id));
 }
예제 #21
0
파일: NPCMgr.cs 프로젝트: uvbs/Asda2-Server
 internal static List <VendorItemEntry> GetOrCreateVendorList(NPCId npcId)
 {
     return(NPCMgr.GetOrCreateVendorList((uint)npcId));
 }
예제 #22
0
파일: NPCMgr.cs 프로젝트: uvbs/Asda2-Server
 public static NPCEntry GetEntry(NPCId id, uint difficultyIndex)
 {
     return(NPCMgr.GetEntry(id)?.GetEntry(difficultyIndex));
 }
예제 #23
0
파일: NPC.cs 프로젝트: 0xFh/Asda2-Project
        public void SetEntry(NPCId entryId)
        {
            var entry = NPCMgr.GetEntry(entryId);

            SetEntry(entry);
        }
예제 #24
0
 public static void CreateTeleportNPC(NPCId id, IWorldLocation loc)
 {
     CreateTeleportNPC(id, loc.Position, loc.MapId, loc.Phase);
 }
예제 #25
0
파일: Unit.cs 프로젝트: ray2006/WCell
		/// <summary>
		/// Tries to spawn the given pet for this Unit.
		/// </summary>
		/// <returns>null, if the Character already has that kind of Pet.</returns>
		public NPC SpawnMinion(NPCId id)
		{
			return SpawnMinion(id, 0);
		}
예제 #26
0
파일: NPCs.cs 프로젝트: ray2006/WCell
		public static void CreateTeleportNPC(NPCId id, IWorldLocation loc)
		{
			CreateTeleportNPC(id, loc.Position, loc.RegionId);
		}
예제 #27
0
		/// <summary>
		/// Is called to initialize the object; usually after a set of other operations have been performed or if
		/// the right time has come and other required steps have been performed.
		/// </summary>
		public void FinalizeAfterLoad()
		{
			NPCId = (NPCId)Id;
			SetFlagIndeces = Utility.GetSetIndices((uint)Flags);
			DefaultFaction = FactionMgr.Get(DefaultFactionId);

			if (AuraIds != null)
			{
				var auras = new List<Spell>(AuraIds.Length);
				foreach (var auraId in AuraIds)
				{
					var spell = SpellHandler.Get(auraId);
					if (spell != null)
					{
						auras.Add(spell);
					}
				}
				Auras = auras.ToArray();
			}
			else
			{
				Auras = Spell.EmptyArray;
			}

			var entry = NPCMgr.GetEntry(Id);
			if (entry != null)
			{
				// set the prototype
				entry.Prototype = this;
				Entry = entry;
			}

			InstanceTypeHandlers = NPCMgr.GetNPCTypeHandlers(this);
			SpawnTypeHandlers = NPCMgr.GetNPCSpawnTypeHandlers(this);
		}
예제 #28
0
		public static void CreateTeleportNPC(NPCId id, IWorldLocation loc)
		{
			CreateTeleportNPC(id, loc.Position, loc.MapId, loc.Phase);
		}
예제 #29
0
 public static NPC GetNearbyNPC <O>(this O wObj, NPCId id) where O : WorldObject
 {
     return(wObj.GetNearbyNPC(id, WorldObject.BroadcastRange));
 }
예제 #30
0
 public NPCSpawnEntry(NPCId entryId, MapId map, Vector3 pos)
 {
     EntryId  = entryId;
     MapId    = map;
     Position = pos;
 }
예제 #31
0
파일: Unit.cs 프로젝트: MeaNone/WCell
		public void Mount(NPCId mountId)
		{
			var mount = NPCMgr.GetEntry(mountId);
			if (mount != null)
			{
				Mount(mount.DisplayIds.GetRandom());
			}
		}
예제 #32
0
파일: NPC.cs 프로젝트: 0xFh/Asda2-Project
 public static NPC Create(NPCId id)
 {
     return(NPCMgr.GetEntry(id).Create());
 }
예제 #33
0
파일: NPC.cs 프로젝트: ebakkedahl/WCell
 public void SetEntry(NPCId entryId)
 {
     var entry = NPCMgr.GetEntry(entryId);
     SetEntry(entry);
 }
예제 #34
0
파일: NPC.cs 프로젝트: ebakkedahl/WCell
 public static NPC Create(NPCId id)
 {
     return NPCMgr.GetEntry(id).Create();
 }
예제 #35
0
 public static Spell[] GetSpells(NPCId id)
 {
     return(PetSpells.Get((uint)id));
 }
예제 #36
0
		/// <summary>
		/// Returns the first active Quest that requires the given NPC to be interacted with
		/// </summary>
		public Quest GetReqNPCQuest(NPCId npc)
		{
			for (var j = 0; j < m_NPCInteractionQuests.Count; j++)
			{
				var quest = m_NPCInteractionQuests[j];
				for (var i = 0; i < quest.Template.NPCInteractions.Length; i++)
				{
					var interaction = quest.Template.NPCInteractions[i];
					if (interaction.TemplateId == (uint)npc)
					{
						return quest;
					}
				}
			}
			return null;
		}
예제 #37
0
파일: Unit.cs 프로젝트: ray2006/WCell
		/// <summary>
		/// Tries to spawn the given pet for this Unit.
		/// </summary>
		/// <returns>null, if the Character already has that kind of Pet.</returns>
		public NPC SpawnMinion(NPCId id, int durationMillis)
		{
			var entry = NPCMgr.GetEntry(id);
			if (entry != null)
			{
				return SpawnMinion(entry, ref m_position, durationMillis);
			}
			return null;
		}
예제 #38
0
 public NPCSpawnEntry(NPCId entryId, MapId map, Vector3 pos)
 {
     this.EntryId  = entryId;
     this.MapId    = map;
     this.Position = pos;
 }