Example #1
0
		/// <summary>
		/// Create a commander.
		/// </summary>
		/// <param name="npcTemplate"></param>
		/// <param name="owner"></param>
		public CommanderPet(INpcTemplate npcTemplate)
			: base(npcTemplate)
		{
			if (Name.ToLower() == LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "GameObjects.CommanderPet.ReturnedCommander"))
			{
				InitControlledBrainArray(0);
			}

			if (Name.ToLower() == LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "GameObjects.CommanderPet.DecayedCommander") ||
			    Name.ToLower() == LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "GameObjects.CommanderPet.SkeletalCommander"))
			{
				InitControlledBrainArray(1);
			}

			if (Name.ToLower() == LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "GameObjects.CommanderPet.BoneCommander"))
			{
				InitControlledBrainArray(2);
			}

			if (Name.ToLower() == LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "GameObjects.CommanderPet.DreadCommander") ||
			    Name.ToLower() == LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "GameObjects.CommanderPet.DreadGuardian") ||
			    Name.ToLower() == LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "GameObjects.CommanderPet.DreadLich") ||
			    Name.ToLower() == LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "GameObjects.CommanderPet.DreadArcher"))
			{
				InitControlledBrainArray(3);
			}
		}
Example #2
0
		public GamePet(INpcTemplate template) : base(template)
		{
			if (Inventory != null)
			{
				if (Inventory.GetItem(eInventorySlot.DistanceWeapon) != null)
					SwitchWeapon(GameLiving.eActiveWeaponSlot.Distance);
				else if (Inventory.GetItem(eInventorySlot.RightHandWeapon) != null)
					SwitchWeapon(GameLiving.eActiveWeaponSlot.Standard);
				else if (Inventory.GetItem(eInventorySlot.TwoHandWeapon) != null)
					SwitchWeapon(GameLiving.eActiveWeaponSlot.TwoHanded);
			}
			AddStatsToWeapon();
			BroadcastLivingEquipmentUpdate();
		}
Example #3
0
		/// <summary>
		/// Create necromancer pet from template. Con and hit bonuses from
		/// items the caster was wearing when the summon started, will be
		/// transferred to the pet.
		/// </summary>
		/// <param name="npcTemplate"></param>
		/// <param name="owner">Player who summoned this pet.</param>
		/// <param name="summonConBonus">Item constitution bonuses of the player.</param>
		/// <param name="summonHitsBonus">Hits bonuses of the player.</param>
		public NecromancerPet(INpcTemplate npcTemplate, int summonConBonus,
		                      int summonHitsBonus) : base(npcTemplate)
		{
			// Transfer bonuses.
			
			m_summonConBonus = summonConBonus;
			m_summonHitsBonus = summonHitsBonus;

			// Set immunities/load equipment/etc.

			switch (Name)
			{
				case "lesser zombie servant":
				case "zombie servant":
					EffectList.Add(new MezzRootImmunityEffect());
					LoadEquipmentTemplate("barehand_weapon");
					InventoryItem item;
					if (Inventory != null &&
					    (item = Inventory.GetItem(eInventorySlot.RightHandWeapon)) != null)
                        if (item.ProcSpellID==0)
						item.ProcSpellID = (int)Procs.Stun;
					break;
				case "reanimated servant" :
					LoadEquipmentTemplate("reanimated_servant");
					break;
				case "necroservant":
					LoadEquipmentTemplate("necroservant");
					break;
				case "greater necroservant":
					LoadEquipmentTemplate("barehand_weapon");
					if (Inventory != null &&
					    (item = Inventory.GetItem(eInventorySlot.RightHandWeapon)) != null)
                        if (item.ProcSpellID==0)
						item.ProcSpellID = (int)Procs.Poison;
					break;
				case "abomination":
					LoadEquipmentTemplate("abomination_fiery_sword");
					break;
				default:
					LoadEquipmentTemplate("barehand_weapon");
					break;
			}
		}
Example #4
0
        /// <summary>
        /// Adds the mob template to collection
        /// </summary>
        /// <param name="template">New mob template</param>
        public static void AddTemplate(INpcTemplate template)
        {
            lock (m_mobTemplates.SyncRoot)
            {
                object entry = m_mobTemplates[template.TemplateId];

                if (entry == null)
                {
                    m_mobTemplates[template.TemplateId] = template;
                }
                else if (entry is ArrayList)
                {
                    ArrayList array = (ArrayList)entry;
                    array.Add(template);
                }
                else
                {
                    ArrayList arr = new ArrayList(2);
                    arr.Add(entry);
                    arr.Add(template);
                    m_mobTemplates[template.TemplateId] = arr;
                }
            }
        }
Example #5
0
 public GameSummoner(INpcTemplate template) : base(template)
 {
 }
 protected virtual GamePet GetGamePet(INpcTemplate template)
 {
     return(Caster.CreateGamePet(template));
 }
Example #7
0
		protected virtual GamePet GetGamePet(INpcTemplate template)
		{
			return new GamePet(template);
		}
Example #8
0
 public TraitorDaggerPet(INpcTemplate npcTemplate)
     : base(npcTemplate)
 {
 }
