EDIT: 1. per il looter vedi sotto!
2. corretto la formula del delay della bendata
3. aggiunto check mortal, fix sul looter
Nei ritagli di tempo che ho il fine settimana, mi sono rimesso a giocare qualche ora su dreams e perchè no, a scriptare
Essendo passato quasi un anno dagli ultimi codici che ho scritto sono un pò arrugginito e praticamente sto ripartendo da 0 con il LUA, ovviamente i vecchi codici che avevo scritto sono andati persi.
Insomma sarebbe molto utile se qualcuno avesse voglia di provare i miei script e dirmi quali problemi sorgono usandoli.
Per adesso non contattatemi in privato, ormai non controllo piu msn ne icq quindi sono reperibile solo tramite il forum.
Quindi eccovi un paio di script, molto basilari e funzionanti da provare.
Il primo script in lavorazione è quello per la bendata:
	il secondo è un looter:
	edit: ho corretto un errore per cui non ignorava sempre i corpse lootati, inoltre ho aggiunto le liste per lootare reagenti e chiavi dei boss ML per poter fare più test. ovviamente usate lo script a vostro rischio e pericolo 
quello che mi interessa ora è la stabilità quindi provateli così come sono e scrivetemi qualsiasi cosa notiate, anche i dettagli possono aiutare 
							
						
					2. corretto la formula del delay della bendata
3. aggiunto check mortal, fix sul looter
Nei ritagli di tempo che ho il fine settimana, mi sono rimesso a giocare qualche ora su dreams e perchè no, a scriptare

Essendo passato quasi un anno dagli ultimi codici che ho scritto sono un pò arrugginito e praticamente sto ripartendo da 0 con il LUA, ovviamente i vecchi codici che avevo scritto sono andati persi.
Insomma sarebbe molto utile se qualcuno avesse voglia di provare i miei script e dirmi quali problemi sorgono usandoli.
Per adesso non contattatemi in privato, ormai non controllo piu msn ne icq quindi sono reperibile solo tramite il forum.
Quindi eccovi un paio di script, molto basilari e funzionanti da provare.
Il primo script in lavorazione è quello per la bendata:
- contatore che scandisce i secondi sopra al pg
- avverte quando si è a corto di bende (10 o meno)
- controllo sul cursore per cercare di non interrompere i cast
- da implementare: letture sul journal, in caso di errori, ritardi, interruzioni
codice:
	
	-- Soglia di hp per iniziare a curarsi Default: UO.MaxHits per curare appena manca 1hp
hits = UO.MaxHits 
--Inizio script
bandagetype = 3617 
function main()
  local items
  nBende = ContaBende()    
  while true do
    wait(1)
    while UO.Hits < hits or string.find(UO.CharStatus,"C")  and not string.find(UO.CharStatus,"D") do
      if ContaBende() >= 1 then
        WaitCursor()
        UO.Macro(58,0)
        bandageTime = getticks() + 60
        if ContaBende() <= 10 then
          UO.SysMessage("hai solo " .. ContaBende() .. " bende!",233)
          end 
        counter() 
      end 
    end
  end
end  
 
function counter()
timer = ( 11 -  ( UO.Dex - ( UO.Dex % 10 ) ) / 20 ) 
if timer % 1 > 0 and UO.Dex % 20 > 0 then --arrotondamento x la formula secondo stratics
  timer = timer + 0.5
  end
if timer < 5 then timer = 5 end --tempo healing minimo cappato a 5sec
  for i=timer,1,-1 do
    UO.ExMsg(UO.CharID,3,375,tostring(i))
    wait(1000)
  end 
end
function ContaBende()
local cnt = UO.ScanItems(true)-1 
  for i=0,cnt do
    local id,type,kind,contid,x,y,z,stack,rep,col = UO.GetItem(i)
    if contid == UO.BackpackID and type == bandagetype and stack > 0 then
     idbende = id
     return stack 
    end
  end
return false
end
function WaitCursor(t)
if t == nil then
  timeout = 1000 + getticks ()
else 
  timeout = t + getticks ()
  end
while UO.TargCurs == true and timeout > getticks() do 
   wait (5)
   if timeout <= getticks() then
      return false
      end 
   end
return true 
end
main()
- loota gold, gemme, questitem per i peerless, reagenti
- soltanto per adesso: parte solo quando si preme il tasto
- droppa direttamente nello zaino
- da implementare:
- taglio di pelli e ossa, uso della bag of sending, controlli sul peso, altre liste di loot
- controlli supplementari per prevenire eventuali crash
- menu e valutazione delle props degli item
codice:
	
	   -- variabili personalizzabili
hotkey = "F5"
lootgold = true
lootgems = true
lootpeerless = true
lootreagent = true
debug = true
hidelooted = false
--inizializzazione costanti e tavole
corpsetype = 8198
oldcorpses = {}
errmsg = {
  ["Something is standing in your way"] = true,
  ["That is out of sight."] = true,
  ["You must wait to perform another action."] = true,
  ["You can not pick that up."] = true,
  ["Target cannot be seen."] = true,
  [UO.CharName..": I can't reach that."] = true,
  }  
  
