- ServUO Version
- Publish 57
- Ultima Expansion
- Endless Journey
Working on rewriting the universal dye tub as it did not work with ethereals correctly nor did it withdraw from your bank balance, so this is what I have so far however it is crashing on line 56 i_Cost.Cost according to the crash log and I'm still a scrub so I am not sure why. I thought I had everything correct and it does compile it just crashes when you target the animal.
C#:
using System;
using System.Collections;
using Server;
using Server.Commands;
using Server.Items;
using Server.Mobiles;
using Server.Targeting;
using Server.Accounting;
namespace Server.Items
{
public class UltimateTubTarget : Target
{
private Item m_Item;
private readonly UltimateDyeTub i_Cost;
public UltimateTubTarget( Item item ) : base( 12, false, TargetFlags.None )
{
m_Item = item;
}
protected override void OnTarget( Mobile from, object target )
{
if (target is EtherealMount)
{
EtherealMount EtherealMount = target as EtherealMount;
if (EtherealMount.RootParent == from) // Make sure its in their pack
{
EtherealMount.TransparentMountedHue = m_Item.Hue;
EtherealMount.Hue = m_Item.Hue;
}
else
from.SendMessage("You can only dye objects that are in your backpack!");
}
else if (target is BaseJewel || target is BaseArmor || target is BaseClothing || target is BaseShield || target is BaseWeapon || target is BaseSuit || target is BaseContainer || target is Item)
{
Item item = (Item)target;
if (item.RootParent == from) // Make sure its in their pack or they are wearing it
item.Hue = m_Item.Hue;
else
from.SendMessage("You can only dye objects that are in your backpack or on your person!");
}
else if (target is BaseCreature)
{
int totalGold = 0;
if (from.Backpack != null)
totalGold += from.Backpack.GetAmount(typeof(Gold));
totalGold += Banker.GetBalance(from);
if (totalGold < i_Cost.Cost)
{
from.SendMessage("You cannot afford this item.");
}
else
{
int leftPrice = i_Cost.Cost;
if (from.Backpack != null)
leftPrice -= from.Backpack.ConsumeUpTo(typeof(Gold), leftPrice);
if (leftPrice > 0)
Banker.Withdraw(from, leftPrice);
BaseCreature c = target as BaseCreature;
if (c.Controlled && c.ControlMaster == from)
{
c.Hue = m_Item.Hue;
from.SendMessage("Removed 50,000 gold from your bank and hued your pet.");
}
else
from.SendMessage("You can only dye animals whom you control!");
}
from.SendMessage("You lack the funds to hue your pet.");
}
}
}
public class UltimateDyeTub : Item
{
private bool m_Redyable;
private int i_Cost;
[CommandProperty(AccessLevel.GameMaster)]
public int Cost
{
get { return i_Cost; }
set { i_Cost = value; }
}
[Constructable]
public UltimateDyeTub() : base( 0xFAB )
{
Weight = 0.0;
Hue = 0;
Name = "Ultimate Dye Tub";
m_Redyable = false;
Movable = false;
i_Cost = 50000;
}
public UltimateDyeTub( Serial serial ) : base( serial )
{
}
public override void OnDoubleClick( Mobile from )
{
{
from.Target = new UltimateTubTarget( this );
from.SendMessage( "You may now hue your backpack and worn equipment, " +
"you may also hue your pets for 50K gp each.");
}
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write(i_Cost);
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
i_Cost = reader.ReadInt();
if ( Name == "Ultimate Dye Tub" )
{
int intNumber = this.Hue;
string strNumber = intNumber.ToString("#");
Name = strNumber;
}
}
}
}