示例#1
0
		public WeakMulticastDelegate GetEventDelegate(DOLEvent e)
		{
			if (_events.ContainsKey(e))
				return _events[e];

			return null;
		}
示例#2
0
		public static void OnScriptCompiled(DOLEvent e, object sender, EventArgs args)
		{
			// Desactivated
			if (ServerProperties.Properties.STATSAVE_INTERVAL == -1)
				return;
			
			try
			{
				m_systemCpuUsedCounter = new PerformanceCounter("Processor", "% processor time", "_total");
				m_systemCpuUsedCounter.NextValue();
			}
			catch (Exception ex)
			{
				m_systemCpuUsedCounter = null;
				if (log.IsWarnEnabled)
					log.Warn(ex.GetType().Name + " SystemCpuUsedCounter won't be available: " + ex.Message);
			}
			try
			{
				m_processCpuUsedCounter = new PerformanceCounter("Process", "% processor time", GetProcessCounterName());
				m_processCpuUsedCounter.NextValue();
			}
			catch (Exception ex)
			{
				m_processCpuUsedCounter = null;
				if (log.IsWarnEnabled)
					log.Warn(ex.GetType().Name + " ProcessCpuUsedCounter won't be available: " + ex.Message);
			}
			// 1 min * INTERVAL
			m_statFrequency *= ServerProperties.Properties.STATSAVE_INTERVAL;
			lock (typeof(StatSave))
			{
				m_timer = new Timer(new TimerCallback(SaveStats), null, INITIAL_DELAY, Timeout.Infinite);
			}
		}
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_QUESTS)
                return;
            if (log.IsInfoEnabled)
                log.Info("Quest \"" + questTitle + "\" initializing ...");

            #region defineNPCS

            GameNPC[] npcs = WorldMgr.GetNPCsByName("Sir Dorian", eRealm.Albion);

            if (npcs.Length == 0)
            {
                sirDorian = new GameNPC();
                sirDorian.Model = 28;
                sirDorian.Name = "Sir Dorian";
                if (log.IsWarnEnabled)
                    log.Warn("Could not find " + sirDorian.Name + ", creating him ...");
                //k109: My preference, no guildname for quest NPCs.  Uncomment if you like that...
                //sirDorian.GuildName = "Part of " + questTitle + " Quest";
                sirDorian.Realm = eRealm.Albion;
                sirDorian.CurrentRegionID = 1;

                GameNpcInventoryTemplate template = new GameNpcInventoryTemplate();
                template.AddNPCEquipment(eInventorySlot.HandsArmor, 49);
                template.AddNPCEquipment(eInventorySlot.FeetArmor, 50);
                template.AddNPCEquipment(eInventorySlot.TorsoArmor, 46);
                template.AddNPCEquipment(eInventorySlot.LegsArmor, 47);
                template.AddNPCEquipment(eInventorySlot.ArmsArmor, 48);
                sirDorian.Inventory = template.CloseTemplate();
                sirDorian.SwitchWeapon(GameLiving.eActiveWeaponSlot.Standard);

                sirDorian.Size = 52;
                sirDorian.Level = 40;
                sirDorian.X = 560869;
                sirDorian.Y = 511737;
                sirDorian.Z = 2344;
                sirDorian.Heading = 2930;

                if (SAVE_INTO_DATABASE)
                    sirDorian.SaveIntoDatabase();

                sirDorian.AddToWorld();
            }
            else
                sirDorian = npcs[0];

            #endregion defineNPCS

            GameEventMgr.AddHandler(GamePlayerEvent.AcceptQuest, new DOLEventHandler(SubscribeQuest));
            GameEventMgr.AddHandler(GamePlayerEvent.DeclineQuest, new DOLEventHandler(SubscribeQuest));

            GameEventMgr.AddHandler(sirDorian, GameLivingEvent.Interact, new DOLEventHandler(TalkTosirDorian));
            GameEventMgr.AddHandler(sirDorian, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkTosirDorian));

            sirDorian.AddQuestToGive(typeof(DredgeUpAPledge));

            if (log.IsInfoEnabled)
                log.Info("Quest \"" + questTitle + "\" initialized");
        }
