public void AttemptDiscovery(Mobile from, Item item) { bool success = false; double userSkill = from.Skills.Cartography.Value; double baseChance = 0; double finalChance = 0; if (userSkill < 95) { from.SendMessage("You do not have enough cartography skill to make an appropriate discovery attempt from this."); return; } if (item is TreasureMap) { TreasureMap treasureMap = item as TreasureMap; switch (treasureMap.Level) { case 0: baseChance = 0.025; break; case 1: baseChance = 0.05; break; case 2: baseChance = 0.10; break; case 3: baseChance = 0.15; break; case 4: baseChance = 0.20; break; case 5: baseChance = 0.25; break; case 6: baseChance = 0.30; break; case 7: baseChance = 0.50; break; } } else if (item is SOS) { SOS sos = item as SOS; switch (sos.Level) { case 1: baseChance = 0.10; break; case 2: baseChance = 0.15; break; case 3: baseChance = 0.20; break; case 4: baseChance = 0.25; break; case 5: baseChance = 0.30; break; } } finalChance = baseChance * userSkill / 120; if (Utility.RandomDouble() <= finalChance) { success = true; } if (success) { item.Delete(); AddDiscovery(from); } else { if (Utility.RandomDouble() <= .25) { from.SendSound(0x5BB); from.SendMessage("You exhaust your expertise on the map's contents, and are certain no discoveries shall ever be found within."); item.Delete(); } else { from.SendSound(0x100); from.SendMessage("You take great effort to search the map for hidden discoveries, but alas none reveal themselves to you at the moment."); } } }
public override Item Construct(Type type, Mobile from) { if (type == typeof(TreasureMap)) { int level; //if ( from is PlayerMobile && ((PlayerMobile)from).Young && from.Map == Map.Trammel && TreasureMap.IsInHavenIsland( from ) ) // level = 0; //else level = 1; return(new TreasureMap(level, /*from.Map == Map.Felucca ?*/ Map.Felucca /* : Map.Trammel*/)); } else if (type == typeof(MessageInABottle)) { return(new MessageInABottle(/*from.Map == Map.Felucca ?*/ Map.Felucca /* : Map.Trammel*/)); } Container pack = from.Backpack; if (pack != null) { List <SOS> messages = pack.FindItemsByType <SOS>(); for (int i = 0; i < messages.Count; ++i) { SOS sos = messages[i]; if (from.Map == sos.TargetMap && from.InRange(sos.TargetLocation, 60)) { Item preLoot = null; switch (Utility.Random(8)) { case 0: // Body parts { int[] list = new int[] { 0x1CDD, 0x1CE5, // arm 0x1CE0, 0x1CE8, // torso 0x1CE1, 0x1CE9, // head 0x1CE2, 0x1CEC // leg }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); break; } case 1: // Bone parts { int[] list = new int[] { 0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4, // skulls 0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles 0x1B15, 0x1B16 // pelvis bones }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); break; } case 2: // Paintings and portraits { preLoot = new ShipwreckedItem(Utility.Random(0xE9F, 10)); break; } case 3: // Pillows { preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11)); break; } case 4: // Shells { preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9)); break; } case 5: //Hats { if (Utility.RandomBool()) { preLoot = new SkullCap(); } else { preLoot = new TricorneHat(); } break; } case 6: // Misc { int[] list = new int[] { 0x1EB5, // unfinished barrel 0xA2A, // stool 0xC1F, // broken clock 0x1047, 0x1048, // globe 0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4 // barrel staves }; if (Utility.Random(list.Length + 1) == 0) { preLoot = new Candelabra(); } else { preLoot = new ShipwreckedItem(Utility.RandomList(list)); } break; } } if (preLoot != null) { if (preLoot is IShipwreckedItem) { ((IShipwreckedItem)preLoot).IsShipwreckedItem = true; } return(preLoot); } LockableContainer chest = null; switch (Utility.Random(3)) { case 0: chest = new MetalGoldenChest(); break; case 1: chest = new MetalChest(); break; default: case 2: chest = new WoodenChest(); break; } if (sos.IsAncient) { int hue = 1150; if (0.20 > Utility.RandomDouble()) { switch (Utility.Random((chest is WoodenChest) ? 6 : 14)) { case 0: hue = 1193; break; case 1: hue = 1281; break; case 2: hue = 1190; break; case 3: hue = 1165; break; case 4: hue = 1160; break; case 5: hue = 1126; break; case 6: hue = CraftResources.GetInfo(CraftResource.Valorite).Hue; break; case 7: hue = CraftResources.GetInfo(CraftResource.Verite).Hue; break; case 8: hue = CraftResources.GetInfo(CraftResource.Agapite).Hue; break; case 9: hue = CraftResources.GetInfo(CraftResource.Gold).Hue; break; case 10: hue = CraftResources.GetInfo(CraftResource.Bronze).Hue; break; case 11: hue = CraftResources.GetInfo(CraftResource.Copper).Hue; break; case 12: hue = CraftResources.GetInfo(CraftResource.ShadowIron).Hue; break; case 13: hue = CraftResources.GetInfo(CraftResource.DullCopper).Hue; break; } } chest.Hue = hue; } else if ((chest is MetalChest || chest is MetalGoldenChest) && (0.5 * sos.Level) >= Utility.RandomDouble()) { int randhue = Utility.Random(120); CraftResource resource = CraftResource.None; if (randhue >= 118) { resource = CraftResource.Valorite; } else if (randhue >= 115) { resource = CraftResource.Verite; } else if (randhue >= 110) { resource = CraftResource.Agapite; } else if (randhue >= 100) { resource = CraftResource.Gold; } else if (randhue >= 90) { resource = CraftResource.Bronze; } else if (randhue >= 70) { resource = CraftResource.Copper; } else if (randhue >= 40) { resource = CraftResource.ShadowIron; } else { resource = CraftResource.DullCopper; } chest.Hue = CraftResources.GetInfo(resource).Hue; } int soslevel = Math.Max(1, Math.Max(4, sos.Level)); TreasureMapChest.Fill(chest, soslevel); if (sos.IsAncient) { chest.DropItem(new FabledFishingNet()); } else { chest.DropItem(new SpecialFishingNet()); } chest.Movable = true; chest.Locked = false; chest.Name = "treasure chest"; chest.IsShipwreckedItem = true; if (sos.Level > 0) { chest.TrapType = TrapType.ExplosionTrap; chest.TrapPower = soslevel * Utility.RandomMinMax(5, 15); chest.TrapLevel = 0; } else { chest.TrapType = TrapType.None; chest.TrapPower = 0; chest.TrapLevel = 0; } sos.Delete(); return(chest); } } } return(base.Construct(type, from)); }
public override Item Construct(Type type, Mobile from, Item tool) { // Searing Weapon Support, handled elsewhere if (type == typeof(BaseWeapon)) { return(null); } if (type == typeof(TreasureMap)) { if (from.Map == Map.Tokuno) { return(new TreasureMap(0, Map.Tokuno)); } return(new TreasureMap(0, from.Map == Map.Felucca ? Map.Felucca : Map.Trammel)); } if (type == typeof(MessageInABottle)) { return(new MessageInABottle(from.Map == Map.Felucca ? Map.Felucca : Map.Trammel)); } if (type == typeof(WhitePearl)) { return(new WhitePearl()); } Container pack = from.Backpack; if (pack != null) { List <SOS> messages = pack.FindItemsByType <SOS>(); for (int i = 0; i < messages.Count; ++i) { SOS sos = messages[i]; if ((from.Map == Map.Felucca || from.Map == Map.Trammel) && from.InRange(sos.TargetLocation, 60)) { Item preLoot = null; bool dredge = HasTypeHook(tool, HookType.Dredging); switch (Utility.Random(17)) { case 0: // Body parts case 1: { int[] list = { 0x1CDD, 0x1CE5, // arm 0x1CE0, 0x1CE8, // torso 0x1CE1, 0x1CE9, // head 0x1CE2, 0x1CEC // leg }; preLoot = new ShipwreckedItem(Utility.RandomList(list), dredge); break; } case 2: // Bone parts case 3: { int[] list = { 0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4, // skulls 0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles 0x1B15, 0x1B16 // pelvis bones }; preLoot = new ShipwreckedItem(Utility.RandomList(list), dredge); break; } case 4: // Paintings and portraits case 5: { switch (Utility.Random(2)) { case 0: preLoot = new ShipwreckedItem(Utility.Random(0xE9F, 10), dredge); break; case 1: preLoot = new NewShipPaintings(); break; } break; } case 6: // Pillows case 7: { preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11), dredge); break; } case 8: // Shells case 9: { preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9), dredge); break; } case 10: //Hats case 11: { if (Utility.RandomBool()) { preLoot = new SkullCap(); } else { preLoot = new TricorneHat(); } break; } case 12: // Misc case 13: { int[] list = { 0x1EB5, // unfinished barrel 0xA2A, // stool 0xC1F, // broken clock 0x1047, 0x1048, // globe 0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4 // barrel staves }; if (Utility.Random(list.Length + 1) == 0) { switch (Utility.Random(5)) { case 0: preLoot = new Candelabra(); break; case 1: preLoot = new ShipAnchor(); break; case 2: preLoot = new ShipInBottle(); break; case 3: preLoot = new ShipChain(); break; case 4: preLoot = new ShipPorthole(); break; } } else { preLoot = new ShipwreckedItem(Utility.RandomList(list), dredge); } break; } case 14: { int[] list = { 0x1E19, 0x1E1A, 0x1E1B, //Fish heads 0x1E2A, 0x1E2B, //Oars 0x1E71, 0x1E7A, //Unfinished drawers 0x1E75 //Unfinished legs }; double ran = Utility.RandomDouble(); if (ran < 0.05) { preLoot = new YellowPolkaDotBikini(); } else if (ran < 0.25) { preLoot = new ShipwreckedItem(list[Utility.RandomMinMax(3, 7)], dredge); } else { preLoot = new ShipwreckedItem(list[Utility.Random(3)], dredge); } break; } } if (preLoot != null) { if (preLoot is IShipwreckedItem item) { item.IsShipwreckedItem = true; if (sos.IsAncient) { item.ShipwreckName = sos.ShipwreckName; } } return(preLoot); } LockableContainer chest; if (0.01 > Utility.RandomDouble()) { chest = new ShipsStrongbox(sos.Level); } else { switch (sos.Level) { case 0: chest = new SOSChest(Utility.RandomBool() ? 0xE43 : 0xE41); break; case 1: chest = new SOSChest(0xA306); break; case 2: chest = new SOSChest(Utility.RandomBool() ? 0xE43 : 0xE41); break; case 3: chest = new SOSChest(0xA308); break; default: if (.33 > Utility.RandomDouble()) { chest = new SOSChest(0xA30A); } else { chest = new SOSChest(Utility.RandomBool() ? 0xE41 : 0xE43) { Hue = 0x481 }; } break; } } TreasureMapChest.Fill(from, chest, Math.Max(1, Math.Min(4, sos.Level)), true); sos.OnSOSComplete(chest); if (sos.IsAncient) { chest.DropItem(new FabledFishingNet()); } else { chest.DropItem(new SpecialFishingNet()); } chest.Movable = true; chest.Locked = false; chest.TrapType = TrapType.None; chest.TrapPower = 0; chest.TrapLevel = 0; chest.IsShipwreckedItem = true; if (sos.IsAncient) { chest.ShipwreckName = sos.ShipwreckName; } sos.Delete(); return(chest); } } } return(base.Construct(type, from, tool)); }
public SOSEntry(SOS sos) : base(sos.TargetMap, sos.TargetLocation, sos.Level) { m_Opened = true; m_IsAncient = sos.IsAncient; m_MessageIndex = sos.MessageIndex; }
public IEnumerable <PeqParam> GetEmptyDspData(IEnumerable <int> biquads) { return(biquads.Select(bq => new PeqParam(SOS.Empty(), _flowId, bq, Model.SpeakerPeqType))); }
public override Item Construct(Type type, Mobile from) { if (type == typeof(TreasureMap)) { int level; if (from is PlayerMobile && ((PlayerMobile)from).Young && from.Map == Map.Trammel && TreasureMap.IsInHavenIsland(from)) { level = 0; } else { level = 1; } return(new TreasureMap(level, from.Map == Map.Felucca ? Map.Felucca : Map.Trammel)); } else if (type == typeof(MessageInABottle)) { return(new MessageInABottle(SafeMap(from.Map))); } Container pack = from.Backpack; if (pack != null) { Item[] messages = pack.FindItemsByType(typeof(SOS)); for (int i = 0; i < messages.Length; ++i) { SOS sos = (SOS)messages[i]; if (from.Map == sos.TargetMap && from.InRange(sos.TargetLocation, 60)) { Item preLoot = null; switch (Utility.Random(7)) { case 0: // Body parts { int[] list = new int[] { 0x1CDD, 0x1CE5, // arm 0x1CE0, 0x1CE8, // torso 0x1CE1, 0x1CE9, // head 0x1CE2, 0x1CEC // leg }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); break; } case 1: // Bone parts { int[] list = new int[] { 0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4, // skulls 0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles 0x1B15, 0x1B16 // pelvis bones }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); break; } case 2: // Paintings and portraits { preLoot = new ShipwreckedItem(Utility.Random(0xE9F, 10)); break; } case 3: // Pillows { preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11)); break; } case 4: // Shells { preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9)); break; } case 5: // Misc { int[] list = new int[] { 0x1EB5, // unfinished barrel 0xA2A, // stool 0xC1F, // broken clock 0x1047, 0x1048, // globe 0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4 // barrel staves }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); break; } } if (preLoot != null) { return(preLoot); } sos.Delete(); WoodenChest chest = new WoodenChest(); TreasureMapChest.Fill(chest, Utility.RandomMinMax(1, 3)); // TODO: Are there chances on this? All MIB's I've done had nets.. chest.DropItem(new SpecialFishingNet()); chest.Movable = true; chest.Locked = false; chest.TrapType = TrapType.None; chest.TrapPower = 0; return(chest); } } } return(base.Construct(type, from)); }
protected PeqParam GetSosParamPackage(SOS sos, int biquad) { return(new SafeLoadParam(sos, FlowId, biquad, _model.SpeakerPeqType)); }
public static IEnumerable<byte> SosBytes(SOS data, ushort address) { var bytes = new List<byte>(); foreach (var i in data.DspParams()) { IEnumerable<byte> arr = i.Get5P23Param(); var address1 = DspAddress(address++); bytes.AddRange(address1); bytes.AddRange(arr); } return bytes; }
/// <summary> /// filterMathCalculate.pdf - NOTE: this calculation is different from that of Sigma studio but the /// results are the same! /// </summary> /// <param name="lowOrHigh"> false == lowpass, true == highpass </param> /// <param name="gainLinear"> </param> /// <param name="sinw0"> </param> /// <param name="cosw0"> </param> /// <returns> </returns> private static SOS GetFirstOrderSOSCoeff(bool lowOrHigh, double gainLinear, double sinw0, double cosw0) { //% AD Sigma Studio method for 1st order filter //% (notation from FilterMathCalculations.pdf) //var sos = new SOS {A0 = sinw0 + cosw0 + 1}; //var sos = new SOS {A0 = sinw0 + cosw0 + 1 }; var x = sinw0 + cosw0 + 1; var sos = new SOS(); switch (lowOrHigh) { case false: //lowpass sos.A1 = (sinw0 - cosw0 - 1) / x; //% don't mix this up with a(1) sos.B0 = gainLinear * sinw0 / x; sos.B1 = sos.B0; break; case true: //highpass sos.A1 = (sinw0 - cosw0 - 1) / x; sos.B0 = gainLinear * (1 + cosw0) / x; sos.B1 = -sos.B0; break; } //sos = [b0 b1 0 1 a1 0]; //% SOS section with only a 1st order filter //return new SOS { A0 = sos.B0, A1 = sos.B1, A2 = 0, B0 = 1, B1 = sos.A1, B2 = 0 }; return sos; }
/// <summary> /// GETBIQUADSOS Biquad parameterized by gain, center frequency and octave bandwidth. /// SOS = GETBIQUADSOS(GAIN,OMEGA,OCTAVEBANDWIDTH) computes second-order /// section coefficients for biquads with gain GAIN, normalized center /// frequency OMEGA, and octave bandwidth OCTAVEBANDWIDTH. Bandwidth /// correction is performed depending on input variable CORRECTBANDWIDTH. /// SOS is a 1 by 6 array that contains the coefficients of the /// second-order section: /// SOS = [ b0 b1 b2 1 a1 a2] /// References: /// [1] Robert Bristow-Johnson. "The equivalence of various methods of /// computing biquad coefficients for audio parametric equalizers," /// presented at the 97th AES Convention, 10-13 November 1994, San /// Francisco, CA, USA. /// This function is based on /// $Id: rbjbiquad.m,v 1.2 2010/01/04 21:10:26 nw17581 Exp $ /// by Nate Whetsell Nate_Whetsell at bose.com and has been modified /// by Thomas Steinbrecher thomas_steinbrecher at bose.com 2012/01/12 /// (and equivalent to rbjbiquad_sparse.m) /// </summary> /// <param name="dbBoost"> </param> /// <param name="fc"> </param> /// <param name="octaveBandwidth"> </param> /// <param name="correctBandwith"> </param> /// <param name="fs"> </param> /// <param name="gain"></param> /// <returns> </returns> public static SOS GetBiquadSos(double dbBoost, double fc, double octaveBandwidth, bool correctBandwith, double fs, double gain = 0) { var omega = 2 * Math.PI * fc / Fs; var sqrtK = Math.Pow(10, dbBoost / 40); // initializations var sos = new SOS(); if (correctBandwith) { // equation (15) var sinOmega = Math.Sin(omega); //note: log base 10? var gamma = Math.Sinh(Math.Log(2) / 2 * octaveBandwidth * omega / sinOmega) * sinOmega; // equation (16) var gammaTimesSqrtK = gamma * sqrtK; var gammaOverSqrtK = gamma / sqrtK; var denom = 1 + gammaOverSqrtK; sos.B0 = (1 + gammaTimesSqrtK) / denom; sos.B1 = -2 * Math.Cos(omega) / denom; sos.B2 = (1 - gammaTimesSqrtK) / denom; sos.A0 = 1; sos.A1 = sos.B1; sos.A2 = (1 - gammaOverSqrtK) / denom; } else { //// equation between (10) and (11) //var alpha = 1 / sqrtK * Math.Sinh(Math.Log(2) / 2 * octaveBandwidth); //// equation (12) //// Note that: w0 in [1] is equal to 2/T*tan(omega/2). T = 1/fs, see (7). //var tanOmegaOver2 = Math.Tan(omega / 2); //var twoAlphaTanOmegaOver2 = 2 * alpha * tanOmegaOver2; //var tanOmegaOver2Squared = Math.Pow(tanOmegaOver2, 2); //var denom = 1 + tanOmegaOver2Squared + twoAlphaTanOmegaOver2; //sos.B0 = (1 + tanOmegaOver2Squared + dbBoost * twoAlphaTanOmegaOver2) / denom; //sos.B1 = -2 * (1 - tanOmegaOver2Squared) / denom; //sos.B2 = (1 + tanOmegaOver2Squared - dbBoost * twoAlphaTanOmegaOver2) / denom; //sos.A0 = 1; //sos.A1 = sos.B1; //sos.A2 = (1 + tanOmegaOver2Squared - twoAlphaTanOmegaOver2) / denom; var w0 = 2 * Math.PI * fc / fs; var gainLinear = Math.Pow(10, (gain / 40)); double A = dbBoost.A(); var alpha = Math.Sin(w0) / (2 * A * octaveBandwidth.Q()); sos.A0 = 1 + alpha / A; sos.A1 = -2 * Math.Cos(w0); sos.A2 = 1 - alpha / A; sos.B0 = (1 + alpha * A) * gainLinear; sos.B1 = -(2 * Math.Cos(w0)) * gainLinear; sos.B2 = (1 - alpha * A) * gainLinear; } return sos; // new SOS(sos.B0, sos.B1, sos.B2, sos.A0, sos.A1, sos.A2); }
public static IEnumerable<SOS> GetXoverSOS(double f0, int order, FilterType type, double fs, double gain) { var lstSos = new List<SOS>(); //false = low, true = high; var isHighpass = (type == FilterType.BesselHp || type == FilterType.ButterworthHp || type == FilterType.LinkWitzHp); // function [sos] = getXoverSOS(f0, LowOrHigh, order, type, Fs) //%GETXOVERSOS computes SOS coefficients for high- and lopasses. //% SOS = GETXOVERSOS(F0, TYPE, ORDER, FS) //% Input checking //error(nargchk(4,5,nargin)); //if nargin < 5, Fs = 48000; end % default sampling rate //if nargin < 4, type = 'Butterworth'; end % default filter type //butters = {'Butter','butter','But', 'butterworth'}; //linkwitzes = {'Linkwitz-Riley','LR','L-R'}; //bessels = {'bessel','Bes','bes'}; //if any(strcmp(type, butters)), type = 'Butterworth'; end //if any(strcmp(type, linkwitzes)), type = 'Linkwitz'; end //if any(strcmp(type, bessels)), type = 'Bessel'; end //allowedtypes = {'Butterworth','Linkwitz','Bessel'}; //if ~any(strcmp(type, allowedtypes)) // warning('getXoverSOS:WrongFilterType', ... // 'Sorry, no margarine for now. Will use butter instead.'); // type = 'Butterworth'; //end //if order > 6 // warning('getXoverSOS:OrderTooLarge', ... // 'Other methods like z-p-k syntax shall be used for orders larger than six.'); //end //lows = {'Low','low','Lo','lo'}; //highs = {'High','high','Hi','hi'}; //if any(strcmp(LowOrHigh, lows)) // LowOrHigh = 'Lowpass'; //elseif any(strcmp(LowOrHigh, highs)) // LowOrHigh = 'Highpass'; // else // error('getXoverSOS:WrongFilterType', ... // 'Unsupported LowOrHigh spec.'); //end //% Check order //isevenorder = order % 2; //if rem(order,2) == 0, isevenorder = 1; end //% Basics var w0 = 2 * Math.PI * f0 / fs; var sinw0 = Math.Sin(w0); var cosw0 = Math.Cos(w0); var gainLinear = Math.Pow(10, (gain / 20)); //% Get SOS coeffcients depending on filter type var a = new double[order]; var q = new double[order]; switch (type) { case FilterType.ButterworthHp: case FilterType.ButterworthLp: //% Calculate s-domain (Butterworth) coefficients //% Reference: Tietze/Schenk, 'Halbleiter-Schaltungstechnik', 10th ed., pp. 397) //% A0 //% A(s) = ------------------------------------------- p. 392, Eq. 14.4 //% (1+a(1)*s+b(1)*s^2)*(1+a(2)*s+b(2)*s^2)*... //% //% Note that below, the b(i) are just calculated for completeness, they are not //% required for the SOS construction using Q. //% Get a(i) and b(i) and also, SOS coeffcients if (order % 2 != 0) { //% 1st SOS section with only a 1st order filter: var fistSOS = GetFirstOrderSOSCoeff(isHighpass, gainLinear, sinw0, cosw0); //var fistSOS = FirsOrder(lowOrHigh, gainLinear, w0); lstSos.Add(fistSOS); //% now, remaining full SOS stages, if any; see T/S, p. 398. // a[1] = 1; // q[1] = 1; //% just for initialization //b(1) = 0; //% just for completeness for (var i = 2; i <= (order + 1) / 2; i++) { a[i] = 2 * Math.Cos(((i - 1) * Math.PI) / order); //b(i) = 1; q[i] = 1 / a[i]; //% see RBJ var higherSos = GetSOSCoeff(q[i], isHighpass, sinw0, cosw0); lstSos.Add(higherSos); } } else // % full SOS stages only, see T/S, p. 397. { for (var i = 1; i <= (order / 2); i++) //note:should add 2? { a[i] = 2 * Math.Cos(((2 * i - 1) * Math.PI) / (2 * order)); //b(i) = 1; q[i] = 1 / a[i]; var higherSos = GetSOSCoeff(q[i], isHighpass, sinw0, cosw0); lstSos.Add(higherSos); } } break; case FilterType.LinkWitzHp: case FilterType.LinkWitzLp: switch (order) { case 2: //% Two cascaded 1st order Butterworth filters //% LP2(s) = 1 / (1 + 2s + s^2) q[0] = .5; var sostemp = GetSOSCoeff(q[0], isHighpass, sinw0, cosw0); lstSos.Add(sostemp); break; case 4: // % Two cascaded 2nd order Butterworth filters //% LP4(s) = 1 / (1 + sqrt(2)s + s^2)^2 q[0] = 1 / Math.Sqrt(2); sostemp = GetSOSCoeff(q[0], isHighpass, sinw0, cosw0); lstSos.AddRange(Enumerable.Repeat(sostemp, 2)); break; case 6: //% Two cascaded 3rd order Butterworth filters //% LP6(s) = 1 /(1 + 2s + s^2)/(1 + s + s^2)^2 q = new[] { .5, 1, 1 }; lstSos.AddRange(q.Select(t => GetSOSCoeff(t, isHighpass, sinw0, cosw0))); break; case 8: //% Two cascaded 4th order Butterworth filters //% LP4(s) = [1 / (1 + 1.848 s + s^2)*(1 + 0.765 s + //% s^2)]^2 //% This will give a bad filter q = new[] { 1 / 1.848, 1 / 0.765, 1 / 1.848, 1 / 0.765 }; lstSos.AddRange(q.Select(t => GetSOSCoeff(t, isHighpass, sinw0, cosw0))); break; } // lstSos.AddRange(LinkWitz(f0, order, isHighpass, fs)); break; case FilterType.BesselLp: case FilterType.BesselHp: if (order < 2 || order > 4) throw new Exception( "getXoverSOS:WrongOrder Sorry, Bessel filters must be of order 2, 3 or 4."); //% Get basic 2nd order Bessel coefficients from //% FilterMathCalculations.pdf //% Note that normalization with a0 is performed right away, not as //% with getSOScoeff var alpha = sinw0 / (2 * (1 / Math.Sqrt(3))); var sos = new SOS { A0 = 1 + alpha, A1 = -(2 * cosw0), A2 = (1 - alpha) }; if (isHighpass) { sos.B1 = -(1 + cosw0) * gainLinear; sos.B0 = -sos.B1 / 2; sos.B2 = sos.B0; } else { sos.B1 = (1 - cosw0) * gainLinear; sos.B0 = sos.B1 / 2; sos.B2 = sos.B0; } //sos2 = [B0 B1 B2 1 A1 A2]; //% Get basic 1st order Butterworth coefficients from //% FilterMathCalculations.pdf //% Build all SOS switch (order) { case 2: lstSos.Add(sos); break; case 3: lstSos.Add(GetFirstOrderSOSCoeff(isHighpass, gainLinear, sinw0, cosw0)); lstSos.Add(sos); break; case 4: lstSos.Add(sos); lstSos.Add(sos); break; } break; } return lstSos; }
public SafeToneControl(SOS inputdata, int flow) : base(inputdata, flow) { }
public SafeLoadParam(SOS data, int flowId, int biquad, SpeakerPeqType speakerPeqType) : base(data, flowId, biquad, speakerPeqType) { }
public override Item Construct(Type type, Mobile from, object[] args) { if (type == typeof(TreasureMap)) { return(new TreasureMap(1, from.Map == Map.Felucca ? Map.Felucca : Map.Trammel)); } else if (type == typeof(MessageInABottle)) { // build a level N mib based on the good fishing map level if (args != null && args.Length == 2 && args[0] == typeof(MessageInABottle) && args[1] is int) { return(new MessageInABottle(SafeMap(from.Map), (int)args[1])); } return(new MessageInABottle(SafeMap(from.Map))); } Container pack = from.Backpack; if (pack != null) { Item[] messages = pack.FindItemsByType(typeof(SOS)); for (int i = 0; i < messages.Length; ++i) { SOS sos = (SOS)messages[i]; if (from.Map == sos.TargetMap && from.InRange(sos.TargetLocation, 60)) { Item preLoot = null; switch (Utility.Random(7)) { case 0: // Body parts { int[] list = new int[] { 0x1CDD, 0x1CE5, // arm 0x1CE0, 0x1CE8, // torso 0x1CE1, 0x1CE9, // head 0x1CE2, 0x1CEC // leg }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); break; } case 1: // Bone parts { int[] list = new int[] { 0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4, // skulls 0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles 0x1B15, 0x1B16 // pelvis bones }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); break; } case 2: // Paintings and portraits { preLoot = new ShipwreckedItem(Utility.Random(0xE9F, 10)); break; } case 3: // Pillows { preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11)); break; } case 4: // Shells { preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9)); break; } case 5: // Misc { int[] list = new int[] { 0x1EB5, // unfinished barrel 0xA2A, // stool 0xC1F, // broken clock 0x1047, 0x1048, // globe 0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4 // barrel staves }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); break; } } if (preLoot != null) { return(preLoot); } Container chest = null; if (sos.Level >= 4 && Utility.RandomChance(10)) { chest = new MetalGoldenChest(); } else { chest = new WoodenChest(); } // regular sos's have a chance at a 1, 2 or 3. high level sos's are high level chests int level = (sos.Level >= 4) ? sos.Level : Utility.RandomMinMax(1, 3); TreasureMapChest.Fill((chest as LockableContainer), level); // add 50% more gold since we are decreasing the chance to get rares Item[] golds = chest.FindItemsByType(typeof(Gold)); if (golds != null && golds.Length > 0) { int total = 0; for (int tx = 0; tx < golds.Length; tx++) { total += (golds[tx] as Gold).Amount; } // add 50% more gold chest.DropItem(new Gold(total / 2)); // add some cursed gold chest.DropItem(new CursedGold(total / 8)); } // adjust high end loot by removing high end weapons and armor if (sos.Level >= 4) { // trim the high end weps and armor so as not to to give away all the highend weapons usually reserved for Treasure Map hunters Item[] lootz = chest.FindItemsByType(new Type[] { typeof(EnchantedScroll), typeof(BaseArmor), typeof(BaseWeapon) }); int LootzKeep = level == 4 ? Utility.RandomList(2) + 2 : Utility.RandomList(3) + 2; if (lootz != null && lootz.Length > LootzKeep) { // remove some items as we're dropping too much for the sea chest int toDel = lootz.Length - LootzKeep; for (int ox = 0; ox < toDel; ox++) { Item dx = lootz[ox]; chest.RemoveItem(dx); dx.Delete(); } } } // TODO: Are there chances on this? All MIB's I've done had nets.. chest.DropItem(new SpecialFishingNet()); // add Good Fishing bonus lootz if (Utility.RandomChance(sos.Level * 8)) { switch (sos.Level) { case 1: if (Utility.RandomChance(10)) { Item[] list = new Item[] { new AddonDeed(0x0DBB), // 3515 (0x0DBB) Seaweed new AddonDeed(0x0C2E), // 3118 (0x0C2E) debris }; chest.DropItem(Utility.RandomList(list)); } else { Item[] list = new Item[] { new AddonDeed(0x154D), // 5453 (0x054D) water barrel – empty or filled we don't have them on ai yet. new AddonDeed(0x0DC9), // 3529 (0x0DC9) fishing net – unhued and oddly shaped }; chest.DropItem(Utility.RandomList(list)); } break; case 2: if (Utility.RandomChance(10)) { Item[] list = new Item[] { new AddonDeed(0x1E9A), // 7834 (0x1E9A) hook new AddonDeed(0x1E9D), // 7837 (0x1E9D) pulleys new AddonDeed(0x1E9E), // 7838 (0x1E9E) Pulley }; chest.DropItem(Utility.RandomList(list)); } else { Item[] list = new Item[] { new AddonDeed(0x1EA0), // 7840 (0x1EA0) Rope new AddonDeed(0x1EA9, Direction.South), // 7849 (0x1EA9) Winch – south new AddonDeed(0x1EAC, Direction.East), // 7852 (0x1EAC) Winch – east }; chest.DropItem(Utility.RandomList(list)); } break; case 3: if (Utility.RandomChance(10)) { Item[] list = new Item[] { new AddonDeed(0x0FCD, Direction.South), // 4045 (0x0FCD) string of shells – south new AddonDeed(0x0FCE, Direction.South), // 4046 (0x0FCE) string of shells – south new AddonDeed(0x0FCF, Direction.South), // 4047 (0x0FCF) – string of shells – south new AddonDeed(0x0FD0, Direction.South), // 4048 (0x0FD0) – string of shells – south new AddonDeed(0x0FD1, Direction.East), // 4049 (0x0FD1) – string of shells – east new AddonDeed(0x0FD2, Direction.East), // 4050 (0x0FD2) – string of shells – east new AddonDeed(0x0FD3, Direction.East), // 4051 (0x0FD3) – string of shells – east new AddonDeed(0x0FD4, Direction.East), // 4052 (0x0FD4) – string of shells – east }; chest.DropItem(Utility.RandomList(list)); } else { switch (Utility.Random(4)) { case 0: // 4099 (0x1003) – Spittoon chest.DropItem(new ShipwreckedItem(0x1003)); break; case 1: // 4091 (0x0FFB) – Skull mug 1 chest.DropItem(new ShipwreckedItem(0x0FFB)); break; case 2: // 4092 (0x0FFC) – Skull mug 2 chest.DropItem(new ShipwreckedItem(0x0FFC)); break; case 3: // 3700 (0x0E74) Cannon Balls chest.DropItem(new AddonDeed(0x0E74)); break; } } break; case 4: if (Utility.RandomChance(10)) { Item[] list = new Item[] { new AddonDeed(0x0C2C), // 3116 (0x0C2C) Ruined Painting new AddonDeed(0x0C18), // 3096 (0x0C18) Covered chair - (server birth on osi) }; chest.DropItem(Utility.RandomList(list)); } else { Item[] list = new Item[] { new AddonDeed(0x1EA3, Direction.South), // 7843 (0x1EA3) net – south new AddonDeed(0x1EA4, Direction.East), // 7844 (0x1EA4) net – east new AddonDeed(0x1EA5, Direction.South), // 7845 (0x1EA5) net – south new AddonDeed(0x1EA6, Direction.East), // 7846 (0x1EA6) net – east }; chest.DropItem(Utility.RandomList(list)); } break; case 5: if (Utility.RandomChance(10)) { Item[] list = new Item[] { new DarkFlowerTapestrySouthDeed(), new DarkFlowerTapestryEastDeed(), new LightTapestrySouthDeed(), new LightTapestryEastDeed(), }; chest.DropItem(Utility.RandomList(list)); } else { Item[] list = new Item[] { new DarkTapestrySouthDeed(), new DarkTapestryEastDeed(), new LightFlowerTapestrySouthDeed(), new LightFlowerTapestryEastDeed(), }; chest.DropItem(Utility.RandomList(list)); } break; } } // 1 in 1000 chance at the actual item (rare) if (Utility.RandomChance(.1)) { switch (sos.Level) { case 1: if (Utility.RandomChance(10)) { int[] list = new int[] { 0x0DBB, // 3515 (0x0DBB) Seaweed 0x0C2E, // 3118 (0x0C2E) debris }; chest.DropItem(new ShipwreckedItem(Utility.RandomList(list))); } else { int[] list = new int[] { 0x154D, // 5453 (0x054D) water barrel – empty or filled we don't have them on ai yet. 0x0DC9, // 3529 (0x0DC9) fishing net – unhued and oddly shaped }; chest.DropItem(new ShipwreckedItem(Utility.RandomList(list))); } break; case 2: if (Utility.RandomChance(10)) { int[] list = new int[] { 0x1E9A, // 7834 (0x1E9A) hook 0x1E9D, // 7837 (0x1E9D) pulleys 0x1E9E, // 7838 (0x1E9E) Pulley }; chest.DropItem(new ShipwreckedItem(Utility.RandomList(list))); } else { int[] list = new int[] { 0x1EA0, // 7840 (0x1EA0) Rope 0x1EA9, // 7849 (0x1EA9) Winch – south 0x1EAC, // 7852 (0x1EAC) Winch – east }; chest.DropItem(new ShipwreckedItem(Utility.RandomList(list))); } break; case 3: if (Utility.RandomChance(10)) { int[] list = new int[] { 0x0FCD, // 4045 (0x0FCD) string of shells – south 0x0FCE, // 4046 (0x0FCE) string of shells – south 0x0FCF, // 4047 (0x0FCF) – string of shells – south 0x0FD0, // 4048 (0x0FD0) – string of shells – south 0x0FD1, // 4049 (0x0FD1) – string of shells – east 0x0FD2, // 4050 (0x0FD2) – string of shells – east 0x0FD3, // 4051 (0x0FD3) – string of shells – east 0x0FD4, // 4052 (0x0FD4) – string of shells – east }; chest.DropItem(new ShipwreckedItem(Utility.RandomList(list))); } else { int[] list = new int[] { 0x1003, // 4099 (0x1003) – Spittoon 0x0FFB, // 4091 (0x0FFB) – Skull mug 1 0x0FFC, // 4092 (0x0FFC) – Skull mug 2 0x0E74, // 3700 (0x0E74) Cannon Balls }; chest.DropItem(new ShipwreckedItem(Utility.RandomList(list))); } break; case 4: if (Utility.RandomChance(10)) { int[] list = new int[] { 0x0C2C, // 3116 (0x0C2C) Ruined Painting 0x0C18, // 3096 (0x0C18) Covered chair - (server birth on osi) }; chest.DropItem(new ShipwreckedItem(Utility.RandomList(list))); } else { int[] list = new int[] { 0x1EA3, // 7843 (0x1EA3) net – south 0x1EA4, // 7844 (0x1EA4) net – east 0x1EA5, // 7845 (0x1EA5) net – south 0x1EA6, // 7846 (0x1EA6) net – east }; chest.DropItem(new ShipwreckedItem(Utility.RandomList(list))); } break; case 5: // same frequent drop if (Utility.RandomChance(10)) { Item[] list = new Item[] { new DarkFlowerTapestrySouthDeed(), new DarkFlowerTapestryEastDeed(), new LightTapestrySouthDeed(), new LightTapestryEastDeed(), }; chest.DropItem(Utility.RandomList(list)); } else { Item[] list = new Item[] { new DarkTapestrySouthDeed(), new DarkTapestryEastDeed(), new LightFlowerTapestrySouthDeed(), new LightFlowerTapestryEastDeed(), }; chest.DropItem(Utility.RandomList(list)); } break; } } (chest as LockableContainer).Movable = true; (chest as LockableContainer).Locked = false; (chest as LockableContainer).TrapType = TrapType.None; (chest as LockableContainer).TrapPower = 0; (chest as LockableContainer).TrapLevel = 0; sos.Delete(); return(chest); } } } return(base.Construct(type, from, args)); }
protected override void OnTarget(Mobile from, object target) { if (from == null) { return; } if (from.Deleted) { return; } if (m_AncientMysteryScroll == null) { return; } if (m_AncientMysteryScroll.Deleted || m_AncientMysteryScroll.RootParent != from) { return; } PlayerMobile pm = from as PlayerMobile; if (pm == null) { return; } if (target is ResearchMaterials) { ResearchMaterials researchMaterials = target as ResearchMaterials; if (m_AncientMysteryScroll.ResearchAdded >= AncientMysteryScroll.ResearchRequired) { from.SendMessage("This mystery already has enough research materials contributed."); } else if (!researchMaterials.Researched) { from.SendMessage("Those research materials have not yet been evaluated."); } else { m_AncientMysteryScroll.AddResearchMaterials(from, researchMaterials); } } else if (target is ResearchedMasterScroll) { ResearchedMasterScroll researchedMasterScroll = target as ResearchedMasterScroll; if (m_AncientMysteryScroll.ResearchAdded >= AncientMysteryScroll.ResearchRequired) { from.SendMessage("This mystery already has enough research materials contributed."); } else { m_AncientMysteryScroll.AddResearchedMasterScroll(from, researchedMasterScroll); } } else if (target is TreasureMap) { TreasureMap treasureMap = target as TreasureMap; if (m_AncientMysteryScroll.m_Discoveries.Count >= AncientMysteryScroll.DiscoveriesRequired) { from.SendMessage("This mystery already has a sufficient number of discoveries."); } else if (!treasureMap.Completed) { from.SendMessage("That treasure map has not been completed yet."); } else { m_AncientMysteryScroll.AttemptDiscovery(from, treasureMap); } } else if (target is SOS) { SOS sos = target as SOS; if (m_AncientMysteryScroll.m_Discoveries.Count >= AncientMysteryScroll.DiscoveriesRequired) { from.SendMessage("This mystery already has a sufficient number of discoveries."); } else if (!sos.Completed) { from.SendMessage("That SOS map has not been completed yet."); from.CloseGump(typeof(AncientMysteryGump)); from.SendGump(new AncientMysteryGump(m_AncientMysteryScroll, from)); } else { m_AncientMysteryScroll.AttemptDiscovery(from, sos); } } else { from.SendMessage("That is not research materials, a treasure map, or an SOS."); } from.CloseGump(typeof(AncientMysteryGump)); from.SendGump(new AncientMysteryGump(m_AncientMysteryScroll, from)); }
/// <summary> /// </summary> /// <param name="q"> </param> /// <param name="lowOrHigh"> false == lowpass, true == highpass </param> /// <param name="sinw0"> </param> /// <param name="cosw0"> </param> /// <returns> </returns> private static SOS GetSOSCoeff(double q, bool lowOrHigh, double sinw0, double cosw0) { //% Using RBJ method from 'audioEQ.m' by Michael Monks var alpha = sinw0 / (2 * q); var sos = new SOS(); switch (lowOrHigh) { case false: // % LPF: H(s) = 1 / (s^2 + s/Q + 1) sos.B0 = (1 - cosw0) / 2; sos.B1 = 1 - cosw0; sos.B2 = (1 - cosw0) / 2; sos.A0 = 1 + alpha; sos.A1 = -2 * cosw0; sos.A2 = 1 - alpha; break; case true: //% HPF: H(s) = s^2 / (s^2 + s/Q + 1) sos.B0 = (1 + cosw0) / 2; sos.B1 = -(1 + cosw0); sos.B2 = (1 + cosw0) / 2; sos.A0 = 1 + alpha; sos.A1 = -2 * cosw0; sos.A2 = 1 - alpha; break; } // b = [b0 b1 b2]/a0; // a = [a0 a1 a2]/a0; // sos = [b a]; //return new SOS // { // A0 = sos.B0 / sos.A0, // A1 = sos.B1 / sos.A0, // A2 = sos.B2 / sos.A0 // , // B0 = sos.A0 / sos.A0, // B1 = sos.A1 / sos.A0, // B2 = sos.A2 / sos.A0, // }; return sos; }
public override Item Construct(Type type, Mobile from) { if (type == typeof(TreasureMap)) { int level; if (from is PlayerMobile && ((PlayerMobile)from).Young && from.Map == Map.Trammel && TreasureMap.IsInHavenIsland(from)) { level = 0; } else { level = 1; } return(new TreasureMap(level, from.Map == Map.Felucca ? Map.Felucca : Map.Trammel)); } else if (type == typeof(MessageInABottle)) { return(new MessageInABottle(from.Map == Map.Felucca ? Map.Felucca : Map.Trammel)); } Container pack = from.Backpack; if (pack != null) { List <SOS> messages = pack.FindItemsByType <SOS>(); for (int i = 0; i < messages.Count; ++i) { SOS sos = messages[i]; if ((from.Map == Map.Felucca || from.Map == Map.Trammel) && from.InRange(sos.TargetLocation, 60)) { Item preLoot = null; switch (Utility.Random(8)) { case 0: // Body parts { int[] list = new int[] { 0x1CDD, 0x1CE5, // arm 0x1CE0, 0x1CE8, // torso 0x1CE1, 0x1CE9, // head 0x1CE2, 0x1CEC // leg }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); break; } case 1: // Bone parts { int[] list = new int[] { 0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4, // skulls 0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles 0x1B15, 0x1B16 // pelvis bones }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); break; } case 2: // Paintings and portraits { preLoot = new ShipwreckedItem(Utility.Random(0xE9F, 10)); break; } case 3: // Pillows { preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11)); break; } case 4: // Shells { preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9)); break; } case 5: //Hats { if (Utility.RandomBool()) { preLoot = new SkullCap(); } else { preLoot = new TricorneHat(); } break; } case 6: // Misc { int[] list = new int[] { 0x1EB5, // unfinished barrel 0xA2A, // stool 0xC1F, // broken clock 0x1047, 0x1048, // globe 0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4 // barrel staves }; if (Utility.Random(list.Length + 1) == 0) { preLoot = new Candelabra(); } else { preLoot = new ShipwreckedItem(Utility.RandomList(list)); } break; } } if (preLoot != null) { if (preLoot is IShipwreckedItem) { ((IShipwreckedItem)preLoot).IsShipwreckedItem = true; } return(preLoot); } LockableContainer chest; if (Utility.RandomBool()) { chest = new MetalGoldenChest(); } else { chest = new WoodenChest(); } if (sos.IsAncient) { chest.Hue = 0x481; } TreasureMapChest.Fill(chest, Math.Max(1, Math.Min(4, sos.Level))); if (sos.IsAncient) { chest.DropItem(new FabledFishingNet()); } else { chest.DropItem(new SpecialFishingNet()); } chest.Movable = true; chest.Locked = false; chest.TrapType = TrapType.None; chest.TrapPower = 0; chest.TrapLevel = 0; sos.Delete(); return(chest); } } } return(base.Construct(type, from)); }
public override Item Construct(Type type, Mobile from, Item _i, HarvestDefinition _d, HarvestBank _b, HarvestResource _r) { if (type == typeof(TreasureMap)) { int level = 1; return(new TreasureMap(level, Map.Felucca)); } else if (type == typeof(MessageInABottle)) { return(new MessageInABottle(Map.Felucca)); } Container pack = from.Backpack; if (pack != null) { List <SOS> messages = pack.FindItemsByType <SOS>(); for (int i = 0; i < messages.Count; ++i) { SOS sos = messages[i]; if (from.Map == sos.TargetMap && from.InRange(sos.TargetLocation, 60) && !sos.Completed) { Item preLoot = null; switch (Utility.Random(7)) { case 0: // Body parts { int[] list = new int[] { 0x1CDD, 0x1CE5, // arm 0x1CE0, 0x1CE8, // torso 0x1CE1, 0x1CE9, // head 0x1CE2, 0x1CEC // leg }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); break; } case 1: // Bone parts { int[] list = new int[] { 0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4, // skulls 0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles 0x1B15, 0x1B16 // pelvis bones }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); break; } case 2: // Pillows { preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11)); break; } case 3: // Shells { preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9)); break; } case 4: //Hats { if (Utility.RandomBool()) { preLoot = new SkullCap(); } else { preLoot = new TricorneHat(); } break; } case 5: // Misc { int[] list = new int[] { 0x1EB5, // unfinished barrel 0xA2A, // stool 0xC1F, // broken clock 0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4 // barrel staves }; if (Utility.Random(list.Length + 1) == 0) { preLoot = new Candelabra(); } else { preLoot = new ShipwreckedItem(Utility.RandomList(list)); } break; } } if (preLoot != null) { if (preLoot is IShipwreckedItem) { ((IShipwreckedItem)preLoot).IsShipwreckedItem = true; } return(preLoot); } LockableContainer chest; if (Utility.RandomBool()) { chest = new MetalGoldenChest(); } else { chest = new WoodenChest(); } if (sos.IsAncient) { chest.Hue = 0x481; } TreasureMapChest.Fill(chest, Math.Max(1, Math.Min(3, (sos.Level + 1)))); if (sos.IsAncient) { chest.DropItem(new FabledFishingNet()); } else { chest.DropItem(new SpecialFishingNet()); } if (Utility.Random(500) == 0) { Item mask = new HornedTribalMask(); mask.Hue = 2715; mask.Name = "Mask of Cthulu"; chest.DropItem(mask); } switch (Utility.Random(300)) { case 0: { Item rustedchest = new PlateChest(); rustedchest.Hue = 2718; rustedchest.Name = "a rusted platemail chest recovered from a shipwreck"; chest.DropItem(rustedchest); break; } case 1: { Item rustedarms = new PlateArms(); rustedarms.Hue = 2718; rustedarms.Name = "rusted platemail arms recovered from a shipwreck"; chest.DropItem(rustedarms); break; } case 2: { Item rustedlegs = new PlateLegs(); rustedlegs.Hue = 2718; rustedlegs.Name = "rusted platemail legguards recovered from a shipwreck"; chest.DropItem(rustedlegs); break; } case 3: { Item rustedgloves = new PlateGloves(); rustedgloves.Hue = 2718; rustedgloves.Name = "rusted platemail gloves recovered from a shipwreck"; chest.DropItem(rustedgloves); break; } case 4: { Item rustedgorget = new PlateGorget(); rustedgorget.Hue = 2718; rustedgorget.Name = "rusted platemail gorget recovered from a shipwreck"; chest.DropItem(rustedgorget); break; } case 5: { Item rustedhelm = new PlateHelm(); rustedhelm.Hue = 2718; rustedhelm.Name = "a rusted platemail helmet recovered from a shipwreck"; chest.DropItem(rustedhelm); break; } } switch (Utility.Random(400)) { case 0: { Item lamp = new LampPost1(); lamp.Name = "Britannia Head Light"; lamp.Hue = 2601; chest.DropItem(lamp); break; } case 1: { Item lantern = new HangingLantern(); lantern.Name = "Fog Lamp"; lantern.Hue = 2601; lantern.Movable = true; chest.DropItem(lantern); break; } } chest.Movable = true; chest.Locked = false; chest.TrapType = TrapType.None; chest.TrapPower = 0; chest.TrapLevel = 0; sos.Completed = true; BaseBoat ownerBoat = BaseBoat.FindBoatAt(from.Location, from.Map); PlayerMobile player = from as PlayerMobile; if (ownerBoat != null && player != null) { if (ownerBoat.IsFriend(player) || ownerBoat.IsOwner(player) || ownerBoat.IsCoOwner(player)) { double doubloonValue = Utility.RandomMinMax(25, 50); int finalDoubloonAmount = (int)doubloonValue; bool shipOwner = ownerBoat.IsOwner(player); bool bankDoubloonsValid = false; bool holdPlacementValid = false; //Deposit Half In Player's Bank if (Banker.DepositUniqueCurrency(player, typeof(Doubloon), finalDoubloonAmount)) { Doubloon doubloonPile = new Doubloon(finalDoubloonAmount); player.SendSound(doubloonPile.GetDropSound()); doubloonPile.Delete(); bankDoubloonsValid = true; } //Deposit Other Half in Ship if (ownerBoat.DepositDoubloons(finalDoubloonAmount)) { Doubloon doubloonPile = new Doubloon(finalDoubloonAmount); player.SendSound(doubloonPile.GetDropSound()); doubloonPile.Delete(); holdPlacementValid = true; } if (shipOwner) { player.PirateScore += finalDoubloonAmount; //ownerBoat.doubloonsEarned += finalDoubloonAmount * 2; if (bankDoubloonsValid && holdPlacementValid) { player.SendMessage("You've received " + (finalDoubloonAmount * 2).ToString() + " doubloons for completing a message in a bottle! They have been evenly split between your bank box and your ship's hold."); } else if (bankDoubloonsValid && !holdPlacementValid) { player.SendMessage("You've earned " + (finalDoubloonAmount * 2).ToString() + " doubloons, however there was not enough room to place all of them in your ship's hold."); } else if (!bankDoubloonsValid && holdPlacementValid) { player.SendMessage("You've earned " + (finalDoubloonAmount * 2).ToString() + " doubloons, however there was not enough room to place all of them in your bank box."); } } else { //ownerBoat.doubloonsEarned += finalDoubloonAmount; player.PirateScore += finalDoubloonAmount; if (bankDoubloonsValid) { player.SendMessage("You've earned " + finalDoubloonAmount.ToString() + " doubloons for completing a message in a bottle! They have been placed in your bank box."); } else { player.SendMessage("You've earned doubloons, but there was not enough room to place all of them in your bank box."); } } } } return(chest); } } } return(base.Construct(type, from, _i, _d, _b, _r)); }
public override Item Construct(Type type, Mobile from, Item tool) { // Searing Weapon Support if (type == typeof(BaseWeapon)) { return(null); } if (type == typeof(TreasureMap)) { int level; if (from is PlayerMobile && ((PlayerMobile)from).Young && from.Map == Map.Trammel && TreasureMap.IsInHavenIsland(from)) { level = 0; } else { level = 1; } return(new TreasureMap(level, from.Map == Map.Felucca ? Map.Felucca : Map.Trammel)); } else if (type == typeof(MessageInABottle)) { return(new MessageInABottle(from.Map == Map.Felucca ? Map.Felucca : Map.Trammel)); } else if (type == typeof(WhitePearl)) { return(new WhitePearl()); } Container pack = from.Backpack; if (pack != null) { List <SOS> messages = pack.FindItemsByType <SOS>(); for (int i = 0; i < messages.Count; ++i) { SOS sos = messages[i]; if ((from.Map == Map.Felucca || from.Map == Map.Trammel) && from.InRange(sos.TargetLocation, 60)) { Item preLoot = null; bool dredge = HasTypeHook(tool, HookType.Dredging); switch (Utility.Random(Core.HS ? 17 : 16)) { case 0: // Body parts case 1: { int[] list = new int[] { 0x1CDD, 0x1CE5, // arm 0x1CE0, 0x1CE8, // torso 0x1CE1, 0x1CE9, // head 0x1CE2, 0x1CEC // leg }; preLoot = new ShipwreckedItem(Utility.RandomList(list), dredge); break; } case 2: // Bone parts case 3: { int[] list = new int[] { 0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4, // skulls 0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles 0x1B15, 0x1B16 // pelvis bones }; preLoot = new ShipwreckedItem(Utility.RandomList(list), dredge); break; } case 4: // Paintings and portraits case 5: { preLoot = new ShipwreckedItem(Utility.Random(0xE9F, 10), dredge); break; } case 6: // Pillows case 7: { preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11), dredge); break; } case 8: // Shells case 9: { preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9), dredge); break; } case 10: //Hats case 11: { if (Utility.RandomBool()) { preLoot = new SkullCap(); } else { preLoot = new TricorneHat(); } break; } case 12: // Misc case 13: { int[] list = new int[] { 0x1EB5, // unfinished barrel 0xA2A, // stool 0xC1F, // broken clock 0x1047, 0x1048, // globe 0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4 // barrel staves }; if (Utility.Random(list.Length + 1) == 0) { preLoot = new Candelabra(); } else { preLoot = new ShipwreckedItem(Utility.RandomList(list), dredge); } break; } #region High Seas case 14: { int[] list = new int[] { 0x1E19, 0x1E1A, 0x1E1B, //Fish heads 0x1E2A, 0x1E2B, //Oars 0x1E71, 0x1E7A, //Unfinished drawers 0x1E75, //Unfinished legs }; double ran = Utility.RandomDouble(); if (ran < 0.05) { preLoot = new YellowPolkaDotBikini(); } else if (ran < 0.25) { preLoot = new ShipwreckedItem(list[Utility.RandomMinMax(3, 7)], dredge); } else { preLoot = new ShipwreckedItem(list[Utility.Random(3)], dredge); } break; } #endregion } if (preLoot != null) { if (preLoot is IShipwreckedItem) { ((IShipwreckedItem)preLoot).IsShipwreckedItem = true; } return(preLoot); } LockableContainer chest; if (0.01 > Utility.RandomDouble()) { chest = new ShipsStrongbox(sos.Level); } else { if (Utility.RandomBool()) { chest = new MetalGoldenChest(); } else { chest = new WoodenChest(); } } if (sos.IsAncient) { chest.Hue = 0x481; } TreasureMapChest.Fill(chest, from is PlayerMobile ? ((PlayerMobile)from).RealLuck : from.Luck, Math.Max(1, Math.Min(4, sos.Level)), true, from.Map); sos.OnSOSComplete(chest); if (sos.IsAncient) { chest.DropItem(new FabledFishingNet()); } else { chest.DropItem(new SpecialFishingNet()); } chest.Movable = true; chest.Locked = false; chest.TrapType = TrapType.None; chest.TrapPower = 0; chest.TrapLevel = 0; chest.IsShipwreckedItem = true; sos.Delete(); return(chest); } } } return(base.Construct(type, from, tool)); }
public override Item Construct(Type type, Mobile from) { if (type == typeof(TreasureMap)) { int level; if (from is PlayerMobile && ((PlayerMobile)from).Young && from.Map == Map.Trammel && TreasureMap.IsInHavenIsland(from)) { level = 0; } else { level = 1; } return(new TreasureMap(level, from.Map == Map.Felucca ? Map.Felucca : Map.Trammel)); } else if (type == typeof(MessageInABottle)) { return(new MessageInABottle(SafeMap(from.Map))); } Container pack = from.Backpack; if (pack != null) { Item[] messages = pack.FindItemsByType(typeof(SOS)); for (int i = 0; i < messages.Length; ++i) { SOS sos = (SOS)messages[i]; if (from.Map == sos.TargetMap && from.InRange(sos.TargetLocation, 60)) { Item preLoot = null; switch (Utility.Random(7)) { case 0: // Body parts { int[] list = new int[] { 0x1CDD, 0x1CE5, // arm 0x1CE0, 0x1CE8, // torso 0x1CE1, 0x1CE9, // head 0x1CE2, 0x1CEC // leg }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); break; } case 1: // Bone parts { int[] list = new int[] { 0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4, // skulls 0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles 0x1B15, 0x1B16 // pelvis bones }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); break; } case 2: // Paintings and portraits { preLoot = new ShipwreckedItem(Utility.Random(0xE9F, 10)); break; } case 3: // Pillows { preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11)); break; } case 4: // Shells { preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9)); break; } case 5: // Misc { int[] list = new int[] { 0x1EB5, // unfinished barrel 0xA2A, // stool 0xC1F, // broken clock 0x1047, 0x1048, // globe 0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4, // barrel staves 0xB5B, 0xB4F, 0xB5E, 0xB57, 0xB53, // chairs 0x1560, 0x1562, 0x155D, 0x155E, 0x1582, 0x1634, //Deco Bows/Swords 0x156C, 0x157E, 0x1580, 0x1565, 0x1578, 0x1569, //Deco Shields/Axe 0xC1B, 0xC10, 0xC19, 0xC2C, 0xC2D, 0xB95, // Ruined things/Sign 0xE31, 0x19AA, 0x1853, 0x9FB, 0xA05, 0xA26, // Light sources 0x1EA7, 0x26AC, 0x1879, 0x1005, 0x185B, 0xEFB, // Misc items 0x1810, 0xEFC, 0X14F8, 0x166E // More Misc Items // // *** Can easily add more stuff to fish up while doing chest!! // }; preLoot = new ShipwreckedItem(Utility.RandomList(list)); // This statement converts to Item and tags "... from shipwreck" break; } } if (preLoot != null) // Drew a "0-5" in above Case Stmt and have preLoot { if (0.143 > Utility.RandomDouble()) // Spawn weak monster ~ every 7 tries { BaseCreature serp1; switch (Utility.Random(5)) { case 0: { serp1 = new IcebergSnake(); break; } case 1: { serp1 = new SeaSlime(); break; } case 2: { serp1 = new SeaWorm(); break; } case 3: { serp1 = new ToxicSlime(); break; } default: { serp1 = new OilSlime(); break; } } int x = from.X, y = from.Y; Map map = from.Map; for (int ii = 0; map != null && ii < 20; ++ii) { int tx = from.X - 10 + Utility.Random(21); int ty = from.Y - 10 + Utility.Random(21); Tile t = map.Tiles.GetLandTile(tx, ty); if (t.Z == -5 && ((t.ID >= 0xA8 && t.ID <= 0xAB) || (t.ID >= 0x136 && t.ID <= 0x137)) && !Spells.SpellHelper.CheckMulti(new Point3D(tx, ty, -5), map)) { x = tx; y = ty; break; } } serp1.MoveToWorld(new Point3D(x, y, -5), map); serp1.Home = serp1.Location; serp1.RangeHome = 10; from.SendLocalizedMessage(503170); // Uh oh! That doesn't look like a fish! } return(preLoot); } sos.Delete(); WoodenChest chest = new WoodenChest(); TreasureMapChest.Fill(chest, Utility.RandomMinMax(1, 4)); // TODO: Are there chances on this? All MIB's I've done had nets.. chest.DropItem(new SpecialFishingNet()); chest.Movable = true; chest.Locked = false; chest.TrapType = TrapType.None; chest.TrapPower = 0; return(chest); } } } return(base.Construct(type, from)); }