servuo/Scripts/Items/Resource/ClockworkAssembly.cs

124 lines
3.6 KiB
C#
Raw Permalink Normal View History

2013-10-28 07:09:42 +00:00
using Server.Mobiles;
using System;
2013-10-28 07:09:42 +00:00
namespace Server.Items
{
2018-10-06 02:17:15 +03:00
public class ClockworkAssembly : Item, ICommodity
2013-10-28 07:09:42 +00:00
{
2020-04-16 20:21:33 -04:00
public override int LabelNumber => 1073426; // Clockwork Assembly
2019-02-13 00:17:24 +03:00
2013-10-28 07:09:42 +00:00
[Constructable]
public ClockworkAssembly()
: base(0x1EA8)
{
2019-02-13 00:17:24 +03:00
Weight = 5.0;
Hue = 1102;
2013-10-28 07:09:42 +00:00
}
public ClockworkAssembly(Serial serial)
: base(serial)
{
}
2020-04-16 20:21:33 -04:00
TextDefinition ICommodity.Description => LabelNumber;
bool ICommodity.IsDeedable => true;
2018-10-06 02:17:15 +03:00
2013-10-28 07:09:42 +00:00
public override void OnDoubleClick(Mobile from)
{
2019-02-13 00:17:24 +03:00
if (!IsChildOf(from.Backpack))
2013-10-28 07:09:42 +00:00
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
return;
}
2019-02-13 00:17:24 +03:00
if (from.Skills[SkillName.Tinkering].Value < 60.0)
2013-10-28 07:09:42 +00:00
{
2019-02-13 00:17:24 +03:00
from.SendLocalizedMessage(1071943); // You must be a Journeyman or higher Tinker to construct a golem.
2013-10-28 07:09:42 +00:00
return;
}
else if ((from.Followers + 4) > from.FollowersMax)
{
from.SendLocalizedMessage(1049607); // You have too many followers to control that creature.
return;
}
2013-10-28 07:09:42 +00:00
Container pack = from.Backpack;
if (pack == null)
return;
2019-02-13 00:17:24 +03:00
int res = pack.ConsumeTotal(new Type[] { typeof(PowerCrystal), typeof(IronIngot), typeof(BronzeIngot), typeof(Gears) }, new int[] { 1, 50, 50, 5 });
2013-10-28 07:09:42 +00:00
switch (res)
2013-10-28 07:09:42 +00:00
{
case 0:
{
2019-02-13 00:17:24 +03:00
from.SendLocalizedMessage(1071945); // You need a power crystal to construct a golem.
2013-10-28 07:09:42 +00:00
break;
}
case 1:
{
2019-02-13 00:17:24 +03:00
from.SendLocalizedMessage(1071948); // You need more iron ingots to construct a golem.
2013-10-28 07:09:42 +00:00
break;
}
case 2:
{
2019-02-13 00:17:24 +03:00
from.SendLocalizedMessage(1071947); // You need more bronze ingots to construct a golem.
2013-10-28 07:09:42 +00:00
break;
}
case 3:
{
2019-02-13 00:17:24 +03:00
from.SendLocalizedMessage(1071946); // You need more gears to construct a golem.
2013-10-28 07:09:42 +00:00
break;
}
default:
{
2019-02-13 00:17:24 +03:00
Golem g = new Golem(true, Scalar(from));
2013-10-28 07:09:42 +00:00
if (g.SetControlMaster(from))
{
2020-04-16 21:29:55 -04:00
Delete();
2013-10-28 07:09:42 +00:00
g.MoveToWorld(from.Location, from.Map);
from.PlaySound(0x241);
}
break;
}
}
}
2019-02-13 00:17:24 +03:00
public double Scalar(Mobile m)
{
double scalar;
double skill = m.Skills[SkillName.Tinkering].Value;
if (skill >= 100.0)
scalar = 1.0;
else if (skill >= 90.0)
scalar = 0.9;
else if (skill >= 80.0)
scalar = 0.8;
else if (skill >= 70.0)
scalar = 0.7;
else
scalar = 0.6;
return scalar;
}
2013-10-28 07:09:42 +00:00
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
2013-10-28 07:09:42 +00:00
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
2018-10-06 02:17:15 +03:00
}