示例#4
0
        private void OnAttack(DOLEvent e, object sender, EventArgs arguments)
        {
            GameLiving living = sender as GameLiving;
            if (living == null) return;
            InventoryItem shield = living.Inventory.GetItem(eInventorySlot.LeftHandWeapon);
            if (shield == null)
                return;
            if (shield.Object_Type != (int)eObjectType.Shield)
                return;
            if (living.TargetObject == null)
                return;
            if (living.ActiveWeaponSlot == GameLiving.eActiveWeaponSlot.Distance)
                return;
            if (living.AttackWeapon.Hand == 1)
                return;
            AttackedByEnemyEventArgs attackedByEnemy = arguments as AttackedByEnemyEventArgs;
            AttackData ad = null;
            if (attackedByEnemy != null)
                ad = attackedByEnemy.AttackData;
            if (ad.Attacker.Realm == 0)
                return;

            if (ad.Damage < 1)
                return;

            int absorb = (int)(ad.Damage * 0.9);
            int critic = (int)(ad.CriticalDamage * 0.9);
            ad.Damage -= absorb;
            ad.CriticalDamage -= critic;
            if (living is GamePlayer)
                ((GamePlayer)living).Out.SendMessage("Your Testudo Stance reduces the damage by " + (absorb + critic) + " points", eChatType.CT_Spell, eChatLoc.CL_SystemWindow);
            if (ad.Attacker is GamePlayer)
                ((GamePlayer)ad.Attacker).Out.SendMessage(living.Name + "'s Testudo Stance reducec your damage by " + (absorb + critic) + " points", eChatType.CT_Spell, eChatLoc.CL_SystemWindow);
        }
示例#5
0
 public static void OnScriptUnloaded(DOLEvent e, object sender, EventArgs args)
 {
     if (!ServerProperties.Properties.LOAD_EXAMPLES)
         return;
     GameEventMgr.RemoveHandler(DatabaseEvent.CharacterCreated, new DOLEventHandler(DOLTestCharacterCreation));
     GameEventMgr.RemoveHandler(GamePlayerEvent.GameEntered, new DOLEventHandler(DOLTestPlayerEnterWorld));
 }
        /// <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, Body, new EventArgs());
                }

                m_state = State.Aggressive;
            }
            else if (e == GameNPCEvent.TakeDamage)
            {
                m_state = State.Aggressive;
            }
        }
示例#7
0
        /// <summary>
        /// Triggered When New Character is Created.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public static void OnCharacterCreation(DOLEvent e, object sender, EventArgs args)
        {
            // Check Args
            var chArgs = args as CharacterEventArgs;

            if (chArgs == null)
                return;

            DOLCharacters ch = chArgs.Character;

            // Add all Crafting skills at level 1
            var collectionAllCraftingSkills = new List<string>();
            foreach (int craftingSkillId in Enum.GetValues(typeof(eCraftingSkill)))
            {
                if (craftingSkillId > 0)
                {
                    collectionAllCraftingSkills.Add(string.Format("{0}|1", craftingSkillId));
                    if (craftingSkillId == (int)eCraftingSkill._Last)
                        break;
                }
            }

            // Set Primary Skill to Basic.
            ch.SerializedCraftingSkills = string.Join(";", collectionAllCraftingSkills);
            ch.CraftingPrimarySkill = (int)eCraftingSkill.BasicCrafting;
        }
示例#8
0
        public static void OnScriptCompiled(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_EXAMPLES)
                return;
            //We want to be notified whenever a new character is created
            GameEventMgr.AddHandler(DatabaseEvent.CharacterCreated, new DOLEventHandler(DOLTestCharacterCreation));
            //We want to be notified whenever a player enters the world
            GameEventMgr.AddHandler(GamePlayerEvent.GameEntered, new DOLEventHandler(DOLTestPlayerEnterWorld));

            /* Not yet ;-)
            NonEnterableArea area1 = new NonEnterableArea("Teleport Area", 535405, 479515, 0, 2000);
            area1.Mode = eNonEnterableAreaMode.Teleport;
            NonEnterableArea area2 = new NonEnterableArea("Damage Area", 538405, 479515, 0, 2000);
            area2.Mode = eNonEnterableAreaMode.Damage;
            NonEnterableArea area3 = new NonEnterableArea("Instant Kill Area", 540405, 479515, 0, 2000);
            area3.Mode = eNonEnterableAreaMode.InstantKill;

            WorldMgr.GetRegion(1).AddArea(area1);
            WorldMgr.GetRegion(1).AddArea(area2);
            WorldMgr.GetRegion(1).AddArea(area3);
            */
            //Output success message
            if (log.IsInfoEnabled)
                log.Info("DOLTestServer initialized");
        }
