Author Topic: [question]AttackSelectTarget  (Read 9666 times)

0 Members and 1 Guest are viewing this topic.

Offline J.006Topic starter

  • Newbie
  • *
  • Posts: 9
  • Activity:
    0%
  • Reputation Power: 1
  • J.006 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
[question]AttackSelectTarget
« on: December 30, 2011, 05:23:37 AM »
0
I want to make a automate whirlwindAttack script,so I use these code
Code: [Select]
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? :(
There is no death;there is the Force.

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: [question]AttackSelectTarget
« Reply #1 on: January 01, 2012, 06:46:36 AM »
0
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
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline Crome969

  • Elite
  • *
  • *
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: [question]AttackSelectTarget
« Reply #2 on: January 01, 2012, 10:21:43 AM »
0
I want to make a automate whirlwindAttack script,so I use these code
Code: [Select]
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:

Code: [Select]
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:
Code: [Select]
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
« Last Edit: January 01, 2012, 10:28:31 AM by Crome969 »

Offline J.006Topic starter

  • Newbie
  • *
  • Posts: 9
  • Activity:
    0%
  • Reputation Power: 1
  • J.006 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [question]AttackSelectTarget
« Reply #3 on: January 03, 2012, 05:32:57 AM »
0
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."
There is no death;there is the Force.

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: [question]AttackSelectTarget
« Reply #4 on: January 03, 2012, 06:23:45 AM »
0
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
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline Crome969

  • Elite
  • *
  • *
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: [question]AttackSelectTarget
« Reply #5 on: January 03, 2012, 07:37:45 AM »
0
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 ..

Offline J.006Topic starter

  • Newbie
  • *
  • Posts: 9
  • Activity:
    0%
  • Reputation Power: 1
  • J.006 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [question]AttackSelectTarget
« Reply #6 on: January 09, 2012, 05:00:05 AM »
0
Finally,I use this two function to slove the problem :)
Code: [Select]
SelectPreviousMobile = function() UO.Macro(51,5,'') end
AttackLast = function() UO.Macro(27,0,'') end
Thx everyone in this post.
There is no death;there is the Force.

Offline J.006Topic starter

  • Newbie
  • *
  • Posts: 9
  • Activity:
    0%
  • Reputation Power: 1
  • J.006 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [question]AttackSelectTarget
« Reply #7 on: January 22, 2012, 04:50:03 AM »
0
Got a new problem,is there a function to determine the selectedTarget is friendly or monster?
There is no death;there is the Force.

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: [question]AttackSelectTarget
« Reply #8 on: January 22, 2012, 06:11:11 AM »
0
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.
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline J.006Topic starter

  • Newbie
  • *
  • Posts: 9
  • Activity:
    0%
  • Reputation Power: 1
  • J.006 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [question]AttackSelectTarget
« Reply #9 on: January 23, 2012, 02:59:04 AM »
0
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? :)
There is no death;there is the Force.

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: [question]AttackSelectTarget
« Reply #10 on: January 23, 2012, 11:54:58 PM »
0
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.

Code: [Select]
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
« Last Edit: January 23, 2012, 11:57:13 PM by manwinc »
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline J.006Topic starter

  • Newbie
  • *
  • Posts: 9
  • Activity:
    0%
  • Reputation Power: 1
  • J.006 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [question]AttackSelectTarget
« Reply #11 on: January 24, 2012, 12:52:22 AM »
0
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. :)
« Last Edit: January 24, 2012, 12:56:19 AM by J.006 »
There is no death;there is the Force.

Tags: