Need advice with auto attacking script

Discussion about the technical aspects of scripting. Ask about all issues involving your freelance projects here.
Locked
User avatar
SLiMX
Grandmaster Scribe
Posts: 88
Joined: Sat Jan 21, 2012 4:27 pm

Need advice with auto attacking script

Post by SLiMX »

Hey all,
I am using an outdated auto attcker/ recall script that does not scan for blue player and only uses 1 runebook etc. Also the scan journel does not work correctly. I would like a better script and seeking help me out or I am willing to pay a reasonable price.

Plz [pm Hazardous in game with any info. Thanks and best of luck out there.
Now known as HaZaRdOuS, still the same awesomeness behind the keyboard :)
themadxcow
Novice Scribe
Posts: 9
Joined: Fri Nov 09, 2012 8:30 pm

Re: Need advice with auto attacking script

Post by themadxcow »

basic one that i had been able to play.

Code: Select all

function main()
local timer=getticks()
while true do
if UO.EnemyID==0 or timer<getticks() then
local tmp=UO.LTargetID
local k=UO.LTargetKind
tmpid=scan()

if tmpid>0 then
UO.LTargetKind=3
UO.LTargetID=tmpid
UO.Macro(27,0)
end
end
end
end

function scan()
local item = {}
for i=0, UO.ScanItems(true)-1,1 do
    local nid,typ,kind,contid,xu,yu,zu,stck,col,rep = UO.GetItem(i)
        if kind==1   then    
     if col>2 and col <10 then
       table.insert(item,{id=nid,d=getDist(xu,yu)})
    end
    end
end
table.sort(item,function(a,b) return a.d<b.d end)
if next(item) then
print(item[1].id)
   return item[1].id
end
return 0
end


function getDist(x,y) return math.max(math.abs(UO.CharPosX-x),math.abs(UO.CharPosY-y)) end

main()
Dramoor
Legendary Scribe
Posts: 450
Joined: Wed Feb 23, 2011 7:37 pm

Re: Need advice with auto attacking script

Post by Dramoor »

He wanted something that scanned for players and then recalled away if players were present since his script doesn't recall away and just attacks anything it sees.

But for that code he posted could add this in and get Consecrate Weapon go off just before it wears off and also will Divine Fury if your stamina goes under what you set it to. Unless you have Divine in your autohealer can always -- infront of the divine() line ' --divine() 'to remove it.

Code: Select all

local conc_time = getticks() 
local conc_delay = 9750

Stam = 240

function main()
local timer=getticks()
while true do
if UO.EnemyID==0 or timer<getticks() then
local tmp=UO.LTargetID
local k=UO.LTargetKind
tmpid=scan()


if tmpid>0 then
UO.LTargetKind=3
UO.LTargetID=tmpid
UO.Macro(27,0)
conc_weap()
wait(30)
divine()
UO.Macro(27,0)
end
end
end
end



function scan()
local item = {}
for i=0, UO.ScanItems(true)-1,1 do
    local nid,typ,kind,contid,xu,yu,zu,stck,col,rep = UO.GetItem(i)
        if kind==1   then    
     if col>2 and col <10 then
       table.insert(item,{id=nid,d=getDist(xu,yu)})
    end
    end
end
table.sort(item,function(a,b) return a.d<b.d end)
if next(item) then
print(item[1].id)
   return item[1].id
end
return 0
end

function conc_weap()
	if getticks() - conc_time > conc_delay then 
		UO.Macro(15,203)
		conc_time = getticks()
	end
end

function divine()
        if UO.Stamina <= Stam then
        UO.Macro(15,205)
        end
end


function getDist(x,y) return math.max(math.abs(UO.CharPosX-x),math.abs(UO.CharPosY-y)) end


main()
Notthemadxcow
Novice Scribe
Posts: 6
Joined: Tue Jul 16, 2013 12:47 pm

Re: Need advice with auto attacking script

Post by Notthemadxcow »

i am not going to include the recall function since that would be easily abused afk, but the script does scan for blue players, and a quick change will allow it to stop or call something else if so:

Code: Select all

function scan()
local item = {}
for i=0, UO.ScanItems(true)-1,1 do
    local nid,typ,kind,contid,xu,yu,zu,stck,col,rep = UO.GetItem(i)
        if kind==1   then    
     if col>2 and col <10 then
       table.insert(item,{id=nid,d=getDist(xu,yu)})
    else
          stop() --change to anything you want to happen if a friendly is found.
     end
    end
end
table.sort(item,function(a,b) return a.d<b.d end)
if next(item) then
print(item[1].id)
   return item[1].id
end
return 0
end
Dramoor
Legendary Scribe
Posts: 450
Joined: Wed Feb 23, 2011 7:37 pm

Re: Need advice with auto attacking script

Post by Dramoor »