示例#9
0
		public static void OnServerStarted(DOLEvent e, object sender, EventArgs args)
		{
			if (ServerProperties.Properties.LOAD_HOOKPOINTS)
			{
				/*string name,byte gold,byte silver,byte copper,ushort icon,string objectType,ushort flag*/
				HookPointInventory.RedHPInventory.AddFirstFreeSlot(new HookPointItem("Melee Guard", 67, 2624, "DOL.GS.Keeps.GuardFighter", 0));
				HookPointInventory.RedHPInventory.AddFirstFreeSlot(new HookPointItem("Ranged Guard", 67, 2623, "DOL.GS.Keeps.GuardStaticArcher", 0));
				HookPointInventory.RedHPInventory.AddFirstFreeSlot(new HookPointItem("Healer Guard", 67, 2628, "DOL.GS.Keeps.GuardHealer", 0));
				HookPointInventory.RedHPInventory.AddFirstFreeSlot(new HookPointItem("Caster Guard", 67, 2625, "DOL.GS.Keeps.GuardStaticCaster", 0));
				HookPointInventory.RedHPInventory.AddFirstFreeSlot(new HookPointItem("Stealther Guard", 67, 2627, "DOL.GS.Keeps.GuardStealther", 0));

				HookPointInventory.GreenHPInventory.AddFirstFreeSlot(new HookPointItem("Palintone", 50, 0x0A2C, "DOL.GS.GameSiegeCatapult", 0x4100));
				HookPointInventory.GreenHPInventory.AddFirstFreeSlot(new HookPointItem("Trebuchet", 20, 0x0A22, "DOL.GS.GameSiegeTrebuchet", 0x4B00));

				HookPointInventory.LightGreenHPInventory.AddFirstFreeSlot(new HookPointItem("Ballista", 20, 0x0A2C, "DOL.GS.GameSiegeBallista", 0x4b00));

				HookPointInventory.YellowHPInventory.AddFirstFreeSlot(new HookPointItem("Boiling Oil", 70, 0x0A40, "DOL.GS.GameSiegeCauldron", 0x2800));

				/*
				HookPointInventory.BlueHPInventory.AddFirstFreeSlot(new HookPointItem("Healer", 10, 0x0A40, "DOL.GS.GameHealer", 0));
				HookPointInventory.BlueHPInventory.AddFirstFreeSlot(new HookPointItem("Hastener", 10, 0x0A40, "DOL.GS.GameHastener", 0));
				HookPointInventory.BlueHPInventory.AddFirstFreeSlot(new HookPointItem("BlackSmith", 1, 0x0A40, "DOL.GS.Blacksmith", 0));
				HookPointInventory.BlueHPInventory.AddFirstFreeSlot(new HookPointItem("Dye Master", 1, 0x0A40, "DOL.GS.GameKeepGuard", 0));
				HookPointInventory.BlueHPInventory.AddFirstFreeSlot(new HookPointItem("Arrow Merchant", 1, 0x0A40, "DOL.GS.GameKeepGuard", 0));
				HookPointInventory.BlueHPInventory.AddFirstFreeSlot(new HookPointItem("Poison Merchant", 1, 0x0A40, "DOL.GS.GameKeepGuard", 0));
				*/
			}
		}
        /// <summary>
        /// Handler fired on every melee attack by effect target
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="arguments"></param>
        protected void EventHandler(DOLEvent e, object sender, EventArgs arguments)
        {
            AttackFinishedEventArgs atkArgs = arguments as AttackFinishedEventArgs;
            if (atkArgs == null) return;
            if (atkArgs.AttackData.AttackResult != GameLiving.eAttackResult.HitUnstyled
                && atkArgs.AttackData.AttackResult != GameLiving.eAttackResult.HitStyle) return;
            if (atkArgs.AttackData.Target == null) return;
            GameLiving target = atkArgs.AttackData.Target;
            if (target == null) return;
            if (target.ObjectState != GameObject.eObjectState.Active) return;
            if (target.IsAlive == false) return;
            GameLiving attacker = sender as GameLiving;
            if (attacker == null) return;
            if (attacker.ObjectState != GameObject.eObjectState.Active) return;
            if (attacker.IsAlive == false) return;
            if (atkArgs.AttackData.IsOffHand) return; // only react to main hand
            if (atkArgs.AttackData.Weapon == null) return; // no weapon attack

            int modifier = 100;
            //double dpsCap = (1.2 + 0.3 * attacker.Level) * 0.7;
            //double dps = Math.Min(atkArgs.AttackData.Weapon.DPS_AF/10.0, dpsCap);
            double baseDamage = atkArgs.AttackData.Weapon.DPS_AF / 10.0 *
                                atkArgs.AttackData.WeaponSpeed;

            modifier += (int)(25 * atkArgs.AttackData.Target.GetConLevel(atkArgs.AttackData.Attacker));
            modifier = Math.Min(300, modifier);
            modifier = Math.Max(75, modifier);

            double damage = baseDamage * modifier * 0.001; // attack speed is 10 times higher (2.5spd=25)
            double damageResisted = damage * target.GetResist(eDamageType.Body) * -0.01;

            AttackData ad = new AttackData();
            ad.Attacker = attacker;
            ad.Target = target;
            ad.Damage = (int)(damage + damageResisted);
            ad.Modifier = (int)damageResisted;
            ad.DamageType = eDamageType.Body;
            ad.AttackType = AttackData.eAttackType.MeleeOneHand;
            ad.AttackResult = GameLiving.eAttackResult.HitUnstyled;
            ad.WeaponSpeed = atkArgs.AttackData.WeaponSpeed;

            GamePlayer owner = attacker as GamePlayer;
            if (owner != null)
            {
                owner.Out.SendMessage(LanguageMgr.GetTranslation(owner.Client, "Effects.TripleWieldEffect.MBHitsExtraDamage", target.GetName(0, false), ad.Damage), eChatType.CT_Spell, eChatLoc.CL_SystemWindow);
                GamePlayer playerTarget = target as GamePlayer;
                if (playerTarget != null)
                {
                    owner.Out.SendMessage(LanguageMgr.GetTranslation(owner.Client, "Effects.TripleWieldEffect.XMBExtraDamageToYou", attacker.GetName(0, false), ad.Damage), eChatType.CT_Spell, eChatLoc.CL_SystemWindow);
                }
            }

            target.OnAttackedByEnemy(ad);
            attacker.DealDamage(ad);

            foreach (GamePlayer player in ad.Attacker.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
            {
                player.Out.SendCombatAnimation(null, target, 0, 0, 0, 0, 0x0A, target.HealthPercent);
            }
        }
示例#11
0
 public static void OnScriptLoaded(DOLEvent e, object sender, EventArgs args)
 {
     GameEventMgr.AddHandler(DatabaseEvent.CharacterCreated, new DOLEventHandler(CharacterCreation));
     InitOldStartLocations();
     if (log.IsInfoEnabled)
         log.Info("StartupLocations initialized");
 }
示例#12
0
		private static void PlayerQuit(DOLEvent e, object sender, EventArgs arguments)
		{
			GamePlayer player = sender as GamePlayer;
			if (player == null) return;

			player.Out.SendXFireInfo(0);
		}
示例#13
0
        private void OnAttack(DOLEvent e, object sender, EventArgs arguments)
        {
            GameLiving living = sender as GameLiving;
            if (living == null) return;
            AttackedByEnemyEventArgs attackedByEnemy = arguments as AttackedByEnemyEventArgs;
            AttackData ad = null;
            if (attackedByEnemy != null)
                ad = attackedByEnemy.AttackData;

            //			Log.DebugFormat("sender:{0} res:{1} IsMelee:{2} Type:{3}", living.Name, ad.AttackResult, ad.IsMeleeAttack, ad.AttackType);

            if (ad == null || (ad.AttackResult != GameLiving.eAttackResult.HitStyle && ad.AttackResult != GameLiving.eAttackResult.HitUnstyled))
                return;
            if (!ad.IsMeleeAttack && ad.AttackType != AttackData.eAttackType.Ranged)
                return;

            //default is 50%
            double absorbPercent = 50;
            //But if the buff has a specified spell damage, use that as the percent.
            if (Spell.Damage > 0)
                absorbPercent = Spell.Damage;

            if (absorbPercent > 100)
                absorbPercent = 100;
            //This only absorbs style damage.
            int damageAbsorbed = (int)(0.01 * absorbPercent * (ad.StyleDamage));

            ad.Damage -= damageAbsorbed;

            OnDamageAbsorbed(ad, damageAbsorbed);

            //TODO correct messages
            MessageToLiving(ad.Target, string.Format("Your style absorbtion absorbs {0} damage!", damageAbsorbed), eChatType.CT_Spell);
            MessageToLiving(ad.Attacker, string.Format("A barrier absorbs {0} damage of your attack!", damageAbsorbed), eChatType.CT_Spell);
        }
示例#14
0
        public override void Notify(DOLEvent e, object sender, EventArgs args)
        {
            if (e == AreaEvent.PlayerEnter)
            {
                AreaEventArgs kargs = args as AreaEventArgs;

                if (m_owner is GamePlayer && kargs.GameObject != m_owner)
                    return;

                foreach (AbstractArea area in kargs.GameObject.CurrentAreas)
                {
                    if (area is KeepArea && (area as KeepArea).Keep == m_keep)
                    {
                        FinishMission();
                        break;
                    }
                }
            }
            else if (e == KeepEvent.KeepTaken)
            {
                KeepEventArgs kargs = args as KeepEventArgs;

                if (kargs.Keep != m_keep)
                    return;

                ExpireMission();
            }
        }
示例#15
0
		public void PlayerQuit(DOLEvent e, object sender, EventArgs arguments)
		{
			GamePlayer player = sender as GamePlayer;
			if (player == null) return;		
			lock(player.Inventory)
			{
                InventoryItem item = player.Inventory.GetFirstItemByID("arrow_summoning1", eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack);
				while (item != null)
				{
					player.Inventory.RemoveItem(item);
                    item = player.Inventory.GetFirstItemByID("arrow_summoning1", eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack);
				}
                item = player.Inventory.GetFirstItemByID("arrow_summoning2", eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack);
				while (item != null)
				{
					player.Inventory.RemoveItem(item);
                    item = player.Inventory.GetFirstItemByID("arrow_summoning2", eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack);
				}
                item = player.Inventory.GetFirstItemByID("arrow_summoning3", eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack);
				while (item != null)
				{
					player.Inventory.RemoveItem(item);
                    item = player.Inventory.GetFirstItemByID("arrow_summoning3", eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack);
				}
			}
		}
示例#16
0
		private void OnAttack(DOLEvent e, object sender, EventArgs arguments)
		{
			GameLiving living = sender as GameLiving;
			if (living == null) return;
			AttackedByEnemyEventArgs attackedByEnemy = arguments as AttackedByEnemyEventArgs;
			AttackData ad = null;
			if (attackedByEnemy != null)
				ad = attackedByEnemy.AttackData;

			if (ad.Damage + ad.CriticalDamage < 1)
				return;

			int heal = ad.Damage + ad.CriticalDamage;
			ad.Damage = 0;
			ad.CriticalDamage = 0;
			GamePlayer player = living as GamePlayer;
			GamePlayer attackplayer = ad.Attacker as GamePlayer;
			if (attackplayer != null)
				attackplayer.Out.SendMessage(living.Name + "'s druidic powers absorb your attack!", eChatType.CT_SpellResisted, eChatLoc.CL_SystemWindow);
			int modheal = living.MaxHealth - living.Health;
			if (modheal > heal)
				modheal = heal;
			living.Health += modheal;
			if (player != null)
				player.Out.SendMessage("Your druidic powers convert your enemies attack and heal you for " + modheal + "!", eChatType.CT_Spell, eChatLoc.CL_SystemWindow);

		}
示例#17
0
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_EXAMPLES)
                return;

            #region defineNPCs

            GameNPC[] npcs = WorldMgr.GetNPCsByName("Sir Quait", eRealm.Albion);
            npcs = WorldMgr.GetNPCsByName("Sir Quait", (eRealm)1);
            GameNPC SirQuait = null;
            if (npcs.Length == 0)
            {
                SirQuait = new DOL.GS.GameNPC();
                SirQuait.Model = 40;
                SirQuait.Name = "Sir Quait";
                if (log.IsWarnEnabled)
                    log.Warn("Could not find " + SirQuait.Name + ", creating ...");
                SirQuait.Realm = eRealm.Albion;
                SirQuait.CurrentRegionID = 1;
                SirQuait.Size = 50;
                SirQuait.Level = 10;
                SirQuait.MaxSpeedBase = 100;
                SirQuait.Faction = FactionMgr.GetFactionByID(0);
                SirQuait.X = 531971;
                SirQuait.Y = 478955;
                SirQuait.Z = 0;
                SirQuait.Heading = 3570;
                SirQuait.RespawnInterval = 0;
                SirQuait.BodyType = 0;

                StandardMobBrain brain = new StandardMobBrain();
                brain.AggroLevel = 0;
                brain.AggroRange = 0;
                SirQuait.SetOwnBrain(brain);

                SirQuait.AddToWorld();
            }
            else
            {
                SirQuait = npcs[0];
            }

            #endregion defineNPCs

            #region defineBehaviours

            BaseBehaviour b = new BaseBehaviour(SirQuait);
            MessageAction a = new MessageAction(SirQuait, "This is just a simple test bahaviour.", eTextType.Emote);
            b.AddAction(a);
            InteractTrigger t = new InteractTrigger(SirQuait, b.NotifyHandler, SirQuait);
            b.AddTrigger(t);

            // store the behaviour in a list so it won't be garbage collected
            behaviours.Add(b);

            #endregion defineBehaviours

            log.Info("Simple Test Behaviour added");
        }
