protected override void OnTarget(Mobile from, object o) { try { if (from == null) { return; } if (o == null) { from.SendMessage("Target does not exist."); return; } if (o is BaseContainer == false) { from.SendMessage("That is not a container."); return; } BaseContainer bc = o as BaseContainer; if (Misc.Diagnostics.Assert(from.Backpack != null, "from.Backpack == null") == false) { from.SendMessage("You cannot use this deed without a backpack."); return; } // mobile backpacks may not be used if (bc == from.Backpack || bc.Parent is Mobile) { from.SendMessage("You may not use that container."); return; } // must not be locked down if (bc.IsLockedDown == true || bc.IsSecure == true) { from.SendMessage("That container is locked down."); return; } // if it's in your bankbox, or it's in YOUR house, you can deed it if ((bc.IsChildOf(from.BankBox) || CheckAccess(from)) == false) { from.SendMessage("The container must be in your bankbox, or a home you own."); return; } // cannot be in another container if (bc.RootParent is BaseContainer && bc.IsChildOf(from.BankBox) == false) { from.SendMessage("You must remove it from that container first."); return; } // okay, done with target checking, now deed the container. // place a special deed to reclaim the container in the players backpack PlayerQuestDeed deed = new PlayerQuestDeed(bc); if (from.Backpack.CheckHold(from, deed, true, false, 0, 0)) { bc.PlayerQuest = true; // mark as special bc.MoveToWorld(from.Location, Map.Internal); // put it on the internal map bc.SetLastMoved(); // record the move (will use this in Heartbeat cleanup) //while (deed.Expires.Hours + deed.Expires.Minutes == 0) //Console.WriteLine("Waiting..."); //int hours = deed.Expires.Hours; //int minutes = deed.Expires.Minutes; //string text = String.Format("{0} {1}, and {2} {3}", hours, hours == 1 ? "hour" : "hours", minutes, minutes == 1 ? "minute" : "minutes"); from.Backpack.DropItem(deed); from.SendMessage("A deed for the container has been placed in your backpack."); //from.SendMessage( "This quest will expire in {0}.", text); } else { from.SendMessage("Your backpack is full and connot hold the deed."); deed.Delete(); } } catch (Exception e) { LogHelper.LogException(e); } }
public override void OnHarvestFinished(Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested) { int tileID; Map map; Point3D loc; if (GetHarvestDetails(from, tool, harvested, out tileID, out map, out loc)) { if (0.15 > Utility.RandomDouble()) { HarvestResource res = vein.PrimaryResource; if (res == resource) { try { Type chance; int num; double miningskill = from.Skills[SkillName.Mining].Base; if ((0.67 > Utility.RandomDouble()) && (res.Types.Length >= 2)) { num = (((int)miningskill - 20) + Utility.Random(40)) / 20; if (num >= 0 && num <= 5 && (0.90 > Utility.RandomDouble())) { chance = Spirit[num]; } else { chance = res.Types[1]; } BaseCreature spawned = Activator.CreateInstance(chance, new object[] { 10 }) as BaseCreature; if (spawned != null) { spawned.MoveToWorld(loc, map); spawned.Say("Who has disturbed me!"); spawned.Combatant = from; } } double stealingskill = from.Skills[SkillName.Stealing].Base; if ((stealingskill < 60) ? (0.22 > Utility.RandomDouble()) : (0.17 > Utility.RandomDouble())) { num = ((((int)stealingskill - 30) + Utility.Random(11)) / 7) + 1; if (num < 0) { num = 0; } else if (num > 9) { num = 9; } BaseContainer goodies = Activator.CreateInstance(GraveGoods[Utility.Random(num)], new object[] { }) as BaseContainer; if (goodies != null) { goodies.MoveToWorld(loc, map); from.SendMessage("you dig up something interesting"); } } } catch { } } } } }