FD help

Macro requests from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

bugcoder
orc pawn
orc pawn
Posts: 26
Joined: Mon Nov 04, 2002 1:11 am

FD help

Post by bugcoder » Wed Dec 11, 2002 9:04 pm

I am modifying hunting.mac to do some tailoring item farming. I am doing this with a monk. I was wondering if some kind soul would help me set up a fd code that check for success when running from a big bad mob. So the requirements

1) determine who is pissed at me and fd when it's a big bad mob
2) check if fd worked. if not run like hell.
3) fd again when it pops

repeat as necessary.

Thanks in advance.
I am doing this in EK. Once it works I'll post it for comments.

Bugcoder

ashplayah
decaying skeleton
decaying skeleton
Posts: 8
Joined: Tue Dec 10, 2002 5:55 pm

Post by ashplayah » Thu Dec 12, 2002 1:10 pm

Allow me to suggest that you take this as a learning opportunity and come up with something. We are all much happier to assist you in debugging code that writting it for you.

Much luck,

Ashplayah

Hint: Use an event to check if you fail your FD (you have to assume success)
#event FailedFD "You fall to the ground"
Sub Event_FailedFD
| Stand up and start running again
/return

Vendor001
Cheezily Banned
Cheezily Banned
Posts: 78
Joined: Wed Nov 13, 2002 1:37 pm

Coding at work...do try this at home

Post by Vendor001 » Thu Dec 12, 2002 3:22 pm

Here's a first shot at it. Haven't tried it(may not at all), but let me know if you have any problems.

Thanks goes to hunter.mac author for the obstacle handling code.

Code: Select all

| Macro: ImprovedFD.mac
| Purpose: Perform an "Improved FD"(FD wrapped with logic to re-do it when it
|   fails) if the target level is too high.
| Exit Condition: Target is 80 units away or we zone.
|
#include routines.mac

| Events
#event HitsYou "YOU for"
#event FDFail "You have fallen to"
#event Zoned "LOADING PLEASE WA"

| Variables
#define FDFlag v10
#define MyXLoc v58
#define MyYLoc v59
#define TimeToExit v66

Sub Main
  /zapvars
  /if n $target(level)>=$char(level) /call ClearAggro
/return

| Subroutines--------------------------------------------------------

|Subroutine: ClearAggro
|Purpose: FD, or DIE trying.  Will run on FD failure.
|
Sub ClearAggro
:ClearAggro_ReFeign
  /if $char(ability,"Feign Death")>0 /call DoFD
:ClearAggro_Continue
  /delay 3
  /doevents
  /if n FDFlag == 0 /call CheckObstacle
  /if n $target(distance) < 80 /varset TimeToExit 1
  /if n TimeToExit != 1 {
    /if n FDFlag == 0 {
      /goto :ClearAggro_ReFeign
    } else /goto :ClearAggro_Continue
  }
/return

|Subroutine: DoFD
|Purpose: To FD.
|
Sub DoFD
  /attack off
  /delay 3
  /doability "Feign Death"
  /varset FDFlag 1
/return

|Subroutine: RunAway
|Purpose: Clear FD status and run "away"
|
Sub RunAway
  /varset FDFlag 0
  /stand
  /face fast away
  /AutoRun 1
/return

|Subroutine: CheckObstacle
|Purpose: Make sure we aren't stuck on a rock/tree/guard
|Note: "Borrowed" from hunter.mac
|
Sub CheckObstacle
  | Check Obstacle code from hunter.mac
  /varset MyXLoc $char(x)
  /varset MyYLoc $char(y)
  | Wait a then check loc again if we are on same spot call the obstacle routine to try and get around it
  /delay 1
  /if n $MyXLoc==$char(x) /if $MyYLoc==$char(y) /call Obstacle
/return

|Subroutine: Obstacle
|Purpose: Try to get around object.
|Note: "Borrowed" from hunter.mac
|
Sub Obstacle
   | We appear to be stuck so try and backup and strafe sideways
   /sendkey up up
   /sendkey down down
   /delay 2
   /doevents
   /sendkey up down
   /sendkey down ctrl
   /if n $rand(99)>49 /sendkey down right
     else /sendkey down left
   /delay 3
   /sendkey up right
   /sendkey up left
   /sendkey up ctrl
   /sendkey down up
/return

| Events-------------------------------------------------------------

Sub Event_FDFail
  /call RunAway
/return

Sub Event_HitsYou
  /call RunAway
/return

Sub Event_Zoned
  /varset TimeToExit 1
/return

bugcoder
orc pawn
orc pawn
Posts: 26
Joined: Mon Nov 04, 2002 1:11 am

Thank you

Post by bugcoder » Thu Dec 12, 2002 3:40 pm

Thank you both. I am a bit new at this and haven't figure out how to check events yet. I check how the code work out this weekend Vendor001. Thanks again.

Bugcoder

I R monk
orc pawn
orc pawn
Posts: 28
Joined: Tue Dec 10, 2002 4:29 pm

Post by I R monk » Thu Dec 12, 2002 4:57 pm

Another quick example of how to do what your wanting.
this is not intended to work as is, its just an example to help you make what you need.


#define jumped v10
#define Attacker v11
#define OldTarget v12
#define AttackerLevel v13
#define FdFail v14

#event Hit "You for"
#event Fail "You have fallen to"

/zapvars
/doevents
/if n $jumped==1 {
/varset $OldTarget $target(id)
/target $Attacker
/varset $AttackerLevel $target(level)
/target $OldTarget
}
/if n $AttackerLevel=<$char(level) {
/call FeignCheck
}
/return

sub FeignCheck
:fdtry
/if $char(ability,"Feign Death")>0 {
/call Feign
} else {
/target $Attacker
/face fast away
/sendkey down up
}
/if n $target(distance)=>80 {
/sendkey up up
}
/goto :fdtry
/return

sub Feign
/doability "Feign Death"
/doevents
/if n $FdFail==1{
/sit off
/call FeignCheck
}
:SafeYet
/delay 5
/varset Jumped 0
/doevents
/if n $jumped==0 /if n $target(distance)>50 {
/sit off
} else {
/goto SafeYet
}
/varset Jumped 0
/doevents
/if n $jumped==1 {
/call FeignCheck
}
/return

sub Event_HitsYou
/varset Jumped 1
/varset v90 "$left($calc($instr("YOU","$p0")-1),"$p0")"
/varset v91 $strlen("$v90")
:WalkString
/if "$mid($v91,1,"$v90")"==" " {
/varset v92 $v91
/goto :DoneWalkString
}
/varsub v91 1
/delay 0
/goto :WalkString
:DoneWalkString
/varset Attacker "$left($v92,"$v90")"
/return

sub Event_fail
/varset FdFail 1
/return

bugcoder
orc pawn
orc pawn
Posts: 26
Joined: Mon Nov 04, 2002 1:11 am

thank you

Post by bugcoder » Thu Dec 12, 2002 6:54 pm

I R monk, thank you. I will decode your code as well. Having sample code to start with is a wonderful thing :D .