示例#18
0
        /// <summary>
        /// Called when a player leaves the game
        /// </summary>
        /// <param name="e">The event which was raised</param>
        /// <param name="sender">Sender of the event</param>
        /// <param name="args">EventArgs associated with the event</param>
        protected void PlayerLeftWorld(DOLEvent e, object sender, EventArgs args)
        {
			GamePlayer player = sender as GamePlayer;

			SoldiersCitadelEffect SoldiersCitadel = player.EffectList.GetOfType<SoldiersCitadelEffect>();
			if (SoldiersCitadel != null)
				SoldiersCitadel.Cancel(false);
		}
        public void EventAction(DOLEvent e, object sender, EventArgs args)
        {
            GameLiving player = sender as GameLiving;

            if (player == null) return;
            MessageToCaster("You lose your concentration!", eChatType.CT_SpellExpires);
            RemoveEffect();
        }
示例#20
0
 protected virtual void PlayerLeftWorld(DOLEvent e, object sender, EventArgs args)
 {
     GamePlayer player = (GamePlayer)sender;
     if (this.m_caster == player)
     {
         currentTick = (int)m_lifeTime;
     }
 }
		public static void OnScriptCompiled(DOLEvent e, object sender, EventArgs args)
		{
            GameEventMgr.AddHandler(DatabaseEvent.CharacterCreated, new DOLEventHandler(AddNewbieToStarterGuild));

            if (!STARTING_GUILD)
                return;
            
            CheckStartupGuilds();            
		}
