ScriptUO
Scripting Resources & Utilities => OEUO => OpenEUO Scripting Chat => Topic started by: J.006 on December 30, 2011, 05:23:37 AM
-
I want to make a automate whirlwindAttack script,so I use these code
SelectPreviousMobile = function() UO.Macro(51,5,'') end
AttackSelected = function() UO.Macro(53,'','') end
But there is error what is if there is no target be selected,the IDE will report "ERR_WRONGPAR"..
so how to slove it? :(
-
I'm not sure in OpenEUO, but I know in Easyuo the Easiest method for attacking something is to
set #ltargetid (id)
Event macro 27 0 ; <- Last Target
-
I want to make a automate whirlwindAttack script,so I use these code
SelectPreviousMobile = function() UO.Macro(51,5,'') end
AttackSelected = function() UO.Macro(53,'','') end
But there is error what is if there is no target be selected,the IDE will report "ERR_WRONGPAR"..
so how to slove it? :(
didnt tested but why you making(51,5,"") you can use (51,5) instead.
i can show you how i registered functions in past with following example:
Use={}
--##########################################
Use.LastObjectID=(
function (tID)
while(UO.TargCurs==false)do
UO.LObjectID=tID
UO.LTargetKind=1
UO.Macro(17,0)
wait(500)
end
end
)
--##########################################
Use.LastTargetID=(
function (tID,tKind)
while(UO.TargCurs==true)do
UO.LTargetID=tID
UO.LTargetKind=tKind
UO.Macro(22,0)
wait(500)
end
end
So it should work properly regular..
Edit:
When i rethink your "Solution" its about the "" in the UO.Macro.
In C# i would define different Constructors for different cases.
PseudoCode example:function x (par1)
{
}
function x (par1,par2)
{
}
function x(par1,par2,par3)
{
}
The transmitting of data from openuo into the Easyuocore using stacks( stringstacks) to convert the functions in openuo\easyuo into delphi.
When you now give that stack 3 parameters for something what only have 2 allowed it wouldnt work and return that exception.
When you give a function 3 Parameters, and 3 are allowed, but they must be later converted into integers, it may fail because its "" also nothing.
I would prefer to only use the Parameters you need and not send more parameters:)
So UO.Macro(21,"","") wouldnt work, but UO.Macro(21)
Crome
-
Thx for reply. :)
But if I use UO.Macro(53),the exception is also the "ERR_WRONGPAR".
So I think it maybe the OPENUO's BUG,beacause if I use the macro in UO,AttackSelectTarget,it will show me the information "There is no current target."
-
Perhaps do a check for a change in target?
Check Target
Select Next mobile
if New Target is Different From last target
Attack Selected Target
-
Thx for reply. :)
But if I use UO.Macro(53),the exception is also the "ERR_WRONGPAR".
So I think it maybe the OPENUO's BUG,beacause if I use the macro in UO,AttackSelectTarget,it will show me the information "There is no current target."
Did you tried it with other UO.Macros?
An d when UO.Macro 53 has different handler in his method you will need a 0 or such to predefine handler. I never used Event macro 53 before, think i handled it with other macros ..
-
Finally,I use this two function to slove the problem :)
SelectPreviousMobile = function() UO.Macro(51,5,'') end
AttackLast = function() UO.Macro(27,0,'') end
Thx everyone in this post.
-
Got a new problem,is there a function to determine the selectedTarget is friendly or monster?
-
Got a new problem,is there a function to determine the selectedTarget is friendly or monster?
Using its id .. find it and then look at the rep value.
-
Got a new problem,is there a function to determine the selectedTarget is friendly or monster?
Using its id .. find it and then look at the rep value.
What is rep value? :)
-
First, I'm sorry if my use of LUA is not Correct. I haven't used it much.
In this Situation, you might be better off doing the Macro for Select Next Hostile. Really No reason to Use the New Targeting System for attacking things by selecting Next Mobile.
Would be Much easier to just build an array for the "types" you wish to attack then use something similar to these subs to locate the nearest monster and attack it.
function finddist(x,y)
dx = math.abs(UO.CharPosX - x)
dy = math.abs(UO.CharPosY - y)
return math.max(dx, dy)
end
function attack(types)
local closest = nil
local fdist = 13
for i = 1,UO.ScanItems(true) do
local id,type,kind,contid,x,y,z,stack,rep,col = UO.GetItem(i)
dist = finddist(x,y)
for c = 1,#types do
if type == types[c] and dist<fdist do
fdist = dist
closest = id
end
end
end
if closest ~= nil do
UO.LTargetID = id
UO.LTargetKind = 1
UO.Macro(27,0)
end
end
-
I had tested the "SelectNearestHostile" before,it had some bugs,because not every monster in the screen is "hostile",but they still can attack you,maybe I 'm in a FreeShards. :)
Anyway,thx for your code,I 'll check them later. :)