SLiMX wrote:Hey all,
I am using an outdated auto attcker/ recall script that does not scan for blue player and only uses 1 runebook etc.

I still stand to it, he said Recall Script. Along with [pm hazardous . That is a lot different from posting a portion of a script probably to upset the staff because you are mad with them. Also, this script attacks anything not blue, wastes a lot of time since areas have mobs that are not worth killing for exp or even gold for that matter.
Notthemadxcow
Novice Scribe
Posts: 6
Joined: Tue Jul 16, 2013 12:47 pm

Re: Need advice with auto attacking script

Post by Notthemadxcow »

What? This script is 100% within the rules, and I removed the questionable section in effort to keep it that way. This has nothing to do with what happened, I simply enjoy helping out when I can. Filtering out specific mob types is possible, but I do not have a compiled list of those, nor do I know what is needed to be attacked. Here is the full script then. I have not added in your functions above, but they should work with this one just the same.

Code: Select all

local filter = {"Dull Copper"}  --Runebook name here
local timer=getticks()
local crune=1

function main()
while true do
if UO.EnemyID==0 or timer<getticks() then
local tmp=UO.LTargetID
local k=UO.LTargetKind
tmpid=scan()

if tmpid>0 then
UO.LTargetKind=3
UO.LTargetID=tmpid
UO.Macro(27,0)
end
end
end
end


function scan()
local item = {}
local book
for i=0, UO.ScanItems(true)-1,1 do
    local nid,typ,kind,contid,xu,yu,zu,stck,col,rep = UO.GetItem(i)
        if kind==1   then    
     if col>2 and col <10 then
       table.insert(item,{id=nid,d=getDist(xu,yu)})
    elseif typ==8901 and contid==UO.BackpackID then
           if string.match(filter, UO.Property(nid) then book=nid end
    else
        if openBook(book) then
           bSuc(crune%runeCount())
           crune=crune+1
        end
    end
    end
end
table.sort(item,function(a,b) return a.d<b.d end)
if next(item) then
print(item[1].id)
   return item[1].id
end
return 0
end

function openBook(bid)
UO.LObjectID=bid
while true do
   if UO.ContSizeX==gump[1].sx and UO.ContSizeY==gump[1].sy then break
   elseif timer<getticks() then UO.Macro(17,0) timer=getticks()+500 end
end
if UO.ContSizeX==gump[1].sx and UO.ContSizeY==gump[1].sy then return true
else return false end
end

function runeCount()
   for i=16, 1, -1 do
      local rx = math.floor((i-1) / 8) * 160 + UO.ContPosX +146
      local ry = ((i-1) % 8) * 15 + UO.ContPosY + 74
      if UO.GetPix(rx,ry) == 524288 then
         for ii=0, 9,1 do
            if UO.GetPix(rx+1, (ry-ii)) ~= 524288 or UO.GetPix(rx, (ry-ii)) ~= 524288 then
               return i
            end
         end
      else
         return i
      end
   end
end


function bSuc(int)
local clickX=UO.ContPosX+140+math.floor(((int-1)+(int%2))/2)*35+(math.floor((int-1) / 8)) * 30
   timer=getticks()+200
   UO.Click(clickX ,UO.ContPosY+200, true, true, true, false)
   while timer>getticks() do
         if UO.ContSizeX==gump[1].sx and UO.ContSizeY==gump[1].sy
            and UO.GetPix(UO.ContPosX+gump[1].cx,UO.ContPosY+gump[1].cy)==col then break
	 elseif timer<getticks() then UO.Click(clickX ,UO.ContPosY+200, true, true, true, false)
            timer=getticks()+200
         end
      end
      timer=getticks()+200
      UO.Click(165+UO.ContPosX+((int-1)%2)*140 ,UO.ContPosY+25, true, true, true,false)
      while true do
            if string.match(UO.SysMsg, "default") then break
            elseif timer<getticks() then UO.Click(165+UO.ContPosX+((int-1)%2)*140 ,UO.ContPosY+25, true, true, true,false)
               timer=getticks()+200
            end
      end
      wait(500)
      if UO.ContSizeX==gump[1].sx and UO.ContSizeY==gump[1].sy then
         UO.Click(UO.ContPosX+UO.ContSizeX/2,UO.ContPosY+UO.ContSizeY/2,false,true,true,false)
      end
   return 
end


function getDist(x,y) return math.max(math.abs(UO.CharPosX-x),math.abs(UO.CharPosY-y)) end

main()
Notthemadxcow
Novice Scribe
Posts: 6
Joined: Tue Jul 16, 2013 12:47 pm

Re: Need advice with auto attacking script

Post by Notthemadxcow »

What? This script is 100% within the rules, and I removed the questionable section in effort to keep it that way. This has nothing to do with what happened, I simply enjoy helping out when I can. Filtering out specific mob types is possible, but I do not have a compiled list of those, nor do I know what is needed to be attacked. Here is the full script then. I have not added in your functions above, but they should work with this one just the same.

Code: Select all

local filter = {"Dull Copper"}  --Runebook name here
local timer=getticks()
local crune=1

function main()
while true do
if UO.EnemyID==0 or timer<getticks() then
local tmp=UO.LTargetID
local k=UO.LTargetKind
tmpid=scan()

if tmpid>0 then
UO.LTargetKind=3
UO.LTargetID=tmpid
UO.Macro(27,0)
end
end
end
end


function scan()
local item = {}
local book
for i=0, UO.ScanItems(true)-1,1 do
    local nid,typ,kind,contid,xu,yu,zu,stck,col,rep = UO.GetItem(i)
        if kind==1   then    
     if col>2 and col <10 then
       table.insert(item,{id=nid,d=getDist(xu,yu)})
    elseif typ==8901 and contid==UO.BackpackID then
           if string.match(filter, UO.Property(nid) then book=nid end
    else
        if openBook(book) then
           bSuc(crune%runeCount())
           crune=crune+1
        end
    end
    end
end
table.sort(item,function(a,b) return a.d<b.d end)
if next(item) then
print(item[1].id)
   return item[1].id
end
return 0
end

function openBook(bid)
UO.LObjectID=bid
while true do
   if UO.ContSizeX==gump[1].sx and UO.ContSizeY==gump[1].sy then break
   elseif timer<getticks() then UO.Macro(17,0) timer=getticks()+500 end
end
if UO.ContSizeX==gump[1].sx and UO.ContSizeY==gump[1].sy then return true
else return false end
end

function runeCount()
   for i=16, 1, -1 do
      local rx = math.floor((i-1) / 8) * 160 + UO.ContPosX +146
      local ry = ((i-1) % 8) * 15 + UO.ContPosY + 74
      if UO.GetPix(rx,ry) == 524288 then
         for ii=0, 9,1 do
            if UO.GetPix(rx+1, (ry-ii)) ~= 524288 or UO.GetPix(rx, (ry-ii)) ~= 524288 then
               return i
            end
         end
      else
         return i
      end
   end
end


function bSuc(int)
local clickX=UO.ContPosX+140+math.floor(((int-1)+(int%2))/2)*35+(math.floor((int-1) / 8)) * 30
   timer=getticks()+200
   UO.Click(clickX ,UO.ContPosY+200, true, true, true, false)
   while timer>getticks() do
         if UO.ContSizeX==gump[1].sx and UO.ContSizeY==gump[1].sy
            and UO.GetPix(UO.ContPosX+gump[1].cx,UO.ContPosY+gump[1].cy)==col then break
	 elseif timer<getticks() then UO.Click(clickX ,UO.ContPosY+200, true, true, true, false)
            timer=getticks()+200
         end
      end
      timer=getticks()+200
      UO.Click(165+UO.ContPosX+((int-1)%2)*140 ,UO.ContPosY+25, true, true, true,false)
      while true do
            if string.match(UO.SysMsg, "default") then break
            elseif timer<getticks() then UO.Click(165+UO.ContPosX+((int-1)%2)*140 ,UO.ContPosY+25, true, true, true,false)
               timer=getticks()+200
            end
      end
      wait(500)
      if UO.ContSizeX==gump[1].sx and UO.ContSizeY==gump[1].sy then
         UO.Click(UO.ContPosX+UO.ContSizeX/2,UO.ContPosY+UO.ContSizeY/2,false,true,true,false)
      end
   return 
end


function getDist(x,y) return math.max(math.abs(UO.CharPosX-x),math.abs(UO.CharPosY-y)) end

main()
User avatar
+Nyx
Administrator
Posts: 2472
Joined: Wed May 18, 2011 1:31 pm
Contact:

Re: Need advice with auto attacking script

Post by +Nyx »

George, your original forum account had its posting privileges revoked for the duration of your jail time since you were posting repeatedly. You made a new account, okay, we let that slide so you could say your bit on the topic of your jailing. But you have since stated you plan to quit, and if that is the case then you need to not be posting here. If you want to participate on UOEX, then you need to be actively working on your jail tasks. If you do that then your forum privileges will be restored at the completion. I won't ask +V to revoke your privileges on this new forum account you made, but if you continue to post then I will have to.
Notthemadxcow
Novice Scribe
Posts: 6
Joined: Tue Jul 16, 2013 12:47 pm

Re: Need advice with auto attacking script

Post by Notthemadxcow »

My apologies, I will not bother any more. Asking a player to perform intentionally slow tasks is a creative punishment, but when it would require two complete days and nights of effort is unrealistic.. I do wish I could stay but that's just too extreme for any casual player, especially for a first offence.

I am unable to delete this or the other account from here, but feel free if needed.
Goodbye.
Locked