示例#22
0
 public static void OnScriptUnloaded(DOLEvent e, object sender, EventArgs args)
 {
     if (!ServerProperties.Properties.LOAD_EXAMPLES)
         return;
     //To stop this event, we simply delete
     //(remove from world completly) the npc
     if (m_npc != null)
         m_npc.Delete();
 }
示例#23
0
		public static void OnScriptCompiled(DOLEvent e, object sender, EventArgs args)
		{
			foreach (eRealm currentRealm in Enum.GetValues(typeof(eRealm)))
			{
				if (currentRealm == eRealm.None ||currentRealm == eRealm.Door)
					continue;
				CheckGuild(currentRealm,LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Guild.StartupGuild."+GlobalConstants.RealmToName (currentRealm)));
			}
		}
示例#24
0
        /// <summary>
        /// Level Up Event for Triggering Respec Gifts
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public static void OnLevelUp(DOLEvent e, object sender, EventArgs args)
        {
            var player = sender as GamePlayer;

            if (player == null)
                return;

            // Graveen: give a DOL respec on the GIVE_DOL_RESPEC_ON_LEVELS levels
            foreach (string str in GIVE_DOL_RESPEC_AT_LEVEL.SplitCSV(true))
            {
                byte level_respec = 0;

                if(!byte.TryParse(str, out level_respec))
                    level_respec = 0;

                if (player.Level == level_respec)
                {
                    int oldAmount = player.RespecAmountDOL;
                    player.RespecAmountDOL++;

                    if (oldAmount != player.RespecAmountDOL)
                    {
                        player.Out.SendMessage(string.Format("As you reached level {0}, you are awarded a DOL (full) respec!", player.Level), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                    }
                }
            }

            // Fixed Level Respecs
            switch (player.Level)
            {
                    // full respec on level 5 since 1.70
                case 5:
                    player.RespecAmountAllSkill++;
                    player.IsLevelRespecUsed = false;
                    break;
                case 6:
                    if (player.IsLevelRespecUsed) break;
                    player.RespecAmountAllSkill--;
                    break;

                    // single line respec
                case 20:
                case 40:
                    {
                        player.RespecAmountSingleSkill++; // Give character their free respecs at 20 and 40
                        player.IsLevelRespecUsed = false;
                        break;
                    }
                case 21:
                case 41:
                    {
                        if (player.IsLevelRespecUsed) break;
                        player.RespecAmountSingleSkill--; // Remove free respecs if it wasn't used
                        break;
                    }
            }
        }
示例#25
0
		/// <summary>
		/// Called when a player leaves the game
		/// </summary>
		/// <param name="e">The event which was raised</param>
		/// <param name="sender">Sender of the event</param>
		/// <param name="args">EventArgs associated with the event</param>
		private static void PlayerLeftWorld(DOLEvent e, object sender, EventArgs args)
		{
			GamePlayer player = (GamePlayer)sender;

			BarrierOfFortitudeEffect BoFEffect = player.EffectList.GetOfType<BarrierOfFortitudeEffect>();
			if (BoFEffect != null)
			{
				BoFEffect.Cancel(false);
			}
		}
示例#26
0
		private static void PlayerEntered(DOLEvent e, object sender, EventArgs arguments)
		{
			GamePlayer player = sender as GamePlayer;
			if (player == null) return;
			//			if (player.IsAnonymous) return; TODO check /anon and xfire
			byte flag = 0;
			if (player.DBCharacter.ShowXFireInfo)
				flag = 1;
			player.Out.SendXFireInfo(flag);
		}
示例#27
0
        /// <summary>
        /// Processes events coming from the timer.
        /// </summary>
        /// <param name="e"></param>
        public override void Notify(DOLEvent e)
        {
            if (e is EmoteEvent)
            {
                DoRandomEmote();
                return;
            }

            base.Notify(e);
        }
示例#28
0
        public static void OnScriptCompiled(DOLEvent e, object sender, EventArgs args)
        {
            if (ServerProperties.Properties.ENABLE_MINOTAUR_RELICS)
            {
                if (log.IsDebugEnabled)
                    log.Debug("Minotaur Relics manager initialized");

                Init();
            }
		}
		/// <summary>
		/// Called when a player leaves the game
		/// </summary>
		/// <param name="e">The event which was raised</param>
		/// <param name="sender">Sender of the event</param>
		/// <param name="args">EventArgs associated with the event</param>
		private static void PlayerLeftWorld(DOLEvent e, object sender, EventArgs args)
		{
			GamePlayer player = (GamePlayer)sender;

			AdrenalineRushEffect SPEffect = player.EffectList.GetOfType<AdrenalineRushEffect>();
			if (SPEffect != null)
			{
				SPEffect.Cancel(false);
			}
		}
示例#30
0
		public static void OnScriptUnloaded(DOLEvent e, object sender, EventArgs args)
		{
			if (!ServerProperties.Properties.DISABLE_APPEALSYSTEM)
			{
				GameEventMgr.RemoveHandler(GamePlayerEvent.GameEntered, new DOLEventHandler(PlayerEnter));
				GameEventMgr.RemoveHandler(GamePlayerEvent.Quit, new DOLEventHandler(PlayerQuit));
				GameEventMgr.RemoveHandler(GamePlayerEvent.Linkdeath, new DOLEventHandler(PlayerQuit));
				RunTask(null);
			}
		}
 /// <summary>
 /// The event callback.
 /// </summary>
 /// <param name="e">The event fired.</param>
 /// <param name="sender">The event sender.</param>
 /// <param name="arguments">The event arguments.</param>
 protected override void EventCallback(DOLEvent e, object sender, EventArgs arguments)
 {
     GamePlayer p = sender as GamePlayer;
     if (p != null && p.Titles.Contains(this))
     {
         p.UpdateCurrentTitle();
         return;
     }
     base.EventCallback(e, sender, arguments);
 }
示例#32
0
 /// <summary>
 /// Registers a single object event handler.
 /// The global event handlers will be called for ALL events,
 /// so use them wisely, they might incure a big performance
 /// hit if used unwisely.
 /// If an equal handler has already been added, nothing will be done
 /// </summary>
 /// <param name="e">The event type to register for</param>
 /// <param name="del">The event handler to register for this event type</param>
 /// <exception cref="ArgumentNullException">If one of the parameters is null</exception>
 public static void AddHandlerUnique(object obj, DOLEvent e, DOLEventHandler del)
 {
     AddHandler(obj, e, del, true);
 }
示例#33
0
 /// <summary>
 /// Registers a single local event handler.
 /// Local event handlers will only be called if the
 /// "sender" parameter in the Notify method equals
 /// the object for which a local event handler was
 /// registered.
 /// </summary>
 /// <remarks>
 /// Certain events will never have a local event handler.
 /// This happens if the Notify method is called without
 /// a sender parameter for example!
 /// </remarks>
 /// <param name="obj">The object that needs to be the sender of events</param>
 /// <param name="e">The event type to register for</param>
 /// <param name="del">The event handler to register for this event type</param>
 /// <exception cref="ArgumentNullException">If one of the parameters is null</exception>
 public static void AddHandler(object obj, DOLEvent e, DOLEventHandler del)
 {
     AddHandler(obj, e, del, false);
 }
示例#34
0
        /// <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);
            }
        }
