///////////////////////////////////////////////////////////////////////// // // www.ultima.smoce.net // Name: Inscript v2 // ///////////////////////////////////////////////////////////////////////// using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using Phoenix; using Phoenix.WorldData; namespace Scripts.MagicGeneration { public class Inscript { /// /// Způsob doplňování many: /// 1 - Jen Potion /// 2 - Jen Meditace /// 3 - Meditace + Potion /// public const int zpusob = 3; /// /// Druh Mana potionu: /// 1 - TMR /// 2 - MR /// public const int drink = 1; /// /// Zapnout PRINT hlasky: /// True - Ano /// False - Ne /// public const bool print = true; /// /// Zadej pocet svitku (hotovich), kdy se maj prenest do truhle zadane: /// public const int prenest_scroll = 5; /// /// Zadej pocet kolik blanku ma prenaset /// public const int prenest_blanky = 20; /// /// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// /// #region Define_svitku private UOItem box_blanky; private UOItem box_regy; private UOItem box_scroll; private string druh_memmory; private int min_mana_potrebna; private int temp_ui,temp_ov=0; private int statistika_ok = 0; private int statistika_fizz = 0; private struct TMR { public const ushort Keg_t = 0x1843; public const ushort Keg_c = 0x0003; public const ushort type = 0x0F09; public const ushort color = 0x0003; } private struct ManaRef { public const ushort Keg_t = 0x1843; public const ushort Keg_c = 0x0005; public const ushort type = 0x0F09; public const ushort color = 0x0005; } private Dictionary scroll = new Dictionary { {"Agility", new ScrollType(2,10 ,0x1F35, 1,BM,1,MR,0,NIC,0,NIC)}, {"Arch Cure", new ScrollType(4,10 ,0x1F45, 1,GA,1,GI,1,MR,0,NIC)}, {"Arch Protection", new ScrollType(4,10 ,0x1F46 , 1,GA,1,GI,1,MR,1,SA)}, {"Blade Spirits", new ScrollType(5,10 ,0x1F4D, 1,BP,1,MR,1,NS,1,GA)}, {"Bless", new ScrollType(3,10 ,0x1F3D, 1,GA,1,MR,0,NIC,0,NIC)}, {"Clumsy", new ScrollType(1,10 ,0x1F2E, 1,BM,1,NS,0,NIC,0,NIC)}, {"Create Food", new ScrollType(1,10 ,0x1F2F, 10,GA,10,GI,10,MR,0,NIC)}, {"Cunning", new ScrollType(2,10 ,0x1F36 , 1,MR,1,NS,0,NIC,0,NIC)}, {"Cure", new ScrollType(2,10 ,0x1F37, 1,GA,1,GI,0,NIC,0,NIC)}, {"Curse", new ScrollType(4,10 ,0x0E35, 1,GA,1,NS,1,SA,0,NIC)}, {"Dispel", new ScrollType(6,10 ,0x1F55, 1,GA,1,MR,1,SA,0,NIC)}, {"Dispel Field", new ScrollType(5,10 ,0x1F4E , 1,GA,1,BP,1,SS,1,SA)}, {"Energy Bolt", new ScrollType(6,10 ,0x1F56, 1,BP,1,NS,0,NIC,0,NIC)}, {"Energy Field", new ScrollType(7,10 ,0x1F5E, 1,BP,1,NS,0,NIC,0,NIC)}, {"Energy Vortex", new ScrollType(8,10 ,0x1F66, 1,BP,1,NS,0,NIC,0,NIC)}, {"Explosion", new ScrollType(6,10 ,0x1F57, 1,BP,1,MR,1,SA,0,NIC)}, {"Feeblemind", new ScrollType(1,10 ,0x1F30, 1,GI,1,NS,0,NIC,0,NIC)}, {"Fire Field", new ScrollType(4,10 ,0x1F48, 1,GI,1,NS,0,NIC,0,NIC)}, {"Fireball", new ScrollType(3,10 ,0x1F3E, 1,BP,1,SA,0,NIC,0,NIC)}, {"Flamestrike", new ScrollType(7,10 ,0x1F5F, 1,BP,1,SA,0,NIC,0,NIC)}, {"Gate Travel", new ScrollType(7,10 ,0x1F60 , 1,BP,1,MR,1,SA,0,NIC)}, {"Greater Heal", new ScrollType(4,10 ,0x1F49, 1,GA,1,GI,1,MR,1,SS)}, {"Harm", new ScrollType(2,10 ,0x1F38, 1,SS,1,NS,0,NIC,0,NIC)}, {"Heal", new ScrollType(1,10 ,0x1F31, 1,GA,1,GI,1,SS,0,NIC)}, {"Chain Lighting", new ScrollType(7,10 ,0x1F5D, 1,BP,1,MR,1,BM,1,SA)}, {"Lighting", new ScrollType(4,10 ,0x1F4A , 1,BP,1,MR,1,BM,1,SA)}, {"Magic Arrow", new ScrollType(1,10 ,0x1F32, 1,BP,1,NS,0,NIC,0,NIC)}, {"Magic Reflection", new ScrollType(5,10 ,0x1F50, 1,BP,1,NS,0,NIC,0,NIC)}, {"Magic Trap", new ScrollType(2,10 ,0x1F39, 1,BP,1,NS,0,NIC,0,NIC)}, {"Magic Untrap", new ScrollType(2,10 ,0x1F40, 1,BM,1,SA,0,NIC,0,NIC)}, {"Mark", new ScrollType(6,10 ,0x1F59, 1,BP,1,BM,1,MR,0,NIC)}, {"Mass Dispel", new ScrollType(7,10 ,0x1F62, 1,BP,1,GA,1,MR,1,SA)}, {"Meteor Swarm", new ScrollType(7,10 ,0x1F63, 1,BM,1,SS,1,MR,1,SA)}, {"Mind Blast", new ScrollType(5,10 ,0x1F51, 1,BP,1,MR,1,NS,1,SA)}, {"Night Sight", new ScrollType(1,10 ,0x1F33 , 1,SS,1,SA,0,NIC,0,NIC)}, {"Paralyze", new ScrollType(5,10 ,0x1F52, 1,GA,1,MR,1,SS,0,NIC)}, {"Paralyze Field", new ScrollType(6,10 ,0x1F5B , 1,GA,1,MR,1,SS,0,NIC)}, {"Poison", new ScrollType(3,10 ,0x1F40, 1,GA,1,MR,1,SS,0,NIC)}, {"Poison Field", new ScrollType(5,10 ,0x1F53, 1,GA,1,MR,1,SS,0,NIC)}, {"Polymorph", new ScrollType(7,10 ,0x1F64, 1,BM,1,MR,1,SS,0,NIC)}, {"Protection", new ScrollType(2,10 ,0x1F3B, 1,GA,1,GI,1,SA,0,NIC)}, {"Reactive Armor", new ScrollType(1,10 ,0x1F2D, 1,GA,1,SA,1,SS,0,NIC)}, {"Recall", new ScrollType(4,10 ,0x1F4C, 1,BP,1,BM,1,MR,0,NIC)}, {"Resurrection", new ScrollType(8,10 ,0x1F67, 1,BM,1,GA,1,GI,0,NIC)}, {"Reveal", new ScrollType(6,10 ,0x1F5C, 1,BM,1,SA,0,NIC,0,NIC)}, {"Strenght", new ScrollType(2,10 ,0x1F3C, 1,MR,1,NS,0,NIC,0,NIC)}, {"Summon Air Elemental", new ScrollType(9,10 ,0x1F68, 1,BM,1,MR,1,SS,0,NIC)}, {"Summon Daemon", new ScrollType(8,10 ,0x1F69, 1,BM,1,MR,1,SS,0,NIC)}, {"Summon Earth Elemental", new ScrollType(8,10 ,0x1F6A, 1,BM,1,MR,1,SS,0,NIC)}, {"Summon Fire Elemental", new ScrollType(8,10 ,0x1F6B, 1,BM,1,MR,1,SS,1,SA)}, {"Summon Water Elemental", new ScrollType(8,10 ,0x1F6C, 1,BM,1,MR,1,SS,0,NIC)}, {"Teleport", new ScrollType(3,10 ,0x1F42, 1,BM,1,MR,0,NIC,0,NIC)}, {"Unlock", new ScrollType(3,10 ,0x1F43, 1,BM,1,SA,0,NIC,0,NIC)}, {"Wall Of Stone", new ScrollType(3,10 ,0x1F44, 1,BM,1,SA,0,NIC,0,NIC)}, {"Weaken", new ScrollType(1,10 ,0x1F34, 1,GA,1,NS,0,NIC,0,NIC)} }; #endregion #region ScrollType public class ScrollType { private int kruh; private int min_mana; private ushort scroll; private int creg1; private ushort reg1; private int creg2; private ushort reg2; private int creg3; private ushort reg3; private int creg4; private ushort reg4; public ScrollType(int _kruh, int _mana, ushort _ushort, int _regc1, ushort _reg1, int _regc2, ushort _reg2, int _regc3, ushort _reg3, int _regc4, ushort _reg4) { kruh = _kruh; min_mana = _mana; scroll = _ushort; reg1 = _reg1; creg1 = _regc1; reg2 = _reg2; creg2 = _regc2; reg3 = _reg3; creg3 = _regc3; reg4 = _reg4; creg4 = _regc4; } public int Kruh { get { return kruh; } } public int Minimal_Mana { get { return min_mana; } } public ushort Scroll { get { return scroll; } } public ushort Reg1 { get { return reg1; } } public ushort Reg2 { get { return reg2; } } public ushort Reg3 { get { return reg3; } } public ushort Reg4 { get { return reg4; } } public int CReg1 { get { return creg1; } } public int CReg2 { get { return creg2; } } public int CReg3 { get { return creg3; } } public int CReg4 { get { return creg4; } } } public const ushort BP = 0x0F7A; public const ushort BM = 0x0F7B; public const ushort GA = 0x0F84; public const ushort GI = 0x0F85; public const ushort MR = 0x0F86; public const ushort NS = 0x0F88; public const ushort SA = 0x0F8C; public const ushort SS = 0x0F8D; public const ushort NIC = 0x0000; #endregion [Command("insc")] [BlockMultipleExecutions("insc")] public void insc(string druh) { target_box(); if (!scroll.ContainsKey(druh)) { UO.Print("Zadany svitek v parametru neexistuje {0}", druh); return; } else { UO.Print("Dneska budeme psati {0}", druh); if (druh_memmory != druh) { statistika_ok = 0; statistika_fizz = 0; } druh_memmory = druh; min_mana_potrebna = scroll[druh_memmory].Minimal_Mana+5; } while (!World.Player.Dead) { check_vyrobku(); UO.Wait(300); check_regy(); UO.Wait(300); check_blanky(); UO.Wait(500); check_mana(); check_mana(); UO.Wait(300); inscript(); UO.Wait(300); } info("Konec programu"); } private void inscript() { if (World.Player.Mana > min_mana_potrebna) { info("Pisu svitek .."); UO.DeleteJournal(); temp_ui = World.Player.Mana; string[] incs = { "Spell Circles", scroll[druh_memmory].Kruh.ToString(), scroll[druh_memmory].Kruh.ToString(), druh_memmory }; UO.WaitMenu(incs); UOItem blanky = World.Player.Backpack.AllItems.FindType(0x0E34); blanky.Use(); string[] hlaskys = { "You put", "You fail" }; Journal.WaitForText(true, hlaskys); if (temp_ov == 0) { min_mana_potrebna = (temp_ui - World.Player.Mana)+5; info(0x0116, "Nastavena minimalni mana na svitek: " + min_mana_potrebna.ToString()); } temp_ov = 1; if (UO.InJournal("You put")) { statistika_ok++; info(0x010C,"Uspesny"); } else { statistika_fizz++; info(0x0080,"Neuspesny"); } statistika(); } } private void statistika() { int celkem = statistika_fizz+statistika_ok; float vysledek = (statistika_ok / celkem)*100; UO.Print(0x055A, "Statistika:"); UO.Print(0x055A, "Celkem: {0} ", celkem); UO.Print(0x055A, "Uspesne: {0} ", statistika_ok); UO.Print(0x055A, "Neuspesne: {0}", statistika_fizz); UO.Print(0x055A, "Uspesnost: {0}%", (float)vysledek); } private void check_mana() { if (World.Player.Mana < min_mana_potrebna) { #pragma warning disable info(0x0116, "Malo Many, jdu to resit"); switch (zpusob) { case 1: piti(); break; case 2: meditace(); break; case 3: piti(); meditace(); break; default: info("Chyba v nastaveni zpusobu doplnovani many!!!!"); meditace(); break; } #pragma warning restore } } private void check_blanky() { if (UO.Count(0x0E34) == 0) { if (!box_blanky.Opened) { box_blanky.Use(); UO.Wait(500); } info(0x002B,"Prenasim " + prenest_blanky.ToString() + " blanky do backpacku"); UOItem blanks = new UOItem(box_blanky.AllItems.FindType(0x0E34)); if (!blanks.Exist) { info(0x002B, "Nejdou pretahnout blanky do backpacku ... KONEC"); UO.TerminateAll(); } blanks.Move(prenest_blanky, World.Player.Backpack); } } private void check_regy() { if (UO.Count(scroll[druh_memmory].Reg1) < scroll[druh_memmory].CReg1) { if (!box_regy.Opened) { box_regy.Use(); UO.Wait(500); } UOItem regs1 = new UOItem(box_regy.AllItems.FindType(scroll[druh_memmory].Reg1)); if (!regs1.Exist) { info("Nenalezeny reg typu 1.. Viz DP. web ... KONEC"); UO.TerminateAll(); } regs1.Move(100, World.Player.Backpack); info(0x002B, "Doplneni regu 1"); UO.Wait(300); } if (UO.Count(scroll[druh_memmory].Reg2) < scroll[druh_memmory].CReg2) { if (!box_regy.Opened) { box_regy.Use(); UO.Wait(500); } UOItem regs2 = new UOItem(box_regy.AllItems.FindType(scroll[druh_memmory].Reg2)); if (!regs2.Exist) { info("Nenalezeny reg typu 2.. Viz DP. web ... KONEC"); UO.TerminateAll(); } regs2.Move(100, World.Player.Backpack); info(0x002B, "Doplneni regu 2"); UO.Wait(300); } if (UO.Count(scroll[druh_memmory].Reg3) < scroll[druh_memmory].CReg3) { if (!box_regy.Opened) { box_regy.Use(); UO.Wait(500); } UOItem regs3 = new UOItem(box_regy.AllItems.FindType(scroll[druh_memmory].Reg3)); if (!regs3.Exist) { info("Nenalezeny reg typu 1.. Viz DP. web ... KONEC"); UO.TerminateAll(); } regs3.Move(100, World.Player.Backpack); info(0x002B, "Doplneni regu 3"); UO.Wait(300); } if (UO.Count(scroll[druh_memmory].Reg4) < scroll[druh_memmory].CReg4) { if (!box_regy.Opened) { box_regy.Use(); UO.Wait(500); } UOItem regs4 = new UOItem(box_regy.AllItems.FindType(scroll[druh_memmory].Reg4)); if (!regs4.Exist) { info("Nenalezeny reg typu 1.. Viz DP. web ... KONEC"); UO.TerminateAll(); } regs4.Move(100, World.Player.Backpack); info(0x002B, "Doplneni regu 4"); UO.Wait(300); } } private void check_vyrobku() { if (UO.Count(scroll[druh_memmory].Scroll) >= prenest_scroll && box_scroll.Serial != World.Player.Backpack) { info(0x002B, "Zjistuju stav "); UOItem hotov_vyrobek = new UOItem(World.Player.Backpack.AllItems.FindType(scroll[druh_memmory].Scroll)); hotov_vyrobek.Move(0, box_scroll.Serial); info(0x002B, "Prenos "+hotov_vyrobek.Amount.ToString() +" svitku dokoncen..."); } } private void target_box() { info(0x010C,"Zvol truhlu s blanky"); box_blanky = new UOItem(UIManager.TargetObject()); UO.Wait(500); if(!box_blanky.Exist) { info(0x0026, "Truhla s blanky neexistuje nastavuje se BackPack"); box_blanky = World.Player.Backpack; } info(0x010C, "Zvol truhlu, kam se budou prenaset svitky hotove"); box_scroll = new UOItem(UIManager.TargetObject()); UO.Wait(500); if (!box_scroll.Exist) { info(0x0026,"Truhla s hotovima svitkama neexistuje nastavuje se BackPack"); box_scroll = World.Player.Backpack; } info(0x010C, "Zvol truhlu s regy"); box_regy = new UOItem(UIManager.TargetObject()); UO.Wait(500); if (!box_regy.Exist) { info(0x0026, "Truhla s REGY neexistuje nastavuje se BackPack"); box_blanky = World.Player.Backpack; } } private void piti() { #pragma warning disable switch (drink) { case 1: if (UO.Count(TMR.type, TMR.color) > 0) { vypij(TMR.type, TMR.color, "TMR"); } else { if (UO.Count(TMR.Keg_t, TMR.Keg_c) > 0) { nalij(TMR.Keg_t, TMR.Keg_c, "TMR"); vypij(TMR.type, TMR.color, "TMR"); } else { jak_doplnit_manu(); } } break; case 2: if (UO.Count(ManaRef.type, ManaRef.color) > 0) { vypij(ManaRef.type, ManaRef.color, "MR"); } else { if (UO.Count(ManaRef.Keg_t, ManaRef.Keg_c) > 0) { nalij(ManaRef.Keg_t, ManaRef.Keg_c, "MR"); vypij(ManaRef.type, ManaRef.color, "MR"); } else { jak_doplnit_manu(); } } break; default: if (UO.Count(TMR.type, TMR.color) > 0) { vypij(TMR.type, TMR.color, "TMR"); } else { if (UO.Count(TMR.Keg_t, TMR.Keg_c) > 0) { nalij(TMR.Keg_t, TMR.Keg_c, "TMR"); vypij(TMR.type, TMR.color, "TMR"); } else { jak_doplnit_manu(); } } break; } #pragma warning restore } private void jak_doplnit_manu() { #pragma warning disable if (zpusob == 2 || zpusob == 3) { meditace(); } else { Cekani_intervals("TMR"); } #pragma warning restore } private void vypij(ushort type, ushort color, string name) { UOItem potion = World.Player.Backpack.AllItems.FindType(type,color); potion.Use(); info(0x0116, "Vypito "+name+" "); } private void nalij(ushort type, ushort color,string name) { UOItem keg = World.Player.Backpack.AllItems.FindType(type, color); UOItem emptyBottle = World.Player.Backpack.AllItems.FindType(0x0F0E); UO.WaitTargetObject(emptyBottle.Serial); keg.Use(); UO.Wait(200); info(0x0116, "Nalil jsem "+name+" z kade"); } private void info(string hlaska) { info(0x00baf, hlaska); } private void info(ushort color, string hlaska) { if (print) { UO.Print(color,"Inscript: {0}", hlaska); } } private void Cekani_intervals(string hlaska) { while(World.Player.Mana <= (min_mana_potrebna+2)) { UO.Wait(2000); } info(0x0120,"Mana hranice pro svitek docerpana"); } private void meditace() { while (World.Player.Mana < World.Player.MaxMana) { if (!World.Player.Dead) { UO.UseSkill("Meditation"); UO.Wait(2500); // info(0x0120,"Medituju " + World.Player.Mana.ToString() + "/" + World.Player.MaxMana.ToString() + ""); } else { break; } } } } }