-- Liste loot
gems = {3855,3856,3857,3859,3861,3862,3864,3865,3873,3877,3878,3885}
gold = {3821}
peerlesskeys = {3829,3975,4328,6880,7391,7406,7408,7583,8193,8194,8765,8766,8770
,8773,8775,8776,22334}
reagents = {3960,3962,3963,3965,3966,3968,3969,3972,3973,3974,3976,3978,3980
,3981,3982,3983,12688,12689,16503}
-- INIZIO SCRIPT 
function buildlootlist ()
lootlist = {}
if lootgold then
   for k,v in pairs(gold) do
      table.insert(lootlist,v)
      end
end
if lootgems then
    for k,v in pairs(gems) do
      table.insert(lootlist,v)
      end
    end
if lootreagent then
   for k,v in pairs(reagents) do
      table.insert(lootlist,v)
      end
   end
if lootpeerless then
   for k,v in pairs(peerlesskeys) do
      table.insert(lootlist,v)
      end
   end
end
--presa da choosy non mi piace, DA RIFARE
--[[Features: debug
    Parameter: range = 'number'
    Return: true at first matching item
            false if nothing found
]]--
function FindCorpse(range)
  local i, c, dx, dy
  for i = 0,UO.ScanItems(true)-1 do
    local id,type,kind,contid,x,y,z,stack,rep,col = UO.GetItem(i)
    if type == 8198 then
      local skip = false
      for c = 1,#oldcorpses do
        if id == oldcorpses[c] then
          skip = true
        end
      end
      if not skip then
        dx = math.abs(x-UO.CharPosX)
        dy = math.abs(y-UO.CharPosY)
        if dy < range and dx < range then
          corpse = id
          return true
        end
      end
    end
  end 
  return false  
end
--[[Parameter needed: global variable corpse = 'ID'
    Returns: false if timed out or error occurs   
             true and sets variables if success
             public variables: ccX
                               ccY
                               corpseCont
]]--
function OpenCorpse()
  UO.LObjectID = corpse
  local timeout = getticks() + 2000
  local tempCont = UO.ContID
  UO.Macro(17, 0, "")
  wait (100)
  repeat 
    if checkMsg(timeout - getticks()) then
      print("OpenCorpse function error: not possible to complete")
      return false
    end
    if corpsetype == UO.ContType and corpse == UO.ContID then
     corpseCont = UO.ContID
     ccX = UO.ContPosX + 75
     ccY = UO.ContPosY + 75
     return true
    end
    wait(1)
  until timeout < getticks()
return false
end
--[[Parameter: timeout = 'number'
    return: true if message is found
            false if nothing
]]--
function checkMsg(timeout)
  local ref = 0
  local i, jstr, col, cnt
  ref,cnt = UO.ScanJournal(ref)
  repeat
    wait(1)
    ref,cnt = UO.ScanJournal(ref)
  until cnt > 0 or timeout < getticks()
  if cnt < 1 then
    return false
  end
  for i = cnt-1,0,-1 do
    jstr,col = UO.GetJournal(i)
    if errmsg[jstr] then
      print(jstr)
      return true
    end
  end
return false
end
function CloseCorpse()
  while UO.ContID == corpseCont do
    UO.Click(ccX,ccY,false,true,true,false)
    wait (20)
  end
  UO.HideItem(corpse)
end
function dropitem(it,amt,bag)
  UO.Drag(it,amt)
  wait(100)
  repeat
  UO.DropC(UO.BackpackID)
  until not checkMsg(2000) 
  wait(210)
    --print("drag item error")
    --return false
  --end
  return true
end
function CheckLoot()
  lootTable = {}
  itemAmt = {}
  local i, j, added
  for i = 0,UO.ScanItems(true)-1 do
    local id,type,kind,contid,x,y,z,stack,rep,col = UO.GetItem(i)
    added = false
    for j = 1,#lootlist do
      if type == lootlist[j] and contid == corpseCont then
        table.insert(lootTable,id)
        table.insert(itemAmt,stack)
        added = true
      end
    end
    --[[if not added and contid == corpseCont then
      if evaluate(id) > minvalue then
        table.insert(lootTable,id)
        table.insert(itemAmt,1)
      end
    end 
    ]]-- 
  end
  if #lootTable == 0 or #lootTable == nil then
    if hidelooted then CloseCorpse () end
    return false
  end
  return true
end
function LootCorpse()
  local i,timeout
  timeout = getticks() + 20000 
  CheckLoot ()
  repeat  
  for i = 1, #lootTable do
    if not dropitem(lootTable[i],itemAmt[i],lootbag) then
      print ("error looting?")
      return false
    end
  end
  until not CheckLoot () 
  return true
end
timestamp = function(ms)
--UO.SysMessage ("Operazione completata in " .. getticks() - ms .. " millisecondi" , 51)
print("Operazione completata in " .. getticks() - ms .. " millisecondi") 
end
function main()
   if FindCorpse (3) then
      timer = getticks()
      if OpenCorpse () then
        if LootCorpse () then
          UO.SysMessage ( "looted in " .. getticks() - timer .. "ms" , 233)  
          if hidelooted then CloseCorpse () end 
          table.insert(oldcorpses,corpse)   
        end
      else
          UO.SysMessage ( "looted in " .. getticks() - timer .. "ms" , 233)  
      end
   end
end
buildlootlist()
repeat 
if getkey(hotkey) then
  main()
  wait(600)
  end
  wait (5)
until false == true

quello che mi interessa ora è la stabilità quindi provateli così come sono e scrivetemi qualsiasi cosa notiate, anche i dettagli possono aiutare
 
							
						


 : algander#6292
: algander#6292




 
							
						
 
 
Commenta