/////////////////////////////////////////////////////////////////////////
//
// www.ultima.smoce.net
// Name: Craftman
//
/////////////////////////////////////////////////////////////////////////
using Phoenix;
using Phoenix.WorldData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Collections;
using System.Threading;
using System.Diagnostics;
using System.Drawing;
namespace Scripts.DarkParadise
{
public class Craftsman
{
private UOItem _zdrojB;
private UOItem _cielB;
private string[] _hlasky = { "You put", "You fail", "Tinkering failed", "You have failed" };
private int _podarky;
private int _nepodarky;
//grafika materiálu
private ushort _ironG = 0x1BEF;
private ushort _copperG = 0x1BE3;
private ushort _silverG = 0x1BF5;
private ushort _goldG = 0x1BE9;
private ushort _iStringG = 0x1876;
private ushort _barrelLidG = 0x1DB8;
private ushort _barrelStavesG = 0x1EB1;
//color materiálu
//_nullC - pre všetko, čo má color hodnotu 0x0000
private ushort _nullC = 0x0000;
//grafika nástrojov pre crafta
private ushort _tinkerTools = 0x1EBC;
//grafika výrobkov
private ushort _ironWiresG = 0x1876;
private ushort _copperStringG = 0x1879;
private ushort _silverStringG = 0x1877;
private ushort _goldStringG = 0x1878;
private ushort _ironStringG = 0x1420;
private ushort _formaLahveG = 0x0E7F;
//color vyrobkov
private ushort _formaLahveC = 0x0909;
//jednotlivé menu výroby
private string[] _iWires = { "Tinkering", "Wires", "Wires", "Iron Wire" };
private string[] _cWires = { "Tinkering", "Wires", "Wires", "Copper Wire" };
private string[] _sWires = { "Tinkering", "Wires", "Wires", "Silver Wire" };
private string[] _gWires = { "Tinkering", "Wires", "Wires", "Gold Wire" };
private string[] _iString = { "Tinkering", "Wires", "Wires", "Iron String" };
private string[] _formaL = { "Carpentry", "Containers & Cont. parts", "Containers & Cont. parts", "Forma na lahve" };
///
/// Materiál -- 1 Iron ingot
/// Skill -- Tinkering 0.0
///
[Executable]
public void IronWire()
{
IronWire(0);
}
[Executable]
public void IronWire(int pocetV)
{
Hashtable table = new Hashtable();
ushort[] material = { _iStringG, _nullC };
table.Add(1, material);
Craftenie(_iWires, pocetV, _tinkerTools, table, _ironWiresG, _nullC);
}
///
/// Materiál -- 1 Iron wire
/// Skill -- Tinkering 35 + 35 blacksmithy
///
[Executable]
public void IronString()
{
IronString(0);
}
[Executable]
public void IronString(int pocetV)
{
Hashtable table = new Hashtable();
ushort[] material = { _ironG, _nullC };
table.Add(1, material);
Craftenie(_iString, pocetV, _tinkerTools, table, _ironStringG, _nullC);
}
///
/// Materiál -- 1 copper ingot
/// Skill -- Tinkering 15,0
///
[Executable]
public void CopperWire()
{
CopperWire(0);
}
[Executable]
public void CopperWire(int pocetV)
{
Hashtable table = new Hashtable();
ushort[] material = { _copperG, _nullC };
table.Add(1, material);
Craftenie(_cWires, pocetV, _tinkerTools, table, _copperStringG, _nullC);
}
///
/// Materiál -- 1 sivler ingot
/// Skill -- Tinkering 20,0
///
[Executable]
public void SilverWire()
{
SilverWire(0);
}
[Executable]
public void SilverWire(int pocetV)
{
Hashtable table = new Hashtable();
ushort[] material = { _silverG, _nullC };
table.Add(1, material);
Craftenie(_sWires, pocetV, _tinkerTools, table, _silverStringG, _nullC);
}
///
/// Materiál -- 1 gold ingot
/// Skill -- Tinkering 25,0
///
[Executable]
public void GoldWire()
{
GoldWire(0);
}
[Executable]
public void GoldWire(int pocetV)
{
Hashtable table = new Hashtable();
ushort[] material = { _goldG, _nullC };
table.Add(1, material);
Craftenie(_gWires, pocetV, _tinkerTools, table, _goldStringG, _nullC);
}
///
/// Materiál -- 2 barrel staves, 2 barrel lid
/// Skill -- Carpentry 90,0
///
[Executable]
public void FormaLahve()
{
FormaLahve(0);
}
[Executable]
public void FormaLahve(int pocetV)
{
Hashtable table = new Hashtable();
ushort[] material1 = { _barrelLidG, _nullC, 2 };
ushort[] material2 = { _barrelStavesG, _nullC, 2 };
table.Add(1, material1);
table.Add(2, material2);
Craftenie(_formaL, pocetV, _tinkerTools, table, _formaLahveG, _formaLahveC);
}
///
/// Základ craftenia pre výrobky, pre ktoré je potrebné len jeden materiál na výrobu
/// menu - craftské menu pre daný výrobok
/// pocet - udáva číslo, koľko výrobkov chce vyrobiť
/// tool - grafika crafstkého nástroja, ktoré je potrebné pre daný výrobok
/// mastros - hashtabulka kde value = pole s hodnotami materiálu, grafika, color a počet daného materiálu
/// vyrobokG - grafika výsledného výrobku
/// vyrobokC - color výsledného výrobku
///
public void Craftenie(string[] menu, int pocet, ushort tool, Hashtable matros, ushort vyrobokG, ushort vyrobokC)
{
//grafika a množštvo materiálu, ktorého počet je najmenší pri výrobe
ushort matG = 0x000;
int amount = 0;
_podarky = 0;
_nepodarky = 0;
//kontrola nástrojov
UOItem tools = World.Player.Backpack.AllItems.FindType(tool, _nullC);
if (tools.Amount < 1)
{
UO.PrintWarning("Chyba ti nastroj, koncim!");
return;
}
TargetContainers();
slucka:
foreach (DictionaryEntry de in matros)
{
ushort[] temp = (ushort[])de.Value;
//ushort mnozstvo = (ushort)((int)de.Key * 20);
if (amount > temp[2])
{
amount = (int)temp[2];
matG = temp[0];
}
if (UO.Count(temp[0]) < temp[2])
{
UOItem material = _zdrojB.AllItems.FindType(temp[0], temp[1]);
if (material.Amount > 0)
material.Move((ushort)(temp[2] * 20), World.Player.Backpack.Serial);
else
{
UO.PrintWarning("Nedostatok materialu u zdroje, koncim!");
Presun(vyrobokG, vyrobokC, matros);
return;
}
}
}
do
{
UO.Print(_podarky == pocet);
if (pocet > 0)
{
if (_podarky == pocet)
{
Presun(vyrobokG, vyrobokC, matros);
return;
}
}
//UO.PrintInformation("Vyrabam");
UO.WaitMenu(_iWires);
tools.Use();
Journal.WaitForText(true, _hlasky);
if (UO.InJournal("You put"))
_podarky++;
else
_nepodarky++;
UO.DeleteJournal();
}
while (UO.Count(matG) > amount);
goto slucka;
}
private void Presun(ushort vyrobokG, ushort vyrobokC, Hashtable matros)
{
foreach (DictionaryEntry de in matros)
{
ushort[] temp = (ushort[])de.Value;
//prenesiem výrobky do bedne + vrátim materiál na pôvodné miesto
UO.PrintInformation("Prenasam vyrobky a materialy");
UOItem vyrobky = World.Player.Backpack.AllItems.FindType(vyrobokG, vyrobokC);
UOItem materialy = World.Player.Backpack.AllItems.FindType(temp[0], temp[1]);
vyrobky.Move(0, _cielB.Serial);
materialy.Move(0, _zdrojB.Serial);
}
}
private void TargetContainers()
{
UO.PrintInformation("Vyber bednu z matrosom!");
_zdrojB = new UOItem(UIManager.TargetObject());
UO.Wait(100);
UO.PrintInformation("Vyber bednu na hotove vyrobky");
_cielB = new UOItem(UIManager.TargetObject());
_zdrojB.Use();
_cielB.Use();
}
}
}