Example #9
0
		/// <summary>
		/// Adds the mob template to collection
		/// </summary>
		/// <param name="template">New mob template</param>
		public static void AddTemplate(INpcTemplate template)
		{
			lock (m_mobTemplates.SyncRoot)
			{
				object entry = m_mobTemplates[template.TemplateId];

				if (entry == null)
				{
					m_mobTemplates[template.TemplateId] = template;
				}
				else if (entry is ArrayList)
				{
					ArrayList array = (ArrayList)entry;
					array.Add(template);
				}
				else
				{
					ArrayList arr = new ArrayList(2);
					arr.Add(entry);
					arr.Add(template);
					m_mobTemplates[template.TemplateId] = arr;
				}
			}
		}
 protected override GamePet GetGamePet(INpcTemplate template)
 {
     return(new TraitorDaggerPet(template));
 }
Example #11
0
        /// <summary>
        /// Create an add from the specified template.
        /// </summary>
        /// <param name="templateID"></param>
        /// <param name="level"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="uptime"></param>
        /// <returns></returns>
        protected GameNPC SpawnTimedAdd(int templateID, int level, int x, int y, int uptime, bool isRetriever)
        {
            GameNPC add = null;

            try
            {
                if (m_addTemplate == null || m_addTemplate.TemplateId != templateID)
                {
                    m_addTemplate = NpcTemplateMgr.GetTemplate(templateID);
                }

                // Create add from template.
                // The add will automatically despawn after 30 seconds.

                if (m_addTemplate != null)
                {
                    add = new GameNPC(m_addTemplate);

                    if (isRetriever)
                    {
                        add.SetOwnBrain(new RetrieverMobBrain());
                    }
                    add.CurrentRegion = this.CurrentRegion;
                    add.Heading = (ushort)(Util.Random(0, 4095));
                    add.Realm = 0;
                    add.X = x;
                    add.Y = y;
                    add.Z = Z;
                    add.CurrentSpeed = 0;
                    add.Level = (byte)level;
                    add.RespawnInterval = -1;
                    add.AddToWorld();
                    new DespawnTimer(this, add, uptime * 1000);
                }
            }
            catch
            {
                log.Warn(String.Format("Unable to get template for {0}", Name));
            }
            return add;
        }
Example #12
0
 protected override GamePet GetGamePet(INpcTemplate template)
 {
     return(new SummonElementalPet(template));
 }
 protected override GamePet GetGamePet(INpcTemplate template) { return new AstralPet(template); }
Example #14
0
		public TurretPet(INpcTemplate template)
			: base(template)
		{
		}
Example #15
0
 protected override GamePet GetGamePet(INpcTemplate template)
 {
     return(new CommanderPet(template));
 }
Example #16
0
		public GameTaxi(INpcTemplate templateid) : base(templateid)
		{
			BlankBrain brain = new BlankBrain();
			SetOwnBrain(brain);
		}
Example #17
0
 protected override GamePet GetGamePet(INpcTemplate template)
 {
     return(new AstralPet(template));
 }
Example #18
0
 public AstralPet(INpcTemplate npcTemplate) : base(npcTemplate)
 {
 }
