Dungeon treasure chest fun?

Locked
pgi
Apprentice Scribe
Posts: 11
Joined: Sat Jul 28, 2012 6:16 am

Dungeon treasure chest fun?

Post by pgi »

While playing with RunUO I decided to play with another old wish: "better" dungeon treasure chests. The basics of the idea are:

1. the content depends on the skill of the thief (i like skill-based returns)
2. dungeon chests are guarded (fiction: by the cursed souls of the thieves that died when trying to open them)

Things can get quite complicated on the logical part of the system but the mechanics are very easy. The file Scripts\Items\Containers\TreasureChests.cs contains the classes of the chests. Each class extends BaseTreasureChest so to customize the behavior one can introduce a middle layer between BaseTreasureChest and the real chest (MetalTreasureChest or WoodenTreasureChest). So instead of:

Code: Select all

	[FlipableAttribute( 0x9ab, 0xe7c )] 
	public class MetalTreasureChest : BaseTreasureChest 
we write:

Code: Select all

	[FlipableAttribute( 0x9ab, 0xe7c )] 
	public class MetalTreasureChest : BaseCustomTreasureChest 
the remaining is unchanged. Then we write this BaseCustomTreasureChest. When the user picks the lock, the system calls the LockPick(Mobile) method. When the user opens the chest, the system calls Open(Mobile). Mobile is the player - or at least i suppose it is. In the LockPick method we check the lockpicking skill of the player and the higher it is the better the loot we create (one could factor luck in but i hate luck).

When the user opens the chest for the first time the system spawns a "cursed thief". This is the code i'm working on:

Code: Select all

using Server;
using Server.Items;
using Server.Network;
using System;
using System.Collections;

namespace Server.Items
{
	
	public class BaseCustomTreasureChest : BaseTreasureChest {
		private static int VERSION = 0;
		private bool hasBeenOpened;
	
		[Constructable]
		public BaseCustomTreasureChest(int itemID) : base(itemID, TreasureLevel.Level2) {}
		
		public BaseCustomTreasureChest(Serial serial) : base(serial) {}
		
		[CommandProperty(AccessLevel.GameMaster)]
		public bool HasBeenOpened {
			get { return hasBeenOpened; }
			set { hasBeenOpened = value; }
		}
		
		private double ComputeSkillFactor(Mobile thief) {
			double skill = thief.Skills.Lockpicking.Value;
			return (skill - 95.0) / 25.0;
		}
		
		public override void LockPick(Mobile thief) {
			int MIN_GOLD_BASE = 1000;
			int MAX_GOLD_BASE = 10000;
			base.LockPick(thief);
			double skillFactor = ComputeSkillFactor(thief);
			int minGold = Math.Max(1, (int)Math.Round(skillFactor * MIN_GOLD_BASE));
			int maxGold = Math.Max(1, (int)Math.Round(skillFactor * MAX_GOLD_BASE));
			Gold gold = new Gold(minGold, maxGold);
			ClearContents();
			DropItem(gold);
		}
		
		public override void Open(Mobile who) {
			base.Open(who);
			if(hasBeenOpened) return;
			
			hasBeenOpened = true;
			SpawnCursedThief(who);
		}
		
		public void SpawnCursedThief(Mobile player) {
			Console.Out.WriteLine("implement spawn cursed thief");
		}
		
		public override void Serialize(GenericWriter writer) {
			base.Serialize(writer);
			writer.Write(VERSION);
			writer.Write(hasBeenOpened);
		}
		
		public override void Deserialize(GenericReader reader) {
			base.Deserialize(reader);
			int version = reader.ReadInt();
			hasBeenOpened = reader.ReadBool();
		}
	}
}
I did a separate test with a mongbat, now i have to decide how strong the cursed thieves will be (i plan to use beefed up monsters, like "a cursed gargoyle thief", "a cursed demon thief" and a like).
Dramoor
Legendary Scribe
Posts: 450
Joined: Wed Feb 23, 2011 7:37 pm

Re: Dungeon treasure chest fun?

Post by Dramoor »

Asmodean
Legendary Scribe
Posts: 304
Joined: Thu Mar 24, 2011 12:51 pm

Re: Dungeon treasure chest fun?

Post by Asmodean »

While i think treasure chests could be beefed up, i don't necessarily agree with this method.
Reason being, why would me being a 120 lock picker spawn more loot in the chest than someone
with a 50, or 100. The stuff in the chest, was put there by whomever locked it (in theory), and certainly
wouldn't increase just because the skill of the lock picker was greater.

I do think we need additional reason to go treasure hunting, and i think a better solution
would be to ranzomize the levels of the chests and the loot contained within that particular
level chest.

A level 4 chest should contain roughly the same stuff as any other level 4 chest, regardless of the skill
of the lock picker. As far as guardians, there is already a system in place for that, in the treasure hunting
system. I don't necessarily agree with it being in dungeon chests, as you have to clear the way to them first.

Another system that could use improving, is fishing mibs, and amibs.. Unfortunately as Dramoor pointed out,
suggestions are closed, and not being implimented currently.
pgi
Apprentice Scribe
Posts: 11
Joined: Sat Jul 28, 2012 6:16 am

Re: Dungeon treasure chest fun?

Post by pgi »

At first glance the code for the t-maps' chests looks different in that it requires a t-map object to operate so you have to carve out the relevant part from the TreasureMap.cs code to achieve the same effect; you can make and identical system but you can't do that by using the same classes (well, maybe you can instantiate a dummy t-map but i don't know how the system behaves when dealing with "fake" items).

The reason why i think that adapting the content of the chest to the skill of the thief is the way to go is to reward the (relative) effort needed to improve your skill. While you can move the generation of contents at open time instead of respawn time, from the user point of view the chest might well have been filled some time in the past so it makes no fictional difference.

I'm posting the code for the sake of sharing it not because it can/should be integrated in the server - the actual set of classes used in the shard is probably different from the basic RunUO distribution, it can't be simply copied and pasted in some folder, it has to be changed, probably in a substantial way.
Locked