Reorganizes Project (#41)
This commit is contained in:
parent
08bf44af9a
commit
3614a66aee
3499 changed files with 79 additions and 55 deletions
120
Projects/Scripts/Items/Skill Items/Misc/RecipeScroll.cs
Normal file
120
Projects/Scripts/Items/Skill Items/Misc/RecipeScroll.cs
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
using Server.Engines.Craft;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class RecipeScroll : Item
|
||||
{
|
||||
private int m_RecipeID;
|
||||
|
||||
public RecipeScroll(Recipe r) : this(r.ID)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public RecipeScroll(int recipeID) : base(0x2831)
|
||||
{
|
||||
m_RecipeID = recipeID;
|
||||
}
|
||||
|
||||
public RecipeScroll(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1074560; // recipe scroll
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int RecipeID
|
||||
{
|
||||
get => m_RecipeID;
|
||||
set
|
||||
{
|
||||
m_RecipeID = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public Recipe Recipe
|
||||
{
|
||||
get
|
||||
{
|
||||
Recipe.Recipes.TryGetValue(m_RecipeID, out Recipe recipe);
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
Recipe r = Recipe;
|
||||
|
||||
if (r != null)
|
||||
list.Add(1049644, r.TextDefinition.ToString()); // [~1_stuff~]
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
||||
return;
|
||||
}
|
||||
|
||||
Recipe r = Recipe;
|
||||
|
||||
if (r != null && from is PlayerMobile pm)
|
||||
{
|
||||
if (!pm.HasRecipe(r))
|
||||
{
|
||||
bool allRequiredSkills = true;
|
||||
double chance = r.CraftItem.GetSuccessChance(pm, null, r.CraftSystem, false, ref allRequiredSkills);
|
||||
|
||||
if (allRequiredSkills && chance >= 0.0)
|
||||
{
|
||||
pm.SendLocalizedMessage(1073451,
|
||||
r.TextDefinition.ToString()); // You have learned a new recipe: ~1_RECIPE~
|
||||
pm.AcquireRecipe(r);
|
||||
Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
pm.SendLocalizedMessage(1044153); // You don't have the required skills to attempt this item.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pm.SendLocalizedMessage(1073427); // You already know this recipe.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
writer.Write(m_RecipeID);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_RecipeID = reader.ReadInt();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue