Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #291 from ServUO/master
Merge W/ Upstream master
  • Loading branch information
kevin-10 committed Feb 18, 2019
2 parents b47b557 + 2939196 commit 8e3bd38
Show file tree
Hide file tree
Showing 21 changed files with 1,960 additions and 410 deletions.
4 changes: 2 additions & 2 deletions Scripts/Gumps/HouseGumpAOS.cs
Expand Up @@ -316,7 +316,7 @@ public HouseGumpAOS(HouseGumpPageAOS page, Mobile from, BaseHouse house)
AddLabel(250, 310, LabelHue, GetDateTime(house.LastTraded));

AddHtmlLocalized(20, 330, 200, 20, 1061793, SelectedColor, false, false); // House Value
AddLabel(250, 330, LabelHue, house.Price.ToString());
AddLabel(250, 330, LabelHue, house.Price.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("en-US")));

AddHtmlLocalized(20, 360, 300, 20, 1011241, SelectedColor, false, false); // Number of visits this building has had:
AddLabel(350, 360, LabelHue, house.TotalVisits.ToString());
Expand Down Expand Up @@ -1592,4 +1592,4 @@ private ArrayList Wrap(string value)
return list;
}
}
}
}
132 changes: 88 additions & 44 deletions Scripts/Items/Addons/Craft Addons/AddonToolComponenet.cs
Expand Up @@ -4,6 +4,7 @@
using Server.ContextMenus;
using System.Collections.Generic;
using Server.Multis;
using Server.Network;

namespace Server.Items
{
Expand Down Expand Up @@ -34,6 +35,12 @@ public class AddonToolComponent : BaseTool, IChopable
[CommandProperty(AccessLevel.GameMaster)]
public int ActiveID { get; private set; }

[CommandProperty(AccessLevel.GameMaster)]
public int InactiveMessage { get; set; }

[CommandProperty(AccessLevel.GameMaster)]
public int ActiveMessage { get; set; }

[CommandProperty(AccessLevel.GameMaster)]
public bool TurnedOn
{
Expand All @@ -46,16 +53,21 @@ public bool TurnedOn
if (_TurnedOn != value)
{
if (value)
this.ItemID = ActiveID;
ItemID = ActiveID;
else
this.ItemID = InactiveID;
ItemID = InactiveID;
}

_TurnedOn = value;
}
}

public AddonToolComponent(CraftSystem system, int inactiveid, int activeid, int cliloc, int uses, CraftAddon addon)
: this(system, inactiveid, activeid, 0, 0, cliloc, uses, addon)
{
}

public AddonToolComponent(CraftSystem system, int inactiveid, int activeid, int inactivemessage, int activemessage, int cliloc, int uses, CraftAddon addon)
: base(0, inactiveid)
{
_CraftSystem = system;
Expand All @@ -66,6 +78,9 @@ public AddonToolComponent(CraftSystem system, int inactiveid, int activeid, int
InactiveID = inactiveid;
ActiveID = activeid;

InactiveMessage = inactivemessage;
ActiveMessage = activemessage;

UsesRemaining = uses;
}

Expand All @@ -77,19 +92,6 @@ public void OnChop(Mobile from)
from.SendLocalizedMessage(500446); // That is too far away.
}

public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);

if (Addon != null)
{
if (_TurnedOn)
list.Add(502695); // turned on
else
list.Add(502696); // turned off
}
}

public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
Expand All @@ -101,17 +103,26 @@ public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> l

if (house != null && house.HasSecureAccess(from, Addon.Level))
{
list.Add(new SimpleContextMenuEntry(from, _TurnedOn ? 1011035 : 1011034, m =>
{
list.Add(new SimpleContextMenuEntry(from, 1155742, m => // Toggle: On/Off
{
if (_TurnedOn)
{
TurnedOn = false;
if (InactiveMessage != 0)
PrivateOverheadMessage(MessageType.Regular, 0x3B2, InactiveMessage, from.NetState);
}
else
{
TurnedOn = true;
if (ActiveMessage != 0)
{
PrivateOverheadMessage(MessageType.Regular, 0x3B2, ActiveMessage, from.NetState);
from.PlaySound(84);
}
}
}, 8)); // Activate this item : Deactivate this item TODO: Correct???
}, 8));

SetSecureLevelEntry.AddTo(from, Addon, list);
}
Expand All @@ -125,7 +136,7 @@ public override bool CheckAccessible(Mobile m, ref int num)

if (house == null || Addon == null || !house.HasSecureAccess(m, Addon.Level))
{
num = 1061637; // You are not allowed to access this.
num = 1061637; // You are not allowed to access
return false;
}
}
Expand Down Expand Up @@ -171,30 +182,48 @@ public override void OnAfterDelete()

public override bool OnDragDrop(Mobile from, Item dropped)
{
if (dropped is ITool)
{
var tool = dropped as ITool;
BaseHouse house = BaseHouse.FindHouseAt(this);

if (tool.CraftSystem == _CraftSystem)
if (house != null && Addon != null && house.HasSecureAccess(from, Addon.Level))
{
if (dropped is ITool && !(dropped is BaseRunicTool))
{
if (UsesRemaining >= MaxUses)
{
from.SendMessage("That is already at its maximum charges.");
return false;
}
else
var tool = dropped as ITool;

if (tool.CraftSystem == _CraftSystem)
{
int toadd = Math.Min(tool.UsesRemaining, MaxUses - UsesRemaining);
if (UsesRemaining >= MaxUses)
{
from.SendLocalizedMessage(1155740); // Adding this to the power tool would put it over the max number of charges the tool can hold.
}
else
{
int toadd = Math.Min(tool.UsesRemaining, MaxUses - UsesRemaining);

UsesRemaining += toadd;
tool.UsesRemaining -= toadd;
UsesRemaining += toadd;
tool.UsesRemaining -= toadd;

if (tool.UsesRemaining <= 0 && !tool.Deleted)
tool.Delete();
if (tool.UsesRemaining <= 0 && !tool.Deleted)
tool.Delete();

return true;
from.SendLocalizedMessage(1155741); // Charges have been added to the power tool.

return true;
}
}
else
{
from.SendLocalizedMessage(1074836); // The container cannot hold that type of object.
}
}
else
{
from.SendLocalizedMessage(1074836); // The container cannot hold that type of object.
}
}
else
{
from.SendLocalizedMessage(1074836); // The container cannot hold that type of object.
}

return false;
Expand All @@ -208,8 +237,10 @@ public AddonToolComponent(Serial serial)
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)1);

writer.Write((int)0);
writer.Write(InactiveMessage);
writer.Write(ActiveMessage);
writer.Write(Offset);
writer.Write(Addon);
writer.Write(_LabelNumber);
Expand All @@ -221,17 +252,30 @@ public override void Serialize(GenericWriter writer)
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);

int version = reader.ReadInt();
Offset = reader.ReadPoint3D();
Addon = reader.ReadItem() as CraftAddon;
_LabelNumber = reader.ReadInt();
ActiveID = reader.ReadInt();
InactiveID = reader.ReadInt();
TurnedOn = reader.ReadBool();

switch (version)
{
case 1:
{
InactiveMessage = reader.ReadInt();
ActiveMessage = reader.ReadInt();
goto case 0;
}
case 0:
{
Offset = reader.ReadPoint3D();
Addon = reader.ReadItem() as CraftAddon;
_LabelNumber = reader.ReadInt();
ActiveID = reader.ReadInt();
InactiveID = reader.ReadInt();
TurnedOn = reader.ReadBool();
break;
}
}

if (Addon != null)
Addon.OnCraftComponentLoaded(this);
}
}
}
}

0 comments on commit 8e3bd38

Please sign in to comment.