示例#35
0
 /// <summary>
 /// Registers a single global event handler.
 /// The global event handlers will be called for ALL events,
 /// so use them wisely, they might incure a big performance
 /// hit if used unwisely.
 /// If an equal handler has already been added, nothing will be done
 /// </summary>
 /// <param name="e">The event type to register for</param>
 /// <param name="del">The event handler to register for this event type</param>
 /// <exception cref="ArgumentNullException">If one of the parameters is null</exception>
 public static void AddHandlerUnique(DOLEvent e, DOLEventHandler del)
 {
     AddHandler(e, del, true);
 }
示例#36
0
        /// <summary>
        /// Registers a single local event handler.
        /// Local event handlers will only be called if the
        /// "sender" parameter in the Notify method equals
        /// the object for which a local event handler was
        /// registered.
        /// </summary>
        /// <remarks>
        /// Certain events will never have a local event handler.
        /// This happens if the Notify method is called without
        /// a sender parameter for example!
        /// </remarks>
        /// <param name="obj">The object that needs to be the sender of events</param>
        /// <param name="e">The event type to register for</param>
        /// <param name="del">The event handler to register for this event type</param>
        /// <param name="unique">Flag wether event shall be added unique or not</param>
        /// <exception cref="ArgumentNullException">If one of the parameters is null</exception>
        private static void AddHandler(object obj, DOLEvent e, DOLEventHandler del, bool unique)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj), "No object given!");
            }

            if (e == null)
            {
                throw new ArgumentNullException(nameof(e), "No event type given!");
            }

            if (del == null)
            {
                throw new ArgumentNullException(nameof(del), "No event handler given!");
            }

            if (!e.IsValidFor(obj))
            {
                throw new ArgumentException("Object is not valid for this event type", nameof(obj));
            }

            if (Lock.TryEnterUpgradeableReadLock(LOCK_TIMEOUT))
            {
                try
                {
                    DOLEventHandlerCollection col;

                    if (!m_gameObjectEventCollections.TryGetValue(obj, out col))
                    {
                        col = new DOLEventHandlerCollection();

                        if (Lock.TryEnterWriteLock(LOCK_TIMEOUT))
                        {
                            try
                            {
                                m_gameObjectEventCollections.Add(obj, col);
                            }
                            finally
                            {
                                Lock.ExitWriteLock();
                            }
                        }
                        else
                        {
                            log.ErrorFormat("Timeout exceeded on attempt to AddHandler for object: {0}, event: {1}", obj.ToString(), e.Name);
                        }
                    }

                    if (unique)
                    {
                        col.AddHandlerUnique(e, del);
                    }
                    else
                    {
                        col.AddHandler(e, del);
                    }
                }
                finally
                {
                    Lock.ExitUpgradeableReadLock();
                }
            }
        }
