Script:Veterinary.boo
Z AmonWiki
(Rozdíly mezi verzemi)
m |
|||
Řádka 12: | Řádka 12: | ||
<source lang="boo"> | <source lang="boo"> | ||
namespace Scripts.DarkParadise | namespace Scripts.DarkParadise | ||
- | + | ||
import System | import System | ||
+ | import System.Linq.Enumerable | ||
import System.Collections.Generic | import System.Collections.Generic | ||
import Phoenix | import Phoenix | ||
import Phoenix.WorldData | import Phoenix.WorldData | ||
import System.Threading | import System.Threading | ||
- | + | ||
class Veterinary: | class Veterinary: | ||
static final BandagesType as ushort = 0x0E21 | static final BandagesType as ushort = 0x0E21 | ||
static final HitsCritical = 45 | static final HitsCritical = 45 | ||
- | + | ||
private def SelectMob(name) as UOCharacter: | private def SelectMob(name) as UOCharacter: | ||
UO.Print("Vyber ${name} zvire:") | UO.Print("Vyber ${name} zvire:") | ||
mob = UOCharacter(UIManager.TargetObject()) | mob = UOCharacter(UIManager.TargetObject()) | ||
- | + | ||
if not mob.Exist or not mob.RequestStatus(5000) or not mob.Renamable: | if not mob.Exist or not mob.RequestStatus(5000) or not mob.Renamable: | ||
UO.PrintWarning('Neplatny target.') | UO.PrintWarning('Neplatny target.') | ||
return null | return null | ||
- | + | ||
return mob | return mob | ||
- | + | ||
[Executable('veterinary')] | [Executable('veterinary')] | ||
[BlockMultipleExecutions] | [BlockMultipleExecutions] | ||
Řádka 38: | Řádka 39: | ||
// Select animals | // Select animals | ||
mobs = List[of UOCharacter]() | mobs = List[of UOCharacter]() | ||
- | + | ||
for i in range(4): | for i in range(4): | ||
m = SelectMob(i + 1) | m = SelectMob(i + 1) | ||
- | + | ||
if m is null and (i % 2) > 0: | if m is null and (i % 2) > 0: | ||
raise ScriptErrorException('Nelze mit lichy pocet zviratek.') | raise ScriptErrorException('Nelze mit lichy pocet zviratek.') | ||
Řádka 48: | Řádka 49: | ||
if mobs.Contains(m): | if mobs.Contains(m): | ||
raise ScriptErrorException('Nemuzes vybrat stejne zvire 2x.') | raise ScriptErrorException('Nemuzes vybrat stejne zvire 2x.') | ||
- | + | ||
mobs.Add(m) | mobs.Add(m) | ||
- | + | ||
- | + | ||
if mobs.Count == 0: | if mobs.Count == 0: | ||
raise ScriptErrorException('Nevybral jsi zadne zvire!') | raise ScriptErrorException('Nevybral jsi zadne zvire!') | ||
- | + | ||
UO.Print("Vybrano ${mobs.Count} zvirat pro trening.") | UO.Print("Vybrano ${mobs.Count} zvirat pro trening.") | ||
- | + | ||
// Validate names | // Validate names | ||
names = List[of string]() | names = List[of string]() | ||
for i in range(0, mobs.Count): | for i in range(0, mobs.Count): | ||
n = mobs[i].Name.ToLowerInvariant() | n = mobs[i].Name.ToLowerInvariant() | ||
- | + | ||
if names.Contains(n): | if names.Contains(n): | ||
raise ScriptErrorException('Zvirata maji stejne jmeno, prosim prejmenujte je.') | raise ScriptErrorException('Zvirata maji stejne jmeno, prosim prejmenujte je.') | ||
- | + | ||
names.Add(n) | names.Add(n) | ||
- | + | ||
// Show status bars | // Show status bars | ||
//for m in mobs: | //for m in mobs: | ||
// UO.Exec('statusbar', m.Serial) | // UO.Exec('statusbar', m.Serial) | ||
- | + | ||
// Spust hlidace | // Spust hlidace | ||
run = true | run = true | ||
target_sync = object() | target_sync = object() | ||
- | + | ||
watchman_func = def(): | watchman_func = def(): | ||
try: | try: | ||
lastAttack = DateTime() | lastAttack = DateTime() | ||
- | + | ||
i = 0 | i = 0 | ||
interval = TimeSpan.FromSeconds(8 / mobs.Count) | interval = TimeSpan.FromSeconds(8 / mobs.Count) | ||
- | + | ||
while run and World.Player.Hits >= World.Player.MaxHits: | while run and World.Player.Hits >= World.Player.MaxHits: | ||
noattack = false | noattack = false | ||
- | + | ||
// Kontrola hp | // Kontrola hp | ||
for mob in mobs: | for mob in mobs: | ||
Řádka 92: | Řádka 93: | ||
UO.Wait(5000) | UO.Wait(5000) | ||
noattack = true | noattack = true | ||
- | + | ||
if not noattack and (DateTime.Now - lastAttack) > interval: | if not noattack and (DateTime.Now - lastAttack) > interval: | ||
lastAttack = DateTime.Now | lastAttack = DateTime.Now | ||
- | + | ||
mob1 = mobs[i] | mob1 = mobs[i] | ||
mob2 = mobs[i + 1] | mob2 = mobs[i + 1] | ||
- | + | ||
// Posli je do utoku | // Posli je do utoku | ||
lock target_sync: | lock target_sync: | ||
r1 = UO.WaitTargetObject(mob2.Serial) | r1 = UO.WaitTargetObject(mob2.Serial) | ||
UO.Say(mob1.Name + ' Kill') | UO.Say(mob1.Name + ' Kill') | ||
- | + | ||
if not r1.Wait(8000): | if not r1.Wait(8000): | ||
UO.PrintWarning('Kill command timeout.') | UO.PrintWarning('Kill command timeout.') | ||
continue | continue | ||
- | + | ||
UO.Wait(400) | UO.Wait(400) | ||
- | + | ||
lock target_sync: | lock target_sync: | ||
r2 = UO.WaitTargetObject(mob1.Serial) | r2 = UO.WaitTargetObject(mob1.Serial) | ||
UO.Say(mob2.Name + ' Kill') | UO.Say(mob2.Name + ' Kill') | ||
- | + | ||
if not r2.Wait(8000): | if not r2.Wait(8000): | ||
UO.PrintWarning('Kill command timeout.') | UO.PrintWarning('Kill command timeout.') | ||
continue | continue | ||
- | + | ||
UO.Wait(400) | UO.Wait(400) | ||
- | + | ||
// Increment | // Increment | ||
i = (i + 2) % mobs.Count | i = (i + 2) % mobs.Count | ||
Řádka 132: | Řádka 133: | ||
ensure: | ensure: | ||
run = false | run = false | ||
- | + | ||
watchman = Thread(watchman_func) | watchman = Thread(watchman_func) | ||
watchman.IsBackground = true | watchman.IsBackground = true | ||
watchman.Start() | watchman.Start() | ||
- | + | ||
// Zde je samotny script | // Zde je samotny script | ||
try: | try: | ||
Řádka 142: | Řádka 143: | ||
while run: | while run: | ||
bandy = UO.Backpack.Items.FindType(BandagesType, 0) | bandy = UO.Backpack.Items.FindType(BandagesType, 0) | ||
- | + | ||
if bandy.Amount < 2: | if bandy.Amount < 2: | ||
UO.PrintError('Dosli bandy!') | UO.PrintError('Dosli bandy!') | ||
break | break | ||
- | + | ||
if World.SunLight > 0: | if World.SunLight > 0: | ||
UO.Cast(StandardSpell.NightSight, Aliases.Self) | UO.Cast(StandardSpell.NightSight, Aliases.Self) | ||
UO.Wait(3000) | UO.Wait(3000) | ||
- | + | ||
// Koho lecit? | // Koho lecit? | ||
- | mobs. | + | h = mobs.OrderBy({s as UOCharacter | cast(single, s.Hits) / cast(single, s.MaxHits)}).First() |
- | + | ||
- | + | ||
// Ma to vubec cenu? | // Ma to vubec cenu? | ||
if h.Hits >= h.MaxHits: | if h.Hits >= h.MaxHits: | ||
Řádka 160: | Řádka 160: | ||
UO.Wait(500) | UO.Wait(500) | ||
continue | continue | ||
- | + | ||
// Lecime | // Lecime | ||
Journal.Clear() | Journal.Clear() | ||
Řádka 168: | Řádka 168: | ||
if not t.Wait(8000): | if not t.Wait(8000): | ||
UO.PrintWarning('Bandages target timeout.') | UO.PrintWarning('Bandages target timeout.') | ||
- | + | ||
UO.Wait(2400) | UO.Wait(2400) | ||
Journal.WaitForText(true, 5000, 'bloody bandages', 'apply the bandages', 'Chces vytvorit', 'Cancelled', 'the target', 'wait', 'battle', 'frozen', 'vylecil', 'state') | Journal.WaitForText(true, 5000, 'bloody bandages', 'apply the bandages', 'Chces vytvorit', 'Cancelled', 'the target', 'wait', 'battle', 'frozen', 'vylecil', 'state') | ||
- | + | ||
if Journal.Contains(true, 'battle', 'frozen'): | if Journal.Contains(true, 'battle', 'frozen'): | ||
UO.Say('All Stop') | UO.Say('All Stop') | ||
UO.RunCmd('speak', 'Help! Someone is attacking you!') | UO.RunCmd('speak', 'Help! Someone is attacking you!') | ||
break | break | ||
- | + | ||
run = false | run = false | ||
watchman.Join(2000) | watchman.Join(2000) | ||
Řádka 185: | Řádka 185: | ||
except : | except : | ||
pass | pass | ||
- | + | ||
// Finalize | // Finalize | ||
UO.Say('All Stop') | UO.Say('All Stop') | ||
UO.RunCmd('speak', 'Veterinary script stopped.') | UO.RunCmd('speak', 'Veterinary script stopped.') | ||
</source> | </source> |
Aktuální verze z 5. 7. 2010, 09:04
Jazyk: Boo
Shard: Dark Paradise
Tréning veteriny na zvířatech, ovládání, healování, hlídaní.
Script podporuje až 4 zvířata (technicky jich může být neomezeně, ale začnete pak lagovat server = toužíte po jailu).
Po spuštění vás script nechá vybrat zvířata. Musí jich být sudý počet. Pokud chcete jen dvě (pro nižší skill bohatě stačí), na třetí target zmáčkněte escape (nebo targetněte nejakou blbost).
Script se ukončí pokud dojdou bandy nebo vám něco ublíží (musíte mít plné HP).
Zvířata proti sobě script poštve přes All Kill v párech. Jestliže je nějaké zvíře na umření, script všechny zastaví a dohealuje ho. Sám pak pokračuje.
Pozn: Bandy musíte mít přímo v batohu.
Nemakrujte AFK!!!
namespace Scripts.DarkParadise import System import System.Linq.Enumerable import System.Collections.Generic import Phoenix import Phoenix.WorldData import System.Threading class Veterinary: static final BandagesType as ushort = 0x0E21 static final HitsCritical = 45 private def SelectMob(name) as UOCharacter: UO.Print("Vyber ${name} zvire:") mob = UOCharacter(UIManager.TargetObject()) if not mob.Exist or not mob.RequestStatus(5000) or not mob.Renamable: UO.PrintWarning('Neplatny target.') return null return mob [Executable('veterinary')] [BlockMultipleExecutions] public def Train(): // Select animals mobs = List[of UOCharacter]() for i in range(4): m = SelectMob(i + 1) if m is null and (i % 2) > 0: raise ScriptErrorException('Nelze mit lichy pocet zviratek.') if m is null: break if mobs.Contains(m): raise ScriptErrorException('Nemuzes vybrat stejne zvire 2x.') mobs.Add(m) if mobs.Count == 0: raise ScriptErrorException('Nevybral jsi zadne zvire!') UO.Print("Vybrano ${mobs.Count} zvirat pro trening.") // Validate names names = List[of string]() for i in range(0, mobs.Count): n = mobs[i].Name.ToLowerInvariant() if names.Contains(n): raise ScriptErrorException('Zvirata maji stejne jmeno, prosim prejmenujte je.') names.Add(n) // Show status bars //for m in mobs: // UO.Exec('statusbar', m.Serial) // Spust hlidace run = true target_sync = object() watchman_func = def(): try: lastAttack = DateTime() i = 0 interval = TimeSpan.FromSeconds(8 / mobs.Count) while run and World.Player.Hits >= World.Player.MaxHits: noattack = false // Kontrola hp for mob in mobs: if mob.Hits < HitsCritical: // Zastav je UO.Say('All Stop') UO.Wait(5000) noattack = true if not noattack and (DateTime.Now - lastAttack) > interval: lastAttack = DateTime.Now mob1 = mobs[i] mob2 = mobs[i + 1] // Posli je do utoku lock target_sync: r1 = UO.WaitTargetObject(mob2.Serial) UO.Say(mob1.Name + ' Kill') if not r1.Wait(8000): UO.PrintWarning('Kill command timeout.') continue UO.Wait(400) lock target_sync: r2 = UO.WaitTargetObject(mob1.Serial) UO.Say(mob2.Name + ' Kill') if not r2.Wait(8000): UO.PrintWarning('Kill command timeout.') continue UO.Wait(400) // Increment i = (i + 2) % mobs.Count else: // Jinak cekej UO.Wait(200) except ex as ThreadAbortException: UO.Print('Watchman thread aborted.') except e as Exception: UO.PrintError('Unhandled exception in watchmam thread.') UO.PrintError(e.Message) ensure: run = false watchman = Thread(watchman_func) watchman.IsBackground = true watchman.Start() // Zde je samotny script try: // Start loop while run: bandy = UO.Backpack.Items.FindType(BandagesType, 0) if bandy.Amount < 2: UO.PrintError('Dosli bandy!') break if World.SunLight > 0: UO.Cast(StandardSpell.NightSight, Aliases.Self) UO.Wait(3000) // Koho lecit? h = mobs.OrderBy({s as UOCharacter | cast(single, s.Hits) / cast(single, s.MaxHits)}).First() // Ma to vubec cenu? if h.Hits >= h.MaxHits: UO.PrintInformation('Nothing to do.') UO.Wait(500) continue // Lecime Journal.Clear() lock target_sync: t = UO.WaitTargetObject(h.Serial) bandy.Use() if not t.Wait(8000): UO.PrintWarning('Bandages target timeout.') UO.Wait(2400) Journal.WaitForText(true, 5000, 'bloody bandages', 'apply the bandages', 'Chces vytvorit', 'Cancelled', 'the target', 'wait', 'battle', 'frozen', 'vylecil', 'state') if Journal.Contains(true, 'battle', 'frozen'): UO.Say('All Stop') UO.RunCmd('speak', 'Help! Someone is attacking you!') break run = false watchman.Join(2000) ensure: try: if watchman.IsAlive: watchman.Abort() except : pass // Finalize UO.Say('All Stop') UO.RunCmd('speak', 'Veterinary script stopped.')