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
Code: Select all
[FlipableAttribute( 0x9ab, 0xe7c )]
public class MetalTreasureChest : BaseCustomTreasureChest
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();
}
}
}