private static void Postfix(GameLocation location, BreakableContainer __instance, NetInt ___containerType) { if (Game1.random.NextDouble() > 0.01) { return; } int objectID = ___containerType.Value switch { BreakableContainer.barrel => Game1.random.NextDouble() < 0.5 ? ModEntry.LuckyFertilizerID : ModEntry.PaddyCropFertilizerID, BreakableContainer.frostBarrel => location is MineShaft shaft && shaft.GetAdditionalDifficulty() > 0 ? ModEntry.DeluxeFruitTreeFertilizerID : ModEntry.OrganicFertilizerID, BreakableContainer.darkBarrel => location is MineShaft shaft && shaft.GetAdditionalDifficulty() > 0 ? ModEntry.DeluxeJojaFertilizerID : ModEntry.JojaFertilizerID, BreakableContainer.desertBarrel => Game1.random.NextDouble() < 0.5 ? ModEntry.BountifulFertilizerID : ModEntry.FruitTreeFertilizerID, BreakableContainer.volcanoBarrel => Game1.random.NextDouble() < 0.5 ? ModEntry.FishFoodID : ModEntry.DomesticatedFishFoodID, _ => ModEntry.LuckyFertilizerID, }; Game1.createMultipleObjectDebris( objectID, (int)__instance.TileLocation.X, (int)__instance.TileLocation.Y, Game1.random.Next(1, Math.Clamp(Game1.player.MiningLevel / 2, 2, 10)), location); }
public static bool Prefix(BreakableContainer __instance, GameLocation location, Farmer who) { if (location is LunarLocation) { DoDrops(__instance, location, who); return(false); } return(true); }
private static void DoDrops(BreakableContainer __instance, GameLocation location, Farmer who) { Random r = new Random((int)__instance.tileLocation.X + (int)__instance.tileLocation.Y * 10000 + (int)Game1.stats.DaysPlayed); int x = (int)__instance.tileLocation.X; int y = (int)__instance.tileLocation.Y; if (r.NextDouble() < 0.2) { return; } if (Game1.random.NextDouble() <= 0.075 && Game1.player.team.SpecialOrderRuleActive("DROP_QI_BEANS")) { Game1.createMultipleObjectDebris(890, x, y, r.Next(1, 3), who.UniqueMultiplayerID, location); } if (r.NextDouble() < 0.01) { Game1.createItemDebris(new DynamicGameAssets.Game.CustomObject(DynamicGameAssets.Mod.Find(ItemIds.SoulSapphire) as ObjectPackData), __instance.TileLocation * Game1.tileSize, 0, location); } if (r.NextDouble() < 0.65) { Item item = null; Item item2 = null; switch (r.Next(5)) { case 0: case 1: case 2: case 3: case 4: //item = new DynamicGameAssets.Game.CustomObject( DynamicGameAssets.Mod.Find( ItemIds.LunarWheat ) as ObjectPackData ) { Stack = 4 + r.Next( 13 ) }; item2 = new DynamicGameAssets.Game.CustomObject(DynamicGameAssets.Mod.Find(ItemIds.LunarWheatSeeds) as ObjectPackData) { Stack = 1 + r.Next(6) }; break; } if (item != null) { Game1.createItemDebris(item, __instance.TileLocation * Game1.tileSize, 0, location); } if (item2 != null && r.NextDouble() < 0.25) { Game1.createItemDebris(item2, __instance.TileLocation * Game1.tileSize, 0, location); } } else if (r.NextDouble() < 0.75) { Game1.createItemDebris(new DynamicGameAssets.Game.CustomObject(DynamicGameAssets.Mod.Find(ItemIds.MythiciteOre) as ObjectPackData) { Stack = 1 + r.Next(4) }, __instance.TileLocation * Game1.tileSize, 0, location); } }
protected void PlaceBreakableAt(AsteroidsDungeon location, Random rand, int tx, int ty) { Vector2 position = new Vector2(tx, ty); if (location.netObjects.ContainsKey(position)) { return; } BreakableContainer bcontainer = new BreakableContainer(position, true); bcontainer.setHealth(6); location.netObjects.Add(position, bcontainer); }
protected override void OnTarget(Mobile from, object targeted) { if (m_Item.Deleted) { return; } if (targeted is BreakableContainer) { BreakableContainer breakableContainer = targeted as BreakableContainer; if (breakableContainer.LockpickDamageScalar > 0) { breakableContainer.Interact(from, BreakableContainer.InteractionType.Lockpick); } else { breakableContainer.Interact(from, BreakableContainer.InteractionType.None); } return; } if (targeted is BreakableStatic) { BreakableStatic breakableStatic = targeted as BreakableStatic; if (breakableStatic.LockpickDamageScalar > 0) { breakableStatic.Interact(from, BreakableStatic.InteractionType.Lockpick); } else { breakableStatic.Interact(from, BreakableStatic.InteractionType.None); } return; } if (targeted is Hold) { Hold hold = targeted as Hold; hold.LockpickHold(from, m_Item); return; } if (targeted is ILockpickable) { Item item = (Item)targeted; from.Direction = from.GetDirectionTo(item); from.BeginAction(typeof(Lockpick)); Timer.DelayCall(TimeSpan.FromSeconds(SkillCooldown.LockpickingCooldown), delegate { if (from != null) { from.EndAction(typeof(Lockpick)); } }); if (((ILockpickable)targeted).Locked) { from.PlaySound(0x241); new InternalTimer(from, (ILockpickable)targeted, m_Item).Start(); } else { // The door is not locked from.SendLocalizedMessage(502069); // This does not appear to be locked } } else { from.SendLocalizedMessage(501666); // You can't unlock that! } }
public void Explode(Mobile from, bool direct, Point3D loc, Map map) { if (Deleted) { return; } // 12/8/13 Xiani - Nullifying an explosion when in an ArenaRegion. //TEST: CHECK THIS if (from.CombatProhibited) { return; } //TEST: CHECK THIS if (!ArenaFight.AllowFreeConsume(from, typeof(BasePotion))) { Consume(); } for (int i = 0; m_Users != null && i < m_Users.Count; ++i) { Mobile m = (Mobile)m_Users[i]; ThrowTarget targ = m.Target as ThrowTarget; if (targ != null && targ.Potion == this) { Target.Cancel(m); } } if (map == null) { return; } Effects.PlaySound(loc, map, 0x207); Effects.SendLocationEffect(loc, map, 0x36BD, 20); int alchemyBonus = 0; IPooledEnumerable eable = LeveledExplosion ? (IPooledEnumerable)map.GetObjectsInRange(loc, ExplosionRange) : (IPooledEnumerable)map.GetMobilesInRange(loc, ExplosionRange); ArrayList toExplode = new ArrayList(); int toDamage = 0; foreach (object o in eable) { if (o is Mobile) { toExplode.Add(o); ++toDamage; } else if (o is BaseExplosionPotion && o != this) { toExplode.Add(o); } if (o is BreakableContainer) { toExplode.Add(o); } if (o is BreakableStatic) { toExplode.Add(o); } } eable.Free(); int min = Scale(from, MinDamage); int max = Scale(from, MaxDamage); int baseDamage = Utility.RandomMinMax(min, max); for (int i = 0; i < toExplode.Count; ++i) { object o = toExplode[i]; double divisor = 0; if (o is Mobile) { Mobile m = (Mobile)o; if (from == null || (SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false))) { if (from != null) { from.DoHarmful(m); } int damage = baseDamage; damage += alchemyBonus; if (m is PlayerMobile) { if (m.InRange(loc, 0)) { divisor = 1; } else if (m.InRange(loc, 1)) { divisor = 2; } else if (m.InRange(loc, 2)) { divisor = 4; } damage = (int)(damage / divisor); if (damage > 40) { damage = 40; } } else { damage = (int)((double)damage * CreatureDamageScalar); } AOS.Damage(m, from, damage, 0, 100, 0, 0, 0); } } else if (o is BaseExplosionPotion) { BaseExplosionPotion pot = (BaseExplosionPotion)o; pot.Explode(from, false, pot.GetWorldLocation(), pot.Map); } else if (o is BreakableContainer) { BreakableContainer breakableContainer = (BreakableContainer)o; if (breakableContainer.ObjectBreakingDeviceDamageScalar == 0) { continue; } baseDamage = (int)((double)baseDamage * CreatureDamageScalar * breakableContainer.ObjectBreakingDeviceDamageScalar); breakableContainer.ReceiveDamage(from, baseDamage, BreakableContainer.InteractionType.ObjectBreakingDevice); } else if (o is BreakableStatic) { BreakableStatic breakableStatic = (BreakableStatic)o; if (breakableStatic.ObjectBreakingDeviceDamageScalar == 0) { continue; } baseDamage = (int)((double)baseDamage * CreatureDamageScalar * breakableStatic.ObjectBreakingDeviceDamageScalar); breakableStatic.ReceiveDamage(from, baseDamage, BreakableStatic.InteractionType.ObjectBreakingDevice); } } }
public void Init(BreakableContainer tContr, Transform tTransform = null, Vector3 tTranslate = new Vector3()) { Sprite = GetComponent<SpriteRenderer>(); OriginalColor = Sprite.color; ResetNeighbours(); Kinematic = false; Collider = gameObject.GetComponent<BoxCollider2D>(); Container = tContr; Container.AddChild(this); if (tTransform != null) { transform.localPosition = tTransform.localPosition; transform.localRotation = tTransform.localRotation; transform.Translate(tTranslate); transform.localScale = tTransform.localScale; } }
protected override void OnTarget(Mobile from, object targeted) { if (m_Item.Deleted) { return; } if (targeted is BreakableContainer) { BreakableContainer breakableContainer = targeted as BreakableContainer; if (breakableContainer.LockpickDamageScalar > 0) { breakableContainer.Interact(from, BreakableContainer.InteractionType.Lockpick); } else { breakableContainer.Interact(from, BreakableContainer.InteractionType.None); } return; } if (targeted is BreakableStatic) { BreakableStatic breakableStatic = targeted as BreakableStatic; if (breakableStatic.LockpickDamageScalar > 0) { breakableStatic.Interact(from, BreakableStatic.InteractionType.Lockpick); } else { breakableStatic.Interact(from, BreakableStatic.InteractionType.None); } return; } if (targeted is Hold) { Hold hold = targeted as Hold; hold.LockpickHold(from, m_Item); return; } if (targeted is ILockpickable) { if (targeted is BaseTreasureChest) { PlayerMobile player = from as PlayerMobile; if (player != null) { CaptchaPersistance.CheckAndCreateCaptchaAccountEntry(player); if (!player.m_CaptchaAccountData.Attempt(player, CaptchaSourceType.DungeonChest)) { return; } } } Item item = (Item)targeted; from.Direction = from.GetDirectionTo(item); from.BeginAction(typeof(Lockpick)); Timer.DelayCall(TimeSpan.FromSeconds(SkillCooldown.LockpickingCooldown), delegate { if (from != null) { from.EndAction(typeof(Lockpick)); } }); if (((ILockpickable)targeted).Locked) { from.PlaySound(0x241); new InternalTimer(from, (ILockpickable)targeted, m_Item).Start(); } else { // The door is not locked from.SendLocalizedMessage(502069); // This does not appear to be locked } } else { from.SendLocalizedMessage(501666); // You can't unlock that! } }