/// <summary> /// Buys an item off a housing merchant. If the list has been customized then this must be modified to /// match that customized list. /// </summary> /// <param name="player"></param> /// <param name="slot"></param> /// <param name="count"></param> /// <param name="merchantType"></param> public virtual void BuyHousingItem(GamePlayer player, ushort slot, byte count, DOL.GS.PacketHandler.eMerchantWindowType merchantType) { MerchantTradeItems items = null; switch (merchantType) { case eMerchantWindowType.HousingInsideShop: items = HouseTemplateMgr.IndoorShopItems; break; case eMerchantWindowType.HousingOutsideShop: items = HouseTemplateMgr.OutdoorShopItems; break; case eMerchantWindowType.HousingBindstoneHookpoint: items = HouseTemplateMgr.IndoorBindstoneShopItems; break; case eMerchantWindowType.HousingCraftingHookpoint: items = HouseTemplateMgr.IndoorCraftShopItems; break; case eMerchantWindowType.HousingNPCHookpoint: items = HouseTemplateMgr.IndoorNPCShopItems; break; case eMerchantWindowType.HousingVaultHookpoint: items = HouseTemplateMgr.IndoorVaultShopItems; break; } GameMerchant.OnPlayerBuy(player, slot, count, items); }
private void Awake() { if (instance == null) { instance = this; } else if (instance != null && instance != this) { Destroy(this); return; } DontDestroyOnLoad(this); }
/// <summary> /// Called whenever the NPC's body sends something to its brain. /// </summary> /// <param name="e">The event that occured.</param> /// <param name="sender">The source of the event.</param> /// <param name="args">The event details.</param> public override void Notify(DOL.Events.DOLEvent e, object sender, EventArgs args) { // When we get the WalkTo event we start running towards the target // location; once we've arrived we'll tell our master. If someone // attacks us before we can get to the target location, we'll do what // any other mob would do. base.Notify(e, sender, args); if (e == GameNPCEvent.WalkTo && m_state == State.Passive) m_state = State.GettingHelp; else if (e == GameNPCEvent.ArriveAtTarget && m_state == State.GettingHelp) { if (Master != null && Master.Brain != null) Master.Brain.Notify(GameNPCEvent.ArriveAtTarget, this.Body, new EventArgs()); m_state = State.Aggressive; } else if (e == GameNPCEvent.TakeDamage) m_state = State.Aggressive; }
private void UnsafeAddToListWithDistanceCheck( SubNodeElement startElement, int x, int y, int z, uint sqRadius, int typeIndex, int subZoneIndex, ArrayList partialList, DOL.GS.Collections.Hashtable inZoneElements, DOL.GS.Collections.Hashtable outOfZoneElements, bool ignoreZ) { // => check all distances for all objects in the subzone SubNodeElement currentElement = startElement.next; SubNodeElement elementToRemove = null; GameObject currentObject = null; do { currentObject = currentElement.data; if (ShouldElementMove(currentElement, typeIndex, subZoneIndex, inZoneElements, outOfZoneElements)) { elementToRemove = currentElement; currentElement = currentElement.next; elementToRemove.Remove(); if (log.IsDebugEnabled) { log.Debug("Zone" + ID + ": " + ((currentObject != null) ? "object " + currentObject.ObjectID : "ghost object") + " removed for subzone"); } } else { if (CheckSquareDistance(x, y, z, currentObject.X, currentObject.Y, currentObject.Z, sqRadius, ignoreZ) && !partialList.Contains(currentObject)) { // the current object exists, is Active and still in the current subzone // moreover it is in the right range and not yet in the result set // => add it partialList.Add(currentObject); } currentElement = currentElement.next; } } while (currentElement != startElement); }
private bool ShouldElementMove(SubNodeElement currentElement, int typeIndex, int subZoneIndex, DOL.GS.Collections.Hashtable inZoneElements, DOL.GS.Collections.Hashtable outOfZoneElements) { if (!m_initialized) InitializeZone(); bool removeElement = true; GameObject currentObject = currentElement.data; if ((currentObject != null) && (((int)currentObject.ObjectState) == (int)GameObject.eObjectState.Active) && (currentObject.CurrentRegion == ZoneRegion)) { // the current object exists, is Active and still in the Region where this Zone is located int currentElementSubzoneIndex = GetSubZoneIndex(currentObject.X, currentObject.Y); if (currentElementSubzoneIndex == -1) { // the object has moved in another Zone in the same Region ArrayList movedElements = (ArrayList)outOfZoneElements[typeIndex]; if (movedElements == null) { movedElements = new ArrayList(); outOfZoneElements[typeIndex] = movedElements; } movedElements.Add(currentElement); Interlocked.Decrement(ref m_objectCount); } else { // the object is still inside this Zone if (removeElement = (currentElementSubzoneIndex != subZoneIndex)) { // it has changed of subzone SubNodeElement newSubZoneStartElement = m_subZoneElements[currentElementSubzoneIndex][typeIndex]; ArrayList movedElements = (ArrayList)inZoneElements[newSubZoneStartElement]; if (movedElements == null) { movedElements = new ArrayList(); inZoneElements[newSubZoneStartElement] = movedElements; } // make it available for relocation movedElements.Add(currentElement); } } } else { // ghost object // => remove it Interlocked.Decrement(ref m_objectCount); } return removeElement; }
private void PlaceElementsInZone(DOL.GS.Collections.Hashtable elements) { DOL.GS.Collections.DictionaryEntry currentEntry = null; ArrayList currentList = null; SubNodeElement currentStartElement = null; SubNodeElement currentElement = null; IEnumerator entryEnumerator = elements.GetEntryEnumerator(); while (entryEnumerator.MoveNext()) { currentEntry = (DOL.GS.Collections.DictionaryEntry)entryEnumerator.Current; currentStartElement = (SubNodeElement)currentEntry.key; currentList = (ArrayList)currentEntry.value; lock (currentStartElement) { for (int i = 0; i < currentList.Count; i++) { currentElement = (SubNodeElement)currentList[i]; currentStartElement.PushBack(currentElement); } } } }
private void PlaceElementsInOtherZones(DOL.GS.Collections.Hashtable elements) { DOL.GS.Collections.DictionaryEntry currentEntry = null; int currentType = 0; ArrayList currentList = null; Zone currentZone = null; SubNodeElement currentElement = null; IEnumerator entryEnumerator = elements.GetEntryEnumerator(); while (entryEnumerator.MoveNext()) { currentEntry = (DOL.GS.Collections.DictionaryEntry)entryEnumerator.Current; currentType = (int)currentEntry.key; currentList = (ArrayList)currentEntry.value; for (int i = 0; i < currentList.Count; i++) { currentElement = (SubNodeElement)currentList[i]; currentZone = ZoneRegion.GetZone(currentElement.data.X, currentElement.data.Y); if (currentZone != null) { currentZone.ObjectEnterZone((eGameObjectType)currentType, currentElement); } } } }
public void SendCheckLOS(GameObject Checker, GameObject Target, DOL.GS.PacketHandler.CheckLOSResponse callback) { }
/// <summary> /// Process events. /// </summary> /// <param name="e"></param> /// <param name="sender"></param> /// <param name="args"></param> public override void Notify(DOL.Events.DOLEvent e, object sender, EventArgs args) { base.Notify(e, sender, args); if (e == GameNPCEvent.PetSpell) { PetSpellEventArgs petSpell = (PetSpellEventArgs)args; bool hadQueuedSpells = false; if (SpellsQueued) { MessageToOwner(LanguageMgr.GetTranslation((Owner as GamePlayer).Client.Account.Language, "AI.Brain.Necromancer.CastSpellAfterAction", Body.Name), eChatType.CT_System); hadQueuedSpells = true; } AddToSpellQueue(petSpell.Spell, petSpell.SpellLine, petSpell.Target); // immediate casts are ok if we're not doing anything else if (hadQueuedSpells == false && Body.AttackState == false && Body.IsCasting == false) { CheckSpellQueue(); } } else if (e == GameLivingEvent.Dying) { // At necropet Die, we check DamageRvRMemory for transfer it to owner if necessary. GamePlayer playerowner = GetPlayerOwner(); if (playerowner != null && Body.DamageRvRMemory > 0) { playerowner.DamageRvRMemory = Body.DamageRvRMemory; } return; } else if (e == GameLivingEvent.CastFinished) { // Remove the spell that has finished casting from the queue, if // there are more, keep casting. RemoveSpellFromQueue(); AttackMostWanted(); if (SpellsQueued) { DebugMessageToOwner("+ Cast finished, more spells to cast"); } else { DebugMessageToOwner("- Cast finished, no more spells to cast"); } Owner.Notify(GamePlayerEvent.CastFinished, Owner, args); if (SpellsQueued && Body.CurrentRegion.Time - Body.LastAttackedByEnemyTick > 5 * 1000) { CheckSpellQueue(); } } else if (e == GameLivingEvent.CastFailed) { // Tell owner why cast has failed. switch ((args as CastFailedEventArgs).Reason) { case CastFailedEventArgs.Reasons.TargetTooFarAway: MessageToOwner(LanguageMgr.GetTranslation((Owner as GamePlayer).Client.Account.Language, "AI.Brain.Necromancer.ServantFarAwayToCast"), eChatType.CT_SpellResisted); break; case CastFailedEventArgs.Reasons.TargetNotInView: MessageToOwner(LanguageMgr.GetTranslation((Owner as GamePlayer).Client.Account.Language, "AI.Brain.Necromancer.PetCantSeeTarget", Body.Name), eChatType.CT_SpellResisted); break; case CastFailedEventArgs.Reasons.NotEnoughPower: RemoveSpellFromQueue(); MessageToOwner(LanguageMgr.GetTranslation((Owner as GamePlayer).Client.Account.Language, "AI.Brain.Necromancer.NoPower", Body.Name), eChatType.CT_SpellResisted); break; } } else if (e == GameLivingEvent.CastSucceeded) { // The spell will cast. PetSpellEventArgs spellArgs = args as PetSpellEventArgs; GameLiving target = spellArgs.Target; SpellLine spellLine = spellArgs.SpellLine; if (spellArgs != null && spellArgs.Spell != null) DebugMessageToOwner(String.Format("Now casting '{0}'", spellArgs.Spell.Name)); // This message is for spells from the spell queue only, so suppress // it for insta cast buffs coming from the pet itself. if (spellLine.Name != (Body as NecromancerPet).PetInstaSpellLine) { Owner.Notify(GameLivingEvent.CastStarting, Body, new CastingEventArgs(Body.CurrentSpellHandler)); MessageToOwner(LanguageMgr.GetTranslation((Owner as GamePlayer).Client.Account.Language, "AI.Brain.Necromancer.PetCastingSpell", Body.Name), eChatType.CT_System); } // If pet is casting an offensive spell and is not set to // passive, put target on its aggro list; that way, even with // no attack directive from the owner it will start an attack // after the cast has finished. if (target != Body && spellArgs.Spell.Target == "Enemy") { if (target != null) { if (!Body.AttackState && AggressionState != eAggressionState.Passive) { (Body as NecromancerPet).DrawWeapon(); AddToAggroList(target, 1); } } } } else if (e == GameNPCEvent.SwitchedTarget && sender == Body.TargetObject && sender is GameNPC && !(sender as GameNPC).IsCrowdControlled) { // Target has started attacking someone else. if (Body.EffectList.GetOfType<TauntEffect>() != null) (Body as NecromancerPet).Taunt(); } else if (e == GameNPCEvent.AttackFinished) { Owner.Notify(GamePlayerEvent.AttackFinished, Owner, args); } else if (e == GameNPCEvent.OutOfTetherRange) { // Pet past its tether, update effect icon (remaining time) and send // warnings to owner at t = 10 seconds and t = 5 seconds. int secondsRemaining = (args as TetherEventArgs).Seconds; SetTetherTimer(secondsRemaining); if (secondsRemaining == 10) MessageToOwner(LanguageMgr.GetTranslation((Owner as GamePlayer).Client.Account.Language, "AI.Brain.Necromancer.PetTooFarBeLostSecIm", secondsRemaining), eChatType.CT_System); else if (secondsRemaining == 5) MessageToOwner(LanguageMgr.GetTranslation((Owner as GamePlayer).Client.Account.Language, "AI.Brain.Necromancer.PetTooFarBeLostSec", secondsRemaining), eChatType.CT_System); } else if (e == GameNPCEvent.PetLost) { // Pet despawn is imminent, notify owner. MessageToOwner(LanguageMgr.GetTranslation((Owner as GamePlayer).Client.Account.Language, "AI.Brain.Necromancer.HaveLostBondToPet"), eChatType.CT_System); } }
public virtual GameStaticItem PlaceHousingInteriorItem(DOL.GS.Housing.House house, ItemTemplate item, IPoint3D location, ushort heading) { GameStaticItem hookpointObject = new GameStaticItem(); hookpointObject.CurrentHouse = house; hookpointObject.InHouse = true; hookpointObject.OwnerID = item.Id_nb; hookpointObject.X = location.X; hookpointObject.Y = location.Y; hookpointObject.Z = location.Z; hookpointObject.Heading = heading; hookpointObject.CurrentRegionID = house.RegionID; hookpointObject.Name = item.Name; hookpointObject.Model = (ushort)item.Model; hookpointObject.AddToWorld(); return hookpointObject; }
public override void OnSpellPulse(DOL.GS.Effects.PulsingSpellEffect effect) { SendCastAnimation(); base.OnSpellPulse(effect); }
public Boolean registerCreateScriptExtension(DOL.Tools.QuestDesigner.QuestDesignerConfiguration.Transformator transformator) { ToolStripMenuItem exportMenuItem = new ToolStripMenuItem(); exportMenuItem.Enabled = transformator.Enabled; exportMenuItem.Name = "QuestToolStripMenuItem" + Utils.ConvertToObjectName(transformator.Name) + this.createToolStripMenuItem.DropDownItems.Count; //exportMenuItem.Size = new System.Drawing.Size(156, 22); exportMenuItem.Text = transformator.Name; exportMenuItem.ToolTipText = transformator.Description; exportMenuItem.Tag = transformator; exportMenuItem.Click += new EventHandler(exportMenuItem_Click); this.createToolStripMenuItem.DropDownItems.Add(exportMenuItem); // add link label for active transformators if (transformator.Enabled) { LinkLabel exportLinkLabel = new LinkLabel(); exportLinkLabel.AutoSize = true; exportLinkLabel.Image = global::DOL.Tools.QuestDesigner.Properties.Resources.create; exportLinkLabel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; exportLinkLabel.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline; exportLinkLabel.Location = new System.Drawing.Point(5, 48 + (this.xpTGActions.Controls.Count * 20)); exportLinkLabel.Name = "linkLabelExport" + transformator.Name; exportLinkLabel.Padding = new System.Windows.Forms.Padding(18, 2, 0, 2); exportLinkLabel.Text = String.Format(Resources.lblExportTransformator, transformator.Name); exportLinkLabel.Tag = transformator; exportLinkLabel.LinkClicked += new LinkLabelLinkClickedEventHandler(exportLinkLabel_LinkClicked); this.xpTGActions.Controls.Add(exportLinkLabel); this.xpTGActions.Height = 48 + (this.xpTGActions.Controls.Count * 20); this.xpTGQuestPart.Location = new Point(this.xpTGQuestPart.Location.X, this.xpTGActions.Location.Y + this.xpTGActions.Height + 20); } return true; }
public SQLExporter(DOL.Tools.QuestDesigner.QuestDesignerConfiguration.Transformator transformator) : base(transformator) { }
/// <summary> /// Called whenever the dragon's body sends something to its brain. /// </summary> /// <param name="e">The event that occured.</param> /// <param name="sender">The source of the event.</param> /// <param name="args">The event details.</param> public override void Notify(DOL.Events.DOLEvent e, object sender, EventArgs args) { base.Notify(e, sender, args); if (sender == Body) { GameDragon dragon = sender as GameDragon; if (e == GameObjectEvent.TakeDamage) { if (CheckHealth()) return; // Someone hit the dragon. If the attacker is in melee range, there // is a chance the dragon will cast a debuff specific to melee // classes on him, if not, well, dragon will try to get its Glare off... GameObject source = (args as TakeDamageEventArgs).DamageSource; if (source != null) { if (dragon.IsWithinRadius(source, dragon.AttackRange)) { dragon.CheckMeleeDebuff(source as GamePlayer); } else { dragon.CheckGlare(source as GamePlayer); } } else { log.Error("Dragon takes damage from null source. args = " + (args == null ? "null" : args.ToString())); } } else if (e == GameLivingEvent.EnemyHealed) { // Someone healed an enemy. If the healer is in melee range, there // is a chance the dragon will cast a debuff specific to ranged // classes on him, if not, there's still Glare... GameObject source = (args as EnemyHealedEventArgs).HealSource; if (source != null) { if (dragon.IsWithinRadius(source, dragon.AttackRange)) { dragon.CheckRangedDebuff(source as GamePlayer); } else { dragon.CheckGlare(source as GamePlayer); } } else { log.Error("Dragon heal source null. args = " + (args == null ? "null" : args.ToString())); } } } else if (e == GameNPCEvent.ArriveAtTarget && sender != null) { // Message from another NPC, such as a retriever, // for example. log.Info(String.Format("DragonBrain.Notify: ArriveAtTarget({0})", (sender as GameObject).Name)); (Body as GameDragon).OnRetrieverArrived(sender as GameNPC); } }
private void UnsafeAddToListWithoutDistanceCheck(SubNodeElement startElement, int typeIndex, int subZoneIndex, ArrayList partialList, DOL.GS.Collections.Hashtable inZoneElements, DOL.GS.Collections.Hashtable outOfZoneElements) { SubNodeElement currentElement = startElement.next; SubNodeElement elementToRemove = null; GameObject currentObject = null; do { currentObject = currentElement.data; if (ShouldElementMove(currentElement, typeIndex, subZoneIndex, inZoneElements, outOfZoneElements)) { elementToRemove = currentElement; currentElement = currentElement.next; elementToRemove.Remove(); if (log.IsDebugEnabled) { log.Debug("Zone" + ID + ": " + ((currentObject != null) ? "object " + currentObject.ObjectID : "ghost object") + " removed for subzone"); } } else { // the current object exists, is Active and still in the current subzone // => add it if (!partialList.Contains(currentObject)) { partialList.Add(currentObject); } currentElement = currentElement.next; } } while (currentElement != startElement); }
/// <summary> /// Get a housing hookpoint NPC /// </summary> /// <param name="house"></param> /// <param name="templateID"></param> /// <param name="heading"></param> /// <param name="index"></param> /// <returns></returns> public virtual GameNPC PlaceHousingNPC(DOL.GS.Housing.House house, ItemTemplate item, IPoint3D location, ushort heading) { NpcTemplate npcTemplate = NpcTemplateMgr.GetTemplate(item.Bonus); try { string defaultClassType = ServerProperties.Properties.GAMENPC_DEFAULT_CLASSTYPE; if (npcTemplate == null || string.IsNullOrEmpty(npcTemplate.ClassType)) { log.Warn("[Housing] null classtype in hookpoint attachment, using GAMENPC_DEFAULT_CLASSTYPE instead"); } else { defaultClassType = npcTemplate.ClassType; } var npc = (GameNPC)Assembly.GetAssembly(typeof(GameServer)).CreateInstance(defaultClassType, false); if (npc == null) { foreach (Assembly asm in ScriptMgr.Scripts) { npc = (GameNPC)asm.CreateInstance(defaultClassType, false); if (npc != null) break; } } if (npc == null) { HouseMgr.log.Error("[Housing] Can't create instance of type: " + defaultClassType); return null; } npc.Model = 0; if (npcTemplate != null) { npc.LoadTemplate(npcTemplate); } else { npc.Size = 50; npc.Level = 50; npc.GuildName = "No Template Found"; } if (npc.Model == 0) { // defaults if templates are missing if (house.Realm == eRealm.Albion) { npc.Model = (ushort)Util.Random(7, 8); } else if (house.Realm == eRealm.Midgard) { npc.Model = (ushort)Util.Random(160, 161); } else { npc.Model = (ushort)Util.Random(309, 310); } } // always set the npc realm to the house model realm npc.Realm = house.Realm; npc.Name = item.Name; npc.CurrentHouse = house; npc.InHouse = true; npc.OwnerID = item.Id_nb; npc.X = location.X; npc.Y = location.Y; npc.Z = location.Z; npc.Heading = heading; npc.CurrentRegionID = house.RegionID; if ((npc.Flags & GameNPC.eFlags.PEACE) == 0) { npc.Flags ^= GameNPC.eFlags.PEACE; } npc.AddToWorld(); return npc; } catch (Exception ex) { log.Error("Error filling housing hookpoint using npc template ID " + item.Bonus, ex); } return null; }
/// <summary> /// Send merchant window containing housing items that can be purchased by a player. If this list is customized /// then the customized list must also be handled in BuyHousingItem /// </summary> /// <param name="player"></param> /// <param name="merchantType"></param> public virtual void SendHousingMerchantWindow(GamePlayer player, DOL.GS.PacketHandler.eMerchantWindowType merchantType) { switch (merchantType) { case eMerchantWindowType.HousingInsideShop: player.Out.SendMerchantWindow(HouseTemplateMgr.IndoorShopItems, eMerchantWindowType.HousingInsideShop); break; case eMerchantWindowType.HousingOutsideShop: player.Out.SendMerchantWindow(HouseTemplateMgr.OutdoorShopItems, eMerchantWindowType.HousingOutsideShop); break; case eMerchantWindowType.HousingBindstoneHookpoint: player.Out.SendMerchantWindow(HouseTemplateMgr.IndoorBindstoneShopItems, eMerchantWindowType.HousingBindstoneHookpoint); break; case eMerchantWindowType.HousingCraftingHookpoint: player.Out.SendMerchantWindow(HouseTemplateMgr.IndoorCraftShopItems, eMerchantWindowType.HousingCraftingHookpoint); break; case eMerchantWindowType.HousingNPCHookpoint: player.Out.SendMerchantWindow(HouseTemplateMgr.IndoorNPCShopItems, eMerchantWindowType.HousingNPCHookpoint); break; case eMerchantWindowType.HousingVaultHookpoint: player.Out.SendMerchantWindow(HouseTemplateMgr.IndoorVaultShopItems, eMerchantWindowType.HousingVaultHookpoint); break; default: player.Out.SendMessage("Unknown merchant type!", eChatType.CT_Staff, eChatLoc.CL_SystemWindow); log.ErrorFormat("Unknown merchant type {0}", merchantType); break; } }
public override bool ReceiveItem(GameLiving source, DOL.Database.InventoryItem item) { //todo check if bullet return base.ReceiveItem(source, item); }
public void SendCheckLOS(GameObject source, GameObject target, DOL.GS.PacketHandler.CheckLOSMgrResponse callback) { }