ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: xapcx on September 10, 2009, 04:59:38 PM
-
Im working on an archer that will follow a lead character. when the archer sees a target creature, he will attack it. he will constantly move so that his lead is between him and the creature. this is the begining:
set %timWait ( #SCNT - 16 )
set %findtype PI_DH_FD_ME_TD
set %lastMon 00000
set %disMon 00000
set %corpse YFM
set %Gold POF
set %keys LZF
set %loot POF_LZF_ZFM_MIG
set %prize SWO
set %BOS 00000000
set %findPet 00000000
set %aids ZLF
;=====================================================
set %location 0 ; 0 = everything, 1 = ice, 2 = doom,
;=====================================================
if %location = 0
{
set %creaturetype TH_ME_PI_DH_FD_ME_TD_WD_R_EB
}
if %location = 1
{
set %creaturetype TH
}
if %location = 2
{
set %creaturetype ????
}
;=====================================================
FINDITEM %aids C_ , #BACKPACKID
IF #FINDKIND = -1
{
DISPLAY you need aids. $ HALTED!
HALT
}
set %bandage #findid
gosub setLead
;================== main loop =========================
loop:
gosub healthcheck
wait 1
gosub movOption
wait 1
goto loop
;======================================================
;================== health check ======================
sub healthcheck
if %timWait < ( #SCNT - 4 )
{
if ( #HITS + 10 ) < #MAXHITS || C in #CHARSTATUS
event sysmessage injured
set #lobjectid %bandage
event macro 17 0
target 2s
event macro 23 0
if #MAXSTAM < 115
{
set %timWait ( #SCNT + 2 )
}
set %timWait ( #SCNT + 1 )
}
}
return
;======================================================
sub movOption
gosub findMonster
return
;======================================================
sub findMonster
findItem %creaturetype G_8
if #findkind <> -1
{
if #finddist < 2
{
set #ltargetid #findid
set %target #findid
set %monX #findx
set %monY #findY
gosub findLead2
}
goto fm
}
gosub findLead1
fm:
return
sub findLead1
findItem %lead G_17
if #findkind <> -1
{
if #finddist <= 2
{
set %movex ( #findx )
set %movey ( #findy )
gosub moveNow1
}
}
return
sub findLead2
findItem %lead G_17
if #findkind <> -1
{
if #findx > %monX
{
if #findy > %monY
{
set %movex ( #findx + 1 )
set %movey ( #findy + 1 )
}
if #findy < %monY
{
set %movex ( #findx + 1 )
set %movey ( #findy - 1 )
}
if #findy = %monY
{
set %movex ( #findx + 1 )
set %movey ( #findy )
}
}
if #findx < %monX
{
if #findy > %monY
{
set %movex ( #findx - 1 )
set %movey ( #findy + 1 )
}
if #findy < %monY
{
set %movex ( #findx - 1 )
set %movey ( #findy - 1 )
}
if #findy = %monY
{
set %movex ( #findx - 1 )
set %movey ( #findy )
}
}
if #findx = %monX
{
if #findy > %monY
{
set %movex ( #findx )
set %movey ( #findy + 1 )
}
if #findy < %monY
{
set %movex ( #findx )
set %movey ( #findy - 1 )
}
}
gosub moveNow2
gosub attack
}
return
;================== move now ==========================================
sub moveNow1
set %x %movex
set %y %movey
set %z %movez
moving1:
event pathfind %x %y
if #CHARPOSX < ( %x - 2 ) || #CHARPOSX > ( %x + 2 ) || #CHARPOSY < ( %y - 2) || #CHARPOSY > ( %y + 2)
{
wait 10
goto moving1
}
return
sub moveNow2
set %x %movex
set %y %movey
set %z %movez
moving2:
event pathfind %x %y
if #CHARPOSX <> %x || #CHARPOSY <> %y
{
wait 10
goto moving2
}
return
;========================= attack ======================================
sub attack
event macro 22 0
wait 1
event macro 27 0
event sysmessage attack!
wait 10
return
;========================================================================
sub setLead
display ok please target your Lead.
set #targcurs 1
target 5s
watLeadLup:
if #targcurs = 1
{
goto watLeadLup
wait 5
}
finditem #ltargetid
set %lead #ltargetid
return
-
My advice is look for Cerveza's Gbot. Do a search for it on here and use globals... You'll like it WAY more, and it lets you control the character DIRECTLY from the script on your main screen. You set the "second" char to follow, then you can move him with buttons on a menu to a safe location. Might give you some good ideas to have a look. :)
-
I was trying to make the script so that i did not command the archer at all. I am hoping he always moves so that the monster is away and the lead character is between the archer and the monster:
A L M or M L A or M or A
L
L
A M
does that diagram make sense?
I do want to look into and understand the Gbot because that is what I want the third account doing.
-
You can make the Gbot do anything you like. It doesn't have to be controlled by you, but it's very easy to add that in if you'd like to have it also. But having it follow is the same thing basically, and you can position yourself how you like... Try out the Gbot when EUO is working again, you'll see what I mean.