We have Xanthos shrink system on the server & its working great. We also have Repairing NPC's that repair weapons and/or armor for a price. The PetLeash is currently set for 50 charges in ShrinkConfig which is fine. What we are wanting to do is have a recharge system for them (make the players pay for extended use). I'm trying to combine both systems & so far its working with 1 minor detail. The Repairer I made recognizes the PetLeash, but says it doesnt need recharged & I think I know why. The Leash reads from the ShrinkConfig which is set for 50 uses, but has no "max" charges, so the repairer has nothing to compare to. I'm including the section of my repairer that has the pet leash recharge coding along with the scripts for the repairer, petleash & shrinkconfig. I'm hoping I wont have to alter coding in the petleash or config very much (if at all) since it ties in with other things we have.
Code:
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is IShrinkTool && from.Backpack != null)
{
IShrinkTool st = targeted as IShrinkTool;
Container pack = from.Backpack;
int toConsume = 0;
if (st.ShrinkCharges < st.ShrinkCharges)
{
toConsume = (st.ShrinkCharges - st.ShrinkCharges) * 20; // 2 gp per hitpoint - change 2 to whatever you want as a multiplier
}
else
{
m_Trainer.SayTo(from, "That does not need to be recharged.");
}
if (toConsume == 0)
return;
if (pack.ConsumeTotal(typeof(Gold), toConsume))
{
m_Trainer.SayTo(from, "Here is your pet leash.");
from.SendMessage(String.Format("You pay {0} gold.", toConsume));
Effects.PlaySound(from.Location, from.Map, 0x55);
st.ShrinkCharges -= 1;
st.ShrinkCharges = st.ShrinkCharges;
}
else
{
m_Trainer.SayTo(from, "It would cost you {0} gold to have that repaired.", toConsume);
from.SendMessage("You do not have enough gold.");
}
}
else
m_Trainer.SayTo(from, "I cannot recharge that.");
}