Example #19
0
 public TheurgistPet(INpcTemplate npcTemplate) : base(npcTemplate)
 {
 }
		/// <summary>
		/// Load a NPC template onto this NPC
		/// </summary>
		/// <param name="template"></param>
		public virtual void LoadTemplate(INpcTemplate template)
		{
			if (template == null)
				return;

			var m_templatedInventory = new List<string>();
			this.TranslationId = template.TranslationId;
			this.Name = template.Name;
			this.Suffix = template.Suffix;
			this.GuildName = template.GuildName;
			this.ExamineArticle = template.ExamineArticle;
			this.MessageArticle = template.MessageArticle;
			
			#region Models, Sizes, Levels, Gender
			// Grav: this.Model/Size/Level accessors are triggering SendUpdate()
			// so i must use them, and not directly use private variables
			ushort choosenModel = 1;
			var splitModel = template.Model.SplitCSV(true);
			ushort.TryParse(splitModel[Util.Random(0,splitModel.Count-1)], out choosenModel);
			this.Model = choosenModel;
			
			// Graveen: template.Gender is 0,1 or 2 for respectively eGender.Neutral("it"), eGender.Male ("he"), 
			// eGender.Female ("she"). Any other value is randomly choosing a gender for current GameNPC
			int choosenGender = template.Gender>2?Util.Random(0,2):template.Gender;

			switch (choosenGender)
			{
				default	:
				case 0	: this.Gender = eGender.Neutral; break;
				case 1	: this.Gender = eGender.Male; break;
				case 2	: this.Gender = eGender.Female; break;			
			}
			
			byte choosenSize = 50;
			if (!Util.IsEmpty(template.Size))
			{
				var split = template.Size.SplitCSV(true);
				byte.TryParse(split[Util.Random(0,split.Count-1)], out choosenSize);
			}
			this.Size = choosenSize;
			
			byte choosenLevel = 1;
			if (!Util.IsEmpty(template.Level))
			{
				var split = template.Level.SplitCSV(true);
				byte.TryParse(split[Util.Random(0,split.Count-1)], out choosenLevel);
			}
			this.Level = choosenLevel;
			#endregion

			#region Stats
			// Stats
			if (template.Strength==0)
			{
				this.AutoSetStats();
			}
			else
			{
				this.Constitution = (short)template.Constitution;
				this.Dexterity = (short)template.Dexterity;
				this.Strength = (short)template.Strength;
				this.Quickness = (short)template.Quickness;
				this.Intelligence = (short)template.Intelligence;
				this.Piety = (short)template.Piety;
				this.Empathy = (short)template.Empathy;
				this.Charisma = (short)template.Charisma;
			}
			#endregion

			#region Misc Stats
			this.MaxDistance = template.MaxDistance;
			this.TetherRange = template.TetherRange;
			this.Race = (short)template.Race;
			this.BodyType = (ushort)template.BodyType;
			this.MaxSpeedBase = template.MaxSpeed;
			this.Flags = (eFlags)template.Flags;
			this.MeleeDamageType = template.MeleeDamageType;
			this.ParryChance = template.ParryChance;
			this.EvadeChance = template.EvadeChance;
			this.BlockChance = template.BlockChance;
			this.LeftHandSwingChance = template.LeftHandSwingChance;
			#endregion

			#region Inventory
			//Ok lets start loading the npc equipment - only if there is a value!
			if (!Util.IsEmpty(template.Inventory))
			{
				bool equipHasItems = false;
				GameNpcInventoryTemplate equip = new GameNpcInventoryTemplate();
				//First let's try to reach the npcequipment table and load that!
				//We use a ';' split to allow npctemplates to support more than one equipmentIDs
				var equipIDs = template.Inventory.SplitCSV();
				if (!template.Inventory.Contains(":"))
				{

					foreach (string str in equipIDs)
					{
						m_templatedInventory.Add(str);
					}

					string equipid = "";

					if (m_templatedInventory.Count > 0)
					{
						if (m_templatedInventory.Count == 1)
							equipid = template.Inventory;
						else
							equipid = m_templatedInventory[Util.Random(m_templatedInventory.Count - 1)];
					}
					if (equip.LoadFromDatabase(equipid))
						equipHasItems = true;
				}

				#region Legacy Equipment Code
				//Nope, nothing in the npcequipment table, lets do the crappy parsing
				//This is legacy code
				if (!equipHasItems && template.Inventory.Contains(":"))
				{
					//Temp list to store our models
					List<int> tempModels = new List<int>();

					//Let's go through all of our ';' seperated slots
					foreach (string str in equipIDs)
					{
						tempModels.Clear();
						//Split the equipment into slot and model(s)
						string[] slotXModels = str.Split(':');
						//It should only be two in length SLOT : MODELS
						if (slotXModels.Length == 2)
						{
							int slot;
							//Let's try to get our slot
							if (Int32.TryParse(slotXModels[0], out slot))
							{
								//Now lets go through and add all the models to the list
								string[] models = slotXModels[1].Split('|');
								foreach (string strModel in models)
								{
									//We'll add it to the list if we successfully parse it!
									int model;
									if (Int32.TryParse(strModel, out model))
										tempModels.Add(model);
								}

								//If we found some models let's randomly pick one and add it the equipment
								if (tempModels.Count > 0)
									equipHasItems |= equip.AddNPCEquipment((eInventorySlot)slot, tempModels[Util.Random(tempModels.Count - 1)]);
							}
						}
					}
				}
				#endregion

				//We added some items - let's make it the new inventory
				if (equipHasItems)
				{
					this.Inventory = new GameNPCInventory(equip);
					if (this.Inventory.GetItem(eInventorySlot.DistanceWeapon) != null)
						this.SwitchWeapon(eActiveWeaponSlot.Distance);
				}
				
				if (template.VisibleActiveWeaponSlot > 0)
					this.VisibleActiveWeaponSlots = template.VisibleActiveWeaponSlot;
			}
			#endregion
			
			if (template.Spells != null) this.Spells = template.Spells;
			if (template.Styles != null) this.Styles = template.Styles;
			if (template.Abilities != null)
			{
				lock (m_lockAbilities)
				{
					foreach (Ability ab in template.Abilities)
						m_abilities[ab.KeyName] = ab;
				}
			}
			BuffBonusCategory4[(int)eStat.STR] += template.Strength;
			BuffBonusCategory4[(int)eStat.DEX] += template.Dexterity;
			BuffBonusCategory4[(int)eStat.CON] += template.Constitution;
			BuffBonusCategory4[(int)eStat.QUI] += template.Quickness;
			BuffBonusCategory4[(int)eStat.INT] += template.Intelligence;
			BuffBonusCategory4[(int)eStat.PIE] += template.Piety;
			BuffBonusCategory4[(int)eStat.EMP] += template.Empathy;
			BuffBonusCategory4[(int)eStat.CHR] += template.Charisma;

			m_ownBrain = new StandardMobBrain
			{
				Body = this,
				AggroLevel = template.AggroLevel,
				AggroRange = template.AggroRange
			};
			this.NPCTemplate = template as NpcTemplate;
		}
Example #21
0
		protected override GamePet GetGamePet(INpcTemplate template)
		{
			return new NecromancerPet(template, m_summonConBonus, m_summonHitsBonus);
		}
