public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); //Version 0 if (version >= 0) { m_ArenaGroupController = (ArenaGroupController)reader.ReadItem(); m_Tournament = (ArenaTournament)reader.ReadItem(); m_Creator = (PlayerMobile)reader.ReadMobile(); m_CreationDate = reader.ReadDateTime(); m_MatchStatus = (MatchStatusType)reader.ReadInt(); m_Ruleset = (ArenaRuleset)reader.ReadItem(); m_ArenaFight = (ArenaFight)reader.ReadItem(); int m_TeamsCount = reader.ReadInt(); for (int a = 0; a < m_TeamsCount; a++) { m_Teams.Add(reader.ReadItem() as ArenaTeam); } int m_BannedPlayersCount = reader.ReadInt(); for (int a = 0; a < m_BannedPlayersCount; a++) { m_BannedPlayers.Add(reader.ReadMobile() as PlayerMobile); } } }
public void Target(Mobile mobile) { if (!Caster.CanSee(mobile) || mobile.Hidden) { Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (CheckHSequence(mobile)) { SpellHelper.Turn(Caster, mobile); SpellHelper.CheckReflect((int)this.Circle, Caster, ref mobile); if (mobile.Spell != null) { mobile.Spell.OnCasterHurt(); } mobile.Paralyzed = false; bool success = false; if (CheckMagicResist(mobile) && mobile is PlayerMobile) { mobile.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. } else { ApplyEffect(Caster, mobile); success = true; } //Player Enhancement Customization: Venomous bool venomous = false; //PlayerEnhancementPersistance.IsCustomizationEntryActive(Caster, CustomizationType.Venomous); if (venomous) { if (success) { CustomizationAbilities.Venomous(mobile); } else { mobile.FixedParticles(0x374A, 10, 15, 5021, 0, 0, EffectLayer.Waist); mobile.PlaySound(0x474); } } else { mobile.FixedParticles(0x374A, 10, 15, 5021, 0, 0, EffectLayer.Waist); mobile.PlaySound(0x474); } } ArenaFight.SpellCompletion(Caster, typeof(PoisonSpell)); FinishSequence(); }
public ArenaFight CreateArenaFight(ArenaPreFight preFight) { var challengersTeam = new ArenaTeam(TeamEnum.TEAM_CHALLENGER, preFight.Arena.Map.GetRedFightPlacement()); var defendersTeam = new ArenaTeam(TeamEnum.TEAM_DEFENDER, preFight.Arena.Map.GetBlueFightPlacement()); var fight = new ArenaFight(preFight.Id, preFight.Arena.Map, defendersTeam, challengersTeam); AddEntity(fight.Id, fight); return(fight); }
public int OnHit(BaseWeapon weapon, int damage, Mobile attacker) { Mobile owner = this.Parent as Mobile; if (owner == null) { return(damage); } if (DecorativeEquipment) { return(damage); } double successChance = owner.Skills[SkillName.Parry].Value * ShieldParrySkillScalar; if (owner.CheckSkill(SkillName.Parry, successChance, 1.0)) { damage = (int)(Math.Round((double)damage * ShieldParryDamageScalar)); if (damage < 1) { damage = 1; } owner.FixedEffect(0x37B9, 10, 16); if (!ArenaFight.AllowDurabilityImmunity(owner)) { if (Utility.RandomDouble() <= DurabilityLossChance && LootType != LootType.Blessed && MaxHitPoints > 0) { if (HitPoints > 1) { HitPoints--; if (HitPoints == 5) { if (Parent is Mobile) { ((Mobile)Parent).LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061121); // Your equipment is severely damaged. } } } else { Delete(); } } } } return(damage); }
public override void OnMiss(Mobile attacker, Mobile defender) { double arrowChance = 0.4; if (!ArenaFight.AllowFreeConsume(attacker, typeof(Arrow))) { if (attacker.Player && arrowChance >= Utility.RandomDouble()) { Ammo.MoveToWorld(new Point3D(defender.X + Utility.RandomMinMax(-1, 1), defender.Y + Utility.RandomMinMax(-1, 1), defender.Z), defender.Map); } } base.OnMiss(attacker, defender); }
public static bool PlayDrinkEffect(Mobile mobile) { mobile.RevealingAction(); mobile.PlaySound(0x2D6); bool freeConsume = false; bool dropBottle = true; PlayerMobile player = mobile as PlayerMobile; if (ArenaFight.AllowFreeConsume(player, typeof(BasePotion))) { freeConsume = true; dropBottle = false; } //Water Aspect AspectArmorProfile aspectArmorProfile = AspectGear.GetAspectArmorProfile(mobile); if (aspectArmorProfile != null) { if (aspectArmorProfile.m_Aspect == AspectEnum.Water) { double waterAspectChance = AspectGear.WaterChanceForPotionNoConsume * (AspectGear.WaterChanceForPotionNoConsumePerTier * (double)aspectArmorProfile.m_TierLevel); if (Utility.RandomDouble() <= waterAspectChance) { freeConsume = true; dropBottle = false; //TEST: Add Aspect Visual } } } if (dropBottle) { mobile.AddToBackpack(new Bottle()); } if (mobile.Body.IsHuman /*&& !m.Mounted*/) { mobile.Animate(34, 5, 1, true, false, 0); } return(freeConsume); }
protected override void OnTarget(Mobile from, object targeted) { if (m_Potion.Deleted) { return; } bool startTimer = false; if (targeted is Food || targeted is FukiyaDarts || targeted is Shuriken) { startTimer = true; } else if (targeted is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)targeted; if (weapon.Layer == Layer.OneHanded || weapon.Layer == Layer.TwoHanded) { //One-Hand Swords, Fencing startTimer = (weapon.Type == WeaponType.Slashing || weapon.Type == WeaponType.Piercing); } } if (startTimer) { PlayerMobile player = from as PlayerMobile; if (!ArenaFight.AttemptItemUsage(player, m_Potion)) { return; } new InternalTimer(from, (Item)targeted, m_Potion).Start(); from.PlaySound(0x4F); m_Potion.Consume(); from.AddToBackpack(new Bottle()); } else { from.SendLocalizedMessage(502145); // You cannot poison that! You can only poison bladed or piercing weapons, food or drink. } }
public override void OnHit(Mobile attacker, Mobile defender, double damageBonus) { double arrowChance = 0.4; if (!ArenaFight.AllowFreeConsume(attacker, typeof(Arrow))) { if (attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) && arrowChance >= Utility.RandomDouble()) { defender.AddToBackpack(Ammo); } } base.OnHit(attacker, defender, damageBonus); if (!(attacker is PlayerMobile && defender is PlayerMobile)) { AttemptWeaponPoison(attacker, defender); } }
protected override void OnTarget(Mobile from, object targeted) { if (m_Bandage.Deleted) { return; } if (targeted is Mobile) { Mobile target = targeted as Mobile; if (target.Hidden) { from.SendMessage("That cannot be seen."); return; } else if (from.InRange(m_Bandage.GetWorldLocation(), Bandage.Range)) { PlayerMobile playerTarget = targeted as PlayerMobile; if (BandageContext.BeginHeal(from, (Mobile)targeted) != null) { if (!ArenaFight.AllowFreeConsume(from, typeof(Bandage))) { m_Bandage.Consume(); } } } else { from.SendLocalizedMessage(500295); // You are too far away to do that. } } else { from.SendLocalizedMessage(500970); // Bandages can not be used on that. } }
public virtual bool OnFired(Mobile attacker, Mobile defender) { Container pack = attacker.Backpack; if (attacker.Player) { if (!ArenaFight.AllowFreeConsume(attacker, typeof(Arrow))) { if (pack == null || !pack.ConsumeTotal(AmmoType, 1)) { attacker.StealthAttackActive = false; attacker.StealthAttackReady = false; return(false); } } } attacker.MovingEffect(defender, EffectID, 18, 1, false, false); return(true); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); //Version 0 if (version >= 0) { ArenaGroupController = reader.ReadItem() as ArenaGroupController; Enabled = reader.ReadBool(); ArenaBoundary = reader.ReadRect2D(); m_ArenaFight = reader.ReadItem() as ArenaFight; int staticWallsCount = reader.ReadInt(); for (int a = 0; a < staticWallsCount; a++) { m_Walls.Add(reader.ReadItem()); } } //----- m_Instances.Add(this); }
public static bool Mobile_AllowHarmful(Mobile from, Mobile target) { if (from == null || target == null || from.AccessLevel > AccessLevel.Player || target.AccessLevel > AccessLevel.Player) { return(true); } PlayerMobile pm_From = from as PlayerMobile; PlayerMobile pm_Target = target as PlayerMobile; BaseCreature bc_From = from as BaseCreature; BaseCreature bc_Target = target as BaseCreature; PlayerMobile fromRootPlayer = null; PlayerMobile targetRootPlayer = null; if (pm_From != null) { fromRootPlayer = pm_From; } if (pm_Target != null) { targetRootPlayer = pm_Target; } if (bc_From != null) { if (bc_From.ControlMaster is PlayerMobile) { fromRootPlayer = bc_From.ControlMaster as PlayerMobile; } } if (bc_Target != null) { if (bc_Target.ControlMaster is PlayerMobile) { targetRootPlayer = bc_Target.ControlMaster as PlayerMobile; } } #region Arena ArenaGroupController fromArenaGroupController = ArenaGroupController.GetArenaGroupRegionAtLocation(from.Location, from.Map); ArenaGroupController targetArenaGroupController = ArenaGroupController.GetArenaGroupRegionAtLocation(target.Location, target.Map); if (fromArenaGroupController != null || targetArenaGroupController != null) { if (fromRootPlayer != null && targetRootPlayer != null) { ArenaFight fromArenaFight = fromRootPlayer.m_ArenaFight; ArenaFight targetArenaFight = targetRootPlayer.m_ArenaFight; if (fromArenaFight != null && targetArenaFight != null && fromArenaFight == targetArenaFight) { if (fromArenaFight.m_FightPhase == ArenaFight.FightPhaseType.Fight) { if (fromArenaFight.IsWithinArena(from.Location, from.Map) && fromArenaFight.IsWithinArena(target.Location, target.Map)) { return(true); } } } } return(false); } #endregion #region Ress Penalty if (fromRootPlayer != null && targetRootPlayer != null) { if (fromRootPlayer.RessPenaltyExpiration > DateTime.UtcNow && fromRootPlayer.m_RessPenaltyAccountWideAggressionRestriction) { return(false); } } #endregion Map map = from.Map; // Young Players in Felucca if (from.Player && target.Player && (((PlayerMobile)target).Young || ((PlayerMobile)from).Young) && !(target.Criminal || from.Criminal)) { return(false); // Old players cannot attack youngs and vice versa unless young is crim } //Felucca if (map != null && ((map.Rules & MapRules.BeneficialRestrictions) == 0)) { return(true); // In felucca, anything goes. Special case fire dungeon as players can access it in fel or trammel under fel rules } //Other Maps BaseCreature bc = from as BaseCreature; if (!from.Player && !(bc != null && bc.GetMaster() != null && bc.GetMaster().AccessLevel == AccessLevel.Player)) { if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && target is PlayerMobile && ((PlayerMobile)target).CheckYoungProtection(from)) { return(false); } return(true); // Uncontrolled NPCs are only restricted by the young system } if (target is BaseCreature && (((BaseCreature)target).Controlled || (((BaseCreature)target).Summoned && from != ((BaseCreature)target).SummonMaster))) { return(false); // Cannot harm other controlled mobiles } if (target.Player) { return(false); // Cannot harm other players } if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent)) { if (Notoriety.Compute(from, target) == Notoriety.Innocent) { return(false); // Cannot harm innocent mobiles } } return(true); }
public override void OnCast() { if (SpellHelper.CheckTown(Caster, Caster) && CheckSequence()) { List <Mobile> targets = new List <Mobile>(); Map map = Caster.Map; //Player Enhancement Customization: Tremor bool tremor = false; //PlayerEnhancementPersistance.IsCustomizationEntryActive(Caster, CustomizationType.Tremors); bool enhancedSpellcast = SpellHelper.IsEnhancedSpell(Caster, null, EnhancedSpellbookType.Wizard, false, true); Boolean chargedSpellcast = SpellHelper.IsChargedSpell(Caster, null, false, Scroll != null); int range = 1 + (int)(Caster.Skills[SkillName.Magery].Value / 15.0); bool useHeightCheck = true; int maxDifferenceZ = 20; if (map != null) { foreach (Mobile m in Caster.GetMobilesInRange(range)) { int differenceZ = Math.Abs(Caster.Location.Z - m.Location.Z); if (useHeightCheck && (differenceZ >= maxDifferenceZ)) { continue; } if (Caster != m && SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false) && (!Core.AOS || Caster.InLOS(m))) { targets.Add(m); } } } Caster.PlaySound(0x2f3); int baseDamage = Utility.RandomMinMax(20, 25); for (int i = 0; i < targets.Count; ++i) { Mobile mobile = targets[i]; double damage = (double)Utility.RandomMinMax(5, 10); double damageBonus = 0; CheckMagicResist(mobile); if (mobile is PlayerMobile) { damage = (double)mobile.Hits * .6; } else { Boolean isTamedTarget = SpellHelper.IsTamedTarget(Caster, mobile); if (enhancedSpellcast) { if (isTamedTarget) { damageBonus += SpellHelper.EnhancedSpellTamedCreatureBonus; } else { damageBonus += SpellHelper.EnhancedSpellBonus; } } if (chargedSpellcast) { if (isTamedTarget) { damageBonus += SpellHelper.ChargedSpellTamedCreatureBonus; } else { damageBonus += SpellHelper.ChargedSpellBonus; } } mobile.FixedEffect(0x3779, 10, 20); BaseCreature bc_Target = mobile as BaseCreature; PlayerMobile pm_Target = mobile as PlayerMobile; if (bc_Target != null) { if (bc_Target.ShipOccupied != null) { damage *= BaseShip.shipBasedAoESpellDamageToCreatureScalar; } } if (pm_Target != null) { if (pm_Target.ShipOccupied != null) { damage *= BaseShip.shipBasedAoESpellDamageToPlayerScalar; } } damage *= GetDamageScalar(mobile, damageBonus); } Caster.DoHarmful(mobile); SpellHelper.Damage(this, Caster, mobile, damage); } if (tremor) { CustomizationAbilities.Tremor(Caster, range); } } ArenaFight.SpellCompletion(Caster, typeof(EarthquakeSpell)); FinishSequence(); }
public void Target(IPoint3D p) { if (!Caster.CanSee(p)) { Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (BaseShip.FindShipAt(p, Caster.Map) != null) { Caster.SendMessage("That location is blocked."); } else if (SpellHelper.CheckTown(p, Caster) && CheckSequence()) { SpellHelper.Turn(Caster, p); SpellHelper.GetSurfaceTop(ref p); int dx = Caster.Location.X - p.X; int dy = Caster.Location.Y - p.Y; int rx = (dx - dy) * 44; int ry = (dx + dy) * 44; bool eastToWest; if (rx >= 0 && ry >= 0) { eastToWest = false; } else if (rx >= 0) { eastToWest = true; } else if (ry >= 0) { eastToWest = true; } else { eastToWest = false; } Effects.PlaySound(p, Caster.Map, 0x20B); int itemID = eastToWest ? 0x3915 : 0x3922; TimeSpan duration = TimeSpan.FromSeconds(3.0 + (Caster.Skills[SkillName.Magery].Value * 0.4)); bool chargeUsed = false; bool enhancedSpellcast = SpellHelper.IsEnhancedSpell(Caster, null, EnhancedSpellbookType.Warlock, true, true); for (int i = -2; i <= 2; ++i) { Point3D loc = new Point3D(eastToWest ? p.X + i : p.X, eastToWest ? p.Y : p.Y + i, p.Z); PoisonFieldItem item = new PoisonFieldItem(itemID, loc, Caster, Caster.Map, duration, i); if (enhancedSpellcast) { item.m_Enhanced = true; } } } ArenaFight.SpellCompletion(Caster, typeof(PoisonFieldSpell)); FinishSequence(); }
public override void OnDoubleClick(Mobile from) { if (IsDeadFollower) { return; } PlayerMobile player = from as PlayerMobile; if (player == null) { return; } ArenaFight arenaFight = player.m_ActiveInsideArenaFight; if (arenaFight != null) { if (arenaFight.m_ArenaMatch != null) { if (arenaFight.m_ArenaMatch.m_Ruleset != null) { switch (arenaFight.m_ArenaMatch.m_Ruleset.m_MountsRestriction) { case ArenaRuleset.MountsRestrictionType.Allowed: break; case ArenaRuleset.MountsRestrictionType.NotAllowed: from.SendMessage("Rules of this match do not allow mounts."); return; break; } } } } if (from.IsBodyMod && !from.Body.IsHuman) { from.SendLocalizedMessage(1061628); // You can't do that while polymorphed. return; } if (!CheckMountAllowed(from, true)) { return; } if (from.Mounted) { from.SendLocalizedMessage(1005583); // Please dismount first. return; } if (from.Female ? !AllowFemaleRider : !AllowMaleRider) { OnDisallowedRider(from); return; } if (!Multis.DesignContext.Check(from)) { return; } if (from.HasTrade) { from.SendLocalizedMessage(1042317, "", 0x41); // You may not ride at this time return; } if (from.InRange(this, 1)) { bool canAccess = (from.AccessLevel >= AccessLevel.GameMaster) || (Controlled && ControlMaster == from) || (Summoned && SummonMaster == from); if (canAccess) { if (this.Poisoned) { PrivateOverheadMessage(Network.MessageType.Regular, 0x3B2, 1049692, from.NetState); // This mount is too ill to ride. } else { Rider = from; } } else if (!Controlled && !Summoned) { // That mount does not look broken! You would have to tame it to ride it. PrivateOverheadMessage(Network.MessageType.Regular, 0x3B2, 501263, from.NetState); } else { // This isn't your mount; it refuses to let you ride. PrivateOverheadMessage(Network.MessageType.Regular, 0x3B2, 501264, from.NetState); } } else { from.SendLocalizedMessage(500206); // That is too far away to ride. } }
public void Target(Mobile mobile) { if (!Caster.CanSee(mobile) || mobile.Hidden) { Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (CheckHSequence(mobile)) { SpellHelper.Turn(Caster, mobile); SpellHelper.CheckReflect((int)this.Circle, Caster, ref mobile); double duration; if (mobile.Player) { duration = 5 + (Caster.Skills[SkillName.Magery].Value * 0.05); if (CheckMagicResist(mobile)) { duration *= 0.5; } } else { duration = 10.0 + (Caster.Skills[SkillName.Magery].Value * 0.2); if (CheckMagicResist(mobile)) { duration *= 0.75; } } bool enhancedSpellcast = SpellHelper.IsEnhancedSpell(Caster, mobile, EnhancedSpellbookType.Warlock, true, true); int spellHue = 0; AspectArmorProfile defenderAspectArmorProfile = AspectGear.GetAspectArmorProfile(mobile); double airAvoidanceChance = 0; if (defenderAspectArmorProfile != null) { if (defenderAspectArmorProfile.m_Aspect == AspectEnum.Air) { airAvoidanceChance = AspectGear.AirMeleeAvoidMovementEffectAvoidance * (AspectGear.AirMeleeAvoidMovementEffectAvoidancePerTier * (double)defenderAspectArmorProfile.m_TierLevel); } } if (Utility.RandomDouble() <= airAvoidanceChance) { //TEST: Add Aspect Visuals } else if (enhancedSpellcast) { if (mobile.Paralyze(Caster, duration * 5)) { mobile.FixedEffect(0x376A, 10, 30, spellHue, 0); mobile.PlaySound(0x204); } else if (mobile is PlayerMobile) { mobile.FixedEffect(0x376A, 10, 30, spellHue, 0); mobile.PlaySound(0x204); } } else { if (mobile.Paralyze(Caster, duration)) { mobile.FixedEffect(0x376A, 10, 15, spellHue, 0); mobile.PlaySound(0x204); } else if (mobile is PlayerMobile) { mobile.FixedEffect(0x376A, 10, 15, spellHue, 0); mobile.PlaySound(0x204); } } HarmfulSpell(mobile); } ArenaFight.SpellCompletion(Caster, typeof(ParalyzeSpell)); FinishSequence(); }
public void Explode(Mobile from, bool direct, Point3D loc, Map map) { if (Deleted) { return; } // 12/8/13 Xiani - Nullifying an explosion when in an ArenaRegion. //TEST: CHECK THIS if (from.CombatProhibited) { return; } //TEST: CHECK THIS if (!ArenaFight.AllowFreeConsume(from, typeof(BasePotion))) { Consume(); } for (int i = 0; m_Users != null && i < m_Users.Count; ++i) { Mobile m = (Mobile)m_Users[i]; ThrowTarget targ = m.Target as ThrowTarget; if (targ != null && targ.Potion == this) { Target.Cancel(m); } } if (map == null) { return; } Effects.PlaySound(loc, map, 0x207); Effects.SendLocationEffect(loc, map, 0x36BD, 20); int alchemyBonus = 0; IPooledEnumerable eable = LeveledExplosion ? (IPooledEnumerable)map.GetObjectsInRange(loc, ExplosionRange) : (IPooledEnumerable)map.GetMobilesInRange(loc, ExplosionRange); ArrayList toExplode = new ArrayList(); int toDamage = 0; foreach (object o in eable) { if (o is Mobile) { toExplode.Add(o); ++toDamage; } else if (o is BaseExplosionPotion && o != this) { toExplode.Add(o); } if (o is BreakableContainer) { toExplode.Add(o); } if (o is BreakableStatic) { toExplode.Add(o); } } eable.Free(); int min = Scale(from, MinDamage); int max = Scale(from, MaxDamage); int baseDamage = Utility.RandomMinMax(min, max); for (int i = 0; i < toExplode.Count; ++i) { object o = toExplode[i]; double divisor = 0; if (o is Mobile) { Mobile m = (Mobile)o; if (from == null || (SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false))) { if (from != null) { from.DoHarmful(m); } int damage = baseDamage; damage += alchemyBonus; if (m is PlayerMobile) { if (m.InRange(loc, 0)) { divisor = 1; } else if (m.InRange(loc, 1)) { divisor = 2; } else if (m.InRange(loc, 2)) { divisor = 4; } damage = (int)(damage / divisor); if (damage > 40) { damage = 40; } } else { damage = (int)((double)damage * CreatureDamageScalar); } AOS.Damage(m, from, damage, 0, 100, 0, 0, 0); } } else if (o is BaseExplosionPotion) { BaseExplosionPotion pot = (BaseExplosionPotion)o; pot.Explode(from, false, pot.GetWorldLocation(), pot.Map); } else if (o is BreakableContainer) { BreakableContainer breakableContainer = (BreakableContainer)o; if (breakableContainer.ObjectBreakingDeviceDamageScalar == 0) { continue; } baseDamage = (int)((double)baseDamage * CreatureDamageScalar * breakableContainer.ObjectBreakingDeviceDamageScalar); breakableContainer.ReceiveDamage(from, baseDamage, BreakableContainer.InteractionType.ObjectBreakingDevice); } else if (o is BreakableStatic) { BreakableStatic breakableStatic = (BreakableStatic)o; if (breakableStatic.ObjectBreakingDeviceDamageScalar == 0) { continue; } baseDamage = (int)((double)baseDamage * CreatureDamageScalar * breakableStatic.ObjectBreakingDeviceDamageScalar); breakableStatic.ReceiveDamage(from, baseDamage, BreakableStatic.InteractionType.ObjectBreakingDevice); } } }
public bool Cast() { m_StartCastTime = DateTime.UtcNow; if (m_Caster.Player) { PlayerMobile player = m_Caster as PlayerMobile; if (!ArenaFight.AttemptSpellUsage(player, this.GetType())) { return(false); } Item item = m_Caster.FindItemOnLayer(Layer.OneHanded); if (item != null && !(item is Spellbook) && !(item is Runebook) && !(item is BaseWand)) { m_Caster.SendLocalizedMessage(502626); // Your hands must be free to cast spells or meditate return(false); } item = m_Caster.FindItemOnLayer(Layer.TwoHanded); if (item != null && !(item is Spellbook) && !(item is Runebook)) { m_Caster.SendLocalizedMessage(502626); // Your hands must be free to cast spells or meditate return(false); } } if (!m_Caster.CheckAlive()) { return(false); } else if (m_Scroll is BaseWand && m_Caster.Spell != null && m_Caster.Spell.IsCasting) { m_Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen. } else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting) { m_Caster.SendLocalizedMessage(502642); // You are already casting a spell. } else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen || m_Caster.IsHindered())) { m_Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen. } else if (CheckNextSpellTime && DateTime.UtcNow < m_Caster.NextSpellTime) { m_Caster.SendLocalizedMessage(502644); // You have not yet recovered from casting a spell. } else if (m_Caster.Mana >= ScaleMana(GetMana())) { if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this)) { m_State = SpellState.Casting; m_Caster.Spell = this; if (RevealOnCast) { m_Caster.RevealingAction(); } SayMantra(); TimeSpan castDelay = this.GetCastDelay(); int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds); if (ShowHandMovement && m_Caster.Body.IsHuman && m_Caster.Player) { if (count != 0) { m_AnimTimer = new AnimTimer(this, count); m_AnimTimer.Start(); } if (m_Info.LeftHandEffect > 0) { Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand); } if (m_Info.RightHandEffect > 0) { Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand); } } //Creature Casting else if (m_Caster is BaseCreature) { if (count != 0) { BaseCreature creature = m_Caster as BaseCreature; //Animation Duration double castDelayInSeconds = castDelay.TotalSeconds; double spellSpeedSCalar = creature.SpellSpeedScalar; castDelay = castDelay + TimeSpan.FromSeconds(castDelayInSeconds * .4 * spellSpeedSCalar); count = (int)Math.Ceiling((castDelay.TotalSeconds) / AnimateDelay.TotalSeconds); if (count > 0) { m_AnimTimer = new AnimTimer(this, count); m_AnimTimer.Start(); } //Next Spellcast Allowed Delay double speedScalar = 1 + creature.GetSpecialAbilityEntryValue(SpecialAbilityEffect.Cripple); double mageryModifier = 1.0; double experienceModifier = 1.0; if (creature.Controlled && creature.ControlMaster is PlayerMobile) { mageryModifier = 1 / creature.TamedBaseMageryCreationScalar; experienceModifier = 1 - (.20 * creature.GetExperienceScalar()); } double SpellDelay = (creature.SpellDelayMin + ((creature.SpellDelayMax - creature.SpellDelayMin) * Utility.RandomDouble())) * speedScalar * mageryModifier * experienceModifier; if (SpellDelay < .1) { SpellDelay = .1; } creature.NextSpellTime = DateTime.UtcNow + TimeSpan.FromSeconds(castDelay.TotalSeconds) + TimeSpan.FromSeconds(SpellDelay); } } //Players Clear Hands / NPCs keep weapons equipped when casting if (ClearHandsOnCast && m_Caster is PlayerMobile) { m_Caster.ClearHands(); } //Increase SwingDelay for BaseCreatures While Casting if (m_Caster is BaseCreature) { BaseWeapon weapon = m_Caster.Weapon as BaseWeapon; if (weapon != null) { m_Caster.LastSwingTime = DateTime.UtcNow + TimeSpan.FromSeconds((double)count); } } m_CastTimer = new CastTimer(this, castDelay); OnBeginCast(); if (castDelay > TimeSpan.Zero) { m_CastTimer.Start(); } else { m_CastTimer.Tick(); } return(true); } else { return(false); } } else { m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625); // Insufficient mana } return(false); }
protected override void OnTick() { if (m_ArenaGroupController == null) { Stop(); return; } if (m_ArenaGroupController.Deleted) { Stop(); return; } if (!m_ArenaGroupController.Enabled) { Stop(); return; } if (DateTime.UtcNow >= m_ArenaGroupController.m_NextListingAudit) { m_ArenaGroupController.AuditListings(); } ArenaController emptyArena = m_ArenaGroupController.GetAvailableArena(); if (emptyArena != null) { foreach (ArenaMatch arenaMatch in m_ArenaGroupController.m_MatchListings) { if (!ArenaMatch.IsValidArenaMatch(arenaMatch, null, false)) { continue; } if (DateTime.UtcNow < arenaMatch.m_NextReadyCheck) { continue; } if (!arenaMatch.IsReadyToStart()) { continue; } List <KeyValuePair <PlayerMobile, ArenaRuleset.ArenaRulesetFailureType> > m_RulesetViolations = new List <KeyValuePair <PlayerMobile, ArenaRuleset.ArenaRulesetFailureType> >(); bool rulesetViolationExists = false; foreach (ArenaTeam arenaTeam in arenaMatch.m_Teams) { if (arenaTeam == null) { continue; } if (arenaTeam.Deleted) { continue; } foreach (ArenaParticipant arenaParticipant in arenaTeam.m_Participants) { if (arenaParticipant == null) { continue; } if (arenaParticipant.Deleted) { continue; } if (arenaParticipant.m_Player == null) { continue; } if (arenaParticipant.Deleted == null) { continue; } if (arenaMatch.m_Ruleset == null) { continue; } ArenaRuleset.ArenaRulesetFailureType rulesetFailure = arenaMatch.m_Ruleset.CheckForRulesetViolations(arenaMatch, arenaParticipant.m_Player); m_RulesetViolations.Add(new KeyValuePair <PlayerMobile, ArenaRuleset.ArenaRulesetFailureType>(arenaParticipant.m_Player, rulesetFailure)); if (rulesetFailure != ArenaRuleset.ArenaRulesetFailureType.None) { rulesetViolationExists = true; } } } if (rulesetViolationExists) { arenaMatch.BroadcastMessage("Unable to start match due to the following ruleset violations:", 0); bool arenaError = false; foreach (KeyValuePair <PlayerMobile, ArenaRuleset.ArenaRulesetFailureType> rulesetViolation in m_RulesetViolations) { string message = ""; PlayerMobile player = rulesetViolation.Key; ArenaRuleset.ArenaRulesetFailureType rule = rulesetViolation.Value; if (player == null) { continue; } switch (rulesetViolation.Value) { case ArenaRuleset.ArenaRulesetFailureType.ArenaInvalid: arenaError = true; break; case ArenaRuleset.ArenaRulesetFailureType.Dead: message = player.RawName + ": Not Alive"; break; case ArenaRuleset.ArenaRulesetFailureType.EquipmentAllowed: message = player.RawName + ": Has Restricted Equipment (worn or in backpack)"; break; case ArenaRuleset.ArenaRulesetFailureType.Follower: message = player.RawName + ": Exceeds Follower Control Slots Allowed"; break; case ArenaRuleset.ArenaRulesetFailureType.PackAnimal: message = player.RawName + ": Pack Animals Not Allowed"; break; case ArenaRuleset.ArenaRulesetFailureType.Mount: message = player.RawName + ": Mounts Not Allowed"; break; case ArenaRuleset.ArenaRulesetFailureType.NotInArenaRegion: message = player.RawName + ": Outside of Arena Region"; break; case ArenaRuleset.ArenaRulesetFailureType.NotOnline: message = player.RawName + ": Not Online"; break; case ArenaRuleset.ArenaRulesetFailureType.PoisonedWeapon: message = player.RawName + ": Exceeds Allowed Number of Poisoned Weapons"; break; case ArenaRuleset.ArenaRulesetFailureType.Transformed: message = player.RawName + ": Transformed or Disguised"; break; case ArenaRuleset.ArenaRulesetFailureType.Young: message = player.RawName + ": Young Status"; break; case ArenaRuleset.ArenaRulesetFailureType.NotEnoughArenaCredits: message = player.RawName + ": Insufficient Arena Credits"; break; } if (message != "") { arenaMatch.BroadcastMessage(message, 1256); } } if (arenaError) { arenaMatch.BroadcastMessage("Arena Configuration Error", 1256); } arenaMatch.m_NextReadyCheck = DateTime.UtcNow + ArenaMatch.ReadyCheckInterval; string timeRemaining = Utility.CreateTimeRemainingString(DateTime.UtcNow, arenaMatch.m_NextReadyCheck, false, true, true, true, true); arenaMatch.BroadcastMessage("Match will re-attempt to start in " + timeRemaining + ".", 0); } else { arenaMatch.m_MatchStatus = ArenaMatch.MatchStatusType.Fighting; ArenaFight arenaFight = new ArenaFight(); arenaFight.m_ArenaController = emptyArena; arenaFight.m_ArenaMatch = arenaMatch; arenaMatch.m_ArenaFight = arenaFight; emptyArena.m_ArenaFight = arenaFight; arenaFight.Initialize(); } } } }
public static void RecordDamage(Mobile owner, Mobile from, Mobile target, DamageType damageType, int amount) { PlayerMobile player = owner as PlayerMobile; if (player == null) { return; } if (player.m_DamageTracker == null) { player.m_DamageTracker = new DamageTracker(player); } BaseCreature bc_From = from as BaseCreature; BaseCreature bc_Target = target as BaseCreature; PlayerMobile pm_From = from as PlayerMobile; PlayerMobile pm_Target = target as PlayerMobile; PlayerMobile rootPlayerFrom = pm_From; PlayerMobile rootPlayerTarget = pm_Target; #region Ship Damage to Creature: For Doubloon Distribution on Death if (bc_Target != null) { if (bc_Target.DoubloonValue > 0) { BaseShip shipFrom = null; if (bc_From != null) { if (bc_From.ShipOccupied != null) { shipFrom = bc_From.ShipOccupied; } } if (pm_From != null) { if (pm_From.ShipOccupied != null) { shipFrom = pm_From.ShipOccupied; } } if (shipFrom != null) { bool foundDamageEntry = false; foreach (DamageFromShipEntry damageFromShipEntry in bc_Target.m_DamageFromShipEntries) { if (damageFromShipEntry == null) { continue; } if (damageFromShipEntry.m_Ship == shipFrom) { damageFromShipEntry.m_TotalAmount += amount; damageFromShipEntry.m_LastDamageTime = DateTime.UtcNow; foundDamageEntry = true; } } if (!foundDamageEntry) { DamageFromShipEntry damageEntry = new DamageFromShipEntry(shipFrom, amount, DateTime.UtcNow); bc_Target.m_DamageFromShipEntries.Add(damageEntry); } } } } #endregion #region Arena bool checkArenaDamage = false; if (bc_From != null) { if (bc_From.ControlMaster is PlayerMobile) { rootPlayerFrom = bc_From.ControlMaster as PlayerMobile; } } if (bc_Target != null) { if (bc_Target.ControlMaster is PlayerMobile) { rootPlayerTarget = bc_Target.ControlMaster as PlayerMobile; } } if (rootPlayerFrom != null && rootPlayerTarget != null) { ArenaGroupController arenaGroupControllerFrom = ArenaGroupController.GetArenaGroupRegionAtLocation(rootPlayerFrom.Location, rootPlayerFrom.Map); ArenaGroupController arenaGroupControllerTarget = ArenaGroupController.GetArenaGroupRegionAtLocation(rootPlayerFrom.Location, rootPlayerFrom.Map); if (arenaGroupControllerFrom != null && arenaGroupControllerTarget != null && arenaGroupControllerFrom == arenaGroupControllerTarget) { if (rootPlayerFrom.m_ArenaMatch != null && rootPlayerTarget.m_ArenaMatch != null && rootPlayerFrom.m_ArenaMatch == rootPlayerTarget.m_ArenaMatch) { if (rootPlayerFrom.m_ArenaMatch.m_MatchStatus == ArenaMatch.MatchStatusType.Fighting) { checkArenaDamage = true; } } } } #endregion switch (damageType) { case DamageType.MeleeDamage: if (player.m_ShowMeleeDamage == DamageDisplayMode.PrivateMessage) { player.SendMessage(player.PlayerMeleeDamageTextHue, "You attack " + target.Name + " for " + amount.ToString() + " damage."); } if (player.m_ShowMeleeDamage == DamageDisplayMode.PrivateOverhead) { target.PrivateOverheadMessage(MessageType.Regular, player.PlayerMeleeDamageTextHue, false, "-" + amount.ToString(), player.NetState); } if (checkArenaDamage) { ArenaFight.CheckArenaDamage(player, DamageType.MeleeDamage, amount); } break; case DamageType.SpellDamage: if (player.m_ShowSpellDamage == DamageDisplayMode.PrivateMessage) { player.SendMessage(player.PlayerSpellDamageTextHue, "Your spell hits " + target.Name + " for " + amount.ToString() + " damage."); } if (player.m_ShowSpellDamage == DamageDisplayMode.PrivateOverhead) { target.PrivateOverheadMessage(MessageType.Regular, player.PlayerSpellDamageTextHue, false, "-" + amount.ToString(), player.NetState); } if (checkArenaDamage) { ArenaFight.CheckArenaDamage(player, DamageType.SpellDamage, amount); } break; case DamageType.FollowerDamage: if (player.m_ShowFollowerDamage == DamageDisplayMode.PrivateMessage) { player.SendMessage(player.PlayerFollowerDamageTextHue, "Follower: " + from.Name + " attacks " + target.Name + " for " + amount.ToString() + " damage."); } if (player.m_ShowFollowerDamage == DamageDisplayMode.PrivateOverhead) { target.PrivateOverheadMessage(MessageType.Regular, player.PlayerFollowerDamageTextHue, false, "-" + amount.ToString(), player.NetState); } if (checkArenaDamage) { ArenaFight.CheckArenaDamage(player, DamageType.FollowerDamage, amount); } break; case DamageType.ProvocationDamage: if (player.m_ShowProvocationDamage == DamageDisplayMode.PrivateMessage) { player.SendMessage(player.PlayerProvocationDamageTextHue, "Provocation: " + from.Name + " inflicts " + amount.ToString() + " damage on " + target.Name + "."); } if (player.m_ShowProvocationDamage == DamageDisplayMode.PrivateOverhead) { target.PrivateOverheadMessage(MessageType.Regular, player.PlayerProvocationDamageTextHue, false, "-" + amount.ToString(), player.NetState); } if (checkArenaDamage) { ArenaFight.CheckArenaDamage(player, DamageType.ProvocationDamage, amount); } break; case DamageType.PoisonDamage: if (player.m_ShowPoisonDamage == DamageDisplayMode.PrivateMessage) { player.SendMessage(player.PlayerPoisonDamageTextHue, "You inflict " + amount.ToString() + " poison damage on " + target.Name + "."); } if (player.m_ShowPoisonDamage == DamageDisplayMode.PrivateOverhead) { target.PrivateOverheadMessage(MessageType.Regular, player.PlayerPoisonDamageTextHue, false, "-" + amount.ToString(), player.NetState); } if (checkArenaDamage) { ArenaFight.CheckArenaDamage(player, DamageType.PoisonDamage, amount); } break; case DamageType.DamageTaken: if (player.m_ShowDamageTaken == DamageDisplayMode.PrivateMessage) { player.SendMessage(player.PlayerDamageTakenTextHue, from.Name + " attacks you for " + amount.ToString() + " damage."); } if (player.m_ShowDamageTaken == DamageDisplayMode.PrivateOverhead) { player.PrivateOverheadMessage(MessageType.Regular, player.PlayerDamageTakenTextHue, false, "-" + amount.ToString(), player.NetState); } if (checkArenaDamage) { ArenaFight.CheckArenaDamage(player, DamageType.DamageTaken, amount); } break; case DamageType.FollowerDamageTaken: if (player.m_ShowFollowerDamageTaken == DamageDisplayMode.PrivateMessage) { player.SendMessage(player.PlayerFollowerDamageTakenTextHue, "Follower: " + target.Name + " is hit for " + amount.ToString() + " damage."); } if (player.m_ShowFollowerDamageTaken == DamageDisplayMode.PrivateOverhead && player.NetState != null) { target.PrivateOverheadMessage(MessageType.Regular, player.PlayerFollowerDamageTakenTextHue, false, "-" + amount.ToString(), player.NetState); } break; } if (!player.m_DamageTracker.m_Running) { return; } switch (damageType) { case DamageType.MeleeDamage: player.m_DamageTracker.MeleeDamage += amount; break; case DamageType.SpellDamage: player.m_DamageTracker.SpellDamage += amount; break; case DamageType.FollowerDamage: player.m_DamageTracker.FollowerDamage += amount; break; case DamageType.ProvocationDamage: player.m_DamageTracker.ProvocationDamage += amount; break; case DamageType.PoisonDamage: player.m_DamageTracker.PoisonDamage += amount; break; case DamageType.DamageTaken: player.m_DamageTracker.DamageTaken += amount; break; case DamageType.FollowerDamageTaken: player.m_DamageTracker.FollowerDamageTaken += amount; break; case DamageType.HealingDealt: player.m_DamageTracker.HealingDealt += amount; break; } }
public void Target(IPoint3D p) { if (!Caster.CanSee(p)) { Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (SpellHelper.CheckTown(p, Caster) && CheckSequence()) { bool enhancedSpellcast = false; Boolean chargedSpellcast = false; int spellHue = Enhancements.GetMobileSpellHue(Caster, Enhancements.SpellType.MeteorSwarm); int radius = 3; if (Caster is BaseCreature) { radius += (int)(Math.Floor((Caster.Skills[SkillName.Magery].Value - 75) / 25)); } SpellHelper.Turn(Caster, p); if (p is Item) { p = ((Item)p).GetWorldLocation(); } Map map = Caster.Map; IPooledEnumerable nearbyMobiles = map.GetMobilesInRange(new Point3D(p), radius); Queue m_Queue = new Queue(); int targetCount = 0; bool playerVsCreatureOccurred = false; if (targetCount > 0) { Effects.PlaySound(p, Caster.Map, 0x160); } foreach (Mobile mobile in nearbyMobiles) { if (mobile == Caster) { continue; } if (Caster is BaseCreature) { if (!SpecialAbilities.MonsterCanDamage(Caster, mobile)) { continue; } } if (!Caster.CanBeHarmful(mobile, false)) { continue; } if (Caster is PlayerMobile && mobile is BaseCreature) { playerVsCreatureOccurred = true; } targetCount++; m_Queue.Enqueue(mobile); } nearbyMobiles.Free(); if (playerVsCreatureOccurred) { enhancedSpellcast = SpellHelper.IsEnhancedSpell(Caster, null, EnhancedSpellbookType.Fire, false, true); chargedSpellcast = SpellHelper.IsChargedSpell(Caster, null, false, Scroll != null); } while (m_Queue.Count > 0) { Mobile mobile = (Mobile)m_Queue.Dequeue(); double damage = (double)Utility.RandomMinMax(DamageMin, DamageMax); double damageBonus = 0; CheckMagicResist(mobile); Boolean isTamedTarget = SpellHelper.IsTamedTarget(Caster, mobile); if (Caster is PlayerMobile && mobile is BaseCreature) { damageBonus += SpellSpecificCreatureDamageBonus; } if (enhancedSpellcast && mobile is BaseCreature) { if (isTamedTarget) { damageBonus += SpellHelper.EnhancedSpellTamedCreatureBonus; } else { damageBonus += SpellHelper.EnhancedSpellBonus; } } if (chargedSpellcast && mobile is BaseCreature) { if (isTamedTarget) { damageBonus += SpellHelper.ChargedSpellTamedCreatureBonus; } else { damageBonus += SpellHelper.ChargedSpellBonus; } Caster.MovingParticles(mobile, 0x36D4, 5, 0, false, true, spellHue, 0, 9501, 1, 0, 0x100); Caster.MovingParticles(mobile, 0x36D4, 9, 0, false, true, spellHue, 0, 9501, 1, 0, 0x100); } else { Caster.MovingParticles(mobile, 0x36D4, 7, 0, false, true, spellHue, 0, 9501, 1, 0, 0x100); } BaseCreature bc_Target = mobile as BaseCreature; PlayerMobile pm_Target = mobile as PlayerMobile; if (bc_Target != null) { if (bc_Target.ShipOccupied != null) { damage *= BaseShip.shipBasedAoESpellDamageToCreatureScalar; } } if (pm_Target != null) { if (pm_Target.ShipOccupied != null) { damage *= BaseShip.shipBasedAoESpellDamageToPlayerScalar; } } damage *= GetDamageScalar(mobile, damageBonus); SpellHelper.Damage(this, Caster, mobile, damage); } } ArenaFight.SpellCompletion(Caster, typeof(MeteorSwarmSpell)); FinishSequence(); }