示例#37
0
 /// <summary>
 /// Notifies all global event handlers of the occurance
 /// of a specific event type with some event arguments.
 /// </summary>
 /// <param name="e">The event type that occured</param>
 /// <param name="args">The event arguments</param>
 /// <exception cref="ArgumentNullException">If no event type given</exception>
 public static void Notify(DOLEvent e, EventArgs args)
 {
     Notify(e, null, args);
 }
示例#38
0
 /// <summary>
 /// Notifies all global and local event handlers of the occurance
 /// of a specific event type.
 /// </summary>
 /// <param name="e">The event type that occured</param>
 /// <param name="sender">The sender of this event</param>
 /// <exception cref="ArgumentNullException">If no event type given</exception>
 public static void Notify(DOLEvent e, object sender)
 {
     Notify(e, sender, null);
 }
        public override void Notify(DOL.Events.DOLEvent e, object sender, EventArgs args)
        {
            base.Notify(e, sender, args);

            // Some interesting events we might want to respond to:
            //GameObjectEvent.TakeDamage
            //GameLivingEvent.AttackedByEnemy
            //GameLivingEvent.AttackFinished
            //GameLivingEvent.Dying
            //GameLivingEvent.EnemyKilled
            //GameLivingEvent.Moving
            //GameNPCEvent.TurnTo
            //GameNPCEvent.TurnToHeading

            if (sender != Body)
            {
                return;
            }

            if (e == GameLivingEvent.AttackFinished)
            {
                AttackData ad = (args as AttackFinishedEventArgs).AttackData;

                m_lastAD             = ad;
                m_style              = StyleChooser.GetBestStyle(Body, m_lastAD, m_targetLastAD);
                Body.NextCombatStyle = m_style;

                GameLiving target = ad.Target;

                // Maneuvering may fail if the target is up against a wall or something - then again, mobs can generally walk through walls
                // Let it fail? Or maneuver closer (say, 5 units instead of 65)?
                if (m_style != null && m_style.OpeningRequirementType == Style.eOpening.Positional)
                {
                    float   angle = target.GetAngle(Body);
                    Point2D positionalPoint;

                    switch (m_style.OpeningRequirementValue)
                    {
                    case (int)Style.eOpeningPosition.Front:
                        if (!(angle >= 315 || angle < 45))
                        {
                            positionalPoint = target.GetPointFromHeading(Body.Heading, 65);
                            Body.WalkTo(positionalPoint.X, positionalPoint.Y, target.Z, 1250);
                        }
                        break;

                    case (int)Style.eOpeningPosition.Side:
                        if (!(angle >= 45 && angle < 150) && !(angle >= 210 && angle < 315))
                        {
                            positionalPoint = target.GetPointFromHeading((ushort)(target.Heading + (110.0 * (4096.0 / 360.0))), 65);
                            Body.WalkTo(positionalPoint.X, positionalPoint.Y, target.Z, 1250);
                        }
                        break;

                    case (int)Style.eOpeningPosition.Back:
                        if (!(angle >= 150 && angle < 210))
                        {
                            positionalPoint = target.GetPointFromHeading((ushort)((target.Heading + 2048) & 0xFFF), 65);
                            Body.WalkTo(positionalPoint.X, positionalPoint.Y, target.Z, 1250);
                        }
                        break;
                    }

                    Body.TurnTo(target);
                }

                // mobs often "forget" to wield their weapon after getting stunned - this is an attempt to get them to wield it
                if (m_style != null)
                {
                    if (Body.ActiveWeaponSlot == GameLiving.eActiveWeaponSlot.TwoHanded && Body.Inventory != null && Body.Inventory.GetItem(eInventorySlot.TwoHandWeapon) != null)
                    {
                        Body.SwitchWeapon(GameLiving.eActiveWeaponSlot.TwoHanded);
                    }
                    else
                    {
                        Body.SwitchWeapon(GameLiving.eActiveWeaponSlot.Standard);
                    }
                }
            }
            else
            {
                base.Notify(e, sender, args);
            }
        }
示例#40
0
 /// <summary>
 /// Notifies all global event handlers of the occurance of a specific
 /// event type.
 /// </summary>
 /// <param name="e">The event type that occured</param>
 /// <exception cref="ArgumentNullException">If no event type given</exception>
 public static void Notify(DOLEvent e)
 {
     Notify(e, null, null);
 }
示例#41
0
        /// <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);
            }
        }
示例#42
0
 /// <summary>
 /// Registers a single global event handler.
 /// The global event handlers will be called for ALL events,
 /// so use them wisely, they might incure a big performance
 /// hit if used unwisely.
 /// </summary>
 /// <param name="e">The event type to register for</param>
 /// <param name="del">The event handler to register for this event type</param>
 /// <exception cref="ArgumentNullException">If one of the parameters is null</exception>
 public static void AddHandler(DOLEvent e, DOLEventHandler del)
 {
     AddHandler(e, del, false);
 }