public override void OnDoubleClick( Mobile from ) { if ( (int)from.GetDistanceToSqrt( this ) > 2) { from.SendMessage( "You must be closer to the bank stone to pick it up" ); return; } BaseHouse house = BaseHouse.FindHouseAt( from ); if ( house == null ) { from.SendMessage( "You can not pick up the bank stone from outside the house" ); } else if ( !house.IsOwner( from ) ) { from.SendMessage( "You must be owner of house to pick bank stone up" ); } else { Container pack = from.Backpack; this.Delete(); BankStoneDeed deed = new BankStoneDeed( ); if ( pack == null || !pack.TryDropItem( from, deed, false ) ) deed.MoveToWorld( from.Location, from.Map ); } }
public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!this.Validate(attacker) || !this.CheckMana(attacker, true)) return; ClearCurrentAbility(attacker); attacker.SendMessage("You poisoning target"); defender.SendMessage("You are poisoned"); int level; if (Core.AOS) { if (attacker.InRange(defender, 2)) { int total = (attacker.Skills.Poisoning.Fixed) / 2; if (total >= 1000) level = 3; else if (total > 850) level = 2; else if (total > 650) level = 1; else level = 0; } else { level = 0; } } else { double total = attacker.Skills[SkillName.Poisoning].Value; double dist = attacker.GetDistanceToSqrt(defender); if (dist >= 3.0) total -= (dist - 3.0) * 10.0; if (total >= 200.0 && 1 > Utility.Random(10)) level = 3; else if (total > (Core.AOS ? 170.1 : 170.0)) level = 2; else if (total > (Core.AOS ? 130.1 : 130.0)) level = 1; else level = 0; } defender.ApplyPoison(attacker, Poison.GetPoison(level)); defender.FixedParticles(0x374A, 10, 15, 5021, EffectLayer.Waist); defender.PlaySound(0x474); }
public override void OnDoubleClick( Mobile from ) { if (from == null || from.Deleted) return; if ( !from.InLOS( this.GetWorldLocation() ) ) { from.SendLocalizedMessage( 502800 ); // You can't see that. } else if ( from.GetDistanceToSqrt( this.GetWorldLocation() ) > 4 ) { from.SendLocalizedMessage( 500446 ); // That is too far away. } else if ( !IsNaked( from ) ) { from.SendMessage( "You must be naked to join." ); } else if ( from.Backpack == null ) { from.SendMessage("You can not join without a backpack."); } else if ( m_Game != null ) { if ( m_Game.OpenJoin ) { if ( m_Game.IsInGame( from ) ) { from.SendMessage( "You are already playing!" ); //from.SendGump( new GameTeamSelector( m_Game ) ); } else { if ( from.AccessLevel == AccessLevel.Player ) { from.CloseGump( typeof(GameJoinGump) ); from.SendGump( new GameJoinGump( m_Game, m_GameName, m_RandomTeam ) ); } else from.SendMessage( "It might not be wise for staff to be playing..." ); } } else { from.SendMessage( "{0} join is closed.", m_GameName ); } } else { from.SendMessage( "This stone must be linked to a game stone. Please contact a game master." ); } }
public virtual bool CheckHit(Mobile attacker, Mobile defender) { BaseWeapon atkWeapon = attacker.Weapon as BaseWeapon; BaseWeapon defWeapon = defender.Weapon as BaseWeapon; Skill atkSkill = attacker.Skills[atkWeapon.Skill]; Skill defSkill = defender.Skills[defWeapon.Skill]; double atkValue = atkWeapon.GetAttackSkillValue(attacker, defender); double defValue = defWeapon.GetDefendSkillValue(attacker, defender); double ourValue, theirValue; int bonus = GetHitChanceBonus(); #region Stygian Abyss int hciMod = 0; if (atkWeapon is BaseThrown) { int min = ((BaseThrown)atkWeapon).MinThrowRange; double dist = attacker.GetDistanceToSqrt(defender); //Distance malas if (attacker.InRange(defender, 1)) //Close Quarters bonus -= (12 - Math.Min(12, ((int)attacker.Skills[SkillName.Throwing].Value + attacker.RawDex) / 20)); else if (dist < min) //too close bonus -= 12; //shield penalty BaseShield shield = attacker.FindItemOnLayer(Layer.TwoHanded) as BaseShield; if (shield != null) { double skill = Math.Max(1.0, attacker.Skills[SkillName.Parry].Value); hciMod = (int)Math.Min(50, 1200 / skill); } } #endregion if (Core.AOS) { if (atkValue <= -20.0) { atkValue = -19.9; } if (defValue <= -20.0) { defValue = -19.9; } bonus += AosAttributes.GetValue(attacker, AosAttribute.AttackChance); if (DivineFurySpell.UnderEffect(attacker)) { bonus += 10; // attacker gets 10% bonus when they're under divine fury } if (CheckAnimal(attacker, typeof(GreyWolf)) || CheckAnimal(attacker, typeof(BakeKitsune))) { bonus += 20; // attacker gets 20% bonus when under Wolf or Bake Kitsune form } if (HitLower.IsUnderAttackEffect(attacker)) { bonus -= 25; // Under Hit Lower Attack effect -> 25% malus } WeaponAbility ability = WeaponAbility.GetCurrentAbility(attacker); if (ability != null) { bonus += ability.AccuracyBonus; } SpecialMove move = SpecialMove.GetCurrentMove(attacker); if (move != null) { bonus += move.GetAccuracyBonus(attacker); } #region SA //Gargoyles get a +5 HCI if (attacker.Race == Race.Gargoyle) bonus += 5; if (hciMod > 0) bonus -= (int)(((double)bonus * ((double)hciMod / 100))); //Gargoyle Cap of 50 bonus = Math.Min(attacker.Race == Race.Gargoyle ? 50 : 45, bonus); #endregion ourValue = (atkValue + 20.0) * (100 + bonus); bonus = AosAttributes.GetValue(defender, AosAttribute.DefendChance); if (DivineFurySpell.UnderEffect(defender)) { bonus -= 20; // defender loses 20% bonus when they're under divine fury } if (HitLower.IsUnderDefenseEffect(defender)) { bonus -= 25; // Under Hit Lower Defense effect -> 25% malus } int blockBonus = 0; if (Block.GetBonus(defender, ref blockBonus)) { bonus += blockBonus; } int surpriseMalus = 0; if (SurpriseAttack.GetMalus(defender, ref surpriseMalus)) { bonus -= surpriseMalus; } int discordanceEffect = 0; // Defender loses -0/-28% if under the effect of Discordance. if (Discordance.GetEffect(attacker, ref discordanceEffect)) { bonus -= discordanceEffect; } // Defense Chance Increase = 45% if (bonus > 45) { bonus = 45; } theirValue = (defValue + 20.0) * (100 + bonus); bonus = 0; } else { if (atkValue <= -50.0) { atkValue = -49.9; } if (defValue <= -50.0) { defValue = -49.9; } ourValue = (atkValue + 50.0); theirValue = (defValue + 50.0); } double chance = ourValue / (theirValue * 2.0); chance *= 1.0 + ((double)bonus / 100); if (Core.AOS && chance < 0.02) { chance = 0.02; } return attacker.CheckSkill(atkSkill.SkillName, chance); }
public void CheckGuardCandidate(Mobile m) { if (IsDisabled()) { return; } if (IsGuardCandidate(m)) { GuardTimer timer = null; m_GuardCandidates.TryGetValue(m, out timer); if (timer == null) { timer = new GuardTimer(m, m_GuardCandidates); timer.Start(); m_GuardCandidates[m] = timer; m.SendLocalizedMessage(502275); // Guards can now be called on you! Map map = m.Map; if (map != null) { Mobile fakeCall = null; double prio = 0.0; foreach (Mobile v in m.GetMobilesInRange(8)) { if (!v.Player && v != m && !IsGuardCandidate(v) && ((v is BaseCreature) ? ((BaseCreature)v).IsHumanInTown() : (v.Body.IsHuman && v.Region.IsPartOf(this)))) { double dist = m.GetDistanceToSqrt(v); if (fakeCall == null || dist < prio) { fakeCall = v; prio = dist; } } } if (fakeCall != null) { fakeCall.Say(Utility.RandomList(1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052)); MakeGuard(m); timer.Stop(); m_GuardCandidates.Remove(m); m.SendLocalizedMessage(502276); // Guards can no longer be called on you. } } } else { timer.Stop(); timer.Start(); } } }
public virtual void ProduceEffect( Mobile from, bool first ) { if( first && EffectSound > 0 ) Caster.PlaySound( EffectSound ); if( EffectID > 0 ) from.MovingEffect( TargetMobile, EffectID, 5, 0, false, true, EffectHue, 0 ); DamageDelay = 0.1 * from.GetDistanceToSqrt( TargetMobile.Location ); new MageChainEffectTimer( this ).Start(); }
public override bool DoOrderGuard() { if (m_Mobile.IsDeadPet) { return(true); } Mobile controlMaster = m_Mobile.ControlMaster; if (controlMaster == null || controlMaster.Deleted) { return(true); } Mobile combatant = m_Mobile.Combatant; List <AggressorInfo> aggressors = controlMaster.Aggressors; if (aggressors.Count > 0) { for (int i = 0; i < aggressors.Count; ++i) { AggressorInfo info = aggressors[i]; Mobile attacker = info.Attacker; if (attacker != null && !attacker.Deleted && attacker.GetDistanceToSqrt(m_Mobile) <= m_Mobile.RangePerception) { if (combatant == null || attacker.GetDistanceToSqrt(controlMaster) < combatant.GetDistanceToSqrt(controlMaster)) { if ((attacker is PlayerMobile && m_CanAttackPlayers) || !(attacker is PlayerMobile)) { combatant = attacker; } } } } if (combatant != null) { m_Mobile.DebugSay("Crap, my master has been attacked! I will atack one of those bastards!"); } } if (combatant != null && combatant != m_Mobile && combatant != m_Mobile.ControlMaster && !combatant.Deleted && combatant.Alive && !combatant.IsDeadBondedPet && m_Mobile.CanSee(combatant) && m_Mobile.CanBeHarmful(combatant, false) && combatant.Map == m_Mobile.Map) { m_Mobile.DebugSay("Guarding from target..."); m_Mobile.Combatant = combatant; m_Mobile.FocusMob = combatant; Action = ActionType.Combat; /* * We need to call Think() here or spell casting monsters will not use * spells when guarding because their target is never processed. */ Think(); } else { m_Mobile.DebugSay("Nothing to guard from"); m_Mobile.Warmode = false; WalkMobileRange(controlMaster, 1, false, 0, 1); } return(true); }
public override void OnDoubleClick(Mobile from) { if (!from.InRange(GetWorldLocation(), 2)) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. return; } Point2D[] banks; PMList moongates; if (from.Map == Map.Trammel) { banks = m_TrammelBanks; moongates = PMList.Trammel; } else if (from.Map == Map.Felucca) { banks = m_FeluccaBanks; moongates = PMList.Felucca; } else if (from.Map == Map.Ilshenar) { #if false banks = m_IlshenarBanks; moongates = PMList.Ilshenar; #else from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, 0x482, 3, 1061684, "", "")); // The magic of the sextant fails... return; #endif } else if (from.Map == Map.Malas) { banks = m_MalasBanks; moongates = PMList.Malas; } else { banks = null; moongates = null; } Point3D closestMoongate = Point3D.Zero; double moongateDistance = double.MaxValue; if (moongates != null) { foreach (PMEntry entry in moongates.Entries) { double dist = from.GetDistanceToSqrt(entry.Location); if (moongateDistance > dist) { closestMoongate = entry.Location; moongateDistance = dist; } } } Point2D closestBank = Point2D.Zero; double bankDistance = double.MaxValue; if (banks != null) { foreach (Point2D p in banks) { double dist = from.GetDistanceToSqrt(p); if (bankDistance > dist) { closestBank = p; bankDistance = dist; } } } int moonMsg; if (moongateDistance == double.MaxValue) { moonMsg = 1048021; // The sextant fails to find a Moongate nearby. } else if (moongateDistance > m_LongDistance) { moonMsg = 1046449 + (int)from.GetDirectionTo(closestMoongate); // A moongate is * from here } else if (moongateDistance > m_ShortDistance) { moonMsg = 1048010 + (int)from.GetDirectionTo(closestMoongate); // There is a Moongate * of here. } else { moonMsg = 1048018; // You are next to a Moongate at the moment. } from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, 0x482, 3, moonMsg, "", "")); int bankMsg; if (bankDistance == double.MaxValue) { bankMsg = 1048020; // The sextant fails to find a Bank nearby. } else if (bankDistance > m_LongDistance) { bankMsg = 1046462 + (int)from.GetDirectionTo(closestBank); // A town is * from here } else if (bankDistance > m_ShortDistance) { bankMsg = 1048002 + (int)from.GetDirectionTo(closestBank); // There is a city Bank * of here. } else { bankMsg = 1048019; // You are next to a Bank at the moment. } from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, 0x5AA, 3, bankMsg, "", "")); }
public override void OnSpeech(SpeechEventArgs e) { Mobile from = e.Mobile; if (e.Handled || !from.Alive || from.GetDistanceToSqrt(this) > 3) { return; } if (e.HasKeyword(0x3C) || (e.HasKeyword(0x171) && WasNamed(e.Speech))) // vendor buy, *buy* { if (IsOwner(from)) { SayTo(from, 503212); // You own this shop, just take what you want. } else if (House == null || !House.IsBanned(from)) { from.SendLocalizedMessage(503213); // Select the item you wish to buy. from.Target = new PVBuyTarget(); e.Handled = true; } } else if (e.HasKeyword(0x3D) || (e.HasKeyword(0x172) && WasNamed(e.Speech))) // vendor browse, *browse { if (House != null && House.IsBanned(from) && !IsOwner(from)) { SayTo(from, 1062674); // You can't shop from this home as you have been banned from this establishment. } else { OpenBackpack(from); e.Handled = true; } } else if (e.HasKeyword(0x3E) || (e.HasKeyword(0x173) && WasNamed(e.Speech))) // vendor collect, *collect { if (IsOwner(from)) { CollectGold(from); e.Handled = true; } } else if (e.HasKeyword(0x3F) || (e.HasKeyword(0x174) && WasNamed(e.Speech))) // vendor status, *status { if (IsOwner(from)) { SendOwnerGump(from); e.Handled = true; } else { SayTo(from, 503226); // What do you care? You don't run this shop. } } else if (e.HasKeyword(0x40) || (e.HasKeyword(0x175) && WasNamed(e.Speech))) // vendor dismiss, *dismiss { if (IsOwner(from)) { Dismiss(from); e.Handled = true; } } else if (e.HasKeyword(0x41) || (e.HasKeyword(0x176) && WasNamed(e.Speech))) // vendor cycle, *cycle { if (IsOwner(from)) { this.Direction = this.GetDirectionTo(from); e.Handled = true; } } }
private bool CanBuy(Mobile buyer, List<Item> styles) { if (!IsActiveSeller) return false; if (!buyer.CheckAlive()) return false; if (!CheckVendorAccess(buyer)) { Say(501522); // I shall not treat with scum like thee! return false; } if (styles.Count == 0) { SayTo(buyer, 500187); // Your order cannot be fulfilled, please try again. return false; } if (Math.Round(buyer.GetDistanceToSqrt(this)) > m_MaxDistanceForCut) { Speak(m_ToFarAway); return false; } if (buyer.Mounted && m_NeedsToBeDismounted) { Speak(m_PleaseDismount); return false; } if (buyer.Warmode && m_NeedsPeaceForCut) { Speak(m_GoPeace); return false; } if (buyer.HairItemID == 5147 || buyer.HairItemID == 7947) { Speak(m_NotHuman); return false; } int beardCount = 0, hairCount = 0; foreach (Item item in styles) { if (IsHair(item)) hairCount++; else if (IsBeard(item)) { if (buyer.Female && !m_AllowFemalesBuyingBeard) { Speak(m_FemaleBuyingBeard); return false; } beardCount++; } if (hairCount > 1 || beardCount > 1) { Speak(m_TooManyStylesBought); return false; } } return true; }
public override double GetDamageScalar( Mobile attacker, Mobile defender, int maxRange ) { int dist = (int) Math.Min( attacker.GetDistanceToSqrt( defender ), maxRange ); double scalar = 0.0; try { scalar = m_DamagePenalties[maxRange - 4][dist]; //TODO - Revisar, da un index fuera de rango a veces } catch ( Exception ex ) { Logger.Error( "Exception in Throwing code, maxRange={0}, dist={1}, attacker={2}, defender={3}, exception={4}", maxRange, dist, attacker, defender, ex ); } if ( m_Debug ) attacker.SendMessage( "Your damage scalar due to distance is x{0:0.00}", 1.0 - scalar ); return 1.0 - scalar; }
public override double GetAccuracyScalar( Mobile attacker, Mobile defender, int maxRange ) { int dist = (int) Math.Min( attacker.GetDistanceToSqrt( defender ), maxRange ); double scalar = 0.0; try { //TODO - Revisar, da un index fuera de rango a veces scalar = m_AccuracyPenalties[maxRange - 4][dist]; } catch ( Exception ex ) { Logger.Error( "Exception in Throwing code, maxRange={0}, dist={1}, attacker={2}, defender={3}, exception={4}", maxRange, dist, attacker, defender, ex ); } if ( dist < 2 ) scalar *= 1.0 - Math.Min( 1.0, ( ( attacker.Skills[SkillName.Swords].Value / 240.0 ) + ( attacker.Dex / 300.0 ) ) ); if ( m_Debug ) attacker.SendMessage( "Your hit chance scalar due to distance is x{0:0.00}", 1.0 - scalar ); return 1.0 - scalar; }
protected override void OnTarget(Mobile from, object targeted) { if( targeted == null || !(targeted is Item) ) return; if (_guardPost == null) { //Guard post stage if (!(targeted is KinGuardPost)) { from.SendMessage("You may only fund guard posts"); return; } //Grab guardpost KinGuardPost gp = targeted as KinGuardPost; if (gp == null) return; //Verify owner KinCityData data = KinCityManager.GetCityData(gp.City); if( data == null ) { from.SendMessage("That guard post does not appear to be a valid part of a faction city"); return; } //Owner or city leader can fund if (gp.Owner != from && gp.Owner != data.CityLeader ) { from.SendMessage("That guard post does not belong to you"); return; } from.SendMessage("Select the silver you wish to fund it with"); //Issue new target from.Target = new KinGuardPostFundTarget(gp); } else { Silver silver = targeted as Silver; //Silver stage if (silver == null) { from.SendMessage("You may only fund the guard post with silver"); return; } if (!from.Backpack.Items.Contains(targeted)) { from.SendMessage("The silver must be in your backpack"); } if (from.GetDistanceToSqrt(_guardPost.Location) > 3) { from.SendMessage("You are not close enough to the guard post"); return; } //Verify owner KinCityData data = KinCityManager.GetCityData(_guardPost.City); if (data == null) { from.SendMessage("That guard post does not appear to be a valid part of a faction city"); return; } //check again that the guard post exists and they are the owner if (_guardPost.Deleted || (_guardPost.Owner != from && _guardPost.Owner != data.CityLeader)) { from.SendMessage("The guard post no longer or exists or you are no longer the rightful owner"); return; } int amount = silver.Amount; if (amount <= 0) { //should be impossible from.SendMessage("Your guard post was not successfully funded"); return; } //Fund guardpost silver.Delete(); _guardPost.Silver += amount; //if( !_guardPost.Running ) _guardPost.Running = true; from.SendMessage("Your guard post was successfully funded with {0} silver",amount); } }
public void OnHit(Mobile from, Item tool) { // Vérifions que le joueur ne soit pas trop loin ^^ if(from.GetDistanceToSqrt(this.Location) > 2) { from.SendMessage("Vous êtes trop loin"); return; } // Pour ne pas taper dessus trop vite if (lastHit + TimeSpan.FromSeconds(1) > DateTime.Now) return; lastHit = DateTime.Now; // On retire un point Hits--; // Petite animation from.Direction = from.GetDirectionTo(this); from.Animate(Utility.RandomList(Mining.System.Definitions[0].EffectActions), 5, 1, true, false, 0); from.PlaySound(Utility.RandomList(Mining.System.Definitions[0].EffectSounds)); // S'il n'y a plus de points on delete le rocher if (Hits == 0) { // Delete après l'animation de minage Timer.DelayCall(TimeSpan.FromMilliseconds(900), new TimerCallback(Delete)); // On réduit de 1 le nombre d'utilisation de l'outil ayant servis if (tool is IUsesRemaining) { ((IUsesRemaining)tool).UsesRemaining--; } // Et la récompense tordue :p int max = Utility.Random(5); int countGem = 0; int countOre = 0; for (int i = 0; i < max; i++) { if (Utility.RandomBool()) { countGem++; from.AddToBackpack(Loot.Construct(Loot.GemTypes, Utility.Random(Loot.GemTypes.Length))); } else { if (Utility.RandomBool()) { countOre++; int chance = Utility.Random(100); if (chance > 0) from.AddToBackpack(new IronOre()); else from.AddToBackpack(new SilverOre()); // environ 1 chance sur 200 } } } if (countGem > 0) { from.SendMessage(String.Format("Vous avez trouver {0} gemmes", countGem)); if (countOre > 0) from.SendMessage("ainsi qu'un peu de minerai..."); } else { if (countOre > 0) from.SendMessage("Vous trouvez un peu de minerai..."); } } }
public static void EventSink_Login(LoginEventArgs e) { Mobile from = e.Mobile; if (!IsStranded(from)) { return; } Map map = from.Map; Point2D[] list; if (map == Map.Felucca) { list = m_Felucca; } else if (map == Map.Trammel) { list = m_Trammel; } else if (map == Map.Ilshenar) { list = m_Ilshenar; } else if (map == Map.Tokuno) { list = m_Tokuno; } else { return; } Point2D p = Point2D.Zero; double pdist = double.MaxValue; for (int i = 0; i < list.Length; ++i) { double dist = from.GetDistanceToSqrt(list[i]); if (dist < pdist) { p = list[i]; pdist = dist; } } int x = p.X, y = p.Y; int z; bool canFit = false; z = map.GetAverageZ(x, y); canFit = map.CanSpawnMobile(x, y, z); for (int i = 1; !canFit && i <= 40; i += 2) { for (int xo = -1; !canFit && xo <= 1; ++xo) { for (int yo = -1; !canFit && yo <= 1; ++yo) { if (xo == 0 && yo == 0) { continue; } x = p.X + (xo * i); y = p.Y + (yo * i); z = map.GetAverageZ(x, y); canFit = map.CanSpawnMobile(x, y, z); } } } if (canFit) { from.Location = new Point3D(x, y, z); } }
public void OnHit(Mobile from, Item tool) { // Vérifions que le joueur ne soit pas trop loin ^^ if (from.GetDistanceToSqrt(this.Location) > 2) { from.SendMessage("Vous êtes trop loin"); return; } // Pour ne pas taper dessus trop vite if (lastHit + TimeSpan.FromSeconds(1) > DateTime.Now) { return; } lastHit = DateTime.Now; // On retire un point Hits--; // Petite animation from.Direction = from.GetDirectionTo(this); from.Animate(Utility.RandomList(Mining.System.Definitions[0].EffectActions), 5, 1, true, false, 0); from.PlaySound(Utility.RandomList(Mining.System.Definitions[0].EffectSounds)); // S'il n'y a plus de points on delete le rocher if (Hits == 0) { // Delete après l'animation de minage Timer.DelayCall(TimeSpan.FromMilliseconds(900), new TimerCallback(Delete)); // On réduit de 1 le nombre d'utilisation de l'outil ayant servis if (tool is IUsesRemaining) { ((IUsesRemaining)tool).UsesRemaining--; } // Et la récompense tordue :p int max = Utility.Random(5); int countGem = 0; int countOre = 0; for (int i = 0; i < max; i++) { if (Utility.RandomBool()) { countGem++; from.AddToBackpack(Loot.Construct(Loot.GemTypes, Utility.Random(Loot.GemTypes.Length))); } else { if (Utility.RandomBool()) { countOre++; int chance = Utility.Random(100); if (chance > 0) { from.AddToBackpack(new IronOre()); } else { from.AddToBackpack(new SilverOre()); // environ 1 chance sur 200 } } } } if (countGem > 0) { from.SendMessage(String.Format("Vous avez trouver {0} gemmes", countGem)); if (countOre > 0) { from.SendMessage("ainsi qu'un peu de minerai..."); } } else { if (countOre > 0) { from.SendMessage("Vous trouvez un peu de minerai..."); } } } }
public override void OnResponse( Mobile from, string text ) { PlayerMobile found = null; foreach( NetState state in NetState.Instances ) { PlayerMobile player = state.Mobile as PlayerMobile; if( state.Mobile != null && state.Mobile is PlayerMobile && player.FreeForRP && player.Name == text ) found = player; } if( found != null && found.Alive ) { int distance = (int)from.GetDistanceToSqrt( found.Location ); from.SendMessage( found.Name + " is currently " + distance.ToString() + " squares away in this direction." ); from.QuestArrow = new FindRPArrow( (PlayerMobile)from, found ); } else from.SendMessage( "No character with that name was found." ); }
public void OnPlacement(Mobile from, Point3D p) { PlayerMobile player = from as PlayerMobile; if (Deleted) { return; } else if (!IsChildOf(from.Backpack)) { from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. } else { Map map = from.Map; if (map == null) { return; } if (from.AccessLevel < AccessLevel.GameMaster && map != Map.Felucca) { from.SendLocalizedMessage(1043284); // A ship can not be created here. return; } if (from.Region.IsPartOf(typeof(HouseRegion)) || BaseBoat.FindBoatAt(from, from.Map) != null) { from.SendLocalizedMessage(1010568, null, 0x25); // You may not place a ship while on another ship or inside a house. return; } if (from.GetDistanceToSqrt(p) > 10) { from.SendMessage("You cannot place a ship that far away from land."); return; } foreach (BaseBoat boatInstance in BaseBoat.m_Instances) { if (boatInstance.Owner == from) { from.SendMessage("You already have a boat at sea."); return; } } BaseBoat boat = Boat; if (boat == null) { return; } p = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z); Direction newDirection = Direction.North; int shipFacingItemID = -1; switch (from.Direction) { case Direction.North: newDirection = Direction.North; shipFacingItemID = boat.NorthID; break; case Direction.Up: newDirection = Direction.North; shipFacingItemID = boat.NorthID; break; case Direction.East: newDirection = Direction.East; shipFacingItemID = boat.EastID; break; case Direction.Right: newDirection = Direction.East; shipFacingItemID = boat.EastID; break; case Direction.South: newDirection = Direction.South; shipFacingItemID = boat.SouthID; break; case Direction.Down: newDirection = Direction.South; shipFacingItemID = boat.SouthID; break; case Direction.West: newDirection = Direction.West; shipFacingItemID = boat.WestID; break; case Direction.Left: newDirection = Direction.West; shipFacingItemID = boat.WestID; break; default: newDirection = Direction.North; shipFacingItemID = boat.NorthID; break; } if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, shipFacingItemID)) { //Set Boat Properties Stored in Deed boat.CoOwners = m_CoOwners; boat.Friends = m_Friends; boat.GuildAsFriends = GuildAsFriends; boat.Owner = from; boat.ShipName = m_ShipName; boat.TargetingMode = m_TargetingMode; boat.TimeLastRepaired = m_TimeLastRepaired; boat.NextTimeRepairable = m_NextTimeRepairable; boat.DecayTime = DateTime.UtcNow + boat.BoatDecayDelay; boat.Anchored = true; ShipUniqueness.GenerateShipUniqueness(boat); boat.HitPoints = HitPoints; boat.SailPoints = SailPoints; boat.GunPoints = GunPoints; bool fullSailPoints = (boat.SailPoints == boat.BaseMaxSailPoints); bool fullGunPoints = (boat.GunPoints == boat.BaseMaxGunPoints); bool fullHitPoints = (boat.HitPoints == boat.BaseMaxHitPoints); boat.SetFacing(newDirection); boat.MoveToWorld(p, map); Delete(); BoatRune boatRune = new BoatRune(boat, from); boat.BoatRune = boatRune; BoatRune boatBankRune = new BoatRune(boat, from); boat.BoatBankRune = boatBankRune; bool addedToPack = false; bool addedToBank = false; if (from.AddToBackpack(boatRune)) { addedToPack = true; } BankBox bankBox = from.FindBankNoCreate(); if (bankBox != null) { if (bankBox.Items.Count < bankBox.MaxItems) { bankBox.AddItem(boatBankRune); addedToBank = true; } } string message = "You place the ship at sea. A boat rune has been placed both in your bankbox and your backpack."; if (!addedToPack && !addedToBank) { message = "You place the ship at sea. However, there was no room in neither your bankbox nor your backpack to place boat runes."; } else if (!addedToPack) { message = "You place the ship at sea. A boat rune was placed in your bankbox, however, there was no room in your backpack to place a boat rune."; } else if (!addedToBank) { message = "You place the ship at sea. A boat rune was placed in your backpack, however, there was no room in your bankbox to place a boat rune."; } from.SendMessage(message); } else { boat.Delete(); from.SendMessage("A boat cannot be placed there. You may change your facing to change the direction of the boat placement."); } } }
public void PyroTarget(IPoint3D p) { if (!Caster.CanSee(p)) { Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (SpellHelper.CheckTown(p, Caster) && CheckSequence()) { SpellHelper.Turn(Caster, p); if (p is Item) { p = ((Item)p).GetWorldLocation(); } ArrayList targets = new ArrayList(); Map map = Caster.Map; bool playerVsPlayer = false; Point3D loc = new Point3D(p); if (map != null) { Effects.SendLocationEffect(loc, map, 0x3709, 30); AbilityCollection.AreaEffect(TimeSpan.FromSeconds(0.3), TimeSpan.FromSeconds(0.6), 0.4, map, loc, 0x36CB, 16, 0, 0, 2, 0, true, false, false); try { IPooledEnumerable eable = map.GetMobilesInRange(new Point3D(p), 2); foreach (Mobile m in eable) { if (Core.AOS && m == Caster) { continue; } if (!map.LineOfSight(m, loc)) { continue; } if (SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false)) { targets.Add(m); if (m.Player) { playerVsPlayer = true; } } } eable.Free(); } catch { } } double damage = GetNewAosDamage(45, 1, 5, Caster.Player && playerVsPlayer); if (targets.Count > 0) { for (int i = 0; i < targets.Count; ++i) { Mobile m = (Mobile)targets[i]; double toDeal = damage; if (m.GetDistanceToSqrt(loc) > 0) { toDeal = damage / m.GetDistanceToSqrt(loc); } if (!Core.AOS && CheckResisted(m)) { toDeal *= 0.5; m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. } Caster.DoHarmful(m); SpellHelper.Damage(this, m, toDeal, 0, 100, 0, 0, 0); } } } FinishSequence(); }
public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckStam(attacker, true)) { return; } ClearCurrentAbility(attacker); attacker.SendMessage("You poisoning target"); defender.SendMessage("You are poisoned"); int level; if (Core.AOS) { if (attacker.InRange(defender, 2)) { int total = (attacker.Skills.Poisoning.Fixed) / 2; if (total >= 1000) { level = 3; } else if (total > 850) { level = 2; } else if (total > 650) { level = 1; } else { level = 0; } } else { level = 0; } } else { double total = attacker.Skills[SkillName.Poisoning].Value; double dist = attacker.GetDistanceToSqrt(defender); if (dist >= 3.0) { total -= (dist - 3.0) * 10.0; } if (total >= 200.0 && 1 > Utility.Random(10)) { level = 3; } else if (total > (Core.AOS ? 170.1 : 170.0)) { level = 2; } else if (total > (Core.AOS ? 130.1 : 130.0)) { level = 1; } else { level = 0; } } defender.ApplyPoison(attacker, Poison.GetPoison(level)); defender.FixedParticles(0x374A, 10, 15, 5021, EffectLayer.Waist); defender.PlaySound(0x474); }
/// <summary> /// Moves a stranded mobile. If bCheckStranded == false then a new location is found regardless of the current location /// </summary> /// <param name="from"></param> /// <param name="bCheckCurrentLoc"></param> public static void ProcessStranded(Mobile from, bool bCheckStranded) { Map map = from.Map; if (map == null) { return; } //pla: Change this to allow the code to get a new location even if the current location is good. //This is used to auto-kick ghosts from pirated ships! if (bCheckStranded && map.CanFit(from.X, from.Y, from.Z, 16, CanFitFlags.requireSurface)) { return; } bool isStranded = false; Tile landTile = map.Tiles.GetLandTile(from.X, from.Y); if ((landTile.ID >= 168 && landTile.ID <= 171) || (landTile.ID >= 310 && landTile.ID <= 311)) { isStranded = true; } else { Tile[] tiles = map.Tiles.GetStaticTiles(from.X, from.Y); for (int i = 0; !isStranded && i < tiles.Length; ++i) { Tile tile = tiles[i]; if (tile.ID >= 0x5797 && tile.ID <= 0x57B2) { isStranded = true; } } } //pla: Force stranded to true for auto-kicks if (bCheckStranded == false) { isStranded = true; } if (!isStranded) { return; } Point2D[] list; if (map == Map.Felucca) { list = m_Felucca; } else if (map == Map.Trammel) { list = m_Trammel; } else if (map == Map.Ilshenar) { list = m_Ilshenar; } else { return; } Point2D p = Point2D.Zero; double pdist = double.MaxValue; for (int i = 0; i < list.Length; ++i) { // wea: added legal bounce check if (!CheckLegalBounce(list[i])) { continue; } double dist = from.GetDistanceToSqrt(list[i]); if (dist < pdist) { p = list[i]; pdist = dist; } } int x = p.X, y = p.Y; int z; bool canFit = false; z = map.GetAverageZ(x, y); canFit = map.CanSpawnMobile(x, y, z); for (int i = 1; !canFit && i <= 40; i += 2) { for (int xo = -1; !canFit && xo <= 1; ++xo) { for (int yo = -1; !canFit && yo <= 1; ++yo) { if (xo == 0 && yo == 0) { continue; } x = p.X + (xo * i); y = p.Y + (yo * i); z = map.GetAverageZ(x, y); canFit = map.CanSpawnMobile(x, y, z); } } } if (canFit) { from.Location = new Point3D(x, y, z); } }
public override void OnHit(Mobile attacker, Mobile defender, double damageBonus) { var pm = attacker as PlayerMobile; var battle = AutoPvP.FindBattle(pm); if (attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) && 0.4 >= Utility.RandomDouble() && battle == null) { defender.AddToBackpack(Ammo); } if (EraML && m_Velocity > 0) { var bonus = (int)attacker.GetDistanceToSqrt(defender); if (bonus > 0 && m_Velocity > Utility.Random(100)) { AOS.Damage(defender, attacker, bonus * 3, 100, 0, 0, 0, 0); if (attacker.Player) { attacker.SendLocalizedMessage(1072794); // Your arrow hits its mark with velocity! } if (defender.Player) { defender.SendLocalizedMessage(1072795); // You have been hit by an arrow with velocity! } } } base.OnHit(attacker, defender, damageBonus); }
public static void HandleDeath(Mobile victim, Mobile killer) { if (killer == null) { killer = victim.FindMostRecentDamager(true); } PlayerState victimState = PlayerState.Find(victim); PlayerState killerState = PlayerState.Find(killer); Container pack = victim.Backpack; if (pack != null) { Container killerPack = (killer == null ? null : killer.Backpack); foreach (Sigil sigil in pack.FindItemsByType<Sigil>()) { if (killerState != null && killerPack != null) { if (killer.GetDistanceToSqrt(victim) > 64) { sigil.ReturnHome(); killer.SendLocalizedMessage(1042230); // The sigil has gone back to its home location. } else if (Sigil.ExistsOn(killer)) { sigil.ReturnHome(); killer.SendLocalizedMessage(1010258); // The sigil has gone back to its home location because you already have a sigil. } else if (!killerPack.TryDropItem(killer, sigil, false)) { sigil.ReturnHome(); killer.SendLocalizedMessage(1010259); // The sigil has gone home because your backpack is full. } else if (killer.Region.IsPartOf<HouseRegion>()) { sigil.ReturnHome(); killer.SendLocalizedMessage(1042230); // The sigil has gone back to its home location. } } else { sigil.ReturnHome(); } } } #region Dueling if (victim.Region.IsPartOf<SafeZone>() || victim.Region.IsPartOf<PvPBattleRegion>()) { return; } #endregion if (victim is PlayerMobile && victimState != null && (killer == victim || (killer is BaseFactionGuard && ((BaseFactionGuard)killer).Faction != victimState.Faction) || (killerState != null && killerState.Faction != victimState.Faction))) { ((PlayerMobile)victim).FactionDeath = true; ApplySkillLoss(victim); } if (killerState != null && killer != null) { if (victim is BaseCreature && !(victim is BaseVendor)) { var bc = (BaseCreature)victim; Faction victimFaction = bc.FactionAllegiance; if (IsFactionFacet(bc.Map) && victimFaction != null && killerState.Faction != victimFaction) { int silver = killerState.Faction.AwardSilver(killer, bc.FactionSilverWorth); if (silver > 0) { killer.SendLocalizedMessage(1042748, silver.ToString("N0")); // Thou hast earned ~1_AMOUNT~ silver for vanquishing the vile creature. } } #region Ethics if (Ethic.Enabled && IsFactionFacet(bc.Map) && bc.GetEthicAllegiance(killer) == BaseCreature.Allegiance.Enemy) { Player killerEPL = Player.Find(killer); if (killerEPL != null && killerEPL.Power < Player.MaxPower) { killerEPL.Power += 1; if (0.02 >= Utility.RandomDouble()) { killerEPL.Sphere += 1; killer.SendMessage( "You have gained a sphere of influence for slaying a minion of {0}.", killerEPL.Ethic == Ethic.Evil ? "justice" : "evil"); } killer.SendMessage( "You gain a little life force for slaying a minion of {0}.", killerEPL.Ethic == Ethic.Evil ? "justice" : "evil"); } } #endregion return; } } if (killer == null || victimState == null || killerState == null || killerState.Faction == victimState.Faction) { return; } if (victimState.KillPoints <= -6) { killer.SendLocalizedMessage(501693); // This victim is not worth enough to get kill points from. } else { int award = Math.Max(victimState.KillPoints / 10, 1); if (award > 40) { award = 40; } if (victimState.CanGiveSilverTo(killer)) { if (Ethic.Enabled) { Player killerEPL = Player.Find(killer); Player victimEPL = Player.Find(victim); if (killerEPL == null || victimEPL == null) { return; } int powerTransfer = Math.Min(Math.Max(1, victimEPL.Power / 5), Player.MaxPower - killerEPL.Power); if (powerTransfer > 0) { victimEPL.Power -= powerTransfer; killerEPL.Power += powerTransfer; killer.FixedEffect(0x373A, 10, 30); killer.PlaySound(0x209); killer.SendMessage("You have gained {0} life force for killing {1}.", powerTransfer, victim.Name); victim.SendMessage("You have lost {0} life force for falling victim to {1}.", powerTransfer, killer.Name); } if (killerEPL.Ethic != victimEPL.Ethic && (victimEPL.Sphere > 0 && (victimEPL.Rank > 3 || (killerEPL.Rank - victimEPL.Rank < 3)))) { int sphereTransfer = Math.Max(1, 1 + (victimEPL.Rank - killerEPL.Rank)); //Always at least 1pt victimEPL.Sphere -= sphereTransfer; killerEPL.Sphere += sphereTransfer; killer.SendMessage( "You have gained a sphere of influence for slaying an agent of {0}.", killerEPL.Ethic == Ethic.Evil ? "justice" : "evil"); victim.SendMessage( "You have lost a sphere of influence for being slain by an agent of {0}.", killerEPL.Ethic == Ethic.Hero ? "justice" : "evil"); } } if (victimState.KillPoints > 0) { victimState.IsActive = true; if (1 > Utility.Random(3)) { killerState.IsActive = true; } int silver = killerState.Faction.AwardSilver(killer, award * 40); if (silver > 0) { killer.SendLocalizedMessage(1042736, String.Format("{0:N0} silver\t{1}", silver, victim.Name)); // You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~! } } victimState.KillPoints -= award; killerState.KillPoints += award; killerState.LastKill = DateTime.UtcNow; int offset = (award != 1 ? 0 : 2); // for pluralization string args = String.Format("{0}\t{1}\t{2}", award, victim.Name, killer.Name); killer.SendLocalizedMessage(1042737 + offset, args); // Thou hast been honored with ~1_KILL_POINTS~ kill point(s) for vanquishing ~2_DEAD_PLAYER~! victim.SendLocalizedMessage(1042738 + offset, args); // Thou has lost ~1_KILL_POINTS~ kill point(s) to ~3_ATTACKER_NAME~ for being vanquished! victimState.OnGivenSilverTo(killer); } else { killer.SendLocalizedMessage(1042231); // You have recently defeated this enemy and thus their death brings you no honor. } } //ethics }
public virtual void DoAreaAttack( Mobile from, int sound, int hue, int phys, int fire, int cold, int pois, int nrgy ) { Map map = from.Map; if ( map == null ) return; ArrayList list = new ArrayList(); IPooledEnumerable eable = from.GetMobilesInRange( 10 ); foreach ( Mobile m in eable) { if ( from != m && SpellHelper.ValidIndirectTarget( from, m ) && from.CanBeHarmful( m, false ) && from.InLOS( m ) ) list.Add( m ); } eable.Free(); if ( list.Count == 0 ) return; Effects.PlaySound( from.Location, map, sound ); // TODO: What is the damage calculation? for ( int i = 0; i < list.Count; ++i ) { Mobile m = (Mobile)list[i]; double scalar = (11 - from.GetDistanceToSqrt( m )) / 10; if ( scalar > 1.0 ) scalar = 1.0; else if ( scalar < 0.0 ) continue; from.DoHarmful( m, true ); m.FixedEffect( 0x3779, 1, 15, hue, 0 ); AOS.Damage( m, from, (int)(GetBaseDamage( from ) * scalar), phys, fire, cold, pois, nrgy ); } }
public override void OnDoubleClick(Mobile from) { UpdateTeam(); if (from.AccessLevel >= AccessLevel.Seer) { if (m_Game == null || m_Team == null) { from.SendGump(new PropertiesGump(from, this)); } else { from.SendGump(new PropertiesGump(from, m_Team)); } } else if (m_Team != null && m_Game != null) { if (!m_Game.Running) { from.SendAsciiMessage("The game is currently closed."); return; } CTFTeam team = m_Game.GetTeam(from); if (team != null) { if (!from.InLOS(this.GetWorldLocation())) { from.SendLocalizedMessage(502800); // You can't see that. return; } else if (from.GetDistanceToSqrt(this.GetWorldLocation()) > 3) { from.SendLocalizedMessage(500446); // That is too far away. return; } if (RootParent is Mobile) { if (RootParent == from) { from.Target = new CaptureTarget(this); from.SendAsciiMessage("Target your flag to capture, or target a team-mate to pass the flag."); //"What do you wish to do with the flag?" ); } } else { if (team != m_Team) { if (from.Backpack != null) { from.RevealingAction(); from.Backpack.DropItem(this); from.SendAsciiMessage("You got the enemy flag!"); BeginCapture(); m_Game.PlayerMessage("{0} ({1}) got the {2} flag!", from.Name, team.Name, m_Team.Name); } else { from.SendAsciiMessage("You have no backpack to carry that flag!"); } } else { if (!m_Home) { m_Game.PlayerMessage("{0} has returned the {1} flag!", from.Name, m_Team.Name); ReturnToHome(); } } } } else { from.SendAsciiMessage("You are not part of the game."); } } }
public static void HandleDeath(Mobile victim, Mobile killer) { if (killer == null) killer = victim.FindMostRecentDamager(true); PlayerState killerState = PlayerState.Find(killer); Container pack = victim.Backpack; if (pack != null) { Container killerPack = (killer == null ? null : killer.Backpack); Item[] sigils = pack.FindItemsByType(typeof(Sigil)); for (int i = 0; i < sigils.Length; ++i) { Sigil sigil = (Sigil)sigils[i]; if (killerState != null && killerPack != null) { if (killer.GetDistanceToSqrt(victim) > 64) { sigil.ReturnHome(); killer.SendLocalizedMessage(1042230); // The sigil has gone back to its home location. } else if (Sigil.ExistsOn(killer)) { sigil.ReturnHome(); killer.SendLocalizedMessage(1010258); // The sigil has gone back to its home location because you already have a sigil. } else if (!killerPack.TryDropItem(killer, sigil, false)) { sigil.ReturnHome(); killer.SendLocalizedMessage(1010259); // The sigil has gone home because your backpack is full. } } else { sigil.ReturnHome(); } } } if (killerState == null) return; if (victim is BaseCreature) { BaseCreature bc = (BaseCreature)victim; Faction victimFaction = bc.FactionAllegiance; if (bc.Map == Faction.Facet && victimFaction != null && killerState.Faction != victimFaction) { int silver = killerState.Faction.AwardSilver(killer, bc.FactionSilverWorth); if (silver > 0) killer.SendLocalizedMessage(1042748, silver.ToString("N0")); // Thou hast earned ~1_AMOUNT~ silver for vanquishing the vile creature. } #region Ethics if (bc.Map == Faction.Facet && bc.GetEthicAllegiance(killer) == BaseCreature.Allegiance.Enemy) { Ethics.Player killerEPL = Ethics.Player.Find(killer); if (killerEPL != null && (100 - killerEPL.Power) > Utility.Random(100)) { ++killerEPL.Power; ++killerEPL.History; } } #endregion return; } PlayerState victimState = PlayerState.Find(victim); if (victimState == null) return; #region Dueling if (victim.Region.IsPartOf(typeof(Engines.ConPVP.SafeZone))) return; #endregion if (killer == victim || killerState.Faction != victimState.Faction) ApplySkillLoss(victim); if (killerState.Faction != victimState.Faction) { if (victimState.KillPoints <= -6) { killer.SendLocalizedMessage(501693); // This victim is not worth enough to get kill points from. #region Ethics Ethics.Player killerEPL = Ethics.Player.Find(killer); Ethics.Player victimEPL = Ethics.Player.Find(victim); if (killerEPL != null && victimEPL != null && victimEPL.Power > 0 && victimState.CanGiveSilverTo(killer)) { int powerTransfer = Math.Max(1, victimEPL.Power / 5); if (powerTransfer > (100 - killerEPL.Power)) powerTransfer = 100 - killerEPL.Power; if (powerTransfer > 0) { victimEPL.Power -= (powerTransfer + 1) / 2; killerEPL.Power += powerTransfer; killerEPL.History += powerTransfer; victimState.OnGivenSilverTo(killer); } } #endregion } else { int award = Math.Max(victimState.KillPoints / 10, 1); if (award > 40) award = 40; if (victimState.CanGiveSilverTo(killer)) { if (victimState.KillPoints > 0) { victimState.IsActive = true; if (1 > Utility.Random(3)) killerState.IsActive = true; int silver = 0; silver = killerState.Faction.AwardSilver(killer, award * 40); if (silver > 0) killer.SendLocalizedMessage(1042736, String.Format("{0:N0} silver\t{1}", silver, victim.Name)); // You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~! } victimState.KillPoints -= award; killerState.KillPoints += award; int offset = (award != 1 ? 0 : 2); // for pluralization string args = String.Format("{0}\t{1}\t{2}", award, victim.Name, killer.Name); killer.SendLocalizedMessage(1042737 + offset, args); // Thou hast been honored with ~1_KILL_POINTS~ kill point(s) for vanquishing ~2_DEAD_PLAYER~! victim.SendLocalizedMessage(1042738 + offset, args); // Thou has lost ~1_KILL_POINTS~ kill point(s) to ~3_ATTACKER_NAME~ for being vanquished! #region Ethics Ethics.Player killerEPL = Ethics.Player.Find(killer); Ethics.Player victimEPL = Ethics.Player.Find(victim); if (killerEPL != null && victimEPL != null && victimEPL.Power > 0) { int powerTransfer = Math.Max(1, victimEPL.Power / 5); if (powerTransfer > (100 - killerEPL.Power)) powerTransfer = 100 - killerEPL.Power; if (powerTransfer > 0) { victimEPL.Power -= (powerTransfer + 1) / 2; killerEPL.Power += powerTransfer; killerEPL.History += powerTransfer; } } #endregion victimState.OnGivenSilverTo(killer); } else { killer.SendLocalizedMessage(1042231); // You have recently defeated this enemy and thus their death brings you no honor. } } } }
protected override void OnTarget(Mobile from, object targeted) { if (m_belt.Deleted) { return; } else if (targeted is Mobile) { if (!BasePotion.HasFreeHand(from) && !BasePotion.HasBalancedWeapon(from)) { from.SendLocalizedMessage(1063299); // You must have a free hand to throw shuriken. return; } Mobile m = (Mobile)targeted; double dist = from.GetDistanceToSqrt(m.Location); if (m.Map != from.Map || dist > 11) { from.SendLocalizedMessage(500446); // That is too far away. return; } else if (from.InRange(m, 2)) { from.SendLocalizedMessage(1063303); // Your target is too close! return; } if (m != from && from.HarmfulCheck(m)) { Direction to = from.GetDirectionTo(m); from.Direction = to; from.RevealingAction(); from.Animate(from.Mounted ? 26 : 9, 7, 1, true, false, 0); if (Fukiya.CheckHitChance(from, m)) { from.MovingEffect(m, 0x27AC, 7, 1, false, false, 0x23A, 0); AOS.Damage(m, from, Utility.Random(3, 5), 100, 0, 0, 0, 0); if (m_belt.Poison != null && m_belt.PoisonCharges > 0) { --m_belt.PoisonCharges; Poison poison = m_belt.Poison; int maxLevel = from.Skills[SkillName.Poisoning].Fixed / 200; if (poison.Level > maxLevel) { poison = Poison.GetPoison(maxLevel); } m.ApplyPoison(from, poison); } } else { from.MovingEffect(new Shuriken(), 0x27AC, 7, 1, false, false, 0x23A, 0); from.SendMessage("You miss."); } // Throwing a shuriken restarts you weapon's swing delay from.NextCombatTime = DateTime.Now + from.Weapon.GetDelay(from); m_belt.UsesRemaining--; } } }
public virtual void DoAreaAttack( Mobile from, Mobile defender, int sound, int hue, int phys, int fire, int cold, int pois, int nrgy) { Map map = from.Map; if (map == null) { return; } var list = new List<Mobile>(); foreach (Mobile m in from.GetMobilesInRange(10)) { if (from != m && defender != m && SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false) && (!Core.ML || from.InLOS(m))) { list.Add(m); } } if (list.Count == 0) { return; } Effects.PlaySound(from.Location, map, sound); // TODO: What is the damage calculation? for (int i = 0; i < list.Count; ++i) { Mobile m = list[i]; double scalar = (11 - from.GetDistanceToSqrt(m)) / 10; if (scalar > 1.0) { scalar = 1.0; } else if (scalar < 0.0) { continue; } from.DoHarmful(m, true); m.FixedEffect(0x3779, 1, 15, hue, 0); AOS.Damage(m, from, (int)(GetBaseDamage(from) * scalar), phys, fire, cold, pois, nrgy); } }
protected override void OnTarget(Mobile from, object targeted) { base.OnTarget(from, targeted); if (from.GetDistanceToSqrt(m_KinSigil.Location) > 3) { from.SendMessage("You are too far away to do that."); return; } if (!(targeted != null && targeted is Silver)) { from.SendMessage("You may only pay with silver"); return; } Silver silver = (Silver)targeted; if (silver.Amount < 499) { from.SendMessage("You need at least 500 silver for a scouting report."); return; } int totalAmount = silver.Amount; silver.Delete(); int newAmount = totalAmount - 500; int modifier = (int)Math.Round((double)(newAmount / 100), 0.0); //75% chance for correct results with 0 mod // add 5% for each whole mod point if (modifier > 5) { modifier = 5; //25% max (1k silver) } string scoutReport = string.Empty; int days = GetDaysUntilSpawn(); if (!Utility.RandomChance(75 + (5 * modifier))) { //25% chance to be two days off if (Utility.RandomChance(25)) { days += (Utility.RandomBool() ? 2 : -2); } else //otherwise one day { days += (Utility.RandomBool() ? 1 : -1); } if (days < 0) { days = 0; } if (days < 10) { days = 10; } } scoutReport = string.Format("Your scouts report that in its current standing, the City of {0} has about {1} days before it falls.", m_KinSigil.FactionCity.ToString(), days); if (Utility.RandomChance(5)) { scoutReport = "Your scout party did not make it back alive."; } from.SendMessage("Your scouts will report back within a few minutes."); ScoutTimer timer = new ScoutTimer(from, scoutReport); timer.Start(); }
public static void EventSink_Login(LoginEventArgs e) { Mobile from = e.Mobile; Map map = from.Map; if (map == null) { return; } if (map.CanFit(from.X, from.Y, from.Z, 16, false, false)) { return; } bool isStranded = false; Tile landTile = map.Tiles.GetLandTile(from.X, from.Y); if ((landTile.ID >= 168 && landTile.ID <= 171) || (landTile.ID >= 310 && landTile.ID <= 311)) { isStranded = true; } else { Tile[] tiles = map.Tiles.GetStaticTiles(from.X, from.Y); for (int i = 0; !isStranded && i < tiles.Length; ++i) { Tile tile = tiles[i]; if (tile.ID >= 0x5797 && tile.ID <= 0x57B2) { isStranded = true; } } } if (!isStranded) { return; } Point2D[] list; if (map == Map.Felucca) { list = m_Felucca; } else if (map == Map.Trammel) { list = m_Trammel; } else if (map == Map.Ilshenar) { list = m_Ilshenar; } else { return; } Point2D p = Point2D.Zero; double pdist = double.MaxValue; for (int i = 0; i < list.Length; ++i) { double dist = from.GetDistanceToSqrt(list[i]); if (dist < pdist) { p = list[i]; pdist = dist; } } int x = p.X, y = p.Y; int z; bool canFit = false; z = map.GetAverageZ(x, y); canFit = map.CanSpawnMobile(x, y, z); for (int i = 1; !canFit && i <= 40; i += 2) { for (int xo = -1; !canFit && xo <= 1; ++xo) { for (int yo = -1; !canFit && yo <= 1; ++yo) { if (xo == 0 && yo == 0) { continue; } x = p.X + (xo * i); y = p.Y + (yo * i); z = map.GetAverageZ(x, y); canFit = map.CanSpawnMobile(x, y, z); } } } if (canFit) { from.Location = new Point3D(x, y, z); } }
public override void OnHit(Mobile attacker, Mobile defender, double damageBonus) { if (!(Ammo is ThrowingWeapon) && attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) && 0.4 >= Utility.RandomDouble()) { defender.AddToBackpack(Ammo); } if (defender is BaseCreature && Ammo is ThrowingWeapon && attacker.Player) { BaseCreature bc = (BaseCreature)defender; if (attacker.FindItemOnLayer(Layer.OneHanded) != null) { if (attacker.FindItemOnLayer(Layer.OneHanded) is ThrowingGloves) { ThrowingGloves glove = (ThrowingGloves)(attacker.FindItemOnLayer(Layer.OneHanded)); ThrowingWeapon knife = new ThrowingWeapon(); if (glove.GloveType == "Stones") { knife.ammo = "Throwing Stones"; knife.ItemID = 0x10B6; knife.Name = "throwing stone"; knife.Hue = 0x961; } else if (glove.GloveType == "Axes") { knife.ammo = "Throwing Axes"; knife.ItemID = 0x10B3; knife.Name = "throwing axe"; knife.Hue = 0; } else if (glove.GloveType == "Daggers") { knife.ammo = "Throwing Daggers"; knife.ItemID = 0x10B7; knife.Name = "throwing dagger"; knife.Hue = 0; } else if (glove.GloveType == "Darts") { knife.ammo = "Throwing Darts"; knife.ItemID = 0x10B5; knife.Name = "throwing dart"; knife.Hue = 0; } else { knife.ammo = "Throwing Stars"; knife.ItemID = 0x10B2; knife.Name = "throwing star"; knife.Hue = 0; } bc.PackItem(knife); } } } if (Core.ML && m_Velocity > 0) { int bonus = (int)attacker.GetDistanceToSqrt(defender); if (bonus > 0 && m_Velocity > Utility.Random(100)) { AOS.Damage(defender, attacker, bonus * 3, 100, 0, 0, 0, 0); if (attacker.Player) { attacker.SendLocalizedMessage(1072794); // Your arrow hits its mark with velocity! } if (defender.Player) { defender.SendLocalizedMessage(1072795); // You have been hit by an arrow with velocity! } } } base.OnHit(attacker, defender, damageBonus); }
protected virtual void Respawn() { if (!m_bActive || Deleted) { return; } if (DateTime.Now < m_SpawnTime) { return; } // Check to see if we can spawn more monsters int amount_spawned = 0; while (m_Monsters.Count + m_FreeMonsters.Count < Lvl_MaxMobs && amount_spawned < Lvl_MaxSpawn) { Mobile m = Spawn(); if (m == null) { return; } // Increase vars and place into the big wide world! (old code!) ++amount_spawned; m_Monsters.Add(m); m.MoveToWorld(GetSpawnLocation(m), Map); PrepMob(m); } m_SpawnTime = DateTime.Now + Lvl_SpawnDelay; // if free list has monsters in it, we convert them one a second // preferably away from the players Mobile victim = null; bool random = false; if (m_FreeMonsters.Count > 0) { // try and find a mob that can't be seen by a player for (int i = 0; i < m_FreeMonsters.Count; ++i) { Mobile m = (Mobile)m_FreeMonsters[i]; random = false; IPooledEnumerable eable = m.GetMobilesInRange(15); foreach (Mobile t in eable) { if (t is PlayerMobile) { // found a player. no good!. random = true; break; } } eable.Free(); if (!random) { // this mob will do! victim = m; m_FreeMonsters.RemoveAt(i); break; } } // if we couldn't find one out of sight, pick one at random if (random) { Random r = new Random(); int i = r.Next(m_FreeMonsters.Count); victim = (Mobile)m_FreeMonsters[i]; m_FreeMonsters.RemoveAt(i); } Mobile n = Spawn(); if (n == null) { return; } m_Monsters.Add(n); // we cannot reuse the location of a victem if they have different water/land domains bool sameType = (n.CanSwim == victim.CanSwim && n.CantWalk == victim.CantWalk); // perform rangecheck to see if we can just replace this mob with one from new level if (!random && sameType && victim.GetDistanceToSqrt(Location) <= Lvl_MaxRange) { // they are within spawn range, so replace with new mob in same location n.MoveToWorld(victim.Location, Map); } else // spawn somewhere randomly { n.MoveToWorld(GetSpawnLocation(n), Map); } //delete old mob victim.Delete(); // setup new mob PrepMob(n); } }
public override bool HandlesOnSpeech(Mobile from) { return(from.Alive && from.GetDistanceToSqrt(this) <= 3); }
protected override void OnTarget( Mobile from, object o ) { IPoint3D p = o as IPoint3D; if ( p != null ) { double distance = from.GetDistanceToSqrt( p ); // double skillvalue = from.Skills[ SkillName.Ninjitsu ].Value/10.0; // is this correct? double skillvalue = 11; // Xeor: tested on OSI if ( distance <= skillvalue ) { m_Owner.Target( p ); } else { from.SendLocalizedMessage( 502481 ); // That location is too far away. } } }
private static void ProcessDiscordance(object state) { DiscordanceInfo info = (DiscordanceInfo)state; Mobile from = info.m_From; Mobile targ = info.m_Creature; if (DateTime.Now >= info.m_EndTime || targ.Deleted || from.Map != targ.Map || targ.GetDistanceToSqrt(from) > 16) { if (info.m_Timer != null) { info.m_Timer.Stop(); } info.Clear(); m_Table.Remove(targ); } else { targ.FixedEffect(0x376A, 1, 32); } }
public void CheckGuardCandidate(Mobile m) { if (IsDisabled()) { return; } if (IsGuardCandidate(m)) { GuardTimer timer = null; m_GuardCandidates.TryGetValue(m, out timer); if (timer == null) { timer = new GuardTimer(m, m_GuardCandidates); timer.Start(); m_GuardCandidates[m] = timer; m.SendAsciiMessage("Guards can now be called on you!"); Map map = m.Map; if (map != null) { Mobile fakeCall = null; double prio = 0.0; foreach (Mobile v in m.GetMobilesInRange(8)) { if (!v.Player && v != m && !IsGuardCandidate(v) && ((v is BaseCreature) ? ((BaseCreature)v).IsHumanInTown() : (v.Body.IsHuman && v.Region.IsPartOf(this)))) { double dist = m.GetDistanceToSqrt(v); if (v is BaseGuard && ((BaseGuard)v).Focus != null && ((BaseGuard)v).Focus == m) { return; } if (fakeCall == null || dist < prio) { fakeCall = v; prio = dist; } } } if (fakeCall is BaseGuard && ((BaseGuard)fakeCall).Focus == null) { ((BaseGuard)fakeCall).Focus = m; return; } if (fakeCall != null) { switch (Utility.Random(9)) { case 0: fakeCall.Say(true, "I hope the guards catch thee, scum!"); break; case 1: fakeCall.Say(true, "Guards! Help!"); break; case 2: fakeCall.Say(true, "Thou'rt scum! Guards!"); break; case 3: fakeCall.Say(true, "Guards! A villain!"); break; case 4: fakeCall.Say(true, "Tis a villain! Guards!"); break; case 5: fakeCall.Say(true, "Help! Guards! Flood, fire, famine!"); break; case 6: fakeCall.Say(true, "Aaaah! They will kill me! Guards!"); break; case 7: fakeCall.Say(true, "Arrest this scum!"); break; case 8: fakeCall.Say(true, "Guards! Guards!"); break; } MakeGuard(m); //timer.Stop(); //m_GuardCandidates.Remove( m ); //m.SendAsciiMessage("Guards can no longer be called on you."); } } } else { timer.Stop(); timer.Start(); } } }
public void CheckGuardCandidate(Mobile m, bool autoCallGuards) { if (IsDisabled()) { return; } if (IsGuardCandidate(m)) { GuardTimer timer = null; m_GuardCandidates.TryGetValue(m, out timer); if (autoCallGuards) { MakeGuard(m); if (timer != null) { timer.Stop(); m_GuardCandidates.Remove(m); m.SendLocalizedMessage(502276); // Guards can no longer be called on you. } } else if (timer == null) { timer = new GuardTimer(m, m_GuardCandidates); timer.Start(); m_GuardCandidates[m] = timer; m.SendLocalizedMessage(502275); // Guards can now be called on you! Map map = m.Map; if (map != null) { Mobile fakeCall = null; double prio = 0.0; IPooledEnumerable eable = m.GetMobilesInRange(8); foreach (Mobile v in eable) { if (!v.Player && v != m && !IsGuardCandidate(v) && ((v is BaseCreature) ? ((BaseCreature)v).IsHumanInTown() : (v.Body.IsHuman && v.Region.IsPartOf(this)))) { double dist = m.GetDistanceToSqrt(v); if (fakeCall == null || dist < prio) { fakeCall = v; prio = dist; } } } eable.Free(); if (fakeCall != null) { fakeCall.Say(Utility.RandomList(1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052)); MakeGuard(m); timer.Stop(); m_GuardCandidates.Remove(m); m.SendLocalizedMessage(502276); // Guards can no longer be called on you. } } } else { timer.Stop(); timer.Start(); } } }
protected override void OnTick() { m_Tick++; if (!m_From.Alive || !m_Target.Alive || m_Target.Map != m_From.Map || m_Target.GetDistanceToSqrt(m_From.Location) > 10 || m_LastHit + TimeSpan.FromSeconds(20) < DateTime.Now || m_Tick > 36) { Server.Items.ForceOfNature.Remove(m_From); return; } if (m_Tick == 1) { int damage = Utility.RandomMinMax(15, 35); AOS.Damage(m_Target, m_From, damage, false, 0, 0, 0, 0, 0, 0, 100, false, false, false); } }
public void GroundSlap() { Map map = this.Map; if (map == null) { return; } ArrayList targets = new ArrayList(); foreach (Mobile m in this.GetMobilesInRange(8)) { if (m == this || !CanBeHarmful(m)) { continue; } if (m is BaseCreature && (((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned || ((BaseCreature)m).Team != this.Team)) { targets.Add(m); } else if (m.Player) { targets.Add(m); } } PlaySound(0x140); for (int i = 0; i < targets.Count; ++i) { Mobile m = (Mobile)targets[i]; int distance = (int)m.GetDistanceToSqrt(this); if (distance == 0) { distance = 1; } double damage = 75 / distance; damage = targets.Count * damage; damage = 10 * targets.Count; if (damage < 40.0) { damage = 40.0; } else if (damage > 75.0) { damage = 75.0; } DoHarmful(m); AOS.Damage(m, this, (int)damage, 100, 0, 0, 0, 0); m.FixedParticles(0x3728, 10, 15, 9955, EffectLayer.Waist); BaseMount.Dismount(m); if (m.Alive && m.Body.IsHuman && !m.Mounted) { m.Animate(20, 7, 1, true, false, 0); // take hit } } }
public override bool Obey() { if (m_Creature.Orb == null || !m_Creature.Controlled) { return(base.Obey()); } switch (m_Creature.Orb.Aggression) { default: { m_Creature.ControlOrder = OrderType.Follow; DoOrderFollow(); } break; case Aggression.Defensive: { if (m_Creature.Combatant != null) { if (m_Creature.ControlOrder == OrderType.Follow) { m_Creature.ControlOrder = OrderType.Attack; Action = ActionType.Combat; } break; } if (_NextAggressorCheck <= Core.TickCount) { IPoint3D p = m_Creature.Orb.GetAnchorActual(); double range = m_Creature.RangePerception; IPooledEnumerable eable = m_Creature.Map.GetMobilesInRange(new Point3D(p), (int)range); Mobile closest = null; foreach (Mobile m in eable) { if (m.Combatant == m_Creature || m.Combatant == m_Creature.ControlMaster) { double dist = closest == null ? range : closest.GetDistanceToSqrt(m_Creature); if (closest == null || dist < range) { range = dist; closest = m; } } } eable.Free(); if (closest != null) { m_Creature.ControlTarget = closest; m_Creature.ControlOrder = OrderType.Attack; m_Creature.Combatant = closest; m_Creature.DebugSay("But -that- is not dead. Here we go again..."); Action = ActionType.Combat; } _NextAggressorCheck = Core.TickCount + 1000; } } break; case Aggression.Aggressive: { if (m_Creature.Combatant != null) { if (m_Creature.ControlOrder == OrderType.Follow) { m_Creature.ControlOrder = OrderType.Attack; Action = ActionType.Combat; } break; } if (AcquireFocusMob(m_Creature.RangePerception, m_Creature.FightMode, false, false, true)) { if (m_Creature.FocusMob == m_Creature.ControlMaster) { break; } if (m_Creature.Debug) { m_Creature.DebugSay("I have detected {0}, attacking", m_Creature.FocusMob.Name); } m_Creature.ControlOrder = OrderType.Attack; m_Creature.Combatant = m_Creature.FocusMob; Action = ActionType.Combat; } } break; } if (m_Creature.Combatant == null) { m_Creature.ControlOrder = OrderType.Follow; m_Creature.ControlTarget = m_Creature.ControlMaster; Action = ActionType.Guard; DoOrderFollow(); } Think(); return(true); }
public override bool HandlesOnSpeech(Mobile from) { return(from.Alive && 0.05 > Utility.RandomDouble() && from.GetDistanceToSqrt(this) <= 10); }
public override void OnDoubleClick(Mobile from) { if (!from.InLOS(this.GetWorldLocation())) { from.SendLocalizedMessage(502800); // You can't see that. return; } if (from.GetDistanceToSqrt(this.GetWorldLocation()) > 4) { from.SendLocalizedMessage(500446); // That is too far away. return; } from.SendMessage("You have been given some supplies based on your skills."); //4 pouches for (int i = 0; i < 4; ++i) { Pouch p = new Pouch(); p.TrapType = TrapType.MagicTrap; p.TrapPower = 1; p.Hue = 0x25; PackItem(from, p); } if (from.Skills[SkillName.Magery].Value >= 50.0) { GiveLeatherArmor(from); } else { GiveBoneArmor(from); } if (from.Skills[SkillName.Magery].Value >= 50.0) { PackItem(from, new BagOfReagents()); } if (from.Skills[SkillName.Healing].Value >= 50.0) { PackItem(from, new Bandage(100)); } if (from.Skills[SkillName.Fencing].Value >= 50.0) { PackItem(from, new ShortSpear()); if (from.Skills[SkillName.Parry].Value >= 50.0) { GiveItem(from, new Kryss()); GiveItem(from, new MetalKiteShield()); } else { GiveItem(from, new Spear()); } } if (from.Skills[SkillName.Swords].Value >= 50.0) { if (from.Skills[SkillName.Parry].Value >= 50.0) { GiveItem(from, new MetalKiteShield()); } GiveItem(from, new Katana()); GiveItem(from, new Halberd()); } if (from.Skills[SkillName.Macing].Value >= 50.0) { if (from.Skills[SkillName.Parry].Value >= 50.0) { GiveItem(from, new MetalKiteShield()); } GiveItem(from, new WarAxe()); GiveItem(from, new WarHammer()); } if (from.Skills[SkillName.Archery].Value >= 50.0) { GiveItem(from, new HeavyCrossbow()); GiveItem(from, new Crossbow()); GiveItem(from, new Bow()); PackItem(from, new Bolt(100)); PackItem(from, new Arrow(100)); } if (from.Skills[SkillName.Poisoning].Value >= 50.0) { for (int i = 0; i < 5; i++) { PackItem(from, new GreaterPoisonPotion()); } } PlayerMobile pm = (PlayerMobile)(from); Container bag = new Bag(); Container backpack = pm.Backpack; for (int i = 0; i < 20; i++) { GreaterCurePotion cure = new GreaterCurePotion(); bag.DropItem(cure); } for (int i = 0; i < 20; i++) { GreaterHealPotion heal = new GreaterHealPotion(); bag.DropItem(heal); } for (int i = 0; i < 20; i++) { TotalRefreshPotion refresh = new TotalRefreshPotion(); bag.DropItem(refresh); } backpack.DropItem(bag); }
public virtual void DoAreaAttack( Mobile from, Mobile defender, int sound, int hue, int phys, int fire, int cold, int pois, int nrgy ) { Map map = from.Map; if ( map == null ) return; List<Mobile> list = new List<Mobile>(); int range = Core.ML ? 5 : 10; IPooledEnumerable eable = from.GetMobilesInRange(range); foreach ( Mobile m in eable ) { if ( from != m && defender != m && SpellHelper.ValidIndirectTarget( from, m ) && from.CanBeHarmful( m, false ) && ( !Core.ML || from.InLOS( m ) ) ) list.Add( m ); } eable.Free(); if ( list.Count == 0 ) return; Effects.PlaySound( from.Location, map, sound ); for ( int i = 0; i < list.Count; ++i ) { Mobile m = list[i]; double scalar = Core.ML ? 1.0 : ( 11 - from.GetDistanceToSqrt( m ) ) / 10; double damage = GetBaseDamage( from ); if(scalar <= 0) { continue; } else if( scalar < 1.0 ) { damage *= ( 11 - from.GetDistanceToSqrt( m ) ) / 10; } from.DoHarmful( m, true ); m.FixedEffect( 0x3779, 1, 15, hue, 0 ); AOS.Damage(m, from, (int)damage, phys, fire, cold, pois, nrgy); } }
public bool MoveToNearestDockOrLand(Mobile from) { if ((Boat != null && !Boat.Contains(from)) || !ValidateDockOrLand()) { return(false); } Map map = Map; if (map == null) { return(false); } Rectangle2D rec; Point3D nearest = Point3D.Zero; Point3D p = Point3D.Zero; if (Boat is RowBoat) { rec = new Rectangle2D(Boat.X - 8, Boat.Y - 8, 16, 16); } else { switch (Boat.Facing) { default: case Direction.North: case Direction.South: if (X < Boat.X) { rec = new Rectangle2D(X - 8, Y - 8, 8, 16); } else { rec = new Rectangle2D(X, Y - 8, 8, 16); } break; case Direction.West: case Direction.East: if (Y < Boat.Y) { rec = new Rectangle2D(X - 8, Y - 8, 16, 8); } else { rec = new Rectangle2D(X - 8, Y, 16, 8); } break; } } for (int x = rec.X; x <= rec.X + rec.Width; x++) { for (int y = rec.Y; y <= rec.Y + rec.Height; y++) { p = new Point3D(x, y, map.GetAverageZ(x, y)); if (ValidateTile(from, ref p)) { if (nearest == Point3D.Zero || from.GetDistanceToSqrt(p) < from.GetDistanceToSqrt(nearest)) { nearest = p; } } } } if (nearest != Point3D.Zero) { BaseCreature.TeleportPets(from, nearest, Map); from.MoveToWorld(nearest, Map); if (Boat != null) { Boat.Refresh(); } return(true); } return(false); }
private static Point3D GetNearestShrine( Mobile m ) { Map map = m.Map; Point3D[] locList; if( map == Map.Felucca || map == Map.Trammel ) locList = m_BritanniaLocs; else if( map == Map.Ilshenar ) locList = m_IllshLocs; else if( map == Map.Tokuno ) locList = m_TokunoLocs; else if( map == Map.Malas ) locList = m_MalasLocs; else locList = new Point3D[0]; Point3D closest = Point3D.Zero; double minDist = double.MaxValue; for( int i = 0; i < locList.Length; i++ ) { Point3D p = locList[i]; double dist = m.GetDistanceToSqrt( p ); if( minDist > dist ) { closest = p; minDist = dist; } } return closest; }
public override void OnDoubleClick( Mobile from ) { if ( from.AccessLevel >= AccessLevel.GameMaster ) { if ( m_Game == null || m_Team == null ) from.SendGump( new PropertiesGump( from, this ) ); else from.SendGump( new PropertiesGump( from, m_Team ) ); } else if ( m_Team != null && m_Game != null ) { if ( !m_Game.Running ) { from.SendMessage( "The game is currently closed." ); return; } CTFTeam team = m_Game.GetTeam( from ) as CTFTeam; if ( team != null ) { if ( !from.InLOS( GetWorldLocation() ) ) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. return; } else if ( from.GetDistanceToSqrt( GetWorldLocation() ) > 3 ) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. return; } if ( RootParent is Mobile ) { if ( RootParent == from ) { from.Target = new CaptureTarget( this ); from.SendMessage( "Target your flag to capture, or target a team-mate to pass the flag." );//"What do you wish to do with the flag?" ); } } else { if (team != m_Team) { if (!m_Home) from.SendAsciiMessage("Simply step on the flag to grab it"); else { if (from.Backpack != null) { from.RevealingAction(); from.Backpack.DropItem(this); from.SendMessage("You got the enemy flag!"); BeginCapture(); m_Game.AnnounceToPlayers("{0} ({1}) got the {2} flag!", from.Name, team.Name, m_Team.Name); } else from.SendMessage("You have no backpack to carry that flag!"); } } else if (!m_Home) from.SendAsciiMessage("Simply step on the flag to return it"); } } else { from.SendMessage( "You are not part of the game." ); } } }
public override void OnHit( Mobile attacker, Mobile defender, double damageBonus ) { if ( attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) && 0.4 >= Utility.RandomDouble() ) defender.AddToBackpack( Ammo ); if ( Core.ML && m_Velocity > 0 ) { int bonus = (int) attacker.GetDistanceToSqrt( defender ); if ( bonus > 0 && m_Velocity > Utility.Random( 100 ) ) { AOS.Damage( defender, attacker, bonus * 3, 100, 0, 0, 0, 0 ); if ( attacker.Player ) attacker.SendLocalizedMessage( 1072794 ); // Your arrow hits its mark with velocity! if ( defender.Player ) defender.SendLocalizedMessage( 1072795 ); // You have been hit by an arrow with velocity! } } base.OnHit( attacker, defender, damageBonus ); }
protected override void OnTarget(Mobile from, object targ) { if (targ is RanchStone) { RanchStone stone = (RanchStone)targ; if (stone.Owner == from) { if (t_rs.Map == stone.Map) { int ranchrange = (int)(from.GetDistanceToSqrt(t_rs.Location)); int ranchto = (int)(stone.Size / 2); int ranchfrom = (int)(t_rs.Size / 2); if ((ranchfrom >= (ranchrange - (ranchto + ranchfrom))) && t_rs.Size > stone.Size) { foreach (Item item in stone.GetItemsInRange(stone.Size + 1)) { if (item is FenceGate) { FenceGate fg = (FenceGate)item; if (fg.ranchstone == stone) { fg.ranchstone = t_rs; fg.InvalidateProperties(); } } else if (item is BaseFence) { BaseFence f = (BaseFence)item; if (f.ranchstone == stone) { f.ranchstone = t_rs; f.InvalidateProperties(); } } } RanchDeed rd = new RanchDeed(); from.AddToBackpack(rd); from.SendMessage("You absorb the ranch."); stone.Delete(); } else { from.SendMessage("Your ranch isn't big enough to absorb target ranch!"); } } else { from.SendMessage("That ranch is on a different facet!"); } } else { from.SendMessage("That's not your ranch!"); } } else { from.SendMessage("You can't absorb that!"); } from.SendGump(new RanchStoneGump(t_rs)); }
public override void OnDoubleClick( Mobile from ) { if ( !from.InRange( GetWorldLocation(), 2 ) ) { from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that. return; } Point2D[] banks; PMList moongates; if ( from.Map == Map.Trammel ) { banks = m_TrammelBanks; moongates = PMList.Trammel; } else if ( from.Map == Map.Felucca ) { banks = m_FeluccaBanks; moongates = PMList.Felucca; } else if ( from.Map == Map.Ilshenar ) { #if false banks = m_IlshenarBanks; moongates = PMList.Ilshenar; #else from.Send( new MessageLocalized( Serial, ItemID, MessageType.Label, 0x482, 3, 1061684, "", "" ) ); // The magic of the sextant fails... return; #endif } else if ( from.Map == Map.Malas ) { banks = m_MalasBanks; moongates = PMList.Malas; } else { banks = null; moongates = null; } Point3D closestMoongate = Point3D.Zero; double moongateDistance = double.MaxValue; if ( moongates != null ) { foreach ( PMEntry entry in moongates.Entries ) { double dist = from.GetDistanceToSqrt( entry.Location ); if ( moongateDistance > dist ) { closestMoongate = entry.Location; moongateDistance = dist; } } } Point2D closestBank = Point2D.Zero; double bankDistance = double.MaxValue; if ( banks != null ) { foreach ( Point2D p in banks ) { double dist = from.GetDistanceToSqrt( p ); if ( bankDistance > dist ) { closestBank = p; bankDistance = dist; } } } int moonMsg; if ( moongateDistance == double.MaxValue ) moonMsg = 1048021; // The sextant fails to find a Moongate nearby. else if ( moongateDistance > m_LongDistance ) moonMsg = 1046449 + (int)from.GetDirectionTo( closestMoongate ); // A moongate is * from here else if ( moongateDistance > m_ShortDistance ) moonMsg = 1048010 + (int)from.GetDirectionTo( closestMoongate ); // There is a Moongate * of here. else moonMsg = 1048018; // You are next to a Moongate at the moment. from.Send( new MessageLocalized( Serial, ItemID, MessageType.Label, 0x482, 3, moonMsg, "", "" ) ); int bankMsg; if ( bankDistance == double.MaxValue ) bankMsg = 1048020; // The sextant fails to find a Bank nearby. else if ( bankDistance > m_LongDistance ) bankMsg = 1046462 + (int)from.GetDirectionTo( closestBank ); // A town is * from here else if ( bankDistance > m_ShortDistance ) bankMsg = 1048002 + (int)from.GetDirectionTo( closestBank ); // There is a city Bank * of here. else bankMsg = 1048019; // You are next to a Bank at the moment. from.Send( new MessageLocalized( Serial, ItemID, MessageType.Label, 0x5AA, 3, bankMsg, "", "" ) ); }
public virtual bool CheckHit(Mobile attacker, Mobile defender) { BaseWeapon atkWeapon = attacker.Weapon as BaseWeapon; BaseWeapon defWeapon = defender.Weapon as BaseWeapon; Skill atkSkill = attacker.Skills[atkWeapon.Skill]; Skill defSkill = defender.Skills[defWeapon.Skill]; double atkValue = atkWeapon.GetAttackSkillValue(attacker, defender); double defValue = defWeapon.GetDefendSkillValue(attacker, defender); double ourValue, theirValue; int bonus = GetHitChanceBonus(); #region Stygian Abyss int hciMod = 0; int dciMod = 0; if (atkWeapon is BaseThrown) { int min = ((BaseThrown)atkWeapon).MinThrowRange; double dist = attacker.GetDistanceToSqrt(defender); //Distance malas if (attacker.InRange(defender, 1)) //Close Quarters bonus -= (12 - Math.Min(12, ((int)attacker.Skills[SkillName.Throwing].Value + attacker.RawDex) / 20)); else if (dist < min) //too close bonus -= 12; //shield penalty BaseShield shield = attacker.FindItemOnLayer(Layer.TwoHanded) as BaseShield; if (shield != null) { double skill = Math.Max(1.0, attacker.Skills[SkillName.Parry].Value); hciMod = (int)Math.Min(50, 1200 / skill); } } #endregion if (Core.AOS) { if (atkValue <= -20.0) atkValue = -19.9; if (defValue <= -20.0) defValue = -19.9; bonus += AosAttributes.GetValue(attacker, AosAttribute.AttackChance); #region SA // this value will not be shown on the status bar if (hciMod > 0) bonus -= (int)(((double)bonus * ((double)hciMod / 100))); #endregion //SA Gargoyle cap is 50, else 45 bonus = Math.Min(attacker.Race == Race.Gargoyle ? 50 : 45, bonus); ourValue = (atkValue + 20.0) * (100 + bonus); bonus = AosAttributes.GetValue(defender, AosAttribute.DefendChance); ForceArrow.ForceArrowInfo info = ForceArrow.GetInfo(attacker, defender); if (info != null && info.Defender == defender) bonus -= info.DefenseChanceMalus; #region SA // Like HitChance, this value is not shown in the status window if (defWeapon is BaseThrown) { BaseShield shield = defender.FindItemOnLayer(Layer.TwoHanded) as BaseShield; if (shield != null) { double skill = Math.Max(1.0, defender.Skills[SkillName.Parry].Value); dciMod = (int)Math.Min(50, 1200 / skill); } } if (dciMod > 0) bonus -= (int)(((double)bonus * ((double)dciMod / 100))); #endregion int max = 45 + BaseArmor.GetRefinedDefenseChance(defender); // Defense Chance Increase = 45% if (bonus > max) bonus = max; theirValue = (defValue + 20.0) * (100 + bonus); bonus = 0; } else { if (atkValue <= -50.0) { atkValue = -49.9; } if (defValue <= -50.0) { defValue = -49.9; } ourValue = (atkValue + 50.0); theirValue = (defValue + 50.0); } double chance = ourValue / (theirValue * 2.0); chance *= 1.0 + ((double)bonus / 100); if (Core.AOS && chance < 0.02) { chance = 0.02; } return attacker.CheckSkill(atkSkill.SkillName, chance); }
public override bool HandlesOnSpeech(Mobile from) { return (from.Alive && from.GetDistanceToSqrt(this) <= 3); }
public virtual bool RangeCheck() { Mobile master = ControlMaster; if (Deleted || master == null || master.Deleted) { return(false); } int dist = (int)master.GetDistanceToSqrt(Location); if (master.Map != Map || dist > 15) { if (m_SeperationStart == DateTime.MinValue) { m_SeperationStart = DateTime.UtcNow + TimeSpan.FromMinutes(60); } else if (m_SeperationStart < DateTime.UtcNow) { Delete(); } return(false); } if (m_SeperationStart != DateTime.MinValue) { m_SeperationStart = DateTime.MinValue; } int range = 4; if (!InRange(ControlMaster.Location, RangeHome) && InLOS(ControlMaster)) { Point3D loc = Point3D.Zero; if (Map == master.Map) { int x = (X > master.X) ? (master.X + range) : (master.X - range); int y = (Y > master.Y) ? (master.Y + range) : (master.Y - range); for (int i = 0; i < 10; i++) { loc.X = x + Utility.RandomMinMax(-1, 1); loc.Y = y + Utility.RandomMinMax(-1, 1); loc.Z = Map.GetAverageZ(loc.X, loc.Y); if (Map.CanSpawnMobile(loc)) { break; } loc = master.Location; } if (!Deleted) { SetLocation(loc, true); } } return(false); } return(true); }
public override void OnHit(Mobile attacker, IDamageable damageable, double damageBonus) { if (AmmoType != null && attacker.Player && damageable is Mobile && !((Mobile)damageable).Player && (((Mobile)damageable).Body.IsAnimal || ((Mobile)damageable).Body.IsMonster) && 0.4 >= Utility.RandomDouble()) { ((Mobile)damageable).AddToBackpack(Ammo); } if (Core.ML && m_Velocity > 0) { int bonus = (int)attacker.GetDistanceToSqrt(damageable); if (bonus > 0 && m_Velocity > Utility.Random(100)) { AOS.Damage(damageable, attacker, bonus * 3, 100, 0, 0, 0, 0); if (attacker.Player) { attacker.SendLocalizedMessage(1072794); // Your arrow hits its mark with velocity! } if (damageable is Mobile && ((Mobile)damageable).Player) { ((Mobile)damageable).SendLocalizedMessage(1072795); // You have been hit by an arrow with velocity! } } } base.OnHit(attacker, damageable, damageBonus); }
public void LockpickHold(Mobile from, Lockpick lockpick) { if (from == null || lockpick == null || this.Deleted || this == null) { return; } //NPC Ship if (m_Ship.MobileControlType != MobileControlType.Player) { if (m_Ship.HasCrewAlive()) { from.SendMessage("You cannot access that ship's hold while it's crew members still live."); return; } else { from.SendMessage("With the ship's crew dead, you may access the hold freely."); return; } } Effects.PlaySound(Location, Map, 0x241); from.BeginAction((typeof(Lockpick))); Timer.DelayCall(TimeSpan.FromSeconds(3.0), delegate() { if (from != null) { from.EndAction(typeof(Lockpick)); } if (this == null) { return; } if (this.Deleted) { return; } if (from.GetDistanceToSqrt(this) > 2) { from.SendMessage("You are too far away from the hold to continue lockpicking."); return; } if (!from.Alive) { return; } double lockpickingSkill = from.Skills[SkillName.Lockpicking].Value; double successChance = (lockpickingSkill - 95) * .02; //10% At GM double chanceResult = Utility.RandomDouble(); //Succeed Lockpicking if (chanceResult < successChance) { Effects.PlaySound(Location, Map, 0x4A); from.SendMessage("You succeed in breaking into the ship's hold"); base.OnDoubleClick(from); return; } //Fail Lockpicking else { if (Utility.RandomDouble() > .5) { Effects.PlaySound(Location, Map, 0x3A4); from.SendMessage("You fail to break into the ship's hold and break your lockpick in the process."); lockpick.Consume(); return; } else { from.SendMessage("You fail to break into the ship's hold"); return; } } }); }
public virtual void OnHit(Mobile attacker, Mobile defender, double damageBonus) { if (MirrorImage.HasClone(defender) && (defender.Skills.Ninjitsu.Value / 150.0) > Utility.RandomDouble()) { Clone bc; foreach (Mobile m in defender.GetMobilesInRange(4)) { bc = m as Clone; if (bc != null && bc.Summoned && bc.SummonMaster == defender) { attacker.SendLocalizedMessage(1063141); // Your attack has been diverted to a nearby mirror image of your target! defender.SendLocalizedMessage(1063140); // You manage to divert the attack onto one of your nearby mirror images. /* * TODO: What happens if the Clone parries a blow? * And what about if the attacker is using Honorable Execution * and kills it? */ defender = m; break; } } } PlaySwingAnimation(attacker); PlayHurtAnimation(defender); attacker.PlaySound(GetHitAttackSound(attacker, defender)); defender.PlaySound(GetHitDefendSound(attacker, defender)); int damage = ComputeDamage(attacker, defender); #region Damage Multipliers /* * The following damage bonuses multiply damage by a factor. * Capped at x3 (300%). */ int percentageBonus = 0; WeaponAbility a = WeaponAbility.GetCurrentAbility(attacker); SpecialMove move = SpecialMove.GetCurrentMove(attacker); if (a != null) { percentageBonus += (int)(a.DamageScalar * 100) - 100; } if (move != null) { percentageBonus += (int)(move.GetDamageScalar(attacker, defender) * 100) - 100; } percentageBonus += (int)(damageBonus * 100) - 100; CheckSlayerResult cs = CheckSlayers(attacker, defender); if (cs != CheckSlayerResult.None) { if (cs == CheckSlayerResult.Slayer) { defender.FixedEffect(0x37B9, 10, 5); } percentageBonus += 100; } if (!attacker.Player) { if (defender is PlayerMobile) { PlayerMobile pm = (PlayerMobile)defender; if (pm.EnemyOfOneType != null && pm.EnemyOfOneType != attacker.GetType()) { percentageBonus += 100; } } } else if (!defender.Player) { if (attacker is PlayerMobile) { PlayerMobile pm = (PlayerMobile)attacker; if (pm.WaitingForEnemy) { pm.EnemyOfOneType = defender.GetType(); pm.WaitingForEnemy = false; } if (pm.EnemyOfOneType == defender.GetType()) { defender.FixedEffect(0x37B9, 10, 5, 1160, 0); percentageBonus += 50; } } } int packInstinctBonus = GetPackInstinctBonus(attacker, defender); if (packInstinctBonus != 0) { percentageBonus += packInstinctBonus; } if (m_InDoubleStrike) { percentageBonus -= 10; } TransformContext context = TransformationSpellHelper.GetContext(defender); if ((m_Slayer == SlayerName.Silver || m_Slayer2 == SlayerName.Silver) && context != null && context.Spell is NecromancerSpell && context.Type != typeof(HorrificBeastSpell)) { // Every necromancer transformation other than horrific beast takes an additional 25% damage percentageBonus += 25; } if (attacker is PlayerMobile && !(Core.ML && defender is PlayerMobile)) { PlayerMobile pmAttacker = (PlayerMobile)attacker; if (pmAttacker.HonorActive && pmAttacker.InRange(defender, 1)) { percentageBonus += 25; } if (pmAttacker.SentHonorContext != null && pmAttacker.SentHonorContext.Target == defender) { percentageBonus += pmAttacker.SentHonorContext.PerfectionDamageBonus; } } #region Stygian Abyss percentageBonus += BattleLust.GetBonus(attacker, defender); if (this is BaseThrown) { double dist = attacker.GetDistanceToSqrt(defender); int max = ((BaseThrown)this).MaxThrowRange; if (dist > max) percentageBonus -= 47; } if (attacker.Race == Race.Gargoyle) { double perc = ((double)attacker.Hits / (double)attacker.HitsMax) * 100; perc = 100 - perc; perc /= 20; if (perc > 4) percentageBonus += 60; else if (perc >= 3) percentageBonus += 45; else if (perc >= 2) percentageBonus += 30; else if (perc >= 1) percentageBonus += 15; } #endregion #region Mondain's Legacy if (Core.ML) { BaseTalisman talisman = attacker.Talisman as BaseTalisman; if (talisman != null && talisman.Killer != null) { percentageBonus += talisman.Killer.DamageBonus(defender); } if (this is ButchersWarCleaver) { if (defender is Bull || defender is Cow || defender is Gaman) { percentageBonus += 100; } } } #endregion percentageBonus = Math.Min(percentageBonus, 300); damage = AOS.Scale(damage, 100 + percentageBonus); #endregion if (attacker is BaseCreature) { ((BaseCreature)attacker).AlterMeleeDamageTo(defender, ref damage); } if (defender is BaseCreature) { ((BaseCreature)defender).AlterMeleeDamageFrom(attacker, ref damage); } damage = AbsorbDamage(attacker, defender, damage); if (!Core.AOS && damage < 1) { damage = 1; } else if (Core.AOS && damage == 0) // parried { if (a != null && a.Validate(attacker) /*&& a.CheckMana( attacker, true )*/) // Parried special moves have no mana cost { a = null; WeaponAbility.ClearCurrentAbility(attacker); attacker.SendLocalizedMessage(1061140); // Your attack was parried! } } #region Mondain's Legacy if (m_Immolating) { int d = ImmolatingWeaponSpell.GetImmolatingDamage(this); d = AOS.Damage(defender, attacker, d, 0, 100, 0, 0, 0); AttuneWeaponSpell.TryAbsorb(defender, ref d); if (d > 0) { defender.Damage(d); } } #endregion #region SA if (m_SearingWeapon && attacker.Mana > 0) { int d = SearingWeaponContext.Damage; if ((this is BaseRanged && 10 > Utility.Random(100)) || 20 > Utility.Random(100)) { AOS.Damage(defender, attacker, d, 0, 100, 0, 0, 0); AOS.Damage(attacker, null, 4, false, 0, 0, 0, 0, 0, 0, 100, false, false, false); defender.FixedParticles(0x36F4, 1, 11, 0x13A8, 0, 0, EffectLayer.Waist); SearingWeaponContext.CheckHit(defender); attacker.Mana--; } } bool splintering = false; if (m_AosWeaponAttributes.SplinteringWeapon > 0 && m_AosWeaponAttributes.SplinteringWeapon > Utility.Random(100)) { if (SplinteringWeaponContext.CheckHit(attacker, defender, this)) splintering = true; } #endregion AddBlood(attacker, defender, damage); int phys, fire, cold, pois, nrgy, chaos, direct; GetDamageTypes(attacker, out phys, out fire, out cold, out pois, out nrgy, out chaos, out direct); if (Core.ML && this is BaseRanged) { BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver; if (quiver != null) { quiver.AlterBowDamage(ref phys, ref fire, ref cold, ref pois, ref nrgy, ref chaos, ref direct); } } if (m_Consecrated) { phys = defender.PhysicalResistance; fire = defender.FireResistance; cold = defender.ColdResistance; pois = defender.PoisonResistance; nrgy = defender.EnergyResistance; int low = phys, type = 0; if (fire < low) { low = fire; type = 1; } if (cold < low) { low = cold; type = 2; } if (pois < low) { low = pois; type = 3; } if (nrgy < low) { low = nrgy; type = 4; } phys = fire = cold = pois = nrgy = chaos = direct = 0; if (type == 0) { phys = 100; } else if (type == 1) { fire = 100; } else if (type == 2) { cold = 100; } else if (type == 3) { pois = 100; } else if (type == 4) { nrgy = 100; } } // TODO: Scale damage, alongside the leech effects below, to weapon speed. if (ImmolatingWeaponSpell.IsImmolating(this) && damage > 0) { ImmolatingWeaponSpell.DoEffect(this, defender); } int damageGiven = damage; if (a != null && !a.OnBeforeDamage(attacker, defender)) { WeaponAbility.ClearCurrentAbility(attacker); a = null; } if (move != null && !move.OnBeforeDamage(attacker, defender)) { SpecialMove.ClearCurrentMove(attacker); move = null; } bool ignoreArmor = (a is ArmorIgnore || (move != null && move.IgnoreArmor(attacker))); damageGiven = AOS.Damage( defender, attacker, damage, ignoreArmor, phys, fire, cold, pois, nrgy, chaos, direct, false, this is BaseRanged, false); #region Stygian Abyss SoulChargeContext.CheckHit(attacker, defender, damageGiven); #endregion double propertyBonus = (move == null) ? 1.0 : move.GetPropertyBonus(attacker); if (Core.AOS) { int lifeLeech = 0; int stamLeech = 0; int manaLeech = 0; int wraithLeech = 0; if ((int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitLeechHits) * propertyBonus) > Utility.Random(100)) { lifeLeech += 30; // HitLeechHits% chance to leech 30% of damage as hit points } if ((int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitLeechStam) * propertyBonus) > Utility.Random(100)) { stamLeech += 100; // HitLeechStam% chance to leech 100% of damage as stamina } if ((int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitLeechMana) * propertyBonus) > Utility.Random(100)) { manaLeech += 40; // HitLeechMana% chance to leech 40% of damage as mana } if (m_Cursed) { lifeLeech += 50; // Additional 50% life leech for cursed weapons (necro spell) } context = TransformationSpellHelper.GetContext(attacker); if (context != null && context.Type == typeof(VampiricEmbraceSpell)) { lifeLeech += 20; // Vampiric embrace gives an additional 20% life leech } if (context != null && context.Type == typeof(WraithFormSpell)) { wraithLeech = (5 + (int)((15 * attacker.Skills.SpiritSpeak.Value) / 100)); // Wraith form gives an additional 5-20% mana leech // Mana leeched by the Wraith Form spell is actually stolen, not just leeched. defender.Mana -= AOS.Scale(damageGiven, wraithLeech); manaLeech += wraithLeech; } if (lifeLeech != 0) { int toHeal = AOS.Scale(damageGiven, lifeLeech); #region High Seas if (defender is BaseCreature && ((BaseCreature)defender).TaintedLifeAura) { AOS.Damage(attacker, defender, toHeal, false, 0, 0, 0, 0, 0, 0, 100, false, false, false); attacker.SendLocalizedMessage(1116778); //The tainted life force energy damages you as your body tries to absorb it. } else attacker.Hits += toHeal; #endregion } if (stamLeech != 0) { attacker.Stam += AOS.Scale(damageGiven, stamLeech); } if (manaLeech != 0) { attacker.Mana += AOS.Scale(damageGiven, manaLeech); } if (lifeLeech != 0 || stamLeech != 0 || manaLeech != 0) { attacker.PlaySound(0x44D); } } if (m_MaxHits > 0 && ((MaxRange <= 1 && (defender is Slime || defender is ToxicElemental || defender is CorrosiveSlime)) || splintering || Utility.Random(25) == 0)) // Stratics says 50% chance, seems more like 4%.. { if (MaxRange <= 1 && (defender is Slime || defender is ToxicElemental || defender is CorrosiveSlime)) { attacker.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500263); // *Acid blood scars your weapon!* } if (Core.AOS && m_AosWeaponAttributes.SelfRepair + (IsSetItem && m_SetEquipped ? m_SetSelfRepair : 0) > Utility.Random(10)) { HitPoints += 2; } else { if (m_Hits > 0) { --HitPoints; } else if (m_MaxHits > 1) { --MaxHitPoints; if (Parent is Mobile) { ((Mobile)Parent).LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061121); // Your equipment is severely damaged. } } else { Delete(); } } } if (attacker is VampireBatFamiliar) { BaseCreature bc = (BaseCreature)attacker; Mobile caster = bc.ControlMaster; if (caster == null) { caster = bc.SummonMaster; } if (caster != null && caster.Map == bc.Map && caster.InRange(bc, 2)) { caster.Hits += damage; } else { bc.Hits += damage; } } if (Core.AOS) { int physChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitPhysicalArea) * propertyBonus); int fireChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitFireArea) * propertyBonus); int coldChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitColdArea) * propertyBonus); int poisChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitPoisonArea) * propertyBonus); int nrgyChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitEnergyArea) * propertyBonus); if (physChance != 0 && physChance > Utility.Random(100)) { DoAreaAttack(attacker, defender, 0x10E, 50, 100, 0, 0, 0, 0); } if (fireChance != 0 && fireChance > Utility.Random(100)) { DoAreaAttack(attacker, defender, 0x11D, 1160, 0, 100, 0, 0, 0); } if (coldChance != 0 && coldChance > Utility.Random(100)) { DoAreaAttack(attacker, defender, 0x0FC, 2100, 0, 0, 100, 0, 0); } if (poisChance != 0 && poisChance > Utility.Random(100)) { DoAreaAttack(attacker, defender, 0x205, 1166, 0, 0, 0, 100, 0); } if (nrgyChance != 0 && nrgyChance > Utility.Random(100)) { DoAreaAttack(attacker, defender, 0x1F1, 120, 0, 0, 0, 0, 100); } int maChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitMagicArrow) * propertyBonus); int harmChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitHarm) * propertyBonus); int fireballChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitFireball) * propertyBonus); int lightningChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitLightning) * propertyBonus); int dispelChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitDispel) * propertyBonus); #region Stygian Abyss int curseChance = (int)(m_AosWeaponAttributes.HitCurse * propertyBonus); int fatigueChance = (int)(m_AosWeaponAttributes.HitFatigue * propertyBonus); int manadrainChance = (int)(m_AosWeaponAttributes.HitManaDrain * propertyBonus); #endregion if (maChance != 0 && maChance > Utility.Random(100)) { DoMagicArrow(attacker, defender); } if (harmChance != 0 && harmChance > Utility.Random(100)) { DoHarm(attacker, defender); } if (fireballChance != 0 && fireballChance > Utility.Random(100)) { DoFireball(attacker, defender); } if (lightningChance != 0 && lightningChance > Utility.Random(100)) { DoLightning(attacker, defender); } if (dispelChance != 0 && dispelChance > Utility.Random(100)) { DoDispel(attacker, defender); } #region Stygian Abyss if (curseChance != 0 && curseChance > Utility.Random(100)) { DoCurse(attacker, defender); } if (fatigueChance != 0 && fatigueChance > Utility.Random(100)) { DoFatigue(attacker, defender, damageGiven); } if (manadrainChance != 0 && manadrainChance > Utility.Random(100)) { DoManaDrain(attacker, defender, damageGiven); } #endregion int laChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitLowerAttack) * propertyBonus); int ldChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitLowerDefend) * propertyBonus); if (laChance != 0 && laChance > Utility.Random(100)) { DoLowerAttack(attacker, defender); } if (ldChance != 0 && ldChance > Utility.Random(100)) { DoLowerDefense(attacker, defender); } } if (attacker is BaseCreature) { ((BaseCreature)attacker).OnGaveMeleeAttack(defender); } if (defender is BaseCreature) { ((BaseCreature)defender).OnGotMeleeAttack(attacker); } if (a != null) { a.OnHit(attacker, defender, damage); } if (move != null) { move.OnHit(attacker, defender, damage); } if (defender is IHonorTarget && ((IHonorTarget)defender).ReceivedHonorContext != null) { ((IHonorTarget)defender).ReceivedHonorContext.OnTargetHit(attacker); } if (!(this is BaseRanged)) { if (AnimalForm.UnderTransformation(attacker, typeof(GiantSerpent))) { defender.ApplyPoison(attacker, Poison.Lesser); } if (AnimalForm.UnderTransformation(defender, typeof(BullFrog))) { attacker.ApplyPoison(defender, Poison.Regular); } } XmlAttach.OnWeaponHit(this, attacker, defender, damageGiven); }
public override void OnDoubleClick(Mobile from) { Faction faction = Faction.Find(from); if (!IsChildOf(from.Backpack)) { // That is not in your backpack. from.SendLocalizedMessage(1042593); } else if (faction == null) { // You may not use this unless you are a faction member! from.SendLocalizedMessage(1010376, null, 0x25); } else if (m_CooldownTable.ContainsKey(from)) { Timer cooldownTimer = m_CooldownTable[from]; // You must wait ~1_seconds~ seconds before you can use this item. from.SendLocalizedMessage(1079263, (cooldownTimer.Next - DateTime.Now).Seconds.ToString()); } else { for (int x = -5; x <= 5; x++) { for (int y = -5; y <= 5; y++) { Point3D p = new Point3D(from.Location.X + x, from.Location.Y + y, from.Location.Z); int dist = (int)Utility.GetDistanceToSqrt(from.Location, p); if (dist <= 5) { Timer.DelayCall(TimeSpan.FromSeconds(0.2 * dist), new TimerCallback( delegate { Effects.SendPacket(from, from.Map, new HuedEffect(EffectType.FixedXYZ, Serial.Zero, Serial.Zero, 0x3709, p, p, 20, 30, true, false, 1502, 4)); } )); } } } double alchemy = from.Skills[SkillName.Alchemy].Value; int damage = (int)BasePotion.Scale(from, 19 + alchemy / 5); foreach (Mobile to in from.GetMobilesInRange(5).ToArray()) { int distance = (int)from.GetDistanceToSqrt(to); if (to != from && distance <= 5 && from.CanSee(to) && from.InLOS(to) && SpellHelper.ValidIndirectTarget(from, to) && from.CanBeHarmful(to) && !to.Hidden) { AOS.Damage(to, from, damage - distance, 0, 100, 0, 0, 0); } } Consume(); m_CooldownTable[from] = Timer.DelayCall(Cooldown, new TimerCallback(delegate { m_CooldownTable.Remove(from); })); } }
protected override void OnTarget(Mobile from, object targeted) { if (m_Axe.Deleted) { return; } else if (!from.Items.Contains(m_Axe)) { from.SendMessage("You must be holding that weapon to use it."); } else if (targeted is Mobile) { Mobile m = (Mobile)targeted; if (m != from && from.HarmfulCheck(m)) { Direction to = from.GetDirectionTo(m); from.Direction = to; from.Animate(from.Mounted ? 26 : 9, 7, 1, true, false, 0); if (from.CheckTargetSkill(SkillName.Throwing, m, 40.0, 100.0)) { from.MovingEffect(m, 0x1BFE, 7, 1, false, false, 0x481, 0); int distance = (int)from.GetDistanceToSqrt(m.Location); int mindamage = m_Axe.MinDamage; if (from.Dex > 100) mindamage += 2; distance -= (int)from.Skills[SkillName.Tactics].Value / 20; if (distance < 0) distance = 0; int count = (int)from.Skills[SkillName.Throwing].Value / 10; count += (int)from.Skills[SkillName.Anatomy].Value / 20; if (distance > 6) count -= distance - 5; AOS.Damage(m, from,Utility.Random(mindamage,count) - distance/2, true,0,0,0,0,0,0,100,false,false,false); m_Axe.MoveToWorld(m.Location, m.Map); } else { int x = 0, y = 0; switch (to & Direction.Mask) { case Direction.North: --y; break; case Direction.South: ++y; break; case Direction.West: --x; break; case Direction.East: ++x; break; case Direction.Up: --x; --y; break; case Direction.Down: ++x; ++y; break; case Direction.Left: --x; ++y; break; case Direction.Right: ++x; --y; break; } x += Utility.Random(-1, 3); y += Utility.Random(-1, 3); x += m.X; y += m.Y; m_Axe.MoveToWorld(new Point3D(x, y, m.Z), m.Map); from.MovingEffect(m_Axe, 0x1BFE, 7, 1, false, false, 0x481, 0); from.SendMessage("You miss."); } m_Axe.HitPoints -= 1; } } }
public void Invoke( Mobile from, object targeted ) { CancelTimeout(); from.ClearTarget(); if ( from.Deleted ) { OnTargetCancel( from, TargetCancelType.Canceled ); OnTargetFinish( from ); return; } IPoint3D loc; Map map; if ( targeted is LandTarget ) { loc = ( (LandTarget) targeted ).Location; map = from.Map; } else if ( targeted is StaticTarget ) { loc = ( (StaticTarget) targeted ).Location; map = from.Map; } else if ( targeted is Mobile ) { if ( ( (Mobile) targeted ).Deleted ) { OnTargetDeleted( from, targeted ); OnTargetFinish( from ); return; } else if ( !( (Mobile) targeted ).CanTarget ) { OnTargetUntargetable( from, targeted ); OnTargetFinish( from ); return; } loc = ( (Mobile) targeted ).Location; map = ( (Mobile) targeted ).Map; } else if ( targeted is Item ) { Item item = (Item) targeted; if ( item.Deleted ) { OnTargetDeleted( from, targeted ); OnTargetFinish( from ); return; } else if ( !item.CanTarget ) { OnTargetUntargetable( from, targeted ); OnTargetFinish( from ); return; } object root = item.RootParent; if ( !m_AllowNonlocal && root is Mobile && root != from && from.AccessLevel == AccessLevel.Player ) { OnNonlocalTarget( from, targeted ); OnTargetFinish( from ); return; } loc = item.GetWorldLocation(); map = item.Map; } else { OnTargetCancel( from, TargetCancelType.Canceled ); OnTargetFinish( from ); return; } if ( map == null || map != from.Map || ( m_Range != -1 && (int) from.GetDistanceToSqrt( loc ) > m_Range ) ) { OnTargetOutOfRange( from, targeted ); } else { if ( !from.CanSee( targeted ) ) OnCantSeeTarget( from, targeted ); else if ( m_CheckLOS && !from.InLOS( targeted ) ) OnTargetOutOfLOS( from, targeted ); else if ( targeted is Item && ( (Item) targeted ).InSecureTrade ) OnTargetInSecureTrade( from, targeted ); else if ( targeted is Item && !( (Item) targeted ).IsAccessibleTo( from ) ) OnTargetNotAccessible( from, targeted ); else if ( targeted is Item && !( (Item) targeted ).CheckTarget( from, this, targeted ) ) OnTargetUntargetable( from, targeted ); else if ( targeted is Mobile && !( (Mobile) targeted ).CheckTarget( from, this, targeted ) ) OnTargetUntargetable( from, targeted ); else if ( from.Region.OnTarget( from, this, targeted ) ) OnTarget( from, targeted ); } OnTargetFinish( from ); }