Example #22
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (client.Player == null)
            {
                return;
            }

            GamePlayer player = client.Player;

            string key = GetInstanceKey(player);

            if (args.Length < 2)
            {
                if (key != "")
                {
                    SendMessage(client, "Current instance key is " + key);
                }

                DisplaySyntax(client);
                return;
            }

            if (key == "" && args[1] != "key")
            {
                SendMessage(client, "You must first assign an instance to work with using /instance key <ID>.");
                return;
            }

            switch (args[1].ToLower())
            {
                #region SetInstanceID
            case "key":
                string newKey = string.Join(" ", args, 2, args.Length - 2);
                client.Player.TempProperties.setProperty(INSTANCE_KEY, newKey);
                SendMessage(client, "Instance key set to " + newKey);
                break;

                #endregion
                #region Create Entry
            case "entry":
            {
                try
                {
                    if (args.Length < 3)
                    {
                        DisplaySyntax(client);
                        return;
                    }

                    //Create the database entry...
                    DBInstanceXElement element = new DBInstanceXElement();
                    element.Heading    = client.Player.Heading;
                    element.X          = (int)client.Player.Position.X;
                    element.Y          = (int)client.Player.Position.Y;
                    element.Z          = (int)client.Player.Position.Z;
                    element.InstanceID = key;
                    element.ClassType  = args[2];

                    int npctemplate = 0;

                    try { npctemplate = int.Parse(args[3]); }
                    catch { }

                    element.NPCTemplate = npctemplate.ToString();

                    if (npctemplate > 0)
                    {
                        // reload all templates to grab any new ones
                        NpcTemplateMgr.Reload();
                    }


                    //Save the element to database!
                    GameServer.Database.AddObject(element);
                    GameServer.Database.SaveObject(element);

                    //Dinberg: place a marker at this spot!
                    string theType = args[2];

                    SendMessage(client, "Created an element here! Use your memory for now, I sure as hell dont have anything else to show you where it is ^^");

                    //Only create ones that have namespaces (signified by '.')
                    if (theType.Contains("."))
                    {
                        SendMessage(client, "theType suspected to be a ClassType - attempting to invoke a marker of this class.");
                        GameObject obj = null;

                        //Now we have the classtype to create, create it thus!
                        //This is required to ensure we check scripts for the space aswell, such as quests!
                        foreach (Assembly asm in ScriptMgr.GameServerScripts)
                        {
                            obj = (GameObject)(asm.CreateInstance(theType, false));
                            if (obj != null)
                            {
                                break;
                            }
                        }

                        if (args.Length == 4)
                        {
                            int templateID = 0;
                            try { templateID = int.Parse(args[3]); }
                            catch { }
                            //If its an npc, load from the npc template about now.
                            //By default, we ignore npctemplate if its set to 0.
                            if ((GameNPC)obj != null && templateID != 0)
                            {
                                INpcTemplate npcTemplate = NpcTemplateMgr.GetTemplate(templateID);
                                //we only want to load the template if one actually exists, or there could be trouble!
                                if (npcTemplate != null)
                                {
                                    ((GameNPC)obj).LoadTemplate(npcTemplate);
                                }
                            }
                        }

                        //Add to world...
                        obj.Name      = element.ObjectId.Substring(0, 18);
                        obj.GuildName = element.ObjectId.Substring(18);

                        obj.Position = new Vector3(element.X, element.Y, element.Z);
                        obj.Heading  = element.Heading;

                        obj.CurrentRegion = client.Player.CurrentRegion;

                        // now make sure model is visible
                        if (obj is GameNPC && obj.Model == 0)
                        {
                            obj.Model = 408;                                             // red ball
                        }
                        else if (obj is GameStaticItem && obj.Model == 0)
                        {
                            obj.Model = 100;                                             // bag
                        }
                        if (!obj.AddToWorld())
                        {
                            client.Out.SendMessage("Error: Object not added to world correctly!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                        }
                        else
                        {
                            client.Out.SendMessage("Object added!", eChatType.CT_Say, eChatLoc.CL_SystemWindow);
                        }
                    }
                }
                catch (Exception ex)
                {
                    client.Out.SendMessage("An Exception has occurred when trying to add object, review server error logs! Exception: " + ex.Message, eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                    log.Error("Instance Entry Error", ex);
                }
            }
            break;

                #endregion
                #region remove
            case "remove":
            {
                GameObject obj = client.Player.TargetObject;
                if (obj == null)
                {
                    return;
                }
                string     ObjectId = obj.Name + obj.GuildName;
                DataObject o        = GameServer.Database.FindObjectByKey <DBInstanceXElement>(ObjectId);

                if (o == null)
                {
                    client.Out.SendMessage("Could not find the entry in the database! <key=" + ObjectId + ">", eChatType.CT_Say, eChatLoc.CL_SystemWindow);
                    return;
                }

                GameServer.Database.DeleteObject(o);
                client.Out.SendMessage("Object removed!", eChatType.CT_Say, eChatLoc.CL_SystemWindow);

                //Remove object...
                obj.RemoveFromWorld();
                obj.Delete();
                obj.DeleteFromDatabase();
            }
            break;

                #endregion
                #region create
            case "create":
            {
                if (player.CurrentRegion.IsInstance)
                {
                    SendMessage(client, "You are already in an instance, use /instance exit to get out.");
                    return;
                }

                try
                {
                    if (args.Length < 3)
                    {
                        throw new Exception("You need to provide a skin id.  A skin is the ID of the region you want this instance to look like.");
                    }

                    Instance newInstance = player.TempProperties.getProperty <object>(key, null) as Instance;

                    if (newInstance != null)
                    {
                        throw new Exception("You already have an instance '" + key + "' created, please close it before creating another.");
                    }

                    ushort skinID = Convert.ToUInt16(args[2]);

                    newInstance = (Instance)WorldMgr.CreateInstance(skinID, typeof(Instance));

                    if (newInstance == null)
                    {
                        SendMessage(client, "Instance creation failed.");
                    }
                    else
                    {
                        SendMessage(client, "Instance created, now loading elements for instance '" + key + "' from the DB.");
                        newInstance.LoadFromDatabase(key);
                        player.TempProperties.setProperty(key, newInstance);
                    }
                }
                catch (Exception ex)
                {
                    SendMessage(client, ex.Message);
                    return;
                }
            }
            break;

                #endregion
                #region close
            case "close":
            {
                Instance newInstance = player.TempProperties.getProperty <object>(key, null) as Instance;

                if (newInstance == null)
                {
                    SendMessage(client, "Can't find an instance to delete.");
                }
                else
                {
                    player.TempProperties.removeProperty(key);
                    newInstance.DestroyWhenEmpty = true;
                    if (newInstance.NumPlayers == 0)
                    {
                        SendMessage(client, "Instance closed.");
                    }
                    else
                    {
                        SendMessage(client, "Instance will close once all players leave.");
                    }
                }
            }
            break;

                #endregion
                #region test
            case "test":
            {
                if (player.CurrentRegion.IsInstance)
                {
                    SendMessage(client, "You are already in an instance, use /instance exit to get out.");
                    return;
                }

                Instance newInstance = player.TempProperties.getProperty <object>(key, null) as Instance;

                if (newInstance == null)
                {
                    SendMessage(client, "Can't find an instance to test, you will need to create one first.");
                }
                else
                {
                    // start with some generic coordinates that seem to work well in many instance zones
                    var    pos     = new Vector3(32361, 31744, 16003);
                    ushort heading = 1075;

                    // If you're having trouble zoning into an instance then try adding an entrance element so it can be used here
                    if (newInstance.InstanceEntranceLocation != null)
                    {
                        pos     = newInstance.InstanceEntranceLocation.Position;
                        heading = newInstance.InstanceEntranceLocation.Heading;
                    }

                    // save current position for use with /instance exit
                    GameLocation saveLocation = new GameLocation(player.Name + "_exit", player.CurrentRegionID, player.Position, player.Heading);
                    player.TempProperties.setProperty(saveLocation.Name, saveLocation);

                    bool success = true;

                    if (!player.MoveTo(newInstance.ID, pos, heading))
                    {
                        SendMessage(client, "MoveTo to entrance failed, now trying to move to current location inside the instance.");

                        if (!player.MoveTo(newInstance.ID, player.Position, player.Heading))
                        {
                            SendMessage(client, "That failed as well.  Either add an entrance to this instance or move in the world to a corresponding instance location.");
                            success = false;
                        }
                    }

                    if (success)
                    {
                        SendMessage(client, "Welcome to Instance ID " + newInstance.ID + ", Skin: " + newInstance.Skin + ", with " + newInstance.Zones.Count + " zones and " + newInstance.Objects.Length + " objects inside the region!");
                        SendMessage(client, "Use '/instance exit' to leave if you get stuck.");
                    }
                }
            }
            break;

                #endregion
                #region exit
            case "exit":
            {
                if (!player.CurrentRegion.IsInstance)
                {
                    SendMessage(client, "You need to be in an instance to use this command.");
                    return;
                }

                GameLocation saveLocation = player.TempProperties.getProperty <object>(player.Name + "_exit", null) as GameLocation;

                if (saveLocation == null)
                {
                    ushort sourceRegion = (player.CurrentRegion as BaseInstance).Skin;

                    if (!player.MoveTo(sourceRegion, player.Position, player.Heading))
                    {
                        player.MoveToBind();
                    }
                }
                else
                {
                    player.MoveTo(saveLocation.RegionID, saveLocation.Position, saveLocation.Heading);
                }
            }
            break;
                #endregion
            }

            return;
        }
Example #23
0
 protected override GamePet GetGamePet(INpcTemplate template)
 {
     return(new NecromancerPet(template, m_summonConBonus, m_summonHitsBonus));
 }
Example #24
0
 protected override GamePet GetGamePet(INpcTemplate template)
 {
     return(new TheurgistPet(template));
 }
 public IllusionBladePet(INpcTemplate npcTemplate) : base(npcTemplate)
 {
 }
Example #26
0
 protected override GamePet GetGamePet(INpcTemplate template)
 {
     return new BDSubPet(template);
 }
 protected override GamePet GetGamePet(INpcTemplate template)
 {
     return(new IllusionBladePet(template));
 }
Example #28
0
		/// <summary>
		/// Removes a template
		/// </summary>
		/// <param name="template">mob template</param>
		public static void RemoveTemplate(INpcTemplate template)
		{
			lock (m_mobTemplates.SyncRoot)
			{
				if (m_mobTemplates[template.TemplateId] != null)
				{
					m_mobTemplates[template.TemplateId] = null;
				}
			}
		}
Example #29
0
 protected override GamePet GetGamePet(INpcTemplate template)
 {
     return new SummonElementalPet(template);
 }
Example #30
0
 protected override GamePet GetGamePet(INpcTemplate template)
 {
     return new TraitorDaggerPet(template);
 }
Example #31
0
 public SummonHealingElementalPet(INpcTemplate npcTemplate)
     : base(npcTemplate)
 {
 }
Example #32
0
        /// <summary>
        /// Loads elements relating to the given instance keyname from the database and populates the instance.
        /// </summary>
        /// <param name="instanceName"></param>
        public virtual void LoadFromDatabase(string instanceName)
        {
            var objects = GameServer.Database.SelectObjects <DBInstanceXElement>("`InstanceID` = @InstanceID", new QueryParameter("@InstanceID", instanceName));

            if (objects.Count == 0)
            {
                return;
            }

            int count = 0;

            //Now we have a list of DBElements, lets create the various entries
            //associated with them and populate the instance.
            foreach (DBInstanceXElement entry in objects)
            {
                if (entry == null)
                {
                    continue;                     //an odd error, but experience knows best.
                }
                GameObject obj     = null;
                string     theType = "DOL.GS.GameNPC";

                //Switch the classtype to see what we are making.
                switch (entry.ClassType)
                {
                case "entrance":
                {
                    //create the entrance, then move to the next.
                    m_entranceLocation = new GameLocation(instanceName + "entranceRegion" + ID, ID, entry.X, entry.Y, entry.Z, entry.Heading);
                    //move to the next entry, nothing more to do here...
                    continue;
                }

                case "region": continue;                                 //This is used to save the regionID as NPCTemplate.

                case "DOL.GS.GameNPC": break;

                default: theType = entry.ClassType; break;
                }

                //Now we have the classtype to create, create it thus!
                //This is required to ensure we check scripts for the space aswell, such as quests!
                foreach (Assembly asm in ScriptMgr.GameServerScripts)
                {
                    obj = (GameObject)(asm.CreateInstance(theType, false));
                    if (obj != null)
                    {
                        break;
                    }
                }


                if (obj == null)
                {
                    continue;
                }


                //We now have an object that isnt null. Lets place it at the location, in this region.

                obj.X               = entry.X;
                obj.Y               = entry.Y;
                obj.Z               = entry.Z;
                obj.Heading         = entry.Heading;
                obj.CurrentRegionID = ID;

                //If its an npc, load from the npc template about now.
                //By default, we ignore npctemplate if its set to 0.
                if ((GameNPC)obj != null && !Util.IsEmpty(entry.NPCTemplate, true))
                {
                    var listTemplate = Util.SplitCSV(entry.NPCTemplate, true);
                    int template     = 0;

                    if (int.TryParse(listTemplate[Util.Random(listTemplate.Count - 1)], out template) && template > 0)
                    {
                        INpcTemplate npcTemplate = NpcTemplateMgr.GetTemplate(template);
                        //we only want to load the template if one actually exists, or there could be trouble!
                        if (npcTemplate != null)
                        {
                            ((GameNPC)obj).LoadTemplate(npcTemplate);
                        }
                    }
                }
                //Finally, add it to the world!
                obj.AddToWorld();

                //Keep track of numbers.
                count++;
            }

            log.Info("Successfully loaded a db entry to " + Description + " - Region ID " + ID + ". Loaded Entities: " + count);
        }
		protected override GamePet GetGamePet(INpcTemplate template)
		{
			return new CommanderPet(template);
		}
Example #34
0
 public GameHastener(INpcTemplate template) : base(template) { }
Example #35
0
 public ZoarkatPet(INpcTemplate npcTemplate) : base(npcTemplate)
 {
 }
Example #36
0
 public ZoarkatPet(INpcTemplate npcTemplate) : base(npcTemplate) { }
Example #37
0
 protected override GamePet GetGamePet(INpcTemplate template)
 {
     return(new BDSubPet(template));
 }
Example #38
0
 /// <summary>
 /// Create a commander.
 /// </summary>
 /// <param name="npcTemplate"></param>
 /// <param name="owner"></param>
 public BDSubPet(INpcTemplate npcTemplate) : base(npcTemplate) { }
Example #39
0
 /// <summary>
 /// Create a commander.
 /// </summary>
 /// <param name="npcTemplate"></param>
 /// <param name="owner"></param>
 public BDSubPet(INpcTemplate npcTemplate) : base(npcTemplate)
 {
 }
 protected virtual GamePet GetGamePet(INpcTemplate template)
 {
     return Caster.CreateGamePet(template);
 }
 public IllusionBladePet(INpcTemplate npcTemplate) : base(npcTemplate) { }
		/// <summary>
		/// create npc from template
		/// </summary>
		/// <param name="template">template of generator</param>
		public GameNPC(INpcTemplate template)
			: this()
		{
			if (template == null) return;

			// save the original template so we can do calculations off the original values
			m_template = template;

			LoadTemplate(template);
		}
 protected override GamePet GetGamePet(INpcTemplate template) { return new IllusionBladePet(template); }
 public AstralPet(INpcTemplate npcTemplate) : base(npcTemplate) { }
Example #45
0
        /// <summary>
        /// Apply effect on target or do spell action if non duration spell
        /// </summary>
        /// <param name="target">target that gets the effect</param>
        /// <param name="effectiveness">factor from 0..1 (0%-100%)</param>
        public override void ApplyEffectOnTarget(GameLiving target, double effectiveness)
        {
            INpcTemplate template = NpcTemplateMgr.GetTemplate(Spell.LifeDrainReturn);

            if (template == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.WarnFormat("NPC template {0} not found! Spell: {1}", Spell.LifeDrainReturn, Spell.ToString());
                }
                MessageToCaster("NPC template " + Spell.LifeDrainReturn + " not found!", eChatType.CT_System);
                return;
            }

            GameSpellEffect effect = CreateSpellEffect(target, effectiveness);

            IControlledBrain brain = null;

            if (template.ClassType != null && template.ClassType.Length > 0)
            {
                Assembly asm = Assembly.GetExecutingAssembly();
                brain = (IControlledBrain)asm.CreateInstance(template.ClassType, true);

                if (brain == null && log.IsWarnEnabled)
                {
                    log.Warn($"ApplyEffectOnTarget(): ClassType {template.ClassType} on NPCTemplateID {template.TemplateId} not found, using default ControlledBrain");
                }
            }
            if (brain == null)
            {
                brain = GetPetBrain(Caster);
            }

            m_pet = GetGamePet(template);
            //brain.WalkState = eWalkState.Stay;
            m_pet.SetOwnBrain(brain as AI.ABrain);

            m_pet.SummonSpellDamage = Spell.Damage;
            m_pet.SummonSpellValue  = Spell.Value;

            int    x, y, z;
            ushort heading;
            Region region;

            GetPetLocation(out x, out y, out z, out heading, out region);

            m_pet.X             = x;
            m_pet.Y             = y;
            m_pet.Z             = z;
            m_pet.Heading       = heading;
            m_pet.CurrentRegion = region;

            m_pet.CurrentSpeed = 0;
            m_pet.Realm        = Caster.Realm;

            if (m_isSilent)
            {
                m_pet.IsSilent = true;
            }

            m_pet.AddToWorld();

            //Check for buffs
            if (brain is ControlledNpcBrain)
            {
                (brain as ControlledNpcBrain).CheckSpells(StandardMobBrain.eCheckSpellType.Defensive);
            }

            AddHandlers();

            SetBrainToOwner(brain);

            m_pet.SetPetLevel();
            m_pet.Health = m_pet.MaxHealth;

            if (DOL.GS.ServerProperties.Properties.PET_SCALE_SPELL_MAX_LEVEL > 0)
            {
                m_pet.Spells = template.Spells;                 // Have to scale spells again now that the pet level has been assigned
            }
            effect.Start(m_pet);

            Caster.OnPetSummoned(m_pet);
        }
Example #46
0
		public override void LoadTemplate(INpcTemplate template)
		{
			base.LoadTemplate(template);

			if (string.IsNullOrEmpty(template.ItemsListTemplateID) == false)
			{
				TradeItems = new MerchantTradeItems(template.ItemsListTemplateID);
			}
		}
Example #47
0
 protected override GamePet GetGamePet(INpcTemplate template)
 {
     return new TheurgistPet(template);
 }
Example #48
0
 public SummonElementalPet(INpcTemplate npcTemplate) : base(npcTemplate)
 {
 }
Example #49
0
 public GameHastener(INpcTemplate template) : base(template)
 {
 }
Example #50
0
 public TurretPet(INpcTemplate template)
     : base(template)
 {
 }
Example #51
0
        /// <summary>
        /// Load from Database override to clone objects from original Region.
        /// Loads Objects, Mobs, Areas from Database using "SkinID"
        /// </summary>
        public override void LoadFromDatabase(Mob[] mobObjs, ref long mobCount, ref long merchantCount, ref long itemCount, ref long bindCount)
        {
            if (!LoadObjects)
            {
                return;
            }

            Assembly gasm       = Assembly.GetAssembly(typeof(GameServer));
            var      staticObjs = GameServer.Database.SelectObjects <WorldObject>("`Region` = @Region", new QueryParameter("@Region", Skin));
            var      areaObjs   = GameServer.Database.SelectObjects <DBArea>("`Region` = @Region", new QueryParameter("@Region", Skin));

            int count = mobObjs.Length + staticObjs.Count;

            if (count > 0)
            {
                PreAllocateRegionSpace(count + 100);
            }

            int myItemCount     = staticObjs.Count;
            int myMobCount      = 0;
            int myMerchantCount = 0;

            string allErrors = string.Empty;

            if (mobObjs.Length > 0)
            {
                foreach (Mob mob in mobObjs)
                {
                    GameNPC myMob = null;
                    string  error = string.Empty;

                    // Default Classtype
                    string classtype = ServerProperties.Properties.GAMENPC_DEFAULT_CLASSTYPE;

                    // load template if any
                    INpcTemplate template = null;
                    if (mob.NPCTemplateID != -1)
                    {
                        template = NpcTemplateMgr.GetTemplate(mob.NPCTemplateID);
                    }

                    if (mob.Guild.Length > 0 && mob.Realm >= 0 && mob.Realm <= (int)eRealm._Last)
                    {
                        Type type = ScriptMgr.FindNPCGuildScriptClass(mob.Guild, (eRealm)mob.Realm);
                        if (type != null)
                        {
                            try
                            {
                                myMob = (GameNPC)type.Assembly.CreateInstance(type.FullName);
                            }
                            catch (Exception e)
                            {
                                if (log.IsErrorEnabled)
                                {
                                    log.Error("LoadFromDatabase", e);
                                }
                            }
                        }
                    }

                    if (myMob == null)
                    {
                        if (template != null && template.ClassType != null && template.ClassType.Length > 0 && template.ClassType != Mob.DEFAULT_NPC_CLASSTYPE && template.ReplaceMobValues)
                        {
                            classtype = template.ClassType;
                        }
                        else if (!string.IsNullOrWhiteSpace(mob.ClassType) && mob.ClassType != Mob.DEFAULT_NPC_CLASSTYPE)
                        {
                            classtype = mob.ClassType;
                        }

                        try
                        {
                            myMob = (GameNPC)gasm.CreateInstance(classtype, false);
                        }
                        catch
                        {
                            error = classtype;
                        }

                        if (myMob == null)
                        {
                            foreach (Assembly asm in ScriptMgr.Scripts)
                            {
                                try
                                {
                                    myMob = (GameNPC)asm.CreateInstance(classtype, false);
                                    error = string.Empty;
                                }
                                catch
                                {
                                    error = classtype;
                                }

                                if (myMob != null)
                                {
                                    break;
                                }
                            }

                            if (myMob == null)
                            {
                                myMob = new GameNPC();
                                error = classtype;
                            }
                        }
                    }

                    if (!allErrors.Contains(error))
                    {
                        allErrors += $" {error},";
                    }

                    if (myMob != null)
                    {
                        try
                        {
                            Mob clone = (Mob)mob.Clone();
                            clone.AllowAdd    = false;
                            clone.AllowDelete = false;
                            clone.Region      = ID;

                            myMob.LoadFromDatabase(clone);

                            if (myMob is GameMerchant)
                            {
                                myMerchantCount++;
                            }
                            else
                            {
                                myMobCount++;
                            }
                        }
                        catch (Exception e)
                        {
                            if (log.IsErrorEnabled)
                            {
                                log.Error($"Failed: {myMob.GetType().FullName}:LoadFromDatabase({mob.GetType().FullName});", e);
                            }

                            throw;
                        }

                        myMob.AddToWorld();
                    }
                }
            }

            if (staticObjs.Count > 0)
            {
                foreach (WorldObject item in staticObjs)
                {
                    WorldObject itemclone = (WorldObject)item.Clone();
                    itemclone.AllowAdd    = false;
                    itemclone.AllowDelete = false;
                    itemclone.Region      = ID;

                    GameStaticItem myItem;
                    if (!string.IsNullOrEmpty(itemclone.ClassType))
                    {
                        myItem = gasm.CreateInstance(itemclone.ClassType, false) as GameStaticItem;
                        if (myItem == null)
                        {
                            foreach (Assembly asm in ScriptMgr.Scripts)
                            {
                                try
                                {
                                    myItem = (GameStaticItem)asm.CreateInstance(itemclone.ClassType, false);
                                }
                                catch { }

                                if (myItem != null)
                                {
                                    break;
                                }
                            }

                            if (myItem == null)
                            {
                                myItem = new GameStaticItem();
                            }
                        }
                    }
                    else
                    {
                        myItem = new GameStaticItem();
                    }

                    myItem.AddToWorld();
                }
            }

            int areaCnt = 0;

            // Add missing area
            foreach (DBArea area in areaObjs)
            {
                // Don't bind in instance.
                if (area.ClassType.Equals("DOL.GS.Area+BindArea"))
                {
                    continue;
                }

                // clone DB object.
                DBArea newDBArea = (DBArea)area.Clone();
                newDBArea.AllowAdd = false;
                newDBArea.Region   = ID;

                // Instantiate Area with cloned DB object and add to region
                try
                {
                    AbstractArea newArea = (AbstractArea)gasm.CreateInstance(newDBArea.ClassType, false);
                    newArea.LoadFromDatabase(newDBArea);
                    newArea.Sound        = newDBArea.Sound;
                    newArea.CanBroadcast = newDBArea.CanBroadcast;
                    newArea.CheckLOS     = newDBArea.CheckLOS;
                    AddArea(newArea);
                    areaCnt++;
                }
                catch
                {
                    log.Warn($"area type {area.ClassType} cannot be created, skipping");
                    continue;
                }
            }

            if (myMobCount + myItemCount + myMerchantCount > 0)
            {
                if (log.IsInfoEnabled)
                {
                    log.Info($"AdventureWingInstance: {Description} ({ID}) loaded {myMobCount} mobs, {myMerchantCount} merchants, {myItemCount} items, {areaCnt}/{areaObjs.Count} areas from DB ({TimeManager.Name})");
                }

                log.Debug($"Used Memory: {GC.GetTotalMemory(false) / 1024 / 1024}MB");

                if (allErrors != string.Empty)
                {
                    log.Error($"Error loading the following NPC ClassType(s), GameNPC used instead:{allErrors.TrimEnd(',')}");
                }

                Thread.Sleep(0);  // give up remaining thread time to other resources
            }

            mobCount      += myMobCount;
            merchantCount += myMerchantCount;
            itemCount     += myItemCount;
        }
Example #52
0
        public GameTaxi(INpcTemplate templateid) : base(templateid)
        {
            BlankBrain brain = new BlankBrain();

            SetOwnBrain(brain);
        }
Example #53
0
 public Doppelganger(INpcTemplate template) : base(template)
 {
 }
Example #54
0
		public TheurgistPet(INpcTemplate npcTemplate) : base(npcTemplate) { }
 public TraitorDaggerPet(INpcTemplate npcTemplate) : base(npcTemplate)
 {
 }